You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by de...@apache.org on 2013/11/21 22:54:42 UTC
svn commit: r1544337 - in /uima/sandbox/uima-ducc/trunk/uima-ducc-common/src:
main/java/org/apache/uima/ducc/common/jd/plugin/
test/java/org/apache/uima/ducc/common/test/
Author: degenaro
Date: Thu Nov 21 21:54:42 2013
New Revision: 1544337
URL: http://svn.apache.org/r1544337
Log:
UIMA-3442 DUCC pre-R1.0 has classes that look like tests in the main?
Added:
uima/sandbox/uima-ducc/trunk/uima-ducc-common/src/test/java/org/apache/uima/ducc/common/test/JdProcessExceptionHandlerTest.java
Removed:
uima/sandbox/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/jd/plugin/TestJdProcessExceptionHandler.java
Modified:
uima/sandbox/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/jd/plugin/AbstractJdProcessExceptionHandler.java
uima/sandbox/uima-ducc/trunk/uima-ducc-common/src/test/java/org/apache/uima/ducc/common/test/JdProcessExceptionHandlerLoaderTest.java
Modified: uima/sandbox/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/jd/plugin/AbstractJdProcessExceptionHandler.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/jd/plugin/AbstractJdProcessExceptionHandler.java?rev=1544337&r1=1544336&r2=1544337&view=diff
==============================================================================
--- uima/sandbox/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/jd/plugin/AbstractJdProcessExceptionHandler.java (original)
+++ uima/sandbox/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/jd/plugin/AbstractJdProcessExceptionHandler.java Thu Nov 21 21:54:42 2013
@@ -43,16 +43,23 @@ public abstract class AbstractJdProcessE
*/
public Directive handle(String processId, CAS cas, Throwable t, Properties properties) {
Directive directive = null;
- directive = handleRetry(processId, cas, t, properties);
- if(directive != null) {
- return directive;
- }
- directive = handleError(processId, cas, t, properties);
- if(directive != null) {
- return directive;
+ try {
+ directive = handleRetry(processId, cas, t, properties);
+ if(directive != null) {
+ return directive;
+ }
+ directive = handleError(processId, cas, t, properties);
+ if(directive != null) {
+ return directive;
+ }
+ directive = Directive.ProcessContinue_CasNoRetry;
+ directive.setReason("default");
+ }
+ catch(Exception e) {
+ directive = Directive.ProcessContinue_CasNoRetry;
+ directive.setReason("exception during exception handler");
}
- directive = Directive.ProcessContinue_CasNoRetry;
- directive.setReason("default");
+
return directive;
}
Modified: uima/sandbox/uima-ducc/trunk/uima-ducc-common/src/test/java/org/apache/uima/ducc/common/test/JdProcessExceptionHandlerLoaderTest.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-common/src/test/java/org/apache/uima/ducc/common/test/JdProcessExceptionHandlerLoaderTest.java?rev=1544337&r1=1544336&r2=1544337&view=diff
==============================================================================
--- uima/sandbox/uima-ducc/trunk/uima-ducc-common/src/test/java/org/apache/uima/ducc/common/test/JdProcessExceptionHandlerLoaderTest.java (original)
+++ uima/sandbox/uima-ducc/trunk/uima-ducc-common/src/test/java/org/apache/uima/ducc/common/test/JdProcessExceptionHandlerLoaderTest.java Thu Nov 21 21:54:42 2013
@@ -1,3 +1,21 @@
+/*
+ * 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.uima.ducc.common.test;
import static org.junit.Assert.*;
Added: uima/sandbox/uima-ducc/trunk/uima-ducc-common/src/test/java/org/apache/uima/ducc/common/test/JdProcessExceptionHandlerTest.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-common/src/test/java/org/apache/uima/ducc/common/test/JdProcessExceptionHandlerTest.java?rev=1544337&view=auto
==============================================================================
--- uima/sandbox/uima-ducc/trunk/uima-ducc-common/src/test/java/org/apache/uima/ducc/common/test/JdProcessExceptionHandlerTest.java (added)
+++ uima/sandbox/uima-ducc/trunk/uima-ducc-common/src/test/java/org/apache/uima/ducc/common/test/JdProcessExceptionHandlerTest.java Thu Nov 21 21:54:42 2013
@@ -0,0 +1,120 @@
+/*
+ * 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.uima.ducc.common.test;
+
+import static org.junit.Assert.*;
+
+import java.util.Properties;
+
+import org.apache.uima.aae.error.UimaASProcessCasTimeout;
+import org.apache.uima.cas.CAS;
+import org.apache.uima.ducc.common.jd.plugin.JdProcessExceptionHandler;
+import org.apache.uima.resource.ResourceProcessException;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class JdProcessExceptionHandlerTest {
+
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ }
+
+ @AfterClass
+ public static void tearDownAfterClass() throws Exception {
+ }
+
+ @Before
+ public void setUp() throws Exception {
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ private static void generateUimaASProcessCasTimeout() throws Exception {
+ throw new UimaASProcessCasTimeout();
+ }
+
+ private static void generateTimeout() throws Exception {
+ try {
+ generateUimaASProcessCasTimeout();
+ }
+ catch(Exception e) {
+ throw new ResourceProcessException(e);
+ }
+ }
+
+ private static void generateError() throws Exception {
+ try {
+ throw new NullPointerException();
+ }
+ catch(Exception e) {
+ throw new ResourceProcessException(e);
+ }
+ }
+
+ @Test
+ public void test() {
+ try {
+ JdProcessExceptionHandler jdProcessExceptionHandler = new JdProcessExceptionHandler();
+ for(int i=1; i<20; i++) {
+ try {
+ generateTimeout();
+ }
+ catch(Exception e) {
+ String processId = "0";
+ CAS cas = null;
+ Properties properties = null;
+ jdProcessExceptionHandler.handle(processId, cas, e, properties);
+ }
+ }
+ for(int i=1; i<4; i++) {
+ try {
+ generateError();
+ }
+ catch(Exception e) {
+ String processId = "1";
+ CAS cas = null;
+ Properties properties = null;
+ jdProcessExceptionHandler.handle(processId, cas, e, properties);
+ }
+ }
+ for(int i=1; i<13; i++) {
+ try {
+ generateError();
+ }
+ catch(Exception e) {
+ String processId = "2";
+ CAS cas = null;
+ Properties properties = null;
+ jdProcessExceptionHandler.handle(processId, cas, e, properties);
+ }
+ }
+ }
+ catch(Exception e) {
+ e.printStackTrace();
+ fail("Exception");
+ }
+
+ }
+
+}