fr.inria.lille.repair.common.config.NopolContext Java Examples

The following examples show how to use fr.inria.lille.repair.common.config.NopolContext. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AbstractRealBugsEvaluation.java    From nopol with GNU General Public License v2.0 6 votes vote down vote up
@Ignore
@Test
public void AM2() {
    String projectName = "am2";
    RepairType repairType = RepairType.DOUBLE_LITERAL;
    NopolContext config = new NopolContext();
    List<Patch> patches = setupAndRun(
            projectName,
repairType,
            new String[]{"org.apache.commons.math.optimization.direct.BOBYQAOptimizerTest"}, config);

    assertEquals(patches.toString(), 1, patches.size());
    Patch patch = patches.get(0);
    assertEquals(patch.getType(), repairType);
    System.out.println(String.format("Patch for real bug %s: %s",
            projectName, patch.asString()));

    TestUtility.assertAgainstKnownPatches(patch, "stopFitness;");

    String rootFolder = realBugPath + projectName + "/";
    String srcFolder = rootFolder + "src";
    clean(srcFolder); // TODO
}
 
Example #2
Source File: AbstractRealBugsEvaluation.java    From nopol with GNU General Public License v2.0 6 votes vote down vote up
@Test
public void AM1() {
    String projectName = "am1";
    RepairType repairType = RepairType.DOUBLE_LITERAL;
    NopolContext config = new NopolContext();
    config.setSolver(NopolContext.NopolSolver.Z3);
    config.setSolverPath("lib/z3/z3_for_linux");

    List<Patch> patches = setupAndRun(
            projectName,
repairType,
            new String[]{"org.apache.commons.math3.complex.QuaternionTest"}, config);

    assertEquals(patches.toString(), 1, patches.size());
    Patch patch = patches.get(0);
    assertEquals(patch.getType(), repairType);
    System.out.println(String.format("Patch for real bug %s: %s",
            projectName, patch.asString()));

    TestUtility.assertAgainstKnownPatches(patch, "start == seqEnd");

    String rootFolder = realBugPath + projectName + "/";
    String srcFolder = rootFolder + "src";
    clean(srcFolder); // TODO
}
 
Example #3
Source File: SynthesizerOnRealBugTest.java    From nopol with GNU General Public License v2.0 6 votes vote down vote up
@Test
public void CM3() throws InterruptedException {
    Map<String, Object[]> oracle = new HashMap<>();
    oracle.put("org.apache.commons.math.util.MathUtilsTest#testFactorial", new Object[]{false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false});
    oracle.put("org.apache.commons.math.util.MathUtilsTest#testFactorialFail_1", new Object[]{true});
    oracle.put("org.apache.commons.math.util.MathUtilsTest#testFactorialFail_2", new Object[]{true});
    oracle.put("org.apache.commons.math.util.MathUtilsTest#testFactorialFail_3", new Object[]{true});
    oracle.put("org.apache.commons.math.util.MathUtilsTest#testFactorialFail_4", new Object[]{false});
    oracle.put("org.apache.commons.math.util.MathUtilsTest#testFactorialFail_5", new Object[]{false});

    SourceLocation location = new SourceLocation("org.apache.commons.math.util.MathUtils", 419);
    boolean isMaven = false;
    test("cm3",
            isMaven,
            "",
            oracle,
            location,
            new String[] {"commons-discovery-SNAPSHOT.jar",
                    "commons-logging-1.0.3.jar"},
            new NopolContext(),
            "n < 0", "n < 0.0");
}
 
