How do integration test in 0.8.0 version? (almost giving up)

551 views
Skip to first unread message

Mr. Pichler

unread,
Mar 13, 2015, 4:43:11 PM3/13/15
to dropwiz...@googlegroups.com
I'm trying to migrate from 0.7.1 to 0.8.0 version and get a lot of problems. I'm almost giving up. Maybe I should wait for improvements on documentation site.

Anyway, I´m trying to create a integration test:

 Client client = new JerseyClientBuilder(RULE.getEnvironment()).build("test client");

 
HttpAuthenticationFeature feature = HttpAuthenticationFeature.basicBuilder()
 
.nonPreemptive().credentials(rb.getString("email_free_account"), rb.getString("passwd")).build();

 client
.register(feature);

 
String encoded = "LH237 23MAR STRMUC 0800 1300";

 
String url = MessageFormat.format("http://localhost:{0}/v1/decode",
 
Integer.toString(RULE.getLocalPort()), URLEncoder.encode(encoded, "UTF-8").replace("+", "%20"));

 
WebTarget target = client.target(url).queryParam("encodedPNR", encoded);


 
Response response = target
 
.request().get();//ClientResponse.class);
 
System.out.println(response);

The server is hit, the authentication works nice, but always happen this error:

javax.ws.rs.ProcessingException: java.net.SocketTimeoutException: Read timed out
        at io
.dropwizard.client.DropwizardApacheConnector.apply(DropwizardApacheConnector.java:102)
        at org
.glassfish.jersey.client.ClientRuntime.invoke(ClientRuntime.java:246)
        at org
.glassfish.jersey.client.JerseyInvocation$1.call(JerseyInvocation.java:667)
        at org
.glassfish.jersey.client.JerseyInvocation$1.call(JerseyInvocation.java:664)
        at org
.glassfish.jersey.internal.Errors.process(Errors.java:315)
        at org
.glassfish.jersey.internal.Errors.process(Errors.java:297)
        at org
.glassfish.jersey.internal.Errors.process(Errors.java:228)
        at org
.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:444)
        at org
.glassfish.jersey.client.JerseyInvocation.invoke(JerseyInvocation.java:664)
        at org
.glassfish.jersey.client.authentication.HttpAuthenticationFilter.repeatRequest(HttpAuthenticationFilter.java:334)
        at org
.glassfish.jersey.client.authentication.BasicAuthenticator.filterResponseAndAuthenticate(BasicAuthenticator.java:125)
        at org
.glassfish.jersey.client.authentication.HttpAuthenticationFilter.filter(HttpAuthenticationFilter.java:250)
        at org
.glassfish.jersey.client.ClientFilteringStages$ResponseFilterStage.apply(ClientFilteringStages.java:134)
        at org
.glassfish.jersey.client.ClientFilteringStages$ResponseFilterStage.apply(ClientFilteringStages.java:123)
        at org
.glassfish.jersey.process.internal.Stages.process(Stages.java:171)
        at org
.glassfish.jersey.client.ClientRuntime.invoke(ClientRuntime.java:251)
        at org
.glassfish.jersey.client.JerseyInvocation$1.call(JerseyInvocation.java:667)
        at org
.glassfish.jersey.client.JerseyInvocation$1.call(JerseyInvocation.java:664)
        at org
.glassfish.jersey.internal.Errors.process(Errors.java:315)
        at org
.glassfish.jersey.internal.Errors.process(Errors.java:297)
        at org
.glassfish.jersey.internal.Errors.process(Errors.java:228)
        at org
.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:444)
        at org
.glassfish.jersey.client.JerseyInvocation.invoke(JerseyInvocation.java:664)
        at org
.glassfish.jersey.client.JerseyInvocation$Builder.method(JerseyInvocation.java:399)
        at org
.glassfish.jersey.client.JerseyInvocation$Builder.get(JerseyInvocation.java:303)
        at test
.integration.DecodeTests.hugeString(DecodeTests.java:62)
        at sun
.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun
.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun
.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at org
.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
        at org
