Skip to content

Commit 5f764b5

Browse files
hansonrhansonr
authored andcommitted
JAXB test files
1 parent 3759232 commit 5f764b5

File tree

2 files changed

+81
-11
lines changed

2 files changed

+81
-11
lines changed

sources/net.sf.j2s.java.core/src/test/Test_JAXB_FIELD.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import javax.xml.namespace.QName;
2323

2424
import test.jaxb.Root_FIELD;
25+
import test.jaxb.Root_NONE;
2526

2627
@XmlRegistry
2728
public class Test_JAXB_FIELD extends Test_ {
@@ -41,7 +42,7 @@ public static void main(String[] args) {
4142
Date d = new Date(1373360175539L);
4243
System.out.println(d);
4344

44-
Root_FIELD root = new Root_FIELD();
45+
Root_FIELD root = new Root_FIELD(false);
4546
System.out.println("c is " + root.C());
4647
System.out.println("getPropertyC is " + root.getPropertyC());
4748
System.out.println("DEFVAL is " + root.DEFVAL);
@@ -60,16 +61,18 @@ public static void main(String[] args) {
6061
ByteArrayInputStream is = new ByteArrayInputStream(s.getBytes("UTF-8"));
6162
Root_FIELD r = (Root_FIELD) unmarshaller.unmarshal(is);
6263
assert(r.getPropertyAng().equals("\u212B"));
64+
System.out.println("date is " + r.date);
6365
System.out.println("PropertyC is " + r.PC());
6466
System.out.println("propertyc is " + r.pc());
6567
System.out.println("propertyC is " + r.pC());
6668
System.out.println("getPropertyAng[].length is " + r.getPropertyAng().getBytes("utf-8").length);
6769
System.out.println("DEFVAL is " + r.DEFVAL);
6870

69-
Class<?> c = Test_JAXB_FIELD.class;
70-
InputStream ris = c.getResourceAsStream("jaxb/Root_FIELD.xml");
71-
unmarshaller.unmarshal(ris);
72-
71+
//
72+
// Class<?> c = Test_JAXB_FIELD.class;
73+
// InputStream ris = c.getResourceAsStream("jaxb/Root_FIELD.xml");
74+
// ByteArrayInputStream ris = new ByteArrayInputStream(s.getBytes("UTF-8"));
75+
7376
} catch (UnsupportedEncodingException e) {
7477
e.printStackTrace();
7578
}

sources/net.sf.j2s.java.core/src/test/Test_JAXB_NONE.java

Lines changed: 73 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,80 @@
1616

1717
import test.jaxb.Root_NONE;
1818

19+
/**
20+
* see notes in jaxb/Root_NONE.java
21+
*
22+
* @author hansonr
23+
*
24+
*/
1925
@XmlRegistry
2026
public class Test_JAXB_NONE extends Test_ {
2127

28+
// Java read out:
29+
// getPropertyC is =getproPERtyC:propertyC01
30+
// getAToBe
31+
// getAToBe
32+
// getAToBe
33+
// isB2()
34+
// getB3()
35+
// private!getC
36+
// private!getC
37+
// private!getC
38+
// getPropertyAToBe
39+
// getPropertyAToBe
40+
// getPropertyAToBe
41+
//
42+
// <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
43+
// <ns2:RootNone xmlns:ns2="www.jalview.org" ang="?" pi1A="0" pi2A="0" pi3A="3">
44+
// <propertyC>propertyC0</propertyC>
45+
// <AToBe>getAtoBe</AToBe>
46+
// <b2>true</b2>
47+
// <b3>true</b3>
48+
// <c>getC</c>
49+
// <propertyAToBe>getPropertyAtoB</propertyAToBe>
50+
// <propc>=getproPERtyC:propertyC01</propc>
51+
// <propertyc>=getpropertyc:propertyC0</propertyc>
52+
// </ns2:RootNone>
53+
//
54+
// setAToBe:getAtoBe
55+
// setB2()
56+
// setB3()
57+
// private!setC
58+
// setPropertyAToBe:getPropertyAtoB
59+
// setProPERtyC:=getproPERtyC:propertyC01
60+
// setpropertyc:=getpropertyc:propertyC0
61+
// getPropertyAng[].length is 3
62+
// Test_JAXB_NONE OK
63+
64+
// JavaScript read out:
65+
// getPropertyC is =getproPERtyC:propertyC01
66+
// private!getC
67+
// isB2()
68+
// getB3()
69+
// getAToBe
70+
// getPropertyAToBe
71+
//
72+
// <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
73+
// <ns2:RootNone xmlns="www.jalview.org" xmlns:ns2="www.jalview.org" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" Ang="&#8491;" pi1a="0" pi2a="0" pi3a="3">
74+
// <propertyC>propertyC0</propertyC>
75+
// <c>getC</c>
76+
// <propc>=getproPERtyC:propertyC01</propc>
77+
// <propertyc>=getpropertyc:propertyC0</propertyc>
78+
// <b2>true</b2>
79+
// <b3>true</b3>
80+
// <aToBe>getAtoBe</aToBe>
81+
// <propertyAToBe>=getPropertyAtoB</propertyAToBe>
82+
// </ns2:RootNone>
83+
// private!setC
84+
// setProPERtyC:=getproPERtyC:propertyC01
85+
// setpropertyc:=getpropertyc:propertyC0
86+
// setB2()
87+
// setB3()
88+
// setAToBe:getAtoBe
89+
// setPropertyAToBe:=getPropertyAtoB
90+
// getPropertyAng[].length is 3
91+
// Test_JAXB_NONE OK
92+
2293
@XmlElementDecl(namespace = "www.jalview.org", name = "Root")
2394
public static JAXBElement<Root_NONE> createRootModel(Root_NONE value) {
2495
return new JAXBElement<Root_NONE>(new QName("www.jalview.org", "Root"), Root_NONE.class, null, value);
@@ -29,9 +100,8 @@ public static void main(String[] args) {
29100
try {
30101
jc = JAXBContext.newInstance(Root_NONE.class);
31102

32-
Root_NONE root = new Root_NONE();
33-
System.out.println("c is " + root.C());
34-
System.out.println("getPropertyC is " + root.getPropertyC());
103+
Root_NONE root = new Root_NONE("test");
104+
System.out.println("getPropertyC is " + root.getproPERtyC());
35105
Marshaller marshaller = jc.createMarshaller();
36106
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
37107
ByteArrayOutputStream bos = new ByteArrayOutputStream();
@@ -45,9 +115,6 @@ public static void main(String[] args) {
45115
ByteArrayInputStream is = new ByteArrayInputStream(s.getBytes("UTF-8"));
46116
Root_NONE r = (Root_NONE) unmarshaller.unmarshal(is);
47117
assert(r.getPropertyAng().equals("\u212B"));
48-
System.out.println("PropertyC is " + r.PC());
49-
System.out.println("propertyc is " + r.pc());
50-
System.out.println("propertyC is " + r.pC());
51118
System.out.println("getPropertyAng[].length is " + r.getPropertyAng().getBytes("utf-8").length);
52119
} catch (UnsupportedEncodingException e) {
53120
// TODO Auto-generated catch block

0 commit comments

Comments
 (0)