Example #4
Source File: AbstractRealBugsEvaluation.java    From nopol with GNU General Public License v2.0 6 votes vote down vote up
@Test
public void PM2() {
    String projectName = "pm2";
    RepairType repairType = RepairType.PRECONDITION;
    NopolContext config = new NopolContext();
    List<Patch> patches = setupAndRun(
            projectName,
repairType,
            new String[]{"org.apache.commons.math.exception.util.MessageFactoryTest"},
            config,
            "junit-4.10.jar");

    assertEquals(patches.toString(), 1, patches.size());
    Patch patch = patches.get(0);
    assertEquals(patch.getType(), repairType);
    System.out.println(String.format("Patch for real bug %s: %s",
            projectName, patch.asString()));


    TestUtility.assertAgainstKnownPatches(patch, "specific!=null", "null != specific", "0 != ((java.lang.StringBuilder)sb).length()");

    String rootFolder = realBugPath + projectName + "/";
    String srcFolder = rootFolder + "src";
    clean(srcFolder); // TODO
}
 
Example #5
Source File: DynamothCodeGenesisTest.java    From nopol with GNU General Public License v2.0 6 votes vote down vote up
private DynamothCodeGenesis createSynthesizer(int nopolExampleNumber, Map<String, Object[]> o, int line, NopolContext nopolContext) {
    String executionType = "nopol";
    String pack = executionType + "_examples." + executionType + "_example_" + nopolExampleNumber;
    String className = pack + ".NopolExample";
    String testName = pack + ".NopolExampleTest";
    List<String> tests = new ArrayList<>();

    Map<String, Object[]> oracle = new HashMap<>();

    for (String next : o.keySet()) {
        oracle.put(testName + "#" + next, o.get(next));
        tests.add(testName + "#" + next);
    }

    nopolContext.setDataCollectionTimeoutInSecondForSynthesis(5);

    String classpath = "../test-projects/target/test-classes"+File.pathSeparatorChar+"../test-projects/target/classes/"+File.pathSeparatorChar+"lib/junit-4.11.jar";
    SourceLocation location = new SourceLocation(className, line);
    File[] files = new File []{new File("../test-projects/src/main/java/"), new File("../test-projects/src/test/java/")};

    DynamothCodeGenesis dynamothCodeGenesis = new DynamothCodeGenesisImpl(files, location, JavaLibrary.classpathFrom(classpath), oracle, tests.toArray(new String[0]),nopolContext);

    dynamothCodeGenesis.run(TimeUnit.MINUTES.toMillis(15));
    return dynamothCodeGenesis;
}
 
Example #6
Source File: SynthesizerOnRealBugTest.java    From nopol with GNU General Public License v2.0 6 votes vote down vote up
private void test(String projectName, boolean isMaven, String sourceFolder, Map<String, Object[]> oracle, SourceLocation location, String[] dependencies, NopolContext nopolContext, String... patch) {
    String realBugPath = "../../nopol-dataset/";
    String rootFolder = realBugPath + projectName + "/";
    String srcFolder = rootFolder + "src/";
    String binFolder = rootFolder + "bin/";
    if (isMaven) {
        binFolder = rootFolder + "target/classes:" + rootFolder + "target/test-classes";
    }
    String libFolder = rootFolder + "lib/";

    String classpath = binFolder + ":/home/thomas/.m2/repository/junit/junit/4.11/junit-4.11.jar:/home/thomas/.m2/repository/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar:";
    for (int i = 0; i < dependencies.length; i++) {
        classpath += libFolder + dependencies[i];
        if (i < dependencies.length - 1) {
            classpath += ":";
        }
    }
    File[] sourceFiles = { new File(srcFolder + sourceFolder) };
    URL[] classpathURL = JavaLibrary.classpathFrom(classpath);
    String[] tests = oracle.keySet().toArray(new String[0]);
    DynamothCodeGenesis synthesizer = new DynamothCodeGenesisImpl(sourceFiles,location, classpathURL, oracle, tests, nopolContext);
    Candidates expression = synthesizer.run(TimeUnit.MINUTES.toMillis(15));
    check(expression, patch);
}
 
