diff --git a/runtime/src/test/java/org/jvnet/jaxb2_commons/lang/tests/CyclicTests.java b/runtime/src/test/java/org/jvnet/jaxb2_commons/lang/tests/CyclicTests.java index d932fedd..c43bedcc 100644 --- a/runtime/src/test/java/org/jvnet/jaxb2_commons/lang/tests/CyclicTests.java +++ b/runtime/src/test/java/org/jvnet/jaxb2_commons/lang/tests/CyclicTests.java @@ -5,8 +5,8 @@ import junit.framework.TestCase; -import org.jvnet.jaxb2_commons.lang.CopyStrategy; -import org.jvnet.jaxb2_commons.lang.CopyTo; +import org.jvnet.jaxb2_commons.lang.CopyStrategy2; +import org.jvnet.jaxb2_commons.lang.CopyTo2; import org.jvnet.jaxb2_commons.lang.JAXBCopyStrategy; import org.jvnet.jaxb2_commons.locator.DefaultRootObjectLocator; import org.jvnet.jaxb2_commons.locator.ObjectLocator; @@ -14,7 +14,7 @@ public class CyclicTests extends TestCase { - public interface CopyToInstance extends CopyTo { + public interface CopyToInstance extends CopyTo2 { } public static class A implements CopyToInstance { @@ -29,10 +29,11 @@ public Object copyTo(Object target) { } public Object copyTo(ObjectLocator locator, Object target, - CopyStrategy copyStrategy) { + CopyStrategy2 copyStrategy) { final A that = (A) target; - that.b = (B) copyStrategy.copy(LocatorUtils.property(locator, "b", - this.b), this.b); + that.b = (B) copyStrategy.copy( + LocatorUtils.property(locator, "b", this.b), this.b, + this.b != null); return that; } @@ -50,10 +51,11 @@ public Object copyTo(Object target) { } public Object copyTo(ObjectLocator locator, Object target, - CopyStrategy copyStrategy) { + CopyStrategy2 copyStrategy) { final B that = (B) target; - that.a = (A) copyStrategy.copy(LocatorUtils.property(locator, "a", - this.a), this.a); + that.a = (A) copyStrategy.copy( + LocatorUtils.property(locator, "a", this.a), this.a, + this.a != null); return that; } } @@ -68,7 +70,8 @@ public void testCycle() throws Exception { private Map copies = new IdentityHashMap(); @Override - public Object copy(ObjectLocator locator, Object object) { + public Object copy(ObjectLocator locator, Object object, + boolean objectSet) { final Object existingCopy = copies.get(object); if (existingCopy != null) { return existingCopy; @@ -80,7 +83,7 @@ public Object copy(ObjectLocator locator, Object object) { source.copyTo(locator, newCopy, this); return newCopy; } else { - final Object newCopy = super.copy(locator, object); + final Object newCopy = super.copy(locator, object, objectSet); copies.put(object, newCopy); return newCopy; } diff --git a/testing/src/main/java/org/jvnet/jaxb2_commons/test/AbstractSamplesTest.java b/testing/src/main/java/org/jvnet/jaxb2_commons/test/AbstractSamplesTest.java index b4de9a52..f8e6890c 100644 --- a/testing/src/main/java/org/jvnet/jaxb2_commons/test/AbstractSamplesTest.java +++ b/testing/src/main/java/org/jvnet/jaxb2_commons/test/AbstractSamplesTest.java @@ -7,7 +7,7 @@ import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBException; -import junit.framework.Assert; +import org.junit.Assert; import junit.framework.TestCase; import org.apache.commons.io.FileUtils; diff --git a/tests/issues/src/test/java/org/jvnet/jaxb2_commons/tests/issues/GH37Test.java b/tests/issues/src/test/java/org/jvnet/jaxb2_commons/tests/issues/GH37Test.java index df364121..4248ed34 100644 --- a/tests/issues/src/test/java/org/jvnet/jaxb2_commons/tests/issues/GH37Test.java +++ b/tests/issues/src/test/java/org/jvnet/jaxb2_commons/tests/issues/GH37Test.java @@ -2,11 +2,13 @@ import org.junit.Assert; import org.junit.Test; +import org.jvnet.jaxb2_commons.lang.JAXBToStringStrategy; +import org.jvnet.jaxb2_commons.lang.ToStringStrategy2; public class GH37Test { @Test - public void considersDefaultValues() { + public void considersDefaultValuesInMerge() { final IssueGH37Type left = new IssueGH37Type(); final IssueGH37Type right = new IssueGH37Type(); final IssueGH37Type result = new IssueGH37Type(); @@ -14,4 +16,32 @@ public void considersDefaultValues() { Assert.assertTrue(result.isTestBoolean()); } + @Test + public void considersDefaultValuesInCopyTo() { + final IssueGH37Type original = new IssueGH37Type(); + final IssueGH37Type copy = (IssueGH37Type) original.clone(); + Assert.assertTrue(copy.isTestBoolean()); + Assert.assertFalse(copy.isSetTestBoolean()); + Assert.assertEquals(original, copy); + } + + @Test + public void considersDefaultValuesInToString() { + final ToStringStrategy2 strategy = new JAXBToStringStrategy() { + @Override + public boolean isUseIdentityHashCode() { + return false; + } + }; + IssueGH37Type a = new IssueGH37Type(); + Assert.assertEquals( + "org.jvnet.jaxb2_commons.tests.issues.IssueGH37Type[testBoolean=true(default)]", + a.append(null, new StringBuilder(), strategy).toString()); + IssueGH37Type b = new IssueGH37Type(); + b.setTestBoolean(true); + Assert.assertEquals( + "org.jvnet.jaxb2_commons.tests.issues.IssueGH37Type[testBoolean=true]", + b.append(null, new StringBuilder(), strategy).toString()); + } + } diff --git a/tests/issues/src/test/java/org/jvnet/jaxb2_commons/tests/issues/JIIB10Test.java b/tests/issues/src/test/java/org/jvnet/jaxb2_commons/tests/issues/JIIB10Test.java index 9b8e1d85..c1640275 100644 --- a/tests/issues/src/test/java/org/jvnet/jaxb2_commons/tests/issues/JIIB10Test.java +++ b/tests/issues/src/test/java/org/jvnet/jaxb2_commons/tests/issues/JIIB10Test.java @@ -4,9 +4,10 @@ import javax.xml.bind.annotation.XmlAnyElement; -import junit.framework.Assert; import junit.framework.TestCase; +import org.junit.Assert; + public class JIIB10Test extends TestCase { public void testXmlAnyElementLax() throws Exception { diff --git a/tests/issues/src/test/java/org/jvnet/jaxb2_commons/tests/issues/JIIB14Test.java b/tests/issues/src/test/java/org/jvnet/jaxb2_commons/tests/issues/JIIB14Test.java index 5b5249d2..6e82c4b0 100644 --- a/tests/issues/src/test/java/org/jvnet/jaxb2_commons/tests/issues/JIIB14Test.java +++ b/tests/issues/src/test/java/org/jvnet/jaxb2_commons/tests/issues/JIIB14Test.java @@ -1,8 +1,9 @@ package org.jvnet.jaxb2_commons.tests.issues; -import junit.framework.Assert; import junit.framework.TestCase; +import org.junit.Assert; + public class JIIB14Test extends TestCase { public void testIssueJIIB14() throws Exception { diff --git a/tests/issues/src/test/java/org/jvnet/jaxb2_commons/tests/issues/JIIB20Test.java b/tests/issues/src/test/java/org/jvnet/jaxb2_commons/tests/issues/JIIB20Test.java index 1c63d5d8..959241b7 100644 --- a/tests/issues/src/test/java/org/jvnet/jaxb2_commons/tests/issues/JIIB20Test.java +++ b/tests/issues/src/test/java/org/jvnet/jaxb2_commons/tests/issues/JIIB20Test.java @@ -3,9 +3,10 @@ import java.util.Arrays; import java.util.List; -import junit.framework.Assert; import junit.framework.TestCase; +import org.junit.Assert; + public class JIIB20Test extends TestCase { public void testException() throws Exception { diff --git a/tests/issues/src/test/java/org/jvnet/jaxb2_commons/tests/issues/JIIB35Test.java b/tests/issues/src/test/java/org/jvnet/jaxb2_commons/tests/issues/JIIB35Test.java index 0ea33da3..a9067978 100644 --- a/tests/issues/src/test/java/org/jvnet/jaxb2_commons/tests/issues/JIIB35Test.java +++ b/tests/issues/src/test/java/org/jvnet/jaxb2_commons/tests/issues/JIIB35Test.java @@ -2,7 +2,7 @@ import javax.xml.bind.JAXBContext; -import junit.framework.Assert; +import org.junit.Assert; import junit.framework.TestCase; import org.jvnet.jaxb2_commons.lang.ContextUtils; diff --git a/tests/issues/src/test/java/org/jvnet/jaxb2_commons/tests/issues/JIIB38Test.java b/tests/issues/src/test/java/org/jvnet/jaxb2_commons/tests/issues/JIIB38Test.java index f162a023..bbec7934 100644 --- a/tests/issues/src/test/java/org/jvnet/jaxb2_commons/tests/issues/JIIB38Test.java +++ b/tests/issues/src/test/java/org/jvnet/jaxb2_commons/tests/issues/JIIB38Test.java @@ -1,6 +1,6 @@ package org.jvnet.jaxb2_commons.tests.issues; -import junit.framework.Assert; +import org.junit.Assert; import junit.framework.TestCase; public class JIIB38Test extends TestCase { diff --git a/tests/issues/src/test/java/org/jvnet/jaxb2_commons/tests/issues/JIIB8Test.java b/tests/issues/src/test/java/org/jvnet/jaxb2_commons/tests/issues/JIIB8Test.java index 14b85427..c53703b5 100644 --- a/tests/issues/src/test/java/org/jvnet/jaxb2_commons/tests/issues/JIIB8Test.java +++ b/tests/issues/src/test/java/org/jvnet/jaxb2_commons/tests/issues/JIIB8Test.java @@ -2,7 +2,7 @@ import java.util.Arrays; -import junit.framework.Assert; +import org.junit.Assert; import junit.framework.TestCase; public class JIIB8Test extends TestCase { diff --git a/tests/superclass/b/pom.xml b/tests/superclass/b/pom.xml index 8196811e..c8545e81 100644 --- a/tests/superclass/b/pom.xml +++ b/tests/superclass/b/pom.xml @@ -47,13 +47,17 @@ org.jvnet.jaxb2_commons jaxb2-basics + + org.jvnet.jaxb2_commons + jaxb2-basics-test-superclass-a + - +