SQOOP-2822: Sqoop2: RESTiliency: Provide tests for Link POST action
authorColin Ma <colin@apache.org>
Wed, 17 Feb 2016 03:58:00 +0000 (11:58 +0800)
committerColin Ma <colin@apache.org>
Wed, 17 Feb 2016 03:58:00 +0000 (11:58 +0800)
 (Jarek Jarcec Cecho via Colin Ma)

test/src/test/java/org/apache/sqoop/integration/server/rest/LinkRestTest.java

index f9b0cbf..d988f2d 100644 (file)
@@ -65,6 +65,26 @@ public class LinkRestTest extends RestTest {
         assertServerException("Entity requested doesn't exist", "SERVER_0006");
         assertContains("Invalid connector: i-dont-exists");
       }}),
+
+    // Post
+    new TestDescription("Empty data", "v1/link", "POST", "", new Validator() {
+      @Override
+      void validate() throws Exception {
+        assertResponseCode(500);
+        assertServerException("Invalid JSON", "SERIALIZATION_002");
+      }}),
+    new TestDescription("Corrupted JSON", "v1/link", "POST", "{\"blah\" : {}", new Validator() {
+      @Override
+      void validate() throws Exception {
+        assertResponseCode(500);
+        assertServerException("Invalid JSON", "SERIALIZATION_002");
+      }}),
+    new TestDescription("Empty JSON", "v1/link", "POST", "{}", new Validator() {
+      @Override
+      void validate() throws Exception {
+        assertResponseCode(500);
+        assertServerException("Required key field is missing", "SERIALIZATION_003");
+      }}),
   };
 
   @DataProvider(name="link-rest-test", parallel=false)