camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christian Schneider <ch...@die-schneider.net>
Subject Re: My camel-CXF tests fails, if they run together
Date Mon, 05 Jul 2010 21:02:11 GMT
  Hi Christian,

you are doing some setup in your @Before method. This method will be 
called before each test method. Is this what you intend?
If you only want the code to be executed once you should try @BeforeClass.

Greetings

Christian


Am 05.07.2010 16:39, schrieb Christian Müller:
> After some additional tests it looks like, that each second test fails
> because of this. If I run all tests, number one succeed, number two fails,
> number three succeed and number four fails. If I comment number number two,
> number three fails and number four succeed. If I comment number two and
> three, number four succeed. Very strange...
>
> Regards,
> Christian
>
> On Mon, Jul 5, 2010 at 4:21 PM, Christian Müller<
> christian.mueller@gmail.com>  wrote:
>
>> Hello list,
>>
>> I using Apache Camel 2.2.0-fuse-01-00 and I have trouble to run my four
>> unit tests. If I run each test separate (annotate the other tests with
>> @Ignore or run only one test method in my IDE) all tests succeed. But if I
>> run all tests together (one test after the others) with Maven or in my IDE,
>> I receive a java.net.SocketTimeoutException. Unfortunately I have no idea,
>> where the side effect is.
>>
>> My test looks as following:
>> public class IncommingRouteTest extends CamelSpringTestSupport {
>>
>>      private Person client;
>>
>>      @EndpointInject(uri = "mock:result")
>>      private MockEndpoint queueEndpoint;
>>
>>      @EndpointInject(uri = "mock:error")
>>      private MockEndpoint errorEndpoint;
>>
>>      @Before
>>      public void setUp() throws Exception {
>>          disableJMX();
>>
>>          super.setUp();
>>
>>          URL wsdlURL =
>> IncommingRouteTest.class.getClassLoader().getResource("META-INF/wlsi/person-non-wrapper.wsdl");
>>          PersonService ss = new PersonService(wsdlURL, new QName("
>> http://camel.apache.org/non-wrapper", "PersonService"));
>>          client = ss.getSoap();
>>      }
>>
>>      @Test
>>      public void process() throws Exception {
>>          queueEndpoint.expectedMessageCount(1);
>>
>> queueEndpoint.expectedBodiesReceived("com.awl.wlsi.example.eai.service.types.GetPerson[personId='1']");
>>          errorEndpoint.expectedMessageCount(0);
>>
>>          GetPerson request = new GetPerson();
>>          request.setPersonId("1");
>>          GetPersonResponse response = client.getPerson(request);
>>
>>          assertEquals("1", response.getPersonId());
>>          assertEquals("Christian Mueller", response.getName());
>>          assertEquals("123", response.getSsn());
>>
>>          queueEndpoint.assertIsSatisfied();
>>          errorEndpoint.assertIsSatisfied();
>>      }
>>
>>      @Test
>>      public void processIrrecoverableExceptionForUnknowPerson() throws
>> Exception {
>>          queueEndpoint.expectedMessageCount(1);
>>
>> queueEndpoint.expectedBodiesReceived("com.awl.wlsi.example.eai.service.types.GetPerson[personId='?']");
>>          errorEndpoint.expectedMessageCount(0);
>>
>>          GetPerson request = new GetPerson();
>>          request.setPersonId("?");
>>
>>          try {
>>              client.getPerson(request);
>>              fail("We expect to get the UnknowPersonFault here");
>>          } catch (UnknownPersonFault fault) {
>>              // We expect to get fault here
>>              assertEquals("Receive an invalid personId: '?'",
>> fault.getMessage());
>>          }
>>
>>          queueEndpoint.assertIsSatisfied();
>>          errorEndpoint.assertIsSatisfied();
>>      }
>>
>>      @Test
>>      public void processRecoverableExceptionForUnknowPerson() throws
>> Exception {
>>          queueEndpoint.expectedMessageCount(1);
>>
>> queueEndpoint.expectedBodiesReceived("com.awl.wlsi.example.eai.service.types.GetPerson[personId='5']");
>>          errorEndpoint.expectedMessageCount(1);
>>
>>          GetPerson request = new GetPerson();
>>          request.setPersonId("5");
>>
>>          try {
>>              client.getPerson(request);
>>              fail("We expect to get the SOAPFaultException here");
>>          } catch (SOAPFaultException fault) {
>>              // We expect to get fault here
>>              assertEquals("Recoverable exception", fault.getMessage());
>>          }
>>
>>          queueEndpoint.assertIsSatisfied();
>>          errorEndpoint.assertIsSatisfied();
>>      }
>>
>>      @Test
>>      public void processInvalidRequest() throws Exception {
>>          queueEndpoint.expectedMessageCount(0);
>>          errorEndpoint.expectedMessageCount(0);
>>
>>          GetPerson request = new GetPerson();
>>          request.setPersonId("tooooooooooooooooooooooo long");
>>
>>          try {
>>              client.getPerson(request);
>>              fail("We expect to get a message schema validation
>> failure");
>>          } catch (Exception ex) {
>>              // We expect to get fault here
>>              assertEquals("Unmarshalling Error: cvc-maxLength-valid: Value
>> 'tooooooooooooooooooooooo long' with length = '29' is not facet-valid with
>> respect to maxLength '10' for type 'personId'. ", ex.getMessage());
>>          }
>>
>>          queueEndpoint.assertIsSatisfied();
>>          errorEndpoint.assertIsSatisfied();
>>      }
>>
>>      @Override
>>      protected ClassPathXmlApplicationContext createApplicationContext() {
>>          return new ClassPathXmlApplicationContext(new
>> String[]{"META-INF/spring/bundle-context.xml",
>> "META-INF/spring/bundle-context-test.xml"});
>>      }
>>
>>      @Override
>>      protected int getExpectedRouteCount() {
>>          return 0;
>>      }
>> }
>>
>>
>> stack trace:
>> 2010-07-05 16:07:40,963 [main           ] DEBUG
>> DefaultCamelContext            - ... Routes started
>> 2010-07-05 16:07:40,963 [main           ] INFO
>> DefaultCamelContext            - Started 3 routes
>> 2010-07-05 16:07:40,963 [main           ] INFO
>> DefaultCamelContext            - Apache Camel 2.2.0-fuse-01-00
>> (CamelContext:camelContext) started
>> 2010-07-05 16:07:40,963 [main           ] DEBUG
>> IncommingRouteTest             - Camel Routes:
>> [EventDrivenConsumerRoute[Endpoint[
>> http://localhost:8181/Services/PersonService] ->
>> Instrumentation:route[UnitOfWork(Channel[Multicast[[Channel[sendTo(Endpoint[direct://queue])],
>> Channel[sendTo(Endpoint[direct://processor])]]]])]],
>> EventDrivenConsumerRoute[Endpoint[direct://queue] ->
>> Instrumentation:route[UnitOfWork(Pipeline[Channel[com.awl.wlsi.example.eai.in.IncommingRoute$1@b3a5d1],
>> Channel[sendTo(Endpoint[mock://result] InOnly)]])]],
>> EventDrivenConsumerRoute[Endpoint[direct://processor] ->
>> Instrumentation:route[UnitOfWork(Channel[com.awl.wlsi.example.eai.in.PersonProcessor@139ef3a
>> ])]]]
>> 2010-07-05 16:07:40,963 [main           ] TRACE
>> CamelBeanPostProcessor         - Camel bean processing before initialization
>> for bean: this
>> 2010-07-05 16:07:40,963 [main           ] TRACE
>> DefaultCamelContext            - Getting endpoint with uri: mock://result
>> 2010-07-05 16:07:40,963 [main           ] TRACE
>> DefaultCamelContext            - Getting endpoint with uri: mock://error
>> 2010-07-05 16:07:40,963 [main           ] DEBUG
>> IncommingRouteTest             - Using created route builder: Routes: []
>> 2010-07-05 16:07:40,963 [main           ] DEBUG
>> DefaultCamelContext            - Adding routes from builder: Routes: []
>> 2010-07-05 16:07:40,963 [main           ] DEBUG
>> IncommingRouteTest             - Routing Rules are:
>> [EventDrivenConsumerRoute[Endpoint[
>> http://localhost:8181/Services/PersonService] ->
>> Instrumentation:route[UnitOfWork(Channel[Multicast[[Channel[sendTo(Endpoint[direct://queue])],
>> Channel[sendTo(Endpoint[direct://processor])]]]])]],
>> EventDrivenConsumerRoute[Endpoint[direct://queue] ->
>> Instrumentation:route[UnitOfWork(Pipeline[Channel[com.awl.wlsi.example.eai.in.IncommingRoute$1@b3a5d1],
>> Channel[sendTo(Endpoint[mock://result] InOnly)]])]],
>> EventDrivenConsumerRoute[Endpoint[direct://processor] ->
>> Instrumentation:route[UnitOfWork(Channel[com.awl.wlsi.example.eai.in.PersonProcessor@139ef3a
>> ])]]]
>> 2010-07-05 16:07:40,963 [main           ] DEBUG
>> IncommingRouteTest             - Routing Rules are:
>> [EventDrivenConsumerRoute[Endpoint[
>> http://localhost:8181/Services/PersonService] ->
>> Instrumentation:route[UnitOfWork(Channel[Multicast[[Channel[sendTo(Endpoint[direct://queue])],
>> Channel[sendTo(Endpoint[direct://processor])]]]])]],
>> EventDrivenConsumerRoute[Endpoint[direct://queue] ->
>> Instrumentation:route[UnitOfWork(Pipeline[Channel[com.awl.wlsi.example.eai.in.IncommingRoute$1@b3a5d1],
>> Channel[sendTo(Endpoint[mock://result] InOnly)]])]],
>> EventDrivenConsumerRoute[Endpoint[direct://processor] ->
>> Instrumentation:route[UnitOfWork(Channel[com.awl.wlsi.example.eai.in.PersonProcessor@139ef3a
>> ])]]]
>> 05.07.2010 16:07:40
>> org.apache.cxf.service.factory.ReflectionServiceFactoryBean
>> buildServiceFromWSDL
>> INFO: Creating Service {http://camel.apache.org/non-wrapper}PersonService<http://camel.apache.org/non-wrapper%7DPersonService>from
WSDL:
>> file:/D:/workspaceWLSI/wlsi/examples/wlsi-example-eai/wlsi-example-eai-incomming/target/classes/META-INF/wlsi/person-non-wrapper.wsdl
>> 05.07.2010 16:08:41 org.apache.cxf.phase.PhaseInterceptorChain
>> doDefaultLogging
>> WARNUNG: Interceptor for {
>> http://camel.apache.org/non-wrapper}PersonService#{http://camel.apache.org/non-wrapper}GetPerson<http://camel.apache.org/non-wrapper%7DPersonService#%7Bhttp://camel.apache.org/non-wrapper%7DGetPerson>has
thrown exception, unwinding now
>> org.apache.cxf.interceptor.Fault: Could not send Message.
>>      at
>> org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:64)
>>      at
>> org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:243)
>>      at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:484)
>>      at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:310)
>>      at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:262)
>>      at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:73)
>>      at
>> org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:124)
>>      at $Proxy51.getPerson(Unknown Source)
>>      at
>> com.awl.wlsi.example.eai.in.IncommingRouteTest.process(IncommingRouteTest.java:50)
>>      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:597)
>>      at org.junit.internal.runners.TestMethod.invoke(TestMethod.java:59)
>>      at
>> org.junit.internal.runners.MethodRoadie.runTestMethod(MethodRoadie.java:98)
>>      at org.junit.internal.runners.MethodRoadie$2.run(MethodRoadie.java:79)
>>      at
>> org.junit.internal.runners.MethodRoadie.runBeforesThenTestThenAfters(MethodRoadie.java:87)
>>      at
>> org.junit.internal.runners.MethodRoadie.runTest(MethodRoadie.java:77)
>>      at org.junit.internal.runners.MethodRoadie.run(MethodRoadie.java:42)
>>      at
>> org.junit.internal.runners.JUnit4ClassRunner.invokeTestMethod(JUnit4ClassRunner.java:88)
>>      at
>> org.junit.internal.runners.JUnit4ClassRunner.runMethods(JUnit4ClassRunner.java:51)
>>      at
>> org.junit.internal.runners.JUnit4ClassRunner$1.run(JUnit4ClassRunner.java:44)
>>      at
>> org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:27)
>>      at
>> org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:37)
>>      at
>> org.junit.internal.runners.JUnit4ClassRunner.run(JUnit4ClassRunner.java:42)
>>      at
>> org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:46)
>>      at
>> org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
>>      at
>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
>>      at
>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
>>      at
>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
>>      at
>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
>> Caused by: java.net.SocketTimeoutException: SocketTimeoutException invoking
>> http://localhost:8181/Services/PersonService: Read timed out
>>      at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
>> Method)
>>      at
>> sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
>>      at
>> sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
>>      at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
>>      at
>> org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.mapException(HTTPConduit.java:2011)
>>      at
>> org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1992)
>>      at
>> org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:66)
>>      at
>> org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:640)
>>      at
>> org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:62)
>>      ... 30 more
>> Caused by: java.net.SocketTimeoutException: Read timed out
>>      at java.net.SocketInputStream.socketRead0(Native Method)
>>      at java.net.SocketInputStream.read(SocketInputStream.java:129)
>>      at java.io.BufferedInputStream.fill(BufferedInputStream.java:218)
>>      at java.io.BufferedInputStream.read1(BufferedInputStream.java:258)
>>      at java.io.BufferedInputStream.read(BufferedInputStream.java:317)
>>      at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:687)
>>      at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:632)
>>      at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:766)
>>      at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:632)
>>      at
>> sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1072)
>>      at
>> java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:373)
>>      at
>> org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponseInternal(HTTPConduit.java:2110)
>>      at
>> org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponse(HTTPConduit.java:2087)
>>      at
>> org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1985)
>>      ... 33 more
>> 2010-07-05 16:08:41,497 [main           ] DEBUG
>> IncommingRouteTest             - tearDown test
>> 2010-07-05 16:08:41,497 [main           ] TRACE
>> ServiceHelper                  - Stopping service
>> org.apache.camel.impl.ProducerCache@89949a
>>
>> Any idea? I could also provide my other code, if it's required...
>>
>> Thanks in advance,
>> Christian
>>

-- 
----
http://www.liquid-reality.de


Mime
View raw message