Skip to content

Commit ad645ee

Browse files
committed
Test listeners
1 parent 9b91d00 commit ad645ee

10 files changed

Lines changed: 113 additions & 16 deletions

File tree

Code/ChroniclerJ/src/edu/columbia/cs/psl/chroniclerj/ChroniclerJExportRunner.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@
2020

2121
public class ChroniclerJExportRunner extends Thread {
2222

23-
private static String mainClass;
23+
private static String mainClass = "";
2424

25-
private static String[] mainArgs;
25+
private static String[] mainArgs = new String[0];
2626

2727
private static ArrayList<String> serializableLogs = new ArrayList<>();
2828

@@ -35,12 +35,16 @@ public static void logMain(String main, String[] args) {
3535
System.arraycopy(args, 0, mainArgs, 0, args.length);
3636
}
3737

38-
public static void genTestCase() {
38+
public static void genTestCase()
39+
{
40+
genTestCase("chroniclerj-crash-" + System.currentTimeMillis() + ".test");
41+
}
42+
public static void genTestCase(String name) {
3943
export();
4044
exportSerializable();
4145
try {
4246

43-
File logFile = new File("chroniclerj-crash-" + System.currentTimeMillis() + ".test");
47+
File logFile = new File(name);
4448

4549
Manifest manifest = new Manifest();
4650
manifest.getMainAttributes().put(Attributes.Name.MANIFEST_VERSION, "1.0");
@@ -99,7 +103,8 @@ public static void genTestCase() {
99103
zos.flush();
100104
zos.close();
101105
System.out.println("Chroniclerj exported a test case");
102-
106+
serializableLogs.clear();
107+
otherLogs.clear();
103108
} catch (IOException e) {
104109
// TODO Auto-generated catch block
105110
e.printStackTrace();

Code/ChroniclerJ/src/edu/columbia/cs/psl/chroniclerj/Log.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,15 @@ public static void clearLog() {
3030

3131
}
3232

33-
private static boolean hasRegisteredHook = false;
34-
static {
35-
if(!hasRegisteredHook){
36-
hasRegisteredHook = true;
37-
Runtime.getRuntime().addShutdownHook(new Thread(){
38-
public void run(){
39-
ChroniclerJExportRunner.genTestCase();
40-
}
41-
});
42-
}
43-
}
33+
// private static boolean hasRegisteredHook = false;
34+
// static {
35+
// if(!hasRegisteredHook){
36+
// hasRegisteredHook = true;
37+
// Runtime.getRuntime().addShutdownHook(new Thread(){
38+
// public void run(){
39+
// ChroniclerJExportRunner.genTestCase();
40+
// }
41+
// });
42+
// }
43+
// }
4444
}

Code/JUnitListener/.classpath

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentry kind="src" path="src"/>
4+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
5+
<classpathentry kind="lib" path="ant-junit.jar"/>
6+
<classpathentry kind="lib" path="ant-junit4.jar"/>
7+
<classpathentry kind="lib" path="ant.jar"/>
8+
<classpathentry kind="lib" path="junit-4.12.jar"/>
9+
<classpathentry combineaccessrules="false" kind="src" path="/ChroniclerJ"/>
10+
<classpathentry kind="output" path="bin"/>
11+
</classpath>

Code/JUnitListener/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/bin/

Code/JUnitListener/.project

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>ChroniclerJJUnitListener</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.jdt.core.javabuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
</buildSpec>
14+
<natures>
15+
<nature>org.eclipse.jdt.core.javanature</nature>
16+
</natures>
17+
</projectDescription>

Code/JUnitListener/ant-junit.jar

116 KB
Binary file not shown.

Code/JUnitListener/ant-junit4.jar

12.8 KB
Binary file not shown.

Code/JUnitListener/ant.jar

1.94 MB
Binary file not shown.

Code/JUnitListener/junit-4.12.jar

308 KB
Binary file not shown.
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
package edu.cs.columbia.cs.psl.chronicler;
2+
import java.io.OutputStream;
3+
4+
import junit.framework.AssertionFailedError;
5+
import junit.framework.Test;
6+
7+
import org.apache.tools.ant.BuildException;
8+
import org.apache.tools.ant.taskdefs.optional.junit.JUnitResultFormatter;
9+
import org.apache.tools.ant.taskdefs.optional.junit.JUnitTest;
10+
11+
import edu.columbia.cs.psl.chroniclerj.ChroniclerJExportRunner;
12+
public class ChroniclerJUnitListener implements JUnitResultFormatter {
13+
14+
@Override
15+
public void addError(Test arg0, Throwable arg1) {
16+
17+
}
18+
19+
@Override
20+
public void addFailure(Test arg0, AssertionFailedError arg1) {
21+
22+
}
23+
24+
@Override
25+
public void endTest(Test arg0) {
26+
ChroniclerJExportRunner.genTestCase("chroniclerj_"+arg0.toString()+".test");
27+
}
28+
29+
@Override
30+
public void startTest(Test arg0) {
31+
32+
}
33+
34+
@Override
35+
public void endTestSuite(JUnitTest arg0) throws BuildException {
36+
37+
}
38+
39+
@Override
40+
public void setOutput(OutputStream arg0) {
41+
// TODO Auto-generated method stub
42+
43+
}
44+
45+
@Override
46+
public void setSystemError(String arg0) {
47+
// TODO Auto-generated method stub
48+
49+
}
50+
51+
@Override
52+
public void setSystemOutput(String arg0) {
53+
// TODO Auto-generated method stub
54+
55+
}
56+
57+
@Override
58+
public void startTestSuite(JUnitTest arg0) throws BuildException {
59+
// TODO Auto-generated method stub
60+
61+
}
62+
63+
}

0 commit comments

Comments
 (0)