Refactoring of junit test setup.

This commit is contained in:
Achim D. Brucker 2016-08-28 15:51:55 +01:00
parent f9389b3e12
commit 5a327ff30b
24 changed files with 311 additions and 146 deletions

View File

@ -57,5 +57,6 @@ public class Test01 {
Test01 test = new Test01();
test.good01();
test.bad();
}
}
}

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="org.eclipse.jdt.junit.launchconfig">
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
<listEntry value="/eu.aniketos.dasca.dataflow/src/main/java/eu/aniketos/dasca/dataflow/test/AllTests.java"/>
<listEntry value="/eu.aniketos.dasca.dataflow/src/main/java/eu/aniketos/dasca/dataflow/test/TestSuite.java"/>
</listAttribute>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="1"/>
@ -15,7 +15,7 @@
<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit4"/>
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_USE_START_ON_FIRST_THREAD" value="true"/>
<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="org.eclipse.m2e.launchconfig.classpathProvider"/>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="eu.aniketos.dasca.dataflow.test.AllTests"/>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="eu.aniketos.dasca.dataflow.test.TestSuite"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="eu.aniketos.dasca.dataflow"/>
<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.m2e.launchconfig.sourcepathProvider"/>
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-ea"/>

View File

@ -1,59 +0,0 @@
/*
* (C) Copyright 2016 The University of Sheffield.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
*/
package eu.aniketos.dasca.dataflow.test;
import java.io.IOException;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import org.junit.BeforeClass;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import org.junit.runners.Suite.SuiteClasses;
import eu.aniketos.dasca.dataflow.util.PlugInUtil;
import com.ibm.wala.cast.java.client.JavaSourceAnalysisEngine;
import com.ibm.wala.dataflow.IFDS.ICFGSupergraph;
import com.ibm.wala.ipa.callgraph.AnalysisCache;
import com.ibm.wala.ipa.callgraph.CallGraph;
import com.ibm.wala.properties.WalaProperties;
import com.ibm.wala.util.CancelException;
@RunWith(Suite.class)
@SuiteClasses({
Test01.class, Test02.class, Test03.class, Test04.class,
Test05.class, Test06.class, Test07.class, Test08.class,
Test09.class, Test10.class, Test11.class, Test12.class,
Test13.class, Test14.class, Test15.class, Test16.class,
Test17.class, Test18.class, Test19.class
})
public class AllTests {
protected static ICFGSupergraph superGraph = null;
protected static String testDir = "../eu.aniketos.dasca.dataflow.test.data/src/main/java/eu/aniketos/dasca/dataflow/test/data/";
@BeforeClass
public static void setUp() throws IllegalArgumentException, CancelException, IOException {
if (null != superGraph){
return;
}
Collection<String> sources = Arrays.asList(testDir);
List<String> libs = Arrays.asList(WalaProperties.getJ2SEJarFiles());
JavaSourceAnalysisEngine engine = PlugInUtil.createECJJavaEngine(sources, libs);
CallGraph cg = engine.buildDefaultCallGraph();
AnalysisCache ac = new AnalysisCache();
superGraph = ICFGSupergraph.make(cg, ac);
}
}

View File

@ -16,8 +16,10 @@ import static org.junit.Assert.assertEquals;
import java.io.IOException;
import org.eclipse.core.runtime.CoreException;
import org.junit.Before;
import org.junit.Test;
import com.ibm.wala.dataflow.IFDS.ICFGSupergraph;
import com.ibm.wala.util.CancelException;
import eu.aniketos.dasca.dataflow.util.SuperGraphUtil;
@ -26,24 +28,30 @@ public class Test01 {
String entryClass = "Test01";
@Before
public void initTest() throws IllegalArgumentException, CancelException, IOException{
TestSuite.initTestSG(entryClass);
}
@Test
public void testBad() throws IllegalArgumentException, CancelException, IOException, CoreException {
int result = SuperGraphUtil.analyzeAndSaveSuperGraph(AllTests.superGraph, entryClass, "bad");
int result = SuperGraphUtil.analyzeAndSaveSuperGraph(TestSuite.superGraph, entryClass, "bad");
assertEquals(1, result);
return;
}
@Test
public void testGood01() throws IllegalArgumentException, CancelException, IOException, CoreException {
int result = SuperGraphUtil.analyzeAndSaveSuperGraph(AllTests.superGraph, entryClass, "good01");
int result = SuperGraphUtil.analyzeAndSaveSuperGraph(TestSuite.superGraph, entryClass, "good01");
assertEquals(0, result);
return;
}
@Test
public void testGood02() throws IllegalArgumentException, CancelException, IOException, CoreException {
int result = SuperGraphUtil.analyzeAndSaveSuperGraph(AllTests.superGraph, entryClass, "good02");
int result = SuperGraphUtil.analyzeAndSaveSuperGraph(TestSuite.superGraph, entryClass, "good02");
assertEquals(-1, result);
return;
}
}

