rest-assured / rest-assured Goto Github PK
View Code? Open in Web Editor NEWJava DSL for easy testing of REST services
License: Apache License 2.0
Java DSL for easy testing of REST services
License: Apache License 2.0
I supply the keystore file but it doesn't work.. I also made a liitle java
program to see if the keystore works at all.
openssl s_client -connect https://unity-unl-acc.powerhouse.local -starttls ssl
> essent.cer
System.setProperty("javax.net.ssl.trustStore","/path/to/myKeystore");
System.setProperty("javax.net.ssl.trustStorePassword","password");
URL url = new URL("https://url.local");
URLConnection con = url.openConnection();
Reader reader = new InputStreamReader(con.getInputStream());
while (true) {
int ch = reader.read();
if (ch == -1) {
break;
}
System.out.print((char) ch);
}
Gives expected output. (without keystore it does NOT)
My rest assured test look like this:
RestAssured.baseURI = getData().getUrl();
RestAssured.requestSpecification = new
RequestSpecBuilder().log(LogDetail.ALL).setContentType(ContentType.JSON).build()
;
RestAssured.defaultParser = Parser.JSON;
/* Object creation */
Session session = new Session();
session.setGebruikersnaam("test1");
session.setWachtwoord("test1");
char[] password = "changeit".toCharArray();
FileInputStream fIn = new FileInputStream("path/to/myKeystore");
KeyStore keystore = KeyStore.getInstance("JKS");
keystore.load(fIn, password);
/* Rest call */
Response res =
given().trustStore(keystore).body(session).post("/rest/session").then().extract(
).response();
and gives the following output:
javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException:
PKIX path building failed:
sun.security.provider.certpath.SunCertPathBuilderException: unable to find
valid certification path to requested target
at sun.security.ssl.Alerts.getSSLException(Alerts.java:192)
at sun.security.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1917)
What can be the cause of this? How to debug/fix this?
Any help is much appreciated!
Original issue reported on code.google.com by [email protected]
on 28 Apr 2015 at 9:57
What steps will reproduce the problem?
1. Ha a service that reurns the following json
{
"queryString": "(\"Foo\" AND ())"
}
2.enable logging by creating a ResponseSpecification log().status()
What is the expected output?
I would expect it to log what's actually in the response body and which is
valid json, i.e:
{
"queryString": "(\"Foo\" AND ())"
}
What do you see instead?
{
"queryString": "("Foo" AND ())"
}
What version of the product are you using?
1.6.2
Original issue reported on code.google.com by [email protected]
on 26 Aug 2012 at 3:39
E.g.
Greeting greeting =
get("/something").andMap().path("greeting.firstName").and().path("greeting.lastN
ame").to(Greeting.class);
Original issue reported on code.google.com by [email protected]
on 6 Oct 2011 at 4:54
What steps will reproduce the problem?
1. Set the contentType of a request to `ContentType.JSON`
1.b do NOT set the character encoding
2. Add a Unicode body with characters not within ISO-8859-1
3. Send the data.
What is the expected output? What do you see instead?
- Expect: the data to be sent as specified.
- Actual: non ISO-8859-1 characters are mangled.
What version of the product are you using? On what operating system?
2.4.1, OSX 10.9, 10.10
Please provide any additional information below.
When sending JSON data, any non ISO-8859-1 characters are mangled unless the
encoding is specified as UTF-8.
Issue #228 initially brought up the issue, but the solution to specify a
charset of the content-type, while useful for others, is unnecessary for JSON,
and arguably wrong.
From rfc4627: http://www.ietf.org/rfc/rfc4627.txt
JSON text SHALL be encoded in Unicode. The default encoding is UTF-8.
Since the first two characters of a JSON text will always be ASCII
characters [RFC0020], it is possible to determine whether an octet
stream is UTF-8, UTF-16 (BE or LE), or UTF-32 (BE or LE) by looking
at the pattern of nulls in the first four octets.
Accordingly, charset parameter is not allowed in the JSON MIME type
specifically because the unicode variant can be determined from the content:
The MIME media type for JSON text is application/json.
Type name: application
Subtype name: json
Required parameters: n/a
Optional parameters: n/a
Encoding considerations: 8bit if UTF-8; binary if UTF-16 or UTF-32
JSON may be represented using UTF-8, UTF-16, or UTF-32. When JSON
is written in UTF-8, JSON is 8bit compatible. When JSON is
written in UTF-16 or UTF-32, the binary content-transfer-encoding
must be used.
The preferred workaround should be to set the defaultContentCharset on the
encoderConfig(), and avoid unnecessary charset parameter.
newConfig().encoderConfig(encoderConfig().defaultContentCharset("UTF-8"))
Original issue reported on code.google.com by [email protected]
on 25 Jun 2015 at 4:42
E.g.
from(json).to(MyClass.class);
or
from(json).get(MyClass.class);
or
from(json).getObject(MyClass.class);
Original issue reported on code.google.com by [email protected]
on 21 Oct 2011 at 8:19
E.g.
String template = "x.%s.z.%s";
... from(xml).getString(template, "some", "thing");
Original issue reported on code.google.com by [email protected]
on 27 Sep 2011 at 12:12
public static String pathOf(String... pathFragments) { return
StringUtils.join(pathFragments, ".");
}
Usage:
from(json).getString(pathOf(SOME, THING));
instead of:
from(json).getString(String.format("%s.%s", SOME, THING));
Original issue reported on code.google.com by [email protected]
on 21 Oct 2011 at 8:48
What steps will reproduce the problem?
I'm looking for a way to add additional headers and content-type to multipart
section(according to my Request Payload), for example I would like to be able
to add
Content-Disposition: form-data; name="file"; filename="pincode_master_data.csv"
Content-Type: text/csv
When i tried Using : given().multiPart("file",new
File("/home/ravi/Downloads/pincode_master_data.csv")).expect().statuscode("200")
.when().post("/");
I got an error: That status code is 400
If i want to make use of MultiPartSpecBuilder, please let me know, how i need
to use it.
What is the expected output? What do you see instead?
Without providing headers/content-type to the multipart, the Rest API i am
trying to invoke does not work. It does not upload the excel file to the server
if multipart headers/content-type are not provided.
What version of the product are you using? On what operating system?
I am using latest version of Rest Assured library (rest-assured-2.4.1.jar) on
Ubuntu OS.
Please provide any additional information below.
If normally i set the header/content-type to the request then it will just be
added to the request and not to a particular multi-part section.
Please look closely into the issue as it is a basic requirement.
Original issue reported on code.google.com by [email protected]
on 6 May 2015 at 5:39
Specify that you can set the pathSyntax:
RestAssured.pathSyntax = JSON_PATH;
RestAssured.pathSyntax = GROOVY;
JSON_PATH requires http://code.google.com/p/json-path/ in CP (optional
dependency) whereas GROOVY uses the current impl.
Note that this setting should not be affected by the reset() method.
Original issue reported on code.google.com by [email protected]
on 15 Feb 2011 at 7:45
HTTP is an open protocol that gets augmented by several extension
specifications. One of them, for example, is WebDAV, which brings new methods
like PROPFIND and SEARCH.
To be able to use REST-assured with any HTTP-based protocol (not only with the
base protocol's methods), it would be best to have an ".invoke(String)" method
added to com.jayway.restassured.specification.RequestSende (and an
implementation of that in RequestSpecificationImpl):
/**
* Perform a custom request to a <code>path</code>. Normally the path doesn't have to be fully-qualified e.g. you don't need to
* specify the path as <tt>http://localhost:8080/path</tt>. In this case it's enough to use <tt>/path</tt>.
*
* @param methodName The name of the custom HTTP method to invoke.
* @param path The path to send the request to.
* @param pathParams The path parameters.
* @return The response of the request.
*/
Response invoke(String methodName, String path, Map<String, ?> pathParams);
Original issue reported on code.google.com by headcrashing
on 10 Aug 2012 at 9:45
Given test should pass
RestAssured.baseURI = "https://sni.velox.ch"; // sample server with SNI configured
given().expect().statusCode(200).with().get("/");
but it throws an exception instead:
javax.net.ssl.SSLException: hostname in certificate didn't match:
<sni.velox.ch> != <alice.sni.velox.ch> OR <alice.sni.velox.ch> OR
<carol.sni.velox.ch>
Test with relaxed HTTP validation passes:
given().relaxedHTTPSValidation().expect().statusCode(200).with().get("/");
I run the test on Java 1.7 using TestNG and Maven.
Original issue reported on code.google.com by [email protected]
on 19 Mar 2015 at 1:04
then().
body("timestamp", notNullValue(),
"errorCode", is(-2),
"details", equalTo(".."));
Here all expectations could be validated at once just like expect.
Original issue reported on code.google.com by [email protected]
on 27 Mar 2015 at 4:46
public static String pathOf(String... pathFragments) { return
StringUtils.join(pathFragments, ".");
}
Usage:
from(json).getString(pathOf(SOME, THING));
instead of:
from(json).getString(String.format("%s.%s", SOME, THING));
Original issue reported on code.google.com by [email protected]
on 21 Oct 2011 at 8:48
I've noticed that RequestSpecification.basePath is ignored when using form
authentication.
Consider two scenarious below:
1) working snippet:
RestAssured.basePath = "/my-app";
given()
.auth().form(userName, password, FormAuthConfig.springSecurity())
.when()
.get("tested-api")
2) non working snippet:
====================
RequestSpecification mySpec= new RequestSpecBuilder()
.setBasePath("/my-app")
.build();
given()
.spec(mySpec)
.auth().form(userName, password, FormAuthConfig.springSecurity())
.when()
.get("tested-api")
In working snippet (1) authentication form sent to
/my-app/j_spring_security_check
While in non-working snippet (2) authentication form sent to
/j_spring_security_check
actual GET request does respect basePath in both cases.
Original issue reported on code.google.com by [email protected]
on 27 May 2015 at 3:15
E.g.
from(json).to(MyClass.class);
or
from(json).get(MyClass.class);
or
from(json).getObject(MyClass.class);
Original issue reported on code.google.com by [email protected]
on 21 Oct 2011 at 8:19
E.g.
String template = "x.%s.z.%s";
... from(xml).getString(template, "some", "thing");
Original issue reported on code.google.com by [email protected]
on 27 Sep 2011 at 12:12
When passing a map as parameter it should also be possible to include List
values, e.g.
map.put("listOfStuff", asList(stuff1, stuff2));
..
Original issue reported on code.google.com by [email protected]
on 28 Jun 2011 at 1:59
E.g.
expect().body("root.child", equalTo("x")).when("/jsonp?callback=y");
But perhaps it's better/easier to do something like:
expect().jsonp("callback", "y").body("root.child",
equalTo("x")).when().get("/jsonp");
or:
expect().jsonp("callback").body("root.child",
equalTo("x")).when().get("/jsonp");
which should generate a random method-name.
It should also be possible to set it as default:
RestAssured.expectedParser = jsonp("callback", "y");
RestAssured.expectedParser = jsonp("callback");
RestAssured.expectedParser = auto(); // Default
There should also be a JsonpPath that simply extends JsonPath and removes
method call.
Original issue reported on code.google.com by [email protected]
on 10 Mar 2011 at 2:00
What steps will reproduce the problem?
1.
> I have created tenantAdd() method - to add a tenant user by taking json input
in a text file using multipart() method.
> Manually using POST REST client /using body() method when I parse the json
input it works fine, but using multipart() method it is not working.
> Method:
=======
public static void tenantAdd(){
Response res=given().headers("Accept","application/json")
.contentType("application/json")
.multiPart(newFile("file","D:/t/json.txt"))
.log().everything().when().post("/sites/"+id+"/tenants");
res.prettyPrint();
}
> D:/t/json.txt file input:
========================
{
"name" : "Test ",
"description" : "administration tenant", "password" : "Test_123", "email" : " [email protected] "
}
It is failing with below error:
==============================
> {
> "detail": "Create tenant fails, cause: null",
> "title": "Internal Server Error caused by unexpected exception",
> "errorCode": "EMVI-WS-11019",
> "problemType": "http://www.w3.org/Protocols/HTTP/HTRESP.html",
> "httpStatus": 500,
> "httpMessage": "Internal error 'An error occurred while creating object
from json String.' encountered while accessing 'Site' resource identified by
'/em/websvcs/restful/extws/virtualization/infrastructure/v1/sites/<id>/tenants'"
,
> "problemInstance":
"/em/websvcs/restful/extws/virtualization/infrastructure/v1/sites/<id>/tenants"
> }
What is the expected output? What do you see instead?
> Output:
> ======
> Request method: POST
> Request
path: https://<IP:PORT>/em/websvcs/restful/extws/virtualization/infrastructure/v
1/sites/<id>/tenants
> Proxy: <none>
> Request params: <none>
> Query params: <none>
> Form params: <none>
> Path params: <none>
> Multiparts: <none>
> Headers: Accept=*/*
> Content-Type=application/json; charset=ISO-8859-1
> Cookies: <none>
> Body:
> {
> "name": "Test",
> "description": " administration tenant ",
> "password": "Test_123",
> "email": "[email protected]"
> }
What version of the product are you using? On what operating system?
Rest assured - 2.4.1
OS win7
Please provide any additional information below.
Original issue reported on code.google.com by [email protected]
on 17 May 2015 at 6:20
Attachments:
I am doing a GET on an endpoint which returns a 14M JSON response and it throws
a TruncatedChunkException when I try to get the body as a String. The response
is gzipped.
What steps will reproduce the problem?
Response response = get("http://domain.com");
String body = response.asString(); // throws TruncatedChunkException
But when I the following it works as expected:
Response response = expect().body(notNullValue()).get("http://domain.com");
String body = response.asString(); // this works properly
What is the expected output? What do you see instead?
I wish to get the body as a String but in the first scenario a
TruncatedChunkException is thrown.
What version of the product are you using? On what operating system?
rest-assured v2.4.1 OSX and Linux AMI
Please provide any additional information below.
Original issue reported on code.google.com by [email protected]
on 15 Jul 2015 at 2:46
Specify that you can set the pathSyntax:
RestAssured.pathSyntax = JSON_PATH;
RestAssured.pathSyntax = GROOVY;
JSON_PATH requires http://code.google.com/p/json-path/ in CP (optional
dependency) whereas GROOVY uses the current impl.
Note that this setting should not be affected by the reset() method.
Original issue reported on code.google.com by [email protected]
on 15 Feb 2011 at 7:45
What steps will reproduce the problem?
1. Add the two classes into your workspace
2. Execute SpringValueAnnotationNotRecognizedTest
3. You will see that the test
SpringValueAnnotationNotRecognizedTest.testControllerMethodThatWontRecognizeTheS
pringValueAnnotation will fail, because the Spring's @Value Annotation is not
recognized.
Original issue reported on code.google.com by [email protected]
on 7 Jul 2015 at 1:00
Attachments:
new PathBuilder().thirdElementIn(PERSONS).find(TITLE,
equalTo("Johan")).path(IMAGE_NAME).build();
should translate to path: persons[2].find(matcher.matches(it.title)).image_name;
This should also work:
expect().body(thirdElementIn(PERSONS).find(TITLE,
equalTo("Johan")).path(IMAGE_NAME), is("person.png")).when(). ..
Original issue reported on code.google.com by [email protected]
on 23 Oct 2011 at 9:26
What steps will reproduce the problem?
1. Try to create a body expression for a list whose name has a hyphen
Example:
RestAssured.when().get().then().body("root.some-item[0]", equalTo(""));
What is the expected output? What do you see instead?
It should look for the first "some-thing" entry and match it (and in the above
case fail on matching), instead it throws an exception because it thinks that
'item' is a parameter. This happens for both JSON and XML.
What version of the product are you using? On what operating system?
2.4.1
Please provide any additional information below.
It seems to be ok for the root element, and only fail for the second one on, as:
RestAssured.when().get().then().body("some-item[0]", equalTo(""));
does not throw the same exception.
Stracktrace:
java.lang.IllegalArgumentException: The parameter "item" was used but not
defined. Define parameters using the XmlPath.params(...) function
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
at org.codehaus.groovy.reflection.CachedConstructor.invoke(CachedConstructor.java:77)
at org.codehaus.groovy.runtime.callsite.ConstructorSite$ConstructorSiteNoUnwrapNoCoerce.callConstructor(ConstructorSite.java:102)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallConstructor(CallSiteArray.java:57)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:232)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:252)
at com.jayway.restassured.assertion.XMLAssertion.getResult(XMLAssertion.groovy:75)
at com.jayway.restassured.assertion.XMLAssertion$getResult.callCurrent(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:49)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:151)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:179)
at com.jayway.restassured.assertion.XMLAssertion.getResult(XMLAssertion.groovy:107)
at com.jayway.restassured.internal.assertion.Assertion$getResult.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:110)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:130)
at com.jayway.restassured.assertion.BodyMatcher.validate(BodyMatcher.groovy:94)
at com.jayway.restassured.assertion.BodyMatcher$validate$0.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:110)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:138)
at com.jayway.restassured.assertion.BodyMatcherGroup$_validate_closure2.doCall(BodyMatcherGroup.groovy:47)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:324)
at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:292)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1016)
at groovy.lang.Closure.call(Closure.java:423)
at groovy.lang.Closure.call(Closure.java:439)
at org.codehaus.groovy.runtime.DefaultGroovyMethods.collect(DefaultGroovyMethods.java:3167)
at org.codehaus.groovy.runtime.DefaultGroovyMethods.collect(DefaultGroovyMethods.java:3137)
at org.codehaus.groovy.runtime.dgm$66.invoke(Unknown Source)
at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite$PojoMetaMethodSiteNoUnwrapNoCoerce.invoke(PojoMetaMethodSite.java:271)
at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite.call(PojoMetaMethodSite.java:53)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:110)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:122)
at com.jayway.restassured.assertion.BodyMatcherGroup.validate(BodyMatcherGroup.groovy:47)
at com.jayway.restassured.assertion.BodyMatcherGroup$validate$3.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:110)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:138)
at com.jayway.restassured.internal.ResponseSpecificationImpl$HamcrestAssertionClosure.validate(ResponseSpecificationImpl.groovy:560)
at com.jayway.restassured.internal.ResponseSpecificationImpl$HamcrestAssertionClosure$validate$1.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:110)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:122)
at com.jayway.restassured.internal.ResponseSpecificationImpl.validateResponseIfRequired(ResponseSpecificationImpl.groovy:731)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite$PogoCachedMethodSiteNoUnwrapNoCoerce.invoke(PogoMetaMethodSite.java:207)
at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.callCurrent(PogoMetaMethodSite.java:56)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:49)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:151)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:163)
at com.jayway.restassured.internal.ResponseSpecificationImpl.content(ResponseSpecificationImpl.groovy:227)
at com.jayway.restassured.specification.ResponseSpecification$content$2.callCurrent(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:49)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:151)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:187)
at com.jayway.restassured.internal.ResponseSpecificationImpl.body(ResponseSpecificationImpl.groovy:210)
at com.jayway.restassured.internal.ValidatableResponseOptionsImpl.body(ValidatableResponseOptionsImpl.java:257)
at com.bamnetworks.media.service.jersey.SimplifiedContentRetrievalTest.test(SimplifiedContentRetrievalTest.java:16)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
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.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
Caused by: groovy.lang.MissingPropertyException: No such property: item for
class: Script1
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:51)
at org.codehaus.groovy.runtime.callsite.PogoGetPropertySite.getProperty(PogoGetPropertySite.java:49)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGroovyObjectGetProperty(AbstractCallSite.java:304)
at Script1.run(Script1.groovy:1)
at groovy.lang.GroovyShell.evaluate(GroovyShell.java:589)
at groovy.lang.GroovyShell.evaluate(GroovyShell.java:627)
at groovy.lang.GroovyShell.evaluate(GroovyShell.java:598)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite$PogoCachedMethodSiteNoUnwrap.invoke(PogoMetaMethodSite.java:187)
at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.call(PogoMetaMethodSite.java:68)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:110)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:122)
at com.jayway.restassured.assertion.XMLAssertion.eval(XMLAssertion.groovy:245)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite$PogoCachedMethodSiteNoUnwrapNoCoerce.invoke(PogoMetaMethodSite.java:207)
at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.callCurrent(PogoMetaMethodSite.java:56)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:49)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:151)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:179)
at com.jayway.restassured.assertion.XMLAssertion.getResult(XMLAssertion.groovy:71)
... 85 more
Original issue reported on code.google.com by [email protected]
on 8 Jun 2015 at 7:05
E.g.
response.print(); // Prints everything
response.printBody(); // print body
Original issue reported on code.google.com by [email protected]
on 26 Jan 2012 at 8:15
What is the expected output? What do you see instead?
SocketException instead of Successful connection to server when running test
with Java 6 defined as the JDK.
What version of the product are you using? On what operating system?
2.4.0, Java 6, Windows 7
Please provide any additional information below.
I have a REST API test suite that uses Rest Assured 2.4.0. Login to the
application is using a POST call. I am working around the cert validation by
using RestAssured.useRelaxedHTTPSValidation()
statically for all requests. The tests run just fine with JDK 1.7.0_79 but are
failing with SocketException errors when running with JDK 1.6.0_43. (on Windows
7)
Here is how I login and get Authorization Header which are needed for all
requests
public static RequestSpecification userWithAuthHeader() throws IOException {
testData = readTestDataFile();
RestAssured.baseURI = testData.getString("environment.URI");
RestAssured.basePath = testData.getString("environment.Path");
RestAssured.config.getHttpClientConfig().reuseHttpClientInstance();
RestAssured.useRelaxedHTTPSValidation();
String user = testData.getString("user.username");
String password = testData.getString("user.password");
String domain = testData.getString("user.domain");
String acceptHeader = testData.getString("acceptHeader");
String auth= post("/system/login?domain=" + domain + "&user=" + user + "&pw=" + password).getHeader("Authorization");
RequestSpecification requestSpec = with().log().all().headers("Authorization", auth, "Accept", acceptHeader);
return requestSpec;
}
The post method above fails when running it on Windows 7 with JDK 6 with the
following errors:
Running com.org.group.preCheckInSPTests.getAppliancesTest
Configuring TestNG with: TestNG652Configurator
May 24, 2015 7:54:26 AM org.apache.http.impl.client.DefaultRequestDirector tryConnect
INFO: I/O exception (java.net.SocketException) caught when connecting to {s}->https://<IP_ADDRESS>:
Connection reset
May 24, 2015 7:54:26 AM org.apache.http.impl.client.DefaultRequestDirector tryConnect
INFO: Retrying connect to {s}->https://<IP_ADDRESS>
May 24, 2015 7:54:26 AM org.apache.http.impl.client.DefaultRequestDirector tryConnect
INFO: I/O exception (java.net.SocketException) caught when connecting to {s}->https://<IP_ADDRESS>:
Connection reset
May 24, 2015 7:54:26 AM org.apache.http.impl.client.DefaultRequestDirector tryConnect
INFO: Retrying connect to {s}->https://<IP_ADDRESS>
May 24, 2015 7:54:26 AM org.apache.http.impl.client.DefaultRequestDirector tryConnect
INFO: I/O exception (java.net.SocketException) caught when connecting to {s}->https://<IP_ADDRESS>:
Connection reset
May 24, 2015 7:54:26 AM org.apache.http.impl.client.DefaultRequestDirector tryConnect
INFO: Retrying connect to {s}->https://<IP_ADDRESS>
Tests run: 4, Failures: 1, Errors: 0, Skipped: 3, Time elapsed: 6.116 sec <<< FAILURE! - in com.org.group.preCheckInSPTests.getAppliancesTest
loginAsUser(com.org.group.preCheckIn.getAppliancesTest) Time elapsed: 5.846 sec <<< FAILURE!
java.net.SocketException: Connection reset
at java.net.SocketInputStream.read(SocketInputStream.java:168)
at com.sun.net.ssl.internal.ssl.InputRecord.readFully(InputRecord.java:422)
at com.sun.net.ssl.internal.ssl.InputRecord.read(InputRecord.java:460)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:863)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1188)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1215)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1199)
at org.apache.http.conn.ssl.SSLSocketFactory.connectSocket(SSLSocketFactory.java:535)
at org.apache.http.conn.ssl.SSLSocketFactory.connectSocket(SSLSocketFactory.java:403)
at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:177)
at org.apache.http.impl.conn.ManagedClientConnectionImpl.open(ManagedClientConnectionImpl.java:304)
at org.apache.http.impl.client.DefaultRequestDirector.tryConnect(DefaultRequestDirector.java:611)
at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:446)
at org.apache.http.impl.client.AbstractHttpClient.doExecute(AbstractHttpClient.java:863)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:82)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:57)
at org.apache.http.client.HttpClient$execute$0.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:120)
at com.jayway.restassured.internal.RequestSpecificationImpl$RestAssuredHttpBuilder.doRequest(RequestSpecificationImpl.groovy:1764)
at com.jayway.restassured.internal.http.HTTPBuilder.post(HTTPBuilder.java:333)
at com.jayway.restassured.internal.http.HTTPBuilder$post$2.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:120)
at com.jayway.restassured.internal.RequestSpecificationImpl.sendRequest(RequestSpecificationImpl.groovy:1067)
at com.jayway.restassured.internal.RequestSpecificationImpl.this$2$sendRequest(RequestSpecificationImpl.groovy)
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.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:324)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1207)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1016)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:807)
at com.jayway.restassured.internal.RequestSpecificationImpl.invokeMethod(RequestSpecificationImpl.groovy)
at org.codehaus.groovy.runtime.callsite.PogoInterceptableSite.call(PogoInterceptableSite.java:45)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:128)
at com.jayway.restassured.internal.filter.SendRequestFilter.filter(SendRequestFilter.groovy:31)
at com.jayway.restassured.filter.Filter$filter.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:124)
at com.jayway.restassured.internal.filter.FilterContextImpl.next(FilterContextImpl.groovy:49)
at com.jayway.restassured.filter.FilterContext$next.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:120)
at com.jayway.restassured.internal.RequestSpecificationImpl.invokeFilterChain(RequestSpecificationImpl.groovy:956)
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.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:324)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1207)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1016)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:807)
at com.jayway.restassured.internal.RequestSpecificationImpl.invokeMethod(RequestSpecificationImpl.groovy)
at org.codehaus.groovy.runtime.callsite.PogoInterceptableSite.call(PogoInterceptableSite.java:45)
at org.codehaus.groovy.runtime.callsite.PogoInterceptableSite.callCurrent(PogoInterceptableSite.java:55)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:49)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:133)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:149)
at com.jayway.restassured.internal.RequestSpecificationImpl.applyPathParamsAndSendRequest(RequestSpecificationImpl.groovy:1414)
at com.jayway.restassured.internal.RequestSpecificationImpl.this$2$applyPathParamsAndSendRequest(RequestSpecificationImpl.groovy)
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.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:324)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1207)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1016)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:807)
at com.jayway.restassured.internal.RequestSpecificationImpl.invokeMethod(RequestSpecificationImpl.groovy)
at org.codehaus.groovy.runtime.callsite.PogoInterceptableSite.call(PogoInterceptableSite.java:45)
at org.codehaus.groovy.runtime.callsite.PogoInterceptableSite.callCurrent(PogoInterceptableSite.java:55)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:49)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:133)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:149)
at com.jayway.restassured.internal.RequestSpecificationImpl.post(RequestSpecificationImpl.groovy:154)
at com.jayway.restassured.internal.RequestSpecificationImpl.post(RequestSpecificationImpl.groovy)
at com.jayway.restassured.RestAssured.post(RestAssured.java:832)
Link to question on stackoverflow:
http://stackoverflow.com/questions/30423660/rest-assured-userelaxedhttpsvalidati
on-and-java-6-issues
Original issue reported on code.google.com by [email protected]
on 24 May 2015 at 9:10
What steps will reproduce the problem?
1.Have an expires value for cookie header in ISO 8601 date format.
2. Http headers suggest only three date formats and ISO is not among them.
3. I don't have a problem parsing response with other clients like jersey
What is the expected output? What do you see instead?
Expected Output: Parse response fine and get back status code of 200 ok
Actual Output: com.jayway.restassured.internal.http.ResponseParseException: OK
What version of the product are you using? On what operating system?
com.jayway.restassured : 2.3.4
OS: windows 7
Stack Trace:
com.jayway.restassured.internal.http.ResponseParseException: OK
at org.apache.http.impl.cookie.DateUtils.parseDate(DateUtils.java:118)
at org.apache.http.impl.cookie.DateUtils.parseDate(DateUtils.java:79)
at org.apache.http.impl.cookie.DateUtils$parseDate.call(Unknown Source)
at com.jayway.restassured.assertion.CookieMatcher.setCookieProperty(CookieMatcher.groovy:117)
at sun.reflect.GeneratedMethodAccessor22.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:324)
at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:368)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1016)
at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(PogoMetaClassSite.java:66)
Original issue reported on code.google.com by [email protected]
on 2 Jun 2015 at 4:25
Should follow:
* Specification - getters
* BddSpecification implements Specification - "setters" for Bdd style
* BuilderSpecification implements Specification - "setters" for Builder style
Setters does not mutate the state but return a new instance of the spec.
Original issue reported on code.google.com by [email protected]
on 8 Nov 2011 at 11:40
When passing a map as parameter it should also be possible to include List
values, e.g.
map.put("listOfStuff", asList(stuff1, stuff2));
..
Original issue reported on code.google.com by [email protected]
on 28 Jun 2011 at 1:59
While not required, and somewhat meaningless, the ContentType header of 204 (No
Content) responses are ignored, and assumed to be the empty string ("").
However, a 204 may include headers, and a contentType(...) validation will fail
for 204 responses, even if the expected contentType header was present.
It could be argued 204 content type should not be validated, but if it is
there, and validation is attempted, it should at worst warn that the value has
no meaning.
What steps will reproduce the problem?
1. Instruct the server to set ContentType: application/json for a 204 response
2. Request the resource, and validate that the contentType is ContentType.JSON
RestAssured.given().post(requestURL)
.then()
.statusCode(204)
.contentType(ContentType.JSON);
What is the expected output? What do you see instead?
- Expect the validation to succeed, as both the response code, and contentType are correct
- Instead, the contentType validation fails with the message:
Expected content-type "JSON" doesn't match actual content-type "".
What version of the product are you using? On what operating system?
2.4.1. OSX 10.9, 10.10
Original issue reported on code.google.com by [email protected]
on 25 Jun 2015 at 4:13
Should follow:
* Specification - getters
* BddSpecification implements Specification - "setters" for Bdd style
* BuilderSpecification implements Specification - "setters" for Builder style
Setters does not mutate the state but return a new instance of the spec.
Original issue reported on code.google.com by [email protected]
on 8 Nov 2011 at 11:40
What steps will reproduce the problem?
1. Provide a REST service returning a typed JSON array like this one : [ {
"foo": "foo", "bar": "bar" }, { "foo": "hello", "bar": "world" } ]
2. Try to call this service in rest-assured, then map it on a List<Foo> (where
Foo contains foo and bar fields) :
List<Foo> myList = expect().statusCode(200).when().get("/foos").as(List.class);
3. Since we have reified generics in Java, rest-assured cannot predict the
parameterized type of the List and then, will map the return type in a
List<Map> instead of a List<Foo>
Idea would be to provide a GSON-like approach with something looking like
TypeToken.
Discussion started on google group here :
https://groups.google.com/forum/#!topic/rest-assured/0GIQQfzC_6c
Original issue reported on code.google.com by [email protected]
on 10 Jan 2012 at 8:08
This code (in version 2.4.1):
given()
.multiPart("dto", dto, "application/json").log().all()
.when()
.post("/api/upload")
.then()
.statusCode(HttpStatus.SC_OK);
causes a
java.lang.IllegalArgumentException: Cannot specify file name for non file
content (java.lang.String).
at com.jayway.restassured.builder.MultiPartSpecBuilder.fileName(MultiPartSpecBuilder.java:120)
at com.jayway.restassured.module.mockmvc.internal.MockMvcRequestSenderImpl.logRequestIfApplicable(MockMvcRequestSenderImpl.java:464)
at com.jayway.restassured.module.mockmvc.internal.MockMvcRequestSenderImpl.sendRequest(MockMvcRequestSenderImpl.java:334)
at com.jayway.restassured.module.mockmvc.internal.MockMvcRequestSenderImpl.post(MockMvcRequestSenderImpl.java:502)
at com.jayway.restassured.module.mockmvc.internal.MockMvcRequestSenderImpl.post(MockMvcRequestSenderImpl.java:53)
...
I debugged a bit:
In the class 'MockMvcRequestSenderImpl' the 'dto' object is serialized and put
in the (MockMultipartHttpServletRequestBuilder) request (line 319).
But if the 'requestLoggingFilter' is not null, eventually
'fileName(multiPart.getFileName())' is called and multipart is neither a File,
FileInputStream or byte[].
Without the 'log().all()' things work fine (except there's no logging...)
Kind regards,
steveN
Original issue reported on code.google.com by [email protected]
on 19 Jun 2015 at 7:23
E.g.
String template = "x.%s.z.%s";
... from(xml).getString(template, "some", "thing");
Original issue reported on code.google.com by [email protected]
on 27 Sep 2011 at 12:12
What steps will reproduce the problem?
1. HTTP service returns body {"number": 0.0}
2. trying to match this with then().body("number", Matchers.closeTo(0.0, 0.001))
What is the expected output? What do you see instead?
Expect the match to succeed, fails instead with error message
java.lang.AssertionError: JSON path number doesn't match.
Expected: a numeric value within <0.001> of <0.0>
Actual: 0.0
What version of the product are you using? On what operating system?
OS: Mac OS X 10.10.4, Product Version: 2.4.1 from maven repository
Attached is a minimal working example project.
Original issue reported on code.google.com by [email protected]
on 16 Jul 2015 at 4:18
Attachments:
E.g.
expect().body("root.child", equalTo("x")).when("/jsonp?callback=y");
But perhaps it's better/easier to do something like:
expect().jsonp("callback", "y").body("root.child",
equalTo("x")).when().get("/jsonp");
or:
expect().jsonp("callback").body("root.child",
equalTo("x")).when().get("/jsonp");
which should generate a random method-name.
It should also be possible to set it as default:
RestAssured.expectedParser = jsonp("callback", "y");
RestAssured.expectedParser = jsonp("callback");
RestAssured.expectedParser = auto(); // Default
There should also be a JsonpPath that simply extends JsonPath and removes
method call.
Original issue reported on code.google.com by [email protected]
on 10 Mar 2011 at 2:00
Specify that you can set the pathSyntax:
RestAssured.pathSyntax = JSON_PATH;
RestAssured.pathSyntax = GROOVY;
JSON_PATH requires http://code.google.com/p/json-path/ in CP (optional
dependency) whereas GROOVY uses the current impl.
Note that this setting should not be affected by the reset() method.
Original issue reported on code.google.com by [email protected]
on 15 Feb 2011 at 7:45
HTTP is an open protocol that gets augmented by several extension
specifications. One of them, for example, is WebDAV, which brings new methods
like PROPFIND and SEARCH.
To be able to use REST-assured with any HTTP-based protocol (not only with the
base protocol's methods), it would be best to have an ".invoke(String)" method
added to com.jayway.restassured.specification.RequestSende (and an
implementation of that in RequestSpecificationImpl):
/**
* Perform a custom request to a <code>path</code>. Normally the path doesn't have to be fully-qualified e.g. you don't need to
* specify the path as <tt>http://localhost:8080/path</tt>. In this case it's enough to use <tt>/path</tt>.
*
* @param methodName The name of the custom HTTP method to invoke.
* @param path The path to send the request to.
* @param pathParams The path parameters.
* @return The response of the request.
*/
Response invoke(String methodName, String path, Map<String, ?> pathParams);
Original issue reported on code.google.com by headcrashing
on 10 Aug 2012 at 9:45
What steps will reproduce the problem?
1. Send request, which returns some UTF-8 characters like
"ŘÍŠŽŤČÝŮŇÚĚĎÁÉÓ", which contains all special Czech characters
2. Print response using com.jayway.restassured.response.ResponseBody#print
3. Print response using com.jayway.restassured.response.ResponseBody#prettyPrint
4. Compare responses
What is the expected output? What do you see instead?
Expected output is "ŘÍŠŽŤČÝŮŇÚĚĎÁÉÓ", but I got in prettyPrint()
"\u0158\u00cd\u0160\u017d\u0164\u010c\u00dd\u016e\u0147\u00da\u011a\u010e\u00c1\
u00c9\u00d3"
Content-Type=application/json; charset=UTF-8
What version of the product are you using? On what operating system?
rest-assured 2.4.0
Please provide any additional information below.
Original issue reported on code.google.com by [email protected]
on 15 May 2015 at 8:45
See
http://joel-costigliola.github.io/assertj/assertj-core-news.html#assertj-core-2.
0.0-bdd-soft-assertions
For example:
@Rule
public final RestAssuredSoftAssertions rule = new RestAssuredSoftAssertions();
then().soft().
body()..
body()..
Original issue reported on code.google.com by [email protected]
on 26 Mar 2015 at 11:31
1. Prepare JSON like:
{
"features": [
{
"type": "Feature",
"geometry": {
"type": "GeometryCollection",
"geometries": [
{
"type": "Point",
"coordinates": [
19.883992823270653,
50.02026203045478
]
}
]
},
"properties": {
"gridId": 6
}
},
{
"type": "Feature",
"geometry": {
"type": "GeometryCollection",
"geometries": [
{
"type": "Point",
"coordinates": [
19.901266347582094,
50.07074684071764
]
}
]
},
"properties": {
"gridId": 7
}
}
]
}
2.
Here are two examples of code. First one is working, second is not.
List<String> typeList= JSON.jsonPath().get("features.geometry.type"); //It's
working
List<Integer> gridIdList= JSON.jsonPath().get("features.properties.gridId");
//It's not working
In second case I should get list of all gridIds but its not working, it returns
null. I
assumed it is connected with property name = "properties". The example above is
valid GeoJson format.
What is more interesting I can do something like that and it's working:
Integer gridId = JSON.jsonPath().get("features[0].properties.gridId");
Version: 2.4.0
Original issue reported on code.google.com by [email protected]
on 21 Apr 2015 at 9:07
What steps will reproduce the problem?
1. Provide a REST service returning a typed JSON array like this one : [ {
"foo": "foo", "bar": "bar" }, { "foo": "hello", "bar": "world" } ]
2. Try to call this service in rest-assured, then map it on a List<Foo> (where
Foo contains foo and bar fields) :
List<Foo> myList = expect().statusCode(200).when().get("/foos").as(List.class);
3. Since we have reified generics in Java, rest-assured cannot predict the
parameterized type of the List and then, will map the return type in a
List<Map> instead of a List<Foo>
Idea would be to provide a GSON-like approach with something looking like
TypeToken.
Discussion started on google group here :
https://groups.google.com/forum/#!topic/rest-assured/0GIQQfzC_6c
Original issue reported on code.google.com by [email protected]
on 10 Jan 2012 at 8:08
When passing a map as parameter it should also be possible to include List
values, e.g.
map.put("listOfStuff", asList(stuff1, stuff2));
..
Original issue reported on code.google.com by [email protected]
on 28 Jun 2011 at 1:59
What steps will reproduce the problem?
1. Ha a service that reurns the following json
{
"queryString": "(\"Foo\" AND ())"
}
2.enable logging by creating a ResponseSpecification log().status()
What is the expected output?
I would expect it to log what's actually in the response body and which is
valid json, i.e:
{
"queryString": "(\"Foo\" AND ())"
}
What do you see instead?
{
"queryString": "("Foo" AND ())"
}
What version of the product are you using?
1.6.2
Original issue reported on code.google.com by [email protected]
on 26 Aug 2012 at 3:39
E.g.
Greeting greeting =
get("/something").andMap().path("greeting.firstName").and().path("greeting.lastN
ame").to(Greeting.class);
Original issue reported on code.google.com by [email protected]
on 6 Oct 2011 at 4:54
E.g.
Greeting greeting =
get("/something").andMap().path("greeting.firstName").and().path("greeting.lastN
ame").to(Greeting.class);
Original issue reported on code.google.com by [email protected]
on 6 Oct 2011 at 4:54
E.g.
from(json).to(MyClass.class);
or
from(json).get(MyClass.class);
or
from(json).getObject(MyClass.class);
Original issue reported on code.google.com by [email protected]
on 21 Oct 2011 at 8:19
E.g.
response.print(); // Prints everything
response.printBody(); // print body
Original issue reported on code.google.com by [email protected]
on 26 Jan 2012 at 8:15
E.g.
expect().body("root.child", equalTo("x")).when("/jsonp?callback=y");
But perhaps it's better/easier to do something like:
expect().jsonp("callback", "y").body("root.child",
equalTo("x")).when().get("/jsonp");
or:
expect().jsonp("callback").body("root.child",
equalTo("x")).when().get("/jsonp");
which should generate a random method-name.
It should also be possible to set it as default:
RestAssured.expectedParser = jsonp("callback", "y");
RestAssured.expectedParser = jsonp("callback");
RestAssured.expectedParser = auto(); // Default
There should also be a JsonpPath that simply extends JsonPath and removes
method call.
Original issue reported on code.google.com by [email protected]
on 10 Mar 2011 at 2:00
new PathBuilder().thirdElementIn(PERSONS).find(TITLE,
equalTo("Johan")).path(IMAGE_NAME).build();
should translate to path: persons[2].find(matcher.matches(it.title)).image_name;
This should also work:
expect().body(thirdElementIn(PERSONS).find(TITLE,
equalTo("Johan")).path(IMAGE_NAME), is("person.png")).when(). ..
Original issue reported on code.google.com by [email protected]
on 23 Oct 2011 at 9:26
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.