{"id":9257,"date":"2013-03-01T16:00:43","date_gmt":"2013-03-01T14:00:43","guid":{"rendered":"http:\/\/www.javacodegeeks.com\/?p=9257"},"modified":"2013-03-01T09:21:27","modified_gmt":"2013-03-01T07:21:27","slug":"java-rest-assured-or-rest-very-easy","status":"publish","type":"post","link":"https:\/\/www.javacodegeeks.com\/2013\/03\/java-rest-assured-or-rest-very-easy.html","title":{"rendered":"Java: Rest-assured (or Rest-Very-Easy)"},"content":{"rendered":"<p>Recently I had to write some Java code to <b><span style=\"text-decoration: underline;\">consume<\/span> REST services<\/b> over HTTP. I&#8217;ve decided to use the Client libraries of <a href=\"http:\/\/www.jboss.org\/resteasy\">RestEasy<\/a>, the framework I use most of the time to expose REST services in Java, since it also implements the official <b>JAX-RS<\/b> specification. I am very satisfied with the annotation driven approach that the specification defines and it makes exposing REST services a very pleasant task. But unluckily <b>I cannot say that I like the client API<\/b> the same way. If you are lucky enough to be able to build a proxy client based on the interface implemented by the service, well, that&#8217;s not bad:<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n&nbsp;<\/p>\n<pre class=\" brush:java\">import org.jboss.resteasy.client.ProxyFactory;\r\n...\r\n\/\/ this initialization only needs to be done once per VM\r\nRegisterBuiltin.register(ResteasyProviderFactory.getInstance());\r\n\r\nSimpleClient client = ProxyFactory.create(MyRestServiceInterface.class, 'http:\/\/localhost:8081');\r\nclient.myBusinessMethod('hello world');<\/pre>\n<p>Having a Proxy client similar to a JAX-WS one is good, I do agree. But <b>most of the time, when we are consuming REST web service we do not have a Java interface to import. <\/b>All those Twitter, Google or whatever public rest services available out there are just HTTP endpoints. The way to go with RestEasy in these cases is to rely on the RestEasy Manual ClientRequest API:<\/p>\n<pre class=\" brush:java\">ClientRequest request = new ClientRequest('http:\/\/localhost:8080\/some\/path');\r\nrequest.header('custom-header', 'value');\r\n\r\n\/\/ We're posting XML and a JAXB object\r\nrequest.body('application\/xml', someJaxb);\r\n\r\n\/\/ we're expecting a String back\r\nClientResponse&lt;String&gt; response = request.post(String.class);\r\n\r\nif (response.getStatus() == 200) \/\/ OK!\r\n{\r\n   String str = response.getEntity();\r\n}<\/pre>\n<p>That is in my opinion a very verbose way to fetch what is most of the time, just a bunch of strings from the web. And it gets even worse if you need to include Authentication informations:<\/p>\n<pre class=\" brush:java\">\/\/ Configure HttpClient to authenticate preemptively\r\n\/\/ by prepopulating the authentication data cache.\r\n\r\n\/\/ 1. Create AuthCache instance\r\nAuthCache authCache = new BasicAuthCache();\r\n\r\n\/\/ 2. Generate BASIC scheme object and add it to the local auth cache\r\nBasicScheme basicAuth = new BasicScheme();\r\nauthCache.put('com.bluemonkeydiamond.sippycups', basicAuth);\r\n\r\n\/\/ 3. Add AuthCache to the execution context\r\nBasicHttpContext localContext = new BasicHttpContext();\r\nlocalContext.setAttribute(ClientContext.AUTH_CACHE, authCache);\r\n\r\n\/\/ 4. Create client executor and proxy\r\nhttpClient = new DefaultHttpClient();\r\nApacheHttpClient4Executor executor = new ApacheHttpClient4Executor(httpClient, localContext);\r\nclient = ProxyFactory.create(BookStoreService.class, url, executor);<\/pre>\n<p>I have found that <b><a href=\"https:\/\/code.google.com\/p\/rest-assured\/\">Rest-assured<\/a><\/b> provide a much nicer API to write client invocations. Officially the aim of the project is to create a <b>testing and validating framework<\/b>; and most of the tutorials out there are covering those aspects, like the recent Heiko Rupp&#8217;s one: <a href=\"http:\/\/pilhuhn.blogspot.nl\/2013\/01\/testing-rest-apis-with-rest-assured.html\">http:\/\/pilhuhn.blogspot.nl\/2013\/01\/testing-rest-apis-with-rest-assured.html<\/a>. I suggest yout, instead, to <b>use it as a development tool to experiment and write REST invocation very rapidly.<\/b> What is important to know about rest-assured:<\/p>\n<ul>\n<li>it implements a <b>Domain Specific Language<\/b> thanks to <b>fluid API<\/b><\/li>\n<li>it is a <b>single Maven dependency<\/b><\/li>\n<li>it almost completely expose a <b>shared style for both xml and json<\/b> response objects<\/li>\n<li>it relies on <b>Apache Commons Client<\/b><\/li>\n<\/ul>\n<p>So, I&#8217;ll show you a bunch of real world use cases and I will leave you with some good link if you want to know more. As most of the DSL on Java, it works better if you <b>import statically the most important objects<\/b>:<div style=\"display:inline-block; margin: 15px 0;\"> <div id=\"adngin-JavaCodeGeeks_incontent_video-0\" style=\"display:inline-block;\"><\/div> <\/div><\/p>\n<pre class=\" brush:java\">import static   com.jayway.restassured.RestAssured.*;\r\nimport static   com.jayway.restassured.matcher.RestAssuredMatchers.*;<\/pre>\n<p>Base usage:<\/p>\n<pre class=\" brush:java\">get('http:\/\/api.twitter.com\/1\/users\/show.xml').asString();<\/pre>\n<p>That returns:<\/p>\n<pre class=\" brush:xml\">&lt;errors&gt;\r\n  &lt;error code=\"34\"&gt;Sorry, that page does not exist&lt;\/error&gt;\r\n&lt;\/errors&gt;<\/pre>\n<p>Uh oh, some <b>error<\/b>. Yeah, we need to pass some parameter:<\/p>\n<pre class=\" brush:java\">with()\r\n    .parameter('screen_name', 'resteasy')\r\n.get('http:\/\/api.twitter.com\/1\/users\/show.xml').asString();<\/pre>\n<p>That returns:<\/p>\n<pre class=\" brush:xml\">&lt;user&gt;\r\n  &lt;id&gt;27016395&lt;\/id&gt;\r\n  &lt;name&gt;Resteasy&lt;\/name&gt;\r\n  &lt;screen_name&gt;resteasy&lt;\/screen_name&gt;\r\n  &lt;location&gt;&lt;\/location&gt;\r\n  &lt;profile_image_url&gt;http:\/\/a0.twimg.com\/sticky\/default_profile_images\/default_profile_0_normal.png&lt;\/profile_image_url&gt;\r\n  &lt;profile_image_url_https&gt;https:\/\/si0.twimg.com\/sticky\/default_profile_images\/default_profile_0_normal.png&lt;\/profile_image_url_https&gt;\r\n  &lt;url&gt;&lt;\/url&gt;\r\n  &lt;description&gt;jboss.org\/resteasy\r\n \r\nJBoss\/Red Hat REST project&lt;\/description&gt;\r\n  &lt;protected&gt;false&lt;\/protected&gt;\r\n  &lt;followers_count&gt;244&lt;\/followers_count&gt;\r\n  &lt;profile_background_color&gt;C0DEED&lt;\/profile_background_color&gt;\r\n  &lt;profile_text_color&gt;333333&lt;\/profile_text_color&gt;\r\n  &lt;profile_link_color&gt;0084B4&lt;\/profile_link_color&gt;\r\n  &lt;profile_sidebar_fill_color&gt;DDEEF6&lt;\/profile_sidebar_fill_color&gt;\r\n  &lt;profile_sidebar_border_color&gt;C0DEED&lt;\/profile_sidebar_border_color&gt;\r\n  &lt;friends_count&gt;1&lt;\/friends_count&gt;\r\n  &lt;created_at&gt;Fri Mar 27 14:39:52 +0000 2009&lt;\/created_at&gt;\r\n  &lt;favourites_count&gt;0&lt;\/favourites_count&gt;\r\n  &lt;utc_offset&gt;&lt;\/utc_offset&gt;\r\n  &lt;time_zone&gt;&lt;\/time_zone&gt;\r\n  &lt;profile_background_image_url&gt;http:\/\/a0.twimg.com\/images\/themes\/theme1\/bg.png&lt;\/profile_background_image_url&gt;\r\n  &lt;profile_background_image_url_https&gt;https:\/\/si0.twimg.com\/images\/themes\/theme1\/bg.png&lt;\/profile_background_image_url_https&gt;\r\n  &lt;profile_background_tile&gt;false&lt;\/profile_background_tile&gt;\r\n  &lt;profile_use_background_image&gt;true&lt;\/profile_use_background_image&gt;\r\n  &lt;geo_enabled&gt;false&lt;\/geo_enabled&gt;\r\n  &lt;verified&gt;false&lt;\/verified&gt;\r\n  &lt;statuses_count&gt;8&lt;\/statuses_count&gt;\r\n  &lt;lang&gt;en&lt;\/lang&gt;\r\n  &lt;contributors_enabled&gt;false&lt;\/contributors_enabled&gt;\r\n  &lt;is_translator&gt;false&lt;\/is_translator&gt;\r\n  &lt;listed_count&gt;21&lt;\/listed_count&gt;\r\n  &lt;default_profile&gt;true&lt;\/default_profile&gt;\r\n  &lt;default_profile_image&gt;true&lt;\/default_profile_image&gt;\r\n...\r\n&lt;\/user&gt;<\/pre>\n<p>Much better! Now, let&#8217;s say that we want only <b>a token of this big String XML<\/b>:<\/p>\n<pre class=\" brush:java\">with()\r\n    .parameter('screen_name', 'resteasy')\r\n.get('http:\/\/api.twitter.com\/1\/users\/show.xml')\r\n    .path('user.profile_image_url')<\/pre>\n<p>And here&#8217;s our output:<\/p>\n<pre class=\" brush:xml\">http:\/\/a0.twimg.com\/sticky\/default_profile_images\/default_profile_0_normal.png<\/pre>\n<p>What if it was a <b>JSON<\/b> response?<\/p>\n<pre class=\" brush:java\">with()\r\n    .parameter('screen_name', 'resteasy')\r\n.get('http:\/\/api.twitter.com\/1\/users\/show.json')<\/pre>\n<p>And here&#8217;s our output:<\/p>\n<pre style=\"background-image: URL(http:\/\/2.bp.blogspot.com\/_z5ltvMQPaa8\/SjJXr_U2YBI\/AAAAAAAAAAM\/46OqEP32CJ8\/s320\/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;\">\r\n<code style=\"color: black; word-wrap: normal;\">{\"id\":27016395,\"id_str\":\"27016395\",\"name\":\"Resteasy\",\"screen_name\":\"resteasy\",\"location\":\"\",\"url\":null,\"description\":\"jboss.org\\\/resteasy\\n\\nJBoss\\\/Red Hat REST project\",\"protected\":false,\"followers_count\":244,\"friends_count\":1,\"listed_count\":21,\"created_at\":\"Fri Mar 27 14:39:52 +0000 2009\",\"favourites_count\":0,\"utc_offset\":null,\"time_zone\":null,\"geo_enabled\":false,\"verified\":false,\"statuses_count\":8,\"lang\":\"en\",\"status\":{\"created_at\":\"Tue Mar 23 14:48:51 +0000 2010\",\"id\":10928528312,\"id_str\":\"10928528312\",\"text\":\"Doing free webinar tomorrow on REST, JAX-RS, RESTEasy, and REST-*.  Only 40 min, so its brief.  http:\\\/\\\/tinyurl.com\\\/yz6xwek\",\"source\":\"web\",\"truncated\":false,\"in_reply_to_status_id\":null,\"in_reply_to_status_id_str\":null,\"in_reply_to_user_id\":null,\"in_reply_to_user_id_str\":null,\"in_reply_to_screen_name\":null,\"geo\":null,\"coordinates\":null,\"place\":null,\"contributors\":null,\"retweet_count\":0,\"favorited\":false,\"retweeted\":false},\"contributors_enabled\":false,\"is_translator\":false,\"profile_background_color\":\"C0DEED\",\"profile_background_image_url\":\"http:\\\/\\\/a0.twimg.com\\\/images\\\/themes\\\/theme1\\\/bg.png\",\"profile_background_image_url_https\":\"https:\\\/\\\/si0.twimg.com\\\/images\\\/themes\\\/theme1\\\/bg.png\",\"profile_background_tile\":false,\"profile_image_url\":\"http:\\\/\\\/a0.twimg.com\\\/sticky\\\/default_profile_images\\\/default_profile_0_normal.png\",\"profile_image_url_https\":\"https:\\\/\\\/si0.twimg.com\\\/sticky\\\/default_profile_images\\\/default_profile_0_normal.png\",\"profile_link_color\":\"0084B4\",\"profile_sidebar_border_color\":\"C0DEED\",\"profile_sidebar_fill_color\":\"DDEEF6\",\"profile_text_color\":\"333333\",\"profile_use_background_image\":true,\"default_profile\":true,\"default_profile_image\":true,\"following\":null,\"follow_request_sent\":null,\"notifications\":null}<\/code><\/pre>\n<p>And <b>the same interface undestands JSON object navigation.<\/b> Note that the navigation expression does not include &#8216;user&#8217; since it was not there in the full json response:<\/p>\n<pre class=\" brush:java\">with()\r\n    .parameter('screen_name', 'resteasy')\r\n.get('http:\/\/api.twitter.com\/1\/users\/show.json')\r\n    .path('profile_image_url')<\/pre>\n<p>And here&#8217;s our output:<\/p>\n<pre class=\" brush:xml\">http:\/\/a0.twimg.com\/sticky\/default_profile_images\/default_profile_0_normal.png<\/pre>\n<p>Now an example of <b>Path Parameters<\/b>:<\/p>\n<pre class=\" brush:java\">with()\r\n    .parameter('key', 'HomoSapiens')\r\n.get('http:\/\/eol.org\/api\/search\/{key}').asString()<\/pre>\n<p>Information about the <b>http request<\/b>:<\/p>\n<pre class=\" brush:java\">get('http:\/\/api.twitter.com\/1\/users\/show.xml').statusCode();\r\nget('http:\/\/api.twitter.com\/1\/users\/show.xml').statusLine();<\/pre>\n<p>An example of <b>Basic Authentication<\/b>:<\/p>\n<pre class=\" brush:java\">with()\r\n  .auth().basic('paolo', 'xxxx')\r\n.get('http:\/\/localhost:8080\/b\/secured\/hello')\r\n  .statusLine()<\/pre>\n<p>An example of <b>Multipart Form Upload <\/b><\/p>\n<pre class=\" brush:java\">with()\r\n    .multiPart('file', 'test.txt', fileContent.getBytes())\r\n.post('\/upload')<\/pre>\n<p><b>Maven dependency<\/b>:<\/p>\n<pre class=\" brush:xml\">&lt;dependency&gt;\r\n &lt;groupid&gt;com.jayway.restassured&lt;\/groupid&gt;\r\n &lt;artifactid&gt;rest-assured&lt;\/artifactid&gt;\r\n &lt;version&gt;1.4&lt;\/version&gt;\r\n &lt;scope&gt;test&lt;\/scope&gt;\r\n&lt;\/dependency&gt;\r\n<\/pre>\n<p>And a <b>Groovy snippet<\/b> that can be pasted and executed directly in <b>groovyConsole<\/b> thanks to <b>Grapes<\/b> fetches the dependencies and add them automatically to the classpath, that shows you <b>JAXB<\/b> support:<\/p>\n<pre class=\" brush:java\">@Grapes([  \r\n    @Grab('com.jayway.restassured:rest-assured:1.7.2')\r\n])\r\nimport static   com.jayway.restassured.RestAssured.*\r\nimport static   com.jayway.restassured.matcher.RestAssuredMatchers.*\r\nimport  javax.xml.bind.annotation.*\r\n\r\n@XmlRootElement(name = 'user')\r\n@XmlAccessorType( XmlAccessType.FIELD )\r\n    class TwitterUser {\r\n        String id;\r\n        String name;\r\n        String description;\r\n        String location;\r\n\r\n        @Override\r\n        String toString() {\r\n            return 'Id: $id, Name: $name, Description: $description, Location: $location'\r\n        }\r\n\r\n    }\r\n\r\nprintln with().parameter('screen_name', 'resteasy').get('http:\/\/api.twitter.com\/1\/users\/show.xml').as(TwitterUser.class)\r\n\r\n\/\/<\/pre>\n<p>This is just a brief list of the features of the library, just you an idea of how easy it is to work with it. For a further examples I suggest you to read the official pages here: <a href=\"https:\/\/code.google.com\/p\/rest-assured\/wiki\/Usage\">https:\/\/code.google.com\/p\/rest-assured\/wiki\/Usage<\/a>. Or another good tutorial here with a sample application to play with: <a href=\"http:\/\/www.hascode.com\/2011\/10\/testing-restful-web-services-made-easy-using-the-rest-assured-framework\">http:\/\/www.hascode.com\/2011\/10\/testing-restful-web-services-made-easy-using-the-rest-assured-framework<\/a><br \/>\n&nbsp;<\/p>\n<p><b><i>Reference: <\/i><\/b><a href=\"http:\/\/giallone.blogspot.gr\/2013\/01\/java-rest-assured-or-rest-very-easy.html\">Java: Rest-assured (or Rest-Very-Easy)<\/a> from our <a href=\"http:\/\/www.javacodegeeks.com\/p\/jcg.html\">JCG partner<\/a> Paolo Antinori at the <a href=\"http:\/\/giallone.blogspot.gr\/\">Someday Never Comes<\/a> blog.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Recently I had to write some Java code to consume REST services over HTTP. I&#8217;ve decided to use the Client libraries of RestEasy, the framework I use most of the time to expose REST services in Java, since it also implements the official JAX-RS specification. I am very satisfied with the annotation driven approach that &hellip;<\/p>\n","protected":false},"author":363,"featured_media":160,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[135,54],"class_list":["post-9257","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-enterprise-java","tag-jboss-resteasy","tag-restful-web-services"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Java: Rest-assured (or Rest-Very-Easy)<\/title>\n<meta name=\"description\" content=\"Recently I had to write some Java code to consume REST services over HTTP. I&#039;ve decided to use the Client libraries of RestEasy, the framework I use most\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.javacodegeeks.com\/2013\/03\/java-rest-assured-or-rest-very-easy.html\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Java: Rest-assured (or Rest-Very-Easy)\" \/>\n<meta property=\"og:description\" content=\"Recently I had to write some Java code to consume REST services over HTTP. I&#039;ve decided to use the Client libraries of RestEasy, the framework I use most\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.javacodegeeks.com\/2013\/03\/java-rest-assured-or-rest-very-easy.html\" \/>\n<meta property=\"og:site_name\" content=\"Java Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/javacodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2013-03-01T14:00:43+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/jboss-resteasy-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Paolo Antinori\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:site\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Paolo Antinori\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"8 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/03\\\/java-rest-assured-or-rest-very-easy.html#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/03\\\/java-rest-assured-or-rest-very-easy.html\"},\"author\":{\"name\":\"Paolo Antinori\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/cdb2d8037b6869b611f348274bc6b719\"},\"headline\":\"Java: Rest-assured (or Rest-Very-Easy)\",\"datePublished\":\"2013-03-01T14:00:43+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/03\\\/java-rest-assured-or-rest-very-easy.html\"},\"wordCount\":600,\"commentCount\":1,\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/03\\\/java-rest-assured-or-rest-very-easy.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/jboss-resteasy-logo.jpg\",\"keywords\":[\"JBoss RESTEasy\",\"RESTful Web Services\"],\"articleSection\":[\"Enterprise Java\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/03\\\/java-rest-assured-or-rest-very-easy.html#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/03\\\/java-rest-assured-or-rest-very-easy.html\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/03\\\/java-rest-assured-or-rest-very-easy.html\",\"name\":\"Java: Rest-assured (or Rest-Very-Easy)\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/03\\\/java-rest-assured-or-rest-very-easy.html#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/03\\\/java-rest-assured-or-rest-very-easy.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/jboss-resteasy-logo.jpg\",\"datePublished\":\"2013-03-01T14:00:43+00:00\",\"description\":\"Recently I had to write some Java code to consume REST services over HTTP. I've decided to use the Client libraries of RestEasy, the framework I use most\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/03\\\/java-rest-assured-or-rest-very-easy.html#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/03\\\/java-rest-assured-or-rest-very-easy.html\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/03\\\/java-rest-assured-or-rest-very-easy.html#primaryimage\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/jboss-resteasy-logo.jpg\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/jboss-resteasy-logo.jpg\",\"width\":150,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/03\\\/java-rest-assured-or-rest-very-easy.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Java\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/java\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Enterprise Java\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/java\\\/enterprise-java\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Java: Rest-assured (or Rest-Very-Easy)\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"name\":\"Java Code Geeks\",\"description\":\"Java Developers Resource Center\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"alternateName\":\"JCG\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.javacodegeeks.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/javacodegeeks\",\"https:\\\/\\\/x.com\\\/javacodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/cdb2d8037b6869b611f348274bc6b719\",\"name\":\"Paolo Antinori\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/211bb365c4be46d0753fb843ae41247013e293c8d0ab329804e859e58f3ab335?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/211bb365c4be46d0753fb843ae41247013e293c8d0ab329804e859e58f3ab335?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/211bb365c4be46d0753fb843ae41247013e293c8d0ab329804e859e58f3ab335?s=96&d=mm&r=g\",\"caption\":\"Paolo Antinori\"},\"sameAs\":[\"http:\\\/\\\/giallone.blogspot.gr\\\/\"],\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/author\\\/paolo-antinori\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Java: Rest-assured (or Rest-Very-Easy)","description":"Recently I had to write some Java code to consume REST services over HTTP. I've decided to use the Client libraries of RestEasy, the framework I use most","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.javacodegeeks.com\/2013\/03\/java-rest-assured-or-rest-very-easy.html","og_locale":"en_US","og_type":"article","og_title":"Java: Rest-assured (or Rest-Very-Easy)","og_description":"Recently I had to write some Java code to consume REST services over HTTP. I've decided to use the Client libraries of RestEasy, the framework I use most","og_url":"https:\/\/www.javacodegeeks.com\/2013\/03\/java-rest-assured-or-rest-very-easy.html","og_site_name":"Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_published_time":"2013-03-01T14:00:43+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/jboss-resteasy-logo.jpg","type":"image\/jpeg"}],"author":"Paolo Antinori","twitter_card":"summary_large_image","twitter_creator":"@javacodegeeks","twitter_site":"@javacodegeeks","twitter_misc":{"Written by":"Paolo Antinori","Est. reading time":"8 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.javacodegeeks.com\/2013\/03\/java-rest-assured-or-rest-very-easy.html#article","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/2013\/03\/java-rest-assured-or-rest-very-easy.html"},"author":{"name":"Paolo Antinori","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/cdb2d8037b6869b611f348274bc6b719"},"headline":"Java: Rest-assured (or Rest-Very-Easy)","datePublished":"2013-03-01T14:00:43+00:00","mainEntityOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2013\/03\/java-rest-assured-or-rest-very-easy.html"},"wordCount":600,"commentCount":1,"publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2013\/03\/java-rest-assured-or-rest-very-easy.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/jboss-resteasy-logo.jpg","keywords":["JBoss RESTEasy","RESTful Web Services"],"articleSection":["Enterprise Java"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.javacodegeeks.com\/2013\/03\/java-rest-assured-or-rest-very-easy.html#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.javacodegeeks.com\/2013\/03\/java-rest-assured-or-rest-very-easy.html","url":"https:\/\/www.javacodegeeks.com\/2013\/03\/java-rest-assured-or-rest-very-easy.html","name":"Java: Rest-assured (or Rest-Very-Easy)","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2013\/03\/java-rest-assured-or-rest-very-easy.html#primaryimage"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2013\/03\/java-rest-assured-or-rest-very-easy.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/jboss-resteasy-logo.jpg","datePublished":"2013-03-01T14:00:43+00:00","description":"Recently I had to write some Java code to consume REST services over HTTP. I've decided to use the Client libraries of RestEasy, the framework I use most","breadcrumb":{"@id":"https:\/\/www.javacodegeeks.com\/2013\/03\/java-rest-assured-or-rest-very-easy.html#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.javacodegeeks.com\/2013\/03\/java-rest-assured-or-rest-very-easy.html"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/2013\/03\/java-rest-assured-or-rest-very-easy.html#primaryimage","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/jboss-resteasy-logo.jpg","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/jboss-resteasy-logo.jpg","width":150,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/www.javacodegeeks.com\/2013\/03\/java-rest-assured-or-rest-very-easy.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.javacodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"Java","item":"https:\/\/www.javacodegeeks.com\/category\/java"},{"@type":"ListItem","position":3,"name":"Enterprise Java","item":"https:\/\/www.javacodegeeks.com\/category\/java\/enterprise-java"},{"@type":"ListItem","position":4,"name":"Java: Rest-assured (or Rest-Very-Easy)"}]},{"@type":"WebSite","@id":"https:\/\/www.javacodegeeks.com\/#website","url":"https:\/\/www.javacodegeeks.com\/","name":"Java Code Geeks","description":"Java Developers Resource Center","publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"alternateName":"JCG","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.javacodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.javacodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/www.javacodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/javacodegeeks","https:\/\/x.com\/javacodegeeks"]},{"@type":"Person","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/cdb2d8037b6869b611f348274bc6b719","name":"Paolo Antinori","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/211bb365c4be46d0753fb843ae41247013e293c8d0ab329804e859e58f3ab335?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/211bb365c4be46d0753fb843ae41247013e293c8d0ab329804e859e58f3ab335?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/211bb365c4be46d0753fb843ae41247013e293c8d0ab329804e859e58f3ab335?s=96&d=mm&r=g","caption":"Paolo Antinori"},"sameAs":["http:\/\/giallone.blogspot.gr\/"],"url":"https:\/\/www.javacodegeeks.com\/author\/paolo-antinori"}]}},"_links":{"self":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/9257","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/users\/363"}],"replies":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/comments?post=9257"}],"version-history":[{"count":0,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/9257\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media\/160"}],"wp:attachment":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media?parent=9257"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=9257"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=9257"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}