use of org.jose4j.json.internal.json_simple.JSONObject in project open-ecard by ecsec.
the class TestRealVersionUpdate method versionUpdateinvalidSemanticVersionSpecified.
@Test(enabled = true)
public void versionUpdateinvalidSemanticVersionSpecified() {
try {
String invalidVersion = "0.0.0";
JSONObject obj = new JSONObjectBuilder().version(invalidVersion).build();
VersionUpdate update = VersionUpdate.fromJson(obj);
// Exception expected
Assert.fail();
} catch (InvalidUpdateDefinition ex) {
Assert.assertEquals(ex.getMessage(), "Invalid version specified.");
}
}
use of org.jose4j.json.internal.json_simple.JSONObject in project service-proxy by membrane.
the class GenericJsonParserTest method testChildElement.
@Test
public void testChildElement() {
JSONObject spec = new JSONObject(new HashMap<String, Object>() {
{
put("path", new HashMap<String, Object>() {
{
put("isRegExp", true);
put("value", "/abb");
}
});
}
});
ServiceProxy sp = GenericJsonParser.parse(ServiceProxy.class, spec);
assertTrue(sp.getPath().isRegExp());
assertEquals("/abb", sp.getPath().getValue());
}
use of org.jose4j.json.internal.json_simple.JSONObject in project service-proxy by membrane.
the class GenericJsonParserTest method testAttributeBoolean.
@Test
public void testAttributeBoolean() {
JSONObject spec = new JSONObject(new HashMap<String, Object>() {
{
put("blockRequest", true);
}
});
ServiceProxy sp = GenericJsonParser.parse(ServiceProxy.class, spec);
assertTrue(sp.isBlockRequest());
}
use of org.jose4j.json.internal.json_simple.JSONObject in project service-proxy by membrane.
the class GenericJsonParserTest method testMultipleChildElements.
@Test
public void testMultipleChildElements() {
JSONObject spec = new JSONObject(new HashMap<String, Object>() {
{
put("interceptors", Arrays.asList(new HashMap<String, Object>() {
{
put("groovy", new HashMap<String, Object>() {
{
put("src", "println()");
}
});
}
}, new HashMap<String, Object>() {
{
put("target", new HashMap<String, Object>() {
{
put("host", "localhost");
put("port", 8080);
}
});
}
}));
}
});
ServiceProxy sp = GenericJsonParser.parse(ServiceProxy.class, spec);
assertEquals(2, sp.getInterceptors().size());
assertTrue(sp.getInterceptors().get(0) instanceof GroovyInterceptor);
assertEquals("println()", ((GroovyInterceptor) sp.getInterceptors().get(0)).getSrc());
assertTrue(sp.getInterceptors().get(1) instanceof AbstractServiceProxy.Target);
assertEquals("localhost", ((AbstractServiceProxy.Target) sp.getInterceptors().get(1)).getHost());
assertEquals(8080, ((AbstractServiceProxy.Target) sp.getInterceptors().get(1)).getPort());
}
use of org.jose4j.json.internal.json_simple.JSONObject in project service-proxy by membrane.
the class GenericJsonParserTest method testChildElements.
@Test
public void testChildElements() {
JSONObject spec = new JSONObject(new HashMap<String, Object>() {
{
put("interceptors", Collections.singletonList(new HashMap<String, Object>() {
{
put("groovy", new HashMap<String, Object>() {
{
put("src", "println()");
}
});
}
}));
}
});
ServiceProxy sp = GenericJsonParser.parse(ServiceProxy.class, spec);
assertFalse(sp.getInterceptors().isEmpty());
assertEquals("println()", ((GroovyInterceptor) sp.getInterceptors().get(0)).getSrc());
}
Aggregations