Package org.simpleframework.xml.core

Examples of org.simpleframework.xml.core.Persister


    assertEquals(0, new File(testConnection.getPath() + "/multichunks/").listFiles().length);
    assertEquals(1, new File(testConnection.getPath() + "/actions/").listFiles().length);
    assertEquals(1, new File(testConnection.getPath() + "/transactions/").listFiles().length);

    File transactionFile = new File(testConnection.getPath() + "/transactions/").listFiles()[0];
    TransactionTO transactionTO = new Persister().read(TransactionTO.class, transactionFile);

    assertEquals(2, transactionTO.getActions().size());
    assertTrue(transactionTO.getActions().get(0).getRemoteFile().getName().contains("multichunk-"));
    assertTrue(transactionTO.getActions().get(1).getRemoteFile().getName().contains("database-"));
View Full Code Here


    assertEquals(1, new File(testConnection.getPath() + "/transactions/").listFiles().length);

    assertEquals(1, new File(testConnection.getPath() + "/temporary/").listFiles().length);

    File transactionFile = new File(testConnection.getPath() + "/transactions/").listFiles()[0];
    TransactionTO transactionTO = new Persister().read(TransactionTO.class, transactionFile);

    assertEquals(2, transactionTO.getActions().size());
    assertTrue(transactionTO.getActions().get(0).getRemoteFile().getName().contains("multichunk-"));
    assertTrue(transactionTO.getActions().get(1).getRemoteFile().getName().contains("database-"));
View Full Code Here

    assertEquals(1, tempFiles.length);
    assertTrue(tempFiles[0].length() > 500 * 1024); // 1 MC with 1 MB, 1 with 4 MB; must be larger than 500 KB

    File transactionFile = new File(testConnection.getPath() + "/transactions/").listFiles()[0];
    TransactionTO transactionTO = new Persister().read(TransactionTO.class, transactionFile);

    assertEquals(3, transactionTO.getActions().size());
    assertTrue(transactionTO.getActions().get(0).getRemoteFile().getName().contains("multichunk-"));
    assertTrue(transactionTO.getActions().get(1).getRemoteFile().getName().contains("multichunk-"));
    assertTrue(transactionTO.getActions().get(2).getRemoteFile().getName().contains("database-"));
View Full Code Here

    assertEquals(2, tempFiles.length);
    assertTrue(tempFiles[0].length() > 500 * 1024 || tempFiles[1].length() > 500 * 1024); // The second multichunk should be >500 KB
    assertTrue(tempFiles[0].length() < 100 * 1024 || tempFiles[1].length() < 100 * 1024); // The database file should be <100 KB

    File transactionFile = new File(testConnection.getPath() + "/transactions/").listFiles()[0];
    TransactionTO transactionTO = new Persister().read(TransactionTO.class, transactionFile);

    assertEquals(3, transactionTO.getActions().size());
    assertTrue(transactionTO.getActions().get(0).getRemoteFile().getName().contains("multichunk-"));
    assertTrue(transactionTO.getActions().get(1).getRemoteFile().getName().contains("multichunk-"));
    assertTrue(transactionTO.getActions().get(2).getRemoteFile().getName().contains("database-"));
View Full Code Here

    assertEquals(2, tempFiles.length);
    assertTrue(tempFiles[0].length() > 500 * 1024 || tempFiles[1].length() > 500 * 1024); // The second multichunk should be >500 KB
    assertTrue(tempFiles[0].length() < 100 * 1024 || tempFiles[1].length() < 100 * 1024); // The database file should be <100 KB

    File transactionFile = new File(testConnection.getPath() + "/transactions/").listFiles()[0];
    TransactionTO transactionTO = new Persister().read(TransactionTO.class, transactionFile);

    assertEquals(3, transactionTO.getActions().size());
    assertTrue(transactionTO.getActions().get(0).getRemoteFile().getName().contains("multichunk-"));
    assertTrue(transactionTO.getActions().get(1).getRemoteFile().getName().contains("multichunk-"));
    assertTrue(transactionTO.getActions().get(2).getRemoteFile().getName().contains("database-"));
View Full Code Here

    this.repoId = repoId;
  }

  public void save(File file) throws ConfigException {
    try {
      new Persister().write(this, file);
    }
    catch (Exception e) {
      throw new ConfigException("Cannot write repoTO to file " + file, e);
    }
  }
View Full Code Here

  public void save(File file, List<CipherSpec> cipherSpecs, SaltedSecretKey masterKey) throws ConfigException {
    try {

      ByteArrayOutputStream plaintextRepoOutputStream = new ByteArrayOutputStream();

      Serializer serializer = new Persister();
      serializer.write(this, plaintextRepoOutputStream);

      CipherUtil.encrypt(new ByteArrayInputStream(plaintextRepoOutputStream.toByteArray()), new FileOutputStream(file), cipherSpecs, masterKey);
    }
    catch (Exception e) {
      throw new ConfigException("Cannot write repoTO (encrypted) to file " + file, e);
View Full Code Here

    }
    else {
      is = transformer.createInputStream(new FileInputStream(transactionFile));
    }

    return new Persister().read(TransactionTO.class, is);
  }
View Full Code Here

    else {
      out = new PrintWriter(new OutputStreamWriter(
          transformer.createOutputStream(new FileOutputStream(transactionFile)), "UTF-8"));
    }

    Serializer serializer = new Persister();
    serializer.write(this, out);
    out.flush();
    out.close();
  }
View Full Code Here

    lts.setPath(File.createTempFile("aaa", "bbb"));
    ts.subsettings = lts;

    assertTrue(ts.isValid());

    Serializer serializer = new Persister();
    serializer.write(conf, tmpFile);

    System.out.println(new String(Files.readAllBytes(Paths.get(tmpFile.toURI()))));

    ConfigTO confRestored = ConfigTO.load(tmpFile);
    TransferPlugin plugin = Plugins.get(confRestored.getTransferSettings().getType(), TransferPlugin.class);
View Full Code Here

TOP

Related Classes of org.simpleframework.xml.core.Persister

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.