View File

@ -16,6 +16,7 @@ import static org.junit.Assert.assertEquals;
import java.io.IOException;
import org.eclipse.core.runtime.CoreException;
import org.junit.Before;
import org.junit.Test;
import com.ibm.wala.util.CancelException;
@ -25,24 +26,29 @@ import eu.aniketos.dasca.dataflow.util.SuperGraphUtil;
public class Test02 {
String entryClass = "Test02";
@Before
public void initTest() throws IllegalArgumentException, CancelException, IOException{
TestSuite.initTestSG(entryClass);
}
@Test
public void testBad() throws IllegalArgumentException, CancelException, IOException, CoreException {
int result = SuperGraphUtil.analyzeAndSaveSuperGraph(AllTests.superGraph, entryClass, "bad");
int result = SuperGraphUtil.analyzeAndSaveSuperGraph(TestSuite.superGraph, entryClass, "bad");
assertEquals(1, result);
return;
}
@Test
public void testGood01() throws IllegalArgumentException, CancelException, IOException, CoreException {
int result = SuperGraphUtil.analyzeAndSaveSuperGraph(AllTests.superGraph, entryClass, "good01");
int result = SuperGraphUtil.analyzeAndSaveSuperGraph(TestSuite.superGraph, entryClass, "good01");
assertEquals(0, result);
return;
}
@Test
public void testGood02() throws IllegalArgumentException, CancelException, IOException, CoreException {
int result = SuperGraphUtil.analyzeAndSaveSuperGraph(AllTests.superGraph, entryClass, "good02");
int result = SuperGraphUtil.analyzeAndSaveSuperGraph(TestSuite.superGraph, entryClass, "good02");
assertEquals(0, result);
return;
}

View File

@ -16,6 +16,7 @@ import static org.junit.Assert.assertEquals;
import java.io.IOException;
import org.eclipse.core.runtime.CoreException;
import org.junit.Before;
import org.junit.Test;
import com.ibm.wala.util.CancelException;
@ -26,16 +27,21 @@ public class Test03 {
String entryClass = "Test03";
@Before
public void initTest() throws IllegalArgumentException, CancelException, IOException{
TestSuite.initTestSG(entryClass);
}
@Test
public void testBad() throws IllegalArgumentException, CancelException, IOException, CoreException {
int result = SuperGraphUtil.analyzeAndSaveSuperGraph(AllTests.superGraph, entryClass, "bad");
int result = SuperGraphUtil.analyzeAndSaveSuperGraph(TestSuite.superGraph, entryClass, "bad");
assertEquals(1, result);
return;
}
@Test
public void testGood01() throws IllegalArgumentException, CancelException, IOException, CoreException {
int result = SuperGraphUtil.analyzeAndSaveSuperGraph(AllTests.superGraph, entryClass, "good01");
int result = SuperGraphUtil.analyzeAndSaveSuperGraph(TestSuite.superGraph, entryClass, "good01");
assertEquals(0, result);
return;
}

View File

@ -16,6 +16,7 @@ import static org.junit.Assert.assertEquals;
import java.io.IOException;
import org.eclipse.core.runtime.CoreException;
import org.junit.Before;
import org.junit.Test;
import com.ibm.wala.util.CancelException;
@ -26,16 +27,21 @@ public class Test04 {
String entryClass = "Test04";
@Before
public void initTest() throws IllegalArgumentException, CancelException, IOException{
TestSuite.initTestSG(entryClass);
}
@Test
public void testBad() throws IllegalArgumentException, CancelException, IOException, CoreException {
int result = SuperGraphUtil.analyzeAndSaveSuperGraph(AllTests.superGraph, entryClass, "bad");
int result = SuperGraphUtil.analyzeAndSaveSuperGraph(TestSuite.superGraph, entryClass, "bad");
assertEquals(1, result);
return;
}
@Test
public void testGood01() throws IllegalArgumentException, CancelException, IOException, CoreException {
int result = SuperGraphUtil.analyzeAndSaveSuperGraph(AllTests.superGraph, entryClass, "good01");
int result = SuperGraphUtil.analyzeAndSaveSuperGraph(TestSuite.superGraph, entryClass, "good01");
assertEquals(0, result);
return;
}

View File

@ -16,6 +16,7 @@ import static org.junit.Assert.assertEquals;
import java.io.IOException;
import org.eclipse.core.runtime.CoreException;
import org.junit.Before;
import org.junit.Test;
import com.ibm.wala.util.CancelException;
@ -26,16 +27,21 @@ public class Test05 {
String entryClass = "Test05";
@Before
public void initTest() throws IllegalArgumentException, CancelException, IOException{
TestSuite.initTestSG(entryClass);
}
@Test
public void testBad() throws IllegalArgumentException, CancelException, IOException, CoreException {
int result = SuperGraphUtil.analyzeAndSaveSuperGraph(AllTests.superGraph, entryClass, "bad");
int result = SuperGraphUtil.analyzeAndSaveSuperGraph(TestSuite.superGraph, entryClass, "bad");
assertEquals(1, result);
return;
}
@Test
public void testGood01() throws IllegalArgumentException, CancelException, IOException, CoreException {
int result = SuperGraphUtil.analyzeAndSaveSuperGraph(AllTests.superGraph, entryClass, "good01");
int result = SuperGraphUtil.analyzeAndSaveSuperGraph(TestSuite.superGraph, entryClass, "good01");
assertEquals(0, result);
return;
}

View File

@ -13,31 +13,41 @@ package eu.aniketos.dasca.dataflow.test;
import static org.junit.Assert.assertEquals;
import java.io.IOException;
import org.junit.Before;
import org.junit.Test;
import com.ibm.wala.util.CancelException;
import eu.aniketos.dasca.dataflow.util.SuperGraphUtil;
public class Test06 {
String entryClass = "Test06";
@Before
public void initTest() throws IllegalArgumentException, CancelException, IOException{
TestSuite.initTestSG(entryClass);
}
@Test
public void testBad() {
int result = SuperGraphUtil.analyzeAndSaveSuperGraph(AllTests.superGraph, entryClass, "bad");
int result = SuperGraphUtil.analyzeAndSaveSuperGraph(TestSuite.superGraph, entryClass, "bad");
assertEquals(1, result);
return;
}
@Test
public void testGood01() {
int result = SuperGraphUtil.analyzeAndSaveSuperGraph(AllTests.superGraph, entryClass, "good01");
int result = SuperGraphUtil.analyzeAndSaveSuperGraph(TestSuite.superGraph, entryClass, "good01");
assertEquals(0, result);
return;
}
@Test
public void testGood02() {
int result = SuperGraphUtil.analyzeAndSaveSuperGraph(AllTests.superGraph, entryClass, "good02");
int result = SuperGraphUtil.analyzeAndSaveSuperGraph(TestSuite.superGraph, entryClass, "good02");
assertEquals(0, result);
return;
}

View File

@ -16,6 +16,7 @@ import static org.junit.Assert.assertEquals;
import java.io.IOException;
import org.eclipse.core.runtime.CoreException;
import org.junit.Before;
import org.junit.Test;
import com.ibm.wala.util.CancelException;
@ -25,17 +26,22 @@ import eu.aniketos.dasca.dataflow.util.SuperGraphUtil;
public class Test07 {
String entryClass = "Test07";
@Before
public void initTest() throws IllegalArgumentException, CancelException, IOException{
TestSuite.initTestSG(entryClass);
}
@Test
public void testBad() throws IllegalArgumentException, CancelException, IOException, CoreException {
int result = SuperGraphUtil.analyzeAndSaveSuperGraph(AllTests.superGraph, entryClass, "bad");
int result = SuperGraphUtil.analyzeAndSaveSuperGraph(TestSuite.superGraph, entryClass, "bad");
assertEquals(1, result);
return;
}
@Test
public void testGood01() throws IllegalArgumentException, CancelException, IOException, CoreException {
int result = SuperGraphUtil.analyzeAndSaveSuperGraph(AllTests.superGraph, entryClass, "good01");
int result = SuperGraphUtil.analyzeAndSaveSuperGraph(TestSuite.superGraph, entryClass, "good01");
assertEquals(0, result);
return;
}

View File

@ -16,6 +16,7 @@ import static org.junit.Assert.assertEquals;
import java.io.IOException;
import org.eclipse.core.runtime.CoreException;
import org.junit.Before;
import org.junit.Test;
import com.ibm.wala.util.CancelException;
@ -26,30 +27,35 @@ public class Test08 {
String entryClass = "Test08";
@Before
public void initTest() throws IllegalArgumentException, CancelException, IOException{
TestSuite.initTestSG(entryClass);
}
@Test
public void testBad() throws IllegalArgumentException, CancelException, IOException, CoreException {
int result = SuperGraphUtil.analyzeAndSaveSuperGraph(AllTests.superGraph, entryClass, "bad");
int result = SuperGraphUtil.analyzeAndSaveSuperGraph(TestSuite.superGraph, entryClass, "bad");
assertEquals(1, result);
return;
}
@Test
public void testGood01() throws IllegalArgumentException, CancelException, IOException, CoreException {
int result = SuperGraphUtil.analyzeAndSaveSuperGraph(AllTests.superGraph, entryClass, "good01");
int result = SuperGraphUtil.analyzeAndSaveSuperGraph(TestSuite.superGraph, entryClass, "good01");
assertEquals(0, result);
return;
}
@Test
public void testGood02() throws IllegalArgumentException, CancelException, IOException, CoreException {
int result = SuperGraphUtil.analyzeAndSaveSuperGraph(AllTests.superGraph, entryClass, "good02");
int result = SuperGraphUtil.analyzeAndSaveSuperGraph(TestSuite.superGraph, entryClass, "good02");
assertEquals(0, result);
return;
}
@Test
public void testGood03() throws IllegalArgumentException, CancelException, IOException, CoreException {
int result = SuperGraphUtil.analyzeAndSaveSuperGraph(AllTests.superGraph, entryClass, "good03");
int result = SuperGraphUtil.analyzeAndSaveSuperGraph(TestSuite.superGraph, entryClass, "good03");
assertEquals(0, result);
return;
}

View File

@ -16,6 +16,7 @@ import static org.junit.Assert.assertEquals;
import java.io.IOException;
import org.eclipse.core.runtime.CoreException;
import org.junit.Before;
import org.junit.Test;
import com.ibm.wala.util.CancelException;
@ -26,30 +27,35 @@ public class Test09 {
String entryClass = "Test09";
@Before
public void initTest() throws IllegalArgumentException, CancelException, IOException{
TestSuite.initTestSG(entryClass);
}
@Test
public void testBad() throws IllegalArgumentException, CancelException, IOException, CoreException {
int result = SuperGraphUtil.analyzeAndSaveSuperGraph(AllTests.superGraph, entryClass, "bad");
int result = SuperGraphUtil.analyzeAndSaveSuperGraph(TestSuite.superGraph, entryClass, "bad");
assertEquals(1, result);
return;
}
@Test
public void testGood01() throws IllegalArgumentException, CancelException, IOException, CoreException {
int result = SuperGraphUtil.analyzeAndSaveSuperGraph(AllTests.superGraph, entryClass, "good01");
int result = SuperGraphUtil.analyzeAndSaveSuperGraph(TestSuite.superGraph, entryClass, "good01");
assertEquals(0, result);
return;
}
@Test
public void testGood02() throws IllegalArgumentException, CancelException, IOException, CoreException {
int result = SuperGraphUtil.analyzeAndSaveSuperGraph(AllTests.superGraph, entryClass, "good02");
int result = SuperGraphUtil.analyzeAndSaveSuperGraph(TestSuite.superGraph, entryClass, "good02");
assertEquals(0, result);
return;
}
@Test
public void testGood03() throws IllegalArgumentException, CancelException, IOException, CoreException {
int result = SuperGraphUtil.analyzeAndSaveSuperGraph(AllTests.superGraph, entryClass, "good03");
int result = SuperGraphUtil.analyzeAndSaveSuperGraph(TestSuite.superGraph, entryClass, "good03");
assertEquals(0, result);
return;
}

View File

@ -16,6 +16,7 @@ import static org.junit.Assert.assertEquals;
import java.io.IOException;
import org.eclipse.core.runtime.CoreException;
import org.junit.Before;
import org.junit.Test;
import com.ibm.wala.util.CancelException;
@ -26,30 +27,35 @@ public class Test10 {
String entryClass = "Test10";
@Before
public void initTest() throws IllegalArgumentException, CancelException, IOException{
TestSuite.initTestSG(entryClass);
}
@Test
public void testBad() throws IllegalArgumentException, CancelException, IOException, CoreException {
int result = SuperGraphUtil.analyzeAndSaveSuperGraph(AllTests.superGraph, entryClass, "bad");
int result = SuperGraphUtil.analyzeAndSaveSuperGraph(TestSuite.superGraph, entryClass, "bad");
assertEquals(1, result);
return;
}
@Test
public void testGood01() throws IllegalArgumentException, CancelException, IOException, CoreException {
int result = SuperGraphUtil.analyzeAndSaveSuperGraph(AllTests.superGraph, entryClass, "good01");
int result = SuperGraphUtil.analyzeAndSaveSuperGraph(TestSuite.superGraph, entryClass, "good01");
assertEquals(0, result);
return;
}
@Test
public void testGood02() throws IllegalArgumentException, CancelException, IOException, CoreException {
int result = SuperGraphUtil.analyzeAndSaveSuperGraph(AllTests.superGraph, entryClass, "good02");
int result = SuperGraphUtil.analyzeAndSaveSuperGraph(TestSuite.superGraph, entryClass, "good02");
assertEquals(0, result);
return;
}
@Test
public void testGood03() throws IllegalArgumentException, CancelException, IOException, CoreException {
int result = SuperGraphUtil.analyzeAndSaveSuperGraph(AllTests.superGraph, entryClass, "good03");
int result = SuperGraphUtil.analyzeAndSaveSuperGraph(TestSuite.superGraph, entryClass, "good03");
assertEquals(0, result);
return;
}

View File

@ -16,6 +16,7 @@ import static org.junit.Assert.assertEquals;
import java.io.IOException;
import org.eclipse.core.runtime.CoreException;
import org.junit.Before;
import org.junit.Test;
import com.ibm.wala.util.CancelException;
@ -26,44 +27,49 @@ public class Test11 {
String entryClass = "Test11";
@Before
public void initTest() throws IllegalArgumentException, CancelException, IOException{
TestSuite.initTestSG(entryClass);
}
@Test
public void testBad() throws IllegalArgumentException, CancelException, IOException, CoreException {
int result = SuperGraphUtil.analyzeAndSaveSuperGraph(AllTests.superGraph, entryClass, "bad");
int result = SuperGraphUtil.analyzeAndSaveSuperGraph(TestSuite.superGraph, entryClass, "bad");
assertEquals(1, result);
return;
}
@Test
public void testGood01() throws IllegalArgumentException, CancelException, IOException, CoreException {
int result = SuperGraphUtil.analyzeAndSaveSuperGraph(AllTests.superGraph, entryClass, "good01");
int result = SuperGraphUtil.analyzeAndSaveSuperGraph(TestSuite.superGraph, entryClass, "good01");
assertEquals(0, result);
return;
}
@Test
public void testGood02() throws IllegalArgumentException, CancelException, IOException, CoreException {
int result = SuperGraphUtil.analyzeAndSaveSuperGraph(AllTests.superGraph, entryClass, "good02");
int result = SuperGraphUtil.analyzeAndSaveSuperGraph(TestSuite.superGraph, entryClass, "good02");
assertEquals(0, result);
return;
}
@Test
public void testGood03() throws IllegalArgumentException, CancelException, IOException, CoreException {
int result = SuperGraphUtil.analyzeAndSaveSuperGraph(AllTests.superGraph, entryClass, "good03");
int result = SuperGraphUtil.analyzeAndSaveSuperGraph(TestSuite.superGraph, entryClass, "good03");
assertEquals(0, result);
return;
}
@Test
public void testGood04() throws IllegalArgumentException, CancelException, IOException, CoreException {
int result = SuperGraphUtil.analyzeAndSaveSuperGraph(AllTests.superGraph, entryClass, "good04");
int result = SuperGraphUtil.analyzeAndSaveSuperGraph(TestSuite.superGraph, entryClass, "good04");
assertEquals(0, result);
return;
}
@Test
public void testGood05() throws IllegalArgumentException, CancelException, IOException, CoreException {
int result = SuperGraphUtil.analyzeAndSaveSuperGraph(AllTests.superGraph, entryClass, "good05");
int result = SuperGraphUtil.analyzeAndSaveSuperGraph(TestSuite.superGraph, entryClass, "good05");
assertEquals(0, result);
return;
}

View File

@ -16,6 +16,7 @@ import static org.junit.Assert.assertEquals;
import java.io.IOException;
import org.eclipse.core.runtime.CoreException;
import org.junit.Before;
import org.junit.Test;
import com.ibm.wala.util.CancelException;
@ -26,16 +27,21 @@ public class Test12 {
String entryClass = "Test12";
@Before
public void initTest() throws IllegalArgumentException, CancelException, IOException{
TestSuite.initTestSG(entryClass);
}
@Test
public void testBad() throws IllegalArgumentException, CancelException, IOException, CoreException {
int result = SuperGraphUtil.analyzeAndSaveSuperGraph(AllTests.superGraph, entryClass, "bad");
int result = SuperGraphUtil.analyzeAndSaveSuperGraph(TestSuite.superGraph, entryClass, "bad");
assertEquals(1, result);
return;
}
@Test
public void testGood01() throws IllegalArgumentException, CancelException, IOException, CoreException {
int result = SuperGraphUtil.analyzeAndSaveSuperGraph(AllTests.superGraph, entryClass, "good01");
int result = SuperGraphUtil.analyzeAndSaveSuperGraph(TestSuite.superGraph, entryClass, "good01");
assertEquals(0, result);
return;
}

View File

@ -16,6 +16,7 @@ import static org.junit.Assert.assertEquals;
import java.io.IOException;
import org.eclipse.core.runtime.CoreException;
import org.junit.Before;
import org.junit.Test;
import com.ibm.wala.util.CancelException;
@ -26,23 +27,28 @@ public class Test13 {
String entryClass = "Test13";
@Before
public void initTest() throws IllegalArgumentException, CancelException, IOException{
TestSuite.initTestSG(entryClass);
}
@Test
public void testBad() throws IllegalArgumentException, CancelException, IOException, CoreException {
int result = SuperGraphUtil.analyzeAndSaveSuperGraph(AllTests.superGraph, entryClass, "bad");
int result = SuperGraphUtil.analyzeAndSaveSuperGraph(TestSuite.superGraph, entryClass, "bad");
assertEquals(1, result);
return;
}
@Test
public void testGood01() throws IllegalArgumentException, CancelException, IOException, CoreException {
int result = SuperGraphUtil.analyzeAndSaveSuperGraph(AllTests.superGraph, entryClass, "good01");
int result = SuperGraphUtil.analyzeAndSaveSuperGraph(TestSuite.superGraph, entryClass, "good01");
assertEquals(0, result);
return;
}
@Test
public void testGood02() throws IllegalArgumentException, CancelException, IOException, CoreException {
int result = SuperGraphUtil.analyzeAndSaveSuperGraph(AllTests.superGraph, entryClass, "good02");
int result = SuperGraphUtil.analyzeAndSaveSuperGraph(TestSuite.superGraph, entryClass, "good02");
assertEquals(0, result);
return;
}

View File

@ -16,6 +16,7 @@ import static org.junit.Assert.assertEquals;
import java.io.IOException;
import org.eclipse.core.runtime.CoreException;
import org.junit.Before;
import org.junit.Test;
import com.ibm.wala.util.CancelException;
@ -26,23 +27,28 @@ public class Test14 {
String entryClass = "Test14";
@Before
public void initTest() throws IllegalArgumentException, CancelException, IOException{
TestSuite.initTestSG(entryClass);
}
@Test
public void testBad() throws IllegalArgumentException, CancelException, IOException, CoreException {
int result = SuperGraphUtil.analyzeAndSaveSuperGraph(AllTests.superGraph, entryClass, "bad");
int result = SuperGraphUtil.analyzeAndSaveSuperGraph(TestSuite.superGraph, entryClass, "bad");
assertEquals(1, result);
return;
}
@Test
public void testGood01() throws IllegalArgumentException, CancelException, IOException, CoreException {
int result = SuperGraphUtil.analyzeAndSaveSuperGraph(AllTests.superGraph, entryClass, "good01");
int result = SuperGraphUtil.analyzeAndSaveSuperGraph(TestSuite.superGraph, entryClass, "good01");
assertEquals(0, result);
return;
}
@Test
public void testGood02() throws IllegalArgumentException, CancelException, IOException, CoreException {
int result = SuperGraphUtil.analyzeAndSaveSuperGraph(AllTests.superGraph, entryClass, "good02");
int result = SuperGraphUtil.analyzeAndSaveSuperGraph(TestSuite.superGraph, entryClass, "good02");
assertEquals(0, result);
return;
}

View File

@ -16,6 +16,7 @@ import static org.junit.Assert.assertEquals;
import java.io.IOException;
import org.eclipse.core.runtime.CoreException;
import org.junit.Before;
import org.junit.Test;
import com.ibm.wala.util.CancelException;
@ -26,30 +27,35 @@ public class Test15 {
String entryClass = "Test15";
@Before
public void initTest() throws IllegalArgumentException, CancelException, IOException{
TestSuite.initTestSG(entryClass);
}
@Test
public void testBad() throws IllegalArgumentException, CancelException, IOException, CoreException {
int result = SuperGraphUtil.analyzeAndSaveSuperGraph(AllTests.superGraph, entryClass, "bad");
int result = SuperGraphUtil.analyzeAndSaveSuperGraph(TestSuite.superGraph, entryClass, "bad");
assertEquals(1, result);
return;
}
@Test
public void testGood01() throws IllegalArgumentException, CancelException, IOException, CoreException {
int result = SuperGraphUtil.analyzeAndSaveSuperGraph(AllTests.superGraph, entryClass, "good01");
int result = SuperGraphUtil.analyzeAndSaveSuperGraph(TestSuite.superGraph, entryClass, "good01");
assertEquals(0, result);
return;
}
@Test
public void testGood02() throws IllegalArgumentException, CancelException, IOException, CoreException {
int result = SuperGraphUtil.analyzeAndSaveSuperGraph(AllTests.superGraph, entryClass, "good02");
int result = SuperGraphUtil.analyzeAndSaveSuperGraph(TestSuite.superGraph, entryClass, "good02");
assertEquals(0, result);
return;
}
@Test
public void testGood03() throws IllegalArgumentException, CancelException, IOException, CoreException {
int result = SuperGraphUtil.analyzeAndSaveSuperGraph(AllTests.superGraph, entryClass, "good03");
int result = SuperGraphUtil.analyzeAndSaveSuperGraph(TestSuite.superGraph, entryClass, "good03");
assertEquals(0, result);
return;
}

View File

@ -16,6 +16,7 @@ import static org.junit.Assert.assertEquals;
import java.io.IOException;
import org.eclipse.core.runtime.CoreException;
import org.junit.Before;
import org.junit.Test;
import com.ibm.wala.util.CancelException;
@ -26,9 +27,14 @@ public class Test16 {
String entryClass = "Test16";
@Before
public void initTest() throws IllegalArgumentException, CancelException, IOException{
TestSuite.initTestSG(entryClass);
}
@Test
public void testBad() throws IllegalArgumentException, CancelException, IOException, CoreException {
int result = SuperGraphUtil.analyzeAndSaveSuperGraph(AllTests.superGraph, entryClass, "bad");
int result = SuperGraphUtil.analyzeAndSaveSuperGraph(TestSuite.superGraph, entryClass, "bad");
assertEquals(1, result);
return;
}

View File

@ -16,6 +16,7 @@ import static org.junit.Assert.assertEquals;
import java.io.IOException;
import org.eclipse.core.runtime.CoreException;
import org.junit.Before;
import org.junit.Test;
import com.ibm.wala.util.CancelException;
@ -26,9 +27,14 @@ public class Test17 {
String entryClass = "Test17";
@Before
public void initTest() throws IllegalArgumentException, CancelException, IOException{
TestSuite.initTestSG(entryClass);
}
@Test
public void testBad() throws IllegalArgumentException, CancelException, IOException, CoreException {
int result = SuperGraphUtil.analyzeAndSaveSuperGraph(AllTests.superGraph, entryClass, "bad");
int result = SuperGraphUtil.analyzeAndSaveSuperGraph(TestSuite.superGraph, entryClass, "bad");
assertEquals(2, result);
return;
}

View File

@ -16,6 +16,7 @@ import static org.junit.Assert.assertEquals;
import java.io.IOException;
import org.eclipse.core.runtime.CoreException;
import org.junit.Before;
import org.junit.Test;
import com.ibm.wala.util.CancelException;
@ -26,9 +27,14 @@ public class Test18 {
String entryClass = "Test18";
@Before
public void initTest() throws IllegalArgumentException, CancelException, IOException{
TestSuite.initTestSG(entryClass);
}
@Test
public void testBad() throws IllegalArgumentException, CancelException, IOException, CoreException {
int result = SuperGraphUtil.analyzeAndSaveSuperGraph(AllTests.superGraph, entryClass, "bad");
int result = SuperGraphUtil.analyzeAndSaveSuperGraph(TestSuite.superGraph, entryClass, "bad");
assertEquals(1, result);
return;
}

View File

@ -16,6 +16,7 @@ import static org.junit.Assert.assertEquals;
import java.io.IOException;
import org.eclipse.core.runtime.CoreException;
import org.junit.Before;
import org.junit.Test;
import com.ibm.wala.util.CancelException;
@ -26,9 +27,14 @@ public class Test19 {
String entryClass = "Test19";
@Before
public void initTest() throws IllegalArgumentException, CancelException, IOException{
TestSuite.initTestSG(entryClass);
}
@Test
public void testBad() throws IllegalArgumentException, CancelException, IOException, CoreException {
int result = SuperGraphUtil.analyzeAndSaveSuperGraph(AllTests.superGraph, entryClass, "bad");
int result = SuperGraphUtil.analyzeAndSaveSuperGraph(TestSuite.superGraph, entryClass, "bad");
assertEquals(2, result);
return;
}

View File

@ -0,0 +1,122 @@
/*
* (C) Copyright 2016 The University of Sheffield.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
*/
package eu.aniketos.dasca.dataflow.test;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import org.junit.runners.Suite.SuiteClasses;
import org.apache.log4j.Logger;
import eu.aniketos.dasca.dataflow.util.AnalysisUtil;
import eu.aniketos.dasca.dataflow.util.PlugInUtil;
import com.ibm.wala.cast.java.client.JavaSourceAnalysisEngine;
import com.ibm.wala.dataflow.IFDS.ICFGSupergraph;
import com.ibm.wala.ipa.callgraph.AnalysisCache;
import com.ibm.wala.ipa.callgraph.CallGraph;
import com.ibm.wala.properties.WalaProperties;
import com.ibm.wala.util.CancelException;
@RunWith(Suite.class)
@SuiteClasses({
Test01.class, Test02.class, Test03.class, Test04.class,
Test05.class, Test06.class, Test07.class, Test08.class,
Test09.class, Test10.class, Test11.class, Test12.class,
Test13.class, Test14.class, Test15.class, Test16.class,
Test17.class, Test18.class, Test19.class
})
public class TestSuite {
private static Logger log = AnalysisUtil.getLogger(TestSuite.class);
protected static ICFGSupergraph superGraph = null;
protected static String testDir = "../eu.aniketos.dasca.dataflow.test.data/src/main/java/eu/aniketos/dasca/dataflow/test/data/";
protected static List<String> sources = null;
protected static List<String> libs = null;
protected static String [] customEntryPoints = {
"Leu/aniketos/dasca/dataflow/test/data/Test01"
,"Leu/aniketos/dasca/dataflow/test/data/Test02"
,"Leu/aniketos/dasca/dataflow/test/data/Test03"
,"Leu/aniketos/dasca/dataflow/test/data/Test04"
,"Leu/aniketos/dasca/dataflow/test/data/Test05"
,"Leu/aniketos/dasca/dataflow/test/data/Test06"
,"Leu/aniketos/dasca/dataflow/test/data/Test07"
,"Leu/aniketos/dasca/dataflow/test/data/Test08"
,"Leu/aniketos/dasca/dataflow/test/data/Test09"
,"Leu/aniketos/dasca/dataflow/test/data/Test10"
,"Leu/aniketos/dasca/dataflow/test/data/Test11"
,"Leu/aniketos/dasca/dataflow/test/data/Test12"
,"Leu/aniketos/dasca/dataflow/test/data/Test13"
,"Leu/aniketos/dasca/dataflow/test/data/Test14"
,"Leu/aniketos/dasca/dataflow/test/data/Test15"
,"Leu/aniketos/dasca/dataflow/test/data/Test16"
,"Leu/aniketos/dasca/dataflow/test/data/Test17"
,"Leu/aniketos/dasca/dataflow/test/data/Test18"
,"Leu/aniketos/dasca/dataflow/test/data/Test19"
};
public static void logConfiguration() {
log.info("Test Configuration:");
log.info("===================");
log.info("Sources:");
for (String element : sources) {
log.info(" "+element);
}
log.info("Libs:");
for (String element : libs) {
log.info(" "+element);
}
log.info("J2SE:" + WalaProperties.J2SE_DIR);
}
public static void initTestSG(String test) throws IllegalArgumentException, CancelException, IOException{
List<String> entryPoints = new ArrayList<String>();
if (null != test) {
entryPoints.add("Leu/aniketos/dasca/dataflow/test/data/"+test);
}else{
entryPoints.addAll(Arrays.asList(customEntryPoints));
}
log.info("Generating Test Specific SG ("+ test +"):");
for (String element : entryPoints) {
log.info(" "+element);
}
JavaSourceAnalysisEngine engine = PlugInUtil.createECJJavaEngine(sources, libs,
entryPoints.stream().toArray(String[]::new));
CallGraph cg = engine.buildDefaultCallGraph();
AnalysisCache ac = new AnalysisCache();
superGraph = ICFGSupergraph.make(cg, ac);
log.info("CG size: "+cg.getNumberOfNodes());
log.info("SG size: "+superGraph.getNumberOfNodes());
}
@BeforeClass
public static void setUp() throws IllegalArgumentException, CancelException, IOException {
if (null != superGraph){
return;
}
sources = Arrays.asList(testDir);
libs = Arrays.asList(WalaProperties.getJ2SEJarFiles());
logConfiguration();
initTestSG(null); }
}

View File

@ -73,37 +73,18 @@ public class PlugInUtil {
public static JavaSourceAnalysisEngine
createECJJavaEngine(Collection<String> sources, List<String> libs) {
JavaSourceAnalysisEngine engine = new ECJJavaSourceAnalysisEngine() {
@Override
protected Iterable<Entrypoint> makeDefaultEntrypoints(AnalysisScope scope, IClassHierarchy cha) {
String [] classes= {
"Leu/aniketos/dasca/dataflow/test/data/Test01"
,"Leu/aniketos/dasca/dataflow/test/data/Test02"
,"Leu/aniketos/dasca/dataflow/test/data/Test03"
,"Leu/aniketos/dasca/dataflow/test/data/Test04"
,"Leu/aniketos/dasca/dataflow/test/data/Test05"
,"Leu/aniketos/dasca/dataflow/test/data/Test06"
,"Leu/aniketos/dasca/dataflow/test/data/Test07"
,"Leu/aniketos/dasca/dataflow/test/data/Test08"
,"Leu/aniketos/dasca/dataflow/test/data/Test09"
,"Leu/aniketos/dasca/dataflow/test/data/Test10"
,"Leu/aniketos/dasca/dataflow/test/data/Test11"
,"Leu/aniketos/dasca/dataflow/test/data/Test12"
,"Leu/aniketos/dasca/dataflow/test/data/Test13"
,"Leu/aniketos/dasca/dataflow/test/data/Test14"
,"Leu/aniketos/dasca/dataflow/test/data/Test15"
,"Leu/aniketos/dasca/dataflow/test/data/Test16"
,"Leu/aniketos/dasca/dataflow/test/data/Test17"
,"Leu/aniketos/dasca/dataflow/test/data/Test18"
,"Leu/aniketos/dasca/dataflow/test/data/Test19"
};
return Util.makeMainEntrypoints(JavaSourceAnalysisScope.SOURCE,cha, classes);
}
};
createECJJavaEngine(Collection<String> sources, List<String> libs, final String [] entryPoints) {
JavaSourceAnalysisEngine engine=null;
if(null == entryPoints){
engine = new ECJJavaSourceAnalysisEngine();
}else{
engine = new ECJJavaSourceAnalysisEngine() {
@Override
protected Iterable<Entrypoint> makeDefaultEntrypoints(AnalysisScope scope, IClassHierarchy cha) {
return Util.makeMainEntrypoints(JavaSourceAnalysisScope.SOURCE,cha, entryPoints);
}
};
}
engine.setExclusionsFile(REGRESSION_EXCLUSIONS);
populateScope(engine, sources, libs);
return engine;