-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#568] add example of toString extended strategy and tests for toStri…
…ng OK for each version
- Loading branch information
1 parent
5adc7ef
commit bc49bb6
Showing
43 changed files
with
631 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
basics/tests/po-0.11.0-runtime/src/main/java/internal/v0_11_0/EnumToStringStrategy.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package internal.v0_11_0; | ||
|
||
import org.jvnet.jaxb2_commons.lang.JAXBToStringStrategy; | ||
import org.jvnet.jaxb2_commons.locator.ObjectLocator; | ||
|
||
public class EnumToStringStrategy extends JAXBToStringStrategy { | ||
|
||
public boolean isUseIdentityHashCode() { | ||
return false; | ||
} | ||
|
||
public StringBuilder appendStart(ObjectLocator parentLocator, Object parent, StringBuilder stringBuilder) { | ||
if (parent instanceof Enum) { | ||
return stringBuilder; | ||
} else { | ||
return super.appendStart(parentLocator, parent, stringBuilder); | ||
} | ||
} | ||
|
||
public StringBuilder appendEnd(ObjectLocator parentLocator, Object parent, StringBuilder stringBuilder) { | ||
if (parent instanceof Enum) { | ||
return appendEnum((Enum) parent, stringBuilder); | ||
} else { | ||
return super.appendEnd(parentLocator, parent, stringBuilder); | ||
} | ||
} | ||
|
||
protected StringBuilder appendEnum(Enum e, StringBuilder stringBuilder) { | ||
stringBuilder.append(e.name()); | ||
return stringBuilder; | ||
} | ||
|
||
} |
File renamed without changes.
20 changes: 20 additions & 0 deletions
20
....0-runtime/src/test/java/org/jvnet/jaxb2_commons/tests/v0_11_0/EqualsPo_V0_11_0_Test.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package org.jvnet.jaxb2_commons.tests.v0_11_0; | ||
|
||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
public class EqualsPo_V0_11_0_Test { | ||
|
||
@Test | ||
public void testEqualsOld() { | ||
generated.v0_11_0.Items.Item item = new generated.v0_11_0.Items.Item(); | ||
item.setComment("a"); | ||
|
||
|
||
generated.v0_11_0.Items.Item anotherItem = new generated.v0_11_0.Items.Item(); | ||
anotherItem.setComment("a"); | ||
|
||
Assert.assertEquals("equals doesnt work with 0.11.0 runtime", item, anotherItem); | ||
} | ||
|
||
} |
18 changes: 18 additions & 0 deletions
18
...-runtime/src/test/java/org/jvnet/jaxb2_commons/tests/v0_11_0/ToStringPo_V0_11_0_Test.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package org.jvnet.jaxb2_commons.tests.v0_11_0; | ||
|
||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
public class ToStringPo_V0_11_0_Test { | ||
|
||
@Test | ||
public void testToString() { | ||
generated.v0_11_0.Items.Item item = new generated.v0_11_0.Items.Item(); | ||
item.setComment("a"); | ||
|
||
Assert.assertEquals("toString doesnt work with 0.11.0 runtime", | ||
"generated.v0_11_0.Items$Item[productName=<null>(default), quantity=0, usPrice=<null>(default), comment=a, shipDate=<null>(default), partNum=<null>(default)]", | ||
item.toString()); | ||
} | ||
|
||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
basics/tests/po-0.13.1-runtime/src/main/java/internal/v0_13_1/EnumToStringStrategy.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package internal.v0_13_1; | ||
|
||
import org.jvnet.jaxb2_commons.lang.JAXBToStringStrategy; | ||
import org.jvnet.jaxb2_commons.locator.ObjectLocator; | ||
|
||
public class EnumToStringStrategy extends JAXBToStringStrategy { | ||
|
||
public boolean isUseIdentityHashCode() { | ||
return false; | ||
} | ||
|
||
public StringBuilder appendStart(ObjectLocator parentLocator, Object parent, StringBuilder stringBuilder) { | ||
if (parent instanceof Enum) { | ||
return stringBuilder; | ||
} else { | ||
return super.appendStart(parentLocator, parent, stringBuilder); | ||
} | ||
} | ||
|
||
public StringBuilder appendEnd(ObjectLocator parentLocator, Object parent, StringBuilder stringBuilder) { | ||
if (parent instanceof Enum) { | ||
return appendEnum((Enum) parent, stringBuilder); | ||
} else { | ||
return super.appendEnd(parentLocator, parent, stringBuilder); | ||
} | ||
} | ||
|
||
protected StringBuilder appendEnum(Enum e, StringBuilder stringBuilder) { | ||
stringBuilder.append(e.name()); | ||
return stringBuilder; | ||
} | ||
|
||
} |
File renamed without changes.
8 changes: 4 additions & 4 deletions
8
...b2_commons/tests/old/EqualsPoOldTest.java → .../tests/v0_13_1/EqualsPo_V0_13_1_Test.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
...-runtime/src/test/java/org/jvnet/jaxb2_commons/tests/v0_13_1/ToStringPo_V0_13_1_Test.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package org.jvnet.jaxb2_commons.tests.v0_13_1; | ||
|
||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
public class ToStringPo_V0_13_1_Test { | ||
|
||
@Test | ||
public void testToString() { | ||
generated.v0_13_1.Items.Item item = new generated.v0_13_1.Items.Item(); | ||
item.setComment("a"); | ||
|
||
Assert.assertEquals("toString doesnt work with 0.13.1 runtime", | ||
"generated.v0_13_1.Items$Item[productName=<null>(default), quantity=0, usPrice=<null>(default), comment=a, shipDate=<null>(default), partNum=<null>(default)]", | ||
item.toString()); | ||
} | ||
|
||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
basics/tests/po-1.11.1-runtime/src/main/java/internal/v1_11_1/EnumToStringStrategy.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package internal.v1_11_1; | ||
|
||
import org.jvnet.jaxb2_commons.lang.JAXBToStringStrategy; | ||
import org.jvnet.jaxb2_commons.locator.ObjectLocator; | ||
|
||
public class EnumToStringStrategy extends JAXBToStringStrategy { | ||
|
||
public boolean isUseIdentityHashCode() { | ||
return false; | ||
} | ||
|
||
public StringBuilder appendStart(ObjectLocator parentLocator, Object parent, StringBuilder stringBuilder) { | ||
if (parent instanceof Enum) { | ||
return stringBuilder; | ||
} else { | ||
return super.appendStart(parentLocator, parent, stringBuilder); | ||
} | ||
} | ||
|
||
public StringBuilder appendEnd(ObjectLocator parentLocator, Object parent, StringBuilder stringBuilder) { | ||
if (parent instanceof Enum) { | ||
return appendEnum((Enum) parent, stringBuilder); | ||
} else { | ||
return super.appendEnd(parentLocator, parent, stringBuilder); | ||
} | ||
} | ||
|
||
protected StringBuilder appendEnum(Enum e, StringBuilder stringBuilder) { | ||
stringBuilder.append(e.name()); | ||
return stringBuilder; | ||
} | ||
|
||
} |
File renamed without changes.
8 changes: 4 additions & 4 deletions
8
...ests/fakeolder/EqualsPoFakeOlderTest.java → .../tests/v1_11_1/EqualsPo_V1_11_1_Test.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
...-runtime/src/test/java/org/jvnet/jaxb2_commons/tests/v1_11_1/ToStringPo_V1_11_1_Test.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package org.jvnet.jaxb2_commons.tests.v1_11_1; | ||
|
||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
public class ToStringPo_V1_11_1_Test { | ||
|
||
@Test | ||
public void testToString() { | ||
generated.v1_11_1.Items.Item item = new generated.v1_11_1.Items.Item(); | ||
item.setComment("a"); | ||
|
||
Assert.assertEquals("toString doesnt work with 1.11.1 runtime", | ||
"generated.v1_11_1.Items$Item[productName=<null>(default), quantity=0, usPrice=<null>(default), comment=a, shipDate=<null>(default), partNum=<null>(default)]", | ||
item.toString()); | ||
} | ||
|
||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>org.jvnet.jaxb</groupId> | ||
<artifactId>jaxb-basics-project</artifactId> | ||
<version>2.0.15-SNAPSHOT</version> | ||
<relativePath>../../pom.xml</relativePath> | ||
</parent> | ||
<artifactId>jaxb2-basics-test-po-2.0.14-runtime</artifactId> | ||
<packaging>jar</packaging> | ||
<name>JAXB Tools :: JAXB Basics :: Test [po-2.0.14-runtime]</name> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.glassfish.jaxb</groupId> | ||
<artifactId>jaxb-runtime</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.jvnet.jaxb</groupId> | ||
<artifactId>jaxb-maven-plugin-testing</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.jvnet.jaxb</groupId> | ||
<artifactId>jaxb2-basics-runtime</artifactId> | ||
<version>2.0.14</version> | ||
</dependency> | ||
</dependencies> | ||
<build> | ||
<defaultGoal>test</defaultGoal> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.jvnet.jaxb</groupId> | ||
<artifactId>jaxb-maven-plugin</artifactId> | ||
<configuration> | ||
<extension>true</extension> | ||
<generatePackage>generated.v2_0_14</generatePackage> | ||
<args> | ||
<arg>-Xequals</arg> | ||
<arg>-XhashCode</arg> | ||
<arg>-XtoString</arg> | ||
<arg>-XtoString-toStringStrategyClass=internal.v2_0_14.EnumToStringStrategy</arg> | ||
</args> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.jvnet.jaxb</groupId> | ||
<artifactId>jaxb2-basics</artifactId> | ||
<version>2.0.14</version> | ||
</plugin> | ||
</plugins> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
33 changes: 33 additions & 0 deletions
33
basics/tests/po-2.0.14-runtime/src/main/java/internal/v2_0_14/EnumToStringStrategy.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package internal.v2_0_14; | ||
|
||
import org.jvnet.jaxb2_commons.lang.JAXBToStringStrategy; | ||
import org.jvnet.jaxb2_commons.locator.ObjectLocator; | ||
|
||
public class EnumToStringStrategy extends JAXBToStringStrategy { | ||
|
||
public boolean isUseIdentityHashCode() { | ||
return false; | ||
} | ||
|
||
public StringBuilder appendStart(ObjectLocator parentLocator, Object parent, StringBuilder stringBuilder) { | ||
if (parent instanceof Enum) { | ||
return stringBuilder; | ||
} else { | ||
return super.appendStart(parentLocator, parent, stringBuilder); | ||
} | ||
} | ||
|
||
public StringBuilder appendEnd(ObjectLocator parentLocator, Object parent, StringBuilder stringBuilder) { | ||
if (parent instanceof Enum) { | ||
return appendEnum((Enum) parent, stringBuilder); | ||
} else { | ||
return super.appendEnd(parentLocator, parent, stringBuilder); | ||
} | ||
} | ||
|
||
protected StringBuilder appendEnum(Enum e, StringBuilder stringBuilder) { | ||
stringBuilder.append(e.name()); | ||
return stringBuilder; | ||
} | ||
|
||
} |
Oops, something went wrong.