From c3e4b287e4f6d48be09dd1cbeb7949372649425f Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Thu, 8 Jul 2021 14:11:03 +0200 Subject: [PATCH] [DEV] add test for validate the structured list --- .../exml/ExmlTestIntrospectionBoolean.java | 68 ++++++++++++++++++ .../ExmlTestIntrospectionBooleanNative.java | 34 ++++++++- .../exml/ExmlTestIntrospectionByte.java | 65 +++++++++++++++++ .../exml/ExmlTestIntrospectionByteNative.java | 40 +++++++++-- .../exml/ExmlTestIntrospectionDouble.java | 69 +++++++++++++++++++ .../ExmlTestIntrospectionDoubleNative.java | 34 ++++++++- .../exml/ExmlTestIntrospectionEnum.java | 69 +++++++++++++++++++ .../exml/ExmlTestIntrospectionFloat.java | 65 +++++++++++++++++ .../ExmlTestIntrospectionFloatNative.java | 34 ++++++++- .../exml/ExmlTestIntrospectionInteger.java | 68 ++++++++++++++++++ .../ExmlTestIntrospectionIntegerNative.java | 34 ++++++++- .../exml/ExmlTestIntrospectionShort.java | 69 +++++++++++++++++++ .../ExmlTestIntrospectionShortNative.java | 34 ++++++++- 13 files changed, 673 insertions(+), 10 deletions(-) diff --git a/test/src/test/atriasoft/exml/ExmlTestIntrospectionBoolean.java b/test/src/test/atriasoft/exml/ExmlTestIntrospectionBoolean.java index 307cbc5..0dc570b 100644 --- a/test/src/test/atriasoft/exml/ExmlTestIntrospectionBoolean.java +++ b/test/src/test/atriasoft/exml/ExmlTestIntrospectionBoolean.java @@ -9,6 +9,7 @@ import java.util.List; import org.atriasoft.exml.Exml; import org.atriasoft.exml.annotation.XmlDefaultAttibute; +import org.atriasoft.exml.annotation.XmlList; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeAll; @@ -417,5 +418,72 @@ public class ExmlTestIntrospectionBoolean { Assertions.assertEquals(false, root.getValues().get(3)); Assertions.assertEquals(true, root.getValues().get(4)); } + + + + + + public class TestListNodeBooleanStructured { + @XmlList(value="elem") + public List values; + } + @Test + public void testListNodeBooleanStructured() { + TestListNodeBooleanStructured elem = new TestListNodeBooleanStructured(); + elem.values = List.of(false, false, true, false, true); + + StringBuilder builder = new StringBuilder(); + Assertions.assertDoesNotThrow(() -> Exml.generate(elem, ExmlTestIntrospectionBoolean.NODE_NAME, builder)); + String dataTest = builder.toString(); + Log.warning("data generated: " + builder.toString()); + Assertions.assertEquals("\n" + + " \n" + + " false\n" + + " false\n" + + " true\n" + + " false\n" + + " true\n" + + " \n" + + "", dataTest); + + final TestListNodeBooleanStructured root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestListNodeBooleanStructured.class, ExmlTestIntrospectionBoolean.NODE_NAME)); + Assertions.assertEquals(5, root.values.size()); + Assertions.assertEquals(false, root.values.get(0)); + Assertions.assertEquals(false, root.values.get(1)); + Assertions.assertEquals(true, root.values.get(2)); + Assertions.assertEquals(false, root.values.get(3)); + Assertions.assertEquals(true, root.values.get(4)); + } + public class TestArrayNodeBooleanStructured { + @XmlList(value="elem") + public Boolean[] values; + } + @Test + public void testArrayNodeBooleanStructured() { + TestArrayNodeBooleanStructured elem = new TestArrayNodeBooleanStructured(); + elem.values = new Boolean[] {false, false, true, false, true}; + + StringBuilder builder = new StringBuilder(); + Assertions.assertDoesNotThrow(() -> Exml.generate(elem, ExmlTestIntrospectionBoolean.NODE_NAME, builder)); + String dataTest = builder.toString(); + Log.warning("data generated: " + builder.toString()); + Assertions.assertEquals("\n" + + " \n" + + " false\n" + + " false\n" + + " true\n" + + " false\n" + + " true\n" + + " \n" + + "", dataTest); + + final TestArrayNodeBooleanStructured root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestArrayNodeBooleanStructured.class, ExmlTestIntrospectionBoolean.NODE_NAME)); + Assertions.assertEquals(5, root.values.length); + Assertions.assertEquals(false, root.values[0]); + Assertions.assertEquals(false, root.values[1]); + Assertions.assertEquals(true, root.values[2]); + Assertions.assertEquals(false, root.values[3]); + Assertions.assertEquals(true, root.values[4]); + } } diff --git a/test/src/test/atriasoft/exml/ExmlTestIntrospectionBooleanNative.java b/test/src/test/atriasoft/exml/ExmlTestIntrospectionBooleanNative.java index 10b6c00..595387e 100644 --- a/test/src/test/atriasoft/exml/ExmlTestIntrospectionBooleanNative.java +++ b/test/src/test/atriasoft/exml/ExmlTestIntrospectionBooleanNative.java @@ -7,6 +7,7 @@ package test.atriasoft.exml; import org.atriasoft.exml.Exml; import org.atriasoft.exml.annotation.XmlDefaultAttibute; +import org.atriasoft.exml.annotation.XmlList; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeAll; @@ -261,7 +262,38 @@ public class ExmlTestIntrospectionBooleanNative { Assertions.assertEquals(false, root.getValues()[3]); Assertions.assertEquals(true, root.getValues()[4]); } - + + public class TestArrayNodeBooleanNativeStructured { + @XmlList(value="elem") + public boolean[] values; + } + @Test + public void testArrayNodeBooleanNativeStructured() { + TestArrayNodeBooleanNativeStructured elem = new TestArrayNodeBooleanNativeStructured(); + elem.values = new boolean[] {false, false, true, false, true}; + + StringBuilder builder = new StringBuilder(); + Assertions.assertDoesNotThrow(() -> Exml.generate(elem, ExmlTestIntrospectionBoolean.NODE_NAME, builder)); + String dataTest = builder.toString(); + Log.warning("data generated: " + builder.toString()); + Assertions.assertEquals("\n" + + " \n" + + " false\n" + + " false\n" + + " true\n" + + " false\n" + + " true\n" + + " \n" + + "", dataTest); + + final TestArrayNodeBooleanNativeStructured root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestArrayNodeBooleanNativeStructured.class, ExmlTestIntrospectionBoolean.NODE_NAME)); + Assertions.assertEquals(5, root.values.length); + Assertions.assertEquals(false, root.values[0]); + Assertions.assertEquals(false, root.values[1]); + Assertions.assertEquals(true, root.values[2]); + Assertions.assertEquals(false, root.values[3]); + Assertions.assertEquals(true, root.values[4]); + } } diff --git a/test/src/test/atriasoft/exml/ExmlTestIntrospectionByte.java b/test/src/test/atriasoft/exml/ExmlTestIntrospectionByte.java index 1e8e17b..8374662 100644 --- a/test/src/test/atriasoft/exml/ExmlTestIntrospectionByte.java +++ b/test/src/test/atriasoft/exml/ExmlTestIntrospectionByte.java @@ -10,6 +10,7 @@ import java.util.List; import org.atriasoft.exml.Exml; import org.atriasoft.exml.annotation.XmlDefaultAttibute; import org.atriasoft.exml.annotation.XmlList; + import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; @@ -487,5 +488,69 @@ public class ExmlTestIntrospectionByte { Assertions.assertEquals((byte)-127, root.getValues()[4]); } + + + public class TestListNodeByteStructured { + @XmlList(value="elem") + public List values; + } + @Test + public void testListNodeByteStructured() { + TestListNodeByteStructured elem = new TestListNodeByteStructured(); + elem.values = List.of((byte)12, (byte)-13, (byte)33, (byte)78, (byte)-127); + + StringBuilder builder = new StringBuilder(); + Assertions.assertDoesNotThrow(() -> Exml.generate(elem, ExmlTestIntrospectionByte.NODE_NAME, builder)); + String dataTest = builder.toString(); + Log.warning("data generated: " + builder.toString()); + Assertions.assertEquals("\n" + + " \n" + + " 12\n" + + " -13\n" + + " 33\n" + + " 78\n" + + " -127\n" + + " \n" + + "", dataTest); + + final TestListNodeByteStructured root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestListNodeByteStructured.class, ExmlTestIntrospectionByte.NODE_NAME)); + Assertions.assertEquals(5, root.values.size()); + Assertions.assertEquals((byte)12, root.values.get(0)); + Assertions.assertEquals((byte)-13, root.values.get(1)); + Assertions.assertEquals((byte)33, root.values.get(2)); + Assertions.assertEquals((byte)78, root.values.get(3)); + Assertions.assertEquals((byte)-127, root.values.get(4)); + } + public class TestArrayNodeByteStructured { + @XmlList(value="elem") + public Byte[] values; + } + @Test + public void testArrayNodeByteStructured() { + TestArrayNodeByteStructured elem = new TestArrayNodeByteStructured(); + elem.values = new Byte[] {12, -13, 33, 78, -127}; + + StringBuilder builder = new StringBuilder(); + Assertions.assertDoesNotThrow(() -> Exml.generate(elem, ExmlTestIntrospectionByte.NODE_NAME, builder)); + String dataTest = builder.toString(); + Log.warning("data generated: " + builder.toString()); + Assertions.assertEquals("\n" + + " \n" + + " 12\n" + + " -13\n" + + " 33\n" + + " 78\n" + + " -127\n" + + " \n" + + "", dataTest); + + final TestArrayNodeByteStructured root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestArrayNodeByteStructured.class, ExmlTestIntrospectionByte.NODE_NAME)); + Assertions.assertEquals(5, root.values.length); + Assertions.assertEquals((byte)12, root.values[0]); + Assertions.assertEquals((byte)-13, root.values[1]); + Assertions.assertEquals((byte)33, root.values[2]); + Assertions.assertEquals((byte)78, root.values[3]); + Assertions.assertEquals((byte)-127, root.values[4]); + } } diff --git a/test/src/test/atriasoft/exml/ExmlTestIntrospectionByteNative.java b/test/src/test/atriasoft/exml/ExmlTestIntrospectionByteNative.java index 5e2b59e..fde9e7c 100644 --- a/test/src/test/atriasoft/exml/ExmlTestIntrospectionByteNative.java +++ b/test/src/test/atriasoft/exml/ExmlTestIntrospectionByteNative.java @@ -5,18 +5,14 @@ */ package test.atriasoft.exml; -import java.util.List; - import org.atriasoft.exml.Exml; import org.atriasoft.exml.annotation.XmlDefaultAttibute; import org.atriasoft.exml.annotation.XmlList; + import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; -import test.atriasoft.exml.ExmlTestIntrospectionByte.TestArrayNodeByteStructuredFunc; -import test.atriasoft.exml.ExmlTestIntrospectionByte.TestListNodeByteStructuredFunc; - public class ExmlTestIntrospectionByteNative { static final String NODE_NAME = "elem"; @BeforeAll @@ -304,5 +300,39 @@ public class ExmlTestIntrospectionByteNative { Assertions.assertEquals((byte)-127, root.getValues()[4]); } + + + + public class TestArrayNodeByteNativeStructured { + @XmlList(value="elem") + public byte[] values; + } + @Test + public void testArrayNodeByteNativeStructured() { + TestArrayNodeByteNativeStructured elem = new TestArrayNodeByteNativeStructured(); + elem.values = new byte[] {12, -13, 33, 78, -127}; + + StringBuilder builder = new StringBuilder(); + Assertions.assertDoesNotThrow(() -> Exml.generate(elem, ExmlTestIntrospectionByte.NODE_NAME, builder)); + String dataTest = builder.toString(); + Log.warning("data generated: " + builder.toString()); + Assertions.assertEquals("\n" + + " \n" + + " 12\n" + + " -13\n" + + " 33\n" + + " 78\n" + + " -127\n" + + " \n" + + "", dataTest); + + final TestArrayNodeByteNativeStructured root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestArrayNodeByteNativeStructured.class, ExmlTestIntrospectionByte.NODE_NAME)); + Assertions.assertEquals(5, root.values.length); + Assertions.assertEquals((byte)12, root.values[0]); + Assertions.assertEquals((byte)-13, root.values[1]); + Assertions.assertEquals((byte)33, root.values[2]); + Assertions.assertEquals((byte)78, root.values[3]); + Assertions.assertEquals((byte)-127, root.values[4]); + } } diff --git a/test/src/test/atriasoft/exml/ExmlTestIntrospectionDouble.java b/test/src/test/atriasoft/exml/ExmlTestIntrospectionDouble.java index 56f7f71..126f189 100644 --- a/test/src/test/atriasoft/exml/ExmlTestIntrospectionDouble.java +++ b/test/src/test/atriasoft/exml/ExmlTestIntrospectionDouble.java @@ -9,6 +9,7 @@ import java.util.List; import org.atriasoft.exml.Exml; import org.atriasoft.exml.annotation.XmlDefaultAttibute; +import org.atriasoft.exml.annotation.XmlList; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeAll; @@ -411,5 +412,73 @@ public class ExmlTestIntrospectionDouble { Assertions.assertEquals(78, root.getValues().get(3)); Assertions.assertEquals(-127, root.getValues().get(4)); } + + + + + + + public class TestListNodeDoubleStructured { + @XmlList(value="elem") + public List values; + } + @Test + public void testListNodeDoubleStructured() { + TestListNodeDoubleStructured elem = new TestListNodeDoubleStructured(); + elem.values = List.of((double)12, (double)-13, (double)33, (double)78, (double)-127); + + StringBuilder builder = new StringBuilder(); + Assertions.assertDoesNotThrow(() -> Exml.generate(elem, ExmlTestIntrospectionDouble.NODE_NAME, builder)); + String dataTest = builder.toString(); + Log.warning("data generated: " + builder.toString()); + Assertions.assertEquals("\n" + + " \n" + + " 12.0\n" + + " -13.0\n" + + " 33.0\n" + + " 78.0\n" + + " -127.0\n" + + " \n" + + "", dataTest); + + final TestListNodeDoubleStructured root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestListNodeDoubleStructured.class, ExmlTestIntrospectionDouble.NODE_NAME)); + Assertions.assertEquals(5, root.values.size()); + Assertions.assertEquals(12, root.values.get(0)); + Assertions.assertEquals(-13, root.values.get(1)); + Assertions.assertEquals(33, root.values.get(2)); + Assertions.assertEquals(78, root.values.get(3)); + Assertions.assertEquals(-127, root.values.get(4)); + } + public class TestArrayNodeDoubleStructured { + @XmlList(value="elem") + public Double[] values; + } + @Test + public void testArrayNodeDoubleStructured() { + TestArrayNodeDoubleStructured elem = new TestArrayNodeDoubleStructured(); + elem.values = new Double[] {(double)12, (double)-13, (double)33, (double)78, (double)-127}; + + StringBuilder builder = new StringBuilder(); + Assertions.assertDoesNotThrow(() -> Exml.generate(elem, ExmlTestIntrospectionDouble.NODE_NAME, builder)); + String dataTest = builder.toString(); + Log.warning("data generated: " + builder.toString()); + Assertions.assertEquals("\n" + + " \n" + + " 12.0\n" + + " -13.0\n" + + " 33.0\n" + + " 78.0\n" + + " -127.0\n" + + " \n" + + "", dataTest); + + final TestArrayNodeDoubleStructured root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestArrayNodeDoubleStructured.class, ExmlTestIntrospectionDouble.NODE_NAME)); + Assertions.assertEquals((double)5, root.values.length); + Assertions.assertEquals(12, root.values[0]); + Assertions.assertEquals(-13, root.values[1]); + Assertions.assertEquals(33, root.values[2]); + Assertions.assertEquals(78, root.values[3]); + Assertions.assertEquals(-127, root.values[4]); + } } diff --git a/test/src/test/atriasoft/exml/ExmlTestIntrospectionDoubleNative.java b/test/src/test/atriasoft/exml/ExmlTestIntrospectionDoubleNative.java index 6d502b5..889ea3d 100644 --- a/test/src/test/atriasoft/exml/ExmlTestIntrospectionDoubleNative.java +++ b/test/src/test/atriasoft/exml/ExmlTestIntrospectionDoubleNative.java @@ -7,6 +7,7 @@ package test.atriasoft.exml; import org.atriasoft.exml.Exml; import org.atriasoft.exml.annotation.XmlDefaultAttibute; +import org.atriasoft.exml.annotation.XmlList; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeAll; @@ -260,6 +261,37 @@ public class ExmlTestIntrospectionDoubleNative { Assertions.assertEquals(78, root.getValues()[3]); Assertions.assertEquals(-127, root.getValues()[4]); } - + + public class TestArrayNodeDoubleNativeStructured { + @XmlList(value="elem") + public double[] values; + } + @Test + public void testArrayNodeDoubleNativeStructured() { + TestArrayNodeDoubleNativeStructured elem = new TestArrayNodeDoubleNativeStructured(); + elem.values = new double[] {12, -13, 33, 78, -127}; + + StringBuilder builder = new StringBuilder(); + Assertions.assertDoesNotThrow(() -> Exml.generate(elem, ExmlTestIntrospectionDouble.NODE_NAME, builder)); + String dataTest = builder.toString(); + Log.warning("data generated: " + builder.toString()); + Assertions.assertEquals("\n" + + " \n" + + " 12.0\n" + + " -13.0\n" + + " 33.0\n" + + " 78.0\n" + + " -127.0\n" + + " \n" + + "", dataTest); + + final TestArrayNodeDoubleNativeStructured root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestArrayNodeDoubleNativeStructured.class, ExmlTestIntrospectionDouble.NODE_NAME)); + Assertions.assertEquals(5, root.values.length); + Assertions.assertEquals(12, root.values[0]); + Assertions.assertEquals(-13, root.values[1]); + Assertions.assertEquals(33, root.values[2]); + Assertions.assertEquals(78, root.values[3]); + Assertions.assertEquals(-127, root.values[4]); + } } diff --git a/test/src/test/atriasoft/exml/ExmlTestIntrospectionEnum.java b/test/src/test/atriasoft/exml/ExmlTestIntrospectionEnum.java index a0431ed..cf5448f 100644 --- a/test/src/test/atriasoft/exml/ExmlTestIntrospectionEnum.java +++ b/test/src/test/atriasoft/exml/ExmlTestIntrospectionEnum.java @@ -9,6 +9,7 @@ import java.util.List; import org.atriasoft.exml.Exml; import org.atriasoft.exml.annotation.XmlDefaultAttibute; +import org.atriasoft.exml.annotation.XmlList; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeAll; @@ -393,5 +394,73 @@ public class ExmlTestIntrospectionEnum { Assertions.assertEquals(TestEnumVal.VALUE_1, root.getValues().get(3)); Assertions.assertEquals(TestEnumVal.VALUE_2, root.getValues().get(4)); } + + + + + + + public class TestListNodeEnumStructured { + @XmlList(value="elem") + public List values; + } + @Test + public void testListNodeTestEnumValStructured() { + TestListNodeEnumStructured elem = new TestListNodeEnumStructured(); + elem.values = List.of(TestEnumVal.VALUE_1,TestEnumVal.VALUE_2, TestEnumVal.VALUE_3, TestEnumVal.VALUE_1, TestEnumVal.VALUE_2); + + StringBuilder builder = new StringBuilder(); + Assertions.assertDoesNotThrow(() -> Exml.generate(elem, ExmlTestIntrospectionEnum.NODE_NAME, builder)); + String dataTest = builder.toString(); + Log.warning("data generated: " + builder.toString()); + Assertions.assertEquals("\n" + + " \n" + + " VALUE_1\n" + + " VALUE_2\n" + + " VALUE_3\n" + + " VALUE_1\n" + + " VALUE_2\n" + + " \n" + + "", dataTest); + + final TestListNodeEnumStructured root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestListNodeEnumStructured.class, ExmlTestIntrospectionEnum.NODE_NAME)); + Assertions.assertEquals(5, root.values.size()); + Assertions.assertEquals(TestEnumVal.VALUE_1, root.values.get(0)); + Assertions.assertEquals(TestEnumVal.VALUE_2, root.values.get(1)); + Assertions.assertEquals(TestEnumVal.VALUE_3, root.values.get(2)); + Assertions.assertEquals(TestEnumVal.VALUE_1, root.values.get(3)); + Assertions.assertEquals(TestEnumVal.VALUE_2, root.values.get(4)); + } + public class TestArrayNodeEnumStructured { + @XmlList(value="elem") + public TestEnumVal[] values; + } + @Test + public void testArrayNodeTestEnumValStructured() { + TestArrayNodeEnumStructured elem = new TestArrayNodeEnumStructured(); + elem.values = new TestEnumVal[] {TestEnumVal.VALUE_1,TestEnumVal.VALUE_2, TestEnumVal.VALUE_3, TestEnumVal.VALUE_1, TestEnumVal.VALUE_2}; + + StringBuilder builder = new StringBuilder(); + Assertions.assertDoesNotThrow(() -> Exml.generate(elem, ExmlTestIntrospectionEnum.NODE_NAME, builder)); + String dataTest = builder.toString(); + Log.warning("data generated: " + builder.toString()); + Assertions.assertEquals("\n" + + " \n" + + " VALUE_1\n" + + " VALUE_2\n" + + " VALUE_3\n" + + " VALUE_1\n" + + " VALUE_2\n" + + " \n" + + "", dataTest); + + final TestArrayNodeEnumStructured root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestArrayNodeEnumStructured.class, ExmlTestIntrospectionEnum.NODE_NAME)); + Assertions.assertEquals(5, root.values.length); + Assertions.assertEquals(TestEnumVal.VALUE_1, root.values[0]); + Assertions.assertEquals(TestEnumVal.VALUE_2, root.values[1]); + Assertions.assertEquals(TestEnumVal.VALUE_3, root.values[2]); + Assertions.assertEquals(TestEnumVal.VALUE_1, root.values[3]); + Assertions.assertEquals(TestEnumVal.VALUE_2, root.values[4]); + } } diff --git a/test/src/test/atriasoft/exml/ExmlTestIntrospectionFloat.java b/test/src/test/atriasoft/exml/ExmlTestIntrospectionFloat.java index 3ac8bbd..d169a06 100644 --- a/test/src/test/atriasoft/exml/ExmlTestIntrospectionFloat.java +++ b/test/src/test/atriasoft/exml/ExmlTestIntrospectionFloat.java @@ -9,6 +9,7 @@ import java.util.List; import org.atriasoft.exml.Exml; import org.atriasoft.exml.annotation.XmlDefaultAttibute; +import org.atriasoft.exml.annotation.XmlList; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeAll; @@ -411,5 +412,69 @@ public class ExmlTestIntrospectionFloat { Assertions.assertEquals(78, root.getValues().get(3)); Assertions.assertEquals(-127, root.getValues().get(4)); } + + + public class TestListNodeByteStructured { + @XmlList(value="elem") + public List values; + } + @Test + public void testListNodeByteStructured() { + TestListNodeByteStructured elem = new TestListNodeByteStructured(); + elem.values = List.of((float)12, (float)-13, (float)33, (float)78, (float)-127); + + StringBuilder builder = new StringBuilder(); + Assertions.assertDoesNotThrow(() -> Exml.generate(elem, ExmlTestIntrospectionByte.NODE_NAME, builder)); + String dataTest = builder.toString(); + Log.warning("data generated: " + builder.toString()); + Assertions.assertEquals("\n" + + " \n" + + " 12.0\n" + + " -13.0\n" + + " 33.0\n" + + " 78.0\n" + + " -127.0\n" + + " \n" + + "", dataTest); + + final TestListNodeByteStructured root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestListNodeByteStructured.class, ExmlTestIntrospectionByte.NODE_NAME)); + Assertions.assertEquals(5, root.values.size()); + Assertions.assertEquals(12, root.values.get(0)); + Assertions.assertEquals(-13, root.values.get(1)); + Assertions.assertEquals(33, root.values.get(2)); + Assertions.assertEquals(78, root.values.get(3)); + Assertions.assertEquals(-127, root.values.get(4)); + } + public class TestArrayNodeFloatStructured { + @XmlList(value="elem") + public Float[] values; + } + @Test + public void testArrayNodeFloatStructured() { + TestArrayNodeFloatStructured elem = new TestArrayNodeFloatStructured(); + elem.values = new Float[] {(float)12, (float)-13, (float)33, (float)78, (float)-127}; + + StringBuilder builder = new StringBuilder(); + Assertions.assertDoesNotThrow(() -> Exml.generate(elem, ExmlTestIntrospectionFloat.NODE_NAME, builder)); + String dataTest = builder.toString(); + Log.warning("data generated: " + builder.toString()); + Assertions.assertEquals("\n" + + " \n" + + " 12.0\n" + + " -13.0\n" + + " 33.0\n" + + " 78.0\n" + + " -127.0\n" + + " \n" + + "", dataTest); + + final TestArrayNodeFloatStructured root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestArrayNodeFloatStructured.class, ExmlTestIntrospectionFloat.NODE_NAME)); + Assertions.assertEquals(5, root.values.length); + Assertions.assertEquals(12, root.values[0]); + Assertions.assertEquals(-13, root.values[1]); + Assertions.assertEquals(33, root.values[2]); + Assertions.assertEquals(78, root.values[3]); + Assertions.assertEquals(-127, root.values[4]); + } } diff --git a/test/src/test/atriasoft/exml/ExmlTestIntrospectionFloatNative.java b/test/src/test/atriasoft/exml/ExmlTestIntrospectionFloatNative.java index dedc91e..40eec6d 100644 --- a/test/src/test/atriasoft/exml/ExmlTestIntrospectionFloatNative.java +++ b/test/src/test/atriasoft/exml/ExmlTestIntrospectionFloatNative.java @@ -7,6 +7,7 @@ package test.atriasoft.exml; import org.atriasoft.exml.Exml; import org.atriasoft.exml.annotation.XmlDefaultAttibute; +import org.atriasoft.exml.annotation.XmlList; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeAll; @@ -260,6 +261,37 @@ public class ExmlTestIntrospectionFloatNative { Assertions.assertEquals(78, root.getValues()[3]); Assertions.assertEquals(-127, root.getValues()[4]); } - + + public class TestArrayNodeFloatNativeStructured { + @XmlList(value="elem") + public float[] values; + } + @Test + public void testArrayNodeFloatNativeStructured() { + TestArrayNodeFloatNativeStructured elem = new TestArrayNodeFloatNativeStructured(); + elem.values = new float[] {12, -13, 33, 78, -127}; + + StringBuilder builder = new StringBuilder(); + Assertions.assertDoesNotThrow(() -> Exml.generate(elem, ExmlTestIntrospectionFloat.NODE_NAME, builder)); + String dataTest = builder.toString(); + Log.warning("data generated: " + builder.toString()); + Assertions.assertEquals("\n" + + " \n" + + " 12.0\n" + + " -13.0\n" + + " 33.0\n" + + " 78.0\n" + + " -127.0\n" + + " \n" + + "", dataTest); + + final TestArrayNodeFloatNativeStructured root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestArrayNodeFloatNativeStructured.class, ExmlTestIntrospectionFloat.NODE_NAME)); + Assertions.assertEquals(5, root.values.length); + Assertions.assertEquals(12, root.values[0]); + Assertions.assertEquals(-13, root.values[1]); + Assertions.assertEquals(33, root.values[2]); + Assertions.assertEquals(78, root.values[3]); + Assertions.assertEquals(-127, root.values[4]); + } } diff --git a/test/src/test/atriasoft/exml/ExmlTestIntrospectionInteger.java b/test/src/test/atriasoft/exml/ExmlTestIntrospectionInteger.java index e1dafb5..a2e8a25 100644 --- a/test/src/test/atriasoft/exml/ExmlTestIntrospectionInteger.java +++ b/test/src/test/atriasoft/exml/ExmlTestIntrospectionInteger.java @@ -9,6 +9,7 @@ import java.util.List; import org.atriasoft.exml.Exml; import org.atriasoft.exml.annotation.XmlDefaultAttibute; +import org.atriasoft.exml.annotation.XmlList; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeAll; @@ -411,5 +412,72 @@ public class ExmlTestIntrospectionInteger { Assertions.assertEquals(78, root.getValues().get(3)); Assertions.assertEquals(-127, root.getValues().get(4)); } + + + + + + public class TestListNodeIntegerStructured { + @XmlList(value="elem") + public List values; + } + @Test + public void testListNodeIntegerStructured() { + TestListNodeIntegerStructured elem = new TestListNodeIntegerStructured(); + elem.values = List.of(12, -13, 33, 78, -127); + + StringBuilder builder = new StringBuilder(); + Assertions.assertDoesNotThrow(() -> Exml.generate(elem, ExmlTestIntrospectionInteger.NODE_NAME, builder)); + String dataTest = builder.toString(); + Log.warning("data generated: " + builder.toString()); + Assertions.assertEquals("\n" + + " \n" + + " 12\n" + + " -13\n" + + " 33\n" + + " 78\n" + + " -127\n" + + " \n" + + "", dataTest); + + final TestListNodeIntegerStructured root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestListNodeIntegerStructured.class, ExmlTestIntrospectionInteger.NODE_NAME)); + Assertions.assertEquals(5, root.values.size()); + Assertions.assertEquals(12, root.values.get(0)); + Assertions.assertEquals(-13, root.values.get(1)); + Assertions.assertEquals(33, root.values.get(2)); + Assertions.assertEquals(78, root.values.get(3)); + Assertions.assertEquals(-127, root.values.get(4)); + } + public class TestArrayNodeIntegerStructured { + @XmlList(value="elem") + public Integer[] values; + } + @Test + public void testArrayNodeIntegerStructured() { + TestArrayNodeIntegerStructured elem = new TestArrayNodeIntegerStructured(); + elem.values = new Integer[] {12, -13, 33, 78, -127}; + + StringBuilder builder = new StringBuilder(); + Assertions.assertDoesNotThrow(() -> Exml.generate(elem, ExmlTestIntrospectionInteger.NODE_NAME, builder)); + String dataTest = builder.toString(); + Log.warning("data generated: " + builder.toString()); + Assertions.assertEquals("\n" + + " \n" + + " 12\n" + + " -13\n" + + " 33\n" + + " 78\n" + + " -127\n" + + " \n" + + "", dataTest); + + final TestArrayNodeIntegerStructured root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestArrayNodeIntegerStructured.class, ExmlTestIntrospectionInteger.NODE_NAME)); + Assertions.assertEquals(5, root.values.length); + Assertions.assertEquals(12, root.values[0]); + Assertions.assertEquals(-13, root.values[1]); + Assertions.assertEquals(33, root.values[2]); + Assertions.assertEquals(78, root.values[3]); + Assertions.assertEquals(-127, root.values[4]); + } } diff --git a/test/src/test/atriasoft/exml/ExmlTestIntrospectionIntegerNative.java b/test/src/test/atriasoft/exml/ExmlTestIntrospectionIntegerNative.java index dcf1887..aac5fb7 100644 --- a/test/src/test/atriasoft/exml/ExmlTestIntrospectionIntegerNative.java +++ b/test/src/test/atriasoft/exml/ExmlTestIntrospectionIntegerNative.java @@ -7,6 +7,7 @@ package test.atriasoft.exml; import org.atriasoft.exml.Exml; import org.atriasoft.exml.annotation.XmlDefaultAttibute; +import org.atriasoft.exml.annotation.XmlList; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeAll; @@ -260,6 +261,37 @@ public class ExmlTestIntrospectionIntegerNative { Assertions.assertEquals(78, root.getValues()[3]); Assertions.assertEquals(-127, root.getValues()[4]); } - + + public class TestArrayNodeIntegerNativeStructured { + @XmlList(value="elem") + public byte[] values; + } + @Test + public void testArrayNodeIntegerNativeStructured() { + TestArrayNodeIntegerNativeStructured elem = new TestArrayNodeIntegerNativeStructured(); + elem.values = new byte[] {12, -13, 33, 78, -127}; + + StringBuilder builder = new StringBuilder(); + Assertions.assertDoesNotThrow(() -> Exml.generate(elem, ExmlTestIntrospectionInteger.NODE_NAME, builder)); + String dataTest = builder.toString(); + Log.warning("data generated: " + builder.toString()); + Assertions.assertEquals("\n" + + " \n" + + " 12\n" + + " -13\n" + + " 33\n" + + " 78\n" + + " -127\n" + + " \n" + + "", dataTest); + + final TestArrayNodeIntegerNativeStructured root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestArrayNodeIntegerNativeStructured.class, ExmlTestIntrospectionInteger.NODE_NAME)); + Assertions.assertEquals(5, root.values.length); + Assertions.assertEquals((byte)12, root.values[0]); + Assertions.assertEquals((byte)-13, root.values[1]); + Assertions.assertEquals((byte)33, root.values[2]); + Assertions.assertEquals((byte)78, root.values[3]); + Assertions.assertEquals((byte)-127, root.values[4]); + } } diff --git a/test/src/test/atriasoft/exml/ExmlTestIntrospectionShort.java b/test/src/test/atriasoft/exml/ExmlTestIntrospectionShort.java index 60fca06..b4a424b 100644 --- a/test/src/test/atriasoft/exml/ExmlTestIntrospectionShort.java +++ b/test/src/test/atriasoft/exml/ExmlTestIntrospectionShort.java @@ -9,6 +9,7 @@ import java.util.List; import org.atriasoft.exml.Exml; import org.atriasoft.exml.annotation.XmlDefaultAttibute; +import org.atriasoft.exml.annotation.XmlList; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeAll; @@ -411,5 +412,73 @@ public class ExmlTestIntrospectionShort { Assertions.assertEquals((short)78, root.getValues().get(3)); Assertions.assertEquals((short)-127, root.getValues().get(4)); } + + + + + + + public class TestListNodeShortStructured { + @XmlList(value="elem") + public List values; + } + @Test + public void testListNodeShortStructured() { + TestListNodeShortStructured elem = new TestListNodeShortStructured(); + elem.values = List.of((short)12, (short)-13, (short)33, (short)78, (short)-127); + + StringBuilder builder = new StringBuilder(); + Assertions.assertDoesNotThrow(() -> Exml.generate(elem, ExmlTestIntrospectionShort.NODE_NAME, builder)); + String dataTest = builder.toString(); + Log.warning("data generated: " + builder.toString()); + Assertions.assertEquals("\n" + + " \n" + + " 12\n" + + " -13\n" + + " 33\n" + + " 78\n" + + " -127\n" + + " \n" + + "", dataTest); + + final TestListNodeShortStructured root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestListNodeShortStructured.class, ExmlTestIntrospectionShort.NODE_NAME)); + Assertions.assertEquals(5, root.values.size()); + Assertions.assertEquals((short)12, root.values.get(0)); + Assertions.assertEquals((short)-13, root.values.get(1)); + Assertions.assertEquals((short)33, root.values.get(2)); + Assertions.assertEquals((short)78, root.values.get(3)); + Assertions.assertEquals((short)-127, root.values.get(4)); + } + public class TestArrayNodeShortStructured { + @XmlList(value="elem") + public Short[] values; + } + @Test + public void testArrayNodeShortStructured() { + TestArrayNodeShortStructured elem = new TestArrayNodeShortStructured(); + elem.values = new Short[] {12, -13, 33, 78, -127}; + + StringBuilder builder = new StringBuilder(); + Assertions.assertDoesNotThrow(() -> Exml.generate(elem, ExmlTestIntrospectionShort.NODE_NAME, builder)); + String dataTest = builder.toString(); + Log.warning("data generated: " + builder.toString()); + Assertions.assertEquals("\n" + + " \n" + + " 12\n" + + " -13\n" + + " 33\n" + + " 78\n" + + " -127\n" + + " \n" + + "", dataTest); + + final TestArrayNodeShortStructured root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestArrayNodeShortStructured.class, ExmlTestIntrospectionShort.NODE_NAME)); + Assertions.assertEquals(5, root.values.length); + Assertions.assertEquals((short)12, root.values[0]); + Assertions.assertEquals((short)-13, root.values[1]); + Assertions.assertEquals((short)33, root.values[2]); + Assertions.assertEquals((short)78, root.values[3]); + Assertions.assertEquals((short)-127, root.values[4]); + } } diff --git a/test/src/test/atriasoft/exml/ExmlTestIntrospectionShortNative.java b/test/src/test/atriasoft/exml/ExmlTestIntrospectionShortNative.java index b44fc58..aa9b343 100644 --- a/test/src/test/atriasoft/exml/ExmlTestIntrospectionShortNative.java +++ b/test/src/test/atriasoft/exml/ExmlTestIntrospectionShortNative.java @@ -7,6 +7,7 @@ package test.atriasoft.exml; import org.atriasoft.exml.Exml; import org.atriasoft.exml.annotation.XmlDefaultAttibute; +import org.atriasoft.exml.annotation.XmlList; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeAll; @@ -260,6 +261,37 @@ public class ExmlTestIntrospectionShortNative { Assertions.assertEquals((short)78, root.getValues()[3]); Assertions.assertEquals((short)-127, root.getValues()[4]); } - + + public class TestArrayNodeShortNativeStructured { + @XmlList(value="elem") + public short[] values; + } + @Test + public void testArrayNodeShortNativeStructured() { + TestArrayNodeShortNativeStructured elem = new TestArrayNodeShortNativeStructured(); + elem.values = new short[] {12, -13, 33, 78, -127}; + + StringBuilder builder = new StringBuilder(); + Assertions.assertDoesNotThrow(() -> Exml.generate(elem, ExmlTestIntrospectionShort.NODE_NAME, builder)); + String dataTest = builder.toString(); + Log.warning("data generated: " + builder.toString()); + Assertions.assertEquals("\n" + + " \n" + + " 12\n" + + " -13\n" + + " 33\n" + + " 78\n" + + " -127\n" + + " \n" + + "", dataTest); + + final TestArrayNodeShortNativeStructured root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestArrayNodeShortNativeStructured.class, ExmlTestIntrospectionShort.NODE_NAME)); + Assertions.assertEquals(5, root.values.length); + Assertions.assertEquals((short)12, root.values[0]); + Assertions.assertEquals((short)-13, root.values[1]); + Assertions.assertEquals((short)33, root.values[2]); + Assertions.assertEquals((short)78, root.values[3]); + Assertions.assertEquals((short)-127, root.values[4]); + } }