switch to jUnit 4
git-svn-id: https://wala.svn.sourceforge.net/svnroot/wala/trunk@3739 f5eafffb-2e1d-0410-98e4-8ec43c5233c4
This commit is contained in:
parent
d0431b670a
commit
02e7bf2894
@ -4,10 +4,10 @@ Bundle-Name: %pluginName
|
||||
Bundle-SymbolicName: com.ibm.wala.core.tests;singleton:=true
|
||||
Bundle-Version: 1.1.3.qualifier
|
||||
Bundle-Vendor: %providerName
|
||||
Require-Bundle: org.junit,
|
||||
com.ibm.wala.shrike,
|
||||
Require-Bundle: com.ibm.wala.shrike,
|
||||
com.ibm.wala.core,
|
||||
org.eclipse.core.runtime
|
||||
org.eclipse.core.runtime,
|
||||
org.junit4;bundle-version="4.3.1"
|
||||
Bundle-Localization: plugin
|
||||
Export-Package: com.ibm.wala.core.tests.basic,
|
||||
com.ibm.wala.core.tests.callGraph,
|
||||
|
||||
@ -11,7 +11,7 @@
|
||||
<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value="=com.ibm.wala.core.tests"/>
|
||||
<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
|
||||
<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
|
||||
<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit3"/>
|
||||
<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit4"/>
|
||||
<listAttribute key="org.eclipse.jdt.launching.CLASSPATH">
|
||||
<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry containerPath="org.eclipse.jdt.launching.JRE_CONTAINER" javaProject="com.ibm.wala.core.tests" path="1" type="4"/> "/>
|
||||
<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry id="org.eclipse.jdt.launching.classpathentry.defaultClasspath"> <memento exportedEntriesOnly="false" project="com.ibm.wala.core.tests"/> </runtimeClasspathEntry> "/>
|
||||
|
||||
@ -1,27 +1,27 @@
|
||||
<?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="/com.ibm.wala.core.tests"/>
|
||||
</listAttribute>
|
||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
|
||||
<listEntry value="4"/>
|
||||
</listAttribute>
|
||||
<booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="true"/>
|
||||
<stringAttribute key="org.eclipse.debug.ui.ATTR_CAPTURE_IN_FILE" value="c:/temp/console"/>
|
||||
<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value="=com.ibm.wala.core.tests"/>
|
||||
<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
|
||||
<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
|
||||
<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit3"/>
|
||||
<listAttribute key="org.eclipse.jdt.launching.CLASSPATH">
|
||||
<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry containerPath="org.eclipse.jdt.launching.JRE_CONTAINER" javaProject="com.ibm.wala.core.tests" path="1" type="4"/> "/>
|
||||
<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry id="org.eclipse.jdt.launching.classpathentry.defaultClasspath"> <memento exportedEntriesOnly="false" project="com.ibm.wala.core.tests"/> </runtimeClasspathEntry> "/>
|
||||
<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry path="3" projectName="com.ibm.wala.core.testdata" type="1"/> "/>
|
||||
<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/com.ibm.wala.core.testdata/bin" path="3" type="2"/> "/>
|
||||
<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/com.ibm.wala.core.testdata/src" path="3" type="2"/> "/>
|
||||
</listAttribute>
|
||||
<booleanAttribute key="org.eclipse.jdt.launching.DEFAULT_CLASSPATH" value="false"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.JRE_CONTAINER" value="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value=""/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="com.ibm.wala.core.tests"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xmx800M -Dcom.ibm.wala.junit.profile=short -ea -Dcom.ibm.wala.fixedpoint.impl.verbose=true"/>
|
||||
</launchConfiguration>
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<launchConfiguration type="org.eclipse.jdt.junit.launchconfig">
|
||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
|
||||
<listEntry value="/com.ibm.wala.core.tests"/>
|
||||
</listAttribute>
|
||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
|
||||
<listEntry value="4"/>
|
||||
</listAttribute>
|
||||
<booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="true"/>
|
||||
<stringAttribute key="org.eclipse.debug.ui.ATTR_CAPTURE_IN_FILE" value="c:/temp/console"/>
|
||||
<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value="=com.ibm.wala.core.tests"/>
|
||||
<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
|
||||
<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
|
||||
<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit4"/>
|
||||
<listAttribute key="org.eclipse.jdt.launching.CLASSPATH">
|
||||
<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry containerPath="org.eclipse.jdt.launching.JRE_CONTAINER" javaProject="com.ibm.wala.core.tests" path="1" type="4"/> "/>
|
||||
<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry id="org.eclipse.jdt.launching.classpathentry.defaultClasspath"> <memento exportedEntriesOnly="false" project="com.ibm.wala.core.tests"/> </runtimeClasspathEntry> "/>
|
||||
<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry path="3" projectName="com.ibm.wala.core.testdata" type="1"/> "/>
|
||||
<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/com.ibm.wala.core.testdata/bin" path="3" type="2"/> "/>
|
||||
<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/com.ibm.wala.core.testdata/src" path="3" type="2"/> "/>
|
||||
</listAttribute>
|
||||
<booleanAttribute key="org.eclipse.jdt.launching.DEFAULT_CLASSPATH" value="false"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.JRE_CONTAINER" value="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value=""/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="com.ibm.wala.core.tests"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xmx800M -Dcom.ibm.wala.junit.profile=short -ea -Dcom.ibm.wala.fixedpoint.impl.verbose=true"/>
|
||||
</launchConfiguration>
|
||||
|
||||
@ -10,7 +10,7 @@
|
||||
<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value="=com.ibm.wala.core.tests"/>
|
||||
<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
|
||||
<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
|
||||
<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit3"/>
|
||||
<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit4"/>
|
||||
<listAttribute key="org.eclipse.jdt.launching.CLASSPATH">
|
||||
<listEntry value="<?xml version="1.0" encoding="UTF-8"?> <runtimeClasspathEntry containerPath="org.eclipse.jdt.launching.JRE_CONTAINER" javaProject="com.ibm.wala.core.tests" path="1" type="4"/> "/>
|
||||
<listEntry value="<?xml version="1.0" encoding="UTF-8"?> <runtimeClasspathEntry id="org.eclipse.jdt.launching.classpathentry.defaultClasspath"> <memento exportedEntriesOnly="false" project="com.ibm.wala.core.tests"/> </runtimeClasspathEntry> "/>
|
||||
|
||||
@ -10,6 +10,9 @@
|
||||
*******************************************************************************/
|
||||
package com.ibm.wala.core.tests.basic;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.ibm.wala.core.tests.util.WalaTestCase;
|
||||
import com.ibm.wala.dataflow.graph.AbstractMeetOperator;
|
||||
import com.ibm.wala.dataflow.graph.BitVectorFilter;
|
||||
@ -45,7 +48,7 @@ public class GraphDataflowTest extends WalaTestCase {
|
||||
* A simple test of the GraphBitVectorDataflow system
|
||||
* @throws CancelException
|
||||
*/
|
||||
public void testSolverNodeEdge() throws CancelException {
|
||||
@Test public void testSolverNodeEdge() throws CancelException {
|
||||
Graph<String> G = buildGraph();
|
||||
String result = solveNodeEdge(G);
|
||||
System.err.println(result);
|
||||
@ -53,14 +56,14 @@ public class GraphDataflowTest extends WalaTestCase {
|
||||
System.err.println("Uh oh.");
|
||||
System.err.println(expectedStringNodeEdge());
|
||||
}
|
||||
assertEquals(expectedStringNodeEdge(), result);
|
||||
Assert.assertEquals(expectedStringNodeEdge(), result);
|
||||
}
|
||||
|
||||
public void testSolverNodeOnly() throws CancelException {
|
||||
@Test public void testSolverNodeOnly() throws CancelException {
|
||||
Graph<String> G = buildGraph();
|
||||
String result = solveNodeOnly(G);
|
||||
System.err.println(result);
|
||||
assertEquals(expectedStringNodeOnly(), result);
|
||||
Assert.assertEquals(expectedStringNodeOnly(), result);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -10,6 +10,8 @@
|
||||
*******************************************************************************/
|
||||
package com.ibm.wala.core.tests.basic;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import com.ibm.wala.core.tests.util.WalaTestCase;
|
||||
import com.ibm.wala.util.intset.OrdinalSet;
|
||||
|
||||
@ -18,7 +20,7 @@ import com.ibm.wala.util.intset.OrdinalSet;
|
||||
*/
|
||||
public class OrdinalSetTest extends WalaTestCase {
|
||||
|
||||
public void test1() {
|
||||
@Test public void test1() {
|
||||
OrdinalSet.unify(OrdinalSet.empty(), OrdinalSet.empty());
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -15,6 +15,9 @@ import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.ibm.wala.classLoader.IClass;
|
||||
import com.ibm.wala.classLoader.IMethod;
|
||||
import com.ibm.wala.core.tests.util.TestConstants;
|
||||
@ -54,11 +57,8 @@ public class CallGraphTest extends WalaTestCase {
|
||||
justThisTest(CallGraphTest.class);
|
||||
}
|
||||
|
||||
public CallGraphTest(String arg0) {
|
||||
super(arg0);
|
||||
}
|
||||
|
||||
public void testJava_cup() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
@Test public void testJava_cup() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
AnalysisScope scope = CallGraphTestUtil.makeJ2SEAnalysisScope(TestConstants.JAVA_CUP, CallGraphTestUtil.REGRESSION_EXCLUSIONS);
|
||||
ClassHierarchy cha = ClassHierarchy.make(scope);
|
||||
Iterable<Entrypoint> entrypoints = com.ibm.wala.ipa.callgraph.impl.Util.makeMainEntrypoints(scope, cha,
|
||||
@ -68,7 +68,7 @@ public class CallGraphTest extends WalaTestCase {
|
||||
doCallGraphs(options, new AnalysisCache(), cha, scope, useShortProfile());
|
||||
}
|
||||
|
||||
public void testBcelVerifier() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
@Test public void testBcelVerifier() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
AnalysisScope scope = CallGraphTestUtil.makeJ2SEAnalysisScope(TestConstants.BCEL, CallGraphTestUtil.REGRESSION_EXCLUSIONS);
|
||||
ClassHierarchy cha = ClassHierarchy.make(scope);
|
||||
Iterable<Entrypoint> entrypoints = com.ibm.wala.ipa.callgraph.impl.Util.makeMainEntrypoints(scope, cha,
|
||||
@ -78,7 +78,7 @@ public class CallGraphTest extends WalaTestCase {
|
||||
doCallGraphs(options, new AnalysisCache(), cha, scope);
|
||||
}
|
||||
|
||||
public void testJLex() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
@Test public void testJLex() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
AnalysisScope scope = CallGraphTestUtil.makeJ2SEAnalysisScope(TestConstants.JLEX, CallGraphTestUtil.REGRESSION_EXCLUSIONS);
|
||||
ClassHierarchy cha = ClassHierarchy.make(scope);
|
||||
Iterable<Entrypoint> entrypoints = com.ibm.wala.ipa.callgraph.impl.Util
|
||||
@ -88,7 +88,7 @@ public class CallGraphTest extends WalaTestCase {
|
||||
doCallGraphs(options, new AnalysisCache(), cha, scope);
|
||||
}
|
||||
|
||||
public void testCornerCases() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
@Test public void testCornerCases() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
AnalysisScope scope = CallGraphTestUtil.makeJ2SEAnalysisScope(TestConstants.WALA_TESTDATA,
|
||||
CallGraphTestUtil.REGRESSION_EXCLUSIONS);
|
||||
ClassHierarchy cha = ClassHierarchy.make(scope);
|
||||
@ -100,14 +100,14 @@ public class CallGraphTest extends WalaTestCase {
|
||||
// we expect a warning or two about class Abstract1, which has no concrete
|
||||
// subclasses
|
||||
String ws = Warnings.asString();
|
||||
assertTrue("failed to report a warning about Abstract1", ws.indexOf("cornerCases/Abstract1") > -1);
|
||||
Assert.assertTrue("failed to report a warning about Abstract1", ws.indexOf("cornerCases/Abstract1") > -1);
|
||||
|
||||
// we do not expect a warning about class Abstract2, which has a concrete
|
||||
// subclasses
|
||||
assertTrue("reported a warning about Abstract2", ws.indexOf("cornerCases/Abstract2") == -1);
|
||||
Assert.assertTrue("reported a warning about Abstract2", ws.indexOf("cornerCases/Abstract2") == -1);
|
||||
}
|
||||
|
||||
public void testHello() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
@Test public void testHello() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
AnalysisScope scope = CallGraphTestUtil.makeJ2SEAnalysisScope(TestConstants.HELLO, CallGraphTestUtil.REGRESSION_EXCLUSIONS);
|
||||
ClassHierarchy cha = ClassHierarchy.make(scope);
|
||||
Iterable<Entrypoint> entrypoints = com.ibm.wala.ipa.callgraph.impl.Util.makeMainEntrypoints(scope, cha,
|
||||
@ -117,7 +117,7 @@ public class CallGraphTest extends WalaTestCase {
|
||||
doCallGraphs(options, new AnalysisCache(), cha, scope);
|
||||
}
|
||||
|
||||
public void testStaticInit() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
@Test public void testStaticInit() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
AnalysisScope scope = CallGraphTestUtil.makeJ2SEAnalysisScope(TestConstants.WALA_TESTDATA,
|
||||
CallGraphTestUtil.REGRESSION_EXCLUSIONS);
|
||||
ClassHierarchy cha = ClassHierarchy.make(scope);
|
||||
@ -132,15 +132,15 @@ public class CallGraphTest extends WalaTestCase {
|
||||
break;
|
||||
}
|
||||
}
|
||||
assertTrue(foundDoNothing);
|
||||
Assert.assertTrue(foundDoNothing);
|
||||
options.setHandleStaticInit(false);
|
||||
cg = CallGraphTestUtil.buildZeroCFA(options, new AnalysisCache(), cha, scope, false);
|
||||
for (CGNode n : cg) {
|
||||
assertTrue(!n.toString().contains("doNothing"));
|
||||
Assert.assertTrue(!n.toString().contains("doNothing"));
|
||||
}
|
||||
}
|
||||
|
||||
public void testRecursion() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
@Test public void testRecursion() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
AnalysisScope scope = CallGraphTestUtil.makeJ2SEAnalysisScope(TestConstants.WALA_TESTDATA,
|
||||
CallGraphTestUtil.REGRESSION_EXCLUSIONS);
|
||||
ClassHierarchy cha = ClassHierarchy.make(scope);
|
||||
@ -151,7 +151,7 @@ public class CallGraphTest extends WalaTestCase {
|
||||
doCallGraphs(options, new AnalysisCache(), cha, scope);
|
||||
}
|
||||
|
||||
public void testHelloAllEntrypoints() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
@Test public void testHelloAllEntrypoints() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
AnalysisScope scope = CallGraphTestUtil.makeJ2SEAnalysisScope(TestConstants.HELLO, CallGraphTestUtil.REGRESSION_EXCLUSIONS);
|
||||
ClassHierarchy cha = ClassHierarchy.make(scope);
|
||||
Iterable<Entrypoint> entrypoints = new AllApplicationEntrypoints(scope, cha);
|
||||
@ -160,7 +160,7 @@ public class CallGraphTest extends WalaTestCase {
|
||||
doCallGraphs(options, new AnalysisCache(), cha, scope);
|
||||
}
|
||||
|
||||
public void testIO() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
@Test public void testIO() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
AnalysisScope scope = CallGraphTestUtil.makeJ2SEAnalysisScope("primordial.txt", CallGraphTestUtil.REGRESSION_EXCLUSIONS);
|
||||
ClassHierarchy cha = ClassHierarchy.make(scope);
|
||||
Iterable<Entrypoint> entrypoints = makePrimordialPublicEntrypoints(scope, cha, "java/io");
|
||||
@ -189,7 +189,7 @@ public class CallGraphTest extends WalaTestCase {
|
||||
};
|
||||
}
|
||||
|
||||
public void testPrimordial() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
@Test public void testPrimordial() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
if (useShortProfile()) {
|
||||
return;
|
||||
}
|
||||
@ -245,7 +245,7 @@ public class CallGraphTest extends WalaTestCase {
|
||||
GraphIntegrity.check(cg);
|
||||
} catch (UnsoundGraphException e1) {
|
||||
e1.printStackTrace();
|
||||
assertTrue(e1.getMessage(), false);
|
||||
Assert.assertTrue(e1.getMessage(), false);
|
||||
}
|
||||
|
||||
Set<MethodReference> rtaMethods = CallGraphStats.collectMethods(cg);
|
||||
@ -316,7 +316,7 @@ public class CallGraphTest extends WalaTestCase {
|
||||
GraphIntegrity.check(icfg);
|
||||
} catch (UnsoundGraphException e) {
|
||||
e.printStackTrace();
|
||||
assertTrue(false);
|
||||
Assert.assertTrue(false);
|
||||
}
|
||||
|
||||
// perform a little icfg exercise
|
||||
@ -344,7 +344,7 @@ public class CallGraphTest extends WalaTestCase {
|
||||
try {
|
||||
GraphIntegrity.check(cg);
|
||||
} catch (UnsoundGraphException e1) {
|
||||
assertTrue(e1.getMessage(), false);
|
||||
Assert.assertTrue(e1.getMessage(), false);
|
||||
}
|
||||
Set<MethodReference> callGraphMethods = CallGraphStats.collectMethods(cg);
|
||||
System.err.println(thisAlgorithm + " methods reached: " + callGraphMethods.size());
|
||||
|
||||
@ -15,6 +15,8 @@ import java.util.Set;
|
||||
|
||||
import junit.framework.Assert;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import com.ibm.wala.core.tests.util.TestConstants;
|
||||
import com.ibm.wala.core.tests.util.WalaTestCase;
|
||||
import com.ibm.wala.ipa.callgraph.AnalysisCache;
|
||||
@ -36,7 +38,7 @@ import com.ibm.wala.util.CancelException;
|
||||
*/
|
||||
public class ClassConstantTest extends WalaTestCase {
|
||||
|
||||
public void testClassConstants() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
@Test public void testClassConstants() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
|
||||
AnalysisScope scope = CallGraphTestUtil.makeJ2SEAnalysisScope(TestConstants.WALA_TESTDATA,
|
||||
CallGraphTestUtil.REGRESSION_EXCLUSIONS);
|
||||
|
||||
@ -14,6 +14,9 @@ import java.io.IOException;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.ibm.wala.classLoader.CallSiteReference;
|
||||
import com.ibm.wala.core.tests.util.TestConstants;
|
||||
import com.ibm.wala.core.tests.util.WalaTestCase;
|
||||
@ -36,7 +39,7 @@ import com.ibm.wala.util.CancelException;
|
||||
*/
|
||||
public class CloneTest extends WalaTestCase {
|
||||
|
||||
public void testClone() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
@Test public void testClone() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
|
||||
AnalysisScope scope = CallGraphTestUtil.makeJ2SEAnalysisScope(TestConstants.WALA_TESTDATA, CallGraphTestUtil.REGRESSION_EXCLUSIONS);
|
||||
ClassHierarchy cha = ClassHierarchy.make(scope);
|
||||
@ -62,7 +65,7 @@ public class CloneTest extends WalaTestCase {
|
||||
for (Iterator<CGNode> k = targets.iterator(); k.hasNext();) {
|
||||
System.err.println(" " + k.next());
|
||||
}
|
||||
fail("found " + targets.size() + " targets for " + site + " in " + node);
|
||||
Assert.fail("found " + targets.size() + " targets for " + site + " in " + node);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -12,6 +12,8 @@ package com.ibm.wala.core.tests.callGraph;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import com.ibm.wala.core.tests.util.WalaTestCase;
|
||||
import com.ibm.wala.ipa.cha.ClassHierarchyException;
|
||||
import com.ibm.wala.util.CancelException;
|
||||
@ -35,9 +37,8 @@ public class DebuggingBitsetCallGraphTest extends WalaTestCase {
|
||||
|
||||
private final CallGraphTest graphTest;
|
||||
|
||||
public DebuggingBitsetCallGraphTest(String arg0) {
|
||||
super(arg0);
|
||||
graphTest = new CallGraphTest(arg0);
|
||||
public DebuggingBitsetCallGraphTest() {
|
||||
graphTest = new CallGraphTest();
|
||||
}
|
||||
|
||||
private void runBitsetTest(MutableIntSetFactory p, MutableIntSetFactory s) throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
@ -50,23 +51,23 @@ public class DebuggingBitsetCallGraphTest extends WalaTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
public void testBimodalSparse() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
@Test public void testBimodalSparse() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
runBitsetTest(new BimodalMutableIntSetFactory(), new MutableSparseIntSetFactory());
|
||||
}
|
||||
|
||||
public void testSharedBimodal() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
@Test public void testSharedBimodal() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
runBitsetTest(new MutableSharedBitVectorIntSetFactory(), new BimodalMutableIntSetFactory());
|
||||
}
|
||||
|
||||
public void testSharedSparse() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
@Test public void testSharedSparse() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
runBitsetTest(new MutableSharedBitVectorIntSetFactory(), new MutableSparseIntSetFactory());
|
||||
}
|
||||
|
||||
public void testSharedBitVector() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
@Test public void testSharedBitVector() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
runBitsetTest(new MutableSharedBitVectorIntSetFactory(), new BitVectorIntSetFactory());
|
||||
}
|
||||
|
||||
public void testSemiSparseShared() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
@Test public void testSemiSparseShared() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
runBitsetTest(new SemiSparseMutableIntSetFactory(), new MutableSharedBitVectorIntSetFactory());
|
||||
}
|
||||
|
||||
|
||||
@ -14,6 +14,8 @@ import java.io.IOException;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import com.ibm.wala.classLoader.CallSiteReference;
|
||||
import com.ibm.wala.core.tests.util.TestConstants;
|
||||
import com.ibm.wala.core.tests.util.WalaTestCase;
|
||||
@ -102,11 +104,11 @@ public class PiNodeCallGraphTest extends WalaTestCase {
|
||||
assert numberOfCalls == desiredNumberOfCalls;
|
||||
}
|
||||
|
||||
public void testNoPiNodes() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
@Test public void testNoPiNodes() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
checkCallAssertions(doGraph(false), 2, 2);
|
||||
}
|
||||
|
||||
public void testPiNodes() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
@Test public void testPiNodes() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
checkCallAssertions(doGraph(true), 1, 2);
|
||||
}
|
||||
|
||||
|
||||
@ -15,6 +15,9 @@ import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.ibm.wala.classLoader.IClass;
|
||||
import com.ibm.wala.classLoader.IMethod;
|
||||
import com.ibm.wala.core.tests.util.TestConstants;
|
||||
@ -52,7 +55,7 @@ public class ReflectionTest extends WalaTestCase {
|
||||
/**
|
||||
* test that when analyzing Reflect1.main(), there is no warning about "Integer".
|
||||
*/
|
||||
public void testReflect1() throws WalaException, IllegalArgumentException, CancelException, IOException {
|
||||
@Test public void testReflect1() throws WalaException, IllegalArgumentException, CancelException, IOException {
|
||||
AnalysisScope scope = CallGraphTestUtil.makeJ2SEAnalysisScope(TestConstants.WALA_TESTDATA, "Java60RegressionExclusions.txt");
|
||||
ClassHierarchy cha = ClassHierarchy.make(scope);
|
||||
Iterable<Entrypoint> entrypoints = com.ibm.wala.ipa.callgraph.impl.Util.makeMainEntrypoints(scope, cha,
|
||||
@ -67,7 +70,7 @@ public class ReflectionTest extends WalaTestCase {
|
||||
continue;
|
||||
}
|
||||
if (w.toString().indexOf("Integer") >= 0) {
|
||||
assertTrue(w.toString(), false);
|
||||
Assert.assertTrue(w.toString(), false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -76,7 +79,7 @@ public class ReflectionTest extends WalaTestCase {
|
||||
* Test that when analyzing reflect2, the call graph includes a node for java.lang.Integer.<clinit>. This should be
|
||||
* forced by the call for Class.forName("java.lang.Integer").
|
||||
*/
|
||||
public void testReflect2() throws WalaException, IllegalArgumentException, CancelException, IOException {
|
||||
@Test public void testReflect2() throws WalaException, IllegalArgumentException, CancelException, IOException {
|
||||
AnalysisScope scope = CallGraphTestUtil.makeJ2SEAnalysisScope(TestConstants.WALA_TESTDATA, "Java60RegressionExclusions.txt");
|
||||
ClassHierarchy cha = ClassHierarchy.make(scope);
|
||||
Iterable<Entrypoint> entrypoints = com.ibm.wala.ipa.callgraph.impl.Util.makeMainEntrypoints(scope, cha,
|
||||
@ -87,13 +90,13 @@ public class ReflectionTest extends WalaTestCase {
|
||||
TypeReference tr = TypeReference.findOrCreate(ClassLoaderReference.Application, "Ljava/lang/Integer");
|
||||
MethodReference mr = MethodReference.findOrCreate(tr, "<clinit>", "()V");
|
||||
Set<CGNode> nodes = cg.getNodes(mr);
|
||||
assertFalse(nodes.isEmpty());
|
||||
Assert.assertFalse(nodes.isEmpty());
|
||||
}
|
||||
|
||||
/**
|
||||
* Check that when analyzing Reflect3, the successors of newInstance do not include reflection/Reflect3$Hash
|
||||
*/
|
||||
public void testReflect3() throws IOException, ClassHierarchyException, IllegalArgumentException, CancelException {
|
||||
@Test public void testReflect3() throws IOException, ClassHierarchyException, IllegalArgumentException, CancelException {
|
||||
AnalysisScope scope = CallGraphTestUtil.makeJ2SEAnalysisScope(TestConstants.WALA_TESTDATA, "Java60RegressionExclusions.txt");
|
||||
ClassHierarchy cha = ClassHierarchy.make(scope);
|
||||
Iterable<Entrypoint> entrypoints = com.ibm.wala.ipa.callgraph.impl.Util.makeMainEntrypoints(scope, cha,
|
||||
@ -117,13 +120,13 @@ public class ReflectionTest extends WalaTestCase {
|
||||
MethodReference extraneousMR = MethodReference.findOrCreate(extraneousTR, "<init>", "()V");
|
||||
Set<CGNode> extraneousNodes = cg.getNodes(extraneousMR);
|
||||
succNodes.retainAll(extraneousNodes);
|
||||
assertTrue(succNodes.isEmpty());
|
||||
Assert.assertTrue(succNodes.isEmpty());
|
||||
}
|
||||
|
||||
/**
|
||||
* Check that when analyzing Reflect4, successors of newInstance() do not include FilePermission ctor.
|
||||
*/
|
||||
public void testReflect4() throws IOException, ClassHierarchyException, IllegalArgumentException, CancelException {
|
||||
@Test public void testReflect4() throws IOException, ClassHierarchyException, IllegalArgumentException, CancelException {
|
||||
AnalysisScope scope = CallGraphTestUtil.makeJ2SEAnalysisScope(TestConstants.WALA_TESTDATA, "Java60RegressionExclusions.txt");
|
||||
ClassHierarchy cha = ClassHierarchy.make(scope);
|
||||
Iterable<Entrypoint> entrypoints = com.ibm.wala.ipa.callgraph.impl.Util.makeMainEntrypoints(scope, cha,
|
||||
@ -145,13 +148,13 @@ public class ReflectionTest extends WalaTestCase {
|
||||
MethodReference extraneousMR = MethodReference.findOrCreate(extraneousTR, "<init>", "(Ljava/lang/String;Ljava/lang/String;)V");
|
||||
Set<CGNode> extraneousNodes = cg.getNodes(extraneousMR);
|
||||
succNodes.retainAll(extraneousNodes);
|
||||
assertTrue(succNodes.isEmpty());
|
||||
Assert.assertTrue(succNodes.isEmpty());
|
||||
}
|
||||
|
||||
/**
|
||||
* Check that when analyzing Reflect5, successors of newInstance do not include a Reflect5$A ctor
|
||||
*/
|
||||
public void testReflect5() throws IOException, ClassHierarchyException, IllegalArgumentException, CancelException {
|
||||
@Test public void testReflect5() throws IOException, ClassHierarchyException, IllegalArgumentException, CancelException {
|
||||
AnalysisScope scope = CallGraphTestUtil.makeJ2SEAnalysisScope(TestConstants.WALA_TESTDATA, "Java60RegressionExclusions.txt");
|
||||
ClassHierarchy cha = ClassHierarchy.make(scope);
|
||||
Iterable<Entrypoint> entrypoints = com.ibm.wala.ipa.callgraph.impl.Util.makeMainEntrypoints(scope, cha,
|
||||
@ -173,13 +176,13 @@ public class ReflectionTest extends WalaTestCase {
|
||||
MethodReference extraneousMR = MethodReference.findOrCreate(extraneousTR, "<init>", "()V");
|
||||
Set<CGNode> extraneousNodes = cg.getNodes(extraneousMR);
|
||||
succNodes.retainAll(extraneousNodes);
|
||||
assertTrue(succNodes.isEmpty());
|
||||
Assert.assertTrue(succNodes.isEmpty());
|
||||
}
|
||||
|
||||
/**
|
||||
* Check that when analyzing Reflect6, successors of newInstance do not include a Reflect6$A ctor
|
||||
*/
|
||||
public void testReflect6() throws IOException, ClassHierarchyException, IllegalArgumentException, CancelException {
|
||||
@Test public void testReflect6() throws IOException, ClassHierarchyException, IllegalArgumentException, CancelException {
|
||||
AnalysisScope scope = CallGraphTestUtil.makeJ2SEAnalysisScope(TestConstants.WALA_TESTDATA, "Java60RegressionExclusions.txt");
|
||||
ClassHierarchy cha = ClassHierarchy.make(scope);
|
||||
Iterable<Entrypoint> entrypoints = com.ibm.wala.ipa.callgraph.impl.Util.makeMainEntrypoints(scope, cha,
|
||||
@ -201,11 +204,11 @@ public class ReflectionTest extends WalaTestCase {
|
||||
MethodReference extraneousMR = MethodReference.findOrCreate(extraneousTR, "<init>", "(I)V");
|
||||
Set<CGNode> extraneousNodes = cg.getNodes(extraneousMR);
|
||||
succNodes.retainAll(extraneousNodes);
|
||||
assertTrue(succNodes.isEmpty());
|
||||
Assert.assertTrue(succNodes.isEmpty());
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void testReflect7() throws Exception {
|
||||
@Test public void testReflect7() throws Exception {
|
||||
AnalysisScope scope = CallGraphTestUtil.makeJ2SEAnalysisScope(TestConstants.WALA_TESTDATA, "Java60RegressionExclusions.txt");
|
||||
ClassHierarchy cha = ClassHierarchy.make(scope);
|
||||
Iterable<Entrypoint> entrypoints = com.ibm.wala.ipa.callgraph.impl.Util.makeMainEntrypoints(scope, cha,
|
||||
@ -244,7 +247,7 @@ public class ReflectionTest extends WalaTestCase {
|
||||
}
|
||||
}
|
||||
}
|
||||
assertTrue(filePermConstrNewInstanceNode != null);
|
||||
Assert.assertTrue(filePermConstrNewInstanceNode != null);
|
||||
|
||||
// Now verify that this node has FilePermission.<init> children
|
||||
CGNode filePermInitNode = null;
|
||||
@ -257,7 +260,7 @@ public class ReflectionTest extends WalaTestCase {
|
||||
break;
|
||||
}
|
||||
}
|
||||
assertTrue(filePermInitNode != null);
|
||||
Assert.assertTrue(filePermInitNode != null);
|
||||
|
||||
// Furthermore, verify that main has a FilePermission.toString child
|
||||
CGNode filePermToStringNode = null;
|
||||
@ -268,7 +271,7 @@ public class ReflectionTest extends WalaTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
assertTrue(filePermToStringNode != null);
|
||||
Assert.assertTrue(filePermToStringNode != null);
|
||||
}
|
||||
|
||||
private Collection<CGNode> getSuccNodes(CallGraph cg, Collection<CGNode> nodes) {
|
||||
@ -285,7 +288,7 @@ public class ReflectionTest extends WalaTestCase {
|
||||
/**
|
||||
* Test that when analyzing reflect8, the call graph includes a node for java.lang.Integer.toString()
|
||||
*/
|
||||
public void testReflect8() throws WalaException, IllegalArgumentException, CancelException, IOException {
|
||||
@Test public void testReflect8() throws WalaException, IllegalArgumentException, CancelException, IOException {
|
||||
AnalysisScope scope = CallGraphTestUtil.makeJ2SEAnalysisScope(TestConstants.WALA_TESTDATA, "Java60RegressionExclusions.txt");
|
||||
ClassHierarchy cha = ClassHierarchy.make(scope);
|
||||
Iterable<Entrypoint> entrypoints = com.ibm.wala.ipa.callgraph.impl.Util.makeMainEntrypoints(scope, cha,
|
||||
@ -295,13 +298,13 @@ public class ReflectionTest extends WalaTestCase {
|
||||
TypeReference tr = TypeReference.findOrCreate(ClassLoaderReference.Primordial, "Ljava/lang/Integer");
|
||||
MethodReference mr = MethodReference.findOrCreate(tr, "toString", "()Ljava/lang/String;");
|
||||
Set<CGNode> nodes = cg.getNodes(mr);
|
||||
assertFalse(nodes.isEmpty());
|
||||
Assert.assertFalse(nodes.isEmpty());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that when analyzing reflect9, the call graph includes a node for java.lang.Integer.toString()
|
||||
*/
|
||||
public void testReflect9() throws WalaException, IllegalArgumentException, CancelException, IOException {
|
||||
@Test public void testReflect9() throws WalaException, IllegalArgumentException, CancelException, IOException {
|
||||
AnalysisScope scope = CallGraphTestUtil.makeJ2SEAnalysisScope(TestConstants.WALA_TESTDATA, "Java60RegressionExclusions.txt");
|
||||
ClassHierarchy cha = ClassHierarchy.make(scope);
|
||||
Iterable<Entrypoint> entrypoints = com.ibm.wala.ipa.callgraph.impl.Util.makeMainEntrypoints(scope, cha,
|
||||
@ -311,13 +314,13 @@ public class ReflectionTest extends WalaTestCase {
|
||||
TypeReference tr = TypeReference.findOrCreate(ClassLoaderReference.Primordial, "Ljava/lang/Integer");
|
||||
MethodReference mr = MethodReference.findOrCreate(tr, "toString", "()Ljava/lang/String;");
|
||||
Set<CGNode> nodes = cg.getNodes(mr);
|
||||
assertFalse(nodes.isEmpty());
|
||||
Assert.assertFalse(nodes.isEmpty());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that when analyzing Reflect10, the call graph includes a node for java.lang.Integer.toString()
|
||||
*/
|
||||
public void testReflect10() throws WalaException, IllegalArgumentException, CancelException, IOException {
|
||||
@Test public void testReflect10() throws WalaException, IllegalArgumentException, CancelException, IOException {
|
||||
AnalysisScope scope = CallGraphTestUtil.makeJ2SEAnalysisScope(TestConstants.WALA_TESTDATA, "Java60RegressionExclusions.txt");
|
||||
ClassHierarchy cha = ClassHierarchy.make(scope);
|
||||
Iterable<Entrypoint> entrypoints = com.ibm.wala.ipa.callgraph.impl.Util.makeMainEntrypoints(scope, cha,
|
||||
@ -327,13 +330,13 @@ public class ReflectionTest extends WalaTestCase {
|
||||
TypeReference tr = TypeReference.findOrCreate(ClassLoaderReference.Primordial, "Ljava/lang/Integer");
|
||||
MethodReference mr = MethodReference.findOrCreate(tr, "toString", "()Ljava/lang/String;");
|
||||
Set<CGNode> nodes = cg.getNodes(mr);
|
||||
assertFalse(nodes.isEmpty());
|
||||
Assert.assertFalse(nodes.isEmpty());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that when analyzing Reflect11, the call graph includes a node for java.lang.Object.wait()
|
||||
*/
|
||||
public void testReflect11() throws WalaException, IllegalArgumentException, CancelException, IOException {
|
||||
@Test public void testReflect11() throws WalaException, IllegalArgumentException, CancelException, IOException {
|
||||
AnalysisScope scope = CallGraphTestUtil.makeJ2SEAnalysisScope(TestConstants.WALA_TESTDATA, "Java60RegressionExclusions.txt");
|
||||
ClassHierarchy cha = ClassHierarchy.make(scope);
|
||||
Iterable<Entrypoint> entrypoints = com.ibm.wala.ipa.callgraph.impl.Util.makeMainEntrypoints(scope, cha,
|
||||
@ -343,14 +346,14 @@ public class ReflectionTest extends WalaTestCase {
|
||||
TypeReference tr = TypeReference.findOrCreate(ClassLoaderReference.Primordial, "Ljava/lang/Object");
|
||||
MethodReference mr = MethodReference.findOrCreate(tr, "wait", "()V");
|
||||
Set<CGNode> nodes = cg.getNodes(mr);
|
||||
assertFalse(nodes.isEmpty());
|
||||
Assert.assertFalse(nodes.isEmpty());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that when analyzing Reflect12, the call graph does not include a node for reflection.Helper.n
|
||||
* but does include a node for reflection.Helper.m
|
||||
*/
|
||||
public void testReflect12() throws WalaException, IllegalArgumentException, CancelException, IOException {
|
||||
@Test public void testReflect12() throws WalaException, IllegalArgumentException, CancelException, IOException {
|
||||
AnalysisScope scope = CallGraphTestUtil.makeJ2SEAnalysisScope(TestConstants.WALA_TESTDATA, "Java60RegressionExclusions.txt");
|
||||
ClassHierarchy cha = ClassHierarchy.make(scope);
|
||||
Iterable<Entrypoint> entrypoints = com.ibm.wala.ipa.callgraph.impl.Util.makeMainEntrypoints(scope, cha,
|
||||
@ -360,17 +363,17 @@ public class ReflectionTest extends WalaTestCase {
|
||||
TypeReference tr = TypeReference.findOrCreate(ClassLoaderReference.Application, "Lreflection/Helper");
|
||||
MethodReference mr = MethodReference.findOrCreate(tr, "m", "(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V");
|
||||
Set<CGNode> nodes = cg.getNodes(mr);
|
||||
assertFalse(nodes.isEmpty());
|
||||
Assert.assertFalse(nodes.isEmpty());
|
||||
mr = MethodReference.findOrCreate(tr, "n", "(Ljava/lang/Object;Ljava/lang/Object;)V");
|
||||
nodes = cg.getNodes(mr);
|
||||
assertTrue(nodes.isEmpty());
|
||||
Assert.assertTrue(nodes.isEmpty());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that when analyzing Reflect13, the call graph includes both a node for reflection.Helper.n
|
||||
* and a node for reflection.Helper.m
|
||||
*/
|
||||
public void testReflect13() throws WalaException, IllegalArgumentException, CancelException, IOException {
|
||||
@Test public void testReflect13() throws WalaException, IllegalArgumentException, CancelException, IOException {
|
||||
AnalysisScope scope = CallGraphTestUtil.makeJ2SEAnalysisScope(TestConstants.WALA_TESTDATA, "Java60RegressionExclusions.txt");
|
||||
ClassHierarchy cha = ClassHierarchy.make(scope);
|
||||
Iterable<Entrypoint> entrypoints = com.ibm.wala.ipa.callgraph.impl.Util.makeMainEntrypoints(scope, cha,
|
||||
@ -380,17 +383,17 @@ public class ReflectionTest extends WalaTestCase {
|
||||
TypeReference tr = TypeReference.findOrCreate(ClassLoaderReference.Application, "Lreflection/Helper");
|
||||
MethodReference mr = MethodReference.findOrCreate(tr, "m", "(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V");
|
||||
Set<CGNode> nodes = cg.getNodes(mr);
|
||||
assertFalse(nodes.isEmpty());
|
||||
Assert.assertFalse(nodes.isEmpty());
|
||||
mr = MethodReference.findOrCreate(tr, "n", "(Ljava/lang/Object;Ljava/lang/Object;)V");
|
||||
nodes = cg.getNodes(mr);
|
||||
assertFalse(nodes.isEmpty());
|
||||
Assert.assertFalse(nodes.isEmpty());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that when analyzing Reflect14, the call graph does not include a node for reflection.Helper.n
|
||||
* but does include a node for reflection.Helper.s
|
||||
*/
|
||||
public void testReflect14() throws WalaException, IllegalArgumentException, CancelException, IOException {
|
||||
@Test public void testReflect14() throws WalaException, IllegalArgumentException, CancelException, IOException {
|
||||
AnalysisScope scope = CallGraphTestUtil.makeJ2SEAnalysisScope(TestConstants.WALA_TESTDATA, "Java60RegressionExclusions.txt");
|
||||
ClassHierarchy cha = ClassHierarchy.make(scope);
|
||||
Iterable<Entrypoint> entrypoints = com.ibm.wala.ipa.callgraph.impl.Util.makeMainEntrypoints(scope, cha,
|
||||
@ -400,10 +403,10 @@ public class ReflectionTest extends WalaTestCase {
|
||||
TypeReference tr = TypeReference.findOrCreate(ClassLoaderReference.Application, "Lreflection/Helper");
|
||||
MethodReference mr = MethodReference.findOrCreate(tr, "s", "(Ljava/lang/Object;Ljava/lang/Object;)V");
|
||||
Set<CGNode> nodes = cg.getNodes(mr);
|
||||
assertFalse(nodes.isEmpty());
|
||||
Assert.assertFalse(nodes.isEmpty());
|
||||
mr = MethodReference.findOrCreate(tr, "n", "(Ljava/lang/Object;Ljava/lang/Object;)V");
|
||||
nodes = cg.getNodes(mr);
|
||||
assertTrue(nodes.isEmpty());
|
||||
Assert.assertTrue(nodes.isEmpty());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -411,7 +414,7 @@ public class ReflectionTest extends WalaTestCase {
|
||||
* of Helper that takes 2 parameters and for Helper.n, but no node for the constructors of
|
||||
* Helper that takes 0 or 1 parameters.
|
||||
*/
|
||||
public void testReflect15() throws WalaException, IllegalArgumentException, CancelException, IOException {
|
||||
@Test public void testReflect15() throws WalaException, IllegalArgumentException, CancelException, IOException {
|
||||
AnalysisScope scope = CallGraphTestUtil.makeJ2SEAnalysisScope(TestConstants.WALA_TESTDATA, "Java60RegressionExclusions.txt");
|
||||
ClassHierarchy cha = ClassHierarchy.make(scope);
|
||||
Iterable<Entrypoint> entrypoints = com.ibm.wala.ipa.callgraph.impl.Util.makeMainEntrypoints(scope, cha,
|
||||
@ -421,22 +424,22 @@ public class ReflectionTest extends WalaTestCase {
|
||||
TypeReference tr = TypeReference.findOrCreate(ClassLoaderReference.Application, "Lreflection/Helper");
|
||||
MethodReference mr = MethodReference.findOrCreate(tr, "<init>", "(Ljava/lang/Object;Ljava/lang/Object;)V");
|
||||
Set<CGNode> nodes = cg.getNodes(mr);
|
||||
assertFalse(nodes.isEmpty());
|
||||
Assert.assertFalse(nodes.isEmpty());
|
||||
mr = MethodReference.findOrCreate(tr, "<init>", "(Ljava/lang/Object;)V");
|
||||
nodes = cg.getNodes(mr);
|
||||
assertTrue(nodes.isEmpty());
|
||||
Assert.assertTrue(nodes.isEmpty());
|
||||
mr = MethodReference.findOrCreate(tr, "<init>", "()V");
|
||||
nodes = cg.getNodes(mr);
|
||||
assertTrue(nodes.isEmpty());
|
||||
Assert.assertTrue(nodes.isEmpty());
|
||||
mr = MethodReference.findOrCreate(tr, "n", "(Ljava/lang/Object;Ljava/lang/Object;)V");
|
||||
nodes = cg.getNodes(mr);
|
||||
assertFalse(nodes.isEmpty());
|
||||
Assert.assertFalse(nodes.isEmpty());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that when analyzing Reflect16, the call graph includes a node for java.lang.Integer.toString()
|
||||
*/
|
||||
public void testReflect16() throws WalaException, IllegalArgumentException, CancelException, IOException {
|
||||
@Test public void testReflect16() throws WalaException, IllegalArgumentException, CancelException, IOException {
|
||||
AnalysisScope scope = CallGraphTestUtil.makeJ2SEAnalysisScope(TestConstants.WALA_TESTDATA, "Java60RegressionExclusions.txt");
|
||||
ClassHierarchy cha = ClassHierarchy.make(scope);
|
||||
Iterable<Entrypoint> entrypoints = com.ibm.wala.ipa.callgraph.impl.Util.makeMainEntrypoints(scope, cha,
|
||||
@ -446,13 +449,13 @@ public class ReflectionTest extends WalaTestCase {
|
||||
TypeReference tr = TypeReference.findOrCreate(ClassLoaderReference.Primordial, "Ljava/lang/Integer");
|
||||
MethodReference mr = MethodReference.findOrCreate(tr, "toString", "()Ljava/lang/String;");
|
||||
Set<CGNode> nodes = cg.getNodes(mr);
|
||||
assertFalse(nodes.isEmpty());
|
||||
Assert.assertFalse(nodes.isEmpty());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that when analyzing Reflect17, the call graph does not include a node for java.lang.Integer.toString()
|
||||
*/
|
||||
public void testReflect17() throws WalaException, IllegalArgumentException, CancelException, IOException {
|
||||
@Test public void testReflect17() throws WalaException, IllegalArgumentException, CancelException, IOException {
|
||||
AnalysisScope scope = CallGraphTestUtil.makeJ2SEAnalysisScope(TestConstants.WALA_TESTDATA, "Java60RegressionExclusions.txt");
|
||||
ClassHierarchy cha = ClassHierarchy.make(scope);
|
||||
Iterable<Entrypoint> entrypoints = com.ibm.wala.ipa.callgraph.impl.Util.makeMainEntrypoints(scope, cha,
|
||||
@ -462,13 +465,13 @@ public class ReflectionTest extends WalaTestCase {
|
||||
TypeReference tr = TypeReference.findOrCreate(ClassLoaderReference.Primordial, "Ljava/lang/Integer");
|
||||
MethodReference mr = MethodReference.findOrCreate(tr, "toString", "()Ljava/lang/String;");
|
||||
Set<CGNode> nodes = cg.getNodes(mr);
|
||||
assertTrue(nodes.isEmpty());
|
||||
Assert.assertTrue(nodes.isEmpty());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that when analyzing Reflect18, the call graph includes a node for java.lang.Integer.toString()
|
||||
*/
|
||||
public void testReflect18() throws WalaException, IllegalArgumentException, CancelException, IOException {
|
||||
@Test public void testReflect18() throws WalaException, IllegalArgumentException, CancelException, IOException {
|
||||
AnalysisScope scope = CallGraphTestUtil.makeJ2SEAnalysisScope(TestConstants.WALA_TESTDATA, "Java60RegressionExclusions.txt");
|
||||
ClassHierarchy cha = ClassHierarchy.make(scope);
|
||||
Iterable<Entrypoint> entrypoints = com.ibm.wala.ipa.callgraph.impl.Util.makeMainEntrypoints(scope, cha,
|
||||
@ -478,13 +481,13 @@ public class ReflectionTest extends WalaTestCase {
|
||||
TypeReference tr = TypeReference.findOrCreate(ClassLoaderReference.Primordial, "Ljava/lang/Integer");
|
||||
MethodReference mr = MethodReference.findOrCreate(tr, "toString", "()Ljava/lang/String;");
|
||||
Set<CGNode> nodes = cg.getNodes(mr);
|
||||
assertFalse(nodes.isEmpty());
|
||||
Assert.assertFalse(nodes.isEmpty());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that when analyzing Reflect19, the call graph includes a node for java.lang.Integer.toString()
|
||||
*/
|
||||
public void testReflect19() throws WalaException, IllegalArgumentException, CancelException, IOException {
|
||||
@Test public void testReflect19() throws WalaException, IllegalArgumentException, CancelException, IOException {
|
||||
AnalysisScope scope = CallGraphTestUtil.makeJ2SEAnalysisScope(TestConstants.WALA_TESTDATA, "Java60RegressionExclusions.txt");
|
||||
ClassHierarchy cha = ClassHierarchy.make(scope);
|
||||
Iterable<Entrypoint> entrypoints = com.ibm.wala.ipa.callgraph.impl.Util.makeMainEntrypoints(scope, cha,
|
||||
@ -494,13 +497,13 @@ public class ReflectionTest extends WalaTestCase {
|
||||
TypeReference tr = TypeReference.findOrCreate(ClassLoaderReference.Primordial, "Ljava/lang/Integer");
|
||||
MethodReference mr = MethodReference.findOrCreate(tr, "toString", "()Ljava/lang/String;");
|
||||
Set<CGNode> nodes = cg.getNodes(mr);
|
||||
assertFalse(nodes.isEmpty());
|
||||
Assert.assertFalse(nodes.isEmpty());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that when analyzing Reflect20, the call graph includes a node for Helper.o.
|
||||
*/
|
||||
public void testReflect20() throws WalaException, IllegalArgumentException, CancelException, IOException {
|
||||
@Test public void testReflect20() throws WalaException, IllegalArgumentException, CancelException, IOException {
|
||||
AnalysisScope scope = CallGraphTestUtil.makeJ2SEAnalysisScope(TestConstants.WALA_TESTDATA, "Java60RegressionExclusions.txt");
|
||||
ClassHierarchy cha = ClassHierarchy.make(scope);
|
||||
Iterable<Entrypoint> entrypoints = com.ibm.wala.ipa.callgraph.impl.Util.makeMainEntrypoints(scope, cha,
|
||||
@ -510,14 +513,14 @@ public class ReflectionTest extends WalaTestCase {
|
||||
TypeReference tr = TypeReference.findOrCreate(ClassLoaderReference.Application, "Lreflection/Helper");
|
||||
MethodReference mr = MethodReference.findOrCreate(tr, "o", "(Ljava/lang/Object;Ljava/lang/Object;)V");
|
||||
Set<CGNode> nodes = cg.getNodes(mr);
|
||||
assertFalse(nodes.isEmpty());
|
||||
Assert.assertFalse(nodes.isEmpty());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that when analyzing Reflect21, the call graph includes a node for the constructor of {@link Helper} that takes
|
||||
* two {@link Object} parameters. This is to test the support for Class.getDeclaredConstructor.
|
||||
*/
|
||||
public void testReflect21() throws WalaException, IllegalArgumentException, CancelException, IOException {
|
||||
@Test public void testReflect21() throws WalaException, IllegalArgumentException, CancelException, IOException {
|
||||
AnalysisScope scope = CallGraphTestUtil.makeJ2SEAnalysisScope(TestConstants.WALA_TESTDATA, "Java60RegressionExclusions.txt");
|
||||
ClassHierarchy cha = ClassHierarchy.make(scope);
|
||||
Iterable<Entrypoint> entrypoints = com.ibm.wala.ipa.callgraph.impl.Util.makeMainEntrypoints(scope, cha,
|
||||
@ -527,14 +530,14 @@ public class ReflectionTest extends WalaTestCase {
|
||||
TypeReference tr = TypeReference.findOrCreate(ClassLoaderReference.Application, "Lreflection/Helper");
|
||||
MethodReference mr = MethodReference.findOrCreate(tr, "<init>", "(Ljava/lang/Object;Ljava/lang/Object;)V");
|
||||
Set<CGNode> nodes = cg.getNodes(mr);
|
||||
assertFalse(nodes.isEmpty());
|
||||
Assert.assertFalse(nodes.isEmpty());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that when analyzing Reflect22, the call graph includes a node for the constructor of {@link Helper} that takes
|
||||
* one {@link Integer} parameters. This is to test the support for Class.getDeclaredConstructors.
|
||||
*/
|
||||
public void testReflect22() throws WalaException, IllegalArgumentException, CancelException, IOException {
|
||||
@Test public void testReflect22() throws WalaException, IllegalArgumentException, CancelException, IOException {
|
||||
AnalysisScope scope = CallGraphTestUtil.makeJ2SEAnalysisScope(TestConstants.WALA_TESTDATA, "Java60RegressionExclusions.txt");
|
||||
ClassHierarchy cha = ClassHierarchy.make(scope);
|
||||
Iterable<Entrypoint> entrypoints = com.ibm.wala.ipa.callgraph.impl.Util.makeMainEntrypoints(scope, cha,
|
||||
@ -544,14 +547,14 @@ public class ReflectionTest extends WalaTestCase {
|
||||
TypeReference tr = TypeReference.findOrCreate(ClassLoaderReference.Application, "Lreflection/Helper");
|
||||
MethodReference mr = MethodReference.findOrCreate(tr, "<init>", "(Ljava/lang/Integer;)V");
|
||||
Set<CGNode> nodes = cg.getNodes(mr);
|
||||
assertFalse(nodes.isEmpty());
|
||||
Assert.assertFalse(nodes.isEmpty());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that when analyzing Reflect22, the call graph includes a node for the constructor of {@link Helper} that takes
|
||||
* one {@link Integer} parameters. This is to test the support for Class.getDeclaredConstructors.
|
||||
*/
|
||||
public void testReflect23() throws WalaException, IllegalArgumentException, CancelException, IOException {
|
||||
@Test public void testReflect23() throws WalaException, IllegalArgumentException, CancelException, IOException {
|
||||
AnalysisScope scope = CallGraphTestUtil.makeJ2SEAnalysisScope(TestConstants.WALA_TESTDATA, "Java60RegressionExclusions.txt");
|
||||
ClassHierarchy cha = ClassHierarchy.make(scope);
|
||||
Iterable<Entrypoint> entrypoints = com.ibm.wala.ipa.callgraph.impl.Util.makeMainEntrypoints(scope, cha,
|
||||
@ -561,6 +564,6 @@ public class ReflectionTest extends WalaTestCase {
|
||||
TypeReference tr = TypeReference.findOrCreate(ClassLoaderReference.Application, "Lreflection/Helper");
|
||||
MethodReference mr = MethodReference.findOrCreate(tr, "u", "(Ljava/lang/Integer;)V");
|
||||
Set<CGNode> nodes = cg.getNodes(mr);
|
||||
assertFalse(nodes.isEmpty());
|
||||
Assert.assertFalse(nodes.isEmpty());
|
||||
}
|
||||
}
|
||||
|
||||
@ -13,6 +13,9 @@ package com.ibm.wala.core.tests.callGraph;
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.ibm.wala.classLoader.IMethod;
|
||||
import com.ibm.wala.core.tests.util.TestConstants;
|
||||
import com.ibm.wala.core.tests.util.WalaTestCase;
|
||||
@ -36,7 +39,7 @@ import com.ibm.wala.util.CancelException;
|
||||
*/
|
||||
public class SyntheticTest extends WalaTestCase {
|
||||
|
||||
public void testMultiSubtypes() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
@Test public void testMultiSubtypes() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
AnalysisScope scope = CallGraphTestUtil.makeJ2SEAnalysisScope(TestConstants.WALA_TESTDATA,
|
||||
CallGraphTestUtil.REGRESSION_EXCLUSIONS);
|
||||
ClassHierarchy cha = ClassHierarchy.make(scope);
|
||||
@ -53,12 +56,12 @@ public class SyntheticTest extends WalaTestCase {
|
||||
MethodReference barA = MethodReference.findOrCreate(tA, "bar", "()V");
|
||||
TypeReference tB = TypeReference.findOrCreate(ClassLoaderReference.Application, "LmultiTypes/Foo$B");
|
||||
MethodReference barB = MethodReference.findOrCreate(tB, "bar", "()V");
|
||||
assertTrue(cg.getNodes(barA).size() == 1);
|
||||
assertTrue(cg.getNodes(barB).size() == 1);
|
||||
Assert.assertTrue(cg.getNodes(barA).size() == 1);
|
||||
Assert.assertTrue(cg.getNodes(barB).size() == 1);
|
||||
|
||||
CGNode root = cg.getFakeRootNode();
|
||||
IR ir = root.getIR();
|
||||
assertTrue(ir.iteratePhis().hasNext());
|
||||
Assert.assertTrue(ir.iteratePhis().hasNext());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -12,6 +12,11 @@ package com.ibm.wala.core.tests.cha;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.ibm.wala.classLoader.ClassLoaderFactory;
|
||||
import com.ibm.wala.classLoader.ClassLoaderFactoryImpl;
|
||||
import com.ibm.wala.classLoader.IMethod;
|
||||
@ -40,7 +45,8 @@ public class GetTargetsTest extends WalaTestCase {
|
||||
justThisTest(GetTargetsTest.class);
|
||||
}
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
|
||||
scope = AnalysisScopeReader.readJavaScope(TestConstants.WALA_TESTDATA, FileProvider.getFile("J2SEClassHierarchyExclusions.txt"), MY_CLASSLOADER);
|
||||
|
||||
@ -58,35 +64,35 @@ public class GetTargetsTest extends WalaTestCase {
|
||||
*
|
||||
* @see junit.framework.TestCase#tearDown()
|
||||
*/
|
||||
protected void tearDown() throws Exception {
|
||||
@After
|
||||
public void tearDown() throws Exception {
|
||||
scope = null;
|
||||
cha = null;
|
||||
super.tearDown();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test for bug 1714480, reported OOM on {@link ClassHierarchy} getPossibleTargets()
|
||||
*/
|
||||
public void testCell() {
|
||||
@Test public void testCell() {
|
||||
TypeReference t = TypeReference.findOrCreate(ClassLoaderReference.Application, "Lcell/Cell");
|
||||
MethodReference m = MethodReference.findOrCreate(t, "<init>", "(Ljava/lang/Object;)V");
|
||||
Collection<IMethod> c = cha.getPossibleTargets(m);
|
||||
for (IMethod method : c) {
|
||||
System.err.println(method);
|
||||
}
|
||||
assertEquals(1, c.size());
|
||||
Assert.assertEquals(1, c.size());
|
||||
}
|
||||
|
||||
/**
|
||||
* test that calls to <init> methods are treated specially
|
||||
*/
|
||||
public void testObjInit() {
|
||||
@Test public void testObjInit() {
|
||||
MethodReference m = MethodReference.findOrCreate(TypeReference.JavaLangObject, MethodReference.initSelector);
|
||||
Collection<IMethod> c = cha.getPossibleTargets(m);
|
||||
for (IMethod method : c) {
|
||||
System.err.println(method);
|
||||
}
|
||||
assertEquals(1, c.size());
|
||||
Assert.assertEquals(1, c.size());
|
||||
}
|
||||
}
|
||||
|
||||
@ -10,6 +10,11 @@
|
||||
*******************************************************************************/
|
||||
package com.ibm.wala.core.tests.cha;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.ibm.wala.classLoader.ClassLoaderFactory;
|
||||
import com.ibm.wala.classLoader.ClassLoaderFactoryImpl;
|
||||
import com.ibm.wala.classLoader.IClass;
|
||||
@ -41,7 +46,8 @@ public class InnerClassesTest extends WalaTestCase {
|
||||
justThisTest(InnerClassesTest.class);
|
||||
}
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
scope = AnalysisScopeReader.readJavaScope(TestConstants.WALA_TESTDATA, FileProvider.getFile("J2SEClassHierarchyExclusions.txt"),
|
||||
MY_CLASSLOADER);
|
||||
|
||||
@ -54,39 +60,39 @@ public class InnerClassesTest extends WalaTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
protected void tearDown() throws Exception {
|
||||
@After
|
||||
public void tearDown() throws Exception {
|
||||
scope = null;
|
||||
cha = null;
|
||||
super.tearDown();
|
||||
}
|
||||
|
||||
public void test1() throws InvalidClassFileException {
|
||||
@Test public void test1() throws InvalidClassFileException {
|
||||
TypeReference t = TypeReference.findOrCreate(ClassLoaderReference.Application, TypeName
|
||||
.string2TypeName("Linner/TestStaticInner"));
|
||||
IClass klass = cha.lookupClass(t);
|
||||
assert klass != null;
|
||||
ShrikeClass s = (ShrikeClass)klass;
|
||||
assertFalse(s.isInnerClass());
|
||||
Assert.assertFalse(s.isInnerClass());
|
||||
}
|
||||
|
||||
public void test2() throws InvalidClassFileException {
|
||||
@Test public void test2() throws InvalidClassFileException {
|
||||
TypeReference t = TypeReference.findOrCreate(ClassLoaderReference.Application, TypeName
|
||||
.string2TypeName("Linner/TestStaticInner$A"));
|
||||
IClass klass = cha.lookupClass(t);
|
||||
assert klass != null;
|
||||
ShrikeClass s = (ShrikeClass)klass;
|
||||
assertTrue(s.isInnerClass());
|
||||
assertTrue(s.isStaticInnerClass());
|
||||
Assert.assertTrue(s.isInnerClass());
|
||||
Assert.assertTrue(s.isStaticInnerClass());
|
||||
}
|
||||
|
||||
public void test3() throws InvalidClassFileException {
|
||||
@Test public void test3() throws InvalidClassFileException {
|
||||
TypeReference t = TypeReference.findOrCreate(ClassLoaderReference.Application, TypeName
|
||||
.string2TypeName("Linner/TestInner$A"));
|
||||
IClass klass = cha.lookupClass(t);
|
||||
assert klass != null;
|
||||
ShrikeClass s = (ShrikeClass)klass;
|
||||
assertTrue(s.isInnerClass());
|
||||
assertFalse(s.isStaticInnerClass());
|
||||
Assert.assertTrue(s.isInnerClass());
|
||||
Assert.assertFalse(s.isStaticInnerClass());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -10,6 +10,11 @@
|
||||
*******************************************************************************/
|
||||
package com.ibm.wala.core.tests.cha;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.ibm.wala.classLoader.ClassLoaderFactory;
|
||||
import com.ibm.wala.classLoader.ClassLoaderFactoryImpl;
|
||||
import com.ibm.wala.classLoader.IClass;
|
||||
@ -38,7 +43,8 @@ public class InterfaceTest extends WalaTestCase {
|
||||
justThisTest(InterfaceTest.class);
|
||||
}
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
scope = AnalysisScopeReader.readJavaScope(TestConstants.WALA_TESTDATA, FileProvider.getFile("J2SEClassHierarchyExclusions.txt"), MY_CLASSLOADER);
|
||||
|
||||
ClassLoaderFactory factory = new ClassLoaderFactoryImpl(scope.getExclusions() );
|
||||
@ -50,17 +56,17 @@ public class InterfaceTest extends WalaTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
protected void tearDown() throws Exception {
|
||||
@After
|
||||
public void tearDown() throws Exception {
|
||||
scope = null;
|
||||
cha = null;
|
||||
super.tearDown();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test for subtype tests with interfaces; bug reported by Bruno Dufour
|
||||
*/
|
||||
public void test1() {
|
||||
@Test public void test1() {
|
||||
TypeReference prep_stmt_type = TypeReference.findOrCreate(ClassLoaderReference.Primordial, TypeName
|
||||
.string2TypeName("Ljava/sql/PreparedStatement"));
|
||||
TypeReference stmt_type = TypeReference.findOrCreate(ClassLoaderReference.Primordial, TypeName
|
||||
@ -68,28 +74,28 @@ public class InterfaceTest extends WalaTestCase {
|
||||
IClass prep_stmt = cha.lookupClass(prep_stmt_type);
|
||||
IClass stmt = cha.lookupClass(stmt_type);
|
||||
|
||||
assertTrue("did not find PreparedStatement", prep_stmt != null);
|
||||
assertTrue("did not find Statement", stmt != null);
|
||||
Assert.assertTrue("did not find PreparedStatement", prep_stmt != null);
|
||||
Assert.assertTrue("did not find Statement", stmt != null);
|
||||
|
||||
assertTrue(cha.implementsInterface(prep_stmt, stmt));
|
||||
assertFalse(cha.implementsInterface(stmt, prep_stmt));
|
||||
assertTrue(cha.isAssignableFrom(stmt, prep_stmt));
|
||||
assertFalse(cha.isAssignableFrom(prep_stmt, stmt));
|
||||
Assert.assertTrue(cha.implementsInterface(prep_stmt, stmt));
|
||||
Assert.assertFalse(cha.implementsInterface(stmt, prep_stmt));
|
||||
Assert.assertTrue(cha.isAssignableFrom(stmt, prep_stmt));
|
||||
Assert.assertFalse(cha.isAssignableFrom(prep_stmt, stmt));
|
||||
}
|
||||
|
||||
/**
|
||||
* check that arrays implement Cloneable and Serializable
|
||||
*/
|
||||
public void test2() {
|
||||
@Test public void test2() {
|
||||
IClass objArrayClass = cha.lookupClass(TypeReference.JavaLangObject.getArrayTypeForElementType());
|
||||
IClass stringArrayClass = cha.lookupClass(TypeReference.JavaLangString.getArrayTypeForElementType());
|
||||
IClass cloneableClass = cha.lookupClass(TypeReference.JavaLangCloneable);
|
||||
IClass serializableClass = cha.lookupClass(TypeReference.JavaIoSerializable);
|
||||
|
||||
assertTrue(cha.implementsInterface(objArrayClass, cloneableClass));
|
||||
assertTrue(cha.implementsInterface(objArrayClass, serializableClass));
|
||||
assertTrue(cha.implementsInterface(stringArrayClass, cloneableClass));
|
||||
assertTrue(cha.implementsInterface(stringArrayClass, serializableClass));
|
||||
Assert.assertTrue(cha.implementsInterface(objArrayClass, cloneableClass));
|
||||
Assert.assertTrue(cha.implementsInterface(objArrayClass, serializableClass));
|
||||
Assert.assertTrue(cha.implementsInterface(stringArrayClass, cloneableClass));
|
||||
Assert.assertTrue(cha.implementsInterface(stringArrayClass, serializableClass));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -14,6 +14,8 @@ import java.io.IOException;
|
||||
|
||||
import junit.framework.Assert;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import com.ibm.wala.core.tests.ir.DeterministicIRTest;
|
||||
import com.ibm.wala.core.tests.util.TestConstants;
|
||||
import com.ibm.wala.core.tests.util.WalaTestCase;
|
||||
@ -31,7 +33,7 @@ public class LibraryVersionTest extends WalaTestCase {
|
||||
|
||||
private static final ClassLoader MY_CLASSLOADER = DeterministicIRTest.class.getClassLoader();
|
||||
|
||||
public void testLibraryVersion() throws IOException {
|
||||
@Test public void testLibraryVersion() throws IOException {
|
||||
AnalysisScope scope = AnalysisScopeReader.readJavaScope(TestConstants.WALA_TESTDATA, FileProvider.getFile("J2SEClassHierarchyExclusions.txt"), MY_CLASSLOADER);
|
||||
System.err.println("java library version is " + scope.getJavaLibraryVersion());
|
||||
Assert.assertTrue(scope.isJava16Libraries() || scope.isJava15Libraries()||scope.isJava14Libraries());
|
||||
|
||||
@ -12,6 +12,9 @@ package com.ibm.wala.core.tests.cha;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.ibm.wala.classLoader.IClass;
|
||||
import com.ibm.wala.core.tests.util.TestConstants;
|
||||
import com.ibm.wala.core.tests.util.WalaTestCase;
|
||||
@ -29,7 +32,7 @@ public class SourceMapTest extends WalaTestCase {
|
||||
|
||||
private final static String CLASS_IN_PRIMORDIAL_JAR = "Lcom/ibm/wala/model/SyntheticFactory";
|
||||
|
||||
public void testHello() throws ClassHierarchyException, IOException {
|
||||
@Test public void testHello() throws ClassHierarchyException, IOException {
|
||||
AnalysisScope scope = null;
|
||||
scope = AnalysisScopeReader.readJavaScope(TestConstants.HELLO, null, MY_CLASSLOADER);
|
||||
// TODO: it's annoying to have to build a class hierarchy here.
|
||||
@ -37,13 +40,13 @@ public class SourceMapTest extends WalaTestCase {
|
||||
ClassHierarchy cha = ClassHierarchy.make(scope);
|
||||
TypeReference t = TypeReference.findOrCreate(scope.getApplicationLoader(), TestConstants.HELLO_MAIN);
|
||||
IClass klass = cha.lookupClass(t);
|
||||
assertTrue("failed to load " + t, klass != null);
|
||||
Assert.assertTrue("failed to load " + t, klass != null);
|
||||
String sourceFile = klass.getSourceFileName();
|
||||
System.err.println("Source file: " + sourceFile);
|
||||
assertTrue(sourceFile != null);
|
||||
Assert.assertTrue(sourceFile != null);
|
||||
}
|
||||
|
||||
public void testFromJar() throws ClassHierarchyException, IOException {
|
||||
@Test public void testFromJar() throws ClassHierarchyException, IOException {
|
||||
AnalysisScope scope = null;
|
||||
scope = AnalysisScopeReader.readJavaScope(TestConstants.HELLO, null, MY_CLASSLOADER);
|
||||
// TODO: it's annoying to have to build a class hierarchy here.
|
||||
@ -51,9 +54,9 @@ public class SourceMapTest extends WalaTestCase {
|
||||
ClassHierarchy cha = ClassHierarchy.make(scope);
|
||||
TypeReference t = TypeReference.findOrCreate(scope.getPrimordialLoader(), CLASS_IN_PRIMORDIAL_JAR);
|
||||
IClass klass = cha.lookupClass(t);
|
||||
assertTrue(klass != null);
|
||||
Assert.assertTrue(klass != null);
|
||||
String sourceFile = klass.getSourceFileName();
|
||||
assertTrue(sourceFile != null);
|
||||
Assert.assertTrue(sourceFile != null);
|
||||
System.err.println("Source file: " + sourceFile);
|
||||
}
|
||||
}
|
||||
@ -7,6 +7,8 @@
|
||||
*/
|
||||
package com.ibm.wala.core.tests.collections;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import com.ibm.wala.core.tests.util.WalaTestCase;
|
||||
import com.ibm.wala.util.intset.SemiSparseMutableIntSet;
|
||||
|
||||
@ -23,7 +25,7 @@ public final class SemiSparseMutableIntSetTest extends WalaTestCase {
|
||||
|
||||
// --- Test cases
|
||||
|
||||
public void testCase1() {
|
||||
@Test public void testCase1() {
|
||||
final SemiSparseMutableIntSet ssmIntSet = new SemiSparseMutableIntSet();
|
||||
ssmIntSet.add(1);
|
||||
final SemiSparseMutableIntSet ssmIntSet2 = SemiSparseMutableIntSet.diff(ssmIntSet, ssmIntSet);
|
||||
|
||||
@ -7,6 +7,9 @@
|
||||
*/
|
||||
package com.ibm.wala.core.tests.collections;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.ibm.wala.core.tests.util.WalaTestCase;
|
||||
import com.ibm.wala.util.collections.TwoLevelVector;
|
||||
|
||||
@ -23,12 +26,12 @@ public final class TwoLevelVectorTest extends WalaTestCase {
|
||||
|
||||
// --- Test cases
|
||||
|
||||
public void testCase1() {
|
||||
@Test public void testCase1() {
|
||||
final TwoLevelVector<Integer> tlVector = new TwoLevelVector<Integer>();
|
||||
tlVector.iterator();
|
||||
tlVector.set(2147483647, 56);
|
||||
assertNotNull(tlVector.iterator());
|
||||
assertEquals(Integer.valueOf(56), tlVector.get(2147483647));
|
||||
Assert.assertNotNull(tlVector.iterator());
|
||||
Assert.assertEquals(Integer.valueOf(56), tlVector.get(2147483647));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -41,7 +41,7 @@ import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import org.junit.Assert;
|
||||
|
||||
import com.ibm.wala.classLoader.IClass;
|
||||
import com.ibm.wala.core.tests.callGraph.CallGraphTestUtil;
|
||||
@ -75,7 +75,7 @@ import com.ibm.wala.util.debug.Assertions;
|
||||
import com.ibm.wala.util.intset.IntSet;
|
||||
import com.ibm.wala.util.strings.Atom;
|
||||
|
||||
public abstract class AbstractPtrTest extends TestCase {
|
||||
public abstract class AbstractPtrTest {
|
||||
|
||||
protected boolean debug = false;
|
||||
|
||||
@ -152,11 +152,11 @@ public abstract class AbstractPtrTest extends TestCase {
|
||||
}
|
||||
assert scope != null;
|
||||
if (scope.isJava16Libraries()) {
|
||||
assertEquals(expected16Size, pointsTo.size());
|
||||
Assert.assertEquals(expected16Size, pointsTo.size());
|
||||
} else if (scope.isJava15Libraries()) {
|
||||
assertEquals(expected15Size, pointsTo.size());
|
||||
Assert.assertEquals(expected15Size, pointsTo.size());
|
||||
} else if (scope.isJava14Libraries()) {
|
||||
assertEquals(expected14Size, pointsTo.size());
|
||||
Assert.assertEquals(expected14Size, pointsTo.size());
|
||||
} else {
|
||||
Assertions.UNREACHABLE("unexpected library version");
|
||||
}
|
||||
|
||||
@ -40,6 +40,9 @@ package com.ibm.wala.core.tests.demandpa;
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.ibm.wala.demandpa.alg.ContextSensitiveStateMachine;
|
||||
import com.ibm.wala.demandpa.alg.DemandRefinementPointsTo;
|
||||
import com.ibm.wala.demandpa.alg.IDemandPointerAnalysis;
|
||||
@ -58,30 +61,26 @@ import com.ibm.wala.util.strings.Atom;
|
||||
|
||||
public class ContextSensitiveTest extends AbstractPtrTest {
|
||||
|
||||
@Override
|
||||
protected void setUp() {
|
||||
}
|
||||
|
||||
public void testArraySet() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
@Test public void testArraySet() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
doPointsToSizeTest(TestInfo.SCOPE_FILE, TestInfo.TEST_ARRAY_SET, 1);
|
||||
}
|
||||
|
||||
public void testClone() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
@Test public void testClone() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
doPointsToSizeTest(TestInfo.SCOPE_FILE, TestInfo.TEST_CLONE, 1);
|
||||
}
|
||||
|
||||
public void testFooId() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
@Test public void testFooId() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
doPointsToSizeTest(TestInfo.SCOPE_FILE, TestInfo.TEST_ID, 1);
|
||||
}
|
||||
|
||||
public void testHashtableEnum() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
@Test public void testHashtableEnum() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
// 3 because
|
||||
// can't tell between key, value, and entry enumerators in Hashtable
|
||||
doPointsToSizeTest(TestInfo.SCOPE_FILE, TestInfo.TEST_HASHTABLE_ENUM, 3);
|
||||
}
|
||||
|
||||
// we know this one fails...
|
||||
// public void testOnTheFlyCS() throws ClassHierarchyException {
|
||||
// @Test public void testOnTheFlyCS() throws ClassHierarchyException {
|
||||
// String mainClass = TestInfo.TEST_ONTHEFLY_CS;
|
||||
// final IDemandPointerAnalysis dmp =
|
||||
// makeDemandPointerAnalysis(TestInfo.SCOPE_FILE, mainClass);
|
||||
@ -101,7 +100,7 @@ public class ContextSensitiveTest extends AbstractPtrTest {
|
||||
// assertEquals(1, pointsTo.size());
|
||||
// }
|
||||
|
||||
public void testWithinMethodCall() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
@Test public void testWithinMethodCall() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
String mainClass = TestInfo.TEST_WITHIN_METHOD_CALL;
|
||||
final IDemandPointerAnalysis dmp = makeDemandPointerAnalysis(TestInfo.SCOPE_FILE, mainClass);
|
||||
|
||||
@ -112,38 +111,38 @@ public class ContextSensitiveTest extends AbstractPtrTest {
|
||||
if (debug) {
|
||||
System.err.println("points-to for " + mainClass + ": " + pointsTo);
|
||||
}
|
||||
assertEquals(1, pointsTo.size());
|
||||
Assert.assertEquals(1, pointsTo.size());
|
||||
}
|
||||
|
||||
public void testLinkedListIter() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
@Test public void testLinkedListIter() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
doPointsToSizeTest(TestInfo.SCOPE_FILE, TestInfo.TEST_LINKEDLIST_ITER, 1);
|
||||
}
|
||||
|
||||
public void testGlobal() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
@Test public void testGlobal() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
doPointsToSizeTest(TestInfo.SCOPE_FILE, TestInfo.TEST_GLOBAL, 1);
|
||||
}
|
||||
|
||||
public void testHashSet() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
@Test public void testHashSet() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
doPointsToSizeTest(TestInfo.SCOPE_FILE, TestInfo.TEST_HASH_SET, 2, 2, 1);
|
||||
}
|
||||
|
||||
public void testHashMapGet() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
@Test public void testHashMapGet() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
doPointsToSizeTest(TestInfo.SCOPE_FILE, TestInfo.TEST_HASHMAP_GET, 2, 1, 1);
|
||||
}
|
||||
|
||||
public void testMethodRecursion() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
@Test public void testMethodRecursion() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
doPointsToSizeTest(TestInfo.SCOPE_FILE, TestInfo.TEST_METHOD_RECURSION, 2);
|
||||
}
|
||||
|
||||
public void testArraySetIter() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
@Test public void testArraySetIter() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
doPointsToSizeTest(TestInfo.SCOPE_FILE, TestInfo.TEST_ARRAY_SET_ITER, 1);
|
||||
}
|
||||
|
||||
public void testArrayList() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
@Test public void testArrayList() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
doPointsToSizeTest(TestInfo.SCOPE_FILE, TestInfo.TEST_ARRAY_LIST, 1);
|
||||
}
|
||||
|
||||
public void testLinkedList() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
@Test public void testLinkedList() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
doPointsToSizeTest(TestInfo.SCOPE_FILE, TestInfo.TEST_LINKED_LIST, 1);
|
||||
}
|
||||
|
||||
|
||||
@ -39,6 +39,8 @@ package com.ibm.wala.core.tests.demandpa;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import com.ibm.wala.demandpa.alg.IntraProcFilter;
|
||||
import com.ibm.wala.demandpa.alg.statemachine.StateMachineFactory;
|
||||
import com.ibm.wala.demandpa.flowgraph.IFlowLabel;
|
||||
@ -47,7 +49,7 @@ import com.ibm.wala.util.CancelException;
|
||||
|
||||
public class IntraprocTest extends AbstractPtrTest {
|
||||
|
||||
public void testId() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
@Test public void testId() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
doPointsToSizeTest(TestInfo.SCOPE_FILE, TestInfo.TEST_ID, 0);
|
||||
}
|
||||
|
||||
|
||||
@ -39,68 +39,66 @@ package com.ibm.wala.core.tests.demandpa;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import com.ibm.wala.ipa.cha.ClassHierarchyException;
|
||||
import com.ibm.wala.util.CancelException;
|
||||
|
||||
public class NoRefinePtrTest extends AbstractPtrTest {
|
||||
|
||||
@Override
|
||||
protected void setUp() {
|
||||
}
|
||||
|
||||
public void testOnTheFlySimple() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
@Test public void testOnTheFlySimple() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
doPointsToSizeTest(TestInfo.SCOPE_FILE, TestInfo.TEST_ONTHEFLY_SIMPLE, 1);
|
||||
}
|
||||
|
||||
public void testArraySet() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
@Test public void testArraySet() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
doPointsToSizeTest(TestInfo.SCOPE_FILE, TestInfo.TEST_ARRAY_SET, 2);
|
||||
}
|
||||
|
||||
public void testArraySetIter() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
@Test public void testArraySetIter() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
doPointsToSizeTest(TestInfo.SCOPE_FILE, TestInfo.TEST_ARRAY_SET_ITER, 2);
|
||||
}
|
||||
|
||||
public void testHashSet() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
@Test public void testHashSet() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
doPointsToSizeTest(TestInfo.SCOPE_FILE, TestInfo.TEST_HASH_SET, 3, 3, 2);
|
||||
}
|
||||
|
||||
public void testMethodRecursion() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
@Test public void testMethodRecursion() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
doPointsToSizeTest(TestInfo.SCOPE_FILE, TestInfo.TEST_METHOD_RECURSION, 2);
|
||||
}
|
||||
|
||||
public void testFooId() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
@Test public void testFooId() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
doPointsToSizeTest(TestInfo.SCOPE_FILE, TestInfo.TEST_ID, 2);
|
||||
}
|
||||
|
||||
public void testLocals() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
@Test public void testLocals() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
doPointsToSizeTest(TestInfo.SCOPE_FILE, TestInfo.TEST_LOCALS, 1);
|
||||
}
|
||||
|
||||
public void testArrays() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
@Test public void testArrays() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
doPointsToSizeTest(TestInfo.SCOPE_FILE, TestInfo.TEST_ARRAYS, 2);
|
||||
}
|
||||
|
||||
public void testFields() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
@Test public void testFields() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
doPointsToSizeTest(TestInfo.SCOPE_FILE, TestInfo.TEST_FIELDS, 2);
|
||||
}
|
||||
|
||||
public void testFieldsHarder() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
@Test public void testFieldsHarder() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
doPointsToSizeTest(TestInfo.SCOPE_FILE, TestInfo.TEST_FIELDS_HARDER, 2);
|
||||
}
|
||||
|
||||
public void testGetterSetter() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
@Test public void testGetterSetter() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
doPointsToSizeTest(TestInfo.SCOPE_FILE, TestInfo.TEST_GETTER_SETTER, 2);
|
||||
}
|
||||
|
||||
public void testException() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
@Test public void testException() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
doPointsToSizeTest(TestInfo.SCOPE_FILE, TestInfo.TEST_EXCEPTION, 4);
|
||||
}
|
||||
|
||||
public void testMultiDim() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
@Test public void testMultiDim() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
doPointsToSizeTest(TestInfo.SCOPE_FILE, TestInfo.TEST_MULTI_DIM, 2);
|
||||
}
|
||||
|
||||
public void testGlobal() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
@Test public void testGlobal() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
doPointsToSizeTest(TestInfo.SCOPE_FILE, TestInfo.TEST_GLOBAL, 1);
|
||||
}
|
||||
|
||||
|
||||
@ -39,6 +39,8 @@ package com.ibm.wala.core.tests.demandpa;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import com.ibm.wala.demandpa.alg.DemandRefinementPointsTo;
|
||||
import com.ibm.wala.demandpa.alg.refinepolicy.AlwaysRefineCGPolicy;
|
||||
import com.ibm.wala.demandpa.alg.refinepolicy.AlwaysRefineFieldsPolicy;
|
||||
@ -48,7 +50,7 @@ import com.ibm.wala.util.CancelException;
|
||||
|
||||
public class OnTheFlyPtrTest extends AbstractPtrTest {
|
||||
|
||||
public void testOnTheFlySimple() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
@Test public void testOnTheFlySimple() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
doPointsToSizeTest(TestInfo.SCOPE_FILE, TestInfo.TEST_ONTHEFLY_SIMPLE, 1);
|
||||
}
|
||||
|
||||
|
||||
@ -39,6 +39,8 @@ package com.ibm.wala.core.tests.demandpa;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import com.ibm.wala.demandpa.alg.DemandRefinementPointsTo;
|
||||
import com.ibm.wala.demandpa.alg.refinepolicy.AlwaysRefineFieldsPolicy;
|
||||
import com.ibm.wala.demandpa.alg.refinepolicy.NeverRefineCGPolicy;
|
||||
@ -48,43 +50,39 @@ import com.ibm.wala.util.CancelException;
|
||||
|
||||
public class RefineFieldsPtrTest extends AbstractPtrTest {
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
}
|
||||
|
||||
public void testNastyPtrs() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
@Test public void testNastyPtrs() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
doPointsToSizeTest(TestInfo.SCOPE_FILE, TestInfo.TEST_NASTY_PTRS, 10);
|
||||
}
|
||||
|
||||
public void testGlobal() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
@Test public void testGlobal() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
doPointsToSizeTest(TestInfo.SCOPE_FILE, TestInfo.TEST_GLOBAL, 1);
|
||||
}
|
||||
|
||||
public void testFields() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
@Test public void testFields() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
doPointsToSizeTest(TestInfo.SCOPE_FILE, TestInfo.TEST_FIELDS, 1);
|
||||
}
|
||||
|
||||
public void testFieldsHarder() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
@Test public void testFieldsHarder() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
doPointsToSizeTest(TestInfo.SCOPE_FILE, TestInfo.TEST_FIELDS_HARDER, 1);
|
||||
}
|
||||
|
||||
public void testArrays() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
@Test public void testArrays() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
doPointsToSizeTest(TestInfo.SCOPE_FILE, TestInfo.TEST_ARRAYS, 2);
|
||||
}
|
||||
|
||||
public void testGetterSetter() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
@Test public void testGetterSetter() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
doPointsToSizeTest(TestInfo.SCOPE_FILE, TestInfo.TEST_GETTER_SETTER, 1);
|
||||
}
|
||||
|
||||
public void testArraySet() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
@Test public void testArraySet() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
doPointsToSizeTest(TestInfo.SCOPE_FILE, TestInfo.TEST_ARRAY_SET, 2);
|
||||
}
|
||||
|
||||
public void testArraySetIter() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
@Test public void testArraySetIter() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
doPointsToSizeTest(TestInfo.SCOPE_FILE, TestInfo.TEST_ARRAY_SET_ITER, 2);
|
||||
}
|
||||
|
||||
public void testMultiDim() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
@Test public void testMultiDim() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
doPointsToSizeTest(TestInfo.SCOPE_FILE, TestInfo.TEST_MULTI_DIM, 2);
|
||||
}
|
||||
|
||||
|
||||
@ -13,6 +13,9 @@ package com.ibm.wala.core.tests.demandpa;
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.ibm.wala.demandpa.alg.ContextSensitiveStateMachine;
|
||||
import com.ibm.wala.demandpa.alg.DemandRefinementPointsTo;
|
||||
import com.ibm.wala.demandpa.alg.IDemandPointerAnalysis;
|
||||
@ -29,26 +32,26 @@ import com.ibm.wala.util.strings.Atom;
|
||||
|
||||
public class TunedRefinementTest extends AbstractPtrTest {
|
||||
|
||||
public void testArraySet() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
@Test public void testArraySet() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
doPointsToSizeTest(TestInfo.SCOPE_FILE, TestInfo.TEST_ARRAY_SET, 1);
|
||||
}
|
||||
|
||||
public void testClone() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
@Test public void testClone() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
doPointsToSizeTest(TestInfo.SCOPE_FILE, TestInfo.TEST_CLONE, 1);
|
||||
}
|
||||
|
||||
public void testFooId() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
@Test public void testFooId() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
doPointsToSizeTest(TestInfo.SCOPE_FILE, TestInfo.TEST_ID, 1);
|
||||
}
|
||||
|
||||
public void testHashtableEnum() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
@Test public void testHashtableEnum() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
// 3 because
|
||||
// can't tell between key, value, and entry enumerators in Hashtable
|
||||
doPointsToSizeTest(TestInfo.SCOPE_FILE, TestInfo.TEST_HASHTABLE_ENUM, 3);
|
||||
}
|
||||
|
||||
// we know this one fails...
|
||||
// public void testOnTheFlyCS() throws ClassHierarchyException {
|
||||
// @Test public void testOnTheFlyCS() throws ClassHierarchyException {
|
||||
// String mainClass = TestInfo.TEST_ONTHEFLY_CS;
|
||||
// final IDemandPointerAnalysis dmp =
|
||||
// makeDemandPointerAnalysis(TestInfo.SCOPE_FILE, mainClass);
|
||||
@ -68,7 +71,7 @@ public class TunedRefinementTest extends AbstractPtrTest {
|
||||
// assertEquals(1, pointsTo.size());
|
||||
// }
|
||||
|
||||
public void testWithinMethodCall() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
@Test public void testWithinMethodCall() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
String mainClass = TestInfo.TEST_WITHIN_METHOD_CALL;
|
||||
final IDemandPointerAnalysis dmp = makeDemandPointerAnalysis(TestInfo.SCOPE_FILE, mainClass);
|
||||
|
||||
@ -79,38 +82,38 @@ public class TunedRefinementTest extends AbstractPtrTest {
|
||||
if (debug) {
|
||||
System.err.println("points-to for " + mainClass + ": " + pointsTo);
|
||||
}
|
||||
assertEquals(1, pointsTo.size());
|
||||
Assert.assertEquals(1, pointsTo.size());
|
||||
}
|
||||
|
||||
public void testLinkedListIter() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
@Test public void testLinkedListIter() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
doPointsToSizeTest(TestInfo.SCOPE_FILE, TestInfo.TEST_LINKEDLIST_ITER, 1);
|
||||
}
|
||||
|
||||
public void testGlobal() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
@Test public void testGlobal() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
doPointsToSizeTest(TestInfo.SCOPE_FILE, TestInfo.TEST_GLOBAL, 1);
|
||||
}
|
||||
|
||||
public void testHashSet() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
@Test public void testHashSet() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
doPointsToSizeTest(TestInfo.SCOPE_FILE, TestInfo.TEST_HASH_SET, 2, 2, 1);
|
||||
}
|
||||
|
||||
public void testHashMapGet() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
@Test public void testHashMapGet() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
doPointsToSizeTest(TestInfo.SCOPE_FILE, TestInfo.TEST_HASHMAP_GET, 2, 1, 1);
|
||||
}
|
||||
|
||||
public void testMethodRecursion() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
@Test public void testMethodRecursion() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
doPointsToSizeTest(TestInfo.SCOPE_FILE, TestInfo.TEST_METHOD_RECURSION, 2);
|
||||
}
|
||||
|
||||
public void testArraySetIter() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
@Test public void testArraySetIter() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
doPointsToSizeTest(TestInfo.SCOPE_FILE, TestInfo.TEST_ARRAY_SET_ITER, 1);
|
||||
}
|
||||
|
||||
public void testArrayList() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
@Test public void testArrayList() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
doPointsToSizeTest(TestInfo.SCOPE_FILE, TestInfo.TEST_ARRAY_LIST, 1);
|
||||
}
|
||||
|
||||
public void testLinkedList() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
@Test public void testLinkedList() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
doPointsToSizeTest(TestInfo.SCOPE_FILE, TestInfo.TEST_LINKED_LIST, 1);
|
||||
}
|
||||
|
||||
|
||||
@ -4,6 +4,9 @@ import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.ibm.wala.classLoader.IClass;
|
||||
import com.ibm.wala.classLoader.ShrikeClass;
|
||||
import com.ibm.wala.core.tests.callGraph.CallGraphTestUtil;
|
||||
@ -26,7 +29,7 @@ public class AnnotationTest extends WalaTestCase {
|
||||
justThisTest(AnnotationTest.class);
|
||||
}
|
||||
|
||||
public void testClassAnnotations1() throws Exception {
|
||||
@Test public void testClassAnnotations1() throws Exception {
|
||||
TypeReference typeUnderTest = TypeReference.findOrCreate(ClassLoaderReference.Application, "Lannotations/AnnotatedClass1");
|
||||
|
||||
Collection<Annotation> expectedRuntimeInvisibleAnnotations = HashSetFactory.make();
|
||||
@ -39,7 +42,7 @@ public class AnnotationTest extends WalaTestCase {
|
||||
testClassAnnontations(typeUnderTest, expectedRuntimeInvisibleAnnotations, expectedRuntimeVisibleAnnotations);
|
||||
}
|
||||
|
||||
public void testClassAnnotations2() throws Exception {
|
||||
@Test public void testClassAnnotations2() throws Exception {
|
||||
TypeReference typeUnderTest = TypeReference.findOrCreate(ClassLoaderReference.Application, "Lannotations/AnnotatedClass2");
|
||||
|
||||
Collection<Annotation> expectedRuntimeInvisibleAnnotations = HashSetFactory.make();
|
||||
@ -60,8 +63,8 @@ public class AnnotationTest extends WalaTestCase {
|
||||
ClassHierarchy cha = ClassHierarchy.make(scope);
|
||||
|
||||
IClass classUnderTest = cha.lookupClass(typeUnderTest);
|
||||
assertNotNull(typeUnderTest.toString() + " not found", classUnderTest);
|
||||
assertTrue(classUnderTest instanceof ShrikeClass);
|
||||
Assert.assertNotNull(typeUnderTest.toString() + " not found", classUnderTest);
|
||||
Assert.assertTrue(classUnderTest instanceof ShrikeClass);
|
||||
ShrikeClass shrikeClassUnderTest = (ShrikeClass) classUnderTest;
|
||||
|
||||
Collection<Annotation> runtimeInvisibleAnnotations = shrikeClassUnderTest.getRuntimeInvisibleAnnotations();
|
||||
@ -81,10 +84,10 @@ public class AnnotationTest extends WalaTestCase {
|
||||
}
|
||||
|
||||
if (expected.size() != actual.size()){
|
||||
assertTrue("expected=" + expected + " actual=" + actual, false);
|
||||
Assert.assertTrue("expected=" + expected + " actual=" + actual, false);
|
||||
}
|
||||
for (T a : expected){
|
||||
assertTrue ("missing " + a.toString(), actual.contains(a));
|
||||
Assert.assertTrue ("missing " + a.toString(), actual.contains(a));
|
||||
}
|
||||
}
|
||||
// String methodSig = "annotations.AnnotatedClass1.m1()V;";
|
||||
|
||||
@ -10,6 +10,9 @@
|
||||
*******************************************************************************/
|
||||
package com.ibm.wala.core.tests.ir;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.ibm.wala.cfg.ControlFlowGraph;
|
||||
import com.ibm.wala.classLoader.IMethod;
|
||||
import com.ibm.wala.classLoader.Language;
|
||||
@ -67,7 +70,7 @@ public class CFGTest extends WalaTestCase {
|
||||
} catch (UnsoundGraphException e) {
|
||||
e.printStackTrace();
|
||||
System.err.println(ir);
|
||||
assertTrue(" failed cfg integrity check for " + methodSig, false);
|
||||
Assert.assertTrue(" failed cfg integrity check for " + methodSig, false);
|
||||
}
|
||||
|
||||
try {
|
||||
@ -76,7 +79,7 @@ public class CFGTest extends WalaTestCase {
|
||||
e.printStackTrace();
|
||||
System.err.println(ir);
|
||||
System.err.println(cfg);
|
||||
assertTrue(" failed 2-exit cfg integrity check for " + methodSig, false);
|
||||
Assert.assertTrue(" failed 2-exit cfg integrity check for " + methodSig, false);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@ -85,11 +88,11 @@ public class CFGTest extends WalaTestCase {
|
||||
}
|
||||
|
||||
/**
|
||||
* this method does not exist in 1.5 libraries public void testFDBigInt() {
|
||||
* this method does not exist in 1.5 libraries @Test public void testFDBigInt() {
|
||||
* doMethod("java.lang.FDBigInt.class$(Ljava/lang/String;)Ljava/lang/Class;"); }
|
||||
*/
|
||||
|
||||
public void testResolveProxyClass() {
|
||||
@Test public void testResolveProxyClass() {
|
||||
doMethod("java.io.ObjectInputStream.resolveProxyClass([Ljava/lang/String;)Ljava/lang/Class;");
|
||||
}
|
||||
}
|
||||
|
||||
@ -12,6 +12,9 @@ package com.ibm.wala.core.tests.ir;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.ibm.wala.analysis.typeInference.TypeInference;
|
||||
import com.ibm.wala.classLoader.IClass;
|
||||
import com.ibm.wala.classLoader.IMethod;
|
||||
@ -48,15 +51,15 @@ public class CornerCasesTest extends WalaTestCase {
|
||||
* @throws ClassHierarchyException
|
||||
* @throws IOException
|
||||
*/
|
||||
public void testBug38484() throws ClassHierarchyException, IOException {
|
||||
@Test public void testBug38484() throws ClassHierarchyException, IOException {
|
||||
AnalysisScope scope = null;
|
||||
scope = AnalysisScopeReader.readJavaScope(TestConstants.WALA_TESTDATA, FileProvider.getFile("J2SEClassHierarchyExclusions.txt"), MY_CLASSLOADER);
|
||||
ClassHierarchy cha = ClassHierarchy.make(scope);
|
||||
TypeReference t = TypeReference.findOrCreateClass(scope.getApplicationLoader(), "cornerCases", "YuckyInterface");
|
||||
IClass klass = cha.lookupClass(t);
|
||||
assertTrue(klass != null);
|
||||
Assert.assertTrue(klass != null);
|
||||
IMethod m = klass.getMethod(new Selector(Atom.findOrCreateAsciiAtom("x"), Descriptor.findOrCreateUTF8("()V")));
|
||||
assertTrue(m == null);
|
||||
Assert.assertTrue(m == null);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -66,17 +69,17 @@ public class CornerCasesTest extends WalaTestCase {
|
||||
* @throws ClassHierarchyException
|
||||
* @throws IOException
|
||||
*/
|
||||
public void testBug38540() throws ClassHierarchyException, IOException {
|
||||
@Test public void testBug38540() throws ClassHierarchyException, IOException {
|
||||
AnalysisScope scope = null;
|
||||
scope = AnalysisScopeReader.readJavaScope(TestConstants.WALA_TESTDATA, FileProvider.getFile("J2SEClassHierarchyExclusions.txt"), MY_CLASSLOADER);
|
||||
AnalysisOptions options = new AnalysisOptions();
|
||||
ClassHierarchy cha = ClassHierarchy.make(scope);
|
||||
TypeReference t = TypeReference.findOrCreateClass(scope.getApplicationLoader(), "cornerCases", "Main");
|
||||
IClass klass = cha.lookupClass(t);
|
||||
assertTrue(klass != null);
|
||||
Assert.assertTrue(klass != null);
|
||||
ShrikeCTMethod m = (ShrikeCTMethod) klass.getMethod(new Selector(Atom.findOrCreateAsciiAtom("foo"), Descriptor
|
||||
.findOrCreateUTF8("()Ljava/lang/Object;")));
|
||||
assertTrue(m != null);
|
||||
Assert.assertTrue(m != null);
|
||||
IR ir = new AnalysisCache().getSSACache().findOrCreateIR(m, Everywhere.EVERYWHERE, options.getSSAOptions());
|
||||
TypeInference.make(ir, false);
|
||||
}
|
||||
|
||||
@ -12,6 +12,11 @@ package com.ibm.wala.core.tests.ir;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.ibm.wala.classLoader.ClassLoaderFactory;
|
||||
import com.ibm.wala.classLoader.ClassLoaderFactoryImpl;
|
||||
import com.ibm.wala.classLoader.IMethod;
|
||||
@ -57,7 +62,8 @@ public class DeterministicIRTest extends WalaTestCase {
|
||||
justThisTest(DeterministicIRTest.class);
|
||||
}
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
|
||||
scope = AnalysisScopeReader.readJavaScope(TestConstants.WALA_TESTDATA,
|
||||
FileProvider.getFile("J2SEClassHierarchyExclusions.txt"), MY_CLASSLOADER);
|
||||
@ -72,20 +78,20 @@ public class DeterministicIRTest extends WalaTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
protected void tearDown() throws Exception {
|
||||
@After
|
||||
public void tearDown() throws Exception {
|
||||
Warnings.clear();
|
||||
scope = null;
|
||||
cha = null;
|
||||
super.tearDown();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param method
|
||||
*/
|
||||
private IR doMethod(MethodReference method) {
|
||||
assertNotNull("method not found", method);
|
||||
Assert.assertNotNull("method not found", method);
|
||||
IMethod imethod = cha.resolveMethod(method);
|
||||
assertNotNull("imethod not found", imethod);
|
||||
Assert.assertNotNull("imethod not found", imethod);
|
||||
IR ir1 = cache.getIRFactory().makeIR(imethod, Everywhere.EVERYWHERE, options.getSSAOptions());
|
||||
cache.getSSACache().wipe();
|
||||
|
||||
@ -96,7 +102,7 @@ public class DeterministicIRTest extends WalaTestCase {
|
||||
} catch (UnsoundGraphException e) {
|
||||
System.err.println(ir1);
|
||||
e.printStackTrace();
|
||||
assertTrue("unsound CFG for ir1", false);
|
||||
Assert.assertTrue("unsound CFG for ir1", false);
|
||||
}
|
||||
|
||||
IR ir2 = cache.getIRFactory().makeIR(imethod, Everywhere.EVERYWHERE, options.getSSAOptions());
|
||||
@ -107,10 +113,10 @@ public class DeterministicIRTest extends WalaTestCase {
|
||||
} catch (UnsoundGraphException e1) {
|
||||
System.err.println(ir2);
|
||||
e1.printStackTrace();
|
||||
assertTrue("unsound CFG for ir2", false);
|
||||
Assert.assertTrue("unsound CFG for ir2", false);
|
||||
}
|
||||
|
||||
assertEquals(ir1.toString(), ir2.toString());
|
||||
Assert.assertEquals(ir1.toString(), ir2.toString());
|
||||
return ir1;
|
||||
}
|
||||
|
||||
@ -121,7 +127,7 @@ public class DeterministicIRTest extends WalaTestCase {
|
||||
*/
|
||||
private void checkNoneNull(Iterator<?> iterator) {
|
||||
while (iterator.hasNext()) {
|
||||
assertTrue(iterator.next() != null);
|
||||
Assert.assertTrue(iterator.next() != null);
|
||||
}
|
||||
|
||||
}
|
||||
@ -135,32 +141,31 @@ public class DeterministicIRTest extends WalaTestCase {
|
||||
return;
|
||||
}
|
||||
}
|
||||
assertTrue("no instructions generated", false);
|
||||
Assert.assertTrue("no instructions generated", false);
|
||||
}
|
||||
|
||||
public void testIR1() {
|
||||
@Test public void testIR1() {
|
||||
// 'remove' is a nice short method
|
||||
doMethod(scope.findMethod(AnalysisScope.APPLICATION, "Ljava/util/HashMap", Atom.findOrCreateUnicodeAtom("remove"),
|
||||
new ImmutableByteArray(UTF8Convert.toUTF8("(Ljava/lang/Object;)Ljava/lang/Object;"))));
|
||||
}
|
||||
|
||||
public void testIR2() {
|
||||
@Test public void testIR2() {
|
||||
// 'equals' is a nice medium-sized method
|
||||
doMethod(scope.findMethod(AnalysisScope.APPLICATION, "Ljava/lang/String", Atom.findOrCreateUnicodeAtom("equals"),
|
||||
new ImmutableByteArray(UTF8Convert.toUTF8("(Ljava/lang/Object;)Z"))));
|
||||
}
|
||||
|
||||
public void testIR3() {
|
||||
@Test public void testIR3() {
|
||||
// 'resolveProxyClass' is a nice long method (at least in Sun libs)
|
||||
doMethod(scope.findMethod(AnalysisScope.APPLICATION, "Ljava/io/ObjectInputStream", Atom
|
||||
.findOrCreateUnicodeAtom("resolveProxyClass"), new ImmutableByteArray(UTF8Convert
|
||||
.toUTF8("([Ljava/lang/String;)Ljava/lang/Class;"))));
|
||||
}
|
||||
|
||||
public void testIR4() {
|
||||
|
||||
@Test public void testIR4() {
|
||||
// test some corner cases with try-finally
|
||||
doMethod(scope.findMethod(AnalysisScope.APPLICATION, "LcornerCases/TryFinally", Atom
|
||||
.findOrCreateUnicodeAtom("test1"), new ImmutableByteArray(UTF8Convert
|
||||
.toUTF8("(Ljava/io/InputStream;Ljava/io/InputStream;)V"))));
|
||||
doMethod(scope.findMethod(AnalysisScope.APPLICATION, "LcornerCases/TryFinally", Atom.findOrCreateUnicodeAtom("test1"),
|
||||
new ImmutableByteArray(UTF8Convert.toUTF8("(Ljava/io/InputStream;Ljava/io/InputStream;)V"))));
|
||||
}
|
||||
}
|
||||
|
||||
@ -10,6 +10,11 @@
|
||||
*******************************************************************************/
|
||||
package com.ibm.wala.core.tests.ir;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.ibm.wala.classLoader.ClassLoaderFactory;
|
||||
import com.ibm.wala.classLoader.ClassLoaderFactoryImpl;
|
||||
import com.ibm.wala.classLoader.IClass;
|
||||
@ -59,7 +64,8 @@ public class LocalNamesTest extends WalaTestCase {
|
||||
/*
|
||||
* @see junit.framework.TestCase#setUp()
|
||||
*/
|
||||
protected void setUp() throws Exception {
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
|
||||
scope = AnalysisScopeReader.readJavaScope(TestConstants.WALA_TESTDATA, FileProvider.getFile("J2SEClassHierarchyExclusions.txt"),
|
||||
MY_CLASSLOADER);
|
||||
@ -80,23 +86,23 @@ public class LocalNamesTest extends WalaTestCase {
|
||||
*
|
||||
* @see junit.framework.TestCase#tearDown()
|
||||
*/
|
||||
protected void tearDown() throws Exception {
|
||||
@After
|
||||
public void tearDown() throws Exception {
|
||||
scope = null;
|
||||
cha = null;
|
||||
super.tearDown();
|
||||
}
|
||||
|
||||
/**
|
||||
* Build an IR, then check getLocalNames
|
||||
*/
|
||||
public void testAliasNames() {
|
||||
@Test public void testAliasNames() {
|
||||
try {
|
||||
AnalysisScope scope = AnalysisScopeReader.readJavaScope(TestConstants.WALA_TESTDATA, FileProvider
|
||||
.getFile("J2SEClassHierarchyExclusions.txt"), MY_CLASSLOADER);
|
||||
ClassHierarchy cha = ClassHierarchy.make(scope);
|
||||
TypeReference t = TypeReference.findOrCreateClass(scope.getApplicationLoader(), "cornerCases", "AliasNames");
|
||||
IClass klass = cha.lookupClass(t);
|
||||
assertTrue(klass != null);
|
||||
Assert.assertTrue(klass != null);
|
||||
IMethod m = klass.getMethod(new Selector(Atom.findOrCreateAsciiAtom("foo"), Descriptor
|
||||
.findOrCreateUTF8("([Ljava/lang/String;)V")));
|
||||
|
||||
@ -110,7 +116,7 @@ public class LocalNamesTest extends WalaTestCase {
|
||||
String[] localNames = ir.getLocalNames(offsetIndex, instr.getDef());
|
||||
if (localNames != null && localNames.length > 0 && localNames[0] == null) {
|
||||
System.err.println(ir);
|
||||
assertTrue(" getLocalNames() returned [null,...] for the def of instruction at offset " + offsetIndex + "\n\tinstr",
|
||||
Assert.assertTrue(" getLocalNames() returned [null,...] for the def of instruction at offset " + offsetIndex + "\n\tinstr",
|
||||
false);
|
||||
}
|
||||
}
|
||||
@ -121,59 +127,59 @@ public class LocalNamesTest extends WalaTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
public void testLocalNamesWithoutPiNodes() {
|
||||
@Test public void testLocalNamesWithoutPiNodes() {
|
||||
SSAPiNodePolicy save = options.getSSAOptions().getPiNodePolicy();
|
||||
options.getSSAOptions().setPiNodePolicy(null);
|
||||
MethodReference mref = scope.findMethod(AnalysisScope.APPLICATION, "LcornerCases/Locals", Atom.findOrCreateUnicodeAtom("foo"),
|
||||
new ImmutableByteArray(UTF8Convert.toUTF8("([Ljava/lang/String;)V")));
|
||||
assertNotNull("method not found", mref);
|
||||
Assert.assertNotNull("method not found", mref);
|
||||
IMethod imethod = cha.resolveMethod(mref);
|
||||
assertNotNull("imethod not found", imethod);
|
||||
Assert.assertNotNull("imethod not found", imethod);
|
||||
IR ir = cache.getIRFactory().makeIR(imethod, Everywhere.EVERYWHERE, options.getSSAOptions());
|
||||
options.getSSAOptions().setPiNodePolicy(save);
|
||||
|
||||
// v1 should be the parameter "a" at pc 0
|
||||
String[] names = ir.getLocalNames(0, 1);
|
||||
assertTrue("failed local name resolution for v1@0", names != null);
|
||||
assertTrue("incorrect number of local names for v1@0: " + names.length, names.length == 1);
|
||||
assertTrue("incorrect local name resolution for v1@0: " + names[0], names[0].equals("a"));
|
||||
Assert.assertTrue("failed local name resolution for v1@0", names != null);
|
||||
Assert.assertTrue("incorrect number of local names for v1@0: " + names.length, names.length == 1);
|
||||
Assert.assertTrue("incorrect local name resolution for v1@0: " + names[0], names[0].equals("a"));
|
||||
|
||||
// v2 is a compiler-induced temporary
|
||||
assertTrue("didn't expect name for v2 at pc 2", ir.getLocalNames(2, 2) == null);
|
||||
Assert.assertTrue("didn't expect name for v2 at pc 2", ir.getLocalNames(2, 2) == null);
|
||||
|
||||
// at pc 5, v1 should represent the locals "a" and "b"
|
||||
names = ir.getLocalNames(5, 1);
|
||||
assertTrue("failed local name resolution for v1@5", names != null);
|
||||
assertTrue("incorrect number of local names for v1@5: " + names.length, names.length == 2);
|
||||
assertTrue("incorrect local name resolution #0 for v1@5: " + names[0], names[0].equals("a"));
|
||||
assertTrue("incorrect local name resolution #1 for v1@5: " + names[1], names[1].equals("b"));
|
||||
Assert.assertTrue("failed local name resolution for v1@5", names != null);
|
||||
Assert.assertTrue("incorrect number of local names for v1@5: " + names.length, names.length == 2);
|
||||
Assert.assertTrue("incorrect local name resolution #0 for v1@5: " + names[0], names[0].equals("a"));
|
||||
Assert.assertTrue("incorrect local name resolution #1 for v1@5: " + names[1], names[1].equals("b"));
|
||||
}
|
||||
|
||||
public void testLocalNamesWithPiNodes() {
|
||||
@Test public void testLocalNamesWithPiNodes() {
|
||||
SSAPiNodePolicy save = options.getSSAOptions().getPiNodePolicy();
|
||||
options.getSSAOptions().setPiNodePolicy(SSAOptions.getAllBuiltInPiNodes());
|
||||
MethodReference mref = scope.findMethod(AnalysisScope.APPLICATION, "LcornerCases/Locals", Atom.findOrCreateUnicodeAtom("foo"),
|
||||
new ImmutableByteArray(UTF8Convert.toUTF8("([Ljava/lang/String;)V")));
|
||||
assertNotNull("method not found", mref);
|
||||
Assert.assertNotNull("method not found", mref);
|
||||
IMethod imethod = cha.resolveMethod(mref);
|
||||
assertNotNull("imethod not found", imethod);
|
||||
Assert.assertNotNull("imethod not found", imethod);
|
||||
IR ir = cache.getIRFactory().makeIR(imethod, Everywhere.EVERYWHERE, options.getSSAOptions());
|
||||
options.getSSAOptions().setPiNodePolicy(save);
|
||||
|
||||
// v1 should be the parameter "a" at pc 0
|
||||
String[] names = ir.getLocalNames(0, 1);
|
||||
assertTrue("failed local name resolution for v1@0", names != null);
|
||||
assertTrue("incorrect number of local names for v1@0: " + names.length, names.length == 1);
|
||||
assertTrue("incorrect local name resolution for v1@0: " + names[0], names[0].equals("a"));
|
||||
Assert.assertTrue("failed local name resolution for v1@0", names != null);
|
||||
Assert.assertTrue("incorrect number of local names for v1@0: " + names.length, names.length == 1);
|
||||
Assert.assertTrue("incorrect local name resolution for v1@0: " + names[0], names[0].equals("a"));
|
||||
|
||||
// v2 is a compiler-induced temporary
|
||||
assertTrue("didn't expect name for v2 at pc 2", ir.getLocalNames(2, 2) == null);
|
||||
Assert.assertTrue("didn't expect name for v2 at pc 2", ir.getLocalNames(2, 2) == null);
|
||||
|
||||
// at pc 5, v1 should represent the locals "a" and "b"
|
||||
names = ir.getLocalNames(5, 1);
|
||||
assertTrue("failed local name resolution for v1@5", names != null);
|
||||
assertTrue("incorrect number of local names for v1@5: " + names.length, names.length == 2);
|
||||
assertTrue("incorrect local name resolution #0 for v1@5: " + names[0], names[0].equals("a"));
|
||||
assertTrue("incorrect local name resolution #1 for v1@5: " + names[1], names[1].equals("b"));
|
||||
Assert.assertTrue("failed local name resolution for v1@5", names != null);
|
||||
Assert.assertTrue("incorrect number of local names for v1@5: " + names.length, names.length == 2);
|
||||
Assert.assertTrue("incorrect local name resolution #0 for v1@5: " + names[0], names[0].equals("a"));
|
||||
Assert.assertTrue("incorrect local name resolution #1 for v1@5: " + names[1], names[1].equals("b"));
|
||||
}
|
||||
}
|
||||
|
||||
@ -12,6 +12,9 @@ package com.ibm.wala.core.tests.ir;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.ibm.wala.classLoader.IClass;
|
||||
import com.ibm.wala.classLoader.IMethod;
|
||||
import com.ibm.wala.classLoader.Language;
|
||||
@ -36,24 +39,24 @@ public class MultiNewArrayTest extends WalaTestCase {
|
||||
|
||||
private static final ClassLoader MY_CLASSLOADER = MultiNewArrayTest.class.getClassLoader();
|
||||
|
||||
public void testMultiNewArray1() throws IOException, ClassHierarchyException {
|
||||
@Test public void testMultiNewArray1() throws IOException, ClassHierarchyException {
|
||||
AnalysisScope scope = null;
|
||||
scope = AnalysisScopeReader.readJavaScope(TestConstants.WALA_TESTDATA, FileProvider.getFile("J2SEClassHierarchyExclusions.txt"), MY_CLASSLOADER);
|
||||
ClassHierarchy cha = ClassHierarchy.make(scope);
|
||||
IClass klass = cha.lookupClass(TypeReference.findOrCreate(ClassLoaderReference.Application, TestConstants.MULTI_DIM_MAIN));
|
||||
assertTrue(klass != null);
|
||||
Assert.assertTrue(klass != null);
|
||||
IMethod m = klass.getMethod(Selector.make(Language.JAVA, "testNewMultiArray()V"));
|
||||
assertTrue(m != null);
|
||||
Assert.assertTrue(m != null);
|
||||
AnalysisCache cache = new AnalysisCache();
|
||||
IR ir = cache.getIRFactory().makeIR(m, Everywhere.EVERYWHERE, new SSAOptions());
|
||||
assertTrue(ir != null);
|
||||
Assert.assertTrue(ir != null);
|
||||
SSAInstruction[] instructions = ir.getInstructions();
|
||||
for (SSAInstruction instr : instructions) {
|
||||
if (instr instanceof SSANewInstruction) {
|
||||
System.err.println(instr.toString(ir.getSymbolTable()));
|
||||
assertTrue(instr.getNumberOfUses() == 2);
|
||||
assertTrue(ir.getSymbolTable().getIntValue(instr.getUse(0)) == 3);
|
||||
assertTrue(ir.getSymbolTable().getIntValue(instr.getUse(1)) == 4);
|
||||
Assert.assertTrue(instr.getNumberOfUses() == 2);
|
||||
Assert.assertTrue(ir.getSymbolTable().getIntValue(instr.getUse(0)) == 3);
|
||||
Assert.assertTrue(ir.getSymbolTable().getIntValue(instr.getUse(1)) == 4);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -13,6 +13,9 @@ package com.ibm.wala.core.tests.ptrs;
|
||||
import java.io.IOException;
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.ibm.wala.core.tests.callGraph.CallGraphTestUtil;
|
||||
import com.ibm.wala.core.tests.util.TestConstants;
|
||||
import com.ibm.wala.core.tests.util.WalaTestCase;
|
||||
@ -53,8 +56,12 @@ public class MultiDimArrayTest extends WalaTestCase {
|
||||
public MultiDimArrayTest(String arg0) {
|
||||
super(arg0);
|
||||
}
|
||||
|
||||
public MultiDimArrayTest() {
|
||||
|
||||
}
|
||||
|
||||
public void testMultiDim() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
@Test public void testMultiDim() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
AnalysisScope scope = CallGraphTestUtil.makeJ2SEAnalysisScope(TestConstants.WALA_TESTDATA, CallGraphTestUtil.REGRESSION_EXCLUSIONS);
|
||||
ClassHierarchy cha = ClassHierarchy.make(scope);
|
||||
Iterable<Entrypoint> entrypoints = com.ibm.wala.ipa.callgraph.impl.Util
|
||||
@ -69,7 +76,7 @@ public class MultiDimArrayTest extends WalaTestCase {
|
||||
CGNode node = findDoNothingNode(cg);
|
||||
PointerKey pk = pa.getHeapModel().getPointerKeyForLocal(node, 1);
|
||||
OrdinalSet<InstanceKey> ptsTo = pa.getPointsToSet(pk);
|
||||
assertEquals(1, ptsTo.size());
|
||||
Assert.assertEquals(1, ptsTo.size());
|
||||
}
|
||||
|
||||
private final static CGNode findDoNothingNode(CallGraph cg) {
|
||||
|
||||
@ -13,6 +13,9 @@ package com.ibm.wala.core.tests.ptrs;
|
||||
import java.io.IOException;
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.ibm.wala.core.tests.callGraph.CallGraphTestUtil;
|
||||
import com.ibm.wala.core.tests.util.TestConstants;
|
||||
import com.ibm.wala.core.tests.util.WalaTestCase;
|
||||
@ -35,7 +38,7 @@ import com.ibm.wala.util.intset.OrdinalSet;
|
||||
|
||||
public class TypeBasedArrayAliasTest extends WalaTestCase {
|
||||
|
||||
public void testTypeBasedArrayAlias() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
@Test public void testTypeBasedArrayAlias() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
AnalysisScope scope = CallGraphTestUtil.makeJ2SEAnalysisScope(TestConstants.WALA_TESTDATA, CallGraphTestUtil.REGRESSION_EXCLUSIONS);
|
||||
ClassHierarchy cha = ClassHierarchy.make(scope);
|
||||
Iterable<Entrypoint> entrypoints = com.ibm.wala.ipa.callgraph.impl.Util
|
||||
@ -50,17 +53,17 @@ public class TypeBasedArrayAliasTest extends WalaTestCase {
|
||||
CGNode node = findNode(cg, "testMayAlias1");
|
||||
PointerKey pk1 = pa.getHeapModel().getPointerKeyForLocal(node, 1);
|
||||
PointerKey pk2 = pa.getHeapModel().getPointerKeyForLocal(node, 2);
|
||||
assertTrue(mayAliased(pk1, pk2, pa));
|
||||
Assert.assertTrue(mayAliased(pk1, pk2, pa));
|
||||
|
||||
node = findNode(cg, "testMayAlias2");
|
||||
pk1 = pa.getHeapModel().getPointerKeyForLocal(node, 1);
|
||||
pk2 = pa.getHeapModel().getPointerKeyForLocal(node, 2);
|
||||
assertTrue(mayAliased(pk1, pk2, pa));
|
||||
Assert.assertTrue(mayAliased(pk1, pk2, pa));
|
||||
|
||||
node = findNode(cg, "testMayAlias3");
|
||||
pk1 = pa.getHeapModel().getPointerKeyForLocal(node, 1);
|
||||
pk2 = pa.getHeapModel().getPointerKeyForLocal(node, 2);
|
||||
assertTrue(mayAliased(pk1, pk2, pa));
|
||||
Assert.assertTrue(mayAliased(pk1, pk2, pa));
|
||||
}
|
||||
|
||||
private final static CGNode findNode(CallGraph cg, String methodName) {
|
||||
|
||||
@ -19,7 +19,8 @@ import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.ibm.wala.core.tests.callGraph.CallGraphTestUtil;
|
||||
import com.ibm.wala.core.tests.util.TestConstants;
|
||||
@ -57,9 +58,9 @@ import com.ibm.wala.util.debug.Assertions;
|
||||
import com.ibm.wala.util.intset.IntSet;
|
||||
import com.ibm.wala.util.strings.Atom;
|
||||
|
||||
public class SlicerTest extends TestCase {
|
||||
public class SlicerTest {
|
||||
|
||||
public void testSlice1() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
@Test public void testSlice1() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
AnalysisScope scope = CallGraphTestUtil.makeJ2SEAnalysisScope(TestConstants.WALA_TESTDATA,
|
||||
CallGraphTestUtil.REGRESSION_EXCLUSIONS);
|
||||
ClassHierarchy cha = ClassHierarchy.make(scope);
|
||||
@ -86,10 +87,10 @@ public class SlicerTest extends TestCase {
|
||||
i++;
|
||||
}
|
||||
}
|
||||
assertEquals(16, i);
|
||||
Assert.assertEquals(16, i);
|
||||
}
|
||||
|
||||
public void testSlice2() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
@Test public void testSlice2() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
AnalysisScope scope = CallGraphTestUtil.makeJ2SEAnalysisScope(TestConstants.WALA_TESTDATA,
|
||||
CallGraphTestUtil.REGRESSION_EXCLUSIONS);
|
||||
ClassHierarchy cha = ClassHierarchy.make(scope);
|
||||
@ -109,10 +110,10 @@ public class SlicerTest extends TestCase {
|
||||
DataDependenceOptions.FULL, ControlDependenceOptions.NONE);
|
||||
Collection<Statement> slice = computeBackwardSlice;
|
||||
dumpSlice(slice);
|
||||
assertEquals(30, slice.size());
|
||||
Assert.assertEquals(30, slice.size());
|
||||
}
|
||||
|
||||
public void testSlice3() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
@Test public void testSlice3() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
AnalysisScope scope = CallGraphTestUtil.makeJ2SEAnalysisScope(TestConstants.WALA_TESTDATA,
|
||||
CallGraphTestUtil.REGRESSION_EXCLUSIONS);
|
||||
ClassHierarchy cha = ClassHierarchy.make(scope);
|
||||
@ -131,10 +132,10 @@ public class SlicerTest extends TestCase {
|
||||
Collection<Statement> slice = Slicer.computeBackwardSlice(s, cg, builder.getPointerAnalysis(), DataDependenceOptions.FULL,
|
||||
ControlDependenceOptions.NONE);
|
||||
dumpSlice(slice);
|
||||
assertEquals(1, countAllocations(slice));
|
||||
Assert.assertEquals(1, countAllocations(slice));
|
||||
}
|
||||
|
||||
public void testSlice4() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
@Test public void testSlice4() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
AnalysisScope scope = CallGraphTestUtil.makeJ2SEAnalysisScope(TestConstants.WALA_TESTDATA,
|
||||
CallGraphTestUtil.REGRESSION_EXCLUSIONS);
|
||||
ClassHierarchy cha = ClassHierarchy.make(scope);
|
||||
@ -153,10 +154,10 @@ public class SlicerTest extends TestCase {
|
||||
Collection<Statement> slice = Slicer.computeForwardSlice(s, cg, builder.getPointerAnalysis(), DataDependenceOptions.FULL,
|
||||
ControlDependenceOptions.NONE);
|
||||
dumpSlice(slice);
|
||||
assertEquals(4, slice.size());
|
||||
Assert.assertEquals(4, slice.size());
|
||||
}
|
||||
|
||||
public void testSlice5() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
@Test public void testSlice5() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
AnalysisScope scope = CallGraphTestUtil.makeJ2SEAnalysisScope(TestConstants.WALA_TESTDATA,
|
||||
CallGraphTestUtil.REGRESSION_EXCLUSIONS);
|
||||
ClassHierarchy cha = ClassHierarchy.make(scope);
|
||||
@ -175,7 +176,7 @@ public class SlicerTest extends TestCase {
|
||||
Collection<Statement> slice = Slicer.computeForwardSlice(s, cg, builder.getPointerAnalysis(), DataDependenceOptions.FULL,
|
||||
ControlDependenceOptions.NONE);
|
||||
dumpSlice(slice);
|
||||
assertEquals(7, slice.size());
|
||||
Assert.assertEquals(7, slice.size());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -184,7 +185,7 @@ public class SlicerTest extends TestCase {
|
||||
* @throws IllegalArgumentException
|
||||
* @throws IOException
|
||||
*/
|
||||
public void testSlice7() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
@Test public void testSlice7() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
AnalysisScope scope = CallGraphTestUtil.makeJ2SEAnalysisScope(TestConstants.WALA_TESTDATA,
|
||||
CallGraphTestUtil.REGRESSION_EXCLUSIONS);
|
||||
ClassHierarchy cha = ClassHierarchy.make(scope);
|
||||
@ -204,7 +205,7 @@ public class SlicerTest extends TestCase {
|
||||
dumpSlice(slice);
|
||||
}
|
||||
|
||||
public void testTestCD1() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
@Test public void testTestCD1() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
AnalysisScope scope = CallGraphTestUtil.makeJ2SEAnalysisScope(TestConstants.WALA_TESTDATA,
|
||||
CallGraphTestUtil.REGRESSION_EXCLUSIONS);
|
||||
ClassHierarchy cha = ClassHierarchy.make(scope);
|
||||
@ -223,10 +224,10 @@ public class SlicerTest extends TestCase {
|
||||
Collection<Statement> slice = Slicer.computeBackwardSlice(s, cg, builder.getPointerAnalysis(), DataDependenceOptions.NONE,
|
||||
ControlDependenceOptions.FULL);
|
||||
dumpSlice(slice);
|
||||
assertEquals(2, countConditionals(slice));
|
||||
Assert.assertEquals(2, countConditionals(slice));
|
||||
}
|
||||
|
||||
public void testTestCD2() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
@Test public void testTestCD2() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
AnalysisScope scope = CallGraphTestUtil.makeJ2SEAnalysisScope(TestConstants.WALA_TESTDATA,
|
||||
CallGraphTestUtil.REGRESSION_EXCLUSIONS);
|
||||
ClassHierarchy cha = ClassHierarchy.make(scope);
|
||||
@ -245,10 +246,10 @@ public class SlicerTest extends TestCase {
|
||||
Collection<Statement> slice = Slicer.computeBackwardSlice(s, cg, builder.getPointerAnalysis(), DataDependenceOptions.NONE,
|
||||
ControlDependenceOptions.FULL);
|
||||
dumpSlice(slice);
|
||||
assertEquals(1, countConditionals(slice));
|
||||
Assert.assertEquals(1, countConditionals(slice));
|
||||
}
|
||||
|
||||
public void testTestCD3() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
@Test public void testTestCD3() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
AnalysisScope scope = CallGraphTestUtil.makeJ2SEAnalysisScope(TestConstants.WALA_TESTDATA,
|
||||
CallGraphTestUtil.REGRESSION_EXCLUSIONS);
|
||||
ClassHierarchy cha = ClassHierarchy.make(scope);
|
||||
@ -267,10 +268,10 @@ public class SlicerTest extends TestCase {
|
||||
Collection<Statement> slice = Slicer.computeBackwardSlice(s, cg, builder.getPointerAnalysis(), DataDependenceOptions.NONE,
|
||||
ControlDependenceOptions.FULL);
|
||||
dumpSlice(slice);
|
||||
assertEquals(0, countConditionals(slice));
|
||||
Assert.assertEquals(0, countConditionals(slice));
|
||||
}
|
||||
|
||||
public void testTestCD4() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
@Test public void testTestCD4() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
AnalysisScope scope = CallGraphTestUtil.makeJ2SEAnalysisScope(TestConstants.WALA_TESTDATA,
|
||||
CallGraphTestUtil.REGRESSION_EXCLUSIONS);
|
||||
ClassHierarchy cha = ClassHierarchy.make(scope);
|
||||
@ -289,15 +290,15 @@ public class SlicerTest extends TestCase {
|
||||
// compute a no-data slice
|
||||
Collection<Statement> slice = Slicer.computeBackwardSlice(s, cg, builder.getPointerAnalysis(), DataDependenceOptions.NONE, ControlDependenceOptions.FULL);
|
||||
dumpSlice(slice);
|
||||
assertEquals(0, countConditionals(slice));
|
||||
Assert.assertEquals(0, countConditionals(slice));
|
||||
|
||||
// compute a full slice
|
||||
slice = Slicer.computeBackwardSlice(s, cg, builder.getPointerAnalysis(), DataDependenceOptions.FULL, ControlDependenceOptions.FULL);
|
||||
dumpSlice(slice);
|
||||
assertEquals(1, countConditionals(slice));
|
||||
Assert.assertEquals(1, countConditionals(slice));
|
||||
}
|
||||
|
||||
public void testTestId() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
@Test public void testTestId() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
AnalysisScope scope = CallGraphTestUtil.makeJ2SEAnalysisScope(TestConstants.WALA_TESTDATA,
|
||||
CallGraphTestUtil.REGRESSION_EXCLUSIONS);
|
||||
ClassHierarchy cha = ClassHierarchy.make(scope);
|
||||
@ -316,10 +317,10 @@ public class SlicerTest extends TestCase {
|
||||
Collection<Statement> slice = Slicer.computeBackwardSlice(s, cg, builder.getPointerAnalysis(), DataDependenceOptions.FULL,
|
||||
ControlDependenceOptions.NONE);
|
||||
dumpSlice(slice);
|
||||
assertEquals(1, countAllocations(slice));
|
||||
Assert.assertEquals(1, countAllocations(slice));
|
||||
}
|
||||
|
||||
public void testTestArrays() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
@Test public void testTestArrays() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
AnalysisScope scope = CallGraphTestUtil.makeJ2SEAnalysisScope(TestConstants.WALA_TESTDATA,
|
||||
CallGraphTestUtil.REGRESSION_EXCLUSIONS);
|
||||
ClassHierarchy cha = ClassHierarchy.make(scope);
|
||||
@ -338,11 +339,11 @@ public class SlicerTest extends TestCase {
|
||||
Collection<Statement> slice = Slicer.computeBackwardSlice(s, cg, builder.getPointerAnalysis(), DataDependenceOptions.FULL,
|
||||
ControlDependenceOptions.NONE);
|
||||
dumpSlice(slice);
|
||||
assertEquals(2, countAllocations(slice));
|
||||
assertEquals(1, countAloads(slice));
|
||||
Assert.assertEquals(2, countAllocations(slice));
|
||||
Assert.assertEquals(1, countAloads(slice));
|
||||
}
|
||||
|
||||
public void testTestFields() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
@Test public void testTestFields() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
AnalysisScope scope = CallGraphTestUtil.makeJ2SEAnalysisScope(TestConstants.WALA_TESTDATA,
|
||||
CallGraphTestUtil.REGRESSION_EXCLUSIONS);
|
||||
ClassHierarchy cha = ClassHierarchy.make(scope);
|
||||
@ -361,11 +362,11 @@ public class SlicerTest extends TestCase {
|
||||
Collection<Statement> slice = Slicer.computeBackwardSlice(s, cg, builder.getPointerAnalysis(), DataDependenceOptions.FULL,
|
||||
ControlDependenceOptions.NONE);
|
||||
dumpSlice(slice);
|
||||
assertEquals(2, countAllocations(slice));
|
||||
assertEquals(1, countPutfields(slice));
|
||||
Assert.assertEquals(2, countAllocations(slice));
|
||||
Assert.assertEquals(1, countPutfields(slice));
|
||||
}
|
||||
|
||||
public void testThin1() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
@Test public void testThin1() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
AnalysisScope scope = CallGraphTestUtil.makeJ2SEAnalysisScope(TestConstants.WALA_TESTDATA,
|
||||
CallGraphTestUtil.REGRESSION_EXCLUSIONS);
|
||||
ClassHierarchy cha = ClassHierarchy.make(scope);
|
||||
@ -386,19 +387,19 @@ public class SlicerTest extends TestCase {
|
||||
Collection<Statement> slice = Slicer.computeBackwardSlice(s, cg, builder.getPointerAnalysis(), DataDependenceOptions.FULL,
|
||||
ControlDependenceOptions.NONE);
|
||||
dumpSlice(slice);
|
||||
assertEquals(3, countAllocations(slice));
|
||||
assertEquals(2, countPutfields(slice));
|
||||
Assert.assertEquals(3, countAllocations(slice));
|
||||
Assert.assertEquals(2, countPutfields(slice));
|
||||
|
||||
// compute thin slice .. ignore base pointers
|
||||
Collection<Statement> computeBackwardSlice = Slicer.computeBackwardSlice(s, cg, builder.getPointerAnalysis(),
|
||||
DataDependenceOptions.NO_BASE_PTRS, ControlDependenceOptions.NONE);
|
||||
slice = computeBackwardSlice;
|
||||
dumpSlice(slice);
|
||||
assertEquals(2, countAllocations(slice));
|
||||
assertEquals(1, countPutfields(slice));
|
||||
Assert.assertEquals(2, countAllocations(slice));
|
||||
Assert.assertEquals(1, countPutfields(slice));
|
||||
}
|
||||
|
||||
public void testTestGlobal() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
@Test public void testTestGlobal() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
AnalysisScope scope = CallGraphTestUtil.makeJ2SEAnalysisScope(TestConstants.WALA_TESTDATA,
|
||||
CallGraphTestUtil.REGRESSION_EXCLUSIONS);
|
||||
ClassHierarchy cha = ClassHierarchy.make(scope);
|
||||
@ -417,12 +418,12 @@ public class SlicerTest extends TestCase {
|
||||
Collection<Statement> slice = Slicer.computeBackwardSlice(s, cg, builder.getPointerAnalysis(), DataDependenceOptions.FULL,
|
||||
ControlDependenceOptions.NONE);
|
||||
dumpSlice(slice);
|
||||
assertEquals(1, countAllocations(slice));
|
||||
assertEquals(2, countPutstatics(slice));
|
||||
assertEquals(2, countGetstatics(slice));
|
||||
Assert.assertEquals(1, countAllocations(slice));
|
||||
Assert.assertEquals(2, countPutstatics(slice));
|
||||
Assert.assertEquals(2, countGetstatics(slice));
|
||||
}
|
||||
|
||||
public void testTestMultiTarget() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
@Test public void testTestMultiTarget() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
AnalysisScope scope = CallGraphTestUtil.makeJ2SEAnalysisScope(TestConstants.WALA_TESTDATA,
|
||||
CallGraphTestUtil.REGRESSION_EXCLUSIONS);
|
||||
ClassHierarchy cha = ClassHierarchy.make(scope);
|
||||
@ -441,10 +442,10 @@ public class SlicerTest extends TestCase {
|
||||
Collection<Statement> slice = Slicer.computeBackwardSlice(s, cg, builder.getPointerAnalysis(), DataDependenceOptions.FULL,
|
||||
ControlDependenceOptions.NONE);
|
||||
dumpSlice(slice);
|
||||
assertEquals(2, countAllocations(slice));
|
||||
Assert.assertEquals(2, countAllocations(slice));
|
||||
}
|
||||
|
||||
public void testTestRecursion() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
@Test public void testTestRecursion() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
AnalysisScope scope = CallGraphTestUtil.makeJ2SEAnalysisScope(TestConstants.WALA_TESTDATA,
|
||||
CallGraphTestUtil.REGRESSION_EXCLUSIONS);
|
||||
ClassHierarchy cha = ClassHierarchy.make(scope);
|
||||
@ -464,11 +465,11 @@ public class SlicerTest extends TestCase {
|
||||
Collection<Statement> slice = Slicer.computeBackwardSlice(s, cg, builder.getPointerAnalysis(), DataDependenceOptions.FULL,
|
||||
ControlDependenceOptions.NONE);
|
||||
dumpSlice(slice);
|
||||
assertEquals(3, countAllocations(slice));
|
||||
assertEquals(2, countPutfields(slice));
|
||||
Assert.assertEquals(3, countAllocations(slice));
|
||||
Assert.assertEquals(2, countPutfields(slice));
|
||||
}
|
||||
|
||||
public void testPrimGetterSetter() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
@Test public void testPrimGetterSetter() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
AnalysisScope scope = CallGraphTestUtil.makeJ2SEAnalysisScope(TestConstants.WALA_TESTDATA,
|
||||
CallGraphTestUtil.REGRESSION_EXCLUSIONS);
|
||||
ClassHierarchy cha = ClassHierarchy.make(scope);
|
||||
@ -490,11 +491,11 @@ public class SlicerTest extends TestCase {
|
||||
Collection<Statement> slice = Slicer.computeBackwardSlice(s, pcg, builder.getPointerAnalysis(), DataDependenceOptions.FULL,
|
||||
ControlDependenceOptions.FULL);
|
||||
dumpSlice(slice);
|
||||
assertEquals(0, countAllocations(slice));
|
||||
assertEquals(1, countPutfields(slice));
|
||||
Assert.assertEquals(0, countAllocations(slice));
|
||||
Assert.assertEquals(1, countPutfields(slice));
|
||||
}
|
||||
|
||||
public void testTestThrowCatch() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
@Test public void testTestThrowCatch() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
AnalysisScope scope = CallGraphTestUtil.makeJ2SEAnalysisScope(TestConstants.WALA_TESTDATA,
|
||||
CallGraphTestUtil.REGRESSION_EXCLUSIONS);
|
||||
ClassHierarchy cha = ClassHierarchy.make(scope);
|
||||
@ -513,12 +514,12 @@ public class SlicerTest extends TestCase {
|
||||
Collection<Statement> slice = Slicer.computeBackwardSlice(s, cg, builder.getPointerAnalysis(), DataDependenceOptions.FULL,
|
||||
ControlDependenceOptions.NONE);
|
||||
dumpSlice(slice);
|
||||
assertEquals(1, countAllocations(slice));
|
||||
assertEquals(1, countThrows(slice));
|
||||
assertEquals(1, countGetfields(slice));
|
||||
Assert.assertEquals(1, countAllocations(slice));
|
||||
Assert.assertEquals(1, countThrows(slice));
|
||||
Assert.assertEquals(1, countGetfields(slice));
|
||||
}
|
||||
|
||||
public void testTestMessageFormat() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
@Test public void testTestMessageFormat() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
AnalysisScope scope = CallGraphTestUtil.makeJ2SEAnalysisScope(TestConstants.WALA_TESTDATA,
|
||||
CallGraphTestUtil.REGRESSION_EXCLUSIONS);
|
||||
ClassHierarchy cha = ClassHierarchy.make(scope);
|
||||
|
||||
@ -10,6 +10,11 @@
|
||||
*******************************************************************************/
|
||||
package com.ibm.wala.core.tests.typeInference;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.ibm.wala.analysis.typeInference.TypeAbstraction;
|
||||
import com.ibm.wala.analysis.typeInference.TypeInference;
|
||||
import com.ibm.wala.classLoader.ClassLoaderFactory;
|
||||
@ -55,7 +60,8 @@ public class TypeInferenceTest extends WalaTestCase {
|
||||
justThisTest(TypeInferenceTest.class);
|
||||
}
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
|
||||
scope = AnalysisScopeReader.readJavaScope(TestConstants.WALA_TESTDATA, FileProvider.getFile("J2SEClassHierarchyExclusions.txt"), MY_CLASSLOADER);
|
||||
|
||||
@ -70,19 +76,19 @@ public class TypeInferenceTest extends WalaTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
protected void tearDown() throws Exception {
|
||||
@After
|
||||
public void tearDown() throws Exception {
|
||||
Warnings.clear();
|
||||
scope = null;
|
||||
cha = null;
|
||||
super.tearDown();
|
||||
}
|
||||
|
||||
public void test1() {
|
||||
@Test public void test1() {
|
||||
MethodReference method = scope.findMethod(AnalysisScope.APPLICATION, "LtypeInference/TI", Atom.findOrCreateUnicodeAtom("foo"),
|
||||
new ImmutableByteArray(UTF8Convert.toUTF8("()V")));
|
||||
assertNotNull("method not found", method);
|
||||
Assert.assertNotNull("method not found", method);
|
||||
IMethod imethod = cha.resolveMethod(method);
|
||||
assertNotNull("imethod not found", imethod);
|
||||
Assert.assertNotNull("imethod not found", imethod);
|
||||
IR ir = cache.getIRFactory().makeIR(imethod, Everywhere.EVERYWHERE, options.getSSAOptions());
|
||||
System.out.println(ir);
|
||||
|
||||
@ -92,32 +98,32 @@ public class TypeInferenceTest extends WalaTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
public void test2() {
|
||||
@Test public void test2() {
|
||||
MethodReference method = scope.findMethod(AnalysisScope.APPLICATION, "LtypeInference/TI", Atom.findOrCreateUnicodeAtom("bar"),
|
||||
new ImmutableByteArray(UTF8Convert.toUTF8("(I)V")));
|
||||
assertNotNull("method not found", method);
|
||||
Assert.assertNotNull("method not found", method);
|
||||
IMethod imethod = cha.resolveMethod(method);
|
||||
assertNotNull("imethod not found", imethod);
|
||||
Assert.assertNotNull("imethod not found", imethod);
|
||||
IR ir = cache.getIRFactory().makeIR(imethod, Everywhere.EVERYWHERE, options.getSSAOptions());
|
||||
System.out.println(ir);
|
||||
|
||||
TypeInference ti = TypeInference.make(ir, true);
|
||||
assertNotNull("null type abstraction for parameter", ti.getType(2));
|
||||
Assert.assertNotNull("null type abstraction for parameter", ti.getType(2));
|
||||
}
|
||||
|
||||
public void test3() {
|
||||
@Test public void test3() {
|
||||
MethodReference method = scope.findMethod(AnalysisScope.APPLICATION, "LtypeInference/TI", Atom.findOrCreateUnicodeAtom("inferInt"),
|
||||
new ImmutableByteArray(UTF8Convert.toUTF8("()V")));
|
||||
assertNotNull("method not found", method);
|
||||
Assert.assertNotNull("method not found", method);
|
||||
IMethod imethod = cha.resolveMethod(method);
|
||||
assertNotNull("imethod not found", imethod);
|
||||
Assert.assertNotNull("imethod not found", imethod);
|
||||
IR ir = cache.getIRFactory().makeIR(imethod, Everywhere.EVERYWHERE, options.getSSAOptions());
|
||||
System.out.println(ir);
|
||||
|
||||
TypeInference ti = TypeInference.make(ir, true);
|
||||
TypeAbstraction type = ti.getType(7);
|
||||
assertNotNull("null type abstraction", type);
|
||||
assertTrue("inferred wrong type", type.toString().equals("int"));
|
||||
Assert.assertNotNull("null type abstraction", type);
|
||||
Assert.assertTrue("inferred wrong type", type.toString().equals("int"));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -10,8 +10,10 @@
|
||||
*******************************************************************************/
|
||||
package com.ibm.wala.core.tests.util;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import junit.framework.TestSuite;
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.runner.JUnitCore;
|
||||
|
||||
import com.ibm.wala.util.heapTrace.HeapTracer;
|
||||
import com.ibm.wala.util.warnings.Warnings;
|
||||
@ -19,7 +21,7 @@ import com.ibm.wala.util.warnings.Warnings;
|
||||
/**
|
||||
* Simple extension to JUnit test case.
|
||||
*/
|
||||
public abstract class WalaTestCase extends TestCase {
|
||||
public abstract class WalaTestCase {
|
||||
|
||||
final private static boolean ANALYZE_LEAKS = false;
|
||||
|
||||
@ -35,51 +37,56 @@ public abstract class WalaTestCase extends TestCase {
|
||||
/*
|
||||
* @see junit.framework.TestCase#setUp()
|
||||
*/
|
||||
protected void setUp() throws Exception {
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
}
|
||||
|
||||
/*
|
||||
* @see junit.framework.TestCase#tearDown()
|
||||
*/
|
||||
protected void tearDown() throws Exception {
|
||||
@After
|
||||
public void tearDown() throws Exception {
|
||||
Warnings.clear();
|
||||
if (ANALYZE_LEAKS) {
|
||||
HeapTracer.analyzeLeaks();
|
||||
}
|
||||
}
|
||||
|
||||
public WalaTestCase() {
|
||||
super("WalaTestCase");
|
||||
/**
|
||||
* Utility function: each DetoxTestCase subclass can have a main() method that calls this, to create a test suite consisting of
|
||||
* just this test. Useful when investigating a single failing test.
|
||||
*/
|
||||
protected static void justThisTest(Class<?> testClass) {
|
||||
JUnitCore.runClasses(testClass);
|
||||
}
|
||||
|
||||
/**
|
||||
* Utility function: each DetoxTestCase subclass can have a main() method that
|
||||
* calls this, to create a test suite consisting of just this test. Useful
|
||||
* when investigating a single failing test.
|
||||
*/
|
||||
protected static void justThisTest(Class<? extends TestCase> testClass) {
|
||||
TestSuite suite = new TestSuite(testClass.getName());
|
||||
suite.addTestSuite(testClass);
|
||||
junit.textui.TestRunner.run(suite);
|
||||
}
|
||||
private final String name;
|
||||
|
||||
/**
|
||||
* @param arg0
|
||||
*/
|
||||
public WalaTestCase(String arg0) {
|
||||
super(arg0);
|
||||
this.name = arg0;
|
||||
}
|
||||
|
||||
public WalaTestCase() {
|
||||
this(null);
|
||||
}
|
||||
|
||||
protected String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
protected static void assertBound(String tag, double quantity, double bound) {
|
||||
String msg = tag + ", quantity: " + quantity + ", bound:" + bound;
|
||||
System.err.println(msg);
|
||||
assertTrue(msg, quantity <= bound);
|
||||
Assert.assertTrue(msg, quantity <= bound);
|
||||
}
|
||||
|
||||
protected static void assertBound(String tag, int quantity, int bound) {
|
||||
String msg = tag + ", quantity: " + quantity + ", bound:" + bound;
|
||||
System.err.println(msg);
|
||||
assertTrue(msg, quantity <= bound);
|
||||
Assert.assertTrue(msg, quantity <= bound);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user