yuriibezpalko / rest-assured Goto Github PK
View Code? Open in Web Editor NEWAutomatically exported from code.google.com/p/rest-assured
Automatically exported from code.google.com/p/rest-assured
Scala:
given parameters(map) do get("") and verify { json =>
assertEquals(json.johan.hello == "Hello Johan") }
Groovy:
get("").and().verify { response, json -> assertEquals json.code, "ikk" }
get("").and().verify { response -> assertEquals json.code, "ikk" } // Works!
get("").and().verifyResponse("statusLine.statusCode", equalTo(200));
get("").and().verifyResponse(STATUS_CODE, equalTo(200));
get("").and().verifyResponse(header(johan), equalTo(200));
Java:
expect().content("lotto.winners.winnerId", hasItems(23,
54)).when().get("/lotto");
expect().header("lotto.winners.winnerId", hasItems(23,
54)).when().get("/lotto");
expect().contentType(XML).
Original issue reported on code.google.com by [email protected]
on 27 Oct 2010 at 6:35
e.g.
with().pathParams("model", "x").when().get("/admin/{model}/something");
Original issue reported on code.google.com by [email protected]
on 28 Feb 2011 at 1:30
reader can be null in:
private String convertToString(Reader reader) {
Writer writer = new StringWriter();
char[] buffer = new char[1024];
try {
int n;
while ((n = reader.read(buffer)) != -1) {
writer.write(buffer, 0, n);
}
} finally {
reader.close();
}
return writer.toString();
}
Original issue reported on code.google.com by [email protected]
on 3 Feb 2011 at 8:21
E.g.
expect().body("rss.channel.dc:creator", equalTo(""))...
Original issue reported on code.google.com by [email protected]
on 3 Mar 2011 at 7:16
E.g.
Session session = createSession();
session.expect().body("x.y.z", equalTo("xyz")).when().get("/xyz");
session.expect().body("z.y.x", equalTo("zyx")).when().get("/zyx");
session.close();
RA should automatically extract the session id from the header and pass it
along to the next request.
Original issue reported on code.google.com by [email protected]
on 13 Feb 2011 at 10:17
E.g.
List<Object> shoppingCategories = get("/somewhere").read("shopping.category");
and:
xmlPath = new XmlPath(get("/somewhere").asString());
int foo = path.read("..");
List bar = path.read("..");
Original issue reported on code.google.com by [email protected]
on 12 Feb 2011 at 11:30
E.g. isEmpty() (for arrays and lists) and hasSize(x).
Original issue reported on code.google.com by [email protected]
on 13 Jan 2011 at 8:27
I am using RestAssured version 1.0.3, from the central Maven repository. The
code below is being used to test authentication for a user that does not exist.
given()
.auth()
.basic("abcd", "abCD1")
.expect()
.statusCode(401)
.when()
.get("/");
This test passes, but the logger displays the following message.
Mar 3, 2011 11:37:58 AM org.apache.http.impl.client.DefaultRequestDirector
handleResponse
WARNING: Authentication error: basic authorization challenge expected, but not
found
Below are the associated response headers.
$ curl -i http://localhost:8080
HTTP/1.1 401 Authorization Required
WWW-Authenticate: Basic realm="myapplication"
Content-Type: text/html;charset=ISO-8859-1
Cache-Control: must-revalidate,no-cache,no-store
Content-Length: 1391
Server: Jetty(7.3.0.v20110203)
$ curl --user abcd:abCD1 -i http://localhost:8080
HTTP/1.1 401 Unauthorized
Content-Type: text/html;charset=ISO-8859-1
Cache-Control: must-revalidate,no-cache,no-store
Content-Length: 1371
Server: Jetty(7.3.0.v20110203)
I have tried to find the cause of this message, but have had little luck thus
far. I get no such warning for tests with malformed credentials (eg.
"u:ser:passwo:rd") or well-formed credentials for a user that does exist.
Original issue reported on code.google.com by [email protected]
on 3 Mar 2011 at 1:44
E.g. support for:
<greeting>
<name firstName="John" lastName="Doe" />
</greeting>
using expect().body("greeting.name.firstName", equalTo("John").
Original issue reported on code.google.com by [email protected]
on 25 Jan 2011 at 11:13
You cannot work with lists in XML parsing. E.g. get all items doesn't work.
E.g.
expect("rss.channel.item", ..) should return a list of all items but it only
returns the first. This needs to be fixed.
<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0">
<channel>
<title>something</title>
<link>http://www.someone.com</link>
<description>something RSS</description>
<dc:creator>someone</dc:creator>
<item>
<title>A title</title>
<link>http://www.something.com/link/1</link>
<description>Description 1</description>
<enclosure url="http://www.someone.com/somejpg.jpg" length="2721" type="image/jpg" />
<pubDate>Mon, 10 Jan 2011 19:31:46 GMT</pubDate>
<guid isPermaLink="false">http://www.something.com/link/1</guid>
<dc:date>2011-01-10T19:31:46Z</dc:date>
</item>
<item>
<title>Title 2</title>
<link>http://www.something.com/link/2</link>
<description>Description 2</description>
<enclosure url="http://www.someone.com/someotherjpg.jpg" length="2721" type="image/jpg" />
<pubDate>Mon, 10 Jan 2011 19:41:46 GMT</pubDate>
<guid isPermaLink="false">http://www.something.com/link/2</guid>
<dc:date>2011-01-10T19:42:46Z</dc:date>
</item>
</channel>
</rss>
Original issue reported on code.google.com by [email protected]
on 27 Jan 2011 at 9:15
E.g.
response.getStatusLine();
response.getStatusCode();
Original issue reported on code.google.com by [email protected]
on 4 Mar 2011 at 7:12
What steps will reproduce the problem?
Try to get the return of a HTTP 401 status code
What is the expected output? What do you see instead?
When we try this:
String returnStr = with().parameters("name", "tester", "paswoord",
"paswoord").post("/rest/authentication/validation/").asString();
It gives the following exception: java.lang.IllegalStateException: You cannot
use REST Assured expectations and return the response at the same time.
As we can see, we do not use an expectation but rather want the response.
What version of the product are you using? On what operating system?
1.1
Please provide any additional information below.
We have also tried:
String returnStr = with().parameters("name", "tester", "paswoord",
"paswoord").post("/rest/authentication/validation/").andReturn().body().asString
();
Original issue reported on code.google.com by [email protected]
on 2 Mar 2011 at 2:56
E.g. instead of doing:
expect().body(..).when().get("/servlet-mapping-name/getStuff");
expect().body(..).when().get("/servlet-mapping-name/getOtherStuff");
It would be nice to be able to do:
RestAssured.servletMapping = "/servlet-mapping-name"
and then:
expect().body(..).when().get("/getStuff");
expect().body(..).when().get("/getOtherStuff");
Original issue reported on code.google.com by [email protected]
on 13 Jan 2011 at 12:35
What steps will reproduce the problem?
1. Setting up a new project
2. Imported the 3 libraries as asked
3. When running the first test created the following exception happens
java.lang.SecurityException: class "org.hamcrest.Matchers"'s signer information
does not match signer information of other classes in the same package
at java.lang.ClassLoader.checkCerts(Unknown Source)
at java.lang.ClassLoader.preDefineClass(Unknown Source)
at java.lang.ClassLoader.defineClassCond(Unknown Source)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$000(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at com.jayway.restassured.internal.ResponseSpecificationImpl.class$(ResponseSpecificationImpl.groovy)
at com.jayway.restassured.internal.ResponseSpecificationImpl.$get$$class$org$hamcrest$Matchers(ResponseSpecificationImpl.groovy)
at com.jayway.restassured.internal.ResponseSpecificationImpl.statusCode(ResponseSpecificationImpl.groovy:76)
at test.java.SITRestTests.resttests.EM3GetTest.testEm3Rest(EM3GetTest.java:23)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:76)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:49)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
What is the expected output? What do you see instead?
What version of the product are you using? On what operating system?
The latest. Using eclipse in conjunction with junit.
Essentially no tests can run.
Please provide any additional information below.
Original issue reported on code.google.com by [email protected]
on 14 Mar 2011 at 4:59
Scala:
given parameters(map) do get("") and verify { json =>
assertEquals(json.johan.hello == "Hello Johan") }
Groovy:
get("").and().verify { response, json -> assertEquals json.code, "ikk" }
get("").and().verify { response -> assertEquals json.code, "ikk" } // Works!
get("").and().verifyResponse("statusLine.statusCode", equalTo(200));
get("").and().verifyResponse(STATUS_CODE, equalTo(200));
get("").and().verifyResponse(header(johan), equalTo(200));
Java:
expect().content("lotto.winners.winnerId", hasItems(23,
54)).when().get("/lotto");
expect().header("lotto.winners.winnerId", hasItems(23,
54)).when().get("/lotto");
expect().contentType(XML).
Original issue reported on code.google.com by [email protected]
on 27 Oct 2010 at 6:36
Implement
Original issue reported on code.google.com by [email protected]
on 26 Mar 2011 at 4:02
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
Given:
greeting.name.children() = [{attributes={}, children=[], value=John},
{attributes={}, children=[], value=Doe}]
Should allow for:
expect().body("greeting.name.children()", hasItems("John",
"Doe")).get("/anotherGreetXML")
I.e.:
children.containsKey("John") should return true
Original issue reported on code.google.com by [email protected]
on 14 Feb 2011 at 9:24
Instead of doing:
given().
body(..).
body(..).
body(..).
body(..).
body(..).
param(..).
expect().
body(..).
body(..).
body(..).
header(..).
when().
get(..);
it would be nice to able able to re-use. E.g.
given().
spec(requestSpec1).
spec(requestSpec2).
expect().
spec(responseSpec1).
spec(responseSpec2).
when().
get(..);
The specifications can be re-used in multiple tests.
Original issue reported on code.google.com by [email protected]
on 23 Mar 2011 at 6:46
E.g. instead of
expect().
body("x.y.firstName", is(..)).
body("x.y.lastName", is(..)).
body("x.y.age", is(..)).
body("x.y.gender", is(..)).
when().get(..);
You should be able to do something in the line of:
expect().
rootPath("x.y").
body("firstName", is(..)).
body("lastName", is(..)).
body("age", is(..)).
body("gender", is(..)).
when().get(..);
Original issue reported on code.google.com by [email protected]
on 23 Mar 2011 at 6:49
See dropbox for example
Original issue reported on code.google.com by [email protected]
on 17 Jan 2011 at 3:19
E.g.
print().get("/something");
print should set "text/plain" parsing and simply print the reponse to the
console. print() should return TestSpecification directly.
Original issue reported on code.google.com by [email protected]
on 13 Jan 2011 at 8:53
Add @ if not already defined
Original issue reported on code.google.com by [email protected]
on 18 Feb 2011 at 7:39
E.g. instead of
given().auth().basic("john", "doe").expect()..
given().auth().basic("john", "doe").expect()..
given().auth().basic("john", "doe").expect()..
you could do:
RestAssured.defaultAuth = basic("john", "doe");
Original issue reported on code.google.com by [email protected]
on 24 Jan 2011 at 11:31
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
E.g.
expect().body(constant(ITEMS, ADDRESS, STREET), equalTo("something").when()..
where ITEMS, ADDRESS, and STREET are pre-defined (by user) strings that build
up the . notation using String.format().
Original issue reported on code.google.com by [email protected]
on 18 Jan 2011 at 8:14
See dropbox
Original issue reported on code.google.com by [email protected]
on 27 Oct 2010 at 6:38
javadoc everything
Original issue reported on code.google.com by [email protected]
on 27 Oct 2010 at 4:18
Support verifying e.g. atom and rss as XML (e.g. when content type is
application/rss+xml)
Original issue reported on code.google.com by [email protected]
on 12 Jan 2011 at 1:55
We get an error message that you can't using exceptions when a response body
is empty.
E.g. get("/emptyBody").asString() throws exception if /emptyBody returns an
empty response body.
Original issue reported on code.google.com by [email protected]
on 25 Mar 2011 at 9:13
Allow this: get("/redirect?url="+url). Right now the "?" is url encoded.
Original issue reported on code.google.com by [email protected]
on 27 Jan 2011 at 1:02
get(0) and [] must be supported for JSONArray
Original issue reported on code.google.com by [email protected]
on 18 Jan 2011 at 8:55
E.g. if response mime type is text/plain but the content is XML you should be
able to parse it using the XML parser.
E.g.
expect(..).with().parser('application/xml').when().get(..)
Original issue reported on code.google.com by [email protected]
on 12 Jan 2011 at 8:10
E.g. "items.get(0).address.street" should also work with
"items[0].address.street"
Original issue reported on code.google.com by [email protected]
on 18 Jan 2011 at 8:13
E.g. RestAssured.followRedirects = false
Original issue reported on code.google.com by [email protected]
on 27 Jan 2011 at 1:14
Add support for getting headers in response object
Original issue reported on code.google.com by [email protected]
on 12 Feb 2011 at 8:45
Responses should be serialized to Objects if we have e.g. Jackson or Jersey in
CP. E.g.
get("/something").asObject(MyClass.class);
MyClass should be annotated with standard javax bind annotations (XmlElement).
Original issue reported on code.google.com by [email protected]
on 18 Jan 2011 at 9:00
e.g.
expectResponse(XML).and().get("/hello")..
Original issue reported on code.google.com by [email protected]
on 27 Oct 2010 at 4:18
Delete should support body content
Original issue reported on code.google.com by [email protected]
on 23 Mar 2011 at 3:53
Register the "XML" IANA (http://www.iana.org/assignments/media-types/) content
types as XML parsing. See
http://groovy.codehaus.org/modules/http-builder/doc/contentTypes.html for
details.
Original issue reported on code.google.com by [email protected]
on 13 Jan 2011 at 7:08
Allow:
get("/something").andPrintBody();
Implementation:
// pretty print format the response
def stringWriter = new StringWriter()
def node = new XmlParser().parseText(reader.text);
new XmlNodePrinter(new PrintWriter(stringWriter)).print(node)
return stringWriter.toString()
Only works for XML responses. Otherwise don't pretty print, just print.
The method should also return the (original or pretty?) body.
Original issue reported on code.google.com by [email protected]
on 16 Jan 2011 at 8:12
Filter out groovy stuff from error messages, e.g. when "get" on illegal path:
expect().body("validRoot.illegalChild.get(0)")..
Original issue reported on code.google.com by [email protected]
on 21 Feb 2011 at 2:31
when doing e.g.:
expect().body("something").when().get("/admin");
and /admin has content-type of application/xml we force text parsing by setting
the content-type header. This is bad because the server can then respond with a
406. What we should do is to change parser
(http://groovy.codehaus.org/modules/http-builder/doc/contentTypes.html) by:
http.parser.'application/xml' = http.parser.'text/plain'
http.parser.'application/json' = http.parser.'text/plain'
etc.
Original issue reported on code.google.com by [email protected]
on 13 Jan 2011 at 8:05
E.g. if having specified RestAssured.baseURI, basePath etc then doing:
get("http://someOtherBaseUri/x")
should not apply basePath etc.
Original issue reported on code.google.com by [email protected]
on 7 Mar 2011 at 3:36
do it
Original issue reported on code.google.com by [email protected]
on 23 Oct 2010 at 2:06
In Node and NodeChildren
Original issue reported on code.google.com by [email protected]
on 16 Feb 2011 at 7:19
Groovy impl:
def http = new HTTPBuilder('http://myhost.com')
http.headers[ 'Authorization' ] =
"$user:$pass".getBytes('iso-8859-1').encodeBase64()
Original issue reported on code.google.com by [email protected]
on 22 Mar 2011 at 3:21
E.g.
given().
param(x, y).
when().
get("/lotto").
then().
assertThat("lotto.lottoId", is(5));
Copy assertThat defs from JUnit.
get("/lotto") returns an AssertableResponse class which extends Response and
adds assertion capabilities.
Original issue reported on code.google.com by [email protected]
on 15 Mar 2011 at 12:23
E.g.
expect().bodyMatches(XTD).when().get("/something");
Original issue reported on code.google.com by [email protected]
on 13 Feb 2011 at 1:37
In Node and NodeChildren
Original issue reported on code.google.com by [email protected]
on 16 Feb 2011 at 7:19
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.