Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

asserts not matching the returned codes #45

Open
ghost opened this issue Jul 5, 2013 · 0 comments
Open

asserts not matching the returned codes #45

ghost opened this issue Jul 5, 2013 · 0 comments

Comments

@ghost
Copy link

ghost commented Jul 5, 2013

I have a class with 19 tests.
13 are working fine.
6 are failing.

in all the 6 failing cases I am asserting against the returned code and still the test fails.

so here is the code:

@HttpTest(
        method = Method.POST,
        path = "*******",
        content = content,
        order = 200
)
public void testRegistrationUser1()
{
    assertCreated(response);
}

^^^THIS WORKS FINE.

after that I have another test:

@httptest(
method = Method.POST,
path = "++++++",
content = content,
order = 210
)
public void testRegistrationUser1Again()
{
assertConflict(response);

}

this time the test fails.
the result code is a 409 (conflict) but execution never actually gets to the result where it can make the assert (I can tell this because I am debugging and it never stops in the assertConflict()).

the result code is still a 409 but it doesn't seem to go through the normal flow of the test.

all these tests run against an application in a jetty server.
there is a sort of proxy that is between the test and the jetty application.
this proxy grabs the incoming request from the test and turns the url into a java.net.url and then calls that.

below is the stack trace I see in the failing test (this is the stack of the test itself, not the server):

com.github.kevinsawicki.http.HttpRequest$HttpRequestException: java.io.IOException: Server returned HTTP response code: 409 for URL: http://localhost:8080/++++++
at com.github.kevinsawicki.http.HttpRequest.stream(HttpRequest.java:1659)
at com.github.kevinsawicki.http.HttpRequest.buffer(HttpRequest.java:1636)
at com.github.kevinsawicki.http.HttpRequest.body(HttpRequest.java:1584)
at com.github.kevinsawicki.http.HttpRequest.body(HttpRequest.java:1599)
at com.eclipsesource.restfuse.internal.ResponseImpl.(ResponseImpl.java:30)
at com.eclipsesource.restfuse.internal.InternalRequest.post(InternalRequest.java:78)
at com.eclipsesource.restfuse.internal.HttpTestStatement.callService(HttpTestStatement.java:119)
at com.eclipsesource.restfuse.internal.HttpTestStatement.sendRequest(HttpTestStatement.java:105)
at com.eclipsesource.restfuse.internal.BasicStatement.evaluate(BasicStatement.java:30)
at com.eclipsesource.restfuse.internal.HttpTestStatement.doEvaluate(HttpTestStatement.java:84)
at com.eclipsesource.restfuse.internal.HttpTestStatement.evaluate(HttpTestStatement.java:64)
at org.junit.rules.RunRules.evaluate(RunRules.java:20)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.junit.runner.JUnitCore.run(JUnitCore.java:160)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:63)
Caused by: java.io.IOException: Server returned HTTP response code: 409 for URL: http://localhost:8080/++++++
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 sun.net.www.protocol.http.HttpURLConnection$6.run(HttpURLConnection.java:1491)
at java.security.AccessController.doPrivileged(Native Method)
at sun.net.www.protocol.http.HttpURLConnection.getChainedException(HttpURLConnection.java:1485)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1139)
at com.github.kevinsawicki.http.HttpRequest.stream(HttpRequest.java:1657)
... 24 more
Caused by: java.io.IOException: Server returned HTTP response code: 409 for URL: http://localhost:8080/++++++
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1436)
at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:379)
at com.github.kevinsawicki.http.HttpRequest.code(HttpRequest.java:1390)
at com.eclipsesource.restfuse.internal.InternalRequest.sendRequest(InternalRequest.java:149)
at com.eclipsesource.restfuse.internal.InternalRequest.post(InternalRequest.java:77)
... 19 more

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

0 participants