001: package org.hanseltest.probes;
002:
003: import junit.framework.TestCase;
004: import org.hansel.ProbeData;
005:
006: /**
007: * Tests for the org.hansel.probe.*Comparator classes.
008: *
009: * @author Niklas Mehner
010: */
011: public class ACmpBranchProbeTest extends TestCase {
012: /* private ClassLoaderRepository repository;
013: private JavaClass javaClass;
014: private Method[] methods;
015: private ConstantPoolGen cpg;
016:
017: public void setUp() throws Exception {
018: repository = new ClassLoaderRepository(getClass().getClassLoader());
019: javaClass = repository.loadClass(ACmpBranchProbeTest.class.getName());
020: methods = javaClass.getMethods();
021: cpg = new ConstantPoolGen(javaClass.getConstantPool());
022: }*/
023:
024: public ProbeData getProbeData() {
025: /*SymbolicStack stack = new SymbolicStack(null);
026: stack = stack.push(new StackEntry("stack1", Type.INT));
027: stack = stack.push(new StackEntry("stack2", Type.INT));
028:
029: return new ProbeData(new ProbeTable(null),
030: "classname",
031: "methodname",
032: stack,
033: 42,
034: 13,
035: 26); TODO: FixMe */
036: return null;
037: }
038:
039: /**
040: * Test failure message.
041: */
042: public void testFailureMessage() {
043: throw new UnsupportedOperationException("Not yet converted");
044: /* ACmpBranchProbe acbp = new ACmpBranchProbe(getProbeData(),
045: true);
046: assertEquals("Branch not completely covered. Condition '"
047: + "stack1 == stack2"
048: + "' is not fulfilled.", acbp.getFailureMessage());
049:
050: acbp = new ACmpBranchProbe(getProbeData(),
051: false);
052: assertEquals("Branch not completely covered. Condition '"
053: + "stack1 != stack2"
054: + "' is not fulfilled.", acbp.getFailureMessage());*/
055: }
056:
057: /** Test coverage conditions.
058: */
059: /*public void testHit() {
060: Object o1 = new Object();
061: Object o2 = new Object();
062:
063: ACmpBranchProbe acbp = new ACmpBranchProbe(getProbeData(), true);
064: acbp.hit(o1, o1);
065: assertTrue(acbp.getFailureMessage().indexOf("!=") > 0);
066:
067: acbp = new ACmpBranchProbe(getProbeData(), true);
068: acbp.hit(o1, o2);
069: assertTrue(acbp.getFailureMessage().indexOf("==") > 0);
070:
071: acbp = new ACmpBranchProbe(getProbeData(), false);
072: acbp.hit(o1, o1);
073: assertTrue(acbp.getFailureMessage().indexOf("!=") > 0);
074:
075: acbp = new ACmpBranchProbe(getProbeData(), false);
076: acbp.hit(o1, o2);
077: assertTrue(acbp.getFailureMessage().indexOf("==") > 0);
078: }
079:
080: public void testGetCode() {
081: ACmpBranchProbe acbp = new ACmpBranchProbe(getProbeData(), true);
082: InstructionList code = acbp.getProbeCode(cpg);
083: assertEquals(3, code.size());
084:
085: InstructionHandle ih = code.getStart();
086:
087: assertTrue(ih.getInstruction() instanceof DUP2);
088: ih = ih.getNext();
089: assertTrue(ih.getInstruction() instanceof PushInstruction);
090: ih = ih.getNext();
091: assertTrue(ih.getInstruction() instanceof INVOKESTATIC);
092: }
093:
094: /**
095: * Returns a coverage decorator for this test.
096: * @return CoverageTest.
097: */
098: /* public static Test suite() {
099: CoverageDecorator result =
100: new CoverageDecorator(ACmpBranchProbeTest.class,
101: new Class[] {ACmpBranchProbe.class});
102:
103: return result;
104: }*/
105: }
|