diff --git a/.classpath b/.classpath index f648ca63c5ff..e6b57972a1c3 100644 --- a/.classpath +++ b/.classpath @@ -1,10 +1,39 @@ <?xml version="1.0" encoding="UTF-8"?> <classpath> - <classpathentry kind="src" path="src/main/java"/> - <classpathentry kind="src" path="src/test/java"/> - <classpathentry kind="src" path="src/test/resources"/> - <classpathentry kind="src" path="src/main/resources"/> - <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/> + <classpathentry kind="src" output="target/classes" path="src/main/java"> + <attributes> + <attribute name="optional" value="true"/> + <attribute name="maven.pomderived" value="true"/> + </attributes> + </classpathentry> + <classpathentry kind="src" output="target/test-classes" path="src/test/java"> + <attributes> + <attribute name="optional" value="true"/> + <attribute name="maven.pomderived" value="true"/> + <attribute name="test" value="true"/> + </attributes> + </classpathentry> + <classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources"> + <attributes> + <attribute name="maven.pomderived" value="true"/> + <attribute name="test" value="true"/> + </attributes> + </classpathentry> + <classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"> + <attributes> + <attribute name="maven.pomderived" value="true"/> + </attributes> + </classpathentry> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"> + <attributes> + <attribute name="maven.pomderived" value="true"/> + </attributes> + </classpathentry> <classpathentry exported="true" kind="lib" path="lib/hamcrest-core-1.3.jar" sourcepath="lib/hamcrest-core-1.3-sources.jar"/> - <classpathentry kind="output" path="bin"/> + <classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"> + <attributes> + <attribute name="maven.pomderived" value="true"/> + </attributes> + </classpathentry> + <classpathentry kind="output" path="target/classes"/> </classpath> diff --git a/.project b/.project index 88756880f282..df67bf0ce28d 100644 --- a/.project +++ b/.project @@ -10,8 +10,14 @@ <arguments> </arguments> </buildCommand> + <buildCommand> + <name>org.eclipse.m2e.core.maven2Builder</name> + <arguments> + </arguments> + </buildCommand> </buildSpec> <natures> + <nature>org.eclipse.m2e.core.maven2Nature</nature> <nature>org.eclipse.jdt.core.javanature</nature> <nature>org.eclipse.team.cvs.core.cvsnature</nature> </natures> diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs index d54f4c25de99..50326049484c 100644 --- a/.settings/org.eclipse.jdt.core.prefs +++ b/.settings/org.eclipse.jdt.core.prefs @@ -1,4 +1,3 @@ -#Mon Oct 12 21:57:10 EDT 2009 eclipse.preferences.version=1 org.eclipse.jdt.core.codeComplete.argumentPrefixes= org.eclipse.jdt.core.codeComplete.argumentSuffixes= @@ -9,9 +8,9 @@ org.eclipse.jdt.core.codeComplete.localSuffixes= org.eclipse.jdt.core.codeComplete.staticFieldPrefixes= org.eclipse.jdt.core.codeComplete.staticFieldSuffixes= org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.5 +org.eclipse.jdt.core.compiler.compliance=1.6 org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate @@ -92,7 +91,8 @@ org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disa org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning -org.eclipse.jdt.core.compiler.source=1.5 +org.eclipse.jdt.core.compiler.release=disabled +org.eclipse.jdt.core.compiler.source=1.6 org.eclipse.jdt.core.compiler.taskCaseSensitive=enabled org.eclipse.jdt.core.compiler.taskPriorities=NORMAL,NORMAL,HIGH,NORMAL org.eclipse.jdt.core.compiler.taskTags=TODO,REVISIT,HACK,QUESTION diff --git a/src/main/java/org/junit/Assert.java b/src/main/java/org/junit/Assert.java index a3d7905e6d24..17e7b2247fe6 100644 --- a/src/main/java/org/junit/Assert.java +++ b/src/main/java/org/junit/Assert.java @@ -29,6 +29,38 @@ public class Assert { protected Assert() { } + // fixes issue #1432 + /** + * Asserts that charSequence has the same string of chars. If the sequence is not the same, throws a + * {@link AssertionError} with the given message. + * + * @param message the identifying message for the {@link AssertionError} (<code>null</code> + * okay) + * @param expected the sequence to check against + * @param actual the sequence that is being checked + */ + public static void assertContentsEqual(String message, CharSequence expected, + CharSequence actual) { + if (expected.length() != actual.length()) { + failNotEquals(message, expected, actual); + } + for (int i = 0; i < expected.length(); i++) { + if (expected.charAt(i) != actual.charAt(i)) + failNotEquals(message, expected, actual); + } + } + + /** + * Asserts that charSequence has the same string of chars. If the sequence is not the same, throws a + * {@link AssertionError} with the given message. + * + * @param expected the sequence to check against + * @param actual the sequence that is being checked + */ + public static void assertContentsEqual(CharSequence expected, CharSequence actual) { + assertContentsEqual(null, expected, actual); + } + /** * Asserts that a condition is true. If it isn't it throws an * {@link AssertionError} with the given message. diff --git a/src/test/java/org/junit/tests/assertion/AssertionTest.java b/src/test/java/org/junit/tests/assertion/AssertionTest.java index d0c3bdfddc59..8ac4e94fde04 100644 --- a/src/test/java/org/junit/tests/assertion/AssertionTest.java +++ b/src/test/java/org/junit/tests/assertion/AssertionTest.java @@ -36,6 +36,21 @@ public class AssertionTest { private static final String ASSERTION_ERROR_EXPECTED = "AssertionError expected"; + @Test(expected = AssertionError.class) + public void stringContentEqual() { + Assert.assertContentsEqual("String", "String2"); + } + + @Test(expected = AssertionError.class) + public void stringbuilderContentEqual() { + Assert.assertContentsEqual(new StringBuilder("String"), new StringBuilder("String2")); + } + + @Test + public void stringbufferContentEqual() { + Assert.assertContentsEqual(new StringBuffer("String"), new StringBuffer("String")); + } + @Test(expected = AssertionError.class) public void fails() { Assert.fail();