camel-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "James Strachan" <james.strac...@gmail.com>
Subject Re: Unit Test - Non-Deterministic Results
Date Mon, 16 Jun 2008 16:32:41 GMT
2008/6/16 James Strachan <james.strachan@gmail.com>:
> I wonder if using an AtomicInteger inside your ExceptionThrower might help?

BTW I mean change the type of 'i' from int to AtomicInteger then
change the code to something like this...

				switch (i.incrementAndGet()) {
				case 1:
					System.out.println("throwing null");
					throw new NullPointerException();
				case 2:
					System.out.println("throwing exception");
					throw new Exception();
				default:
					System.out.println("throwing nothing");
					; // nop
				}



>
> 2008/6/16 jmfj <j@j3m.org>:
>>
>> The results of this unit test are not the same everytime - it should (right?)
>> -
>>
>> ** FIRST RUN (maven)
>> -------------------------------------------------------------------------------
>> Test set: TestSuite
>> -------------------------------------------------------------------------------
>> Tests run: 2, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 20.743 sec
>> <<< FAILURE!
>>
>> testExceptionHandlerOne(net.quantlet.box.mediation.CamelTest)  Time elapsed:
>> 20.079 sec  <<< FAILURE!
>> java.lang.AssertionError: mock:null-pointer Received message count.
>> Expected: <1> but was: <0>
>>        at org.apache.camel.component.mock.MockEndpoint.fail(MockEndpoint.java:658)
>>        at
>> org.apache.camel.component.mock.MockEndpoint.assertEquals(MockEndpoint.java:640)
>>        at
>> org.apache.camel.component.mock.MockEndpoint.assertIsSatisfied(MockEndpoint.java:217)
>>        at
>> org.apache.camel.component.mock.MockEndpoint.assertIsSatisfied(MockEndpoint.java:193)
>>        at
>> net.quantlet.box.mediation.CamelTest.testExceptionHandlerOne(CamelTest.java:82)
>>
>> TestExceptionHandlerOne was successful
>>
>> ** SECOND RUN (eclipse)
>>
>> java.lang.AssertionError: mock:null-pointer Received message count.
>> Expected: <1> but was: <0>
>>        at org.apache.camel.component.mock.MockEndpoint.fail(MockEndpoint.java:658)
>>        at
>> org.apache.camel.component.mock.MockEndpoint.assertEquals(MockEndpoint.java:640)
>>        at
>> org.apache.camel.component.mock.MockEndpoint.assertIsSatisfied(MockEndpoint.java:217)
>>        at
>> org.apache.camel.component.mock.MockEndpoint.assertIsSatisfied(MockEndpoint.java:193)
>>        at
>> net.quantlet.box.mediation.CamelTest.testExceptionHandlerTwo(CamelTest.java:123)
>>        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>        at
>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>>        at
>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>>        at java.lang.reflect.Method.invoke(Method.java:585)
>>        at org.testng.internal.MethodHelper.invokeMethod(MethodHelper.java:580)
>>        at org.testng.internal.Invoker.invokeMethod(Invoker.java:478)
>>        at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:617)
>>        at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:885)
>>        at
>> org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:126)
>>        at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:110)
>>        at org.testng.TestRunner.runWorkers(TestRunner.java:712)
>>        at org.testng.TestRunner.privateRun(TestRunner.java:582)
>>        at org.testng.TestRunner.run(TestRunner.java:477)
>>        at org.testng.SuiteRunner.runTest(SuiteRunner.java:324)
>>        at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:319)
>>        at org.testng.SuiteRunner.privateRun(SuiteRunner.java:292)
>>        at org.testng.SuiteRunner.run(SuiteRunner.java:198)
>>        at org.testng.TestNG.createAndRunSuiteRunners(TestNG.java:823)
>>        at org.testng.TestNG.runSuitesLocally(TestNG.java:790)
>>        at org.testng.TestNG.run(TestNG.java:708)
>>        at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:73)
>>        at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:124)
>>
>> TestExceptionHandlerOne was successful
>>
>> ** THIRD RUN (eclipse again)
>>
>> java.lang.AssertionError: mock:null-pointer Received message count.
>> Expected: <1> but was: <0>
>>        at org.apache.camel.component.mock.MockEndpoint.fail(MockEndpoint.java:658)
>>        at
>> org.apache.camel.component.mock.MockEndpoint.assertEquals(MockEndpoint.java:640)
>>        at
>> org.apache.camel.component.mock.MockEndpoint.assertIsSatisfied(MockEndpoint.java:217)
>>        at
>> org.apache.camel.component.mock.MockEndpoint.assertIsSatisfied(MockEndpoint.java:193)
>>        at
>> net.quantlet.box.mediation.CamelTest.testExceptionHandlerTwo(CamelTest.java:123)
>>        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>        at
>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>>        at
>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>>        at java.lang.reflect.Method.invoke(Method.java:585)
>>        at org.testng.internal.MethodHelper.invokeMethod(MethodHelper.java:580)
>>        at org.testng.internal.Invoker.invokeMethod(Invoker.java:478)
>>        at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:617)
>>        at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:885)
>>        at
>> org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:126)
>>        at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:110)
>>        at org.testng.TestRunner.runWorkers(TestRunner.java:712)
>>        at org.testng.TestRunner.privateRun(TestRunner.java:582)
>>        at org.testng.TestRunner.run(TestRunner.java:477)
>>        at org.testng.SuiteRunner.runTest(SuiteRunner.java:324)
>>        at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:319)
>>        at org.testng.SuiteRunner.privateRun(SuiteRunner.java:292)
>>        at org.testng.SuiteRunner.run(SuiteRunner.java:198)
>>        at org.testng.TestNG.createAndRunSuiteRunners(TestNG.java:823)
>>        at org.testng.TestNG.runSuitesLocally(TestNG.java:790)
>>        at org.testng.TestNG.run(TestNG.java:708)
>>        at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:73)
>>        at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:124)
>>
>> and
>>
>> java.lang.AssertionError: mock:null-pointer Received message count.
>> Expected: <1> but was: <0>
>>        at org.apache.camel.component.mock.MockEndpoint.fail(MockEndpoint.java:658)
>>        at
>> org.apache.camel.component.mock.MockEndpoint.assertEquals(MockEndpoint.java:640)
>>        at
>> org.apache.camel.component.mock.MockEndpoint.assertIsSatisfied(MockEndpoint.java:217)
>>        at
>> org.apache.camel.component.mock.MockEndpoint.assertIsSatisfied(MockEndpoint.java:193)
>>        at
>> net.quantlet.box.mediation.CamelTest.testExceptionHandlerOne(CamelTest.java:82)
>>        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>        at
>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>>        at
>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>>        at java.lang.reflect.Method.invoke(Method.java:585)
>>        at org.testng.internal.MethodHelper.invokeMethod(MethodHelper.java:580)
>>        at org.testng.internal.Invoker.invokeMethod(Invoker.java:478)
>>        at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:617)
>>        at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:885)
>>        at
>> org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:126)
>>        at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:110)
>>        at org.testng.TestRunner.runWorkers(TestRunner.java:712)
>>        at org.testng.TestRunner.privateRun(TestRunner.java:582)
>>        at org.testng.TestRunner.run(TestRunner.java:477)
>>        at org.testng.SuiteRunner.runTest(SuiteRunner.java:324)
>>        at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:319)
>>        at org.testng.SuiteRunner.privateRun(SuiteRunner.java:292)
>>        at org.testng.SuiteRunner.run(SuiteRunner.java:198)
>>        at org.testng.TestNG.createAndRunSuiteRunners(TestNG.java:823)
>>        at org.testng.TestNG.runSuitesLocally(TestNG.java:790)
>>        at org.testng.TestNG.run(TestNG.java:708)
>>        at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:73)
>>        at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:124)
>>
>> I might be missing something (hope not) - anyways, here is the entire unit
>> test (TestNG) for your enjoyment...
>>
>>  http://www.nabble.com/file/p17867803/CamelTest.java CamelTest.java
>>
>>
>> --
>> View this message in context: http://www.nabble.com/Unit-Test---Non-Deterministic-Results-tp17867803s22882p17867803.html
>> Sent from the Camel - Development mailing list archive at Nabble.com.
>>
>>
>
>
>
> --
> James
> -------
> http://macstrac.blogspot.com/
>
> Open Source Integration
> http://open.iona.com
>



-- 
James
-------
http://macstrac.blogspot.com/

Open Source Integration
http://open.iona.com

Mime
View raw message