use of org.simpleframework.xml.core.Persister in project randomizedtesting by randomizedtesting.
the class TestAntXmlReport method summary.
@Test
public void summary() throws Exception {
super.executeTarget("antxml-summary");
Persister p = new Persister();
File parent = getProject().getBaseDir();
MavenFailsafeSummaryModel_Local m1 = p.read(MavenFailsafeSummaryModel_Local.class, new File(parent, "ant-xmls2/summary1.xml"));
assertEquals(255, (int) m1.result);
assertEquals(5, m1.completed);
assertEquals(2, m1.skipped);
assertEquals(1, m1.errors);
assertEquals(1, m1.failures);
m1 = p.read(MavenFailsafeSummaryModel_Local.class, new File(parent, "ant-xmls2/summary2.xml"));
assertEquals(null, m1.result);
assertEquals(1, m1.completed);
assertEquals(0, m1.skipped);
assertEquals(0, m1.errors);
assertEquals(0, m1.failures);
m1 = p.read(MavenFailsafeSummaryModel_Local.class, new File(parent, "ant-xmls2/summary3.xml"));
assertEquals(254, (int) m1.result);
assertEquals(0, m1.completed);
assertEquals(0, m1.skipped);
assertEquals(0, m1.errors);
assertEquals(0, m1.failures);
}
use of org.simpleframework.xml.core.Persister in project RoboZombie by sahan.
the class DeserializerEndpointTest method testParseXml.
/**
* <p>Test for {@link Deserializers#XML}.
*
* @throws Exception
* if the test terminated with an error
*
* @since 1.3.0
*/
@Test
public final void testParseXml() throws Exception {
Robolectric.getFakeHttpLayer().interceptHttpRequests(false);
String subpath = "/xml";
User user = new User(1, "Shiro", "Wretched-Egg", 17, true);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
new Persister().write(user, baos);
stubFor(get(urlEqualTo(subpath)).willReturn(aResponse().withStatus(200).withBody(baos.toString())));
User deserializedUser = deserializerEndpoint.deserializeXml();
verify(getRequestedFor(urlEqualTo(subpath)));
assertEquals(user.getId(), deserializedUser.getId());
assertEquals(user.getFirstName(), deserializedUser.getFirstName());
assertEquals(user.getLastName(), deserializedUser.getLastName());
assertEquals(user.getAge(), deserializedUser.getAge());
assertEquals(user.isImmortal(), deserializedUser.isImmortal());
}
use of org.simpleframework.xml.core.Persister in project RoboZombie by sahan.
the class SerializerEndpointTest method testSerializeXml.
/**
* <p>Test for {@link Serializers#XML}.</p>
*
* @since 1.3.0
*/
@Test
public final void testSerializeXml() throws Exception {
Robolectric.getFakeHttpLayer().interceptHttpRequests(false);
String subpath = "/xml";
User user = new User(1, "Shiro", "Wretched-Egg", 17, true);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
new Persister().write(user, baos);
stubFor(put(urlEqualTo(subpath)).willReturn(aResponse().withStatus(200)));
serializerEndpoint.serializeXml(user);
verify(putRequestedFor(urlEqualTo(subpath)).withRequestBody(equalTo(baos.toString())));
}
use of org.simpleframework.xml.core.Persister in project syncany by syncany.
the class WatchRunner method start.
public void start() {
watchThread = new Thread(new Runnable() {
@Override
public void run() {
try {
logger.log(Level.INFO, "STARTING watch at" + config.getLocalDir());
watchOperationResult = null;
// Write port to portFile
File portFile = config.getPortFile();
portFile.createNewFile();
portFile.deleteOnExit();
new Persister().write(portTO, portFile);
// Start operation (blocks!)
watchOperationResult = watchOperation.execute();
logger.log(Level.INFO, "STOPPED watch at " + config.getLocalDir());
} catch (Exception e) {
logger.log(Level.SEVERE, "ERROR while running watch at " + config.getLocalDir(), e);
}
}
}, "WR/" + config.getLocalDir().getName());
watchThread.start();
}
use of org.simpleframework.xml.core.Persister in project syncany by syncany.
the class ConfigTO method load.
public static ConfigTO load(File file) throws ConfigException {
try {
Registry registry = new Registry();
Strategy strategy = new RegistryStrategy(registry);
registry.bind(SaltedSecretKey.class, new SaltedSecretKeyConverter());
registry.bind(String.class, new EncryptedTransferSettingsConverter());
return new Persister(strategy).read(ConfigTO.class, file);
} catch (ClassNotFoundException ex) {
// Ugly hack to catch common case of non-existing plugin
String message = ex.getMessage();
if (!message.startsWith("org.syncany.plugins.")) {
// Apparently there are other ClassNotFoundExceptions possible.
throw new ConfigException("Config file does not exist or is invalid: " + file, ex);
}
message = message.replaceFirst("org.syncany.plugins.", "");
message = message.replaceAll("\\..*", "");
throw new ConfigException("Is the " + message + " plugin installed?");
} catch (Exception ex) {
throw new ConfigException("Config file does not exist or is invalid: " + file, ex);
}
}
Aggregations