forked from highsource/jaxb-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[highsource#576] add extra project test for copyable
- Loading branch information
1 parent
5903cd4
commit 680c1d0
Showing
6 changed files
with
184 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<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-plugins-tests</artifactId> | ||
<version>4.0.9-SNAPSHOT</version> | ||
</parent> | ||
<artifactId>jaxb-plugins-test-copyable</artifactId> | ||
<packaging>jar</packaging> | ||
<name>JAXB Tools :: JAXB Plugins :: Test [copyable]</name> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.jvnet.jaxb</groupId> | ||
<artifactId>jaxb-maven-plugin-testing</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
<build> | ||
<defaultGoal>test</defaultGoal> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.jvnet.jaxb</groupId> | ||
<artifactId>jaxb-maven-plugin</artifactId> | ||
<configuration> | ||
<extension>true</extension> | ||
<args> | ||
<arg>-Xcopyable</arg> | ||
</args> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.jvnet.jaxb</groupId> | ||
<artifactId>jaxb-plugins</artifactId> | ||
</plugin> | ||
</plugins> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
41 changes: 41 additions & 0 deletions
41
jaxb-plugins-parent/tests/copyable/src/main/resources/Example.xsd
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,41 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"> | ||
<xs:element name="base"> | ||
<xs:complexType> | ||
<xs:sequence> | ||
<xs:element name="a" type="xs:string" minOccurs="0" /> | ||
<xs:element name="b" type="xs:date" minOccurs="0" /> | ||
<xs:element name="c" type="xs:dateTime" minOccurs="0" /> | ||
<xs:element name="d" type="xs:time" minOccurs="0" /> | ||
<xs:element name="e" type="xs:base64Binary" minOccurs="0" /> | ||
<xs:element name="listOfString" type="xs:string" minOccurs="0" maxOccurs="unbounded" /> | ||
</xs:sequence> | ||
</xs:complexType> | ||
</xs:element> | ||
|
||
<xs:complexType name="primitives"> | ||
<xs:sequence> | ||
<xs:element name="boolean" type="xs:boolean" /> | ||
<xs:element name="byte" type="xs:byte" /> | ||
<!--xs:element name="char" type="xs:char" /--> | ||
<xs:element name="double" type="xs:double" /> | ||
<xs:element name="float" type="xs:float" /> | ||
<xs:element name="long" type="xs:long" /> | ||
<xs:element name="int" type="xs:int" /> | ||
<xs:element name="short" type="xs:short" /> | ||
</xs:sequence> | ||
</xs:complexType> | ||
|
||
<xs:element name="unboxedPrimitives"> | ||
<xs:complexType> | ||
<xs:attribute name="unboxedBoolean" type="xs:boolean" use="optional" /> | ||
<xs:attribute name="unboxedByte" type="xs:byte" use="optional" /> | ||
<!--xs:attribute name="unboxedChar" type="xs:char" use="optional" /--> | ||
<xs:attribute name="unboxedDouble" type="xs:double" use="optional" /> | ||
<xs:attribute name="unboxedFloat" type="xs:float" use="optional" /> | ||
<xs:attribute name="unboxedLong" type="xs:long" use="optional" /> | ||
<xs:attribute name="unboxedInt" type="xs:int" use="optional" /> | ||
<xs:attribute name="unboxedShort" type="xs:short" use="optional" /> | ||
</xs:complexType> | ||
</xs:element> | ||
</xs:schema> |
41 changes: 41 additions & 0 deletions
41
...-plugins-parent/tests/copyable/src/test/java/org/jvnet/jaxb/tests/fluentapi/BaseTest.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,41 @@ | ||
package org.jvnet.jaxb.tests.fluentapi; | ||
|
||
import generated.Base; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import javax.xml.datatype.DatatypeConfigurationException; | ||
import javax.xml.datatype.DatatypeFactory; | ||
import javax.xml.datatype.XMLGregorianCalendar; | ||
import java.nio.charset.StandardCharsets; | ||
import java.util.Arrays; | ||
import java.util.GregorianCalendar; | ||
|
||
public class BaseTest { | ||
|
||
@Test | ||
public void testBase() throws DatatypeConfigurationException { | ||
XMLGregorianCalendar xgc = DatatypeFactory.newInstance().newXMLGregorianCalendar(new GregorianCalendar()); | ||
byte[] textBytes = "String".getBytes(StandardCharsets.UTF_8); | ||
Base a = new Base(); | ||
a.setA("String"); | ||
a.setB(xgc); | ||
a.setC(xgc); | ||
a.setD(xgc); | ||
a.setE(textBytes); | ||
a.getListOfString().addAll(Arrays.asList("a", "b", "c")); | ||
a.getListOfString().addAll(Arrays.asList("e", "f", "g")); | ||
|
||
Base b = new Base(); | ||
a.copyTo(b); | ||
|
||
Assertions.assertEquals("String", b.getA()); | ||
Assertions.assertEquals(xgc, b.getB()); | ||
Assertions.assertEquals(xgc, b.getC()); | ||
Assertions.assertEquals(xgc, b.getD()); | ||
Assertions.assertArrayEquals(textBytes, b.getE()); | ||
Assertions.assertNotNull(b.getListOfString()); | ||
Assertions.assertEquals(6, b.getListOfString().size()); | ||
Assertions.assertTrue(b.getListOfString().containsAll(Arrays.asList("a", "b", "c", "e", "f", "g"))); | ||
} | ||
} |
55 changes: 55 additions & 0 deletions
55
...able/src/test/java/org/jvnet/jaxb/tests/fluentapi/PrimitivesAndUnboxedPrimitivesTest.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,55 @@ | ||
package org.jvnet.jaxb.tests.fluentapi; | ||
|
||
import generated.Primitives; | ||
import generated.UnboxedPrimitives; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
|
||
public class PrimitivesAndUnboxedPrimitivesTest { | ||
|
||
@Test | ||
public void testPrimitives() { | ||
Primitives p1 = new Primitives(); | ||
p1.setBoolean(true); | ||
p1.setInt(1); | ||
p1.setLong(10L); | ||
p1.setDouble(20d); | ||
p1.setFloat(40.0f); | ||
p1.setByte((byte) 80); | ||
p1.setShort((short) 160); | ||
|
||
Primitives p2 = new Primitives(); | ||
p1.copyTo(p2); | ||
|
||
Assertions.assertTrue(p2.isBoolean()); | ||
Assertions.assertEquals(1, p2.getInt()); | ||
Assertions.assertEquals(10L, p2.getLong()); | ||
Assertions.assertEquals(20d, p2.getDouble(), 0); | ||
Assertions.assertEquals(40.0f, p2.getFloat(), 0); | ||
Assertions.assertEquals((byte) 80, p2.getByte()); | ||
Assertions.assertEquals((short) 160, p2.getShort()); | ||
} | ||
|
||
@Test | ||
public void testUnboxedPrimitives() { | ||
UnboxedPrimitives u = new UnboxedPrimitives(); | ||
u.setUnboxedBoolean(Boolean.TRUE); | ||
u.setUnboxedInt(Integer.valueOf(1)); | ||
u.setUnboxedLong(Long.valueOf(10)); | ||
u.setUnboxedDouble(Double.valueOf(20d)); | ||
u.setUnboxedFloat(Float.valueOf(40.0f)); | ||
u.setUnboxedByte(Byte.valueOf((byte) 80)); | ||
u.setUnboxedShort(Short.valueOf((short) 160)); | ||
|
||
UnboxedPrimitives u2 = new UnboxedPrimitives(); | ||
u.copyTo(u2); | ||
|
||
Assertions.assertEquals(Boolean.TRUE, u2.isUnboxedBoolean()); | ||
Assertions.assertEquals(Integer.valueOf(1), u2.getUnboxedInt()); | ||
Assertions.assertEquals(Long.valueOf(10), u2.getUnboxedLong()); | ||
Assertions.assertEquals(Double.valueOf(20d), u2.getUnboxedDouble()); | ||
Assertions.assertEquals(Float.valueOf(40.0f), u2.getUnboxedFloat()); | ||
Assertions.assertEquals(Byte.valueOf((byte) 80), u2.getUnboxedByte()); | ||
Assertions.assertEquals(Short.valueOf((short) 160), u2.getUnboxedShort()); | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
jaxb-plugins-parent/tests/copyable/src/test/resources/log4j.properties
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,5 @@ | ||
log4j.rootCategory=DEBUG, stdout | ||
log4j.appender.stdout=org.apache.log4j.ConsoleAppender | ||
log4j.appender.stdout.target=system.out | ||
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout | ||
log4j.appender.stdout.layout.ConversionPattern=%d %p [%c] - <%m>%n |
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