Example #7
Source File: IfMetric.java    From nopol with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) {

        if (2 != args.length) {
            printUsage();
            return;
        }
        File sourceFolder = new File(args[0]);
        checkArgument(sourceFolder.exists(), "%s: does not exist.",
                sourceFolder);
        checkArgument(sourceFolder.isDirectory(), "%s: is not a directory.",
                sourceFolder);

        System.setProperty("java.class.path",
                System.getProperty("java.class.path") + File.pathSeparatorChar
                        + args[1]);
        String[] paths = args[1].split(Character
                .toString(File.pathSeparatorChar));

        URL[] classpath = IfMetric.createUrls(paths);

        new IfMetric(new NopolContext(new File[]{ sourceFolder }, classpath, null)).run();
    }
 
Example #8
Source File: SynthesizerOnRealBugTest.java    From nopol with GNU General Public License v2.0 6 votes vote down vote up
@Test
public void CM2() throws InterruptedException {
    Map<String, Object[]> oracle = new HashMap<>();
    oracle.put("org.apache.commons.math.util.MathUtilsTest#test0Choose0_3", new Object[]{false});
    oracle.put("org.apache.commons.math.util.MathUtilsTest#testBinomialCoefficient1", new Object[]{false});
    oracle.put("org.apache.commons.math.util.MathUtilsTest#testBinomialCoefficient2", new Object[]{false});
    oracle.put("org.apache.commons.math.util.MathUtilsTest#testBinomialCoefficient3", new Object[]{false});
    oracle.put("org.apache.commons.math.util.MathUtilsTest#testBinomialCoefficient6", new Object[]{false});
    oracle.put("org.apache.commons.math.util.MathUtilsTest#testBinomialCoefficient14_1", new Object[]{false});
    oracle.put("org.apache.commons.math.util.MathUtilsTest#testBinomialCoefficient69", new Object[]{true});

    SourceLocation location = new SourceLocation("org.apache.commons.math.util.MathUtils", 254);
    boolean isMaven = false;
    test("cm2",
            isMaven,
            "",
            oracle,
            location,
            new String[] {},
            new NopolContext(),
            "n < 0", "n < 0.0");
}
 
Example #9
Source File: DynamothCodeGenesisTest.java    From nopol with GNU General Public License v2.0 6 votes vote down vote up
@Test
public void test8() throws InterruptedException {
    Map<String, Object[]> oracle = new HashMap<>();
    oracle.put("test_1", new Object[]{true});
    oracle.put("test_2", new Object[]{true});
    oracle.put("test_3", new Object[]{true});
    oracle.put("test_4", new Object[]{true});
    oracle.put("test_5", new Object[]{true});
    oracle.put("test_6", new Object[]{true});
    oracle.put("test_7", new Object[]{false});
    oracle.put("test_8", new Object[]{false});
    oracle.put("test_9", new Object[]{false});
    oracle.put("test_10", new Object[]{false});
    oracle.put("test_11", new Object[]{false});

    NopolContext nopolContext = TestUtility.configForExample("nopol",8);

    test(8, oracle, 12, new String[] {"(b * a) <= 100", "(a * b) <= 100", "a <= (100 / b)", "b <= (100 / a)"}, nopolContext);
}
 
Example #10
Source File: AbstractRealBugsEvaluation.java    From nopol with GNU General Public License v2.0 6 votes vote down vote up
@Test
public void CM10() {
    String projectName = "cm10";
    RepairType repairType = RepairType.PRECONDITION;
    NopolContext config = new NopolContext();
    List<Patch> patches = setupAndRun(
            projectName,
repairType,
            new String[]{"org.apache.commons.math3.stat.correlation.CovarianceTest"},
            config,
            "junit-4.10.jar");

    assertEquals(patches.toString(), 1, patches.size());
    Patch patch = patches.get(0);
    assertEquals(patch.getType(), repairType);
    System.out.println(String.format("Patch for real bug %s: %s",
            projectName, patch.asString()));

    TestUtility.assertAgainstKnownPatches(patch, "(nRows < 2)", "nRows < 2", "((org.apache.commons.math3.linear.AbstractRealMatrix)matrix).isSquare()", "(1) != (nCols)");

    String rootFolder = realBugPath + projectName + "/";
    String srcFolder = rootFolder + "src";
    clean(srcFolder); // TODO
}
 
