Java Code Examples for fr.inria.lille.repair.common.config.NopolContext#setComplianceLevel()
The following examples show how to use
fr.inria.lille.repair.common.config.NopolContext#setComplianceLevel() .
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 |
@Test public void PL2() { NopolContext config = new NopolContext(); config.setComplianceLevel(4); String projectName = "pl2"; RepairType repairType = RepairType.PRECONDITION; List<Patch> patches = setupAndRun( projectName, repairType, new String[]{"org.apache.commons.lang.StringEscapeUtilsTest"}, 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, "escapeForwardSlash", "escapeSingleQuote"); 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 |
@Test @Ignore public void PL3() { NopolContext config = new NopolContext(); config.setComplianceLevel(4); String projectName = "pl3"; RepairType repairType = RepairType.PRECONDITION; List<Patch> patches = setupAndRun( projectName, repairType, new String[]{"org.apache.commons.lang.WordUtilsTest"}, 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, "lower > str.length()", "((java.lang.String)str).length() <= lower", "str.length() <= lower"); String rootFolder = realBugPath + projectName + "/"; String srcFolder = rootFolder + "src"; clean(srcFolder); // TODO }
Example 3
Source File: NopolMojo.java From repairnator with MIT License | 5 votes |
private NopolContext createNopolContext(List<String> failingTestCases, List<URL> dependencies, List<File> sourceFolders) { NopolContext nopolContext = new NopolContext(sourceFolders.toArray(new File[0]), dependencies.toArray(new URL[0]), failingTestCases.toArray(new String[0]), Collections.<String>emptyList()); nopolContext.setComplianceLevel(getComplianceLevel()); nopolContext.setTimeoutTestExecution(300); nopolContext.setMaxTimeEachTypeOfFixInMinutes(15); nopolContext.setMaxTimeInMinutes(maxTime); nopolContext.setLocalizer(this.resolveLocalizer()); nopolContext.setSynthesis(this.resolveSynthesis()); nopolContext.setType(this.resolveType()); nopolContext.setOnlyOneSynthesisResult(true); nopolContext.setJson(true); if (!outputDirectory.exists()) { outputDirectory.mkdirs(); } nopolContext.setOutputFolder(outputDirectory.getAbsolutePath()); NopolContext.NopolSolver solver = this.resolveSolver(); nopolContext.setSolver(solver); if (nopolContext.getSynthesis() == NopolContext.NopolSynthesis.SMT) { if (solver == NopolContext.NopolSolver.Z3) { String z3Path = this.loadZ3AndGivePath(); SolverFactory.setSolver(solver, z3Path); nopolContext.setSolverPath(z3Path); } else { SolverFactory.setSolver(solver, null); } } return nopolContext; }
Example 4
Source File: InternalNopolActor.java From nopol with GNU General Public License v2.0 | 5 votes |
@Override public void onReceive(Object message) throws Exception { if (message instanceof ConfigActor) { ConfigActor configActor = (ConfigActor) message; NopolContext nopolContext = configActor.getNopolContext(); File tempDirectory = Files.createTempDir(); UnZiper.unZipIt(configActor.getContent(), tempDirectory.getAbsolutePath()); ActorRef client = configActor.getClient(); if (nopolContext.getSynthesis() == NopolContext.NopolSynthesis.SMT) { nopolContext.setSolverPath(pathToSolver); } String sourceFile = tempDirectory.toString() + "/src/"; String classPath = getClasspathFromTargetFolder(new File(tempDirectory.getCanonicalPath() + "/target/")); System.out.println(tempDirectory); List<Patch> patches = Collections.EMPTY_LIST; nopolContext.setProjectSources(sourceFile); nopolContext.setProjectClasspath(JavaLibrary.classpathFrom(classPath)); nopolContext.setComplianceLevel(8); try { NoPol noPol = new NoPol(nopolContext); NopolResult status = noPol.build(); patches = status.getPatches(); } catch (Exception e) { throw new RuntimeException("Error launch NoPol", e); } finally { getSender().tell(NoPolActor.Message.AVAILABLE, getSelf()); } client.tell(patches, ActorRef.noSender()); } else unhandled(message);//Unsupported message type }
Example 5
Source File: Defects4jEvaluationTest.java From nopol with GNU General Public License v2.0 | 5 votes |
@Test(timeout = FIVE_MINUTES_TIMEOUT) public void test_Lang44() throws Exception { if (!testShouldBeRun()) { return; } NopolContext nopolContext = nopolConfigFor("Lang44"); nopolContext.setComplianceLevel(4); NopolResult result = new NoPol(nopolContext).build(); assertEquals(1, result.getPatches().size()); }
Example 6
Source File: Defects4jEvaluationTest.java From nopol with GNU General Public License v2.0 | 5 votes |
@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 7
Source File: Defects4jEvaluationTest.java From nopol with GNU General Public License v2.0 | 5 votes |
@Test(timeout = FIVE_MINUTES_TIMEOUT) public void test_Lang53() throws Exception { if (!testShouldBeRun()) { return; } NopolContext nopolContext = nopolConfigFor("Lang53"); nopolContext.setComplianceLevel(4); NopolResult result = new NoPol(nopolContext).build(); assertEquals(1, result.getPatches().size()); }
Example 8
Source File: Defects4jEvaluationTest.java From nopol with GNU General Public License v2.0 | 5 votes |
@Test(timeout = FIVE_MINUTES_TIMEOUT) public void test_Lang58() throws Exception { if (!testShouldBeRun()) { return; } // many resources on the internet say it's "maven.compiler.source", but it's actually maven.compile.source" NopolContext nopolContext = nopolConfigFor("Lang58", "-Dproject.build.sourceEncoding=ISO-8859-1 -Dmaven.compile.source=1.4 -Dmaven.compile.testSource=1.4"); nopolContext.setComplianceLevel(4); NopolResult result = new NoPol(nopolContext).build(); assertEquals(1, result.getPatches().size()); }
Example 9
Source File: AbstractRealBugsEvaluation.java From nopol with GNU General Public License v2.0 | 5 votes |
@Test public void CM6() { NopolContext config = new NopolContext(); config.setComplianceLevel(5); String projectName = "cm6"; RepairType repairType = RepairType.PRECONDITION; List<Patch> patches = setupAndRun( projectName, repairType, new String[] {}, 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, "(ns)!=(n)", "(0)<=(fa)", "upperBound == 0.0", "-1 == b"); String rootFolder = realBugPath + projectName + "/"; String srcFolder = rootFolder + "src"; clean(srcFolder); // TODO }
Example 10
Source File: AbstractRealBugsEvaluation.java From nopol with GNU General Public License v2.0 | 5 votes |
@Test public void CL1() { NopolContext config = new NopolContext(); config.setComplianceLevel(4); String projectName = "cl1"; RepairType repairType = RepairType.CONDITIONAL; config.setSolver(NopolContext.NopolSolver.Z3); config.setSolverPath("lib/z3/z3_for_linux"); 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, "(text.length())==(3)", "(text.length())==(with.length())", "(null == with) || (0 != ((java.lang.String)with).length())", "(with.length()) != (0)"); String rootFolder = realBugPath + projectName + "/"; String srcFolder = rootFolder + "src"; clean(srcFolder); // TODO }
Example 11
Source File: AbstractRealBugsEvaluation.java From nopol with GNU General Public License v2.0 | 5 votes |
@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 12
Source File: AbstractRealBugsEvaluation.java From nopol with GNU General Public License v2.0 | 5 votes |
@Test public void CL3() { NopolContext config = new NopolContext(); config.setComplianceLevel(4); String projectName = "cl3"; RepairType repairType = RepairType.CONDITIONAL; List<Patch> patches = setupAndRun( projectName, repairType, new String[]{"org.apache.commons.lang.StringUtilsSubstringTest" }, 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, "(!(0 <= len)) || (str.length() < pos)", "((len)<=(-1))||((str.length())<(pos))", "(len < 0) || (((java.lang.String)str).length() < pos)", "(((java.lang.String)str).length() < pos) || (len < 0)", "(len <= -1) || (str.length() < pos)"); String rootFolder = realBugPath + projectName + "/"; String srcFolder = rootFolder + "src"; clean(srcFolder); // TODO }
Example 13
Source File: AbstractRealBugsEvaluation.java From nopol with GNU General Public License v2.0 | 5 votes |
@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 |
@Test public void CL5() { NopolContext config = new NopolContext(); config.setComplianceLevel(6); String projectName = "cl5"; RepairType repairType = RepairType.CONDITIONAL; List<Patch> patches = setupAndRun( projectName, repairType, new String[]{}, 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, "className.length()==0", "0 == ((java.lang.String)className).length()"); String rootFolder = realBugPath + projectName + "/"; String srcFolder = rootFolder + "src"; clean(srcFolder); // TODO }
Example 15
Source File: AbstractRealBugsEvaluation.java From nopol with GNU General Public License v2.0 | 5 votes |
@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 16
Source File: TseEvaluationTest.java From nopol with GNU General Public License v2.0 | 4 votes |
public void testTSEBug(String bug_id) throws Exception { String folder = "unknown"; if (bug_id.startsWith("cm") || bug_id.startsWith("pm")) { folder = "math"; } if (bug_id.startsWith("cl") || bug_id.startsWith("pl")) { folder = "lang"; } JSONTokener tokener = new JSONTokener(new File("../nopol-experiments/data/projects/"+folder+"/bugs/" + bug_id + ".json").toURL().openStream()); JSONObject root = new JSONObject(tokener); //JSONArray s = NopolContext nopolContext = new NopolContext(); String src = "../nopol-experiments/dataset/" + bug_id + "/" + root.getJSONObject("path").getString("source"); nopolContext.setProjectSourcePath(new File[]{new File(src)}); // setting the Java version of the project to repair, required for TSE_CL1 for instance if (root.has("java")) { nopolContext.setComplianceLevel(Integer.parseInt(root.getJSONObject("java").getString("version").substring(2))); } URL[] cp = new URL[root.getJSONArray("dependencies").length()+2]; cp[0] = new File("../nopol-experiments/dataset/"+bug_id+"/"+"target/classes/").toURL(); cp[1] = new File("../nopol-experiments/dataset/"+bug_id+"/"+"target/test-classes/").toURL(); for (int i = 0; i <root.getJSONArray("dependencies").length(); i++) { cp[i+2] = new File("../nopol-experiments/data/lib/"+root.getJSONArray("dependencies").getString(i)).toURL(); } if (root.has("tests")) { String[] tests = new String[root.getJSONArray("tests").length()]; for (int i = 0; i <root.getJSONArray("tests").length(); i++) { tests[i] = root.getJSONArray("tests").getString(i); } ; nopolContext.setProjectTests(tests); } nopolContext.setProjectClasspath(cp); //nopolContext.setLocalizer(NopolContext.NopolLocalizer.COCOSPOON); nopolContext.setType(RepairType.PRECONDITION); if ("condition".equals(root.getString("type"))) { nopolContext.setType(RepairType.CONDITIONAL); } SolverFactory.setSolver("z3", TestUtility.solverPath); NoPol nopol = new NoPol(nopolContext); NopolResult result = nopol.build(); assertEquals(1, result.getPatches().size()); }