Author: rkanter
Date: Mon Feb  4 17:57:43 2013
New Revision: 1442222

URL: http://svn.apache.org/viewvc?rev=1442222&view=rev
Log:
OOZIE-1016 Tests that use junit assert or fail in a new thread report success 
when they are actually failing (rkanter via tucu)

Modified:
    
oozie/branches/branch-3.3/client/src/test/java/org/apache/oozie/cli/TestValidation.java
    
oozie/branches/branch-3.3/core/src/test/java/org/apache/oozie/service/TestSchemaService.java
    
oozie/branches/branch-3.3/core/src/test/java/org/apache/oozie/workflow/lite/TestLiteWorkflowAppParser.java
    oozie/branches/branch-3.3/release-log.txt

Modified: 
oozie/branches/branch-3.3/client/src/test/java/org/apache/oozie/cli/TestValidation.java
URL: 
http://svn.apache.org/viewvc/oozie/branches/branch-3.3/client/src/test/java/org/apache/oozie/cli/TestValidation.java?rev=1442222&r1=1442221&r2=1442222&view=diff
==============================================================================
--- 
oozie/branches/branch-3.3/client/src/test/java/org/apache/oozie/cli/TestValidation.java
 (original)
+++ 
oozie/branches/branch-3.3/client/src/test/java/org/apache/oozie/cli/TestValidation.java
 Mon Feb  4 17:57:43 2013
@@ -21,7 +21,6 @@ import junit.framework.TestCase;
 
 import java.net.URL;
 import java.net.URI;
-import java.util.concurrent.TimeoutException;
 import java.io.File;
 
 public class TestValidation extends TestCase {
@@ -42,23 +41,4 @@ public class TestValidation extends Test
         String[] args = new String[]{"validate", getPath("invalid.xml")};
         assertEquals(-1, new OozieCLI().run(args));
     }
-
-    // Test for Validation of workflow definition against pattern defined in 
schema to complete within 3 seconds
-    public void testTimeout() throws Exception {
-        final String[] args = new String[] { "validate", 
getPath("timeout.xml") };
-        Thread testThread = new Thread() {
-            public void run() {
-                assertEquals(-1, new OozieCLI().run(args));
-            }
-        };
-        testThread.start();
-        Thread.sleep(3000);
-        // Timeout if validation takes more than 3 seconds
-        testThread.interrupt();
-
-        if (testThread.isInterrupted()) {
-            throw new TimeoutException("The pattern validation took too long 
to complete");
-        }
-    }
-
 }

Modified: 
oozie/branches/branch-3.3/core/src/test/java/org/apache/oozie/service/TestSchemaService.java
URL: 
http://svn.apache.org/viewvc/oozie/branches/branch-3.3/core/src/test/java/org/apache/oozie/service/TestSchemaService.java?rev=1442222&r1=1442221&r2=1442222&view=diff
==============================================================================
--- 
oozie/branches/branch-3.3/core/src/test/java/org/apache/oozie/service/TestSchemaService.java
 (original)
+++ 
oozie/branches/branch-3.3/core/src/test/java/org/apache/oozie/service/TestSchemaService.java
 Mon Feb  4 17:57:43 2013
@@ -22,23 +22,15 @@ import org.apache.oozie.service.SchemaSe
 import org.apache.oozie.test.XTestCase;
 import org.apache.oozie.util.XmlUtils;
 import org.jdom.Element;
-import org.xml.sax.SAXParseException;
 
 import javax.xml.validation.Validator;
 import javax.xml.transform.stream.StreamSource;
 
 import java.io.StringReader;
-import java.util.concurrent.TimeoutException;
 
 public class TestSchemaService extends XTestCase {
 
-    public static final String LONG_STRING_PATTERN_VALIDATION = 
"I_am_long_string_with_a_period_._which_is_not_allowed_according_to_schema";
-    public static final String APP_NEG_TEST = "<workflow-app 
xmlns='uri:oozie:workflow:0.1' name='"+LONG_STRING_PATTERN_VALIDATION+"'>" +
-            "<start to='end'/>" +
-            "<end name='end'/>" +
-            "</workflow-app>";
-
-       private static final String APP1 = "<workflow-app 
xmlns='uri:oozie:workflow:0.1' name='app'>" +
+    private static final String APP1 = "<workflow-app 
xmlns='uri:oozie:workflow:0.1' name='app'>" +
             "<start to='end'/>" +
             "<end name='end'/>" +
             "</workflow-app>";
@@ -136,34 +128,6 @@ public class TestSchemaService extends X
         validator.validate(new StreamSource(new 
StringReader(WF_4_MULTIPLE_JAVA_OPTS)));
     }
 