Example #11
Source File: SynthesizerOnRealBugTest.java    From nopol with GNU General Public License v2.0 6 votes vote down vote up
@Test
public void CM9() throws InterruptedException {
    Map<String, Object[]> oracle = new HashMap<>();
    oracle.put("org.apache.commons.math3.util.FastMathTest#testMath904_1", new Object[]{false, false});
    oracle.put("org.apache.commons.math3.util.FastMathTest#testMath904_2", new Object[]{false, false});

    SourceLocation location = new SourceLocation("org.apache.commons.math3.util.FastMath", 1543);
    boolean isMaven = true;
    test("cm9",
            isMaven,
            "main/java/",
            oracle,
            location,
            new String[] {},
            new NopolContext(),
            "y >= TWO_POWER_53 || y <= -TWO_POWER_53");
}
 
Example #12
Source File: SynthesizerOnRealBugTest.java    From nopol with GNU General Public License v2.0 6 votes vote down vote up
@Test
public void CM1() throws InterruptedException {
    Map<String, Object[]> oracle = new HashMap<>();
    oracle.put("org.apache.commons.math.stat.univariate.rank.PercentileTest#testHighPercentile", new Object[]{true});
    oracle.put("org.apache.commons.math.stat.univariate.rank.PercentileTest#testEvaluation", new Object[]{false});

    SourceLocation location = new SourceLocation("org.apache.commons.math.stat.univariate.rank.Percentile", 151);
    boolean isMaven = false;
    test("cm1",
            isMaven,
            "",
            oracle,
            location,
            new String[] {},
            new NopolContext(),
            "n <= pos",
            "n == pos");
}
 
Example #13
Source File: AbstractRealBugsEvaluation.java    From nopol with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void CL4() {
    NopolContext config = new NopolContext();
    config.setComplianceLevel(4);
    String projectName = "cl4";
    RepairType repairType = RepairType.CONDITIONAL;
    List<Patch> patches = setupAndRun(
            projectName,
repairType,
            new String[]{"org.apache.commons.lang.text.StrBuilderTest" },
            config,
            "junit-3.8.jar");

    assertEquals(patches.toString(), 1, patches.size());
    Patch patch = patches.get(0);
    assertEquals(patch.getType(), repairType);
    System.out.println(String.format("Patch for real bug %s: %s",
            projectName, patch.asString()));

    TestUtility.assertAgainstKnownPatches(
            patch,
            "((!(str!=null))||(startIndex >= (size)))&&((!(str!=null))||(startIndex >= (size)))",
            "(!(str!=null))||(startIndex >= (size))",
            "(startIndex >= (size)) || (!(str!=null))",
            "((startIndex >= (size)) || (!(str!=null))) && ((org.apache.commons.lang.text.StrBuilder.this.size) != (-1))");
    String rootFolder = realBugPath + projectName + "/";
    String srcFolder = rootFolder + "src";
    clean(srcFolder); // TODO
}
 
Example #14
Source File: AbstractRealBugsEvaluation.java    From nopol with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void CL2() {
    NopolContext config = new NopolContext();
    config.setComplianceLevel(4);
    String projectName = "cl2";
    RepairType repairType = RepairType.CONDITIONAL;
    List<Patch> patches = setupAndRun(
            projectName,
repairType,
            new String[]{"org.apache.commons.lang.StringUtilsTest" },
            config,
            "junit-3.8.jar");

    assertEquals(patches.toString(), 1, patches.size());
    Patch patch = patches.get(0);
    assertEquals(patch.getType(), repairType);
    System.out.println(String.format("Patch for real bug %s: %s",
            projectName, patch.asString()));

    TestUtility.assertAgainstKnownPatches(patch,
            "(lastIdx)<(org.apache.commons.lang.StringUtils.blanks.length())",
            "lastIdx < org.apache.commons.lang.StringUtils.blanks.length()",
            "(lastIdx)<=(0)",
            "lastIdx <= 0",
            "(lastIdx)<(1)",
            "str.length() <= 1");

    String rootFolder = realBugPath + projectName + "/";
    String srcFolder = rootFolder + "src";
    clean(srcFolder); // TODO
}
 
