You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@oozie.apache.org by vi...@apache.org on 2012/08/18 08:52:05 UTC
svn commit: r1374518 - in /incubator/oozie/trunk:
core/src/main/java/org/apache/oozie/servlet/V1JobServlet.java
core/src/test/java/org/apache/oozie/servlet/TestV1JobServlet.java
release-log.txt
Author: virag
Date: Sat Aug 18 06:52:04 2012
New Revision: 1374518
URL: http://svn.apache.org/viewvc?rev=1374518&view=rev
Log:
OOZIE-923 Improve error message when a user tries to start a coordinator job (sms via virag)
Modified:
incubator/oozie/trunk/core/src/main/java/org/apache/oozie/servlet/V1JobServlet.java
incubator/oozie/trunk/core/src/test/java/org/apache/oozie/servlet/TestV1JobServlet.java
incubator/oozie/trunk/release-log.txt
Modified: incubator/oozie/trunk/core/src/main/java/org/apache/oozie/servlet/V1JobServlet.java
URL: http://svn.apache.org/viewvc/incubator/oozie/trunk/core/src/main/java/org/apache/oozie/servlet/V1JobServlet.java?rev=1374518&r1=1374517&r2=1374518&view=diff
==============================================================================
--- incubator/oozie/trunk/core/src/main/java/org/apache/oozie/servlet/V1JobServlet.java (original)
+++ incubator/oozie/trunk/core/src/main/java/org/apache/oozie/servlet/V1JobServlet.java Sat Aug 18 06:52:04 2012
@@ -80,7 +80,7 @@ public class V1JobServlet extends BaseJo
startBundleJob(request, response);
}
else {
- throw new XServletException(HttpServletResponse.SC_BAD_REQUEST, ErrorCode.E0303);
+ throw new XServletException(HttpServletResponse.SC_BAD_REQUEST, ErrorCode.E0303, RestConstants.ACTION_PARAM, RestConstants.JOB_ACTION_START);
}
}
Modified: incubator/oozie/trunk/core/src/test/java/org/apache/oozie/servlet/TestV1JobServlet.java
URL: http://svn.apache.org/viewvc/incubator/oozie/trunk/core/src/test/java/org/apache/oozie/servlet/TestV1JobServlet.java?rev=1374518&r1=1374517&r2=1374518&view=diff
==============================================================================
--- incubator/oozie/trunk/core/src/test/java/org/apache/oozie/servlet/TestV1JobServlet.java (original)
+++ incubator/oozie/trunk/core/src/test/java/org/apache/oozie/servlet/TestV1JobServlet.java Sat Aug 18 06:52:04 2012
@@ -6,9 +6,9 @@
* 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.
@@ -18,6 +18,7 @@
package org.apache.oozie.servlet;
import org.apache.hadoop.conf.Configuration;
+import org.apache.oozie.ErrorCode;
import org.apache.oozie.client.OozieClient;
import org.apache.oozie.client.rest.RestConstants;
import org.apache.oozie.client.rest.JsonTags;
@@ -26,6 +27,7 @@ import org.apache.oozie.servlet.V1JobSer
import org.json.simple.JSONObject;
import org.json.simple.JSONValue;
+import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
@@ -103,6 +105,62 @@ public class TestV1JobServlet extends Da
_testAction(RestConstants.JOB_ACTION_KILL, null);
}
+ /**
+ * This test will invoke the start action on a coordinator job using HTTP.
+ * Checks for 400 response
+ * @throws Exception
+ */
+ public void testStart() throws Exception {
+ runTest("/v1/job/*", V1JobServlet.class, IS_SECURITY_ENABLED, new Callable<Void>() {
+ public Void call() throws Exception {
+ MockCoordinatorEngineService.reset();
+ Map<String, String> params = new HashMap<String, String>();
+ //testing for the start action
+ params.put(RestConstants.ACTION_PARAM, RestConstants.JOB_ACTION_START);
+ URL url = createURL(MockCoordinatorEngineService.JOB_ID + 1, params);
+ HttpURLConnection conn = (HttpURLConnection) url.openConnection();
+ conn.setRequestMethod("PUT");
+ conn.setRequestProperty("content-type", RestConstants.XML_CONTENT_TYPE);
+ conn.setDoOutput(true);
+ //check if the response is 400
+ assertEquals(HttpServletResponse.SC_BAD_REQUEST, conn.getResponseCode());
+ //check if the state remains uninitialized
+ assertEquals(null, MockCoordinatorEngineService.did);
+ return null;
+ }
+ });
+ }
+
+ /**
+ * This test will invoke the start action on a coordinator job. Since the coordinator job
+ * does not support a start action, the test case is expected to catch the error and verify
+ * the error message.
+ * @throws Exception
+ */
+ public void testStartForErrorCode() throws Exception {
+ @SuppressWarnings("serial")
+ V1JobServlet testV1JobServlet = new V1JobServlet() {
+
+ @Override
+ protected String getResourceName(HttpServletRequest request) {
+ return "-C";
+ }
+ };
+ try {
+ testV1JobServlet.startJob(null, null);
+ // should not get here!
+ fail("Negative test to test an exception. Should not be succeeding!");
+ } catch (XServletException xse) {
+ // check for the error code and the message
+ assertEquals(xse.getErrorCode(), ErrorCode.E0303);
+ assertTrue(xse.getMessage().contains("Invalid parameter value, [action] = [start]"));
+ } catch (Exception e) {
+ // should not get here!
+ fail("Did not expect a generic exception. Was expecting XServletException");
+ }
+
+ }
+
private void _testNonJsonResponses(final String show, final String contentType, final String response)
throws Exception {
runTest("/v1/job/*", V1JobServlet.class, IS_SECURITY_ENABLED, new Callable<Void>() {
Modified: incubator/oozie/trunk/release-log.txt
URL: http://svn.apache.org/viewvc/incubator/oozie/trunk/release-log.txt?rev=1374518&r1=1374517&r2=1374518&view=diff
==============================================================================
--- incubator/oozie/trunk/release-log.txt (original)
+++ incubator/oozie/trunk/release-log.txt Sat Aug 18 06:52:04 2012
@@ -1,5 +1,6 @@
-- Oozie 3.3.0 release (trunk - unreleased)
+OOZIE-923 Improve error message when a user tries to start a coordinator job (sms via virag)
OOZIE-947 Forward porting OOZIE-733 to 3.2 and trunk (mona via virag)
OOZIE-889 Adding HCat credentials class for job conf (mona via virag)
OOZIE-940 Junk messages appear in tomcat log (egashira via virag)