Commit 480de26d authored by ISWB Prasetya's avatar ISWB Prasetya
Browse files

small improvement in the generator of junit testclass

parent 1e8dee8b
...@@ -645,12 +645,13 @@ public class SUITE implements Serializable { ...@@ -645,12 +645,13 @@ public class SUITE implements Serializable {
PrintWriter pw = new PrintWriter(f); PrintWriter pw = new PrintWriter(f);
pw.write("import org.junit.* ;\n") ; pw.write("import org.junit.* ;\n") ;
pw.write("import static org.junit.Assert.* ;\n") ; pw.write("import static org.junit.Assert.* ;\n") ;
pw.write("import java.util.logging.Logger;\n") ;
pw.write("import Sequenic.T3.* ;\n") ; pw.write("import Sequenic.T3.* ;\n") ;
pw.write("import Sequenic.T3.Sequence.Datatype.* ;\n") ; pw.write("import Sequenic.T3.Sequence.Datatype.* ;\n") ;
pw.write("public class " + testclassName + " {\n\n") ; pw.write("public class " + testclassName + " {\n\n") ;
pw.write(" public " + testclassName + "() { }\n\n") ; pw.write(" public " + testclassName + "() { }\n\n") ;
pw.write(" SUITE S = null ;\n") ; pw.write(" static SUITE S = null ;\n") ;
pw.write(" SUITE_RT_info info = null ;\n\n") ; pw.write(" static SUITE_RT_info info = null ;\n\n") ;
// test-1 // test-1
pw.write(" @Test\n") ; pw.write(" @Test\n") ;
pw.write(" public void test1() throws Exception {\n") ; pw.write(" public void test1() throws Exception {\n") ;
...@@ -662,13 +663,16 @@ public class SUITE implements Serializable { ...@@ -662,13 +663,16 @@ public class SUITE implements Serializable {
+ showExcExecution + "," + showExcExecution + ","
+ "true ," // runAll is set to true + "true ," // runAll is set to true
+ regressionMode + "," + regressionMode + ","
+ "null) ;\n" // supress violation reporting + "null) ;\n" // suppress violation reporting, else use System.err
) ; ) ;
pw.write(" assertTrue(!info.seenCrash()) ; "); pw.write(" boolean verdict = !info.seenCrash() ;\n");
pw.write(" if (verdict) Logger.getLogger(CONSTANTS.T3loggerName).info(\"PASS\") ;\n") ;
pw.write(" else Logger.getLogger(CONSTANTS.T3loggerName).info(\"FAIL\") ;\n") ;
pw.write(" assertTrue(verdict) ;\n");
pw.write(" }\n\n") ; pw.write(" }\n\n") ;
// test-2 // test-2
pw.write(" @Test\n") ; pw.write(" @Test\n") ;
pw.write(" public void test2() throws Exception {\n") ; pw.write(" public void testExceptionTypeOnly() throws Exception {\n") ;
pw.write(" if (S==null) S = SUITE.load(\"" + traceFile + "\") ;\n") ; pw.write(" if (S==null) S = SUITE.load(\"" + traceFile + "\") ;\n") ;
pw.write(" Pool pool = new Pool() ;\n") ; pw.write(" Pool pool = new Pool() ;\n") ;
pw.write(" if (info==null) info = S.exec(pool,getClass().getClassLoader(),null," pw.write(" if (info==null) info = S.exec(pool,getClass().getClassLoader(),null,"
...@@ -677,25 +681,30 @@ public class SUITE implements Serializable { ...@@ -677,25 +681,30 @@ public class SUITE implements Serializable {
+ showExcExecution + "," + showExcExecution + ","
+ "true ," // runAll is set to true + "true ," // runAll is set to true
+ regressionMode + "," + regressionMode + ","
+ "null) ;\n" // supress violation reporting + "null) ;\n" // suppress violation reporting, else use System.err
) ; ) ;
pw.write(" assertTrue(info.inconsistentExc.isEmpty()) ; "); pw.write(" boolean verdict = info.inconsistentExc.isEmpty() ;\n");
pw.write(" if (verdict) Logger.getLogger(CONSTANTS.T3loggerName).info(\"PASS\") ;\n") ;
pw.write(" else Logger.getLogger(CONSTANTS.T3loggerName).info(\"FAIL\") ;\n") ;
pw.write(" assertTrue(verdict) ;\n");
pw.write(" }\n\n") ; pw.write(" }\n\n") ;
// test-3 // test-3
pw.write(" @Test\n") ; pw.write(" @Test\n") ;
pw.write(" public void test3() throws Exception {\n") ; pw.write(" public void testAllOracles() throws Exception {\n") ;
pw.write(" if (S==null) S = SUITE.load(\"" + traceFile + "\") ;\n") ; pw.write(" if (S==null) S = SUITE.load(\"" + traceFile + "\") ;\n") ;
pw.write(" Pool pool = new Pool() ;\n") ; pw.write(" Pool pool = new Pool() ;\n") ;
pw.write(" SUITE_RT_info info2 = info ;\n") ; pw.write(" if (info==null) info = S.exec(pool,getClass().getClassLoader(),null,"
pw.write(" if (info2==null) info2 = S.exec(pool,getClass().getClassLoader(),null,"
+ showLength + "," + showLength + ","
+ showDepth + "," + showDepth + ","
+ showExcExecution + "," + showExcExecution + ","
+ "false ," // don't run all, stop at first violation + "true ," // don't run all, stop at first violation
+ regressionMode + "," + regressionMode + ","
+ "System.err) ;\n" // violating trace will be shown to System.err + "null) ;\n" // suppress violation reporting, else use System.err
) ; ) ;
pw.write(" assertTrue(info2.violating.isEmpty()) ; "); pw.write(" boolean verdict = info.violating.isEmpty() ;\n");
pw.write(" if (verdict) Logger.getLogger(CONSTANTS.T3loggerName).info(\"PASS\") ;\n") ;
pw.write(" else Logger.getLogger(CONSTANTS.T3loggerName).info(\"FAIL\") ;\n") ;
pw.write(" assertTrue(verdict) ;\n");
pw.write(" }\n") ; pw.write(" }\n") ;
pw.write("}") ; pw.write("}") ;
pw.flush(); pw.close(); pw.flush(); pw.close();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment