Created
May 29, 2019 19:19
-
-
Save Sovietaced/e6f53dfc4a3cfb32c669181c7526abb0 to your computer and use it in GitHub Desktop.
Revisions
-
Sovietaced created this gist
May 29, 2019 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,75 @@ package org.projectfloodlight.db; import static org.hamcrest.Matchers.is; import static org.junit.Assert.assertThat; import org.junit.After; import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.projectfloodlight.test.RepeatRule; import org.restlet.Server; import org.restlet.data.Protocol; import org.restlet.representation.Representation; import org.restlet.representation.StringRepresentation; import org.restlet.representation.Variant; import org.restlet.resource.ClientResource; import org.restlet.resource.Get; import org.restlet.resource.Put; import org.restlet.resource.ServerResource; public class RestletClientBug { private Server server; @Before public void setup() throws Exception { // Create the HTTP server and listen on port 8182 server = new Server(Protocol.HTTP, 8182, FirstServerResource.class); server.start(); } @After public void teardown() throws Exception { server.stop(); } public static class FirstServerResource extends ServerResource { @Override @Get public String toString() { return "hello, world"; } @Put public String insertDataJson(Representation entity, Variant variant) throws DBException { return "put success"; } } @Rule public final RepeatRule rule = new RepeatRule(); //@Repeat(times=100) @Test public void testGet() throws Exception { ClientResource clientResource = new ClientResource("http://localhost:8182/"); Representation output = clientResource.get(); System.out.println(output.getText()); assertThat(clientResource.getStatus().getCode(), is(200)); clientResource.release(); } //@Repeat(times=5) @Test public void testPut() throws Exception { ClientResource clientResource = new ClientResource("http://localhost:8182/"); Representation output = clientResource.put(new StringRepresentation("\"test\"")); System.out.println(output.getText()); assertThat(clientResource.getStatus().getCode(), is(200)); clientResource.release(); } }