.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
        at org
.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
        at org
.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
        at org
.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
        at org
.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)
        at org
.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
        at org
.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
        at org
.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
        at org
.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
        at org
.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
        at org
.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
        at org
.junit.rules.ExternalResource$1.evaluate(ExternalResource.java:46)
        at org
.junit.rules.RunRules.evaluate(RunRules.java:18)
        at org
.junit.runners.ParentRunner.run(ParentRunner.java:300)
        at org
.junit.runner.JUnitCore.run(JUnitCore.java:157)
        at com
.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:74)
        at com
.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:211)
        at com
.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:67)
        at sun
.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun
.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at com
.intellij.rt.execution.application.AppMain.main(AppMain.java:134)
Caused by: java.net.SocketTimeoutException: Read timed out
        at java
.net.SocketInputStream.socketRead0(Native Method)
        at java
.net.SocketInputStream.read(SocketInputStream.java:152)
        at java
.net.SocketInputStream.read(SocketInputStream.java:122)
        at org
.apache.http.impl.io.SessionInputBufferImpl.streamRead(SessionInputBufferImpl.java:136)
        at org
.apache.http.impl.io.SessionInputBufferImpl.fillBuffer(SessionInputBufferImpl.java:152)
        at org
.apache.http.impl.io.SessionInputBufferImpl.readLine(SessionInputBufferImpl.java:270)
        at org
.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:140)
        at org
.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:57)
        at org
.apache.http.impl.io.AbstractMessageParser.parse(AbstractMessageParser.java:260)
        at org
.apache.http.impl.DefaultBHttpClientConnection.receiveResponseHeader(DefaultBHttpClientConnection.java:161)
        at org
.apache.http.impl.conn.CPoolProxy.receiveResponseHeader(CPoolProxy.java:153)
        at org
.apache.http.protocol.HttpRequestExecutor.doReceiveResponse(HttpRequestExecutor.java:271)
        at org
.apache.http.protocol.HttpRequestExecutor.execute(HttpRequestExecutor.java:123)
        at com
.codahale.metrics.httpclient.InstrumentedHttpRequestExecutor.execute(InstrumentedHttpRequestExecutor.java:44)
        at org
.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:254)
        at org
.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:195)
        at org
.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:86)
        at org
.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:108)
        at org
.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:184)
        at org
.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:82)
        at org
.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:106)
        at io
.dropwizard.client.DropwizardApacheConnector.apply(DropwizardApacheConnector.java:80)
       
... 53 more



Anyone knows if there is any example of getting a raw response, and other getting an Exception from server?

Shervin Asgari

unread,
Mar 16, 2015, 6:01:27 PM3/16/15
to dropwiz...@googlegroups.com
Have you seen the integration test in the Dropwizard Example project?

Marcus Fihlon

unread,
Mar 17, 2015, 4:33:09 AM3/17/15
to dropwiz...@googlegroups.com
Hi Mr. Pichler

For me the upgrade was hard, too. A big problem was the absence of a migration guide. Luckily in the wiki at GitHub a migration guide was started where I contributed all the things I found out. If you go to this wiki page: https://github.com/dropwizard/dropwizard/wiki/Upgrade-guide-0.7.x-to-0.8.x you can scroll down to find working examples of a GET and a POST request. I hope this helps you solving your problem.

Good luck
Marcus

Carlo Barbara

unread,
Mar 17, 2015, 9:55:19 AM3/17/15
to dropwiz...@googlegroups.com
Thanks for contributing Marcus!

--
You received this message because you are subscribed to the Google Groups "dropwizard-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dropwizard-us...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Mr. Pichler

unread,
Mar 17, 2015, 5:32:48 PM3/17/15
to dropwiz...@googlegroups.com
Thank you Marcus. I found my problem.

Just changed this:
Client client = new JerseyClientBuilder(RULE.getEnvironment()).build("test client");

By this:

Client client = ClientBuilder.newClient();

And it worked again.

Reply all
Reply to author
Forward
0 new messages