[DEV] continue rework
This commit is contained in:
parent
cb4d58c32f
commit
a7bdce291d
@ -136,6 +136,70 @@ public class StringSerializer {
|
||||
return new String[] { toString(data) };
|
||||
}
|
||||
});
|
||||
StringSerializer.VALUES_OF.put(float.class, new Converter() {
|
||||
@Override
|
||||
public Object valueOf(final String value) {
|
||||
return Float.valueOf(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(final Object data) {
|
||||
return Float.toString((Float)data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] toStringList(final Object data) {
|
||||
return new String[] { toString(data) };
|
||||
}
|
||||
});
|
||||
StringSerializer.VALUES_OF.put(Float.class, new Converter() {
|
||||
@Override
|
||||
public Object valueOf(final String value) {
|
||||
return Float.valueOf(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(final Object data) {
|
||||
return Float.toString((Float)data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] toStringList(final Object data) {
|
||||
return new String[] { toString(data) };
|
||||
}
|
||||
});
|
||||
StringSerializer.VALUES_OF.put(double.class, new Converter() {
|
||||
@Override
|
||||
public Object valueOf(final String value) {
|
||||
return Double.valueOf(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(final Object data) {
|
||||
return Double.toString((Double)data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] toStringList(final Object data) {
|
||||
return new String[] { toString(data) };
|
||||
}
|
||||
});
|
||||
StringSerializer.VALUES_OF.put(Double.class, new Converter() {
|
||||
@Override
|
||||
public Object valueOf(final String value) {
|
||||
return Double.valueOf(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(final Object data) {
|
||||
return Double.toString((Double)data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] toStringList(final Object data) {
|
||||
return new String[] { toString(data) };
|
||||
}
|
||||
});
|
||||
StringSerializer.VALUES_OF.put(boolean.class, new Converter() {
|
||||
@Override
|
||||
public Object valueOf(final String value) {
|
||||
@ -336,6 +400,90 @@ public class StringSerializer {
|
||||
return out;
|
||||
}
|
||||
});
|
||||
StringSerializer.VALUES_OF.put(float[].class, new Converter() {
|
||||
@Override
|
||||
public Object valueOf(final String value) {
|
||||
return Tools.parseFloatStringList(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(final Object data) {
|
||||
return Tools.toString((float[])data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] toStringList(final Object data) {
|
||||
int[] dataCast = (int[])data;
|
||||
String[] out = new String[dataCast.length];
|
||||
for (int iii=0; iii<dataCast.length; iii++) {
|
||||
out[iii] = Float.toString(dataCast[iii]);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
});
|
||||
StringSerializer.VALUES_OF.put(Float[].class, new Converter() {
|
||||
@Override
|
||||
public Object valueOf(final String value) {
|
||||
return Tools.parseFloatClassStringList(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(final Object data) {
|
||||
return Tools.toString((Float[])data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] toStringList(final Object data) {
|
||||
Float[] dataCast = (Float[])data;
|
||||
String[] out = new String[dataCast.length];
|
||||
for (int iii=0; iii<dataCast.length; iii++) {
|
||||
out[iii] = Float.toString(dataCast[iii]);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
});
|
||||
StringSerializer.VALUES_OF.put(double[].class, new Converter() {
|
||||
@Override
|
||||
public Object valueOf(final String value) {
|
||||
return Tools.parseDoubleStringList(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(final Object data) {
|
||||
return Tools.toString((double[])data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] toStringList(final Object data) {
|
||||
int[] dataCast = (int[])data;
|
||||
String[] out = new String[dataCast.length];
|
||||
for (int iii=0; iii<dataCast.length; iii++) {
|
||||
out[iii] = Double.toString(dataCast[iii]);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
});
|
||||
StringSerializer.VALUES_OF.put(Double[].class, new Converter() {
|
||||
@Override
|
||||
public Object valueOf(final String value) {
|
||||
return Tools.parseDoubleClassStringList(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(final Object data) {
|
||||
return Tools.toString((Double[])data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] toStringList(final Object data) {
|
||||
Double[] dataCast = (Double[])data;
|
||||
String[] out = new String[dataCast.length];
|
||||
for (int iii=0; iii<dataCast.length; iii++) {
|
||||
out[iii] = Double.toString(dataCast[iii]);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
});
|
||||
StringSerializer.VALUES_OF.put(boolean[].class, new Converter() {
|
||||
@Override
|
||||
public Object valueOf(final String value) {
|
||||
|
@ -66,7 +66,7 @@ public class Exml {
|
||||
* @param data Data where the xml is stored
|
||||
*/
|
||||
public static void generate(final XmlNode root, final StringBuilder data) {
|
||||
if (!root.isElement() || !((XmlElement) root).getValue().isEmpty()) {
|
||||
if (!root.isElement() || (((XmlElement) root).getValue() != null && !((XmlElement) root).getValue().isEmpty())) {
|
||||
SerializerXml.serialize(root, data, 0);
|
||||
} else {
|
||||
SerializerXml.serializeRoot((XmlElement) root, data);
|
||||
@ -82,27 +82,29 @@ public class Exml {
|
||||
return (XmlElement) parser.parse(data, property);
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T> T[] parse(final String data, final Class<T> classType, final String rootNodeName) throws ExmlBuilderException, ExmlParserErrorMulti {
|
||||
Builder builder;
|
||||
try {
|
||||
builder = new BuilderIntrospection(classType, rootNodeName);
|
||||
builder = new BuilderIntrospection(ModelType.ARRAY, classType, rootNodeName);
|
||||
final ParseXml parser = new ParseXml(builder);
|
||||
final ParsingProperty property = new ParsingProperty();
|
||||
property.setDisplayError(true);
|
||||
|
||||
final IntrospectionObject introspectionObject = (IntrospectionObject) parser.parse(data, property);
|
||||
introspectionObject.generateTheObject();
|
||||
final Object listRet = introspectionObject.getData();
|
||||
if (listRet != null && listRet instanceof List) {
|
||||
final List<T> rootList = (List<T>) listRet;
|
||||
final T[] strarr = (T[]) Array.newInstance(classType, 0);
|
||||
return rootList.toArray(strarr);
|
||||
if (listRet != null && listRet.getClass().isArray() && listRet.getClass().componentType() == classType) {
|
||||
return (T[]) listRet;
|
||||
}
|
||||
return null;
|
||||
} catch (final ExmlBuilderException ex) {
|
||||
ex.printStackTrace();
|
||||
throw ex;
|
||||
} catch (final Exception e) {
|
||||
} catch (final Exception ex) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
ex.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -28,7 +28,13 @@ public class BuilderIntrospection implements Builder {
|
||||
if (out != null) {
|
||||
return out;
|
||||
}
|
||||
if (model == ModelType.ARRAY) {
|
||||
out = IntrospectionModelFactory.createModelArray(key.nodeName(), key);
|
||||
} else if (model == ModelType.LIST) {
|
||||
out = IntrospectionModelFactory.createModelList(key.nodeName(), key);
|
||||
} else {
|
||||
out = IntrospectionModelFactory.createModelPlop(key);
|
||||
}
|
||||
this.elements.put(key, out);
|
||||
return out;
|
||||
}
|
||||
@ -69,14 +75,24 @@ public class BuilderIntrospection implements Builder {
|
||||
if (typeClass.isArray()) {
|
||||
Class<?> subTypeClass = typeClass.getComponentType();
|
||||
Log.verbose("Create array new 'SUB' class: '" + typeClass.getCanonicalName() + "' for node '" + nodeName + "'");
|
||||
final IntrospectionModel inferData = findOrCreate(ModelType.ARRAY, listTreeName, subTypeClass);
|
||||
IntrospectionModel inferData = null;
|
||||
if (listTreeName == null) {
|
||||
inferData = findOrCreate(ModelType.NORMAL, null, subTypeClass);
|
||||
} else {
|
||||
inferData = findOrCreate(ModelType.ARRAY, listTreeName, subTypeClass);
|
||||
}
|
||||
// Create the data when object is ended created...
|
||||
return new IntrospectionObject(inferData);
|
||||
}
|
||||
if (List.class.isAssignableFrom(typeClass)) {
|
||||
Class<?> subTypeClass = introspectionObject.getTypeOfSubNodeSubType(nodeName);
|
||||
Log.verbose("Create List new 'SUB' class: '" + typeClass.getCanonicalName() + "' for node '" + nodeName + "'");
|
||||
final IntrospectionModel inferData = findOrCreate(ModelType.LIST, listTreeName, subTypeClass);
|
||||
IntrospectionModel inferData = null;
|
||||
if (listTreeName == null) {
|
||||
inferData = findOrCreate(ModelType.NORMAL, null, subTypeClass);
|
||||
} else {
|
||||
inferData = findOrCreate(ModelType.LIST, listTreeName, subTypeClass);
|
||||
}
|
||||
// Create the data when object is ended created...
|
||||
return new IntrospectionObject(inferData);
|
||||
}
|
||||
@ -116,6 +132,14 @@ public class BuilderIntrospection implements Builder {
|
||||
if (nodesAvaillable != null && nodesAvaillable.size() != 0) {
|
||||
throw new ExmlBuilderException("Model can not have direct text with model data= '" + text + "'");
|
||||
}
|
||||
Class<?> arrayType = model.getClassType();
|
||||
final IntrospectionModel inferData = findOrCreate(ModelType.NORMAL, null, arrayType);
|
||||
// Create the data when object is ended created...
|
||||
IntrospectionObject tmpp = new IntrospectionObject(inferData);
|
||||
newText(tmpp, text);
|
||||
Object dataLocal = tmpp.getData();
|
||||
introspectionObject.addObject(IntrospectionObject.STUPID_TOCKEN, dataLocal);
|
||||
return;
|
||||
}
|
||||
introspectionObject.setText(text);
|
||||
}
|
||||
|
@ -28,11 +28,11 @@ public abstract class IntrospectionModel {
|
||||
this.classType = classType;
|
||||
}
|
||||
|
||||
Object createObject(final Map<String, Object> properties, final Map<String, List<Object>> nodes) throws ExmlBuilderException {
|
||||
public Object createObject(final Map<String, Object> properties, final Map<String, List<Object>> nodes) throws ExmlBuilderException {
|
||||
return null;
|
||||
}
|
||||
|
||||
protected List<String> getNodeAvaillable() {
|
||||
public List<String> getNodeAvaillable() {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -1,9 +1,14 @@
|
||||
package org.atriasoft.exml.builder;
|
||||
|
||||
import java.lang.reflect.Array;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.atriasoft.exml.exception.ExmlBuilderException;
|
||||
import org.atriasoft.exml.exception.ExmlParserErrorMulti;
|
||||
import org.atriasoft.exml.parser.ParseXml;
|
||||
import org.atriasoft.exml.parser.ParsingProperty;
|
||||
|
||||
|
||||
public class IntrospectionModelArray extends IntrospectionModel {
|
||||
@ -14,13 +19,31 @@ public class IntrospectionModelArray extends IntrospectionModel {
|
||||
this.nodeName = nodeName;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T> T[] convertList(final Class<T> classType, final List<Object> data) {
|
||||
final List<T> rootList = (List<T>) data;
|
||||
final T[] strarr = (T[]) Array.newInstance(classType, 0);
|
||||
return rootList.toArray(strarr);
|
||||
}
|
||||
@Override
|
||||
Object createObject(final Map<String, Object> properties, final Map<String, List<Object>> nodes) throws ExmlBuilderException {
|
||||
public Object createObject(final Map<String, Object> properties, final Map<String, List<Object>> nodes) throws ExmlBuilderException {
|
||||
List<Object> tmp = null;
|
||||
if (nodeName == null) {
|
||||
tmp = nodes.get(IntrospectionObject.STUPID_TOCKEN);
|
||||
} else {
|
||||
tmp = nodes.get(nodeName);
|
||||
}
|
||||
if (tmp == null) {
|
||||
return null;
|
||||
}
|
||||
return convertList(this.classType, tmp);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> getNodeAvaillable() {
|
||||
public List<String> getNodeAvaillable() {
|
||||
if (nodeName != null) {
|
||||
return Arrays.asList(nodeName);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -14,12 +14,12 @@ public class IntrospectionModelBaseType extends IntrospectionModel {
|
||||
}
|
||||
|
||||
@Override
|
||||
Object createObject(final Map<String, Object> properties, final Map<String, List<Object>> nodes) throws ExmlBuilderException {
|
||||
public Object createObject(final Map<String, Object> properties, final Map<String, List<Object>> nodes) throws ExmlBuilderException {
|
||||
throw new ExmlBuilderException("Base type model can not have properties and nodes ... ");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> getNodeAvaillable() {
|
||||
public List<String> getNodeAvaillable() {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -330,14 +330,17 @@ public class IntrospectionModelComplex extends IntrospectionModel {
|
||||
}
|
||||
|
||||
@Override
|
||||
Object createObject(final Map<String, Object> properties, final Map<String, List<Object>> nodes) throws ExmlBuilderException {
|
||||
public Object createObject(final Map<String, Object> properties, final Map<String, List<Object>> nodes) throws ExmlBuilderException {
|
||||
Object tmp;
|
||||
try {
|
||||
// pb here, can not create a primitive object with the correct elements... ==> must be generated with a siblist of elements
|
||||
|
||||
Constructor<?>[] constructors = this.classType.getConstructors();
|
||||
if (!Modifier.isStatic(this.classType.getModifiers())) {
|
||||
Object tmp2 = null;
|
||||
tmp = constructors[0].newInstance(tmp2);
|
||||
} else {
|
||||
tmp = constructors[0].newInstance();
|
||||
}
|
||||
} catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | SecurityException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
@ -354,7 +357,7 @@ public class IntrospectionModelComplex extends IntrospectionModel {
|
||||
|
||||
|
||||
@Override
|
||||
protected List<String> getNodeAvaillable() {
|
||||
public List<String> getNodeAvaillable() {
|
||||
List<String> out = new ArrayList<>();
|
||||
for (final IntrospectionProperty prop : this.nodes) {
|
||||
out.add(prop.getNames()[0]);
|
||||
@ -638,6 +641,12 @@ public class IntrospectionModelComplex extends IntrospectionModel {
|
||||
} else if (propMethode.getType().componentType() == boolean.class) {
|
||||
boolean[] datas = ArraysTools.listBooleanToPrimitive(tmpp);
|
||||
propMethode.setExistingValue(data, datas);
|
||||
} else if (propMethode.getType().componentType() == float.class) {
|
||||
float[] datas = ArraysTools.listFloatToPrimitive(tmpp);
|
||||
propMethode.setExistingValue(data, datas);
|
||||
} else if (propMethode.getType().componentType() == double.class) {
|
||||
double[] datas = ArraysTools.listDoubleToPrimitive(tmpp);
|
||||
propMethode.setExistingValue(data, datas);
|
||||
} else {
|
||||
Log.verbose(" datas type: " + autoCast(propMethode.getType().componentType(), tmpp).getClass().getCanonicalName());
|
||||
Log.verbose(" methode type: " + propMethode.getType().getCanonicalName());
|
||||
@ -687,6 +696,12 @@ public class IntrospectionModelComplex extends IntrospectionModel {
|
||||
} else if (propField.getType() == long.class) {
|
||||
long dataPrimitive = (Long)value;
|
||||
propField.setExistingValue(data, dataPrimitive);
|
||||
} else if (propField.getType() == float.class) {
|
||||
float dataPrimitive = (Float)value;
|
||||
propField.setExistingValue(data, dataPrimitive);
|
||||
} else if (propField.getType() == double.class) {
|
||||
Double dataPrimitive = (Double)value;
|
||||
propField.setExistingValue(data, dataPrimitive);
|
||||
} else if (propField.getType() == boolean.class) {
|
||||
boolean dataPrimitive = (Boolean)value;
|
||||
propField.setExistingValue(data, dataPrimitive);
|
||||
|
@ -1,6 +1,7 @@
|
||||
package org.atriasoft.exml.builder;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@ -16,12 +17,19 @@ public class IntrospectionModelList extends IntrospectionModel {
|
||||
}
|
||||
|
||||
@Override
|
||||
Object createObject(final Map<String, Object> properties, final Map<String, List<Object>> nodes) throws ExmlBuilderException {
|
||||
return null;
|
||||
public Object createObject(final Map<String, Object> properties, final Map<String, List<Object>> nodes) throws ExmlBuilderException {
|
||||
if (nodeName == null) {
|
||||
return nodes.get(IntrospectionObject.STUPID_TOCKEN);
|
||||
} else {
|
||||
return nodes.get(nodeName);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> getNodeAvaillable() {
|
||||
public List<String> getNodeAvaillable() {
|
||||
if (nodeName != null) {
|
||||
return Arrays.asList(nodeName);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -9,10 +9,9 @@ import org.atriasoft.exml.exception.ExmlBuilderException;
|
||||
import org.atriasoft.exml.internal.Log;
|
||||
|
||||
public class IntrospectionObject {
|
||||
public static final String STUPID_TOCKEN = "___aé\"'__-è==**ù!^$:;,;AZEARTYUIOPMLKJHGFDSQW>XCVBN?"; // can not exist ....
|
||||
private final IntrospectionModel modelInterface;
|
||||
private Object data = null;
|
||||
@Deprecated
|
||||
private final String listNameModel;
|
||||
private final Map<String, Object> properties = new HashMap<>();
|
||||
private final Map<String, List<Object>> nodes = new HashMap<>();
|
||||
|
||||
@ -22,23 +21,10 @@ public class IntrospectionObject {
|
||||
public IntrospectionObject() {
|
||||
this.modelInterface = null;
|
||||
this.data = new ArrayList<>();
|
||||
this.listNameModel = null;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public IntrospectionObject(final IntrospectionModel dataInterface, final String listNameModel) {
|
||||
this.modelInterface = dataInterface;
|
||||
this.listNameModel = listNameModel;
|
||||
}
|
||||
|
||||
public IntrospectionObject(final IntrospectionModel dataInterface) {
|
||||
this.modelInterface = dataInterface;
|
||||
this.listNameModel = null;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public String getListNameModel() {
|
||||
return this.listNameModel;
|
||||
}
|
||||
|
||||
public Object getData() {
|
||||
@ -104,31 +90,10 @@ public class IntrospectionObject {
|
||||
// nothing to do ... ==> element already created
|
||||
return;
|
||||
}
|
||||
if (this.listNameModel == null) {
|
||||
Log.info("Create the element for the Specific node ... type = " + this.modelInterface.getClassType().getCanonicalName());
|
||||
Log.info("Create the element for the Specific node ... type = " + this.modelInterface.getClassType().getCanonicalName() + (this.modelInterface.isArray()?"[array]":"") + (this.modelInterface.isList()?"[List]":""));
|
||||
Log.info(" Properties : " + this.properties.keySet());
|
||||
Log.info(" Nodes : " + this.nodes.keySet());
|
||||
this.data = this.modelInterface.createObject(this.properties, this.nodes);
|
||||
} else {
|
||||
if (this.properties.size() != 0) {
|
||||
throw new ExmlBuilderException("SubNode in tree can not have propoerties !!!!");
|
||||
}
|
||||
if (this.nodes.size() == 0) {
|
||||
this.data = new ArrayList<Object>();
|
||||
return;
|
||||
}
|
||||
if (this.nodes.size() > 1) {
|
||||
throw new ExmlBuilderException("SubNode in tree can not have more than 1 subNodes !!!!");
|
||||
}
|
||||
// check name of node
|
||||
List<Object> values = this.nodes.get(this.listNameModel);
|
||||
if (values == null) {
|
||||
throw new ExmlBuilderException("SubNode in tree name is wrong !!!! must be '" + this.listNameModel + "'");
|
||||
}
|
||||
// create real object ...
|
||||
this.data = values;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.atriasoft.eStringSerialize.StringSerializer;
|
||||
import org.atriasoft.exml.builder.IntrospectionModel;
|
||||
import org.atriasoft.exml.builder.IntrospectionModelFactory;
|
||||
import org.atriasoft.exml.builder.IntrospectionProperty;
|
||||
@ -79,7 +80,7 @@ public class GeneratorIntrospection implements Generator {
|
||||
Class<?> type = elem.getType();
|
||||
IntrospectionModel introspectionSub = null;
|
||||
if (type.isArray()) {
|
||||
Class<?> typeClass = elem.getSubType();
|
||||
Class<?> typeClass = elem.getType().componentType();
|
||||
String listTreeName = elem.getListName();
|
||||
introspectionSub = findOrCreate(ModelType.ARRAY, listTreeName, typeClass);
|
||||
} else if (List.class.isAssignableFrom(type)) {
|
||||
@ -87,12 +88,61 @@ public class GeneratorIntrospection implements Generator {
|
||||
String listTreeName = elem.getListName();
|
||||
introspectionSub = findOrCreate(ModelType.LIST, listTreeName, typeClass);
|
||||
} else {
|
||||
introspectionSub = findOrCreate(ModelType.NORMAL, null, data.getClass());
|
||||
introspectionSub = findOrCreate(ModelType.NORMAL, null, dataObj.getClass());
|
||||
}
|
||||
generateNode(dataObj, introspectionSub, name, tmpp, indent);
|
||||
}
|
||||
}
|
||||
|
||||
public <T> void generateArrayNode(final Class<T> clazz, final Object data, final IntrospectionModel model, final String nodeName, final StringBuilder tmpp, final int indent) throws ExmlBuilderException {
|
||||
//Class<?> clazzData = data.getClass();
|
||||
if (clazz.isPrimitive()) {
|
||||
if (clazz == byte.class) {
|
||||
byte[] datas = (byte[]) data;
|
||||
for (int iii=0; iii<datas.length; iii++) {
|
||||
generateNode(datas[iii], model, nodeName, tmpp, indent);
|
||||
}
|
||||
} else if (clazz == boolean.class) {
|
||||
boolean[] datas = (boolean[]) data;
|
||||
for (int iii=0; iii<datas.length; iii++) {
|
||||
generateNode(datas[iii], model, nodeName, tmpp, indent);
|
||||
}
|
||||
} else if (clazz == short.class) {
|
||||
short[] datas = (short[]) data;
|
||||
for (int iii=0; iii<datas.length; iii++) {
|
||||
generateNode(datas[iii], model, nodeName, tmpp, indent);
|
||||
}
|
||||
} else if (clazz == int.class) {
|
||||
int[] datas = (int[]) data;
|
||||
for (int iii=0; iii<datas.length; iii++) {
|
||||
generateNode(datas[iii], model, nodeName, tmpp, indent);
|
||||
}
|
||||
} else if (clazz == long.class) {
|
||||
long[] datas = (long[]) data;
|
||||
for (int iii=0; iii<datas.length; iii++) {
|
||||
generateNode(datas[iii], model, nodeName, tmpp, indent);
|
||||
}
|
||||
} else if (clazz == float.class) {
|
||||
float[] datas = (float[]) data;
|
||||
for (int iii=0; iii<datas.length; iii++) {
|
||||
generateNode(datas[iii], model, nodeName, tmpp, indent);
|
||||
}
|
||||
} else if (clazz == double.class) {
|
||||
double[] datas = (double[]) data;
|
||||
for (int iii=0; iii<datas.length; iii++) {
|
||||
generateNode(datas[iii], model, nodeName, tmpp, indent);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
@SuppressWarnings("unchecked")
|
||||
T[] datas = (T[]) data;
|
||||
for (int iii=0; iii<datas.length; iii++) {
|
||||
generateNode(datas[iii], model, nodeName, tmpp, indent);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void generateNode(final Object data, final IntrospectionModel model, final String nodeName, final StringBuilder tmpp, final int indent) throws ExmlBuilderException {
|
||||
if (model.isEndPoint()) {
|
||||
if (model.isList()) {
|
||||
@ -118,23 +168,35 @@ public class GeneratorIntrospection implements Generator {
|
||||
tmpp.append(">");
|
||||
}
|
||||
} else if (model.isArray()) {
|
||||
List<IntrospectionProperty> baseName = model.getNodes();
|
||||
List<String> baseName = model.getNodeAvaillable();
|
||||
if (baseName == null || baseName.size() == 0) {
|
||||
// mode render : <nodeName><val>aaa</val><val>bbb</val></nodeName>
|
||||
} else {
|
||||
// mode render : <nodeName>aaa</nodeName><nodeName>bbb</nodeName>
|
||||
|
||||
IntrospectionModel introspectionSub = findOrCreate(ModelType.NORMAL, null, model.getClassType());
|
||||
generateArrayNode(model.getClassType(), data, introspectionSub, nodeName, tmpp, indent);
|
||||
} else {
|
||||
// mode render : <nodeName><val>aaa</val><val>bbb</val></nodeName>
|
||||
}
|
||||
Log.error("lkjlk");
|
||||
} else if (model.isList()) {
|
||||
List<IntrospectionProperty> baseName = model.getNodes();
|
||||
List<String> baseName = model.getNodeAvaillable();
|
||||
if (baseName == null || baseName.size() == 0) {
|
||||
// mode render : <nodeName><val>aaa</val><val>bbb</val></nodeName>
|
||||
} else {
|
||||
// mode render : <nodeName>aaa</nodeName><nodeName>bbb</nodeName>
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
List<Object> datas = (List<Object>)data;
|
||||
for (Object elem : datas) {
|
||||
IntrospectionModel introspectionSub = findOrCreate(ModelType.NORMAL, null, elem.getClass());
|
||||
generateNode(elem, introspectionSub, nodeName, tmpp, indent);
|
||||
}
|
||||
} else {
|
||||
// mode render : <nodeName><val>aaa</val><val>bbb</val></nodeName>
|
||||
tmpp.append("<");
|
||||
tmpp.append(baseName.get(0));
|
||||
tmpp.append(">");
|
||||
tmpp.append(model.toString(data));
|
||||
tmpp.append("</");
|
||||
tmpp.append(baseName.get(0));
|
||||
tmpp.append(">");
|
||||
}
|
||||
Log.error("lkjlk");
|
||||
} else {
|
||||
Tools.addIndent(tmpp, indent);
|
||||
tmpp.append("<");
|
||||
|
@ -9,7 +9,7 @@ import io.scenarium.logger.LogLevel;
|
||||
import io.scenarium.logger.Logger;
|
||||
|
||||
public class Log {
|
||||
private static final boolean FORCE = true;
|
||||
private static final boolean FORCE = false;
|
||||
private static final String LIB_NAME = "exml";
|
||||
private static final String LIB_NAME_DRAW = Logger.getDrawableName(Log.LIB_NAME);
|
||||
private static final boolean PRINT_CRITICAL = Logger.getNeedPrint(Log.LIB_NAME, LogLevel.CRITICAL);
|
||||
|
@ -321,6 +321,94 @@ public class Tools {
|
||||
return out.toString();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static float[] parseFloatStringList(String data) {
|
||||
data = Tools.cleanNumberList(data);
|
||||
final String[] dataArray = data.split(";");
|
||||
final float[] out = new float[dataArray.length];
|
||||
int count = 0;
|
||||
for (final String str : dataArray) {
|
||||
out[count++] = Float.parseFloat(str);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
public static String toString(final float[] data) {
|
||||
StringBuilder out = new StringBuilder();
|
||||
for (int iii=0; iii<data.length; iii++) {
|
||||
if (iii != 0) {
|
||||
out.append(";");
|
||||
}
|
||||
out.append(data[iii]);
|
||||
}
|
||||
return out.toString();
|
||||
}
|
||||
public static Float[] parseFloatClassStringList(String data) {
|
||||
data = Tools.cleanNumberList(data);
|
||||
final String[] dataArray = data.split(";");
|
||||
final Float[] out = new Float[dataArray.length];
|
||||
int count = 0;
|
||||
for (final String str : dataArray) {
|
||||
out[count++] = Float.parseFloat(str);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
public static String toString(final Float[] data) {
|
||||
StringBuilder out = new StringBuilder();
|
||||
for (int iii=0; iii<data.length; iii++) {
|
||||
if (iii != 0) {
|
||||
out.append(";");
|
||||
}
|
||||
out.append(data[iii]);
|
||||
}
|
||||
return out.toString();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static double[] parseDoubleStringList(String data) {
|
||||
data = Tools.cleanNumberList(data);
|
||||
final String[] dataArray = data.split(";");
|
||||
final double[] out = new double[dataArray.length];
|
||||
int count = 0;
|
||||
for (final String str : dataArray) {
|
||||
out[count++] = Double.parseDouble(str);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
public static String toString(final double[] data) {
|
||||
StringBuilder out = new StringBuilder();
|
||||
for (int iii=0; iii<data.length; iii++) {
|
||||
if (iii != 0) {
|
||||
out.append(";");
|
||||
}
|
||||
out.append(data[iii]);
|
||||
}
|
||||
return out.toString();
|
||||
}
|
||||
public static Double[] parseDoubleClassStringList(String data) {
|
||||
data = Tools.cleanNumberList(data);
|
||||
final String[] dataArray = data.split(";");
|
||||
final Double[] out = new Double[dataArray.length];
|
||||
int count = 0;
|
||||
for (final String str : dataArray) {
|
||||
out[count++] = Double.parseDouble(str);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
public static String toString(final Double[] data) {
|
||||
StringBuilder out = new StringBuilder();
|
||||
for (int iii=0; iii<data.length; iii++) {
|
||||
if (iii != 0) {
|
||||
out.append(";");
|
||||
}
|
||||
out.append(data[iii]);
|
||||
}
|
||||
return out.toString();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static Short[] parseShortClassStringList(String data) {
|
||||
data = Tools.cleanNumberList(data);
|
||||
final String[] dataArray = data.split(";");
|
||||
@ -393,4 +481,5 @@ public class Tools {
|
||||
}
|
||||
|
||||
private Tools() {}
|
||||
|
||||
}
|
||||
|
@ -45,7 +45,10 @@ public class SerializerXml {
|
||||
private static void serializeComment(final XmlComment comment, final StringBuilder data, final int indent) {
|
||||
Tools.addIndent(data, indent);
|
||||
data.append("<!--");
|
||||
String commentData = comment.getValue();
|
||||
if (commentData != null) {
|
||||
data.append(comment.getValue());
|
||||
}
|
||||
data.append("-->");
|
||||
}
|
||||
|
||||
|
@ -21,14 +21,14 @@ public class ExmlTestAll {
|
||||
+ " <ex2 ploppp-plpl:erer=\"dfsdfsdfsdf\" lkmjmlk=\"156235\" sdfsdf=\"456321\"/>\n"
|
||||
+ " <exlkjl-_dsfg./>\n"
|
||||
+ " <ex2>Text example ...</ex2>\n"
|
||||
+ "</exemple>\n",
|
||||
+ "</exemple>",
|
||||
"< exemple\n >\n"
|
||||
+ " <ex2 ploppp-plpl:erer=\"dfsdfsdfsdf\" lkmjmlk=\"156235\" sdfsdf=456321 />\n"
|
||||
+ " <exlkjl-_dsfg./>\n"
|
||||
+ " <ex2>\n"
|
||||
+ " Text example ...\n"
|
||||
+ " </ex2>\n"
|
||||
+ "</exemple>\n",
|
||||
+ "</exemple>",
|
||||
-1);
|
||||
//@formatter:on
|
||||
}
|
||||
@ -40,14 +40,14 @@ public class ExmlTestAll {
|
||||
+" <ex2 ploppp-plpl:erer=\"dfsdfsdfsdf\" lkmjmlk=\"156235\" sdfsdf=\"456321\"/>\n"
|
||||
+" <exlkjl-_dsfg./>\n"
|
||||
+" <ex2>Text example ...</ex2>\n"
|
||||
+"</exemple>\n",
|
||||
+"</exemple>",
|
||||
"< exemple\n >\n"
|
||||
+" <ex2 ploppp-plpl:erer=\"dfsdfsdfsdf\" lkmjmlk=\"156235\" sdfsdf=456321 />\n"
|
||||
+" <exlkjl-_dsfg./>\n"
|
||||
+" <ex2>\n"
|
||||
+" Text example ...\n"
|
||||
+" </ex2>\n"
|
||||
+"</exemple>\n",
|
||||
+"</exemple>",
|
||||
-1,
|
||||
false);
|
||||
//@formatter:on
|
||||
@ -63,7 +63,7 @@ public class ExmlTestAll {
|
||||
+" <ex2>\n"
|
||||
+" Text example ...\n"
|
||||
+" </ex2>\n"
|
||||
+"</exemple>\n",
|
||||
+"</exemple>",
|
||||
1);
|
||||
//@formatter:on
|
||||
}
|
||||
|
@ -103,7 +103,7 @@ public class ExmlTestElement {
|
||||
|
||||
final XmlElement myElement = new XmlElement("NodeName");
|
||||
myElement.append(new XmlElement("jkjhkjhkh"));
|
||||
Assertions.assertEquals("<jkjhkjhkh/>\n", myElement.getText());
|
||||
Assertions.assertEquals("<jkjhkjhkh/>", myElement.getText());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -278,7 +278,13 @@ public class ExmlTestIntrospectionBoolean {
|
||||
Assertions.assertDoesNotThrow(() -> Exml.generate(elem, ExmlTestIntrospectionBoolean.NODE_NAME, builder));
|
||||
String dataTest = builder.toString();
|
||||
Log.warning("data generated: " + builder.toString());
|
||||
Assertions.assertEquals("<elem values=\"false;false;true;false;true\"/>", dataTest);
|
||||
Assertions.assertEquals("<elem>\n"
|
||||
+ " <values>false</values>\n"
|
||||
+ " <values>false</values>\n"
|
||||
+ " <values>true</values>\n"
|
||||
+ " <values>false</values>\n"
|
||||
+ " <values>true</values>\n"
|
||||
+ "</elem>", dataTest);
|
||||
|
||||
final TestListNodeBoolean root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestListNodeBoolean.class, ExmlTestIntrospectionBoolean.NODE_NAME));
|
||||
Assertions.assertEquals(5, root.values.size());
|
||||
@ -374,7 +380,8 @@ public class ExmlTestIntrospectionBoolean {
|
||||
Assertions.assertEquals(true, root.getValues()[4]);
|
||||
}
|
||||
|
||||
public class TestListNodeBooleanFunc {
|
||||
// Note this is set in static to test an other part of code...
|
||||
public static class TestListNodeBooleanFunc {
|
||||
private List<Boolean> values;
|
||||
|
||||
public List<Boolean> getValues() {
|
||||
@ -394,7 +401,13 @@ public class ExmlTestIntrospectionBoolean {
|
||||
Assertions.assertDoesNotThrow(() -> Exml.generate(elem, ExmlTestIntrospectionBoolean.NODE_NAME, builder));
|
||||
String dataTest = builder.toString();
|
||||
Log.warning("data generated: " + builder.toString());
|
||||
Assertions.assertEquals("<elem values=\"false;false;true;false;true\"/>", dataTest);
|
||||
Assertions.assertEquals("<elem>\n"
|
||||
+ " <values>false</values>\n"
|
||||
+ " <values>false</values>\n"
|
||||
+ " <values>true</values>\n"
|
||||
+ " <values>false</values>\n"
|
||||
+ " <values>true</values>\n"
|
||||
+ "</elem>", dataTest);
|
||||
|
||||
final TestListNodeBooleanFunc root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestListNodeBooleanFunc.class, ExmlTestIntrospectionBoolean.NODE_NAME));
|
||||
Assertions.assertEquals(5, root.getValues().size());
|
||||
@ -404,35 +417,5 @@ public class ExmlTestIntrospectionBoolean {
|
||||
Assertions.assertEquals(false, root.getValues().get(3));
|
||||
Assertions.assertEquals(true, root.getValues().get(4));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
@ -5,6 +5,8 @@
|
||||
*/
|
||||
package test.atriasoft.exml;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.atriasoft.exml.Exml;
|
||||
import org.atriasoft.exml.annotation.XmlDefaultAttibute;
|
||||
|
||||
@ -12,13 +14,36 @@ import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
||||
public class ExmlTestIntrospectionBooleanNative {
|
||||
private static final String NODE_NAME = "elem";
|
||||
public static final String NODE_NAME = "elem";
|
||||
@BeforeAll
|
||||
public static void beforeClass() {
|
||||
Log.verbose("----------------------------------------------------------------");
|
||||
}
|
||||
|
||||
@XmlDefaultAttibute
|
||||
public class TestBooleanNative {
|
||||
public boolean valueA;
|
||||
public boolean valueB;
|
||||
}
|
||||
@Test
|
||||
public void testModelBooleanNative() {
|
||||
TestBooleanNative elem = new TestBooleanNative();
|
||||
elem.valueA = false;
|
||||
elem.valueB = true;
|
||||
|
||||
StringBuilder builder = new StringBuilder();
|
||||
Assertions.assertDoesNotThrow(() -> Exml.generate(elem, ExmlTestIntrospectionBooleanNative.NODE_NAME, builder));
|
||||
String dataTest = builder.toString();
|
||||
Log.warning("data generated: " + builder.toString());
|
||||
Assertions.assertEquals("<elem valueA=\"false\" valueB=\"true\"/>", dataTest);
|
||||
|
||||
final TestBooleanNative root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestBooleanNative.class, ExmlTestIntrospectionBooleanNative.NODE_NAME));
|
||||
Assertions.assertEquals(false, root.valueA);
|
||||
Assertions.assertEquals(true, root.valueB);
|
||||
}
|
||||
|
||||
@XmlDefaultAttibute
|
||||
public class TestArrayBooleanNative {
|
||||
public boolean[] values;
|
||||
@ -29,13 +54,13 @@ public class ExmlTestIntrospectionBooleanNative {
|
||||
elem.values = new boolean[] {false, false, true, false, true};
|
||||
|
||||
StringBuilder builder = new StringBuilder();
|
||||
Assertions.assertDoesNotThrow(() -> Exml.generate(elem, ExmlTestIntrospectionBoolean.NODE_NAME, builder));
|
||||
final String dataTest = builder.toString();
|
||||
Assertions.assertEquals("<elem values=\"false;true\"/>", dataTest);
|
||||
Assertions.assertDoesNotThrow(() -> Exml.generate(elem, ExmlTestIntrospectionBooleanNative.NODE_NAME, builder));
|
||||
String dataTest = builder.toString();
|
||||
Log.warning("data generated: " + builder.toString());
|
||||
Assertions.assertEquals("<elem values=\"false;false;true;false;true\"/>", dataTest);
|
||||
|
||||
final TestArrayBooleanNative root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestArrayBooleanNative.class, ExmlTestIntrospectionBooleanNative.NODE_NAME));
|
||||
Assertions.assertEquals(1, root.values.length);
|
||||
Assertions.assertEquals(5, root.values.length);
|
||||
Assertions.assertEquals(false, root.values[0]);
|
||||
Assertions.assertEquals(false, root.values[1]);
|
||||
Assertions.assertEquals(true, root.values[2]);
|
||||
@ -43,6 +68,201 @@ public class ExmlTestIntrospectionBooleanNative {
|
||||
Assertions.assertEquals(true, root.values[4]);
|
||||
}
|
||||
|
||||
@XmlDefaultAttibute
|
||||
public class TestBooleanFunc {
|
||||
private boolean valueA;
|
||||
private boolean valueB;
|
||||
public boolean isValueA() {
|
||||
return this.valueA;
|
||||
}
|
||||
public void setValueA(final boolean valueA) {
|
||||
this.valueA = valueA;
|
||||
}
|
||||
public boolean isValueB() {
|
||||
return this.valueB;
|
||||
}
|
||||
public void setValueB(final boolean valueB) {
|
||||
this.valueB = valueB;
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testModelBooleanFunc() {
|
||||
TestBooleanFunc elem = new TestBooleanFunc();
|
||||
elem.setValueA(false);
|
||||
elem.setValueB(true);
|
||||
|
||||
StringBuilder builder = new StringBuilder();
|
||||
Assertions.assertDoesNotThrow(() -> Exml.generate(elem, ExmlTestIntrospectionBooleanNative.NODE_NAME, builder));
|
||||
String dataTest = builder.toString();
|
||||
Log.warning("data generated: " + builder.toString());
|
||||
Assertions.assertEquals("<elem valueA=\"false\" valueB=\"true\"/>", dataTest);
|
||||
|
||||
final TestBooleanFunc root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestBooleanFunc.class, ExmlTestIntrospectionBooleanNative.NODE_NAME));
|
||||
Assertions.assertEquals(false, root.isValueA());
|
||||
Assertions.assertEquals(true, root.isValueB());
|
||||
}
|
||||
|
||||
@XmlDefaultAttibute
|
||||
public class TestArrayBooleanFunc {
|
||||
private boolean[] values;
|
||||
|
||||
public boolean[] getValues() {
|
||||
return this.values;
|
||||
}
|
||||
|
||||
public void setValues(final boolean[] values) {
|
||||
this.values = values;
|
||||
}
|
||||
|
||||
}
|
||||
@Test
|
||||
public void testModelArrayBooleanFunc() {
|
||||
TestArrayBooleanFunc elem = new TestArrayBooleanFunc();
|
||||
elem.setValues(new boolean[] {false, false, true, false, true});
|
||||
|
||||
StringBuilder builder = new StringBuilder();
|
||||
Assertions.assertDoesNotThrow(() -> Exml.generate(elem, ExmlTestIntrospectionBooleanNative.NODE_NAME, builder));
|
||||
String dataTest = builder.toString();
|
||||
Log.warning("data generated: " + builder.toString());
|
||||
Assertions.assertEquals("<elem values=\"false;false;true;false;true\"/>", dataTest);
|
||||
|
||||
final TestArrayBooleanFunc root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestArrayBooleanFunc.class, ExmlTestIntrospectionBooleanNative.NODE_NAME));
|
||||
Assertions.assertEquals(5, root.getValues().length);
|
||||
Assertions.assertEquals(false, root.getValues()[0]);
|
||||
Assertions.assertEquals(false, root.getValues()[1]);
|
||||
Assertions.assertEquals(true, root.getValues()[2]);
|
||||
Assertions.assertEquals(false, root.getValues()[3]);
|
||||
Assertions.assertEquals(true, root.getValues()[4]);
|
||||
}
|
||||
|
||||
public class TestNodeBooleanNative {
|
||||
public boolean valueA;
|
||||
public boolean valueB;
|
||||
}
|
||||
@Test
|
||||
public void testModelNodeBooleanNative() {
|
||||
TestNodeBooleanNative elem = new TestNodeBooleanNative();
|
||||
elem.valueA = false;
|
||||
elem.valueB = true;
|
||||
|
||||
StringBuilder builder = new StringBuilder();
|
||||
Assertions.assertDoesNotThrow(() -> Exml.generate(elem, ExmlTestIntrospectionBooleanNative.NODE_NAME, builder));
|
||||
String dataTest = builder.toString();
|
||||
Log.warning("data generated: " + builder.toString());
|
||||
Assertions.assertEquals("<elem>\n"
|
||||
+ " <valueA>false</valueA>\n"
|
||||
+ " <valueB>true</valueB>\n"
|
||||
+ "</elem>", dataTest);
|
||||
|
||||
final TestNodeBooleanNative root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestNodeBooleanNative.class, ExmlTestIntrospectionBooleanNative.NODE_NAME));
|
||||
Assertions.assertEquals(false, root.valueA);
|
||||
Assertions.assertEquals(true, root.valueB);
|
||||
}
|
||||
|
||||
public class TestArrayNodeBooleanNative {
|
||||
public boolean[] values;
|
||||
}
|
||||
@Test
|
||||
public void testModelArrayNodeBooleanNative() {
|
||||
TestArrayNodeBooleanNative elem = new TestArrayNodeBooleanNative();
|
||||
elem.values = new boolean[] {false, false, true, false, true};
|
||||
|
||||
StringBuilder builder = new StringBuilder();
|
||||
Assertions.assertDoesNotThrow(() -> Exml.generate(elem, ExmlTestIntrospectionBooleanNative.NODE_NAME, builder));
|
||||
String dataTest = builder.toString();
|
||||
Log.warning("data generated: " + builder.toString());
|
||||
Assertions.assertEquals("<elem>\n"
|
||||
+ " <values>false</values>\n"
|
||||
+ " <values>false</values>\n"
|
||||
+ " <values>true</values>\n"
|
||||
+ " <values>false</values>\n"
|
||||
+ " <values>true</values>\n"
|
||||
+ "</elem>", dataTest);
|
||||
|
||||
final TestArrayNodeBooleanNative root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestArrayNodeBooleanNative.class, ExmlTestIntrospectionBooleanNative.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]);
|
||||
}
|
||||
|
||||
public class TestNodeBooleanFunc {
|
||||
private boolean valueA;
|
||||
private boolean valueB;
|
||||
public boolean isValueA() {
|
||||
return this.valueA;
|
||||
}
|
||||
public void setValueA(final boolean valueA) {
|
||||
this.valueA = valueA;
|
||||
}
|
||||
public boolean isValueB() {
|
||||
return this.valueB;
|
||||
}
|
||||
public void setValueB(final boolean valueB) {
|
||||
this.valueB = valueB;
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testModelNodeBooleanFunc() {
|
||||
TestNodeBooleanFunc elem = new TestNodeBooleanFunc();
|
||||
elem.setValueA(false);
|
||||
elem.setValueB(true);
|
||||
|
||||
StringBuilder builder = new StringBuilder();
|
||||
Assertions.assertDoesNotThrow(() -> Exml.generate(elem, ExmlTestIntrospectionBooleanNative.NODE_NAME, builder));
|
||||
String dataTest = builder.toString();
|
||||
Log.warning("data generated: " + builder.toString());
|
||||
Assertions.assertEquals("<elem>\n"
|
||||
+ " <valueA>false</valueA>\n"
|
||||
+ " <valueB>true</valueB>\n"
|
||||
+ "</elem>", dataTest);
|
||||
|
||||
final TestNodeBooleanFunc root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestNodeBooleanFunc.class, ExmlTestIntrospectionBooleanNative.NODE_NAME));
|
||||
Assertions.assertEquals(false, root.isValueA());
|
||||
Assertions.assertEquals(true, root.isValueB());
|
||||
}
|
||||
|
||||
public class TestArrayNodeBooleanFunc {
|
||||
private boolean[] values;
|
||||
|
||||
public boolean[] getValues() {
|
||||
return this.values;
|
||||
}
|
||||
|
||||
public void setValues(final boolean[] values) {
|
||||
this.values = values;
|
||||
}
|
||||
|
||||
}
|
||||
@Test
|
||||
public void testModelArrayNodeBooleanFunc() {
|
||||
TestArrayNodeBooleanFunc elem = new TestArrayNodeBooleanFunc();
|
||||
elem.setValues(new boolean[] {false, false, true, false, true});
|
||||
|
||||
StringBuilder builder = new StringBuilder();
|
||||
Assertions.assertDoesNotThrow(() -> Exml.generate(elem, ExmlTestIntrospectionBooleanNative.NODE_NAME, builder));
|
||||
String dataTest = builder.toString();
|
||||
Log.warning("data generated: " + builder.toString());
|
||||
Assertions.assertEquals("<elem>\n"
|
||||
+ " <values>false</values>\n"
|
||||
+ " <values>false</values>\n"
|
||||
+ " <values>true</values>\n"
|
||||
+ " <values>false</values>\n"
|
||||
+ " <values>true</values>\n"
|
||||
+ "</elem>", dataTest);
|
||||
|
||||
final TestArrayNodeBooleanFunc root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestArrayNodeBooleanFunc.class, ExmlTestIntrospectionBooleanNative.NODE_NAME));
|
||||
Assertions.assertEquals(5, root.getValues().length);
|
||||
Assertions.assertEquals(false, root.getValues()[0]);
|
||||
Assertions.assertEquals(false, root.getValues()[1]);
|
||||
Assertions.assertEquals(true, root.getValues()[2]);
|
||||
Assertions.assertEquals(false, root.getValues()[3]);
|
||||
Assertions.assertEquals(true, root.getValues()[4]);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
415
test/src/test/atriasoft/exml/ExmlTestIntrospectionByte.java
Normal file
415
test/src/test/atriasoft/exml/ExmlTestIntrospectionByte.java
Normal file
@ -0,0 +1,415 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2021, Edouard DUPIN, all right reserved
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
package test.atriasoft.exml;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.atriasoft.exml.Exml;
|
||||
import org.atriasoft.exml.annotation.XmlDefaultAttibute;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class ExmlTestIntrospectionByte {
|
||||
static final String NODE_NAME = "elem";
|
||||
@BeforeAll
|
||||
public static void beforeClass() {
|
||||
Log.warning("================================================================");
|
||||
}
|
||||
|
||||
@XmlDefaultAttibute
|
||||
public class TestByte {
|
||||
public Byte valueA;
|
||||
public Byte valueB;
|
||||
public Byte valueNull;
|
||||
}
|
||||
@Test
|
||||
public void testModelByte() {
|
||||
TestByte elem = new TestByte();
|
||||
elem.valueA = (byte)12;
|
||||
elem.valueB = (byte)-13;
|
||||
elem.valueNull = null;
|
||||
|
||||
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("<elem valueA=\"12\" valueB=\"-13\"/>", dataTest);
|
||||
|
||||
final TestByte root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestByte.class, ExmlTestIntrospectionByte.NODE_NAME));
|
||||
Assertions.assertEquals((byte)12, root.valueA);
|
||||
Assertions.assertEquals((byte)-13, root.valueB);
|
||||
Assertions.assertEquals(null, root.valueNull);
|
||||
}
|
||||
|
||||
@XmlDefaultAttibute
|
||||
public class TestArrayByte {
|
||||
public Byte[] values;
|
||||
}
|
||||
@Test
|
||||
public void testModelArrayByte() {
|
||||
TestArrayByte elem = new TestArrayByte();
|
||||
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("<elem values=\"12;-13;33;78;-127\"/>", dataTest);
|
||||
|
||||
final TestArrayByte root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestArrayByte.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]);
|
||||
}
|
||||
|
||||
@XmlDefaultAttibute
|
||||
public class TestListByte {
|
||||
public List<Byte> values;
|
||||
}
|
||||
@Test
|
||||
public void testModelListByte() {
|
||||
TestListByte elem = new TestListByte();
|
||||
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("<elem values=\"12;-13;33;78;-127\"/>", dataTest);
|
||||
|
||||
final TestListByte root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestListByte.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));
|
||||
}
|
||||
|
||||
|
||||
@XmlDefaultAttibute
|
||||
public class TestByteFunc {
|
||||
private Byte valueA;
|
||||
private Byte valueB;
|
||||
private Byte valueNull;
|
||||
public Byte isValueA() {
|
||||
return this.valueA;
|
||||
}
|
||||
public void setValueA(final Byte valueA) {
|
||||
this.valueA = valueA;
|
||||
}
|
||||
public Byte isValueB() {
|
||||
return this.valueB;
|
||||
}
|
||||
public void setValueB(final Byte valueB) {
|
||||
this.valueB = valueB;
|
||||
}
|
||||
public Byte isValueNull() {
|
||||
return this.valueNull;
|
||||
}
|
||||
public void setValueNull(final Byte valueNull) {
|
||||
this.valueNull = valueNull;
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testModelByteFunc() {
|
||||
TestByteFunc elem = new TestByteFunc();
|
||||
elem.setValueA((byte)-55);
|
||||
elem.setValueB((byte)57);
|
||||
elem.setValueNull(null);
|
||||
|
||||
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("<elem valueA=\"-55\" valueB=\"57\"/>", dataTest);
|
||||
|
||||
final TestByteFunc root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestByteFunc.class, ExmlTestIntrospectionByte.NODE_NAME));
|
||||
Assertions.assertEquals((byte)-55, root.isValueA());
|
||||
Assertions.assertEquals((byte)57, root.isValueB());
|
||||
Assertions.assertEquals(null, root.isValueNull());
|
||||
}
|
||||
|
||||
@XmlDefaultAttibute
|
||||
public class TestArrayByteFunc {
|
||||
private Byte[] values;
|
||||
|
||||
public Byte[] getValues() {
|
||||
return this.values;
|
||||
}
|
||||
|
||||
public void setValues(final Byte[] values) {
|
||||
this.values = values;
|
||||
}
|
||||
|
||||
}
|
||||
@Test
|
||||
public void testModelArrayByteFunc() {
|
||||
TestArrayByteFunc elem = new TestArrayByteFunc();
|
||||
elem.setValues(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("<elem values=\"12;-13;33;78;-127\"/>", dataTest);
|
||||
|
||||
final TestArrayByteFunc root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestArrayByteFunc.class, ExmlTestIntrospectionByte.NODE_NAME));
|
||||
Assertions.assertEquals(5, root.getValues().length);
|
||||
Assertions.assertEquals((byte)12, root.getValues()[0]);
|
||||
Assertions.assertEquals((byte)-13, root.getValues()[1]);
|
||||
Assertions.assertEquals((byte)33, root.getValues()[2]);
|
||||
Assertions.assertEquals((byte)78, root.getValues()[3]);
|
||||
Assertions.assertEquals((byte)-127, root.getValues()[4]);
|
||||
}
|
||||
|
||||
@XmlDefaultAttibute
|
||||
public class TestListByteFunc {
|
||||
private List<Byte> values;
|
||||
|
||||
public List<Byte> getValues() {
|
||||
return this.values;
|
||||
}
|
||||
|
||||
public void setValues(final List<Byte> values) {
|
||||
this.values = values;
|
||||
}
|
||||
}
|
||||
@Test
|
||||
public void testModelListByteFunc() {
|
||||
TestListByteFunc elem = new TestListByteFunc();
|
||||
elem.setValues(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("<elem values=\"12;-13;33;78;-127\"/>", dataTest);
|
||||
|
||||
final TestListByteFunc root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestListByteFunc.class, ExmlTestIntrospectionByte.NODE_NAME));
|
||||
Assertions.assertEquals(5, root.getValues().size());
|
||||
Assertions.assertEquals((byte)12, root.getValues().get(0));
|
||||
Assertions.assertEquals((byte)-13, root.getValues().get(1));
|
||||
Assertions.assertEquals((byte)33, root.getValues().get(2));
|
||||
Assertions.assertEquals((byte)78, root.getValues().get(3));
|
||||
Assertions.assertEquals((byte)-127, root.getValues().get(4));
|
||||
}
|
||||
|
||||
public class TestNodeByte {
|
||||
public Byte valueA;
|
||||
public Byte valueB;
|
||||
public Byte valueNull;
|
||||
}
|
||||
@Test
|
||||
public void testModelNodeByte() {
|
||||
TestNodeByte elem = new TestNodeByte();
|
||||
elem.valueA = (byte)11;
|
||||
elem.valueB = (byte)-120;
|
||||
elem.valueNull = null;
|
||||
|
||||
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("<elem>\n"
|
||||
+ " <valueA>11</valueA>\n"
|
||||
+ " <valueB>-120</valueB>\n"
|
||||
+ "</elem>", dataTest);
|
||||
|
||||
final TestNodeByte root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestNodeByte.class, ExmlTestIntrospectionByte.NODE_NAME));
|
||||
Assertions.assertEquals((byte)11, root.valueA);
|
||||
Assertions.assertEquals((byte)-120, root.valueB);
|
||||
Assertions.assertEquals(null, root.valueNull);
|
||||
}
|
||||
|
||||
public class TestArrayNodeByte {
|
||||
public Byte[] values;
|
||||
}
|
||||
@Test
|
||||
public void testModelArrayNodeByte() {
|
||||
TestArrayNodeByte elem = new TestArrayNodeByte();
|
||||
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("<elem>\n"
|
||||
+ " <values>12</values>\n"
|
||||
+ " <values>-13</values>\n"
|
||||
+ " <values>33</values>\n"
|
||||
+ " <values>78</values>\n"
|
||||
+ " <values>-127</values>\n"
|
||||
+ "</elem>", dataTest);
|
||||
|
||||
final TestArrayNodeByte root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestArrayNodeByte.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]);
|
||||
}
|
||||
|
||||
public class TestListNodeByte {
|
||||
public List<Byte> values;
|
||||
}
|
||||
@Test
|
||||
public void testModelListNodeByte() {
|
||||
TestListNodeByte elem = new TestListNodeByte();
|
||||
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("<elem>\n"
|
||||
+ " <values>12</values>\n"
|
||||
+ " <values>-13</values>\n"
|
||||
+ " <values>33</values>\n"
|
||||
+ " <values>78</values>\n"
|
||||
+ " <values>-127</values>\n"
|
||||
+ "</elem>", dataTest);
|
||||
|
||||
final TestListNodeByte root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestListNodeByte.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 TestNodeByteFunc {
|
||||
private Byte valueA;
|
||||
private Byte valueB;
|
||||
private Byte valueNull;
|
||||
public Byte isValueA() {
|
||||
return this.valueA;
|
||||
}
|
||||
public void setValueA(final Byte valueA) {
|
||||
this.valueA = valueA;
|
||||
}
|
||||
public Byte isValueB() {
|
||||
return this.valueB;
|
||||
}
|
||||
public void setValueB(final Byte valueB) {
|
||||
this.valueB = valueB;
|
||||
}
|
||||
public Byte isValueNull() {
|
||||
return this.valueNull;
|
||||
}
|
||||
public void setValueNull(final Byte valueNull) {
|
||||
this.valueNull = valueNull;
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testModelNodeByteFunc() {
|
||||
TestNodeByteFunc elem = new TestNodeByteFunc();
|
||||
elem.setValueA((byte)54);
|
||||
elem.setValueB((byte)-68);
|
||||
elem.setValueNull(null);
|
||||
|
||||
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("<elem>\n"
|
||||
+ " <valueA>54</valueA>\n"
|
||||
+ " <valueB>-68</valueB>\n"
|
||||
+ "</elem>", dataTest);
|
||||
|
||||
final TestNodeByteFunc root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestNodeByteFunc.class, ExmlTestIntrospectionByte.NODE_NAME));
|
||||
Assertions.assertEquals((byte)54, root.isValueA());
|
||||
Assertions.assertEquals((byte)-68, root.isValueB());
|
||||
Assertions.assertEquals(null, root.isValueNull());
|
||||
}
|
||||
|
||||
public class TestArrayNodeByteFunc {
|
||||
private Byte[] values;
|
||||
|
||||
public Byte[] getValues() {
|
||||
return this.values;
|
||||
}
|
||||
|
||||
public void setValues(final Byte[] values) {
|
||||
this.values = values;
|
||||
}
|
||||
|
||||
}
|
||||
@Test
|
||||
public void testModelArrayNodeByteFunc() {
|
||||
TestArrayNodeByteFunc elem = new TestArrayNodeByteFunc();
|
||||
elem.setValues(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("<elem>\n"
|
||||
+ " <values>12</values>\n"
|
||||
+ " <values>-13</values>\n"
|
||||
+ " <values>33</values>\n"
|
||||
+ " <values>78</values>\n"
|
||||
+ " <values>-127</values>\n"
|
||||
+ "</elem>", dataTest);
|
||||
|
||||
final TestArrayNodeByteFunc root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestArrayNodeByteFunc.class, ExmlTestIntrospectionByte.NODE_NAME));
|
||||
Assertions.assertEquals(5, root.getValues().length);
|
||||
Assertions.assertEquals((byte)12, root.getValues()[0]);
|
||||
Assertions.assertEquals((byte)-13, root.getValues()[1]);
|
||||
Assertions.assertEquals((byte)33, root.getValues()[2]);
|
||||
Assertions.assertEquals((byte)78, root.getValues()[3]);
|
||||
Assertions.assertEquals((byte)-127, root.getValues()[4]);
|
||||
}
|
||||
|
||||
// Note this is set in static to test an other part of code...
|
||||
public static class TestListNodeByteFunc {
|
||||
private List<Byte> values;
|
||||
|
||||
public List<Byte> getValues() {
|
||||
return this.values;
|
||||
}
|
||||
|
||||
public void setValues(final List<Byte> values) {
|
||||
this.values = values;
|
||||
}
|
||||
}
|
||||
@Test
|
||||
public void testModelListNodeByteFunc() {
|
||||
TestListNodeByteFunc elem = new TestListNodeByteFunc();
|
||||
elem.setValues(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("<elem>\n"
|
||||
+ " <values>12</values>\n"
|
||||
+ " <values>-13</values>\n"
|
||||
+ " <values>33</values>\n"
|
||||
+ " <values>78</values>\n"
|
||||
+ " <values>-127</values>\n"
|
||||
+ "</elem>", dataTest);
|
||||
|
||||
final TestListNodeByteFunc root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestListNodeByteFunc.class, ExmlTestIntrospectionByte.NODE_NAME));
|
||||
Assertions.assertEquals(5, root.getValues().size());
|
||||
Assertions.assertEquals((byte)12, root.getValues().get(0));
|
||||
Assertions.assertEquals((byte)-13, root.getValues().get(1));
|
||||
Assertions.assertEquals((byte)33, root.getValues().get(2));
|
||||
Assertions.assertEquals((byte)78, root.getValues().get(3));
|
||||
Assertions.assertEquals((byte)-127, root.getValues().get(4));
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,267 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2021, Edouard DUPIN, all right reserved
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
package test.atriasoft.exml;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.atriasoft.exml.Exml;
|
||||
import org.atriasoft.exml.annotation.XmlDefaultAttibute;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class ExmlTestIntrospectionByteNative {
|
||||
static final String NODE_NAME = "elem";
|
||||
@BeforeAll
|
||||
public static void beforeClass() {
|
||||
Log.warning("================================================================");
|
||||
}
|
||||
|
||||
@XmlDefaultAttibute
|
||||
public class TestByteNative {
|
||||
public byte valueA;
|
||||
public byte valueB;
|
||||
}
|
||||
@Test
|
||||
public void testModelByteNative() {
|
||||
TestByteNative elem = new TestByteNative();
|
||||
elem.valueA = (byte)12;
|
||||
elem.valueB = (byte)-13;
|
||||
|
||||
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("<elem valueA=\"12\" valueB=\"-13\"/>", dataTest);
|
||||
|
||||
final TestByteNative root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestByteNative.class, ExmlTestIntrospectionByte.NODE_NAME));
|
||||
Assertions.assertEquals((byte)12, root.valueA);
|
||||
Assertions.assertEquals((byte)-13, root.valueB);
|
||||
}
|
||||
|
||||
@XmlDefaultAttibute
|
||||
public class TestArrayByteNative {
|
||||
public byte[] values;
|
||||
}
|
||||
@Test
|
||||
public void testModelArrayByteNative() {
|
||||
TestArrayByteNative elem = new TestArrayByteNative();
|
||||
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("<elem values=\"12;-13;33;78;-127\"/>", dataTest);
|
||||
|
||||
final TestArrayByteNative root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestArrayByteNative.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]);
|
||||
}
|
||||
|
||||
@XmlDefaultAttibute
|
||||
public class TestbyteFunc {
|
||||
private byte valueA;
|
||||
private byte valueB;
|
||||
public byte isValueA() {
|
||||
return this.valueA;
|
||||
}
|
||||
public void setValueA(final byte valueA) {
|
||||
this.valueA = valueA;
|
||||
}
|
||||
public byte isValueB() {
|
||||
return this.valueB;
|
||||
}
|
||||
public void setValueB(final byte valueB) {
|
||||
this.valueB = valueB;
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testModelByteFunc() {
|
||||
TestbyteFunc elem = new TestbyteFunc();
|
||||
elem.setValueA((byte)-55);
|
||||
elem.setValueB((byte)57);
|
||||
|
||||
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("<elem valueA=\"-55\" valueB=\"57\"/>", dataTest);
|
||||
|
||||
final TestbyteFunc root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestbyteFunc.class, ExmlTestIntrospectionByte.NODE_NAME));
|
||||
Assertions.assertEquals((byte)-55, root.isValueA());
|
||||
Assertions.assertEquals((byte)57, root.isValueB());
|
||||
}
|
||||
|
||||
@XmlDefaultAttibute
|
||||
public class TestArrayByteFunc {
|
||||
private byte[] values;
|
||||
|
||||
public byte[] getValues() {
|
||||
return this.values;
|
||||
}
|
||||
|
||||
public void setValues(final byte[] values) {
|
||||
this.values = values;
|
||||
}
|
||||
|
||||
}
|
||||
@Test
|
||||
public void testModelArrayByteFunc() {
|
||||
TestArrayByteFunc elem = new TestArrayByteFunc();
|
||||
elem.setValues(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("<elem values=\"12;-13;33;78;-127\"/>", dataTest);
|
||||
|
||||
final TestArrayByteFunc root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestArrayByteFunc.class, ExmlTestIntrospectionByte.NODE_NAME));
|
||||
Assertions.assertEquals(5, root.getValues().length);
|
||||
Assertions.assertEquals((byte)12, root.getValues()[0]);
|
||||
Assertions.assertEquals((byte)-13, root.getValues()[1]);
|
||||
Assertions.assertEquals((byte)33, root.getValues()[2]);
|
||||
Assertions.assertEquals((byte)78, root.getValues()[3]);
|
||||
Assertions.assertEquals((byte)-127, root.getValues()[4]);
|
||||
}
|
||||
|
||||
public class TestNodeByteNative {
|
||||
public byte valueA;
|
||||
public byte valueB;
|
||||
}
|
||||
@Test
|
||||
public void testModelNodeByteNative() {
|
||||
TestNodeByteNative elem = new TestNodeByteNative();
|
||||
elem.valueA = (byte)11;
|
||||
elem.valueB = (byte)-120;
|
||||
|
||||
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("<elem>\n"
|
||||
+ " <valueA>11</valueA>\n"
|
||||
+ " <valueB>-120</valueB>\n"
|
||||
+ "</elem>", dataTest);
|
||||
|
||||
final TestNodeByteNative root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestNodeByteNative.class, ExmlTestIntrospectionByte.NODE_NAME));
|
||||
Assertions.assertEquals((byte)11, root.valueA);
|
||||
Assertions.assertEquals((byte)-120, root.valueB);
|
||||
}
|
||||
|
||||
public class TestArrayNodeByteNative {
|
||||
public byte[] values;
|
||||
}
|
||||
@Test
|
||||
public void testModelArrayNodebyteNative() {
|
||||
TestArrayNodeByteNative elem = new TestArrayNodeByteNative();
|
||||
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("<elem>\n"
|
||||
+ " <values>12</values>\n"
|
||||
+ " <values>-13</values>\n"
|
||||
+ " <values>33</values>\n"
|
||||
+ " <values>78</values>\n"
|
||||
+ " <values>-127</values>\n"
|
||||
+ "</elem>", dataTest);
|
||||
|
||||
final TestArrayNodeByteNative root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestArrayNodeByteNative.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]);
|
||||
}
|
||||
|
||||
public class TestNodebyteFunc {
|
||||
private byte valueA;
|
||||
private byte valueB;
|
||||
public byte isValueA() {
|
||||
return this.valueA;
|
||||
}
|
||||
public void setValueA(final byte valueA) {
|
||||
this.valueA = valueA;
|
||||
}
|
||||
public byte isValueB() {
|
||||
return this.valueB;
|
||||
}
|
||||
public void setValueB(final byte valueB) {
|
||||
this.valueB = valueB;
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testModelNodeByteFunc() {
|
||||
TestNodebyteFunc elem = new TestNodebyteFunc();
|
||||
elem.setValueA((byte)54);
|
||||
elem.setValueB((byte)-68);
|
||||
|
||||
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("<elem>\n"
|
||||
+ " <valueA>54</valueA>\n"
|
||||
+ " <valueB>-68</valueB>\n"
|
||||
+ "</elem>", dataTest);
|
||||
|
||||
final TestNodebyteFunc root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestNodebyteFunc.class, ExmlTestIntrospectionByte.NODE_NAME));
|
||||
Assertions.assertEquals((byte)54, root.isValueA());
|
||||
Assertions.assertEquals((byte)-68, root.isValueB());
|
||||
}
|
||||
|
||||
public class TestArrayNodeByteFunc {
|
||||
private byte[] values;
|
||||
|
||||
public byte[] getValues() {
|
||||
return this.values;
|
||||
}
|
||||
|
||||
public void setValues(final byte[] values) {
|
||||
this.values = values;
|
||||
}
|
||||
|
||||
}
|
||||
@Test
|
||||
public void testModelArrayNodeByteFunc() {
|
||||
TestArrayNodeByteFunc elem = new TestArrayNodeByteFunc();
|
||||
elem.setValues(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("<elem>\n"
|
||||
+ " <values>12</values>\n"
|
||||
+ " <values>-13</values>\n"
|
||||
+ " <values>33</values>\n"
|
||||
+ " <values>78</values>\n"
|
||||
+ " <values>-127</values>\n"
|
||||
+ "</elem>", dataTest);
|
||||
|
||||
final TestArrayNodeByteFunc root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestArrayNodeByteFunc.class, ExmlTestIntrospectionByte.NODE_NAME));
|
||||
Assertions.assertEquals(5, root.getValues().length);
|
||||
Assertions.assertEquals((byte)12, root.getValues()[0]);
|
||||
Assertions.assertEquals((byte)-13, root.getValues()[1]);
|
||||
Assertions.assertEquals((byte)33, root.getValues()[2]);
|
||||
Assertions.assertEquals((byte)78, root.getValues()[3]);
|
||||
Assertions.assertEquals((byte)-127, root.getValues()[4]);
|
||||
}
|
||||
|
||||
}
|
||||
|
415
test/src/test/atriasoft/exml/ExmlTestIntrospectionDouble.java
Normal file
415
test/src/test/atriasoft/exml/ExmlTestIntrospectionDouble.java
Normal file
@ -0,0 +1,415 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2021, Edouard DUPIN, all right reserved
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
package test.atriasoft.exml;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.atriasoft.exml.Exml;
|
||||
import org.atriasoft.exml.annotation.XmlDefaultAttibute;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class ExmlTestIntrospectionDouble {
|
||||
static final String NODE_NAME = "elem";
|
||||
@BeforeAll
|
||||
public static void beforeClass() {
|
||||
Log.warning("================================================================");
|
||||
}
|
||||
|
||||
@XmlDefaultAttibute
|
||||
public class TestDouble {
|
||||
public Double valueA;
|
||||
public Double valueB;
|
||||
public Double valueNull;
|
||||
}
|
||||
@Test
|
||||
public void testModelDouble() {
|
||||
TestDouble elem = new TestDouble();
|
||||
elem.valueA = (double)12;
|
||||
elem.valueB = (double)-13;
|
||||
elem.valueNull = null;
|
||||
|
||||
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("<elem valueA=\"12.0\" valueB=\"-13.0\"/>", dataTest);
|
||||
|
||||
final TestDouble root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestDouble.class, ExmlTestIntrospectionDouble.NODE_NAME));
|
||||
Assertions.assertEquals((double)12, root.valueA);
|
||||
Assertions.assertEquals((double)-13, root.valueB);
|
||||
Assertions.assertEquals(null, root.valueNull);
|
||||
}
|
||||
|
||||
@XmlDefaultAttibute
|
||||
public class TestArrayDouble {
|
||||
public Double[] values;
|
||||
}
|
||||
@Test
|
||||
public void testModelArrayDouble() {
|
||||
TestArrayDouble elem = new TestArrayDouble();
|
||||
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("<elem values=\"12.0;-13.0;33.0;78.0;-127.0\"/>", dataTest);
|
||||
|
||||
final TestArrayDouble root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestArrayDouble.class, ExmlTestIntrospectionDouble.NODE_NAME));
|
||||
Assertions.assertEquals(5, root.values.length);
|
||||
Assertions.assertEquals((double)12, root.values[0]);
|
||||
Assertions.assertEquals((double)-13, root.values[1]);
|
||||
Assertions.assertEquals((double)33, root.values[2]);
|
||||
Assertions.assertEquals((double)78, root.values[3]);
|
||||
Assertions.assertEquals((double)-127, root.values[4]);
|
||||
}
|
||||
|
||||
@XmlDefaultAttibute
|
||||
public class TestListDouble {
|
||||
public List<Double> values;
|
||||
}
|
||||
@Test
|
||||
public void testModelListDouble() {
|
||||
TestListDouble elem = new TestListDouble();
|
||||
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("<elem values=\"12.0;-13.0;33.0;78.0;-127.0\"/>", dataTest);
|
||||
|
||||
final TestListDouble root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestListDouble.class, ExmlTestIntrospectionDouble.NODE_NAME));
|
||||
Assertions.assertEquals(5, root.values.size());
|
||||
Assertions.assertEquals((double)12, root.values.get(0));
|
||||
Assertions.assertEquals((double)-13, root.values.get(1));
|
||||
Assertions.assertEquals((double)33, root.values.get(2));
|
||||
Assertions.assertEquals((double)78, root.values.get(3));
|
||||
Assertions.assertEquals((double)-127, root.values.get(4));
|
||||
}
|
||||
|
||||
|
||||
@XmlDefaultAttibute
|
||||
public class TestDoubleFunc {
|
||||
private Double valueA;
|
||||
private Double valueB;
|
||||
private Double valueNull;
|
||||
public Double isValueA() {
|
||||
return this.valueA;
|
||||
}
|
||||
public void setValueA(final Double valueA) {
|
||||
this.valueA = valueA;
|
||||
}
|
||||
public Double isValueB() {
|
||||
return this.valueB;
|
||||
}
|
||||
public void setValueB(final Double valueB) {
|
||||
this.valueB = valueB;
|
||||
}
|
||||
public Double isValueNull() {
|
||||
return this.valueNull;
|
||||
}
|
||||
public void setValueNull(final Double valueNull) {
|
||||
this.valueNull = valueNull;
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testModelDoubleFunc() {
|
||||
TestDoubleFunc elem = new TestDoubleFunc();
|
||||
elem.setValueA((double)-55);
|
||||
elem.setValueB((double)57);
|
||||
elem.setValueNull(null);
|
||||
|
||||
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("<elem valueA=\"-55.0\" valueB=\"57.0\"/>", dataTest);
|
||||
|
||||
final TestDoubleFunc root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestDoubleFunc.class, ExmlTestIntrospectionDouble.NODE_NAME));
|
||||
Assertions.assertEquals((double)-55, root.isValueA());
|
||||
Assertions.assertEquals((double)57, root.isValueB());
|
||||
Assertions.assertEquals(null, root.isValueNull());
|
||||
}
|
||||
|
||||
@XmlDefaultAttibute
|
||||
public class TestArrayDoubleFunc {
|
||||
private Double[] values;
|
||||
|
||||
public Double[] getValues() {
|
||||
return this.values;
|
||||
}
|
||||
|
||||
public void setValues(final Double[] values) {
|
||||
this.values = values;
|
||||
}
|
||||
|
||||
}
|
||||
@Test
|
||||
public void testModelArrayDoubleFunc() {
|
||||
TestArrayDoubleFunc elem = new TestArrayDoubleFunc();
|
||||
elem.setValues(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("<elem values=\"12.0;-13.0;33.0;78.0;-127.0\"/>", dataTest);
|
||||
|
||||
final TestArrayDoubleFunc root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestArrayDoubleFunc.class, ExmlTestIntrospectionDouble.NODE_NAME));
|
||||
Assertions.assertEquals(5, root.getValues().length);
|
||||
Assertions.assertEquals((double)12, root.getValues()[0]);
|
||||
Assertions.assertEquals((double)-13, root.getValues()[1]);
|
||||
Assertions.assertEquals((double)33, root.getValues()[2]);
|
||||
Assertions.assertEquals((double)78, root.getValues()[3]);
|
||||
Assertions.assertEquals((double)-127, root.getValues()[4]);
|
||||
}
|
||||
|
||||
@XmlDefaultAttibute
|
||||
public class TestListDoubleFunc {
|
||||
private List<Double> values;
|
||||
|
||||
public List<Double> getValues() {
|
||||
return this.values;
|
||||
}
|
||||
|
||||
public void setValues(final List<Double> values) {
|
||||
this.values = values;
|
||||
}
|
||||
}
|
||||
@Test
|
||||
public void testModelListDoubleFunc() {
|
||||
TestListDoubleFunc elem = new TestListDoubleFunc();
|
||||
elem.setValues(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("<elem values=\"12.0;-13.0;33.0;78.0;-127.0\"/>", dataTest);
|
||||
|
||||
final TestListDoubleFunc root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestListDoubleFunc.class, ExmlTestIntrospectionDouble.NODE_NAME));
|
||||
Assertions.assertEquals(5, root.getValues().size());
|
||||
Assertions.assertEquals((double)12, root.getValues().get(0));
|
||||
Assertions.assertEquals((double)-13, root.getValues().get(1));
|
||||
Assertions.assertEquals((double)33, root.getValues().get(2));
|
||||
Assertions.assertEquals((double)78, root.getValues().get(3));
|
||||
Assertions.assertEquals((double)-127, root.getValues().get(4));
|
||||
}
|
||||
|
||||
public class TestNodeDouble {
|
||||
public Double valueA;
|
||||
public Double valueB;
|
||||
public Double valueNull;
|
||||
}
|
||||
@Test
|
||||
public void testModelNodeDouble() {
|
||||
TestNodeDouble elem = new TestNodeDouble();
|
||||
elem.valueA = (double)11;
|
||||
elem.valueB = (double)-120;
|
||||
elem.valueNull = null;
|
||||
|
||||
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("<elem>\n"
|
||||
+ " <valueA>11.0</valueA>\n"
|
||||
+ " <valueB>-120.0</valueB>\n"
|
||||
+ "</elem>", dataTest);
|
||||
|
||||
final TestNodeDouble root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestNodeDouble.class, ExmlTestIntrospectionDouble.NODE_NAME));
|
||||
Assertions.assertEquals((double)11, root.valueA);
|
||||
Assertions.assertEquals((double)-120, root.valueB);
|
||||
Assertions.assertEquals(null, root.valueNull);
|
||||
}
|
||||
|
||||
public class TestArrayNodeDouble {
|
||||
public Double[] values;
|
||||
}
|
||||
@Test
|
||||
public void testModelArrayNodeDouble() {
|
||||
TestArrayNodeDouble elem = new TestArrayNodeDouble();
|
||||
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("<elem>\n"
|
||||
+ " <values>12.0</values>\n"
|
||||
+ " <values>-13.0</values>\n"
|
||||
+ " <values>33.0</values>\n"
|
||||
+ " <values>78.0</values>\n"
|
||||
+ " <values>-127.0</values>\n"
|
||||
+ "</elem>", dataTest);
|
||||
|
||||
final TestArrayNodeDouble root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestArrayNodeDouble.class, ExmlTestIntrospectionDouble.NODE_NAME));
|
||||
Assertions.assertEquals(5, root.values.length);
|
||||
Assertions.assertEquals((double)12, root.values[0]);
|
||||
Assertions.assertEquals((double)-13, root.values[1]);
|
||||
Assertions.assertEquals((double)33, root.values[2]);
|
||||
Assertions.assertEquals((double)78, root.values[3]);
|
||||
Assertions.assertEquals((double)-127, root.values[4]);
|
||||
}
|
||||
|
||||
public class TestListNodeDouble {
|
||||
public List<Double> values;
|
||||
}
|
||||
@Test
|
||||
public void testModelListNodeDouble() {
|
||||
TestListNodeDouble elem = new TestListNodeDouble();
|
||||
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("<elem>\n"
|
||||
+ " <values>12.0</values>\n"
|
||||
+ " <values>-13.0</values>\n"
|
||||
+ " <values>33.0</values>\n"
|
||||
+ " <values>78.0</values>\n"
|
||||
+ " <values>-127.0</values>\n"
|
||||
+ "</elem>", dataTest);
|
||||
|
||||
final TestListNodeDouble root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestListNodeDouble.class, ExmlTestIntrospectionDouble.NODE_NAME));
|
||||
Assertions.assertEquals(5, root.values.size());
|
||||
Assertions.assertEquals((double)12, root.values.get(0));
|
||||
Assertions.assertEquals((double)-13, root.values.get(1));
|
||||
Assertions.assertEquals((double)33, root.values.get(2));
|
||||
Assertions.assertEquals((double)78, root.values.get(3));
|
||||
Assertions.assertEquals((double)-127, root.values.get(4));
|
||||
}
|
||||
|
||||
|
||||
public class TestNodeDoubleFunc {
|
||||
private Double valueA;
|
||||
private Double valueB;
|
||||
private Double valueNull;
|
||||
public Double isValueA() {
|
||||
return this.valueA;
|
||||
}
|
||||
public void setValueA(final Double valueA) {
|
||||
this.valueA = valueA;
|
||||
}
|
||||
public Double isValueB() {
|
||||
return this.valueB;
|
||||
}
|
||||
public void setValueB(final Double valueB) {
|
||||
this.valueB = valueB;
|
||||
}
|
||||
public Double isValueNull() {
|
||||
return this.valueNull;
|
||||
}
|
||||
public void setValueNull(final Double valueNull) {
|
||||
this.valueNull = valueNull;
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testModelNodeDoubleFunc() {
|
||||
TestNodeDoubleFunc elem = new TestNodeDoubleFunc();
|
||||
elem.setValueA((double)54);
|
||||
elem.setValueB((double)-68);
|
||||
elem.setValueNull(null);
|
||||
|
||||
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("<elem>\n"
|
||||
+ " <valueA>54.0</valueA>\n"
|
||||
+ " <valueB>-68.0</valueB>\n"
|
||||
+ "</elem>", dataTest);
|
||||
|
||||
final TestNodeDoubleFunc root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestNodeDoubleFunc.class, ExmlTestIntrospectionDouble.NODE_NAME));
|
||||
Assertions.assertEquals((double)54, root.isValueA());
|
||||
Assertions.assertEquals((double)-68, root.isValueB());
|
||||
Assertions.assertEquals(null, root.isValueNull());
|
||||
}
|
||||
|
||||
public class TestArrayNodeDoubleFunc {
|
||||
private Double[] values;
|
||||
|
||||
public Double[] getValues() {
|
||||
return this.values;
|
||||
}
|
||||
|
||||
public void setValues(final Double[] values) {
|
||||
this.values = values;
|
||||
}
|
||||
|
||||
}
|
||||
@Test
|
||||
public void testModelArrayNodeDoubleFunc() {
|
||||
TestArrayNodeDoubleFunc elem = new TestArrayNodeDoubleFunc();
|
||||
elem.setValues(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("<elem>\n"
|
||||
+ " <values>12.0</values>\n"
|
||||
+ " <values>-13.0</values>\n"
|
||||
+ " <values>33.0</values>\n"
|
||||
+ " <values>78.0</values>\n"
|
||||
+ " <values>-127.0</values>\n"
|
||||
+ "</elem>", dataTest);
|
||||
|
||||
final TestArrayNodeDoubleFunc root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestArrayNodeDoubleFunc.class, ExmlTestIntrospectionDouble.NODE_NAME));
|
||||
Assertions.assertEquals(5, root.getValues().length);
|
||||
Assertions.assertEquals((double)12, root.getValues()[0]);
|
||||
Assertions.assertEquals((double)-13, root.getValues()[1]);
|
||||
Assertions.assertEquals((double)33, root.getValues()[2]);
|
||||
Assertions.assertEquals((double)78, root.getValues()[3]);
|
||||
Assertions.assertEquals((double)-127, root.getValues()[4]);
|
||||
}
|
||||
|
||||
// Note this is set in static to test an other part of code...
|
||||
public static class TestListNodeDoubleFunc {
|
||||
private List<Double> values;
|
||||
|
||||
public List<Double> getValues() {
|
||||
return this.values;
|
||||
}
|
||||
|
||||
public void setValues(final List<Double> values) {
|
||||
this.values = values;
|
||||
}
|
||||
}
|
||||
@Test
|
||||
public void testModelListNodeDoubleFunc() {
|
||||
TestListNodeDoubleFunc elem = new TestListNodeDoubleFunc();
|
||||
elem.setValues(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("<elem>\n"
|
||||
+ " <values>12.0</values>\n"
|
||||
+ " <values>-13.0</values>\n"
|
||||
+ " <values>33.0</values>\n"
|
||||
+ " <values>78.0</values>\n"
|
||||
+ " <values>-127.0</values>\n"
|
||||
+ "</elem>", dataTest);
|
||||
|
||||
final TestListNodeDoubleFunc root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestListNodeDoubleFunc.class, ExmlTestIntrospectionDouble.NODE_NAME));
|
||||
Assertions.assertEquals(5, root.getValues().size());
|
||||
Assertions.assertEquals((double)12, root.getValues().get(0));
|
||||
Assertions.assertEquals((double)-13, root.getValues().get(1));
|
||||
Assertions.assertEquals((double)33, root.getValues().get(2));
|
||||
Assertions.assertEquals((double)78, root.getValues().get(3));
|
||||
Assertions.assertEquals((double)-127, root.getValues().get(4));
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,267 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2021, Edouard DUPIN, all right reserved
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
package test.atriasoft.exml;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.atriasoft.exml.Exml;
|
||||
import org.atriasoft.exml.annotation.XmlDefaultAttibute;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class ExmlTestIntrospectionDoubleNative {
|
||||
static final String NODE_NAME = "elem";
|
||||
@BeforeAll
|
||||
public static void beforeClass() {
|
||||
Log.warning("================================================================");
|
||||
}
|
||||
|
||||
@XmlDefaultAttibute
|
||||
public class TestDoubleNative {
|
||||
public double valueA;
|
||||
public double valueB;
|
||||
}
|
||||
@Test
|
||||
public void testModelDoubleNative() {
|
||||
TestDoubleNative elem = new TestDoubleNative();
|
||||
elem.valueA = (double)12;
|
||||
elem.valueB = (double)-13;
|
||||
|
||||
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("<elem valueA=\"12.0\" valueB=\"-13.0\"/>", dataTest);
|
||||
|
||||
final TestDoubleNative root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestDoubleNative.class, ExmlTestIntrospectionDouble.NODE_NAME));
|
||||
Assertions.assertEquals((double)12, root.valueA);
|
||||
Assertions.assertEquals((double)-13, root.valueB);
|
||||
}
|
||||
|
||||
@XmlDefaultAttibute
|
||||
public class TestArrayDoubleNative {
|
||||
public double[] values;
|
||||
}
|
||||
@Test
|
||||
public void testModelArrayDoubleNative() {
|
||||
TestArrayDoubleNative elem = new TestArrayDoubleNative();
|
||||
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("<elem values=\"12.0;-13.0;33.0;78.0;-127.0\"/>", dataTest);
|
||||
|
||||
final TestArrayDoubleNative root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestArrayDoubleNative.class, ExmlTestIntrospectionDouble.NODE_NAME));
|
||||
Assertions.assertEquals(5, root.values.length);
|
||||
Assertions.assertEquals((double)12, root.values[0]);
|
||||
Assertions.assertEquals((double)-13, root.values[1]);
|
||||
Assertions.assertEquals((double)33, root.values[2]);
|
||||
Assertions.assertEquals((double)78, root.values[3]);
|
||||
Assertions.assertEquals((double)-127, root.values[4]);
|
||||
}
|
||||
|
||||
@XmlDefaultAttibute
|
||||
public class TestdoubleFunc {
|
||||
private double valueA;
|
||||
private double valueB;
|
||||
public double isValueA() {
|
||||
return this.valueA;
|
||||
}
|
||||
public void setValueA(final double valueA) {
|
||||
this.valueA = valueA;
|
||||
}
|
||||
public double isValueB() {
|
||||
return this.valueB;
|
||||
}
|
||||
public void setValueB(final double valueB) {
|
||||
this.valueB = valueB;
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testModelDoubleFunc() {
|
||||
TestdoubleFunc elem = new TestdoubleFunc();
|
||||
elem.setValueA((double)-55);
|
||||
elem.setValueB((double)57);
|
||||
|
||||
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("<elem valueA=\"-55.0\" valueB=\"57.0\"/>", dataTest);
|
||||
|
||||
final TestdoubleFunc root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestdoubleFunc.class, ExmlTestIntrospectionDouble.NODE_NAME));
|
||||
Assertions.assertEquals((double)-55, root.isValueA());
|
||||
Assertions.assertEquals((double)57, root.isValueB());
|
||||
}
|
||||
|
||||
@XmlDefaultAttibute
|
||||
public class TestArrayDoubleFunc {
|
||||
private double[] values;
|
||||
|
||||
public double[] getValues() {
|
||||
return this.values;
|
||||
}
|
||||
|
||||
public void setValues(final double[] values) {
|
||||
this.values = values;
|
||||
}
|
||||
|
||||
}
|
||||
@Test
|
||||
public void testModelArrayDoubleFunc() {
|
||||
TestArrayDoubleFunc elem = new TestArrayDoubleFunc();
|
||||
elem.setValues(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("<elem values=\"12.0;-13.0;33.0;78.0;-127.0\"/>", dataTest);
|
||||
|
||||
final TestArrayDoubleFunc root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestArrayDoubleFunc.class, ExmlTestIntrospectionDouble.NODE_NAME));
|
||||
Assertions.assertEquals(5, root.getValues().length);
|
||||
Assertions.assertEquals((double)12, root.getValues()[0]);
|
||||
Assertions.assertEquals((double)-13, root.getValues()[1]);
|
||||
Assertions.assertEquals((double)33, root.getValues()[2]);
|
||||
Assertions.assertEquals((double)78, root.getValues()[3]);
|
||||
Assertions.assertEquals((double)-127, root.getValues()[4]);
|
||||
}
|
||||
|
||||
public class TestNodeDoubleNative {
|
||||
public double valueA;
|
||||
public double valueB;
|
||||
}
|
||||
@Test
|
||||
public void testModelNodeDoubleNative() {
|
||||
TestNodeDoubleNative elem = new TestNodeDoubleNative();
|
||||
elem.valueA = (double)11;
|
||||
elem.valueB = (double)-120;
|
||||
|
||||
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("<elem>\n"
|
||||
+ " <valueA>11.0</valueA>\n"
|
||||
+ " <valueB>-120.0</valueB>\n"
|
||||
+ "</elem>", dataTest);
|
||||
|
||||
final TestNodeDoubleNative root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestNodeDoubleNative.class, ExmlTestIntrospectionDouble.NODE_NAME));
|
||||
Assertions.assertEquals((double)11, root.valueA);
|
||||
Assertions.assertEquals((double)-120, root.valueB);
|
||||
}
|
||||
|
||||
public class TestArrayNodeDoubleNative {
|
||||
public double[] values;
|
||||
}
|
||||
@Test
|
||||
public void testModelArrayNodeDoubleNative() {
|
||||
TestArrayNodeDoubleNative elem = new TestArrayNodeDoubleNative();
|
||||
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("<elem>\n"
|
||||
+ " <values>12.0</values>\n"
|
||||
+ " <values>-13.0</values>\n"
|
||||
+ " <values>33.0</values>\n"
|
||||
+ " <values>78.0</values>\n"
|
||||
+ " <values>-127.0</values>\n"
|
||||
+ "</elem>", dataTest);
|
||||
|
||||
final TestArrayNodeDoubleNative root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestArrayNodeDoubleNative.class, ExmlTestIntrospectionDouble.NODE_NAME));
|
||||
Assertions.assertEquals(5, root.values.length);
|
||||
Assertions.assertEquals((double)12, root.values[0]);
|
||||
Assertions.assertEquals((double)-13, root.values[1]);
|
||||
Assertions.assertEquals((double)33, root.values[2]);
|
||||
Assertions.assertEquals((double)78, root.values[3]);
|
||||
Assertions.assertEquals((double)-127, root.values[4]);
|
||||
}
|
||||
|
||||
public class TestNodedoubleFunc {
|
||||
private double valueA;
|
||||
private double valueB;
|
||||
public double isValueA() {
|
||||
return this.valueA;
|
||||
}
|
||||
public void setValueA(final double valueA) {
|
||||
this.valueA = valueA;
|
||||
}
|
||||
public double isValueB() {
|
||||
return this.valueB;
|
||||
}
|
||||
public void setValueB(final double valueB) {
|
||||
this.valueB = valueB;
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testModelNodeDoubleFunc() {
|
||||
TestNodedoubleFunc elem = new TestNodedoubleFunc();
|
||||
elem.setValueA((double)54);
|
||||
elem.setValueB((double)-68);
|
||||
|
||||
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("<elem>\n"
|
||||
+ " <valueA>54.0</valueA>\n"
|
||||
+ " <valueB>-68.0</valueB>\n"
|
||||
+ "</elem>", dataTest);
|
||||
|
||||
final TestNodedoubleFunc root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestNodedoubleFunc.class, ExmlTestIntrospectionDouble.NODE_NAME));
|
||||
Assertions.assertEquals((double)54, root.isValueA());
|
||||
Assertions.assertEquals((double)-68, root.isValueB());
|
||||
}
|
||||
|
||||
public class TestArrayNodeDoubleFunc {
|
||||
private double[] values;
|
||||
|
||||
public double[] getValues() {
|
||||
return this.values;
|
||||
}
|
||||
|
||||
public void setValues(final double[] values) {
|
||||
this.values = values;
|
||||
}
|
||||
|
||||
}
|
||||
@Test
|
||||
public void testModelArrayNodeDoubleFunc() {
|
||||
TestArrayNodeDoubleFunc elem = new TestArrayNodeDoubleFunc();
|
||||
elem.setValues(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("<elem>\n"
|
||||
+ " <values>12.0</values>\n"
|
||||
+ " <values>-13.0</values>\n"
|
||||
+ " <values>33.0</values>\n"
|
||||
+ " <values>78.0</values>\n"
|
||||
+ " <values>-127.0</values>\n"
|
||||
+ "</elem>", dataTest);
|
||||
|
||||
final TestArrayNodeDoubleFunc root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestArrayNodeDoubleFunc.class, ExmlTestIntrospectionDouble.NODE_NAME));
|
||||
Assertions.assertEquals(5, root.getValues().length);
|
||||
Assertions.assertEquals((double)12, root.getValues()[0]);
|
||||
Assertions.assertEquals((double)-13, root.getValues()[1]);
|
||||
Assertions.assertEquals((double)33, root.getValues()[2]);
|
||||
Assertions.assertEquals((double)78, root.getValues()[3]);
|
||||
Assertions.assertEquals((double)-127, root.getValues()[4]);
|
||||
}
|
||||
|
||||
}
|
||||
|
415
test/src/test/atriasoft/exml/ExmlTestIntrospectionFloat.java
Normal file
415
test/src/test/atriasoft/exml/ExmlTestIntrospectionFloat.java
Normal file
@ -0,0 +1,415 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2021, Edouard DUPIN, all right reserved
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
package test.atriasoft.exml;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.atriasoft.exml.Exml;
|
||||
import org.atriasoft.exml.annotation.XmlDefaultAttibute;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class ExmlTestIntrospectionFloat {
|
||||
static final String NODE_NAME = "elem";
|
||||
@BeforeAll
|
||||
public static void beforeClass() {
|
||||
Log.warning("================================================================");
|
||||
}
|
||||
|
||||
@XmlDefaultAttibute
|
||||
public class TestFloat {
|
||||
public Float valueA;
|
||||
public Float valueB;
|
||||
public Float valueNull;
|
||||
}
|
||||
@Test
|
||||
public void testModelFloat() {
|
||||
TestFloat elem = new TestFloat();
|
||||
elem.valueA = (float)12;
|
||||
elem.valueB = (float)-13;
|
||||
elem.valueNull = null;
|
||||
|
||||
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("<elem valueA=\"12.0\" valueB=\"-13.0\"/>", dataTest);
|
||||
|
||||
final TestFloat root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestFloat.class, ExmlTestIntrospectionFloat.NODE_NAME));
|
||||
Assertions.assertEquals((float)12, root.valueA);
|
||||
Assertions.assertEquals((float)-13, root.valueB);
|
||||
Assertions.assertEquals(null, root.valueNull);
|
||||
}
|
||||
|
||||
@XmlDefaultAttibute
|
||||
public class TestArrayFloat {
|
||||
public Float[] values;
|
||||
}
|
||||
@Test
|
||||
public void testModelArrayFloat() {
|
||||
TestArrayFloat elem = new TestArrayFloat();
|
||||
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("<elem values=\"12.0;-13.0;33.0;78.0;-127.0\"/>", dataTest);
|
||||
|
||||
final TestArrayFloat root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestArrayFloat.class, ExmlTestIntrospectionFloat.NODE_NAME));
|
||||
Assertions.assertEquals(5, root.values.length);
|
||||
Assertions.assertEquals((float)12, root.values[0]);
|
||||
Assertions.assertEquals((float)-13, root.values[1]);
|
||||
Assertions.assertEquals((float)33, root.values[2]);
|
||||
Assertions.assertEquals((float)78, root.values[3]);
|
||||
Assertions.assertEquals((float)-127, root.values[4]);
|
||||
}
|
||||
|
||||
@XmlDefaultAttibute
|
||||
public class TestListFloat {
|
||||
public List<Float> values;
|
||||
}
|
||||
@Test
|
||||
public void testModelListFloat() {
|
||||
TestListFloat elem = new TestListFloat();
|
||||
elem.values = List.of((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("<elem values=\"12.0;-13.0;33.0;78.0;-127.0\"/>", dataTest);
|
||||
|
||||
final TestListFloat root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestListFloat.class, ExmlTestIntrospectionFloat.NODE_NAME));
|
||||
Assertions.assertEquals(5, root.values.size());
|
||||
Assertions.assertEquals((float)12, root.values.get(0));
|
||||
Assertions.assertEquals((float)-13, root.values.get(1));
|
||||
Assertions.assertEquals((float)33, root.values.get(2));
|
||||
Assertions.assertEquals((float)78, root.values.get(3));
|
||||
Assertions.assertEquals((float)-127, root.values.get(4));
|
||||
}
|
||||
|
||||
|
||||
@XmlDefaultAttibute
|
||||
public class TestFloatFunc {
|
||||
private Float valueA;
|
||||
private Float valueB;
|
||||
private Float valueNull;
|
||||
public Float isValueA() {
|
||||
return this.valueA;
|
||||
}
|
||||
public void setValueA(final Float valueA) {
|
||||
this.valueA = valueA;
|
||||
}
|
||||
public Float isValueB() {
|
||||
return this.valueB;
|
||||
}
|
||||
public void setValueB(final Float valueB) {
|
||||
this.valueB = valueB;
|
||||
}
|
||||
public Float isValueNull() {
|
||||
return this.valueNull;
|
||||
}
|
||||
public void setValueNull(final Float valueNull) {
|
||||
this.valueNull = valueNull;
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testModelFloatFunc() {
|
||||
TestFloatFunc elem = new TestFloatFunc();
|
||||
elem.setValueA((float)-55);
|
||||
elem.setValueB((float)57);
|
||||
elem.setValueNull(null);
|
||||
|
||||
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("<elem valueA=\"-55.0\" valueB=\"57.0\"/>", dataTest);
|
||||
|
||||
final TestFloatFunc root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestFloatFunc.class, ExmlTestIntrospectionFloat.NODE_NAME));
|
||||
Assertions.assertEquals((float)-55, root.isValueA());
|
||||
Assertions.assertEquals((float)57, root.isValueB());
|
||||
Assertions.assertEquals(null, root.isValueNull());
|
||||
}
|
||||
|
||||
@XmlDefaultAttibute
|
||||
public class TestArrayFloatFunc {
|
||||
private Float[] values;
|
||||
|
||||
public Float[] getValues() {
|
||||
return this.values;
|
||||
}
|
||||
|
||||
public void setValues(final Float[] values) {
|
||||
this.values = values;
|
||||
}
|
||||
|
||||
}
|
||||
@Test
|
||||
public void testModelArrayFloatFunc() {
|
||||
TestArrayFloatFunc elem = new TestArrayFloatFunc();
|
||||
elem.setValues(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("<elem values=\"12.0;-13.0;33.0;78.0;-127.0\"/>", dataTest);
|
||||
|
||||
final TestArrayFloatFunc root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestArrayFloatFunc.class, ExmlTestIntrospectionFloat.NODE_NAME));
|
||||
Assertions.assertEquals(5, root.getValues().length);
|
||||
Assertions.assertEquals((float)12, root.getValues()[0]);
|
||||
Assertions.assertEquals((float)-13, root.getValues()[1]);
|
||||
Assertions.assertEquals((float)33, root.getValues()[2]);
|
||||
Assertions.assertEquals((float)78, root.getValues()[3]);
|
||||
Assertions.assertEquals((float)-127, root.getValues()[4]);
|
||||
}
|
||||
|
||||
@XmlDefaultAttibute
|
||||
public class TestListFloatFunc {
|
||||
private List<Float> values;
|
||||
|
||||
public List<Float> getValues() {
|
||||
return this.values;
|
||||
}
|
||||
|
||||
public void setValues(final List<Float> values) {
|
||||
this.values = values;
|
||||
}
|
||||
}
|
||||
@Test
|
||||
public void testModelListFloatFunc() {
|
||||
TestListFloatFunc elem = new TestListFloatFunc();
|
||||
elem.setValues(List.of((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("<elem values=\"12.0;-13.0;33.0;78.0;-127.0\"/>", dataTest);
|
||||
|
||||
final TestListFloatFunc root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestListFloatFunc.class, ExmlTestIntrospectionFloat.NODE_NAME));
|
||||
Assertions.assertEquals(5, root.getValues().size());
|
||||
Assertions.assertEquals((float)12, root.getValues().get(0));
|
||||
Assertions.assertEquals((float)-13, root.getValues().get(1));
|
||||
Assertions.assertEquals((float)33, root.getValues().get(2));
|
||||
Assertions.assertEquals((float)78, root.getValues().get(3));
|
||||
Assertions.assertEquals((float)-127, root.getValues().get(4));
|
||||
}
|
||||
|
||||
public class TestNodeFloat {
|
||||
public Float valueA;
|
||||
public Float valueB;
|
||||
public Float valueNull;
|
||||
}
|
||||
@Test
|
||||
public void testModelNodeFloat() {
|
||||
TestNodeFloat elem = new TestNodeFloat();
|
||||
elem.valueA = (float)11;
|
||||
elem.valueB = (float)-120;
|
||||
elem.valueNull = null;
|
||||
|
||||
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("<elem>\n"
|
||||
+ " <valueA>11.0</valueA>\n"
|
||||
+ " <valueB>-120.0</valueB>\n"
|
||||
+ "</elem>", dataTest);
|
||||
|
||||
final TestNodeFloat root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestNodeFloat.class, ExmlTestIntrospectionFloat.NODE_NAME));
|
||||
Assertions.assertEquals((float)11, root.valueA);
|
||||
Assertions.assertEquals((float)-120, root.valueB);
|
||||
Assertions.assertEquals(null, root.valueNull);
|
||||
}
|
||||
|
||||
public class TestArrayNodeFloat {
|
||||
public Float[] values;
|
||||
}
|
||||
@Test
|
||||
public void testModelArrayNodeFloat() {
|
||||
TestArrayNodeFloat elem = new TestArrayNodeFloat();
|
||||
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("<elem>\n"
|
||||
+ " <values>12.0</values>\n"
|
||||
+ " <values>-13.0</values>\n"
|
||||
+ " <values>33.0</values>\n"
|
||||
+ " <values>78.0</values>\n"
|
||||
+ " <values>-127.0</values>\n"
|
||||
+ "</elem>", dataTest);
|
||||
|
||||
final TestArrayNodeFloat root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestArrayNodeFloat.class, ExmlTestIntrospectionFloat.NODE_NAME));
|
||||
Assertions.assertEquals(5, root.values.length);
|
||||
Assertions.assertEquals((float)12, root.values[0]);
|
||||
Assertions.assertEquals((float)-13, root.values[1]);
|
||||
Assertions.assertEquals((float)33, root.values[2]);
|
||||
Assertions.assertEquals((float)78, root.values[3]);
|
||||
Assertions.assertEquals((float)-127, root.values[4]);
|
||||
}
|
||||
|
||||
public class TestListNodeFloat {
|
||||
public List<Float> values;
|
||||
}
|
||||
@Test
|
||||
public void testModelListNodeFloat() {
|
||||
TestListNodeFloat elem = new TestListNodeFloat();
|
||||
elem.values = List.of((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("<elem>\n"
|
||||
+ " <values>12.0</values>\n"
|
||||
+ " <values>-13.0</values>\n"
|
||||
+ " <values>33.0</values>\n"
|
||||
+ " <values>78.0</values>\n"
|
||||
+ " <values>-127.0</values>\n"
|
||||
+ "</elem>", dataTest);
|
||||
|
||||
final TestListNodeFloat root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestListNodeFloat.class, ExmlTestIntrospectionFloat.NODE_NAME));
|
||||
Assertions.assertEquals(5, root.values.size());
|
||||
Assertions.assertEquals((float)12, root.values.get(0));
|
||||
Assertions.assertEquals((float)-13, root.values.get(1));
|
||||
Assertions.assertEquals((float)33, root.values.get(2));
|
||||
Assertions.assertEquals((float)78, root.values.get(3));
|
||||
Assertions.assertEquals((float)-127, root.values.get(4));
|
||||
}
|
||||
|
||||
|
||||
public class TestNodeFloatFunc {
|
||||
private Float valueA;
|
||||
private Float valueB;
|
||||
private Float valueNull;
|
||||
public Float isValueA() {
|
||||
return this.valueA;
|
||||
}
|
||||
public void setValueA(final Float valueA) {
|
||||
this.valueA = valueA;
|
||||
}
|
||||
public Float isValueB() {
|
||||
return this.valueB;
|
||||
}
|
||||
public void setValueB(final Float valueB) {
|
||||
this.valueB = valueB;
|
||||
}
|
||||
public Float isValueNull() {
|
||||
return this.valueNull;
|
||||
}
|
||||
public void setValueNull(final Float valueNull) {
|
||||
this.valueNull = valueNull;
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testModelNodeFloatFunc() {
|
||||
TestNodeFloatFunc elem = new TestNodeFloatFunc();
|
||||
elem.setValueA((float)54);
|
||||
elem.setValueB((float)-68);
|
||||
elem.setValueNull(null);
|
||||
|
||||
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("<elem>\n"
|
||||
+ " <valueA>54.0</valueA>\n"
|
||||
+ " <valueB>-68.0</valueB>\n"
|
||||
+ "</elem>", dataTest);
|
||||
|
||||
final TestNodeFloatFunc root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestNodeFloatFunc.class, ExmlTestIntrospectionFloat.NODE_NAME));
|
||||
Assertions.assertEquals((float)54, root.isValueA());
|
||||
Assertions.assertEquals((float)-68, root.isValueB());
|
||||
Assertions.assertEquals(null, root.isValueNull());
|
||||
}
|
||||
|
||||
public class TestArrayNodeFloatFunc {
|
||||
private Float[] values;
|
||||
|
||||
public Float[] getValues() {
|
||||
return this.values;
|
||||
}
|
||||
|
||||
public void setValues(final Float[] values) {
|
||||
this.values = values;
|
||||
}
|
||||
|
||||
}
|
||||
@Test
|
||||
public void testModelArrayNodeFloatFunc() {
|
||||
TestArrayNodeFloatFunc elem = new TestArrayNodeFloatFunc();
|
||||
elem.setValues(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("<elem>\n"
|
||||
+ " <values>12.0</values>\n"
|
||||
+ " <values>-13.0</values>\n"
|
||||
+ " <values>33.0</values>\n"
|
||||
+ " <values>78.0</values>\n"
|
||||
+ " <values>-127.0</values>\n"
|
||||
+ "</elem>", dataTest);
|
||||
|
||||
final TestArrayNodeFloatFunc root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestArrayNodeFloatFunc.class, ExmlTestIntrospectionFloat.NODE_NAME));
|
||||
Assertions.assertEquals(5, root.getValues().length);
|
||||
Assertions.assertEquals((float)12, root.getValues()[0]);
|
||||
Assertions.assertEquals((float)-13, root.getValues()[1]);
|
||||
Assertions.assertEquals((float)33, root.getValues()[2]);
|
||||
Assertions.assertEquals((float)78, root.getValues()[3]);
|
||||
Assertions.assertEquals((float)-127, root.getValues()[4]);
|
||||
}
|
||||
|
||||
// Note this is set in static to test an other part of code...
|
||||
public static class TestListNodeFloatFunc {
|
||||
private List<Float> values;
|
||||
|
||||
public List<Float> getValues() {
|
||||
return this.values;
|
||||
}
|
||||
|
||||
public void setValues(final List<Float> values) {
|
||||
this.values = values;
|
||||
}
|
||||
}
|
||||
@Test
|
||||
public void testModelListNodeFloatFunc() {
|
||||
TestListNodeFloatFunc elem = new TestListNodeFloatFunc();
|
||||
elem.setValues(List.of((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("<elem>\n"
|
||||
+ " <values>12.0</values>\n"
|
||||
+ " <values>-13.0</values>\n"
|
||||
+ " <values>33.0</values>\n"
|
||||
+ " <values>78.0</values>\n"
|
||||
+ " <values>-127.0</values>\n"
|
||||
+ "</elem>", dataTest);
|
||||
|
||||
final TestListNodeFloatFunc root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestListNodeFloatFunc.class, ExmlTestIntrospectionFloat.NODE_NAME));
|
||||
Assertions.assertEquals(5, root.getValues().size());
|
||||
Assertions.assertEquals((float)12, root.getValues().get(0));
|
||||
Assertions.assertEquals((float)-13, root.getValues().get(1));
|
||||
Assertions.assertEquals((float)33, root.getValues().get(2));
|
||||
Assertions.assertEquals((float)78, root.getValues().get(3));
|
||||
Assertions.assertEquals((float)-127, root.getValues().get(4));
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,267 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2021, Edouard DUPIN, all right reserved
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
package test.atriasoft.exml;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.atriasoft.exml.Exml;
|
||||
import org.atriasoft.exml.annotation.XmlDefaultAttibute;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class ExmlTestIntrospectionFloatNative {
|
||||
static final String NODE_NAME = "elem";
|
||||
@BeforeAll
|
||||
public static void beforeClass() {
|
||||
Log.warning("================================================================");
|
||||
}
|
||||
|
||||
@XmlDefaultAttibute
|
||||
public class TestFloatNative {
|
||||
public float valueA;
|
||||
public float valueB;
|
||||
}
|
||||
@Test
|
||||
public void testModelFloatNative() {
|
||||
TestFloatNative elem = new TestFloatNative();
|
||||
elem.valueA = (float)12;
|
||||
elem.valueB = (float)-13;
|
||||
|
||||
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("<elem valueA=\"12.0\" valueB=\"-13.0\"/>", dataTest);
|
||||
|
||||
final TestFloatNative root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestFloatNative.class, ExmlTestIntrospectionFloat.NODE_NAME));
|
||||
Assertions.assertEquals((float)12, root.valueA);
|
||||
Assertions.assertEquals((float)-13, root.valueB);
|
||||
}
|
||||
|
||||
@XmlDefaultAttibute
|
||||
public class TestArrayFloatNative {
|
||||
public float[] values;
|
||||
}
|
||||
@Test
|
||||
public void testModelArrayFloatNative() {
|
||||
TestArrayFloatNative elem = new TestArrayFloatNative();
|
||||
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("<elem values=\"12.0;-13.0;33.0;78.0;-127.0\"/>", dataTest);
|
||||
|
||||
final TestArrayFloatNative root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestArrayFloatNative.class, ExmlTestIntrospectionFloat.NODE_NAME));
|
||||
Assertions.assertEquals(5, root.values.length);
|
||||
Assertions.assertEquals((float)12, root.values[0]);
|
||||
Assertions.assertEquals((float)-13, root.values[1]);
|
||||
Assertions.assertEquals((float)33, root.values[2]);
|
||||
Assertions.assertEquals((float)78, root.values[3]);
|
||||
Assertions.assertEquals((float)-127, root.values[4]);
|
||||
}
|
||||
|
||||
@XmlDefaultAttibute
|
||||
public class TestfloatFunc {
|
||||
private float valueA;
|
||||
private float valueB;
|
||||
public float isValueA() {
|
||||
return this.valueA;
|
||||
}
|
||||
public void setValueA(final float valueA) {
|
||||
this.valueA = valueA;
|
||||
}
|
||||
public float isValueB() {
|
||||
return this.valueB;
|
||||
}
|
||||
public void setValueB(final float valueB) {
|
||||
this.valueB = valueB;
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testModelFloatFunc() {
|
||||
TestfloatFunc elem = new TestfloatFunc();
|
||||
elem.setValueA((float)-55);
|
||||
elem.setValueB((float)57);
|
||||
|
||||
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("<elem valueA=\"-55.0\" valueB=\"57.0\"/>", dataTest);
|
||||
|
||||
final TestfloatFunc root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestfloatFunc.class, ExmlTestIntrospectionFloat.NODE_NAME));
|
||||
Assertions.assertEquals((float)-55, root.isValueA());
|
||||
Assertions.assertEquals((float)57, root.isValueB());
|
||||
}
|
||||
|
||||
@XmlDefaultAttibute
|
||||
public class TestArrayFloatFunc {
|
||||
private float[] values;
|
||||
|
||||
public float[] getValues() {
|
||||
return this.values;
|
||||
}
|
||||
|
||||
public void setValues(final float[] values) {
|
||||
this.values = values;
|
||||
}
|
||||
|
||||
}
|
||||
@Test
|
||||
public void testModelArrayFloatFunc() {
|
||||
TestArrayFloatFunc elem = new TestArrayFloatFunc();
|
||||
elem.setValues(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("<elem values=\"12.0;-13.0;33.0;78.0;-127.0\"/>", dataTest);
|
||||
|
||||
final TestArrayFloatFunc root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestArrayFloatFunc.class, ExmlTestIntrospectionFloat.NODE_NAME));
|
||||
Assertions.assertEquals(5, root.getValues().length);
|
||||
Assertions.assertEquals((float)12, root.getValues()[0]);
|
||||
Assertions.assertEquals((float)-13, root.getValues()[1]);
|
||||
Assertions.assertEquals((float)33, root.getValues()[2]);
|
||||
Assertions.assertEquals((float)78, root.getValues()[3]);
|
||||
Assertions.assertEquals((float)-127, root.getValues()[4]);
|
||||
}
|
||||
|
||||
public class TestNodeFloatNative {
|
||||
public float valueA;
|
||||
public float valueB;
|
||||
}
|
||||
@Test
|
||||
public void testModelNodeFloatNative() {
|
||||
TestNodeFloatNative elem = new TestNodeFloatNative();
|
||||
elem.valueA = (float)11;
|
||||
elem.valueB = (float)-120;
|
||||
|
||||
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("<elem>\n"
|
||||
+ " <valueA>11.0</valueA>\n"
|
||||
+ " <valueB>-120.0</valueB>\n"
|
||||
+ "</elem>", dataTest);
|
||||
|
||||
final TestNodeFloatNative root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestNodeFloatNative.class, ExmlTestIntrospectionFloat.NODE_NAME));
|
||||
Assertions.assertEquals((float)11, root.valueA);
|
||||
Assertions.assertEquals((float)-120, root.valueB);
|
||||
}
|
||||
|
||||
public class TestArrayNodeFloatNative {
|
||||
public float[] values;
|
||||
}
|
||||
@Test
|
||||
public void testModelArrayNodeFloatNative() {
|
||||
TestArrayNodeFloatNative elem = new TestArrayNodeFloatNative();
|
||||
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("<elem>\n"
|
||||
+ " <values>12.0</values>\n"
|
||||
+ " <values>-13.0</values>\n"
|
||||
+ " <values>33.0</values>\n"
|
||||
+ " <values>78.0</values>\n"
|
||||
+ " <values>-127.0</values>\n"
|
||||
+ "</elem>", dataTest);
|
||||
|
||||
final TestArrayNodeFloatNative root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestArrayNodeFloatNative.class, ExmlTestIntrospectionFloat.NODE_NAME));
|
||||
Assertions.assertEquals(5, root.values.length);
|
||||
Assertions.assertEquals((float)12, root.values[0]);
|
||||
Assertions.assertEquals((float)-13, root.values[1]);
|
||||
Assertions.assertEquals((float)33, root.values[2]);
|
||||
Assertions.assertEquals((float)78, root.values[3]);
|
||||
Assertions.assertEquals((float)-127, root.values[4]);
|
||||
}
|
||||
|
||||
public class TestNodefloatFunc {
|
||||
private float valueA;
|
||||
private float valueB;
|
||||
public float isValueA() {
|
||||
return this.valueA;
|
||||
}
|
||||
public void setValueA(final float valueA) {
|
||||
this.valueA = valueA;
|
||||
}
|
||||
public float isValueB() {
|
||||
return this.valueB;
|
||||
}
|
||||
public void setValueB(final float valueB) {
|
||||
this.valueB = valueB;
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testModelNodeFloatFunc() {
|
||||
TestNodefloatFunc elem = new TestNodefloatFunc();
|
||||
elem.setValueA((float)54);
|
||||
elem.setValueB((float)-68);
|
||||
|
||||
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("<elem>\n"
|
||||
+ " <valueA>54.0</valueA>\n"
|
||||
+ " <valueB>-68.0</valueB>\n"
|
||||
+ "</elem>", dataTest);
|
||||
|
||||
final TestNodefloatFunc root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestNodefloatFunc.class, ExmlTestIntrospectionFloat.NODE_NAME));
|
||||
Assertions.assertEquals((float)54, root.isValueA());
|
||||
Assertions.assertEquals((float)-68, root.isValueB());
|
||||
}
|
||||
|
||||
public class TestArrayNodeFloatFunc {
|
||||
private float[] values;
|
||||
|
||||
public float[] getValues() {
|
||||
return this.values;
|
||||
}
|
||||
|
||||
public void setValues(final float[] values) {
|
||||
this.values = values;
|
||||
}
|
||||
|
||||
}
|
||||
@Test
|
||||
public void testModelArrayNodeFloatFunc() {
|
||||
TestArrayNodeFloatFunc elem = new TestArrayNodeFloatFunc();
|
||||
elem.setValues(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("<elem>\n"
|
||||
+ " <values>12.0</values>\n"
|
||||
+ " <values>-13.0</values>\n"
|
||||
+ " <values>33.0</values>\n"
|
||||
+ " <values>78.0</values>\n"
|
||||
+ " <values>-127.0</values>\n"
|
||||
+ "</elem>", dataTest);
|
||||
|
||||
final TestArrayNodeFloatFunc root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestArrayNodeFloatFunc.class, ExmlTestIntrospectionFloat.NODE_NAME));
|
||||
Assertions.assertEquals(5, root.getValues().length);
|
||||
Assertions.assertEquals((float)12, root.getValues()[0]);
|
||||
Assertions.assertEquals((float)-13, root.getValues()[1]);
|
||||
Assertions.assertEquals((float)33, root.getValues()[2]);
|
||||
Assertions.assertEquals((float)78, root.getValues()[3]);
|
||||
Assertions.assertEquals((float)-127, root.getValues()[4]);
|
||||
}
|
||||
|
||||
}
|
||||
|
415
test/src/test/atriasoft/exml/ExmlTestIntrospectionInteger.java
Normal file
415
test/src/test/atriasoft/exml/ExmlTestIntrospectionInteger.java
Normal file
@ -0,0 +1,415 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2021, Edouard DUPIN, all right reserved
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
package test.atriasoft.exml;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.atriasoft.exml.Exml;
|
||||
import org.atriasoft.exml.annotation.XmlDefaultAttibute;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class ExmlTestIntrospectionInteger {
|
||||
static final String NODE_NAME = "elem";
|
||||
@BeforeAll
|
||||
public static void beforeClass() {
|
||||
Log.warning("================================================================");
|
||||
}
|
||||
|
||||
@XmlDefaultAttibute
|
||||
public class TestInteger {
|
||||
public Integer valueA;
|
||||
public Integer valueB;
|
||||
public Integer valueNull;
|
||||
}
|
||||
@Test
|
||||
public void testModelInteger() {
|
||||
TestInteger elem = new TestInteger();
|
||||
elem.valueA = (int)12;
|
||||
elem.valueB = (int)-13;
|
||||
elem.valueNull = null;
|
||||
|
||||
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("<elem valueA=\"12\" valueB=\"-13\"/>", dataTest);
|
||||
|
||||
final TestInteger root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestInteger.class, ExmlTestIntrospectionInteger.NODE_NAME));
|
||||
Assertions.assertEquals((int)12, root.valueA);
|
||||
Assertions.assertEquals((int)-13, root.valueB);
|
||||
Assertions.assertEquals(null, root.valueNull);
|
||||
}
|
||||
|
||||
@XmlDefaultAttibute
|
||||
public class TestArrayInteger {
|
||||
public Integer[] values;
|
||||
}
|
||||
@Test
|
||||
public void testModelArrayInteger() {
|
||||
TestArrayInteger elem = new TestArrayInteger();
|
||||
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("<elem values=\"12;-13;33;78;-127\"/>", dataTest);
|
||||
|
||||
final TestArrayInteger root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestArrayInteger.class, ExmlTestIntrospectionInteger.NODE_NAME));
|
||||
Assertions.assertEquals(5, root.values.length);
|
||||
Assertions.assertEquals((int)12, root.values[0]);
|
||||
Assertions.assertEquals((int)-13, root.values[1]);
|
||||
Assertions.assertEquals((int)33, root.values[2]);
|
||||
Assertions.assertEquals((int)78, root.values[3]);
|
||||
Assertions.assertEquals((int)-127, root.values[4]);
|
||||
}
|
||||
|
||||
@XmlDefaultAttibute
|
||||
public class TestListInteger {
|
||||
public List<Integer> values;
|
||||
}
|
||||
@Test
|
||||
public void testModelListInteger() {
|
||||
TestListInteger elem = new TestListInteger();
|
||||
elem.values = List.of((int)12, (int)-13, (int)33, (int)78, (int)-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("<elem values=\"12;-13;33;78;-127\"/>", dataTest);
|
||||
|
||||
final TestListInteger root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestListInteger.class, ExmlTestIntrospectionInteger.NODE_NAME));
|
||||
Assertions.assertEquals(5, root.values.size());
|
||||
Assertions.assertEquals((int)12, root.values.get(0));
|
||||
Assertions.assertEquals((int)-13, root.values.get(1));
|
||||
Assertions.assertEquals((int)33, root.values.get(2));
|
||||
Assertions.assertEquals((int)78, root.values.get(3));
|
||||
Assertions.assertEquals((int)-127, root.values.get(4));
|
||||
}
|
||||
|
||||
|
||||
@XmlDefaultAttibute
|
||||
public class TestIntegerFunc {
|
||||
private Integer valueA;
|
||||
private Integer valueB;
|
||||
private Integer valueNull;
|
||||
public Integer isValueA() {
|
||||
return this.valueA;
|
||||
}
|
||||
public void setValueA(final Integer valueA) {
|
||||
this.valueA = valueA;
|
||||
}
|
||||
public Integer isValueB() {
|
||||
return this.valueB;
|
||||
}
|
||||
public void setValueB(final Integer valueB) {
|
||||
this.valueB = valueB;
|
||||
}
|
||||
public Integer isValueNull() {
|
||||
return this.valueNull;
|
||||
}
|
||||
public void setValueNull(final Integer valueNull) {
|
||||
this.valueNull = valueNull;
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testModelIntegerFunc() {
|
||||
TestIntegerFunc elem = new TestIntegerFunc();
|
||||
elem.setValueA((int)-55);
|
||||
elem.setValueB((int)57);
|
||||
elem.setValueNull(null);
|
||||
|
||||
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("<elem valueA=\"-55\" valueB=\"57\"/>", dataTest);
|
||||
|
||||
final TestIntegerFunc root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestIntegerFunc.class, ExmlTestIntrospectionInteger.NODE_NAME));
|
||||
Assertions.assertEquals((int)-55, root.isValueA());
|
||||
Assertions.assertEquals((int)57, root.isValueB());
|
||||
Assertions.assertEquals(null, root.isValueNull());
|
||||
}
|
||||
|
||||
@XmlDefaultAttibute
|
||||
public class TestArrayIntegerFunc {
|
||||
private Integer[] values;
|
||||
|
||||
public Integer[] getValues() {
|
||||
return this.values;
|
||||
}
|
||||
|
||||
public void setValues(final Integer[] values) {
|
||||
this.values = values;
|
||||
}
|
||||
|
||||
}
|
||||
@Test
|
||||
public void testModelArrayIntegerFunc() {
|
||||
TestArrayIntegerFunc elem = new TestArrayIntegerFunc();
|
||||
elem.setValues(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("<elem values=\"12;-13;33;78;-127\"/>", dataTest);
|
||||
|
||||
final TestArrayIntegerFunc root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestArrayIntegerFunc.class, ExmlTestIntrospectionInteger.NODE_NAME));
|
||||
Assertions.assertEquals(5, root.getValues().length);
|
||||
Assertions.assertEquals((int)12, root.getValues()[0]);
|
||||
Assertions.assertEquals((int)-13, root.getValues()[1]);
|
||||
Assertions.assertEquals((int)33, root.getValues()[2]);
|
||||
Assertions.assertEquals((int)78, root.getValues()[3]);
|
||||
Assertions.assertEquals((int)-127, root.getValues()[4]);
|
||||
}
|
||||
|
||||
@XmlDefaultAttibute
|
||||
public class TestListIntegerFunc {
|
||||
private List<Integer> values;
|
||||
|
||||
public List<Integer> getValues() {
|
||||
return this.values;
|
||||
}
|
||||
|
||||
public void setValues(final List<Integer> values) {
|
||||
this.values = values;
|
||||
}
|
||||
}
|
||||
@Test
|
||||
public void testModelListIntegerFunc() {
|
||||
TestListIntegerFunc elem = new TestListIntegerFunc();
|
||||
elem.setValues(List.of((int)12, (int)-13, (int)33, (int)78, (int)-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("<elem values=\"12;-13;33;78;-127\"/>", dataTest);
|
||||
|
||||
final TestListIntegerFunc root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestListIntegerFunc.class, ExmlTestIntrospectionInteger.NODE_NAME));
|
||||
Assertions.assertEquals(5, root.getValues().size());
|
||||
Assertions.assertEquals((int)12, root.getValues().get(0));
|
||||
Assertions.assertEquals((int)-13, root.getValues().get(1));
|
||||
Assertions.assertEquals((int)33, root.getValues().get(2));
|
||||
Assertions.assertEquals((int)78, root.getValues().get(3));
|
||||
Assertions.assertEquals((int)-127, root.getValues().get(4));
|
||||
}
|
||||
|
||||
public class TestNodeInteger {
|
||||
public Integer valueA;
|
||||
public Integer valueB;
|
||||
public Integer valueNull;
|
||||
}
|
||||
@Test
|
||||
public void testModelNodeInteger() {
|
||||
TestNodeInteger elem = new TestNodeInteger();
|
||||
elem.valueA = (int)11;
|
||||
elem.valueB = (int)-120;
|
||||
elem.valueNull = null;
|
||||
|
||||
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("<elem>\n"
|
||||
+ " <valueA>11</valueA>\n"
|
||||
+ " <valueB>-120</valueB>\n"
|
||||
+ "</elem>", dataTest);
|
||||
|
||||
final TestNodeInteger root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestNodeInteger.class, ExmlTestIntrospectionInteger.NODE_NAME));
|
||||
Assertions.assertEquals((int)11, root.valueA);
|
||||
Assertions.assertEquals((int)-120, root.valueB);
|
||||
Assertions.assertEquals(null, root.valueNull);
|
||||
}
|
||||
|
||||
public class TestArrayNodeInteger {
|
||||
public Integer[] values;
|
||||
}
|
||||
@Test
|
||||
public void testModelArrayNodeInteger() {
|
||||
TestArrayNodeInteger elem = new TestArrayNodeInteger();
|
||||
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("<elem>\n"
|
||||
+ " <values>12</values>\n"
|
||||
+ " <values>-13</values>\n"
|
||||
+ " <values>33</values>\n"
|
||||
+ " <values>78</values>\n"
|
||||
+ " <values>-127</values>\n"
|
||||
+ "</elem>", dataTest);
|
||||
|
||||
final TestArrayNodeInteger root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestArrayNodeInteger.class, ExmlTestIntrospectionInteger.NODE_NAME));
|
||||
Assertions.assertEquals(5, root.values.length);
|
||||
Assertions.assertEquals((int)12, root.values[0]);
|
||||
Assertions.assertEquals((int)-13, root.values[1]);
|
||||
Assertions.assertEquals((int)33, root.values[2]);
|
||||
Assertions.assertEquals((int)78, root.values[3]);
|
||||
Assertions.assertEquals((int)-127, root.values[4]);
|
||||
}
|
||||
|
||||
public class TestListNodeInteger {
|
||||
public List<Integer> values;
|
||||
}
|
||||
@Test
|
||||
public void testModelListNodeInteger() {
|
||||
TestListNodeInteger elem = new TestListNodeInteger();
|
||||
elem.values = List.of((int)12, (int)-13, (int)33, (int)78, (int)-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("<elem>\n"
|
||||
+ " <values>12</values>\n"
|
||||
+ " <values>-13</values>\n"
|
||||
+ " <values>33</values>\n"
|
||||
+ " <values>78</values>\n"
|
||||
+ " <values>-127</values>\n"
|
||||
+ "</elem>", dataTest);
|
||||
|
||||
final TestListNodeInteger root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestListNodeInteger.class, ExmlTestIntrospectionInteger.NODE_NAME));
|
||||
Assertions.assertEquals(5, root.values.size());
|
||||
Assertions.assertEquals((int)12, root.values.get(0));
|
||||
Assertions.assertEquals((int)-13, root.values.get(1));
|
||||
Assertions.assertEquals((int)33, root.values.get(2));
|
||||
Assertions.assertEquals((int)78, root.values.get(3));
|
||||
Assertions.assertEquals((int)-127, root.values.get(4));
|
||||
}
|
||||
|
||||
|
||||
public class TestNodeIntegerFunc {
|
||||
private Integer valueA;
|
||||
private Integer valueB;
|
||||
private Integer valueNull;
|
||||
public Integer isValueA() {
|
||||
return this.valueA;
|
||||
}
|
||||
public void setValueA(final Integer valueA) {
|
||||
this.valueA = valueA;
|
||||
}
|
||||
public Integer isValueB() {
|
||||
return this.valueB;
|
||||
}
|
||||
public void setValueB(final Integer valueB) {
|
||||
this.valueB = valueB;
|
||||
}
|
||||
public Integer isValueNull() {
|
||||
return this.valueNull;
|
||||
}
|
||||
public void setValueNull(final Integer valueNull) {
|
||||
this.valueNull = valueNull;
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testModelNodeIntegerFunc() {
|
||||
TestNodeIntegerFunc elem = new TestNodeIntegerFunc();
|
||||
elem.setValueA((int)54);
|
||||
elem.setValueB((int)-68);
|
||||
elem.setValueNull(null);
|
||||
|
||||
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("<elem>\n"
|
||||
+ " <valueA>54</valueA>\n"
|
||||
+ " <valueB>-68</valueB>\n"
|
||||
+ "</elem>", dataTest);
|
||||
|
||||
final TestNodeIntegerFunc root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestNodeIntegerFunc.class, ExmlTestIntrospectionInteger.NODE_NAME));
|
||||
Assertions.assertEquals((int)54, root.isValueA());
|
||||
Assertions.assertEquals((int)-68, root.isValueB());
|
||||
Assertions.assertEquals(null, root.isValueNull());
|
||||
}
|
||||
|
||||
public class TestArrayNodeIntegerFunc {
|
||||
private Integer[] values;
|
||||
|
||||
public Integer[] getValues() {
|
||||
return this.values;
|
||||
}
|
||||
|
||||
public void setValues(final Integer[] values) {
|
||||
this.values = values;
|
||||
}
|
||||
|
||||
}
|
||||
@Test
|
||||
public void testModelArrayNodeIntegerFunc() {
|
||||
TestArrayNodeIntegerFunc elem = new TestArrayNodeIntegerFunc();
|
||||
elem.setValues(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("<elem>\n"
|
||||
+ " <values>12</values>\n"
|
||||
+ " <values>-13</values>\n"
|
||||
+ " <values>33</values>\n"
|
||||
+ " <values>78</values>\n"
|
||||
+ " <values>-127</values>\n"
|
||||
+ "</elem>", dataTest);
|
||||
|
||||
final TestArrayNodeIntegerFunc root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestArrayNodeIntegerFunc.class, ExmlTestIntrospectionInteger.NODE_NAME));
|
||||
Assertions.assertEquals(5, root.getValues().length);
|
||||
Assertions.assertEquals((int)12, root.getValues()[0]);
|
||||
Assertions.assertEquals((int)-13, root.getValues()[1]);
|
||||
Assertions.assertEquals((int)33, root.getValues()[2]);
|
||||
Assertions.assertEquals((int)78, root.getValues()[3]);
|
||||
Assertions.assertEquals((int)-127, root.getValues()[4]);
|
||||
}
|
||||
|
||||
// Note this is set in static to test an other part of code...
|
||||
public static class TestListNodeIntegerFunc {
|
||||
private List<Integer> values;
|
||||
|
||||
public List<Integer> getValues() {
|
||||
return this.values;
|
||||
}
|
||||
|
||||
public void setValues(final List<Integer> values) {
|
||||
this.values = values;
|
||||
}
|
||||
}
|
||||
@Test
|
||||
public void testModelListNodeIntegerFunc() {
|
||||
TestListNodeIntegerFunc elem = new TestListNodeIntegerFunc();
|
||||
elem.setValues(List.of((int)12, (int)-13, (int)33, (int)78, (int)-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("<elem>\n"
|
||||
+ " <values>12</values>\n"
|
||||
+ " <values>-13</values>\n"
|
||||
+ " <values>33</values>\n"
|
||||
+ " <values>78</values>\n"
|
||||
+ " <values>-127</values>\n"
|
||||
+ "</elem>", dataTest);
|
||||
|
||||
final TestListNodeIntegerFunc root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestListNodeIntegerFunc.class, ExmlTestIntrospectionInteger.NODE_NAME));
|
||||
Assertions.assertEquals(5, root.getValues().size());
|
||||
Assertions.assertEquals((int)12, root.getValues().get(0));
|
||||
Assertions.assertEquals((int)-13, root.getValues().get(1));
|
||||
Assertions.assertEquals((int)33, root.getValues().get(2));
|
||||
Assertions.assertEquals((int)78, root.getValues().get(3));
|
||||
Assertions.assertEquals((int)-127, root.getValues().get(4));
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,267 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2021, Edouard DUPIN, all right reserved
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
package test.atriasoft.exml;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.atriasoft.exml.Exml;
|
||||
import org.atriasoft.exml.annotation.XmlDefaultAttibute;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class ExmlTestIntrospectionIntegerNative {
|
||||
static final String NODE_NAME = "elem";
|
||||
@BeforeAll
|
||||
public static void beforeClass() {
|
||||
Log.warning("================================================================");
|
||||
}
|
||||
|
||||
@XmlDefaultAttibute
|
||||
public class TestIntegerNative {
|
||||
public int valueA;
|
||||
public int valueB;
|
||||
}
|
||||
@Test
|
||||
public void testModelIntegerNative() {
|
||||
TestIntegerNative elem = new TestIntegerNative();
|
||||
elem.valueA = (int)12;
|
||||
elem.valueB = (int)-13;
|
||||
|
||||
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("<elem valueA=\"12\" valueB=\"-13\"/>", dataTest);
|
||||
|
||||
final TestIntegerNative root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestIntegerNative.class, ExmlTestIntrospectionInteger.NODE_NAME));
|
||||
Assertions.assertEquals((int)12, root.valueA);
|
||||
Assertions.assertEquals((int)-13, root.valueB);
|
||||
}
|
||||
|
||||
@XmlDefaultAttibute
|
||||
public class TestArrayIntegerNative {
|
||||
public int[] values;
|
||||
}
|
||||
@Test
|
||||
public void testModelArrayIntegerNative() {
|
||||
TestArrayIntegerNative elem = new TestArrayIntegerNative();
|
||||
elem.values = new int[] {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("<elem values=\"12;-13;33;78;-127\"/>", dataTest);
|
||||
|
||||
final TestArrayIntegerNative root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestArrayIntegerNative.class, ExmlTestIntrospectionInteger.NODE_NAME));
|
||||
Assertions.assertEquals(5, root.values.length);
|
||||
Assertions.assertEquals((int)12, root.values[0]);
|
||||
Assertions.assertEquals((int)-13, root.values[1]);
|
||||
Assertions.assertEquals((int)33, root.values[2]);
|
||||
Assertions.assertEquals((int)78, root.values[3]);
|
||||
Assertions.assertEquals((int)-127, root.values[4]);
|
||||
}
|
||||
|
||||
@XmlDefaultAttibute
|
||||
public class TestintFunc {
|
||||
private int valueA;
|
||||
private int valueB;
|
||||
public int isValueA() {
|
||||
return this.valueA;
|
||||
}
|
||||
public void setValueA(final int valueA) {
|
||||
this.valueA = valueA;
|
||||
}
|
||||
public int isValueB() {
|
||||
return this.valueB;
|
||||
}
|
||||
public void setValueB(final int valueB) {
|
||||
this.valueB = valueB;
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testModelIntegerFunc() {
|
||||
TestintFunc elem = new TestintFunc();
|
||||
elem.setValueA((int)-55);
|
||||
elem.setValueB((int)57);
|
||||
|
||||
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("<elem valueA=\"-55\" valueB=\"57\"/>", dataTest);
|
||||
|
||||
final TestintFunc root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestintFunc.class, ExmlTestIntrospectionInteger.NODE_NAME));
|
||||
Assertions.assertEquals((int)-55, root.isValueA());
|
||||
Assertions.assertEquals((int)57, root.isValueB());
|
||||
}
|
||||
|
||||
@XmlDefaultAttibute
|
||||
public class TestArrayIntegerFunc {
|
||||
private int[] values;
|
||||
|
||||
public int[] getValues() {
|
||||
return this.values;
|
||||
}
|
||||
|
||||
public void setValues(final int[] values) {
|
||||
this.values = values;
|
||||
}
|
||||
|
||||
}
|
||||
@Test
|
||||
public void testModelArrayIntegerFunc() {
|
||||
TestArrayIntegerFunc elem = new TestArrayIntegerFunc();
|
||||
elem.setValues(new int[] {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("<elem values=\"12;-13;33;78;-127\"/>", dataTest);
|
||||
|
||||
final TestArrayIntegerFunc root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestArrayIntegerFunc.class, ExmlTestIntrospectionInteger.NODE_NAME));
|
||||
Assertions.assertEquals(5, root.getValues().length);
|
||||
Assertions.assertEquals((int)12, root.getValues()[0]);
|
||||
Assertions.assertEquals((int)-13, root.getValues()[1]);
|
||||
Assertions.assertEquals((int)33, root.getValues()[2]);
|
||||
Assertions.assertEquals((int)78, root.getValues()[3]);
|
||||
Assertions.assertEquals((int)-127, root.getValues()[4]);
|
||||
}
|
||||
|
||||
public class TestNodeIntegerNative {
|
||||
public int valueA;
|
||||
public int valueB;
|
||||
}
|
||||
@Test
|
||||
public void testModelNodeIntegerNative() {
|
||||
TestNodeIntegerNative elem = new TestNodeIntegerNative();
|
||||
elem.valueA = (int)11;
|
||||
elem.valueB = (int)-120;
|
||||
|
||||
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("<elem>\n"
|
||||
+ " <valueA>11</valueA>\n"
|
||||
+ " <valueB>-120</valueB>\n"
|
||||
+ "</elem>", dataTest);
|
||||
|
||||
final TestNodeIntegerNative root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestNodeIntegerNative.class, ExmlTestIntrospectionInteger.NODE_NAME));
|
||||
Assertions.assertEquals((int)11, root.valueA);
|
||||
Assertions.assertEquals((int)-120, root.valueB);
|
||||
}
|
||||
|
||||
public class TestArrayNodeIntegerNative {
|
||||
public int[] values;
|
||||
}
|
||||
@Test
|
||||
public void testModelArrayNodeintNative() {
|
||||
TestArrayNodeIntegerNative elem = new TestArrayNodeIntegerNative();
|
||||
elem.values = new int[] {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("<elem>\n"
|
||||
+ " <values>12</values>\n"
|
||||
+ " <values>-13</values>\n"
|
||||
+ " <values>33</values>\n"
|
||||
+ " <values>78</values>\n"
|
||||
+ " <values>-127</values>\n"
|
||||
+ "</elem>", dataTest);
|
||||
|
||||
final TestArrayNodeIntegerNative root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestArrayNodeIntegerNative.class, ExmlTestIntrospectionInteger.NODE_NAME));
|
||||
Assertions.assertEquals(5, root.values.length);
|
||||
Assertions.assertEquals((int)12, root.values[0]);
|
||||
Assertions.assertEquals((int)-13, root.values[1]);
|
||||
Assertions.assertEquals((int)33, root.values[2]);
|
||||
Assertions.assertEquals((int)78, root.values[3]);
|
||||
Assertions.assertEquals((int)-127, root.values[4]);
|
||||
}
|
||||
|
||||
public class TestNodeintFunc {
|
||||
private int valueA;
|
||||
private int valueB;
|
||||
public int isValueA() {
|
||||
return this.valueA;
|
||||
}
|
||||
public void setValueA(final int valueA) {
|
||||
this.valueA = valueA;
|
||||
}
|
||||
public int isValueB() {
|
||||
return this.valueB;
|
||||
}
|
||||
public void setValueB(final int valueB) {
|
||||
this.valueB = valueB;
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testModelNodeIntegerFunc() {
|
||||
TestNodeintFunc elem = new TestNodeintFunc();
|
||||
elem.setValueA((int)54);
|
||||
elem.setValueB((int)-68);
|
||||
|
||||
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("<elem>\n"
|
||||
+ " <valueA>54</valueA>\n"
|
||||
+ " <valueB>-68</valueB>\n"
|
||||
+ "</elem>", dataTest);
|
||||
|
||||
final TestNodeintFunc root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestNodeintFunc.class, ExmlTestIntrospectionInteger.NODE_NAME));
|
||||
Assertions.assertEquals((int)54, root.isValueA());
|
||||
Assertions.assertEquals((int)-68, root.isValueB());
|
||||
}
|
||||
|
||||
public class TestArrayNodeIntegerFunc {
|
||||
private int[] values;
|
||||
|
||||
public int[] getValues() {
|
||||
return this.values;
|
||||
}
|
||||
|
||||
public void setValues(final int[] values) {
|
||||
this.values = values;
|
||||
}
|
||||
|
||||
}
|
||||
@Test
|
||||
public void testModelArrayNodeIntegerFunc() {
|
||||
TestArrayNodeIntegerFunc elem = new TestArrayNodeIntegerFunc();
|
||||
elem.setValues(new int[] {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("<elem>\n"
|
||||
+ " <values>12</values>\n"
|
||||
+ " <values>-13</values>\n"
|
||||
+ " <values>33</values>\n"
|
||||
+ " <values>78</values>\n"
|
||||
+ " <values>-127</values>\n"
|
||||
+ "</elem>", dataTest);
|
||||
|
||||
final TestArrayNodeIntegerFunc root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestArrayNodeIntegerFunc.class, ExmlTestIntrospectionInteger.NODE_NAME));
|
||||
Assertions.assertEquals(5, root.getValues().length);
|
||||
Assertions.assertEquals((int)12, root.getValues()[0]);
|
||||
Assertions.assertEquals((int)-13, root.getValues()[1]);
|
||||
Assertions.assertEquals((int)33, root.getValues()[2]);
|
||||
Assertions.assertEquals((int)78, root.getValues()[3]);
|
||||
Assertions.assertEquals((int)-127, root.getValues()[4]);
|
||||
}
|
||||
|
||||
}
|
||||
|
415
test/src/test/atriasoft/exml/ExmlTestIntrospectionShort.java
Normal file
415
test/src/test/atriasoft/exml/ExmlTestIntrospectionShort.java
Normal file
@ -0,0 +1,415 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2021, Edouard DUPIN, all right reserved
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
package test.atriasoft.exml;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.atriasoft.exml.Exml;
|
||||
import org.atriasoft.exml.annotation.XmlDefaultAttibute;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class ExmlTestIntrospectionShort {
|
||||
static final String NODE_NAME = "elem";
|
||||
@BeforeAll
|
||||
public static void beforeClass() {
|
||||
Log.warning("================================================================");
|
||||
}
|
||||
|
||||
@XmlDefaultAttibute
|
||||
public class TestShort {
|
||||
public Short valueA;
|
||||
public Short valueB;
|
||||
public Short valueNull;
|
||||
}
|
||||
@Test
|
||||
public void testModelShort() {
|
||||
TestShort elem = new TestShort();
|
||||
elem.valueA = (short)12;
|
||||
elem.valueB = (short)-13;
|
||||
elem.valueNull = null;
|
||||
|
||||
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("<elem valueA=\"12\" valueB=\"-13\"/>", dataTest);
|
||||
|
||||
final TestShort root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestShort.class, ExmlTestIntrospectionShort.NODE_NAME));
|
||||
Assertions.assertEquals((short)12, root.valueA);
|
||||
Assertions.assertEquals((short)-13, root.valueB);
|
||||
Assertions.assertEquals(null, root.valueNull);
|
||||
}
|
||||
|
||||
@XmlDefaultAttibute
|
||||
public class TestArrayShort {
|
||||
public Short[] values;
|
||||
}
|
||||
@Test
|
||||
public void testModelArrayShort() {
|
||||
TestArrayShort elem = new TestArrayShort();
|
||||
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("<elem values=\"12;-13;33;78;-127\"/>", dataTest);
|
||||
|
||||
final TestArrayShort root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestArrayShort.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]);
|
||||
}
|
||||
|
||||
@XmlDefaultAttibute
|
||||
public class TestListShort {
|
||||
public List<Short> values;
|
||||
}
|
||||
@Test
|
||||
public void testModelListShort() {
|
||||
TestListShort elem = new TestListShort();
|
||||
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("<elem values=\"12;-13;33;78;-127\"/>", dataTest);
|
||||
|
||||
final TestListShort root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestListShort.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));
|
||||
}
|
||||
|
||||
|
||||
@XmlDefaultAttibute
|
||||
public class TestShortFunc {
|
||||
private Short valueA;
|
||||
private Short valueB;
|
||||
private Short valueNull;
|
||||
public Short isValueA() {
|
||||
return this.valueA;
|
||||
}
|
||||
public void setValueA(final Short valueA) {
|
||||
this.valueA = valueA;
|
||||
}
|
||||
public Short isValueB() {
|
||||
return this.valueB;
|
||||
}
|
||||
public void setValueB(final Short valueB) {
|
||||
this.valueB = valueB;
|
||||
}
|
||||
public Short isValueNull() {
|
||||
return this.valueNull;
|
||||
}
|
||||
public void setValueNull(final Short valueNull) {
|
||||
this.valueNull = valueNull;
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testModelShortFunc() {
|
||||
TestShortFunc elem = new TestShortFunc();
|
||||
elem.setValueA((short)-55);
|
||||
elem.setValueB((short)57);
|
||||
elem.setValueNull(null);
|
||||
|
||||
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("<elem valueA=\"-55\" valueB=\"57\"/>", dataTest);
|
||||
|
||||
final TestShortFunc root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestShortFunc.class, ExmlTestIntrospectionShort.NODE_NAME));
|
||||
Assertions.assertEquals((short)-55, root.isValueA());
|
||||
Assertions.assertEquals((short)57, root.isValueB());
|
||||
Assertions.assertEquals(null, root.isValueNull());
|
||||
}
|
||||
|
||||
@XmlDefaultAttibute
|
||||
public class TestArrayShortFunc {
|
||||
private Short[] values;
|
||||
|
||||
public Short[] getValues() {
|
||||
return this.values;
|
||||
}
|
||||
|
||||
public void setValues(final Short[] values) {
|
||||
this.values = values;
|
||||
}
|
||||
|
||||
}
|
||||
@Test
|
||||
public void testModelArrayShortFunc() {
|
||||
TestArrayShortFunc elem = new TestArrayShortFunc();
|
||||
elem.setValues(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("<elem values=\"12;-13;33;78;-127\"/>", dataTest);
|
||||
|
||||
final TestArrayShortFunc root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestArrayShortFunc.class, ExmlTestIntrospectionShort.NODE_NAME));
|
||||
Assertions.assertEquals(5, root.getValues().length);
|
||||
Assertions.assertEquals((short)12, root.getValues()[0]);
|
||||
Assertions.assertEquals((short)-13, root.getValues()[1]);
|
||||
Assertions.assertEquals((short)33, root.getValues()[2]);
|
||||
Assertions.assertEquals((short)78, root.getValues()[3]);
|
||||
Assertions.assertEquals((short)-127, root.getValues()[4]);
|
||||
}
|
||||
|
||||
@XmlDefaultAttibute
|
||||
public class TestListShortFunc {
|
||||
private List<Short> values;
|
||||
|
||||
public List<Short> getValues() {
|
||||
return this.values;
|
||||
}
|
||||
|
||||
public void setValues(final List<Short> values) {
|
||||
this.values = values;
|
||||
}
|
||||
}
|
||||
@Test
|
||||
public void testModelListShortFunc() {
|
||||
TestListShortFunc elem = new TestListShortFunc();
|
||||
elem.setValues(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("<elem values=\"12;-13;33;78;-127\"/>", dataTest);
|
||||
|
||||
final TestListShortFunc root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestListShortFunc.class, ExmlTestIntrospectionShort.NODE_NAME));
|
||||
Assertions.assertEquals(5, root.getValues().size());
|
||||
Assertions.assertEquals((short)12, root.getValues().get(0));
|
||||
Assertions.assertEquals((short)-13, root.getValues().get(1));
|
||||
Assertions.assertEquals((short)33, root.getValues().get(2));
|
||||
Assertions.assertEquals((short)78, root.getValues().get(3));
|
||||
Assertions.assertEquals((short)-127, root.getValues().get(4));
|
||||
}
|
||||
|
||||
public class TestNodeShort {
|
||||
public Short valueA;
|
||||
public Short valueB;
|
||||
public Short valueNull;
|
||||
}
|
||||
@Test
|
||||
public void testModelNodeShort() {
|
||||
TestNodeShort elem = new TestNodeShort();
|
||||
elem.valueA = (short)11;
|
||||
elem.valueB = (short)-120;
|
||||
elem.valueNull = null;
|
||||
|
||||
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("<elem>\n"
|
||||
+ " <valueA>11</valueA>\n"
|
||||
+ " <valueB>-120</valueB>\n"
|
||||
+ "</elem>", dataTest);
|
||||
|
||||
final TestNodeShort root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestNodeShort.class, ExmlTestIntrospectionShort.NODE_NAME));
|
||||
Assertions.assertEquals((short)11, root.valueA);
|
||||
Assertions.assertEquals((short)-120, root.valueB);
|
||||
Assertions.assertEquals(null, root.valueNull);
|
||||
}
|
||||
|
||||
public class TestArrayNodeShort {
|
||||
public Short[] values;
|
||||
}
|
||||
@Test
|
||||
public void testModelArrayNodeShort() {
|
||||
TestArrayNodeShort elem = new TestArrayNodeShort();
|
||||
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("<elem>\n"
|
||||
+ " <values>12</values>\n"
|
||||
+ " <values>-13</values>\n"
|
||||
+ " <values>33</values>\n"
|
||||
+ " <values>78</values>\n"
|
||||
+ " <values>-127</values>\n"
|
||||
+ "</elem>", dataTest);
|
||||
|
||||
final TestArrayNodeShort root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestArrayNodeShort.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]);
|
||||
}
|
||||
|
||||
public class TestListNodeShort {
|
||||
public List<Short> values;
|
||||
}
|
||||
@Test
|
||||
public void testModelListNodeShort() {
|
||||
TestListNodeShort elem = new TestListNodeShort();
|
||||
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("<elem>\n"
|
||||
+ " <values>12</values>\n"
|
||||
+ " <values>-13</values>\n"
|
||||
+ " <values>33</values>\n"
|
||||
+ " <values>78</values>\n"
|
||||
+ " <values>-127</values>\n"
|
||||
+ "</elem>", dataTest);
|
||||
|
||||
final TestListNodeShort root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestListNodeShort.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 TestNodeShortFunc {
|
||||
private Short valueA;
|
||||
private Short valueB;
|
||||
private Short valueNull;
|
||||
public Short isValueA() {
|
||||
return this.valueA;
|
||||
}
|
||||
public void setValueA(final Short valueA) {
|
||||
this.valueA = valueA;
|
||||
}
|
||||
public Short isValueB() {
|
||||
return this.valueB;
|
||||
}
|
||||
public void setValueB(final Short valueB) {
|
||||
this.valueB = valueB;
|
||||
}
|
||||
public Short isValueNull() {
|
||||
return this.valueNull;
|
||||
}
|
||||
public void setValueNull(final Short valueNull) {
|
||||
this.valueNull = valueNull;
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testModelNodeShortFunc() {
|
||||
TestNodeShortFunc elem = new TestNodeShortFunc();
|
||||
elem.setValueA((short)54);
|
||||
elem.setValueB((short)-68);
|
||||
elem.setValueNull(null);
|
||||
|
||||
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("<elem>\n"
|
||||
+ " <valueA>54</valueA>\n"
|
||||
+ " <valueB>-68</valueB>\n"
|
||||
+ "</elem>", dataTest);
|
||||
|
||||
final TestNodeShortFunc root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestNodeShortFunc.class, ExmlTestIntrospectionShort.NODE_NAME));
|
||||
Assertions.assertEquals((short)54, root.isValueA());
|
||||
Assertions.assertEquals((short)-68, root.isValueB());
|
||||
Assertions.assertEquals(null, root.isValueNull());
|
||||
}
|
||||
|
||||
public class TestArrayNodeShortFunc {
|
||||
private Short[] values;
|
||||
|
||||
public Short[] getValues() {
|
||||
return this.values;
|
||||
}
|
||||
|
||||
public void setValues(final Short[] values) {
|
||||
this.values = values;
|
||||
}
|
||||
|
||||
}
|
||||
@Test
|
||||
public void testModelArrayNodeShortFunc() {
|
||||
TestArrayNodeShortFunc elem = new TestArrayNodeShortFunc();
|
||||
elem.setValues(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("<elem>\n"
|
||||
+ " <values>12</values>\n"
|
||||
+ " <values>-13</values>\n"
|
||||
+ " <values>33</values>\n"
|
||||
+ " <values>78</values>\n"
|
||||
+ " <values>-127</values>\n"
|
||||
+ "</elem>", dataTest);
|
||||
|
||||
final TestArrayNodeShortFunc root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestArrayNodeShortFunc.class, ExmlTestIntrospectionShort.NODE_NAME));
|
||||
Assertions.assertEquals(5, root.getValues().length);
|
||||
Assertions.assertEquals((short)12, root.getValues()[0]);
|
||||
Assertions.assertEquals((short)-13, root.getValues()[1]);
|
||||
Assertions.assertEquals((short)33, root.getValues()[2]);
|
||||
Assertions.assertEquals((short)78, root.getValues()[3]);
|
||||
Assertions.assertEquals((short)-127, root.getValues()[4]);
|
||||
}
|
||||
|
||||
// Note this is set in static to test an other part of code...
|
||||
public static class TestListNodeShortFunc {
|
||||
private List<Short> values;
|
||||
|
||||
public List<Short> getValues() {
|
||||
return this.values;
|
||||
}
|
||||
|
||||
public void setValues(final List<Short> values) {
|
||||
this.values = values;
|
||||
}
|
||||
}
|
||||
@Test
|
||||
public void testModelListNodeShortFunc() {
|
||||
TestListNodeShortFunc elem = new TestListNodeShortFunc();
|
||||
elem.setValues(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("<elem>\n"
|
||||
+ " <values>12</values>\n"
|
||||
+ " <values>-13</values>\n"
|
||||
+ " <values>33</values>\n"
|
||||
+ " <values>78</values>\n"
|
||||
+ " <values>-127</values>\n"
|
||||
+ "</elem>", dataTest);
|
||||
|
||||
final TestListNodeShortFunc root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestListNodeShortFunc.class, ExmlTestIntrospectionShort.NODE_NAME));
|
||||
Assertions.assertEquals(5, root.getValues().size());
|
||||
Assertions.assertEquals((short)12, root.getValues().get(0));
|
||||
Assertions.assertEquals((short)-13, root.getValues().get(1));
|
||||
Assertions.assertEquals((short)33, root.getValues().get(2));
|
||||
Assertions.assertEquals((short)78, root.getValues().get(3));
|
||||
Assertions.assertEquals((short)-127, root.getValues().get(4));
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,267 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2021, Edouard DUPIN, all right reserved
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
package test.atriasoft.exml;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.atriasoft.exml.Exml;
|
||||
import org.atriasoft.exml.annotation.XmlDefaultAttibute;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class ExmlTestIntrospectionShortNative {
|
||||
static final String NODE_NAME = "elem";
|
||||
@BeforeAll
|
||||
public static void beforeClass() {
|
||||
Log.warning("================================================================");
|
||||
}
|
||||
|
||||
@XmlDefaultAttibute
|
||||
public class TestShortNative {
|
||||
public short valueA;
|
||||
public short valueB;
|
||||
}
|
||||
@Test
|
||||
public void testModelShortNative() {
|
||||
TestShortNative elem = new TestShortNative();
|
||||
elem.valueA = (short)12;
|
||||
elem.valueB = (short)-13;
|
||||
|
||||
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("<elem valueA=\"12\" valueB=\"-13\"/>", dataTest);
|
||||
|
||||
final TestShortNative root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestShortNative.class, ExmlTestIntrospectionShort.NODE_NAME));
|
||||
Assertions.assertEquals((short)12, root.valueA);
|
||||
Assertions.assertEquals((short)-13, root.valueB);
|
||||
}
|
||||
|
||||
@XmlDefaultAttibute
|
||||
public class TestArrayShortNative {
|
||||
public short[] values;
|
||||
}
|
||||
@Test
|
||||
public void testModelArrayShortNative() {
|
||||
TestArrayShortNative elem = new TestArrayShortNative();
|
||||
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("<elem values=\"12;-13;33;78;-127\"/>", dataTest);
|
||||
|
||||
final TestArrayShortNative root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestArrayShortNative.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]);
|
||||
}
|
||||
|
||||
@XmlDefaultAttibute
|
||||
public class TestshortFunc {
|
||||
private short valueA;
|
||||
private short valueB;
|
||||
public short isValueA() {
|
||||
return this.valueA;
|
||||
}
|
||||
public void setValueA(final short valueA) {
|
||||
this.valueA = valueA;
|
||||
}
|
||||
public short isValueB() {
|
||||
return this.valueB;
|
||||
}
|
||||
public void setValueB(final short valueB) {
|
||||
this.valueB = valueB;
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testModelShortFunc() {
|
||||
TestshortFunc elem = new TestshortFunc();
|
||||
elem.setValueA((short)-55);
|
||||
elem.setValueB((short)57);
|
||||
|
||||
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("<elem valueA=\"-55\" valueB=\"57\"/>", dataTest);
|
||||
|
||||
final TestshortFunc root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestshortFunc.class, ExmlTestIntrospectionShort.NODE_NAME));
|
||||
Assertions.assertEquals((short)-55, root.isValueA());
|
||||
Assertions.assertEquals((short)57, root.isValueB());
|
||||
}
|
||||
|
||||
@XmlDefaultAttibute
|
||||
public class TestArrayShortFunc {
|
||||
private short[] values;
|
||||
|
||||
public short[] getValues() {
|
||||
return this.values;
|
||||
}
|
||||
|
||||
public void setValues(final short[] values) {
|
||||
this.values = values;
|
||||
}
|
||||
|
||||
}
|
||||
@Test
|
||||
public void testModelArrayShortFunc() {
|
||||
TestArrayShortFunc elem = new TestArrayShortFunc();
|
||||
elem.setValues(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("<elem values=\"12;-13;33;78;-127\"/>", dataTest);
|
||||
|
||||
final TestArrayShortFunc root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestArrayShortFunc.class, ExmlTestIntrospectionShort.NODE_NAME));
|
||||
Assertions.assertEquals(5, root.getValues().length);
|
||||
Assertions.assertEquals((short)12, root.getValues()[0]);
|
||||
Assertions.assertEquals((short)-13, root.getValues()[1]);
|
||||
Assertions.assertEquals((short)33, root.getValues()[2]);
|
||||
Assertions.assertEquals((short)78, root.getValues()[3]);
|
||||
Assertions.assertEquals((short)-127, root.getValues()[4]);
|
||||
}
|
||||
|
||||
public class TestNodeShortNative {
|
||||
public short valueA;
|
||||
public short valueB;
|
||||
}
|
||||
@Test
|
||||
public void testModelNodeShortNative() {
|
||||
TestNodeShortNative elem = new TestNodeShortNative();
|
||||
elem.valueA = (short)11;
|
||||
elem.valueB = (short)-120;
|
||||
|
||||
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("<elem>\n"
|
||||
+ " <valueA>11</valueA>\n"
|
||||
+ " <valueB>-120</valueB>\n"
|
||||
+ "</elem>", dataTest);
|
||||
|
||||
final TestNodeShortNative root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestNodeShortNative.class, ExmlTestIntrospectionShort.NODE_NAME));
|
||||
Assertions.assertEquals((short)11, root.valueA);
|
||||
Assertions.assertEquals((short)-120, root.valueB);
|
||||
}
|
||||
|
||||
public class TestArrayNodeShortNative {
|
||||
public short[] values;
|
||||
}
|
||||
@Test
|
||||
public void testModelArrayNodeshortNative() {
|
||||
TestArrayNodeShortNative elem = new TestArrayNodeShortNative();
|
||||
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("<elem>\n"
|
||||
+ " <values>12</values>\n"
|
||||
+ " <values>-13</values>\n"
|
||||
+ " <values>33</values>\n"
|
||||
+ " <values>78</values>\n"
|
||||
+ " <values>-127</values>\n"
|
||||
+ "</elem>", dataTest);
|
||||
|
||||
final TestArrayNodeShortNative root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestArrayNodeShortNative.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]);
|
||||
}
|
||||
|
||||
public class TestNodeshortFunc {
|
||||
private short valueA;
|
||||
private short valueB;
|
||||
public short isValueA() {
|
||||
return this.valueA;
|
||||
}
|
||||
public void setValueA(final short valueA) {
|
||||
this.valueA = valueA;
|
||||
}
|
||||
public short isValueB() {
|
||||
return this.valueB;
|
||||
}
|
||||
public void setValueB(final short valueB) {
|
||||
this.valueB = valueB;
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testModelNodeShortFunc() {
|
||||
TestNodeshortFunc elem = new TestNodeshortFunc();
|
||||
elem.setValueA((short)54);
|
||||
elem.setValueB((short)-68);
|
||||
|
||||
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("<elem>\n"
|
||||
+ " <valueA>54</valueA>\n"
|
||||
+ " <valueB>-68</valueB>\n"
|
||||
+ "</elem>", dataTest);
|
||||
|
||||
final TestNodeshortFunc root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestNodeshortFunc.class, ExmlTestIntrospectionShort.NODE_NAME));
|
||||
Assertions.assertEquals((short)54, root.isValueA());
|
||||
Assertions.assertEquals((short)-68, root.isValueB());
|
||||
}
|
||||
|
||||
public class TestArrayNodeShortFunc {
|
||||
private short[] values;
|
||||
|
||||
public short[] getValues() {
|
||||
return this.values;
|
||||
}
|
||||
|
||||
public void setValues(final short[] values) {
|
||||
this.values = values;
|
||||
}
|
||||
|
||||
}
|
||||
@Test
|
||||
public void testModelArrayNodeShortFunc() {
|
||||
TestArrayNodeShortFunc elem = new TestArrayNodeShortFunc();
|
||||
elem.setValues(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("<elem>\n"
|
||||
+ " <values>12</values>\n"
|
||||
+ " <values>-13</values>\n"
|
||||
+ " <values>33</values>\n"
|
||||
+ " <values>78</values>\n"
|
||||
+ " <values>-127</values>\n"
|
||||
+ "</elem>", dataTest);
|
||||
|
||||
final TestArrayNodeShortFunc root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestArrayNodeShortFunc.class, ExmlTestIntrospectionShort.NODE_NAME));
|
||||
Assertions.assertEquals(5, root.getValues().length);
|
||||
Assertions.assertEquals((short)12, root.getValues()[0]);
|
||||
Assertions.assertEquals((short)-13, root.getValues()[1]);
|
||||
Assertions.assertEquals((short)33, root.getValues()[2]);
|
||||
Assertions.assertEquals((short)78, root.getValues()[3]);
|
||||
Assertions.assertEquals((short)-127, root.getValues()[4]);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -17,8 +17,8 @@ public class ExmlTestParseAttribute {
|
||||
@Test
|
||||
public void testBase() {
|
||||
//@formatter:off
|
||||
ExmlLocal.test("<elementtt attr=\"plop\"/>\n",
|
||||
"<elementtt attr=\"plop\"/>\n",
|
||||
ExmlLocal.test("<elementtt attr=\"plop\"/>",
|
||||
"<elementtt attr=\"plop\"/>",
|
||||
-1);
|
||||
//@formatter:on
|
||||
}
|
||||
@ -26,8 +26,8 @@ public class ExmlTestParseAttribute {
|
||||
@Test
|
||||
public void testEmptyAttribute() {
|
||||
//@formatter:off
|
||||
ExmlLocal.test("<elementtt attr=\"\"/>\n",
|
||||
"<elementtt attr=\"\"/>\n",
|
||||
ExmlLocal.test("<elementtt attr=\"\"/>",
|
||||
"<elementtt attr=\"\"/>",
|
||||
-1);
|
||||
//@formatter:on
|
||||
}
|
||||
@ -35,8 +35,8 @@ public class ExmlTestParseAttribute {
|
||||
@Test
|
||||
public void testEmptyAttributeNoQuote() {
|
||||
//@formatter:off
|
||||
ExmlLocal.test("<elementtt attr=\"\"/>\n",
|
||||
"<elementtt attr=/>\n",
|
||||
ExmlLocal.test("<elementtt attr=\"\"/>",
|
||||
"<elementtt attr=/>",
|
||||
-1);
|
||||
//@formatter:on
|
||||
}
|
||||
@ -54,7 +54,7 @@ public class ExmlTestParseAttribute {
|
||||
public void testEndAttributeErrorMissingEqual() {
|
||||
//@formatter:off
|
||||
ExmlLocal.test("",
|
||||
"<elementtt attr \"kjlkj\"/>\n",
|
||||
"<elementtt attr \"kjlkj\"/>",
|
||||
1);
|
||||
//@formatter:on
|
||||
}
|
||||
@ -62,8 +62,8 @@ public class ExmlTestParseAttribute {
|
||||
@Test
|
||||
public void testMultiline() {
|
||||
//@formatter:off
|
||||
ExmlLocal.test("<elementtt attr=\"plop\"/>\n",
|
||||
"<elementtt attr\n=\n\"plop\"/>\n",
|
||||
ExmlLocal.test("<elementtt attr=\"plop\"/>",
|
||||
"<elementtt attr\n=\n\"plop\"/>",
|
||||
-1);
|
||||
//@formatter:on
|
||||
}
|
||||
@ -71,8 +71,8 @@ public class ExmlTestParseAttribute {
|
||||
@Test
|
||||
public void testMultilineNoQuote() {
|
||||
//@formatter:off
|
||||
ExmlLocal.test("<elementtt attr=\"plop\"/>\n",
|
||||
"<elementtt attr \n = \n\t plop/>\n",
|
||||
ExmlLocal.test("<elementtt attr=\"plop\"/>",
|
||||
"<elementtt attr \n = \n\t plop/>",
|
||||
-1);
|
||||
//@formatter:on
|
||||
}
|
||||
@ -80,8 +80,8 @@ public class ExmlTestParseAttribute {
|
||||
@Test
|
||||
public void testNoQuote() {
|
||||
//@formatter:off
|
||||
ExmlLocal.test("<elementtt attr=\"plop\"/>\n",
|
||||
"<elementtt attr=plop/>\n",
|
||||
ExmlLocal.test("<elementtt attr=\"plop\"/>",
|
||||
"<elementtt attr=plop/>",
|
||||
-1);
|
||||
//@formatter:on
|
||||
}
|
||||
@ -89,8 +89,8 @@ public class ExmlTestParseAttribute {
|
||||
@Test
|
||||
public void testNoQuoteNumber() {
|
||||
//@formatter:off
|
||||
ExmlLocal.test("<elementtt attr=\"234345@3452345_.'\"/>\n",
|
||||
"<elementtt attr=234345@3452345_.' />\n",
|
||||
ExmlLocal.test("<elementtt attr=\"234345@3452345_.'\"/>",
|
||||
"<elementtt attr=234345@3452345_.' />",
|
||||
-1);
|
||||
//@formatter:on
|
||||
}
|
||||
@ -98,8 +98,8 @@ public class ExmlTestParseAttribute {
|
||||
@Test
|
||||
public void testSpace1() {
|
||||
//@formatter:off
|
||||
ExmlLocal.test("<elementtt attr=\"plop\"/>\n",
|
||||
"<elementtt attr =\"plop\"/>\n",
|
||||
ExmlLocal.test("<elementtt attr=\"plop\"/>",
|
||||
"<elementtt attr =\"plop\"/>",
|
||||
-1);
|
||||
//@formatter:on
|
||||
}
|
||||
@ -107,8 +107,8 @@ public class ExmlTestParseAttribute {
|
||||
@Test
|
||||
public void testSpace2() {
|
||||
//@formatter:off
|
||||
ExmlLocal.test("<elementtt attr=\"plop\"/>\n",
|
||||
"<elementtt attr= \"plop\"/>\n",
|
||||
ExmlLocal.test("<elementtt attr=\"plop\"/>",
|
||||
"<elementtt attr= \"plop\"/>",
|
||||
-1);
|
||||
//@formatter:on
|
||||
}
|
||||
|
@ -17,44 +17,44 @@ public class ExmlTestParseComment {
|
||||
@Test
|
||||
public void testAll() {
|
||||
//@formatter:off
|
||||
ExmlLocal.test("<!--<.:!*%^$0945- '(- &<<< >>> '& ( '( '-' <elementPouris>-->\n",
|
||||
"<!-- <.:!*%^$0945- '(- &<<< >>> '& ( '( '-' <elementPouris> -->\n",
|
||||
ExmlLocal.test("<!--<.:!*%^$0945- '(- &<<< >>> '& ( '( '-' <elementPouris>-->",
|
||||
"<!-- <.:!*%^$0945- '(- &<<< >>> '& ( '( '-' <elementPouris> -->",
|
||||
-1);
|
||||
//@formatter:on
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBase() {
|
||||
ExmlLocal.test("<!--exemple-->\n", "<!--exemple-->\n", -1);
|
||||
ExmlLocal.test("<!--exemple-->", "<!--exemple-->\n", -1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEndError() {
|
||||
ExmlLocal.test("<!--exemple-->\n", "<!-- ssdfgdfg >\n", 1);
|
||||
ExmlLocal.test("<!--exemple-->", "<!-- ssdfgdfg >\n", 1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMultiline() {
|
||||
ExmlLocal.test("<!--exemple-->\n", "<!-- \t \t\t exemple \n\n\n\t-->\n", -1);
|
||||
ExmlLocal.test("<!--exemple-->", "<!-- \t \t\t exemple \n\n\n\t-->\n", -1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMultipleEnd() {
|
||||
ExmlLocal.test("<!--exemple-->\n", "<!-- ---> exemple -->\n", 1);
|
||||
ExmlLocal.test("<!--exemple-->", "<!-- ---> exemple -->\n", 1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNoCharInComment() {
|
||||
ExmlLocal.test("<!---->\n", "<!---->\n", -1);
|
||||
ExmlLocal.test("<!---->", "<!---->\n", -1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTiretInComment() {
|
||||
ExmlLocal.test("<!---- exemple-->\n", "<!-- -- exemple -->\n", -1);
|
||||
ExmlLocal.test("<!---- exemple-->", "<!-- -- exemple -->\n", -1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWrongEndParsing() {
|
||||
ExmlLocal.test("<!--> exemple-->\n", "<!--> exemple -->\n", -1);
|
||||
ExmlLocal.test("<!--> exemple-->", "<!--> exemple -->\n", -1);
|
||||
}
|
||||
}
|
||||
|
@ -16,46 +16,46 @@ public class ExmlTestParseDeclaration {
|
||||
|
||||
@Test
|
||||
public void testAll() {
|
||||
ExmlLocal.test("<?xml attr=\"p65421lop\"?>\n", "<?xml attr \n = \n\t p65421lop?>\n", -1);
|
||||
ExmlLocal.test("<?xml attr=\"p65421lop\"?>", "<?xml attr \n = \n\t p65421lop?>", -1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAttribute() {
|
||||
ExmlLocal.test("<?xml attr=\"plop\"?>\n", "<?xml attr=\"plop\"?>\n", -1);
|
||||
ExmlLocal.test("<?xml attr=\"plop\"?>", "<?xml attr=\"plop\"?>", -1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBase() {
|
||||
ExmlLocal.test("<?testDeclaration?>\n", "<?testDeclaration?>\n", -1);
|
||||
ExmlLocal.test("<?testDeclaration?>", "<?testDeclaration?>", -1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCaseSensitiveBalise() {
|
||||
ExmlLocal.test("<Elem/>\n", "<Elem></elem>\n", -1);
|
||||
ExmlLocal.test("<Elem/>", "<Elem></elem>", -1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMultiline() {
|
||||
ExmlLocal.test("<?xml attr=\"plop\"?>\n", "<?xml attr\n=\n\"plop\"?>\n", -1);
|
||||
ExmlLocal.test("<?xml attr=\"plop\"?>", "<?xml attr\n=\n\"plop\"?>", -1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNoQuote() {
|
||||
ExmlLocal.test("<?xml attr=\"plop\"?>\n", "<?xml attr=plop?>\n", -1);
|
||||
ExmlLocal.test("<?xml attr=\"plop\"?>", "<?xml attr=plop?>", -1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNumberNoQuote() {
|
||||
ExmlLocal.test("<?xml attr=\"234345@3452345_.'\"?>\n", "<?xml attr=234345@3452345_.' ?>\n", -1);
|
||||
ExmlLocal.test("<?xml attr=\"234345@3452345_.'\"?>", "<?xml attr=234345@3452345_.' ?>", -1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSpace1() {
|
||||
ExmlLocal.test("<?xml attr=\"plop\"?>\n", "<?xml attr =\"plop\"?>\n", -1);
|
||||
ExmlLocal.test("<?xml attr=\"plop\"?>", "<?xml attr =\"plop\"?>", -1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSpace2() {
|
||||
ExmlLocal.test("<?xml attr=\"plop\"?>\n", "<?xml attr= \"plop\"?>\n", -1);
|
||||
ExmlLocal.test("<?xml attr=\"plop\"?>", "<?xml attr= \"plop\"?>", -1);
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class ExmlTestParseElement {
|
||||
static String refOutputElement = "<exemple/>\n";
|
||||
static String refOutputElement = "<exemple/>";
|
||||
|
||||
@BeforeAll
|
||||
public static void beforeClass() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user