From 6e814e99c13f430583a21740d6ba8d4701cbe159 Mon Sep 17 00:00:00 2001 From: Jean Michel-Lemieux Date: Wed, 27 Feb 2002 16:37:14 +0000 Subject: Added conflicting tests --- .../team/tests/ccvs/core/compatible/ConflictTest.java | 16 +++++++++------- .../team/tests/ccvs/core/compatible/SameResultEnv.java | 15 ++++++++++++--- 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/compatible/ConflictTest.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/compatible/ConflictTest.java index 326af5b29..e45529e3a 100644 --- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/compatible/ConflictTest.java +++ b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/compatible/ConflictTest.java @@ -6,6 +6,7 @@ package org.eclipse.team.tests.ccvs.core.compatible; import junit.framework.Test; import junit.framework.TestSuite; import org.eclipse.team.internal.ccvs.core.CVSException; +import org.eclipse.team.internal.ccvs.core.connection.CVSServerException; import org.eclipse.team.tests.ccvs.core.JUnitTestCase; public class ConflictTest extends JUnitTestCase { @@ -23,10 +24,6 @@ public class ConflictTest extends JUnitTestCase { env2 = new SameResultEnv(arg, getFile("checkout2")); } - public static void main(String[] args) { - run(ConflictTest.class); - } - public void setUp() throws Exception { env1.setUp(); env2.setUp(); @@ -43,6 +40,7 @@ public class ConflictTest extends JUnitTestCase { public static Test suite() { TestSuite suite = new TestSuite(ConflictTest.class); + //return new CompatibleTestSetup(new ConflictTest("testSimpleConflict")); return new CompatibleTestSetup(suite); } @@ -62,11 +60,15 @@ public class ConflictTest extends JUnitTestCase { // and submit the merge env2.execute("update",EMPTY_ARGS,new String[]{"proj2"},""); + // commit must fail because we have a merged conflict which has not been + // edited. + env2.setIgnoreExceptions(true); + env2.execute("ci",new String[]{"-m","TestMessage"},new String[]{"proj2"},""); + env2.setIgnoreExceptions(false); + // Make a change to the file in order to let the cvs-client know // that we solved the confilict env2.appendToFile("proj2/f1/c.txt","That's allright"); - env2.execute("ci",new String[]{"-m","TestMessage"},new String[]{"proj2"},""); } -} - +} \ No newline at end of file diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/compatible/SameResultEnv.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/compatible/SameResultEnv.java index 25f6d6273..e5df2863b 100644 --- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/compatible/SameResultEnv.java +++ b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/compatible/SameResultEnv.java @@ -48,6 +48,7 @@ public final class SameResultEnv extends JUnitTestCase { private File referenceClientRoot; private File eclipseClientRoot; private boolean ignoreExceptions=false; + private boolean expectExceptions=false; private CVSRepositoryLocation referenceClientRepository; private CVSRepositoryLocation eclipseClientRepository; @@ -202,6 +203,9 @@ public final class SameResultEnv extends JUnitTestCase { assertNotNull(globalOptions1); assertNotNull(globalOptions); + boolean referenceClientException = false; + boolean eclipseClientException = false; + localOptions = notNull(localOptions); arguments = notNull(arguments); if (rootExtention == null || rootExtention.equals(".")) { @@ -217,6 +221,7 @@ public final class SameResultEnv extends JUnitTestCase { new NullProgressMonitor(), new PrintStream(new NullOutputStream())); } catch (ReferenceException e) { + referenceClientException = true; if (!ignoreExceptions) { throw e; } @@ -231,10 +236,14 @@ public final class SameResultEnv extends JUnitTestCase { new NullProgressMonitor(), new PrintStream(new NullOutputStream())); } catch (CVSServerException e) { + eclipseClientException = true; if (!ignoreExceptions) { throw e; } } + if(ignoreExceptions) { + assertEquals(referenceClientException == true, eclipseClientException == true); + } assertConsistent(); } @@ -353,7 +362,7 @@ public final class SameResultEnv extends JUnitTestCase { File file2 = new File(eclipseClientRoot,relativeFileName); // Wait a second so that the timestamp will change for sure - //waitMsec(1100); + waitMsec(2000); appendToFile(file1,txt); appendToFile(file2,txt); @@ -458,8 +467,8 @@ public final class SameResultEnv extends JUnitTestCase { private static void assertTimestampEquals(String timestamp1, String timestamp2) { try { EntryFileDateFormat timestampFormat = new EntryFileDateFormat(); - boolean merge1 = timestamp1.indexOf(ResourceSyncInfo.RESULT_OF_MERGE) != -1; - boolean merge2 = timestamp2.indexOf(ResourceSyncInfo.RESULT_OF_MERGE) != -1; + boolean merge1 = timestamp1.indexOf(ResourceSyncInfo.RESULT_OF_MERGE_CONFLICT) != -1; + boolean merge2 = timestamp2.indexOf(ResourceSyncInfo.RESULT_OF_MERGE_CONFLICT) != -1; boolean dummy1 = timestamp1.indexOf(ResourceSyncInfo.DUMMY_TIMESTAMP) != -1; boolean dummy2 = timestamp2.indexOf(ResourceSyncInfo.DUMMY_TIMESTAMP) != -1; assertEquals("both timestamps should show same conflict state", merge1, merge2); -- cgit v1.2.3