You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sqoop.apache.org by af...@apache.org on 2016/03/08 02:08:23 UTC
sqoop git commit: SQOOP-2870: Sqoop2: RESTiliency: Add tests for
DriverHandler
Repository: sqoop
Updated Branches:
refs/heads/sqoop2 049e0d7e8 -> 004b298e3
SQOOP-2870: Sqoop2: RESTiliency: Add tests for DriverHandler
(Jarek Jarcec Cecho via Abraham Fine)
Project: http://git-wip-us.apache.org/repos/asf/sqoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/sqoop/commit/004b298e
Tree: http://git-wip-us.apache.org/repos/asf/sqoop/tree/004b298e
Diff: http://git-wip-us.apache.org/repos/asf/sqoop/diff/004b298e
Branch: refs/heads/sqoop2
Commit: 004b298e388562907ffbadc297e7a3721b0c4190
Parents: 049e0d7
Author: Abraham Fine <af...@apache.org>
Authored: Mon Mar 7 17:06:57 2016 -0800
Committer: Abraham Fine <af...@apache.org>
Committed: Mon Mar 7 17:06:57 2016 -0800
----------------------------------------------------------------------
.../sqoop/handler/DriverRequestHandler.java | 5 --
.../integration/server/rest/DriverRestTest.java | 53 ++++++++++++++++++++
2 files changed, 53 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/sqoop/blob/004b298e/server/src/main/java/org/apache/sqoop/handler/DriverRequestHandler.java
----------------------------------------------------------------------
diff --git a/server/src/main/java/org/apache/sqoop/handler/DriverRequestHandler.java b/server/src/main/java/org/apache/sqoop/handler/DriverRequestHandler.java
index 95a3291..7b82ce5 100644
--- a/server/src/main/java/org/apache/sqoop/handler/DriverRequestHandler.java
+++ b/server/src/main/java/org/apache/sqoop/handler/DriverRequestHandler.java
@@ -40,11 +40,6 @@ public class DriverRequestHandler implements RequestHandler {
@Override
public JsonBean handleEvent(RequestContext ctx) {
- // driver only support GET requests
- if (ctx.getMethod() != Method.GET) {
- throw new SqoopException(ServerError.SERVER_0002, "Unsupported HTTP method for driver:"
- + ctx.getMethod());
- }
AuditLoggerManager.getInstance().logAuditEvent(ctx.getUserName(),
ctx.getRequest().getRemoteAddr(), "get", "driver", "");
http://git-wip-us.apache.org/repos/asf/sqoop/blob/004b298e/test/src/test/java/org/apache/sqoop/integration/server/rest/DriverRestTest.java
----------------------------------------------------------------------
diff --git a/test/src/test/java/org/apache/sqoop/integration/server/rest/DriverRestTest.java b/test/src/test/java/org/apache/sqoop/integration/server/rest/DriverRestTest.java
new file mode 100644
index 0000000..438e074
--- /dev/null
+++ b/test/src/test/java/org/apache/sqoop/integration/server/rest/DriverRestTest.java
@@ -0,0 +1,53 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sqoop.integration.server.rest;
+
+import org.apache.sqoop.test.utils.ParametrizedUtils;
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Factory;
+
+import java.util.Iterator;
+
+public class DriverRestTest extends RestTest {
+
+ public static TestDescription[] PROVIDER_DATA = new TestDescription[]{
+ new TestDescription("Get driver", "v1/driver", "GET", null, new Validator() {
+ @Override
+ void validate() throws Exception {
+ assertResponseCode(200);
+ assertContains("job-config");
+ assertContains("all-config-resources");
+ }}),
+ new TestDescription("Invalid post request", "v1/driver", "POST", "Random data", new Validator() {
+ @Override
+ void validate() throws Exception {
+ assertResponseCode(405);
+ assertServerException("Unsupported HTTP method", "SERVER_0002");
+ }}),
+ };
+
+ @DataProvider(name="driver-rest-test")
+ public static Iterator<Object[]> data() {
+ return ParametrizedUtils.toArrayOfArrays(PROVIDER_DATA).iterator();
+ }
+
+ @Factory(dataProvider = "driver-rest-test")
+ public DriverRestTest(TestDescription desc) {
+ super(desc);
+ }
+}