-    // Test for validation of workflow definition against pattern defined in 
schema to complete within 3 seconds
-    public void testWfSchemaFailure() throws Exception {
-        SchemaService wss = Services.get().get(SchemaService.class);
-        final Validator validator = 
wss.getSchema(SchemaName.WORKFLOW).newValidator();
-        Thread testThread = new Thread() {
-            public void run() {
-                try {
-                    // Validate against wf def
-                    validator.validate(new StreamSource(new 
StringReader(APP_NEG_TEST)));
-                    fail("Expected to catch ParseException but didn't 
encounter any");
-                } catch (SAXParseException saxpe) {
-                    // Expected
-                } catch (Exception e) {
-                    fail("Expected to catch ParseException but an unexpected 
error happened " + e.getMessage());
-                }
-            }
-        };
-
-        testThread.start();
-        Thread.sleep(3000);
-        // Timeout if validation takes more than 3 seconds
-        testThread.interrupt();
-
-        if (testThread.isInterrupted()) {
-            throw new TimeoutException("the pattern validation took too long 
to complete");
-        }
-    }
-
     public void testWfSchemaV2() throws Exception {
         SchemaService wss = Services.get().get(SchemaService.class);
         Validator validator = 
wss.getSchema(SchemaName.WORKFLOW).newValidator();

Modified: 
oozie/branches/branch-3.3/core/src/test/java/org/apache/oozie/workflow/lite/TestLiteWorkflowAppParser.java
URL: 
http://svn.apache.org/viewvc/oozie/branches/branch-3.3/core/src/test/java/org/apache/oozie/workflow/lite/TestLiteWorkflowAppParser.java?rev=1442222&r1=1442221&r2=1442222&view=diff
==============================================================================
--- 
oozie/branches/branch-3.3/core/src/test/java/org/apache/oozie/workflow/lite/TestLiteWorkflowAppParser.java
 (original)
+++ 
oozie/branches/branch-3.3/core/src/test/java/org/apache/oozie/workflow/lite/TestLiteWorkflowAppParser.java
 Mon Feb  4 17:57:43 2013
@@ -18,21 +18,16 @@
 package org.apache.oozie.workflow.lite;
 
 
-import java.io.StringReader;
 import java.lang.reflect.Field;
 import java.lang.reflect.Method;
 import java.util.Arrays;
 import java.util.HashMap;
 import java.util.Map;
-import java.util.concurrent.TimeoutException;
 
 
 import org.apache.oozie.service.ActionService;
 import org.apache.oozie.service.LiteWorkflowStoreService;
-import org.apache.oozie.service.SchemaService;
 import org.apache.oozie.service.Services;
-import org.apache.oozie.service.SchemaService.SchemaName;
-import org.apache.oozie.service.TestSchemaService;
 import org.apache.oozie.workflow.WorkflowException;
 import 
org.apache.oozie.workflow.lite.TestLiteWorkflowLib.TestActionNodeHandler;
 import 
org.apache.oozie.workflow.lite.TestLiteWorkflowLib.TestDecisionNodeHandler;
@@ -331,38 +326,6 @@ public class TestLiteWorkflowAppParser e
         }
     }
 
-    // Test for validation of workflow definition against pattern defined in 
schema to complete within 3 seconds
-    public void testWfValidationFailure() throws Exception {
-        SchemaService wss = Services.get().get(SchemaService.class);
-        final LiteWorkflowAppParser parser = new 
LiteWorkflowAppParser(wss.getSchema(SchemaName.WORKFLOW),
-                LiteWorkflowStoreService.LiteControlNodeHandler.class,
-                LiteWorkflowStoreService.LiteDecisionHandler.class, 
LiteWorkflowStoreService.LiteActionHandler.class);
-
-        Thread testThread = new Thread() {
-            public void run() {
-                try {
-                    // Validate against wf def
-                    parser.validateAndParse(new 
StringReader(TestSchemaService.APP_NEG_TEST), new Configuration());
-                    fail("Expected to catch WorkflowException but didn't 
encounter any");
-                } catch (WorkflowException we) {
-                    assertEquals(ErrorCode.E0701, we.getErrorCode());
-                    
assertTrue(we.getCause().toString().contains("SAXParseException"));
-                } catch (Exception e) {
-                    fail("Expected to catch WorkflowException but an 
unexpected error happened");
-                }
-
-            }
-        };
-        testThread.start();
-        Thread.sleep(3000);
-        // Timeout if validation takes more than 3 seconds
-        testThread.interrupt();
-
-        if (testThread.isInterrupted()) {
-            throw new TimeoutException("the pattern validation took too long 
to complete");
-        }
-    }
-
     /*
      * 1->ok->2
      * 2->ok->end

Modified: oozie/branches/branch-3.3/release-log.txt
URL: 
http://svn.apache.org/viewvc/oozie/branches/branch-3.3/release-log.txt?rev=1442222&r1=1442221&r2=1442222&view=diff
==============================================================================
--- oozie/branches/branch-3.3/release-log.txt (original)
+++ oozie/branches/branch-3.3/release-log.txt Mon Feb  4 17:57:43 2013
@@ -1,5 +1,6 @@
 -- Oozie 3.3.2 (unreleased)
 
+OOZIE-1016 Tests that use junit assert or fail in a new thread report success 
when they are actually failing (rkanter via tucu)
 OOZIE-1017 Add test to make sure old version of Xerces isn't being used 
(rkanter via tucu)
 OOZIE-949 Allow the user to set 'mapred.job.name' (jrkinley via tucu)
 OOZIE-1009 Documentation pages should use default ports for Oozie/JT/NN (tucu)


Reply via email to