Best unofficial Apache Server developers community |
| |||||
| Jul 14, 2010 | |||||
|
Martin Waite |
|
||||
| Tags: | |||||
Similar Threads
Created: (CLK-708) Configurable loop count in performance unit test
Configurable loop count in performance unit test
Created: (HDFS-1304) There is no unit test for HftpFileSystem.open(..)
There is no unit test for HftpFileSystem.open(..)
Re: Mapper Reducer : Unit Test and mocking with static variables
FYI I am on Hadoop 0.20.2, JUnit 4 Varene Olivier a écrit : Hello to all, first of all many thanks for this great piece of software you are all contributing to :) I am actually creating a program in Hadoop MapReduce, but I intend to massively use JUnit Tests to validate my code. To test a Mapper, I mock a Mapper.Context object and run the Mapper.map function with it, but inside my Mapper.map function, I am using Counters to maintain internal statistics. The update of those counters make the test fails with a null pointer (JavaNullPointerException). There is an issue "Counters" of variable visibility from my test ... Do you have any idea how to mock/validate/overcome this issue ? Thanks a lots Best Regards Olivier Varene : Code : -------- private static enum Counters {NBLINES}; private static IntWritable one = new IntWritable(1); private static LongWritable oneL = new LongWritable(1); // Mapper /** * outputs 1 for each line encountered */ public static class LCMapper extends Mapper<LongWritable, Text, IntWritable, LongWritable> { private final static IntWritable one = new IntWritable(1); private final static LongWritable oneL = new LongWritable(1); /** * for each line encountered outputs 1 for the key 1 */ public void map(LongWritable p_key, Text p_inputs, Context p_context) throws IOException, InterruptedException { p_context.getCounter(Counters.NBLINES).increment(1); p_context.write(one,oneL); } // end map } // end Mapper : Test : -------- @Test public void testLCMapper() throws IOException, InterruptedException { LCMapper mapper = new LCMapper(); Text value = new Text("ligneA\nlignB\n"); // mock the map job execution context Context context = mock(Context.class); try { mapper.map(null, value, context); } catch (NullPointerException e) { // exception raised by context.getCounter(...) null pointer // HOW TO MOCK ??? // Counter is a static enum from the englobing class ... // issue with variable visibility (from map function) in this test } // verify that the Mapper issued (one,oneL) pair verify(context).write(one,oneL); } // end testLCMapper
Updated: (HIVE-181) Restore UDFTestLength unit test for UDFs
[
https://issues.apache.org/jira/browse...nels:all-tabpanel
]
Carl Steinbach updated HIVE-181:
Test Failure:mixin nodetype mix:simpleVersionable is missing
Hi, $subject occurs in simple version test.This test failure says repository does not support versioning But I have set the following to true OPTION_VERSIONING_SUPPORTED = true OPTION_SIMPLE_VERSIONING_SUPPORTED = true It will be really great if anyone can help me to solve this problem Regards /subash
Created: (MRM-1388) Test failure in ShowArtifactActionTest for certain locales
Test failure in ShowArtifactActionTest for certain locales
Resolved: (DIRSERVER-1456) build error: JUnit test failure on SchemaLdifExtractorTest
[
https://issues.apache.org/jira/browse...nels:all-tabpanel
]
Pierre-Arnaud Marcelot resolved DIRSERVER-1456.
Resolved: (DERBY-4132) intermittent test failure: extra lock in store/updatelocksJDBC30
[
https://issues.apache.org/jira/browse...nels:all-tabpanel
]
Mike Matrigali resolved DERBY-4132.
Simple Unit testing.
Hello, I have read the tutorial http://felix.apache.org/site/apache-f...sgi-tutorial.html but I didn't find it simple at all. Currently when I run a unit test, in my IDE I can select a single unit test, a test case or a package and I select Run -> Tests. If I want to debug my test, I select Debug -> Tests. That's what I call simple. When I have worked with frameworks in the past, I had to add a few things in the setUp() and tearDown() or extend a custom abstract TestCase which did this for me, but after that the unit test ran normally, in my IDE and in maven. Has anyone done this with OSGi/iPOJO components? Regards, Peter.
Unit tests + injection
Did a bit of unit test hacking while on the plane last night. Just
checked in some pretty good early results. We are still bound by JUnit
3 lifecycle simplicity and have to use static singletons, still I was
able to build a little framework for dependency injection into the
test cases, with access to the new DI Cayenne stack. Underneath that
is an old CayenneResources singleton that loads DB connection,
generates the schema, etc...
Still the unit test "frontend" is now drastically different (see e.g.
DataContextEJBQLConditionsTest, one of the few tests that I switched).
Tests extending DICase (or its subclass - ServerCase) can use @Inject
annotations to get access to the interesting parts of the stack being
tested (in 90% of cases that I converted so far this would be
ObjectContext and DBHelper) in a clean manner that does not obfuscate
the test purpose. I also replaced Spring/XML data sets with DBHelper.
So a typical DB-aware test case may look like
DataContextEJBQLConditionsTest:
@UseServerRuntime(ServerCase.TESTMAP_PROJECT)
public class DataContextEJBQLConditionsTest extends ServerCase {
@Inject
protected ObjectContext context;
@Inject
protected DBHelper dbHelper;
protected TableHelper tArtist;
@Override
protected void setUpAfterInjection() throws Exception {
dbHelper.deleteAll("PAINTING_INFO");
...
tArtist = new TableHelper(dbHelper, "ARTIST");
tArtist.setColumns("ARTIST_ID", "ARTIST_NAME");
...
}
protected void createDataSetXYZ() throws Exception {
tArtist.insert(33001, "B");
tArtist.insert(33002, "A");
tArtist.insert(33003, "D");
tPainting.insert(33009, 33001, "X", 5000);
tPainting.insert(33010, 33001, "Y", 5000);
tPainting.insert(33011, 33002, "Z", 5000);
}
public void testSomething() throws Exception {
createDataSetXYZ();
// normal unit test goes here
...
}
It is much cleaner than what we had before at the unit test level at
the expense of a few trivial DI providers in the DI backend.
In general I feel like the Cayenne DI container is a cool little piece
of technology that will take us pretty far in many areas of the
framework. It is still only 36K in size and has simplicity as its main
design paradigm. The only major feature that it is missing compared to
the other guys is method interception, and we can add that down the
road if we feel compelled to have it for Cayenne uses.
Cheers,
Andrus
Status about hadoop unit testing.
Hi guys, I am running hadoop unit testing and trying to fix some failures for a while. Combining two great projects excites me a lot. Here is my current status: Env: Harmony 6 (requires by hadoop) + linux 32 platform Using: run-test-core Whole test cases: 757 Failures: 8 Errors: 25 To get this result, some code need to be changed in hadoop-common [0], some jiras should be commited [1] and some modules I borrowed from RI [2]. [0] a. UserGroupInformation.java should be changed, because hadoop hard coding the its login module, using com.sun.security things. b. reduce the failure trying times from 45 to 2. Because junit testcase will be timeout if we are trying 45 times. (ri also failed on this) [1] a. HARMONY-6529 </jira/browse/HARMONY-6529>. hadoop is required jdk1.6, patch available. b. HARMONY-6561 </jira/browse/HARMONY-6561> Fixed c. HARMONY-6569 </jira/browse/HARMONY-6569> Fixed d. HARMONY-6571 </jira/browse/HARMONY-6571> JNDI things e. HARMONY-6575 </jira/browse/HARMONY-6575> It may be a drlvm, in my todo list. f. HARMONY-6580 </jira/browse/HARMONY-6580>, HARMONY-6605</jira/browse/HARMONY-6605> Fixed g. HARMONY-6587 </jira/browse/HARMONY-6587> Fixed h. HARMONY-6604 </jira/browse/HARMONY-6604> Behavior different between ri and harmony [2] a. add tools.jar, which in the harmony jdk/lib, in the bootclasspath.properties. Ant try to find the com.sun.tools.javac.Main to determine whether JAVA_HOME is point to a jre or a jdk. This jar is not from ri, but we may need to change our layout a little bit. b. add ecj.jar to the $ANT_HOME/lib or add it in the bootclasspath.properties. c. javax.annotation.processing, javax.lang.model, javax.tools, these package borrow from RI, which is missing in harmony java6. d. sun.security.krb5, this package borrow from RI. Do we have couterpart in harmony? I have not found one. e. sun.misc.HexDumpEncoder, this borrow from RI. Missing in harmony java6. f. sun.reflect.ReflectionFactory, this borrow from RI. Missing in harmony java6. [3] g. sun/misc/Unsafe.defineClass(Ljava/lang/String;[BIILjava/lang/ClassLoader;Ljava/security/ProtectionDomain;)Ljava/lang/Class; This method is not defined in our Unsafe. [3] h. javadoc and doclet package is borrowed from RI. Missing in harmony java6. Is is one of our GSoC now? [3] f and g in [2] is raised from a popular project: mockito. Mockito is using another project: objenesis. Now g is at the top of my todo list.
unit testing jaxrs services
Does CXF provide a mechanism, such as an embedded server, for easily unit-testing jaxrs services? I didn't seen anything in the documentation. Something similar to what RESTEasy provides: http://docs.jboss.org/resteasy/docs/1...ml_single/index.h tml#RESTEasy_Embedded_Container Jason
New joiner's question - mocking for unit tests
Hello all I have quick question: Is there mocking framework in project? Writing dummies for unit tests is quite useless and boring thing. Plus it¹s filling codebase with ³noise². I have some experience with: JMock - http://www.jmock.org/ EasyMock - http://easymock.org/ Mockito (my favourite) - http://mockito.org/ First one hasn¹t updated since Feb 2009, so I think it¹s not a good idea to look there. Two others are great: both have dynamic proxying for interfaces and classes.
Updated: (HIVE-209) Enable assertions for unit tests
[
https://issues.apache.org/jira/browse...nels:all-tabpanel
]
Carl Steinbach updated HIVE-209:
Unit Testing Ibator generated code against hsqldb
hello, I am new to Java and developing a Flex 4, blazeds, spring, ibatis, firebird project for technology absorption purpose so I dont have any constraints. We would like to laydown a ideal way to develop real life projects in future. I have used ibator to generate domain objects, sql maps and spring type daos. I am referring "iBatis in action" book in this process and it recommends unit testing against hsqldb. It explains how to test sqlmaps and daos but the examples are for hand written domains and daos. My generated DAOs are different and I need some help regarding how to test Spring Type DAOs against Hsqldb. Please guide me in this regard. Any urls for tutorials/example code/book etc. etc. will be a great help. BTW Congratulations for New "HOME" and wish you prosperity with it. Thanks and best regards Raja
Hanging forever on database bootup during unit testing
I have a bunch of unit tests that I run as a suite. The first test that tries to boot up the Derby database hangs, with the CPU spiked at 100%. When I stop the process, here is where it is stuck, repeatedly (see stack trace below). When I run the same test by itself, it's slow to boot, but it doesn't hang. The database is small, it actually has no rows in it. Any ideas? Should I be reverting back to 10.4? I seem to be having a lot of issues with 10.5 and booting/shutdown. This is a serious problem; if it happens in production it will be a Very Big Deal. Thanks, David Thread [main] (Suspended) ZipFile$1(InflaterInputStream).<init>(InputStream, Inflater, int) line: not available ZipFile$1.<init>(ZipFile, InputStream, Inflater, int, ZipFile$ZipFileInputStream) line: not available JarFile(ZipFile).getInputStream(String) line: not available JarFile(ZipFile).getInputStream(ZipEntry) line: not available JarFile.getManifestFromReference() line: not available JarFile.getManifest() line: not available URLClassPath$JarLoader$2.getManifest() line: not available Launcher$AppClassLoader(URLClassLoader).defineClass(String, Resource) line: not available URLClassLoader.access$000(URLClassLoader, String, Resource) line: not available URLClassLoader$1.run() line: not available AccessController.doPrivileged(PrivilegedExceptionAction<T>, AccessControlContext) line: not available [native method] Launcher$AppClassLoader(URLClassLoader).findClass(String) line: not available Launcher$AppClassLoader(ClassLoader).loadClass(String, boolean) line: not available Launcher$AppClassLoader.loadClass(String, boolean) line: not available Launcher$AppClassLoader(ClassLoader).loadClass(String) line: not available Launcher$AppClassLoader(ClassLoader).loadClassInternal(String) line: not available Class<T>.forName0(String, boolean, ClassLoader) line: not available [native method] Class<T>.forName(String) line: not available FileMonitor(BaseMonitor).getImplementations(Properties, boolean) line: not available FileMonitor(BaseMonitor).getDefaultImplementations() line: not available FileMonitor(BaseMonitor).runWithState(Properties, PrintStream) line: not available FileMonitor.<init>(Properties, PrintStream) line: not available Monitor.startMonitor(Properties, PrintStream) line: not available JDBCBoot.boot(String, PrintStream) line: not available EmbeddedDriver.boot() line: not available EmbeddedDriver.<clinit>() line: not available AutoloadedDriver.getDriverModule() line: not available AutoloadedDriver.connect(String, Properties) line: not available DriverManager.getConnection(String, Properties, ClassLoader) line: not available DriverManager.getConnection(String, String, String) line: not available http://www.linkedin.com/in/davidvc http://davidvancouvering.blogspot.com http://twitter.com/dcouvering
Resolved: (SCXML-119) Support automated unit testing of benchmark models
[
https://issues.apache.org/jira/browse...nels:all-tabpanel
]
Jacob Beard resolved SCXML-119.
Created: (MRM-1392) Separate webdav unit tests and integration tests
Separate webdav unit tests and integration tests | |||||
(86 lines) Jul 14, 2010 12:38
(197 lines) Aug 3, 2010 10:46
(301 lines) Aug 3, 2010 11:52
(335 lines) Aug 3, 2010 12:19
(60 lines) Aug 4, 2010 03:32