Java 类org.simpleframework.xml.strategy.TreeStrategy 实例源码

项目:simplexml    文件:CompositeInlineMapTest.java   
public void testNotInlineString() throws Exception 
{
   Source source = new Source(new TreeStrategy(), new Support(), new Session());
   MockElementMap map = new MockElementMap(false, // attribute
                                           false, // data
                                           "entry", // entry 
                                           true,  // inline
                                           "key", // key
                                           String.class, // keyType
                                           "name", // name
                                           true, // required
                                           "value", // value
                                           String.class); // valueType
   PrimitiveType type = new PrimitiveType(map);
   Contact string = type.getString();
   Entry entry = new Entry(string, map);
   CompositeInlineMap value = new CompositeInlineMap(source, entry, new ClassType(Map.class));
   OutputNode node = NodeBuilder.write(new PrintWriter(System.out));
   Map exampleMap = new HashMap();

   exampleMap.put("a", "1");
   exampleMap.put("b", "2");
   value.write(node.getChild("notInlineString").getChild("map"), exampleMap);
   node.commit();            
}
项目:simplexml    文件:CompositeInlineMapTest.java   
public void testNoAttributeString() throws Exception 
{
   Source source = new Source(new TreeStrategy(), new Support(), new Session());
   MockElementMap map = new MockElementMap(false, // attribute
                                           false, // data
                                           "entry", // entry 
                                           true,  // inline
                                           "", // key
                                           String.class, // keyType
                                           "name", // name
                                           true, // required
                                           "value", // value
                                           String.class); // valueType
   PrimitiveType type = new PrimitiveType(map);
   Contact string = type.getString();
   Entry entry = new Entry(string, map);
   CompositeInlineMap value = new CompositeInlineMap(source, entry, new ClassType(Map.class));
   OutputNode node = NodeBuilder.write(new PrintWriter(System.out));
   Map exampleMap = new HashMap();

   exampleMap.put("a", "1");
   exampleMap.put("b", "2");      
   value.write(node.getChild("noAttributeString").getChild("map"), exampleMap);
   node.commit();
}
项目:simplexml    文件:CompositeInlineMapTest.java   
public void testAttributeNoKeyString() throws Exception 
{
   Source source = new Source(new TreeStrategy(), new Support(), new Session());
   MockElementMap map = new MockElementMap(true, // attribute
                                           false, // data
                                           "entry", // entry 
                                           true,  // inline
                                           "", // key
                                           String.class, // keyType
                                           "name", // name
                                           true, // required
                                           "value", // value
                                           String.class); // valueType
   PrimitiveType type = new PrimitiveType(map);
   Contact string = type.getString();
   Entry entry = new Entry(string, map);
   CompositeInlineMap value = new CompositeInlineMap(source, entry, new ClassType(Map.class));
   OutputNode node = NodeBuilder.write(new PrintWriter(System.out));
   Map exampleMap = new HashMap();

   exampleMap.put("a", "1");
   exampleMap.put("b", "2");
   value.write(node.getChild("attributeNoKeyString").getChild("map"), exampleMap);
   node.commit();
}
项目:simplexml    文件:PrimitiveValueTest.java   
public void testInlineString() throws Exception 
{
   Source source = new Source(new TreeStrategy(), new Support(), new Session());
   MockElementMap map = new MockElementMap(true, // attribute
                                           false, // data
                                           "entry", // entry 
                                           true,  // inline
                                           "key", // key
                                           String.class, // keyType
                                           "name", // name
                                           true, // required
                                           "value", // value
                                           String.class); // valueType
   PrimitiveType type = new PrimitiveType(map);
   Contact string = type.getString();
   Entry entry = new Entry(string, map);
   PrimitiveValue value = new PrimitiveValue(source, entry, new ClassType(String.class));
   OutputNode node = NodeBuilder.write(new PrintWriter(System.out));

   value.write(node.getChild("inlineString"), "example");
   node.commit();
}
项目:simplexml    文件:PrimitiveValueTest.java   
public void testNotInlineString() throws Exception 
{
   Source source = new Source(new TreeStrategy(), new Support(), new Session());
   MockElementMap map = new MockElementMap(false, // attribute
                                           false, // data
                                           "entry", // entry 
                                           true,  // inline
                                           "key", // key
                                           String.class, // keyType
                                           "name", // name
                                           true, // required
                                           "value", // value
                                           String.class); // valueType
   PrimitiveType type = new PrimitiveType(map);
   Contact string = type.getString();
   Entry entry = new Entry(string, map);
   PrimitiveValue value = new PrimitiveValue(source, entry, new ClassType(String.class));
   OutputNode node = NodeBuilder.write(new PrintWriter(System.out));

   value.write(node.getChild("notInlineString"), "example");
   node.commit();            
}
项目:simplexml    文件:PrimitiveValueTest.java   
public void testNoAttributeString() throws Exception 
{
   Source source = new Source(new TreeStrategy(), new Support(), new Session());
   MockElementMap map = new MockElementMap(false, // attribute
                                           false, // data
                                           "entry", // entry 
                                           true,  // inline
                                           "", // key
                                           String.class, // keyType
                                           "name", // name
                                           true, // required
                                           "value", // value
                                           String.class); // valueType
   PrimitiveType type = new PrimitiveType(map);
   Contact string = type.getString();
   Entry entry = new Entry(string, map);
   PrimitiveValue value = new PrimitiveValue(source, entry, new ClassType(String.class));
   OutputNode node = NodeBuilder.write(new PrintWriter(System.out));

   value.write(node.getChild("noAttributeString"), "example");
   node.commit();
}
项目:simplexml    文件:PrimitiveValueTest.java   
public void testAttributeNoKeyString() throws Exception 
{
   Source source = new Source(new TreeStrategy(), new Support(), new Session());
   MockElementMap map = new MockElementMap(true, // attribute
                                           false, // data
                                           "entry", // entry 
                                           true,  // inline
                                           "", // key
                                           String.class, // keyType
                                           "name", // name
                                           true, // required
                                           "value", // value
                                           String.class); // valueType
   PrimitiveType type = new PrimitiveType(map);
   Contact string = type.getString();
   Entry entry = new Entry(string, map);
   PrimitiveValue value = new PrimitiveValue(source, entry, new ClassType(String.class));
   OutputNode node = NodeBuilder.write(new PrintWriter(System.out));

   value.write(node.getChild("attributeNoKeyString"), "example");
   node.commit();
}
项目:simplexml    文件:CompositeMapTest.java   
public void testInlineString() throws Exception 
{
   Source source = new Source(new TreeStrategy(), new Support(), new Session());
   MockElementMap map = new MockElementMap(true, // attribute
                                           false, // data
                                           "entry", // entry 
                                           true,  // inline
                                           "key", // key
                                           String.class, // keyType
                                           "name", // name
                                           true, // required
                                           "value", // value
                                           String.class); // valueType
   PrimitiveType type = new PrimitiveType(map);
   Contact string = type.getString();
   Entry entry = new Entry(string, map);
   CompositeMap value = new CompositeMap(source, entry, new ClassType(Map.class));
   OutputNode node = NodeBuilder.write(new PrintWriter(System.out));
   Map exampleMap = new HashMap();

   exampleMap.put("a", "1");
   exampleMap.put("b", "2");      
   value.write(node.getChild("inlineString"), exampleMap);
   node.commit();
}
项目:simplexml    文件:CompositeMapTest.java   
public void testNotInlineString() throws Exception 
{
   Source source = new Source(new TreeStrategy(), new Support(), new Session());
   MockElementMap map = new MockElementMap(false, // attribute
                                           false, // data
                                           "entry", // entry 
                                           true,  // inline
                                           "key", // key
                                           String.class, // keyType
                                           "name", // name
                                           true, // required
                                           "value", // value
                                           String.class); // valueType
   PrimitiveType type = new PrimitiveType(map);
   Contact string = type.getString();
   Entry entry = new Entry(string, map);
   CompositeMap value = new CompositeMap(source, entry, new ClassType(Map.class));
   OutputNode node = NodeBuilder.write(new PrintWriter(System.out));
   Map exampleMap = new HashMap();

   exampleMap.put("a", "1");
   exampleMap.put("b", "2");
   value.write(node.getChild("notInlineString"), exampleMap);
   node.commit();            
}
项目:simplexml    文件:CompositeMapTest.java   
public void testNoAttributeString() throws Exception 
{
   Source source = new Source(new TreeStrategy(), new Support(), new Session());
   MockElementMap map = new MockElementMap(false, // attribute
                                           false, // data
                                           "entry", // entry 
                                           true,  // inline
                                           "", // key
                                           String.class, // keyType
                                           "name", // name
                                           true, // required
                                           "value", // value
                                           String.class); // valueType
   PrimitiveType type = new PrimitiveType(map);
   Contact string = type.getString();
   Entry entry = new Entry(string, map);
   CompositeMap value = new CompositeMap(source, entry, new ClassType(Map.class));
   OutputNode node = NodeBuilder.write(new PrintWriter(System.out));
   Map exampleMap = new HashMap();

   exampleMap.put("a", "1");
   exampleMap.put("b", "2");      
   value.write(node.getChild("noAttributeString"), exampleMap);
   node.commit();
}
项目:simplexml    文件:CompositeMapTest.java   
public void testAttributeNoKeyString() throws Exception 
{
   Source source = new Source(new TreeStrategy(), new Support(), new Session());
   MockElementMap map = new MockElementMap(true, // attribute
                                           false, // data
                                           "entry", // entry 
                                           true,  // inline
                                           "", // key
                                           String.class, // keyType
                                           "name", // name
                                           true, // required
                                           "value", // value
                                           String.class); // valueType
   PrimitiveType type = new PrimitiveType(map);
   Contact string = type.getString();
   Entry entry = new Entry(string, map);
   CompositeMap value = new CompositeMap(source, entry, new ClassType(Map.class));
   OutputNode node = NodeBuilder.write(new PrintWriter(System.out));
   Map exampleMap = new HashMap();

   exampleMap.put("a", "1");
   exampleMap.put("b", "2");
   value.write(node.getChild("attributeNoKeyString"), exampleMap);
   node.commit();
}
项目:simplexml    文件:PrimitiveListTest.java   
public void testTwo() throws Exception {
   Context context = new Source(new TreeStrategy(), new Support(), new Session());
   PrimitiveList primitive = new PrimitiveList(context, new ClassType(List.class), new ClassType(String.class), "entry");
   InputNode node = NodeBuilder.read(new StringReader(TWO));
   Object value = primitive.read(node);

   assertEquals(value.getClass(), Vector.class);

   Vector vector = (Vector) value;

   assertEquals(vector.get(0), "one");
   assertEquals(vector.get(1), "two");

   InputNode newNode = NodeBuilder.read(new StringReader(TWO));

   assertTrue(primitive.validate(newNode)); 
}
项目:simplexml    文件:PrimitiveArrayTest.java   
public void testTwo() throws Exception {
   Context context = new Source(new TreeStrategy(), new Support(), new Session());
   PrimitiveArray primitive = new PrimitiveArray(context, new ClassType(String[].class), new ClassType(String.class), "entry");
   InputNode node = NodeBuilder.read(new StringReader(TWO));
   Object value = primitive.read(node);

   assertEquals(value.getClass(), String[].class);

   String[] list = (String[]) value;

   assertEquals(list.length, 2);
   assertEquals(list[0], "one");
   assertEquals(list[1], "two");

   InputNode newNode = NodeBuilder.read(new StringReader(TWO));

   assertTrue(primitive.validate(newNode)); 
}
项目:simplexml    文件:PrimitiveKeyTest.java   
public void testInlineString() throws Exception 
{
   Source source = new Source(new TreeStrategy(), new Support(), new Session());
   MockElementMap map = new MockElementMap(true, // attribute
                                           false, // data
                                           "entry", // entry 
                                           true,  // inline
                                           "key", // key
                                           String.class, // keyType
                                           "name", // name
                                           true, // required
                                           "value", // value
                                           String.class); // valueType
   PrimitiveType type = new PrimitiveType(map);
   Contact string = type.getString();
   Entry entry = new Entry(string, map);
   PrimitiveKey value = new PrimitiveKey(source, entry, new ClassType(String.class));
   OutputNode node = NodeBuilder.write(new PrintWriter(System.out));

   value.write(node.getChild("inlineString"), "example");
   node.commit();
}
项目:simplexml    文件:PrimitiveKeyTest.java   
public void testNotInlineString() throws Exception 
{
   Source source = new Source(new TreeStrategy(), new Support(), new Session());
   MockElementMap map = new MockElementMap(false, // attribute
                                           false, // data
                                           "entry", // entry 
                                           true,  // inline
                                           "key", // key
                                           String.class, // keyType
                                           "name", // name
                                           true, // required
                                           "value", // value
                                           String.class); // valueType
   PrimitiveType type = new PrimitiveType(map);
   Contact string = type.getString();
   Entry entry = new Entry(string, map);
   PrimitiveKey value = new PrimitiveKey(source, entry, new ClassType(String.class));
   OutputNode node = NodeBuilder.write(new PrintWriter(System.out));

   value.write(node.getChild("notInlineString"), "example");
   node.commit();            
}
项目:simplexml    文件:PrimitiveKeyTest.java   
public void testNoAttributeString() throws Exception 
{
   Source source = new Source(new TreeStrategy(), new Support(), new Session());
   MockElementMap map = new MockElementMap(false, // attribute
                                           false, // data
                                           "entry", // entry 
                                           true,  // inline
                                           "", // key
                                           String.class, // keyType
                                           "name", // name
                                           true, // required
                                           "value", // value
                                           String.class); // valueType
   PrimitiveType type = new PrimitiveType(map);
   Contact string = type.getString();
   Entry entry = new Entry(string, map);
   PrimitiveKey value = new PrimitiveKey(source, entry, new ClassType(String.class));
   OutputNode node = NodeBuilder.write(new PrintWriter(System.out));

   value.write(node.getChild("noAttributeString"), "example");
   node.commit();
}
项目:simplexml    文件:PrimitiveKeyTest.java   
public void testAttributeNoKeyString() throws Exception 
{
   Source source = new Source(new TreeStrategy(), new Support(), new Session());
   MockElementMap map = new MockElementMap(true, // attribute
                                           false, // data
                                           "entry", // entry 
                                           true,  // inline
                                           "", // key
                                           String.class, // keyType
                                           "name", // name
                                           true, // required
                                           "value", // value
                                           String.class); // valueType
   PrimitiveType type = new PrimitiveType(map);
   Contact string = type.getString();
   Entry entry = new Entry(string, map);
   PrimitiveKey value = new PrimitiveKey(source, entry, new ClassType(String.class));
   OutputNode node = NodeBuilder.write(new PrintWriter(System.out));

   value.write(node.getChild("attributeNoKeyString"), "example");
   node.commit();
}
项目:simple-xml    文件:CompositeInlineMapTest.java   
public void testNotInlineString() throws Exception 
{
   Source source = new Source(new TreeStrategy(), new Support(), new Session());
   MockElementMap map = new MockElementMap(false, // attribute
                                           false, // data
                                           "entry", // entry 
                                           true,  // inline
                                           "key", // key
                                           String.class, // keyType
                                           "name", // name
                                           true, // required
                                           "value", // value
                                           String.class); // valueType
   PrimitiveType type = new PrimitiveType(map);
   Contact string = type.getString();
   Entry entry = new Entry(string, map);
   CompositeInlineMap value = new CompositeInlineMap(source, entry, new ClassType(Map.class));
   OutputNode node = NodeBuilder.write(new PrintWriter(System.out));
   Map exampleMap = new HashMap();

   exampleMap.put("a", "1");
   exampleMap.put("b", "2");
   value.write(node.getChild("notInlineString").getChild("map"), exampleMap);
   node.commit();            
}
项目:simple-xml    文件:CompositeInlineMapTest.java   
public void testNoAttributeString() throws Exception 
{
   Source source = new Source(new TreeStrategy(), new Support(), new Session());
   MockElementMap map = new MockElementMap(false, // attribute
                                           false, // data
                                           "entry", // entry 
                                           true,  // inline
                                           "", // key
                                           String.class, // keyType
                                           "name", // name
                                           true, // required
                                           "value", // value
                                           String.class); // valueType
   PrimitiveType type = new PrimitiveType(map);
   Contact string = type.getString();
   Entry entry = new Entry(string, map);
   CompositeInlineMap value = new CompositeInlineMap(source, entry, new ClassType(Map.class));
   OutputNode node = NodeBuilder.write(new PrintWriter(System.out));
   Map exampleMap = new HashMap();

   exampleMap.put("a", "1");
   exampleMap.put("b", "2");      
   value.write(node.getChild("noAttributeString").getChild("map"), exampleMap);
   node.commit();
}
项目:simple-xml    文件:CompositeInlineMapTest.java   
public void testAttributeNoKeyString() throws Exception 
{
   Source source = new Source(new TreeStrategy(), new Support(), new Session());
   MockElementMap map = new MockElementMap(true, // attribute
                                           false, // data
                                           "entry", // entry 
                                           true,  // inline
                                           "", // key
                                           String.class, // keyType
                                           "name", // name
                                           true, // required
                                           "value", // value
                                           String.class); // valueType
   PrimitiveType type = new PrimitiveType(map);
   Contact string = type.getString();
   Entry entry = new Entry(string, map);
   CompositeInlineMap value = new CompositeInlineMap(source, entry, new ClassType(Map.class));
   OutputNode node = NodeBuilder.write(new PrintWriter(System.out));
   Map exampleMap = new HashMap();

   exampleMap.put("a", "1");
   exampleMap.put("b", "2");
   value.write(node.getChild("attributeNoKeyString").getChild("map"), exampleMap);
   node.commit();
}
项目:simple-xml    文件:PrimitiveValueTest.java   
public void testInlineString() throws Exception 
{
   Source source = new Source(new TreeStrategy(), new Support(), new Session());
   MockElementMap map = new MockElementMap(true, // attribute
                                           false, // data
                                           "entry", // entry 
                                           true,  // inline
                                           "key", // key
                                           String.class, // keyType
                                           "name", // name
                                           true, // required
                                           "value", // value
                                           String.class); // valueType
   PrimitiveType type = new PrimitiveType(map);
   Contact string = type.getString();
   Entry entry = new Entry(string, map);
   PrimitiveValue value = new PrimitiveValue(source, entry, new ClassType(String.class));
   OutputNode node = NodeBuilder.write(new PrintWriter(System.out));

   value.write(node.getChild("inlineString"), "example");
   node.commit();
}
项目:simple-xml    文件:PrimitiveValueTest.java   
public void testNotInlineString() throws Exception 
{
   Source source = new Source(new TreeStrategy(), new Support(), new Session());
   MockElementMap map = new MockElementMap(false, // attribute
                                           false, // data
                                           "entry", // entry 
                                           true,  // inline
                                           "key", // key
                                           String.class, // keyType
                                           "name", // name
                                           true, // required
                                           "value", // value
                                           String.class); // valueType
   PrimitiveType type = new PrimitiveType(map);
   Contact string = type.getString();
   Entry entry = new Entry(string, map);
   PrimitiveValue value = new PrimitiveValue(source, entry, new ClassType(String.class));
   OutputNode node = NodeBuilder.write(new PrintWriter(System.out));

   value.write(node.getChild("notInlineString"), "example");
   node.commit();            
}
项目:simple-xml    文件:PrimitiveValueTest.java   
public void testNoAttributeString() throws Exception 
{
   Source source = new Source(new TreeStrategy(), new Support(), new Session());
   MockElementMap map = new MockElementMap(false, // attribute
                                           false, // data
                                           "entry", // entry 
                                           true,  // inline
                                           "", // key
                                           String.class, // keyType
                                           "name", // name
                                           true, // required
                                           "value", // value
                                           String.class); // valueType
   PrimitiveType type = new PrimitiveType(map);
   Contact string = type.getString();
   Entry entry = new Entry(string, map);
   PrimitiveValue value = new PrimitiveValue(source, entry, new ClassType(String.class));
   OutputNode node = NodeBuilder.write(new PrintWriter(System.out));

   value.write(node.getChild("noAttributeString"), "example");
   node.commit();
}
项目:simple-xml    文件:PrimitiveValueTest.java   
public void testAttributeNoKeyString() throws Exception 
{
   Source source = new Source(new TreeStrategy(), new Support(), new Session());
   MockElementMap map = new MockElementMap(true, // attribute
                                           false, // data
                                           "entry", // entry 
                                           true,  // inline
                                           "", // key
                                           String.class, // keyType
                                           "name", // name
                                           true, // required
                                           "value", // value
                                           String.class); // valueType
   PrimitiveType type = new PrimitiveType(map);
   Contact string = type.getString();
   Entry entry = new Entry(string, map);
   PrimitiveValue value = new PrimitiveValue(source, entry, new ClassType(String.class));
   OutputNode node = NodeBuilder.write(new PrintWriter(System.out));

   value.write(node.getChild("attributeNoKeyString"), "example");
   node.commit();
}
项目:simple-xml    文件:CompositeMapTest.java   
public void testInlineString() throws Exception 
{
   Source source = new Source(new TreeStrategy(), new Support(), new Session());
   MockElementMap map = new MockElementMap(true, // attribute
                                           false, // data
                                           "entry", // entry 
                                           true,  // inline
                                           "key", // key
                                           String.class, // keyType
                                           "name", // name
                                           true, // required
                                           "value", // value
                                           String.class); // valueType
   PrimitiveType type = new PrimitiveType(map);
   Contact string = type.getString();
   Entry entry = new Entry(string, map);
   CompositeMap value = new CompositeMap(source, entry, new ClassType(Map.class));
   OutputNode node = NodeBuilder.write(new PrintWriter(System.out));
   Map exampleMap = new HashMap();

   exampleMap.put("a", "1");
   exampleMap.put("b", "2");      
   value.write(node.getChild("inlineString"), exampleMap);
   node.commit();
}
项目:simple-xml    文件:CompositeMapTest.java   
public void testNotInlineString() throws Exception 
{
   Source source = new Source(new TreeStrategy(), new Support(), new Session());
   MockElementMap map = new MockElementMap(false, // attribute
                                           false, // data
                                           "entry", // entry 
                                           true,  // inline
                                           "key", // key
                                           String.class, // keyType
                                           "name", // name
                                           true, // required
                                           "value", // value
                                           String.class); // valueType
   PrimitiveType type = new PrimitiveType(map);
   Contact string = type.getString();
   Entry entry = new Entry(string, map);
   CompositeMap value = new CompositeMap(source, entry, new ClassType(Map.class));
   OutputNode node = NodeBuilder.write(new PrintWriter(System.out));
   Map exampleMap = new HashMap();

   exampleMap.put("a", "1");
   exampleMap.put("b", "2");
   value.write(node.getChild("notInlineString"), exampleMap);
   node.commit();            
}
项目:simple-xml    文件:CompositeMapTest.java   
public void testNoAttributeString() throws Exception 
{
   Source source = new Source(new TreeStrategy(), new Support(), new Session());
   MockElementMap map = new MockElementMap(false, // attribute
                                           false, // data
                                           "entry", // entry 
                                           true,  // inline
                                           "", // key
                                           String.class, // keyType
                                           "name", // name
                                           true, // required
                                           "value", // value
                                           String.class); // valueType
   PrimitiveType type = new PrimitiveType(map);
   Contact string = type.getString();
   Entry entry = new Entry(string, map);
   CompositeMap value = new CompositeMap(source, entry, new ClassType(Map.class));
   OutputNode node = NodeBuilder.write(new PrintWriter(System.out));
   Map exampleMap = new HashMap();

   exampleMap.put("a", "1");
   exampleMap.put("b", "2");      
   value.write(node.getChild("noAttributeString"), exampleMap);
   node.commit();
}
项目:simple-xml    文件:CompositeMapTest.java   
public void testAttributeNoKeyString() throws Exception 
{
   Source source = new Source(new TreeStrategy(), new Support(), new Session());
   MockElementMap map = new MockElementMap(true, // attribute
                                           false, // data
                                           "entry", // entry 
                                           true,  // inline
                                           "", // key
                                           String.class, // keyType
                                           "name", // name
                                           true, // required
                                           "value", // value
                                           String.class); // valueType
   PrimitiveType type = new PrimitiveType(map);
   Contact string = type.getString();
   Entry entry = new Entry(string, map);
   CompositeMap value = new CompositeMap(source, entry, new ClassType(Map.class));
   OutputNode node = NodeBuilder.write(new PrintWriter(System.out));
   Map exampleMap = new HashMap();

   exampleMap.put("a", "1");
   exampleMap.put("b", "2");
   value.write(node.getChild("attributeNoKeyString"), exampleMap);
   node.commit();
}
项目:simple-xml    文件:PrimitiveListTest.java   
public void testTwo() throws Exception {
   Context context = new Source(new TreeStrategy(), new Support(), new Session());
   PrimitiveList primitive = new PrimitiveList(context, new ClassType(List.class), new ClassType(String.class), "entry");
   InputNode node = NodeBuilder.read(new StringReader(TWO));
   Object value = primitive.read(node);

   assertEquals(value.getClass(), Vector.class);

   Vector vector = (Vector) value;

   assertEquals(vector.get(0), "one");
   assertEquals(vector.get(1), "two");

   InputNode newNode = NodeBuilder.read(new StringReader(TWO));

   assertTrue(primitive.validate(newNode)); 
}
项目:simple-xml    文件:PrimitiveArrayTest.java   
public void testTwo() throws Exception {
   Context context = new Source(new TreeStrategy(), new Support(), new Session());
   PrimitiveArray primitive = new PrimitiveArray(context, new ClassType(String[].class), new ClassType(String.class), "entry");
   InputNode node = NodeBuilder.read(new StringReader(TWO));
   Object value = primitive.read(node);

   assertEquals(value.getClass(), String[].class);

   String[] list = (String[]) value;

   assertEquals(list.length, 2);
   assertEquals(list[0], "one");
   assertEquals(list[1], "two");

   InputNode newNode = NodeBuilder.read(new StringReader(TWO));

   assertTrue(primitive.validate(newNode)); 
}
项目:simple-xml    文件:PrimitiveKeyTest.java   
public void testInlineString() throws Exception 
{
   Source source = new Source(new TreeStrategy(), new Support(), new Session());
   MockElementMap map = new MockElementMap(true, // attribute
                                           false, // data
                                           "entry", // entry 
                                           true,  // inline
                                           "key", // key
                                           String.class, // keyType
                                           "name", // name
                                           true, // required
                                           "value", // value
                                           String.class); // valueType
   PrimitiveType type = new PrimitiveType(map);
   Contact string = type.getString();
   Entry entry = new Entry(string, map);
   PrimitiveKey value = new PrimitiveKey(source, entry, new ClassType(String.class));
   OutputNode node = NodeBuilder.write(new PrintWriter(System.out));

   value.write(node.getChild("inlineString"), "example");
   node.commit();
}
项目:simple-xml    文件:PrimitiveKeyTest.java   
public void testNotInlineString() throws Exception 
{
   Source source = new Source(new TreeStrategy(), new Support(), new Session());
   MockElementMap map = new MockElementMap(false, // attribute
                                           false, // data
                                           "entry", // entry 
                                           true,  // inline
                                           "key", // key
                                           String.class, // keyType
                                           "name", // name
                                           true, // required
                                           "value", // value
                                           String.class); // valueType
   PrimitiveType type = new PrimitiveType(map);
   Contact string = type.getString();
   Entry entry = new Entry(string, map);
   PrimitiveKey value = new PrimitiveKey(source, entry, new ClassType(String.class));
   OutputNode node = NodeBuilder.write(new PrintWriter(System.out));

   value.write(node.getChild("notInlineString"), "example");
   node.commit();            
}
项目:simple-xml    文件:PrimitiveKeyTest.java   
public void testNoAttributeString() throws Exception 
{
   Source source = new Source(new TreeStrategy(), new Support(), new Session());
   MockElementMap map = new MockElementMap(false, // attribute
                                           false, // data
                                           "entry", // entry 
                                           true,  // inline
                                           "", // key
                                           String.class, // keyType
                                           "name", // name
                                           true, // required
                                           "value", // value
                                           String.class); // valueType
   PrimitiveType type = new PrimitiveType(map);
   Contact string = type.getString();
   Entry entry = new Entry(string, map);
   PrimitiveKey value = new PrimitiveKey(source, entry, new ClassType(String.class));
   OutputNode node = NodeBuilder.write(new PrintWriter(System.out));

   value.write(node.getChild("noAttributeString"), "example");
   node.commit();
}
项目:simple-xml    文件:PrimitiveKeyTest.java   
public void testAttributeNoKeyString() throws Exception 
{
   Source source = new Source(new TreeStrategy(), new Support(), new Session());
   MockElementMap map = new MockElementMap(true, // attribute
                                           false, // data
                                           "entry", // entry 
                                           true,  // inline
                                           "", // key
                                           String.class, // keyType
                                           "name", // name
                                           true, // required
                                           "value", // value
                                           String.class); // valueType
   PrimitiveType type = new PrimitiveType(map);
   Contact string = type.getString();
   Entry entry = new Entry(string, map);
   PrimitiveKey value = new PrimitiveKey(source, entry, new ClassType(String.class));
   OutputNode node = NodeBuilder.write(new PrintWriter(System.out));

   value.write(node.getChild("attributeNoKeyString"), "example");
   node.commit();
}
项目:simplexml    文件:PrimitiveArrayTest.java   
public void testZero() throws Exception {
   Context context = new Source(new TreeStrategy(), new Support(), new Session());
   PrimitiveArray primitive = new PrimitiveArray(context, new ClassType(String[].class), new ClassType(String.class), "entry");
   InputNode node = NodeBuilder.read(new StringReader(ZERO));
   Object value = primitive.read(node);

   assertEquals(value.getClass(), String[].class);

   InputNode newNode = NodeBuilder.read(new StringReader(ZERO));

   assertTrue(primitive.validate(newNode)); 
}
项目:simplexml    文件:ConversionTest.java   
public void testConverter() throws Exception {
   Registry registry = new Registry();
   Strategy strategy = new TreeStrategy();
   Strategy interceptor = new Interceptor(strategy, registry);
   Persister persister = new Persister(interceptor);
   StringWriter writer = new StringWriter();
   PetShop shop = new PetShop();

   registry.register(Dog.class, DogConverter.class);
   registry.register(Cat.class, CatConverter.class);

   shop.addPet(new Dog("Lassie", 10));
   shop.addPet(new Cat("Kitty", 2));

   persister.write(shop, writer);
   persister.write(shop, System.out);

   String text = writer.toString();
   PetShop newShop = persister.read(PetShop.class, text);

   assertEquals("Lassie", newShop.getPet("Lassie").getName());
   assertEquals(10, newShop.getPet("Lassie").getAge());
   assertEquals("Kitty", newShop.getPet("Kitty").getName());
   assertEquals(2, newShop.getPet("Kitty").getAge());

   assertElementHasAttribute(text, "/petShop/pets/pet", "name", "Lassie");
   assertElementHasAttribute(text, "/petShop/pets/pet", "age", "10");
   assertElementExists(text, "/petShop/pets/pet[2]/name");
   assertElementExists(text, "/petShop/pets/pet[2]/age");
}
项目:simplexml    文件:PrimitiveTest.java   
public void testPrimitive() throws Exception {
   Context context = new Source(new TreeStrategy(), new Support(), new Session());
   Primitive primitive = new Primitive(context, new ClassType(String.class));
   InputNode node = NodeBuilder.read(new StringReader(SOURCE));
   Object value = primitive.read(node);

   assertEquals("some text", value);

   InputNode newNode = NodeBuilder.read(new StringReader(SOURCE));

   assertTrue(primitive.validate(newNode)); 
}
项目:simple-xml    文件:PrimitiveArrayTest.java   
public void testZero() throws Exception {
   Context context = new Source(new TreeStrategy(), new Support(), new Session());
   PrimitiveArray primitive = new PrimitiveArray(context, new ClassType(String[].class), new ClassType(String.class), "entry");
   InputNode node = NodeBuilder.read(new StringReader(ZERO));
   Object value = primitive.read(node);

   assertEquals(value.getClass(), String[].class);

   InputNode newNode = NodeBuilder.read(new StringReader(ZERO));

   assertTrue(primitive.validate(newNode)); 
}
项目:simple-xml    文件:ConversionTest.java   
public void testConverter() throws Exception {
   Registry registry = new Registry();
   Strategy strategy = new TreeStrategy();
   Strategy interceptor = new Interceptor(strategy, registry);
   Persister persister = new Persister(interceptor);
   StringWriter writer = new StringWriter();
   PetShop shop = new PetShop();

   registry.register(Dog.class, DogConverter.class);
   registry.register(Cat.class, CatConverter.class);

   shop.addPet(new Dog("Lassie", 10));
   shop.addPet(new Cat("Kitty", 2));

   persister.write(shop, writer);
   persister.write(shop, System.out);

   String text = writer.toString();
   PetShop newShop = persister.read(PetShop.class, text);

   assertEquals("Lassie", newShop.getPet("Lassie").getName());
   assertEquals(10, newShop.getPet("Lassie").getAge());
   assertEquals("Kitty", newShop.getPet("Kitty").getName());
   assertEquals(2, newShop.getPet("Kitty").getAge());

   assertElementHasAttribute(text, "/petShop/pets/pet", "name", "Lassie");
   assertElementHasAttribute(text, "/petShop/pets/pet", "age", "10");
   assertElementExists(text, "/petShop/pets/pet[2]/name");
   assertElementExists(text, "/petShop/pets/pet[2]/age");
}
项目:simple-xml    文件:PrimitiveTest.java   
public void testPrimitive() throws Exception {
   Context context = new Source(new TreeStrategy(), new Support(), new Session());
   Primitive primitive = new Primitive(context, new ClassType(String.class));
   InputNode node = NodeBuilder.read(new StringReader(SOURCE));
   Object value = primitive.read(node);

   assertEquals("some text", value);

   InputNode newNode = NodeBuilder.read(new StringReader(SOURCE));

   assertTrue(primitive.validate(newNode)); 
}