{"id":847,"date":"2015-05-20T08:54:16","date_gmt":"2015-05-20T17:54:16","guid":{"rendered":"http:\/\/blog.box.kr\/?p=847"},"modified":"2015-05-20T08:54:16","modified_gmt":"2015-05-20T17:54:16","slug":"scrapautomated-testing-of-rest-services","status":"publish","type":"post","link":"https:\/\/blog.box.kr\/?p=847","title":{"rendered":"[scrap]Automated Testing of REST Services"},"content":{"rendered":"<p><a href=\"http:\/\/java.dzone.com\/articles\/automated-testing-rest?utm_content=buffer084c1&amp;utm_medium=social&amp;utm_source=facebook.com&amp;utm_campaign=buffer\">http:\/\/java.dzone.com\/articles\/automated-testing-rest?utm_content=buffer084c1&amp;utm_medium=social&amp;utm_source=facebook.com&amp;utm_campaign=buffer<\/a><\/p>\n<p>&nbsp;<\/p>\n<div class=\"content\">\n<p>Despite the fact that I\u2019m a Java and Scala developer I still passionate about testing software, to be more precise\u2013 web applications. It\u2019s really interesting to develop web app and be confident that the apps are of good quality.<\/p>\n<p>When I\u2019ve started a career the most popular web architecture was MVC (Model View Control) and that was pretty simple. When you develop some business logic you have to write some unit tests which check a functionality of internal controller functions and this is enough. Integration tests were more complex task at that time because such tests imply usage of some mock frameworks.<\/p>\n<p>But the time moves on. And the old MVC architecture has become insufficient for numerous client types such as smartphones, tablets, browsers.\u00a0<strong>REST architecture\u00a0<\/strong>started to substitute the MVC pattern. More and more apps started use one API to communicate with different clients via HTTP. This circumstance was more then innovative. Because all business logic related to data and data processing was concentrated on servers meanwhile the client-side was responsible for representation of the data and some extra manipulation with it.<br \/>\nAs you probably guessed I just described a principles which are used in a Single Page Application approach (SPA). In this manner built a lot of modern apps Facebook, Instagram, Twitter.<\/p>\n<p>While developers have changed their apps, the ways of testing were mutate too. As a result appeared a new layer on which testing was not just applicable but was very efficient. I talk exactly about API layer. Since an API is consumed by different clients (smartphones, desktops\u2026), make sense to gather a group of tests which check a common logic for all types of clients and to highlight the client-specific test scenarios to focus on a client specific logic. The logic works with data which was already tested in API layer.<\/p>\n<p>Such approach gives us an amazing testing strategy. Testers save time, because they do not need to repeat tests on different clients by interacting with already tested data sets. They just need to pay all attention to a UI and some specific features.<\/p>\n<h3>Automated testing of REST-services<\/h3>\n<p>In my own experience I perform testing of REST API layer by writing automated test scripts. For this purpose I use\u00a0<strong>REST-assured<\/strong>\u00a0library developed by JayWay company. This java library is really strong weapon for automated testing of REST-services.<\/p>\n<p>The code of such tests looks really nice:<\/p>\n<div id=\"highlighter_729807\" class=\"syntaxhighlighter \">\n<div class=\"bar\">\n<div class=\"toolbar\"><a class=\"item viewSource\" title=\"view source\" href=\"http:\/\/java.dzone.com\/articles\/automated-testing-rest?utm_content=buffer084c1&amp;utm_medium=social&amp;utm_source=facebook.com&amp;utm_campaign=buffer#viewSource\">view source<\/a><\/p>\n<div class=\"item copyToClipboard\">\n<\/div>\n<p><a class=\"item printSource\" title=\"print\" href=\"http:\/\/java.dzone.com\/articles\/automated-testing-rest?utm_content=buffer084c1&amp;utm_medium=social&amp;utm_source=facebook.com&amp;utm_campaign=buffer#printSource\">print<\/a><a class=\"item about\" title=\"?\" href=\"http:\/\/java.dzone.com\/articles\/automated-testing-rest?utm_content=buffer084c1&amp;utm_medium=social&amp;utm_source=facebook.com&amp;utm_campaign=buffer#about\">?<\/a>\n<\/div>\n<\/div>\n<div class=\"lines\">\n<div class=\"line alt1\"><code class=\"number\">01.<\/code><span class=\"content\"><span class=\"block\"><code class=\"plain\">@Test<\/code><\/span><\/span>\n<\/div>\n<div class=\"line alt2\"><code class=\"number\">02.<\/code><span class=\"content\"><span class=\"block\"><code class=\"keyword\">public<\/code> <code class=\"keyword\">void<\/code> <code class=\"plain\">getLandLaordTest() {<\/code><\/span><\/span>\n<\/div>\n<div class=\"line alt1\"><code class=\"number\">03.<\/code><span class=\"content\"><span class=\"block\"><code class=\"plain\">given()<\/code><\/span><\/span>\n<\/div>\n<div class=\"line alt2\"><code class=\"number\">04.<\/code><span class=\"content\"><span class=\"block\"><code class=\"plain\">.contentType(ContentType.JSON)<\/code><\/span><\/span>\n<\/div>\n<div class=\"line alt1\"><code class=\"number\">05.<\/code><span class=\"content\"><span class=\"block\"><code class=\"plain\">.pathParam(<\/code><code class=\"string\">\"id\"<\/code><code class=\"plain\">, <\/code><code class=\"string\">\"DoYlvMXN\"<\/code><code class=\"plain\">)<\/code><\/span><\/span>\n<\/div>\n<div class=\"line alt2\"><code class=\"number\">06.<\/code><span class=\"content\"><span class=\"block\"><code class=\"plain\">.when()<\/code><\/span><\/span>\n<\/div>\n<div class=\"line alt1\"><code class=\"number\">07.<\/code><span class=\"content\"><span class=\"block\"><code class=\"plain\">.<\/code><code class=\"keyword\">get<\/code><code class=\"plain\">(<\/code><code class=\"string\">\"\/landlords\/{id}\"<\/code><code class=\"plain\">)<\/code><\/span><\/span>\n<\/div>\n<div class=\"line alt2\"><code class=\"number\">08.<\/code><span class=\"content\"><span class=\"block\"><code class=\"plain\">.then()<\/code><\/span><\/span>\n<\/div>\n<div class=\"line alt1\"><code class=\"number\">09.<\/code><span class=\"content\"><span class=\"block\"><code class=\"plain\">.statusCode(<\/code><code class=\"value\">200<\/code><code class=\"plain\">)<\/code><\/span><\/span>\n<\/div>\n<div class=\"line alt2\"><code class=\"number\">10.<\/code><span class=\"content\"><span class=\"block\"><code class=\"plain\">.body(<\/code><code class=\"string\">\"firstName\"<\/code><code class=\"plain\">, equalTo(<\/code><code class=\"string\">\"Sam\"<\/code><code class=\"plain\">))<\/code><\/span><\/span>\n<\/div>\n<div class=\"line alt1\"><code class=\"number\">11.<\/code><span class=\"content\"><span class=\"block\"><code class=\"plain\">.body(<\/code><code class=\"string\">\"trusted\"<\/code><code class=\"plain\">, equalTo(<\/code><code class=\"keyword\">false<\/code><code class=\"plain\">));<\/code><\/span><\/span>\n<\/div>\n<div class=\"line alt2\"><code class=\"number\">12.<\/code><span class=\"content\"><span class=\"block\"><code class=\"plain\">}<\/code><\/span><\/span>\n<\/div>\n<\/div>\n<\/div>\n<p>It\u2019s pretty concise and not verbose at all. One more advantage of REST-assured usage in a java projects is its simplicity. I\u00a0<a href=\"https:\/\/www.udemy.com\/automation-testing-rest-services\/?couponCode=regular\" target=\"_blank\">can teach any member<\/a>\u00a0of my team to develop such tests in a 3-4 hours. Also it works well with the most popular java testing frameworks such as TestNG, JUnit and Hamcrest.<\/p>\n<h3>Summary<\/h3>\n<p>I recommend to test code you write because it lifts you on a next level of software development competences. Automating of work is a key to success and investment in saved time.<\/p>\n<div>\n<\/div>\n<\/div>\n<p><span class=\"acknowledgement\">Published at DZone with permission of <a href=\"http:\/\/java.dzone.com\/users\/alexzvolinskiy\">Alexey Zvolinskiy<\/a>, author and DZone MVB. (<a href=\"http:\/\/fruzenshtein.com\/automated-testing-of-rest-services\/\" target=\"_blank\">source<\/a>)<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>http:\/\/java.dzone.com\/articles\/automated-testing-rest?utm_content=buffer084c1&amp;utm_medium=social&amp;utm_source=facebook.com&amp;utm_campaign=buffer &nbsp; Despite the fact that I\u2019m a Java and Scala developer I still passionate about testing software, to be more precise\u2013 web applications. It\u2019s really interesting to develop web app and be confident that the apps are of good quality. When I\u2019ve started a career the most popular web architecture was MVC (Model View Control) and that was pretty simple. When you develop some business logic you have to write some unit tests which check a functionality of internal controller functions and this is enough. Integration tests were more complex task at that time because such tests imply usage of some mock frameworks. But the time moves on. And the old MVC architecture has become insufficient for numerous client types such as smartphones, tablets, browsers.\u00a0REST architecture\u00a0started to substitute the MVC pattern. More and more apps started use one API to communicate with different clients via HTTP. This circumstance was more then innovative. Because all business logic related to data and data processing was concentrated on servers meanwhile the client-side was responsible for representation of the data and some extra manipulation with it. As you probably guessed I just described a principles which are used in a Single Page Application [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_mi_skip_tracking":false,"ngg_post_thumbnail":0,"spay_email":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true},"categories":[4,5],"tags":[],"aioseo_notices":[],"jetpack_featured_media_url":"","jetpack_publicize_connections":[],"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p5q9Zn-dF","jetpack-related-posts":[{"id":553,"url":"https:\/\/blog.box.kr\/?p=553","url_meta":{"origin":847,"position":0},"title":"site Links&#8230;","date":"2015-01-25","format":false,"excerpt":"NHN Cloud \uc11c\ube44\uc2a4 \u00a0: \u00a0\u00a0http:\/\/cloud.toast.com\/ URQA \uc11c\ube44\uc2a4 :\u00a0http:\/\/urqa.io\/urqa\/ URQA OpenSource : https:\/\/github.com\/search?utf8=%E2%9C%93&q=URQA APACHE CORDOVA \u00a0: http:\/\/cordova.apache.org\/ AngularJS-MVC-Repository \u00a0: http:\/\/www.codeproject.com\/Articles\/869433\/AngularJS-MVC-Repository dither algorithm foundations :\u00a0http:\/\/blog.danielepiccone.com\/post\/46328916747\/image-processing-dither-algorithm-foundations (Dithering)\uc774\ub780\u00a0PDF :\u00a0\u00a0https:\/\/www.google.co.kr\/url?sa=t&rct=j&q=&esrc=s&source=web&cd=12&ved=0CCEQFjABOAo&url=http%3A%2F%2Fcfile3.uf.tistory.com%2Fattach%2F1519C21349B14149387C6B&ei=-xDHVOWyFsOymAX80IKIAg&usg=AFQjCNHVgi8dVuY1c7eFzVjDTeKhNM6wPA&bvm=bv.84349003,d.dGY&cad=rjt \u00a0 IT PDF\ucc45 :\u00a0http:\/\/www.onlineprogrammingbooks.com\/cplusplus\/ IT PDF\ucc45 :\u00a0http:\/\/www.e-booksdirectory.com\/","rel":"","context":"In &quot;\uae30\uc220&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":899,"url":"https:\/\/blog.box.kr\/?p=899","url_meta":{"origin":847,"position":1},"title":"Cassandra cpp driver install","date":"2015-06-16","format":false,"excerpt":"http:\/\/datastax.github.io\/cpp-driver\/topics\/building\/ \u00a0 Building Supported Platforms The driver is known to work on CentOS\/RHEL 5\/6\/7, Mac OS X 10.8\/10.9 (Mavericks and Yosemite), Ubuntu 12.04\/14.04 LTS, and Windows 7 SP1. It has been built using GCC 4.1.2+, Clang 3.4+, and MSVC 2010\/2012\/2013. Dependencies Driver CMake libuv (1.x or 0.10.x) OpenSSL (optional) NOTE:\u2026","rel":"","context":"In &quot;\uae30\uc220&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":367,"url":"https:\/\/blog.box.kr\/?p=367","url_meta":{"origin":847,"position":2},"title":"[\ud38c]Scala \uc2dc\uc791\ud558\uae30","date":"2014-09-15","format":false,"excerpt":"\u00a0 http:\/\/ppassa.wordpress.com\/2012\/02\/19\/getting_started_scala\/ Scala \uc2dc\uc791\ud558\uae30 \uc694\uc998 \ub4e4\uc5b4\uc11c\u00a0Scala\ub97c \uacf5\ubd80\ud558\uace0 \uc788\ub2e4. \uc544\uc9c1 \ub9ce\uc774 \ubd80\uc871\ud558\uc9c0\ub9cc, \uc9c0\uae08\uae4c\uc9c0 \ubc30\uc6b4 \uac83\ub4e4 \uae30\ub85d\ud574\ub450\uace0, \ub610 \ud639\uc2dc \uc870\uae08\uc774\ub77c\ub3c4 \ub3c4\uc6c0\uc774 \ub418\ub294 \ubd84\ub4e4\uc774 \uc788\uc744 \uc9c0 \ubab0\ub77c \uacf5\uc720\ud574\ubcf4\uace0\uc790 \ud55c\ub2e4. 1. \ub4e4\uc5b4\uac00\uba70 \ubb58 \ub610 \ubc30\uc6cc\uc57c \ud55c\ub2e8 \ub9d0\uc778\uac00? \uc774\ubbf8 C++, Java, Python, Ruby, JavaScript \ub4f1 \ub9ce\uc740 \ud504\ub85c\uadf8\ub798\ubc0d \uc5b8\uc5b4\ub4e4\uc774 \uc788\ub294\ub370, \uc65c \uc790\uafb8 \uc0c8\ub85c\uc6b4 \uc5b8\uc5b4\uac00 \ub098\uc624\uace0 \uc788\ub0d0?\u2026","rel":"","context":"In &quot;\ucc38\uace0\ub97c \uc704\ud55c \uc800\uc7a5\ubb3c&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":673,"url":"https:\/\/blog.box.kr\/?p=673","url_meta":{"origin":847,"position":3},"title":"[Linux]Install MariaDB 10.0 on CentOS linux using YUM command","date":"2015-04-13","format":false,"excerpt":"Adding the MariaDB YUM Repository We highly recommended to use custom\u00a0MariaDB YUM\u00a0repository to install. Create a repo file under\/etc\/yum.repos.d\/MariaDB.repo, Copy and paste following line under MariaDB repository: Add repository on Centos 6.5 32-bit # vi \/etc\/yum.repos.d\/MariaDB.repo and paste following line: # MariaDB 10.0 CentOS repository list - created 2014-03-12 12:46\u2026","rel":"","context":"In &quot;\uae30\uc220\uc790\ub8cc&quot;","img":{"alt_text":"Connect to MariaDB 10.0","src":"https:\/\/i0.wp.com\/lintut.com\/wp-content\/uploads\/2014\/03\/639x352xScreenshot-from-2014-03-12-141810.png.pagespeed.ic.DHQ-h4Kmpx.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":691,"url":"https:\/\/blog.box.kr\/?p=691","url_meta":{"origin":847,"position":4},"title":"[Linux] Nginx\uc124\uce58 \ud6c4 Home Directory\uc758 Owner\ub3c4 \uac19\uace0 file permission \ub3c4 \ud588\ub294\ub370 permission error\uac00 \ub0a0\ub54c","date":"2015-04-15","format":false,"excerpt":"SELinux\ub77c\ub294 \uac1c\ub150\uc774 RHEL5 \ubd80\ud130 \ub4e4\uc5b4 \uc654\ub2e4\uace0 \ud55c\ub2e4 \uc57d\uc790\ub294 Security Enhanced Linux \ub780\ub2e4.. \ubcc4\uc758 \ubcc4\uc9d3\uc744 \ub2e4 \ud574\ub3c4 \uacc4\uc18d \uc801\uc73c\ub85c access dined error\uac00 \ub098\uc654\ub294\ub370 \uc544\ub798\ucc98\ub7fc SELinux\uc758 Mode\ub97c \ubc14\uafd4\uc8fc\uba74 \ud574\uacb0 \ub41c\ub2e4.. \ub2e8, \ubcf4\uc548\uc740 \uc880 \ucde8\uc57d\ud574 \uc9c0\ub294 \uc57d\uc810\uc774 \uc788\ub2e8\ub2e4.. \uadf8\ub7fc.. \ud574\uacb0\ud560 \uc218 \uc788\ub294 \ubc29\ubc95\uc740?? \uc77c\ub2e8 \ub354 \ucc3e\uc544 \ubd10\uc57c \ud560\uac70 \uac19\ub2e4.. If you still see\u2026","rel":"","context":"In &quot;\uae30\uc220\uc790\ub8cc&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":849,"url":"https:\/\/blog.box.kr\/?p=849","url_meta":{"origin":847,"position":5},"title":"[scrap]Introduction to Apache Cassandra&#039;s Architecture","date":"2015-05-20","format":false,"excerpt":"http:\/\/java.dzone.com\/articles\/introduction-apache-cassandras?utm_content=bufferb199d&utm_medium=social&utm_source=facebook.com&utm_campaign=buffer \u00a0 Introduction An Introduction To NoSQL & Apache Cassandra, introduced us to various types of NoSQL database and Apache Cassandra. In this article I am going to delve into Cassandra\u2019s Architecture. Cassandra is a peer-to-peer distributed database that runs on a cluster of homogeneous nodes. Cassandra has been architected\u2026","rel":"","context":"In &quot;\uae30\uc220&quot;","img":{"alt_text":"Cassandra Ring","src":"https:\/\/i0.wp.com\/abiasforaction.net\/wp-content\/uploads\/2015\/01\/Cassandra-Ring.jpg?resize=350%2C200","width":350,"height":200},"classes":[]}],"_links":{"self":[{"href":"https:\/\/blog.box.kr\/index.php?rest_route=\/wp\/v2\/posts\/847"}],"collection":[{"href":"https:\/\/blog.box.kr\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.box.kr\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.box.kr\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.box.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=847"}],"version-history":[{"count":0,"href":"https:\/\/blog.box.kr\/index.php?rest_route=\/wp\/v2\/posts\/847\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.box.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=847"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.box.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=847"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.box.kr\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=847"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}