示例#1
0
  public void testDeserializza() throws FileNotFoundException {

    Context context =
        (Context) _xstream.fromXML(new FileInputStream(new File("./applconf/test.xml")));
    assertTrue(context.getBeanscontext().size() > 0);

    List<BeanContext> beans = context.getBeanscontext();
    ListIterator<BeanContext> beansIterator = beans.listIterator();
    BeanContext beanContext;

    System.out.println("\r\n\r\n");
    System.out.println(_xstream.toXML(context));

    while (beansIterator.hasNext()) {
      beanContext = ((BeanContext) beansIterator.next());
      assertTrue(beanContext.getId().id() != null);

      /*
      boolean b = beanContext.containsEntryProperty("nome");
      System.out.println(b);
      assertTrue(b);
      */
    }
  }
示例#2
0
  public void testBeanSerialize2() {

    Id id = new Id("pippo");
    ClassName className = new ClassName("org.jod.pippo");
    BeanContext beanContext = new BeanContext(id, className);

    Entry aEntry = new Entry(new Key("chiave1"), new Value("value1"));
    beanContext.add(aEntry);
    aEntry = new Entry(new Key("chiave2"), new Value("value2"));
    beanContext.add(aEntry);

    EntryMap aEntryMap = new EntryMap(new Key("mapkey_1"));
    aEntry = new Entry(new Key("chiave_1_1"), new Value("value_1_1"));
    aEntryMap.add(aEntry);
    aEntry = new Entry(new Key("chiave_1_2"), new Value("value_1_2"));
    aEntryMap.add(aEntry);

    beanContext.add(aEntryMap);

    aEntryMap = new EntryMap(new Key("mapkey_2"));
    aEntry = new Entry(new Key("chiave_2_1"), new Value("value_2_1"));
    aEntryMap.add(aEntry);
    aEntry = new Entry(new Key("chiave_2_2"), new Value("value_2_2"));
    aEntryMap.add(aEntry);
    aEntry = new Entry(new Key("chiave_2_3"), new Value("value_2_3"));
    aEntryMap.add(aEntry);

    beanContext.add(aEntryMap);

    boolean b = beanContext.containsEntryProperty("chiave1");
    assertTrue(b);
    Context context = new Context();
    context.add(beanContext);

    System.out.println(_xstream.toXML(context));
  }