Example #15
Source File: NopolProcessorBuilder.java    From nopol with GNU General Public License v2.0 5 votes vote down vote up
private void conditionalReplacer(CtStatement statement) {
    if (SpoonPredicate.canBeRepairedByChangingCondition(statement)) {
        if (nopolContext.getOracle() == NopolContext.NopolOracle.ANGELIC) {
            nopolProcessors.add(new ConditionalReplacer(statement));
        } else if (nopolContext.getOracle() == NopolContext.NopolOracle.SYMBOLIC) {
            nopolProcessors.add(new SymbolicConditionalReplacer(statement));
        }
    }
}
 
Example #16
Source File: Defects4jEvaluationMathTest.java    From nopol with GNU General Public License v2.0 5 votes vote down vote up
@Test(timeout = TEN_MINUTES_TIMEOUT)
public void test_Math49() throws Exception {
	// on Travis: 179sec
	if (!testShouldBeRun()) { return; }
	NopolContext nopolContext = nopolConfigFor("Math49");
	NopolResult result = new NoPol(nopolContext).build();
	assertEquals(1, result.getPatches().size());
}
 
Example #17
Source File: Defects4jEvaluationTest.java    From nopol with GNU General Public License v2.0 5 votes vote down vote up
@Test(timeout = FIVE_MINUTES_TIMEOUT)
public void test_Lang51() throws Exception {
	if (!testShouldBeRun()) { return; }
	NopolContext nopolContext = nopolConfigFor("Lang51");
	nopolContext.setComplianceLevel(4);
	NopolResult result = new NoPol(nopolContext).build();
	assertEquals(1, result.getPatches().size());
}
 
Example #18
Source File: CombinationFactory.java    From nopol with GNU General Public License v2.0 5 votes vote down vote up
public static CombinationExpression create(Operator operator, List<Expression> expressions, NopolContext nopolContext) {
    switch (expressions.size()) {
        case 1:
            return create((UnaryOperator) operator, expressions.get(0), nopolContext);
        case 2:
            return create((BinaryOperator) operator, expressions.get(0), expressions.get(1), nopolContext);
        default:
            throw new IllegalArgumentException("Combination expression with " + expressions.size() + " is not supported");
    }
}
 
Example #19
Source File: DataCombinerModified.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
public static CombinationExpression create(Operator operator, List<Expression> expressions,
		NopolContext nopolContext) {
	switch (expressions.size()) {
	case 1:
		return create((UnaryOperator) operator, expressions.get(0), nopolContext);
	case 2:
		return create((BinaryOperator) operator, expressions.get(0), expressions.get(1), nopolContext);
	default:
		throw new IllegalArgumentException(
				"Combination expression with " + expressions.size() + " is not supported");
	}
}
 
Example #20
Source File: Defects4jEvaluationMathTest.java    From nopol with GNU General Public License v2.0 5 votes vote down vote up
@Test(timeout = FIVE_MINUTES_TIMEOUT *2)
public void test_Math42() throws Exception {
	// on Travis: 215sec
	if (!testShouldBeRun()) { return; }
	NopolContext nopolContext = nopolConfigFor("Math42");
	NopolResult result = new NoPol(nopolContext).build();
	assertEquals(1, result.getPatches().size());
}
 
Example #21
Source File: TestSuiteExecutionTest.java    From nopol with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void runSuite() {
	Result result = TestSuiteExecution.runCasesIn(new String[]{ sampleTestClass() }, classLoaderWithTestClass(), new NopolContext());
	assertFalse(result.wasSuccessful());
	assertTrue(3 == result.getRunCount());
	assertTrue(1 == result.getFailureCount());
}
 
Example #22
Source File: DynamothSynthesizer.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
public DynamothSynthesizer(Map<String, List<Candidates>> values, NopolContext nopolContext,
		Map<String, Object[]> oracle) {
	super();
	this.values = values;
	this.nopolContext = nopolContext;
	this.oracle = oracle;
}
 
