java - SocketTimeoutException cxf httpconduit PUT -


i have test takes lot of time , ended making timeout. tried solution bob , nothing not work. error occurs on tests put.

my test :

@test public void testupdateuse(){      setexpectedresponse("{\"id\":1,\"username\":\"test\",\"email\":\"bob@test.ca\"}");      user usertoupdate = new user();     usertoupdate.setemail("bob@test.ca");     usertoupdate.setusername("superbob");     usertoupdate.setid(1);      userorganization userorganization = new userorganization();     userorganization.setorganizationid(1);     list<userorganization> userorganizations = new arraylist<>();     userorganizations.add(userorganization);      userorganizationunit userorganizationunit = new userorganizationunit();     userorganizationunit.setorganizationunitid(1);     list<userorganizationunit> userorganizationunits = new arraylist<>();     userorganizationunits.add(userorganizationunit);      usertoupdate.setorganizations(userorganizations);     usertoupdate.setorganizationunits(userorganizationunits);      userapiservice.update(1, usertoupdate);      assertlatestrequest("put", "/users/1"); }  @before public void setupserver() throws exception {      thread.sleep(500);     expectedresponse = null;      final authenticator authenticator = new basicauthenticator("") {          @override         public boolean checkcredentials(final string username, final string password) {              return getusername().equals(username) && getpassword().equals(password);         }     };      final httphandler handler = new httphandler() {          @override         public void handle(httpexchange exchange) throws ioexception {              final authenticator.result authresult = authenticator.authenticate(exchange);             if (authresult instanceof authenticator.success || !basicauthrequired) {                 latestexchange = exchange;                  stringwriter writer = new stringwriter();                 try {                     ioutils.copy(new inputstreamreader(latestexchange.getrequestbody()), writer, 1024);                 } catch (ioexception e) {                     e.printstacktrace();                 }                 latestrequestbody = writer.tostring();                  byte[] response = expectedresponse.getbytes();                  exchange.getresponseheaders().add("content-type", expectedcontenttype);                 exchange.sendresponseheaders(expectedstatus, response.length);                 exchange.getresponsebody().write(response);             }              exchange.close();             expectedresponse = null;         }     };      httpserver = httpserver.create(new inetsocketaddress(testport), 0);     httpserver.createcontext("/", handler);     httpserver.start(); }  @after public void teardownserver() throws exception {      if (httpserver != null) {         httpserver.stop(0);     }      context.assertissatisfied();      thread.sleep(500); } 

example code on applicationcontext.xml:

<http:conduit name="{http://service.clientapi.user.com/}*.http-conduit">     <http:client cachecontrol="no-store" connection="keep-alive" allowchunking="false" connectiontimeout="10000" receivetimeout="60000"/> </http:conduit> 

version cxf : 2.7.3 version spring 3 java 7

my solution override httpconduit in test context.xml

<http:conduit name="*.http-conduit">     <http:client cachecontrol="no-store" connection="keep-alive" allowchunking="false" connectiontimeout="10000" receivetimeout="60000"/> </http:conduit> 

Comments

Popular posts from this blog

c++ - OpenCV Error: Assertion failed <scn == 3 ::scn == 4> in unknown function, -

php - render data via PDO::FETCH_FUNC vs loop -

The canvas has been tainted by cross-origin data in chrome only -