use of com.datatorrent.stram.util.JSONSerializationProvider in project apex-core by apache.
the class AppPackageTest method testPropertyInfoSerializer.
@Test
public void testPropertyInfoSerializer() throws JsonGenerationException, JsonMappingException, IOException {
AppPackage.PropertyInfo propertyInfo = new AppPackage.PropertyInfo("test-value", "test-description");
JSONSerializationProvider jomp = new JSONSerializationProvider();
jomp.addSerializer(PropertyInfo.class, new AppPackage.PropertyInfoSerializer(false));
String result = jomp.getContext(null).writeValueAsString(propertyInfo);
Assert.assertEquals("\"test-value\"", result);
jomp = new JSONSerializationProvider();
jomp.addSerializer(PropertyInfo.class, new AppPackage.PropertyInfoSerializer(true));
result = jomp.getContext(null).writeValueAsString(propertyInfo);
Assert.assertEquals("{\"value\":\"test-value\",\"description\":\"test-description\"}", result);
}
use of com.datatorrent.stram.util.JSONSerializationProvider in project apex-core by apache.
the class AppPackageTest method starting.
@BeforeClass
public static void starting() throws IOException, JSONException {
File file = StramTestSupport.createAppPackageFile();
// Set up test instance
ap = new AppPackage(file, true);
try {
// set up another instance
File testfolder = new File("target/testapp");
yap = new AppPackage(file, testfolder, false);
jomp = new JSONSerializationProvider();
json = new JSONObject(jomp.getContext(null).writeValueAsString(ap));
} finally {
IOUtils.closeQuietly(ap);
IOUtils.closeQuietly(yap);
}
}
Aggregations