Example #23
Source File: AbstractRealBugsEvaluation.java    From nopol with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void PL1() {
    NopolContext config = new NopolContext();
    config.setComplianceLevel(4);
    String projectName = "pl1";
    RepairType repairType = RepairType.PRECONDITION;
    List<Patch> patches = setupAndRun(
            projectName,
repairType,
            new String[]{"org.apache.commons.lang.time.StopWatchTest"},
            config,
            "junit-3.8.jar");

    assertEquals(patches.toString(), 1, patches.size());
    Patch patch = patches.get(0);
    assertEquals(patch.getType(), repairType);
    System.out.println(String.format("Patch for real bug %s: %s",
            projectName, patch.asString()));

    TestUtility.assertAgainstKnownPatches(
            patch,
            "(org.apache.commons.lang.time.StopWatch.this.runningState)==(org.apache.commons.lang.time.StopWatch.STATE_RUNNING)",
            "org.apache.commons.lang.time.StopWatch.this.runningState == org.apache.commons.lang.time.StopWatch.STATE_RUNNING",
            "org.apache.commons.lang.time.StopWatch.STATE_RUNNING == org.apache.commons.lang.time.StopWatch.this.runningState",
            "(org.apache.commons.lang.time.StopWatch.STATE_RUNNING)==(org.apache.commons.lang.time.StopWatch.this.runningState)",
            "org.apache.commons.lang.time.StopWatch.this.stopTime == -1",
            "-1 == org.apache.commons.lang.time.StopWatch.this.stopTime",
            "this.stopTime <= 0");

    String rootFolder = realBugPath + projectName + "/";
    String srcFolder = rootFolder + "src";
    clean(srcFolder); // TODO
}
 
Example #24
Source File: AbstractRealBugsEvaluation.java    From nopol with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void CM5() {
    String projectName = "cm5";
    RepairType repairType = RepairType.CONDITIONAL;
    NopolContext config = new NopolContext();
    List<Patch> patches = setupAndRun(
            projectName,
repairType,
            new String[] {"org.apache.commons.math.util.MathUtilsTest"},
            config,
            "commons-beanutils-1.7.0.jar",
            "commons-collections-3.0.jar",
            "commons-discovery-0.4.jar",
            "commons-lang-2.1.jar",
            "commons-logging-1.1.1.jar",
            "junit-4.10.jar");

    assertEquals(patches.toString(), 1, patches.size());
    Patch patch = patches.get(0);
    assertEquals(patch.getType(), repairType);
    System.out.println(String.format("Patch for real bug %s: %s",
            projectName, patch.asString()));


    TestUtility.assertAgainstKnownPatches(patch, "((org.apache.commons.math.util.MathUtils.ZS)==(v))||((!((0)<(u)))&&((u * v) == 0))",
            "((u * v) == 0)&&((!((0)!=(u)))||((v)<(org.apache.commons.math.util.MathUtils.PS)))",
            "(0 == u) || (0 == v)",
            "(0 == v) || (!((u) != (org.apache.commons.math.util.MathUtils.ZB)))",
            "!(((org.apache.commons.math.util.MathUtils.EPSILON <= u) || (u < org.apache.commons.math.util.MathUtils.NB)) && ((v) != (org.apache.commons.math.util.MathUtils.ZB)))",
            "((!((org.apache.commons.math.util.MathUtils.ZB) != (v))) || (org.apache.commons.math.util.MathUtils.ZB == u)) && ((u * v) == 0)");

    String rootFolder = realBugPath + projectName + "/";
    String srcFolder = rootFolder + "src";
    clean(srcFolder); // TODO
}
 
