コード例 #1
0
  public String serialize() {

    String str =
        Username
            + " "
            + Password
            + " "
            + readOnlyStr()
            + " "
            + UID
            + " "
            + GID
            + " "
            + Home
            + " "
            + Root;
    if (!Root.equals(FsRoot)) {
      str = str + " " + FsRoot;
    }
    return str;
  }
コード例 #2
0
  @Test
  @Ignore
  public void testSerialization() throws Exception {
    Root unmarshalledRoot = new Root();
    EmailAddress unmarshalledObject = createFixture();
    unmarshalledRoot.setEmailAddress(unmarshalledObject);

    // Marshall
    JAXBContext context = JAXBContext.newInstance(Root.class, EmailAddress.class);
    Marshaller marshaller = context.createMarshaller();
    StringWriter writer = new StringWriter();
    marshaller.marshal(unmarshalledRoot, writer);
    String outString = writer.toString();
    assertTrue(outString.contains("<emailAddress"));

    // Unmarshall
    context = JAXBContext.newInstance(Root.class, EmailAddress.class);
    Unmarshaller unmarshaller = context.createUnmarshaller();
    StringReader reader = new StringReader(outString);
    Root marshalledRoot = (Root) unmarshaller.unmarshal(reader);
    Assert.isTrue(unmarshalledRoot.equals(marshalledRoot));
    assertEquals(unmarshalledRoot, marshalledRoot);
  }