diff options
author | Pascal Rapicault | 2008-10-20 17:55:36 +0000 |
---|---|---|
committer | Pascal Rapicault | 2008-10-20 17:55:36 +0000 |
commit | 036b9b7fbd0348a124e95944231254eb47ad5d45 (patch) | |
tree | 433c0d048d8fd44b3eb1a72434fa4a907a32d58d /bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/sat4j | |
parent | 75be906438857aad407563dd58e5186cae426043 (diff) | |
download | rt.equinox.p2-036b9b7fbd0348a124e95944231254eb47ad5d45.tar.gz rt.equinox.p2-036b9b7fbd0348a124e95944231254eb47ad5d45.tar.xz rt.equinox.p2-036b9b7fbd0348a124e95944231254eb47ad5d45.zip |
Bug 247567 - ArrayIndexOutOfBoundExecption in PatchTest3
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/sat4j')
3 files changed, 89 insertions, 45 deletions
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/sat4j/smoke/AllTests.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/sat4j/smoke/AllTests.java new file mode 100644 index 000000000..6ba29463c --- /dev/null +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/sat4j/smoke/AllTests.java @@ -0,0 +1,12 @@ +package org.eclipse.equinox.p2.tests.sat4j.smoke; + +import junit.framework.*; + +public class AllTests extends TestCase { + + public static Test suite() { + TestSuite suite = new TestSuite(AllTests.class.getName()); + suite.addTestSuite(SmokeTestSAT4J.class); + return suite; + } +} diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/sat4j/smoke/SmokeTestSAT4J.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/sat4j/smoke/SmokeTestSAT4J.java new file mode 100644 index 000000000..85661abee --- /dev/null +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/sat4j/smoke/SmokeTestSAT4J.java @@ -0,0 +1,77 @@ +package org.eclipse.equinox.p2.tests.sat4j.smoke; + +import java.io.*; +import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; +import org.sat4j.pb.IPBSolver; +import org.sat4j.pb.SolverFactory; +import org.sat4j.pb.reader.OPBEclipseReader2007; +import org.sat4j.reader.ParseFormatException; +import org.sat4j.specs.*; + +public class SmokeTestSAT4J extends AbstractProvisioningTest { + + private IProblem invokeSolver(File problemFile) throws FileNotFoundException, ParseFormatException, ContradictionException, TimeoutException { + IPBSolver solver = SolverFactory.newEclipseP2(); + solver.setTimeoutOnConflicts(1000); + OPBEclipseReader2007 reader = new OPBEclipseReader2007(solver); + // CNF filename is given on the command line + FileReader fr = null; + fr = new FileReader(problemFile); + IProblem problem = reader.parseInstance(fr); + if (problem.isSatisfiable()) + return problem; + return null; + } + + public void testBogusFile() { + File data = getTestData("Opb file 247638", "testData/sat4j/Bug247638.opb"); + Exception raised = null; + try { + invokeSolver(data); + } catch (FileNotFoundException e) { + //Ignore + } catch (ParseFormatException e) { + raised = e; + } catch (ContradictionException e) { + fail("Contradiction exception", e); + } catch (TimeoutException e) { + fail("Timeout exception", e); + } + assertNotNull(raised); + } + + public void testBug247567() { + File data = getTestData("Opb file 247567", "testData/sat4j/Bug247567.opb"); + Exception raised = null; + try { + IProblem pb = invokeSolver(data); + assertNotNull(pb); + for (int i = 1; i <= 6; i++) { + pb.model(i); + } + } catch (ArrayIndexOutOfBoundsException e) { + raised = e; + } catch (FileNotFoundException e) { + //Ignore + } catch (ParseFormatException e) { + raised = e; + } catch (ContradictionException e) { + fail("Contradiction exception", e); + } catch (TimeoutException e) { + fail("Timeout exception", e); + } + assertNull(raised); + + } + + // private void backToIU(IProblem problem) { + // solution = new ArrayList(); + // for (Iterator allIUs = variables.entrySet().iterator(); allIUs.hasNext();) { + // Entry entry = (Entry) allIUs.next(); + // int match = Integer.parseInt(((String) entry.getValue()).substring(1)); + // if (problem.model(match)) { + // solution.add(((IInstallableUnit) entry.getKey()).unresolved()); + // } + // } + // } +} diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/sat4j/smoke/Snippet.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/sat4j/smoke/Snippet.java deleted file mode 100644 index 37e0554a5..000000000 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/sat4j/smoke/Snippet.java +++ /dev/null @@ -1,45 +0,0 @@ -package org.eclipse.equinox.p2.tests.sat4j.smoke; - -import java.io.*; -import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; -import org.sat4j.pb.IPBSolver; -import org.sat4j.pb.SolverFactory; -import org.sat4j.pb.reader.OPBEclipseReader2007; -import org.sat4j.reader.ParseFormatException; -import org.sat4j.specs.*; - -public class Snippet extends AbstractProvisioningTest { - - private void invokeSolver(File problemFile) throws FileNotFoundException, ParseFormatException, ContradictionException, TimeoutException { - - IPBSolver solver = SolverFactory.newEclipseP2(); - solver.setTimeoutOnConflicts(1000); - OPBEclipseReader2007 reader = new OPBEclipseReader2007(solver); - // CNF filename is given on the command line - FileReader fr = null; - fr = new FileReader(problemFile); - IProblem problem = reader.parseInstance(fr); - if (problem.isSatisfiable()) { - System.out.println(reader.decode(problem.model())); - } else { - System.out.println("Unsatisfiable !"); //$NON-NLS-1$ - } - } - - public void testBogusFile() { - File data = getTestData("Opb file 247638", "testData/sat4j/Bug247638.opb"); - Exception raised = null; - try { - invokeSolver(data); - } catch (FileNotFoundException e) { - //Ignore - } catch (ParseFormatException e) { - raised = e; - } catch (ContradictionException e) { - fail("Contradiction exception", e); - } catch (TimeoutException e) { - fail("Timeout exception", e); - } - assertNotNull(raised); - } -} |