Example #25
Source File: NopolTest.java    From nopol with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void testDynamoth() {
	NopolContext nopolContext = TestUtility.configForExample(executionType, 2);
	nopolContext.setType(RepairType.CONDITIONAL);
	nopolContext.setSynthesis(NopolContext.NopolSynthesis.DYNAMOTH);
	nopolContext.setOnlyOneSynthesisResult(false);
	NoPol nopol;

	// contract: Dynamoth stops after the default max values of patches
	nopol = new NoPol(nopolContext);
	assertEquals(10, nopol.build().getPatches().size());
}
 
Example #26
Source File: TestUtility.java    From nopol with GNU General Public License v2.0 5 votes vote down vote up
public static NopolContext configForExample(String executionType, int nopolExampleNumber) {
	String packageName = executionType + "_examples." + executionType + "_example_"
			+ nopolExampleNumber;
	String sourceFile = "../test-projects/src/main/java/"+packageName.replace('.','/');
	String classpath = "../test-projects/target/test-classes" + File.pathSeparatorChar + "../test-projects/target/classes" + File.pathSeparatorChar + "lib/junit-4.11.jar";
	String[] testClasses = new String[]{packageName + ".NopolExampleTest"};
	return new NopolContext(sourceFile, JavaLibrary.classpathFrom(classpath), testClasses);
}
 
Example #27
Source File: PatchGeneratorTest.java    From nopol with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void preconditionElseIfTest() {
	NopolContext nopolContext = new NopolContext(projectSourcePath, null, null);

	Launcher spoon = new Launcher();
	spoon.addInputResource(projectSourcePath);
	spoon.buildModel();

	Factory factory = spoon.getFactory();
	SourceLocation pathLocation = new SourceLocation("fr.inria.lille.diff.testclasses.Bar", 12);
	pathLocation.setSourceStart(125);
	pathLocation.setSourceEnd(140);

	ExpressionPatch patch = new ExpressionPatch(
			new LiteralImpl(ValueFactory.create(false), nopolContext),
			pathLocation,
			RepairType.PRECONDITION);
	PatchGenerator test = new PatchGenerator(
			patch,
			factory, nopolContext);

	Assert.assertEquals("--- a/"+projectSourcePath+"/Bar.java\n"
			+ "+++ b/"+projectSourcePath+"/Bar.java\n"
			+ "@@ -11,4 +11,8 @@\n"
			+ " \n"
			+ "-\t\t} else if (true) {\n"
			+ "-\n"
			+ "+\t\t} else {\n"
			+ "+\t\t\tif (false) {\n"
			+ "+\t\t\t\tif (true) {\n"
			+ "+\t\t\t\t\t\n"
			+ "+\t\t\t\t}\n"
			+ "+\t\t\t}\n"
			+ " \t\t}\n", test.getPatch());
}
 
Example #28
Source File: Infinitel.java    From nopol with GNU General Public License v2.0 5 votes vote down vote up
public static void run(File[] sourceFile, URL[] classpath) {
    Infinitel infiniteLoopFixer = new Infinitel(new NopolContext(sourceFile, classpath, null));
    try {
        infiniteLoopFixer.repair();
    } catch (Exception e) {
        e.printStackTrace();
        logError(infiniteLoopFixer.logger(), "Repair failed");
    }
}
 
Example #29
Source File: Main.java    From nopol with GNU General Public License v2.0 5 votes vote down vote up
private static NopolContext.NopolLocalizer strToLocalizer(String str) {
	if (str.equals("gzoltar")) {
		return NopolContext.NopolLocalizer.GZOLTAR;
	} else if (str.equals("dumb")) {
		return NopolContext.NopolLocalizer.DUMB;
	} else
		return NopolContext.NopolLocalizer.COCOSPOON;
}
 
Example #30
Source File: MethodImpl.java    From nopol with GNU General Public License v2.0 5 votes vote down vote up
public MethodImpl(String method, List<String> argumentTypes, String declaringType, Expression target, List<Expression> parameters, Value value, NopolContext nopolContext) {
    super(value, nopolContext);
    this.method = method;
    this.argumentTypes = argumentTypes;
    this.target = target;
    this.parameters = parameters;
    this.declaringType = declaringType;
}