Java Code Examples for io.vertx.core.json.DecodeException#printStackTrace()

The following examples show how to use io.vertx.core.json.DecodeException#printStackTrace() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BeanTest.java    From okapi with Apache License 2.0 6 votes vote down vote up
@Test
public void testDeploymentDescriptor1() {
  int fail = 0;
  final String docSampleDeployment = "{" + LS
    + "  \"srvcId\" : \"sample-module-1\"," + LS
    + "  \"descriptor\" : {" + LS
    + "    \"exec\" : "
    + "\"java -Dport=%p -jar ../okapi-test-module/target/okapi-test-module-fat.jar\"," + LS
    + "    \"env\" : [ {" + LS
    + "      \"name\" : \"helloGreeting\"," + LS
    + "      \"value\" : \"hej\"" + LS
    + "    } ]" + LS
    + "  }" + LS
    + "}";

  try {
    final DeploymentDescriptor md = Json.decodeValue(docSampleDeployment,
      DeploymentDescriptor.class);
    String pretty = Json.encodePrettily(md);
    assertEquals(docSampleDeployment, pretty);
  } catch (DecodeException ex) {
    ex.printStackTrace();
    fail = 400;
  }
  assertEquals(0, fail);
}
 
Example 2
Source File: BeanTest.java    From okapi with Apache License 2.0 6 votes vote down vote up
@Test
public void testDeploymentDescriptor2() {
  int fail = 0;
  final String docSampleDeployment = "{" + LS
    + "  \"srvcId\" : \"sample-module-1\"," + LS
    + "  \"descriptor\" : {" + LS
    + "    \"exec\" : "
    + "\"java -Dport=%p -jar ../okapi-test-module/target/okapi-test-module-fat.jar\"," + LS
    + "    \"env\" : [ {" + LS
    + "      \"name\" : \"helloGreeting\"" + LS
    + "    } ]" + LS
    + "  }" + LS
    + "}";

  try {
    final DeploymentDescriptor md = Json.decodeValue(docSampleDeployment,
      DeploymentDescriptor.class);
    String pretty = Json.encodePrettily(md);
    assertEquals(docSampleDeployment, pretty);
  } catch (DecodeException ex) {
    ex.printStackTrace();
    fail = 400;
  }
  assertEquals(0, fail);
}
 
Example 3
Source File: BeanTest.java    From okapi with Apache License 2.0 6 votes vote down vote up
@Test
public void testDeploymentDescriptor3() {
  int fail = 0;
  final String docSampleDeployment = "{" + LS
    + "  \"srvcId\" : \"sample-module-1\"," + LS
    + "  \"descriptor\" : {" + LS
    + "    \"exec\" : "
    + "\"java -Dport=%p -jar ../okapi-test-module/target/okapi-test-module-fat.jar\"" + LS
    + "  }" + LS
    + "}";

  try {
    final DeploymentDescriptor md = Json.decodeValue(docSampleDeployment,
      DeploymentDescriptor.class);
    String pretty = Json.encodePrettily(md);
    assertEquals(docSampleDeployment, pretty);
  } catch (DecodeException ex) {
    ex.printStackTrace();
    fail = 400;
  }
  assertEquals(0, fail);
}
 
Example 4
Source File: BeanTest.java    From okapi with Apache License 2.0 5 votes vote down vote up
@Test
public void testDeploymentDescriptor4() {
  int fail = 0;
  final String docSampleDeployment = "{" + LS
    + "  \"srvcId\" : \"sample-module-1\"," + LS
    + "  \"descriptor\" : {" + LS
    + "    \"dockerImage\" : \"my-image\"," + LS
    + "    \"dockerArgs\" : {" + LS
    + "      \"Hostname\" : \"localhost\"," + LS
    + "      \"User\" : \"nobody\"" + LS
    + "    }," + LS
    + "    \"dockerCMD\" : [ \"a\", \"b\" ]" + LS
    + "  }" + LS
    + "}";

  try {
    final DeploymentDescriptor md = Json.decodeValue(docSampleDeployment,
      DeploymentDescriptor.class);
    assertEquals("b", md.getDescriptor().getDockerCmd()[1]);
    String pretty = Json.encodePrettily(md);
    assertEquals(docSampleDeployment, pretty);
  } catch (DecodeException ex) {
    ex.printStackTrace();
    fail = 400;
  }
  assertEquals(0, fail);
}
 
Example 5
Source File: BeanTest.java    From okapi with Apache License 2.0 5 votes vote down vote up
@Test
public void testMultipleProvides() {
  int fail = 0;

  final String docModuleDescriptor = "{" + LS
    + "  \"id\" : \"sample-module-1\"," + LS
    + "  \"provides\" : [ {" + LS
    + "    \"id\" : \"_timer\"," + LS
    + "    \"version\" : \"1.0\"," + LS
    + "    \"handlers\" : [ {" + LS
    + "      \"methods\" : [ \"GET\" ]," + LS
    + "      \"pathPattern\" : \"/test\"," + LS
    + "      \"delay\" : \"1\"," + LS
    + "      \"unit\" : \"second\"" + LS
    + "    } ]" + LS
    + "  }, {" + LS
    + "    \"id\" : \"_timer\"," + LS
    + "    \"version\" : \"1.0\"," + LS
    + "    \"handlers\" : [ {" + LS
    + "      \"methods\" : [ \"GET\" ]," + LS
    + "      \"pathPattern\" : \"/test\"," + LS
    + "      \"delay\" : \"1\"," + LS
    + "      \"unit\" : \"second\"" + LS
    + "    } ]" + LS
    + "  } ]" + LS
    + "}";

  try {
    final ModuleDescriptor md = Json.decodeValue(docModuleDescriptor,
      ModuleDescriptor.class);
    String pretty = Json.encodePrettily(md);
  } catch (DecodeException ex) {
    ex.printStackTrace();
    fail = 400;
  }
  assertEquals(400, fail);
}
 
Example 6
Source File: BeanTest.java    From okapi with Apache License 2.0 4 votes vote down vote up
@Test
public void testModuleDescriptor1() {
  int fail = 0;

  final String docModuleDescriptor = "{" + LS
    + "  \"id\" : \"sample-module-1\"," + LS
    + "  \"name\" : \"sample module\"," + LS
    + "  \"provides\" : [ {" + LS
    + "    \"id\" : \"sample\"," + LS
    + "    \"version\" : \"1.0\"," + LS
    + "    \"handlers\" : [ {" + LS
    + "      \"methods\" : [ \"GET\", \"POST\" ]," + LS
    + "      \"pathPattern\" : \"/users/{id}\"," + LS
    + "      \"level\" : \"30\"," + LS
    + "      \"type\" : \"request-response\"," + LS
    + "      \"permissionsRequired\" : [ \"sample.needed\" ]," + LS
    + "      \"permissionsDesired\" : [ \"sample.extra\" ]," + LS
    + "      \"modulePermissions\" : [ \"sample.modperm\" ]" + LS
    + "    } ]" + LS
    + "  }, {" + LS
    + "    \"id\" : \"_tenant\"," + LS
    + "    \"version\" : \"1.0\"," + LS
    + "    \"interfaceType\" : \"system\"," + LS
    + "    \"handlers\" : [ {" + LS
    + "      \"methods\" : [ \"POST\", \"DELETE\" ]," + LS
    + "      \"path\" : \"/_/tenant\"," + LS
    + "      \"level\" : \"10\"," + LS
    + "      \"type\" : \"system\"" + LS
    + "    } ]" + LS
    + "  } ]," + LS
    + "  \"optional\" : [ {" + LS
    + "    \"id\" : \"foo\"," + LS
    + "    \"version\" : \"1.0\"" + LS
    + "  } ]," + LS
    + "  \"env\" : [ {" + LS
    + "    \"name\" : \"DB_HOST\"," + LS
    + "    \"value\" : \"localhost\"" + LS
    + "  } ]," + LS
    + "  \"metadata\" : {" + LS
    + "    \"scm\" : \"https://github.com/folio-org/mod-something\"," + LS
    + "    \"language\" : \"java\"" + LS
    + "  }," + LS
    + "  \"replaces\" : [ \"old-module\", \"other-module\" ]" + LS
    + "}";

  try {
    final ModuleDescriptor md = Json.decodeValue(docModuleDescriptor,
      ModuleDescriptor.class);
    String pretty = Json.encodePrettily(md);
    assertEquals(docModuleDescriptor, pretty);
  } catch (DecodeException ex) {
    ex.printStackTrace();
    fail = 400;
  }
  assertEquals(0, fail);
}
 
Example 7
Source File: BeanTest.java    From okapi with Apache License 2.0 4 votes vote down vote up
@Test
public void testModuleDescriptor2() {
  int fail = 0;

  final String docModuleDescriptor = "{" + LS
    + "  \"id\" : \"sample-module-1\"," + LS
    + "  \"name\" : \"sample module\"," + LS
    + "  \"provides\" : [ {" + LS
    + "    \"id\" : \"sample\"," + LS
    + "    \"version\" : \"1.0\"," + LS
    + "    \"handlers\" : [ {" + LS
    + "      \"methods\" : [ \"GET\", \"POST\" ]," + LS
    + "      \"pathPattern\" : \"/users/{id}\"," + LS
    + "      \"level\" : \"30\"," + LS
    + "      \"type\" : \"request-response\"," + LS
    + "      \"permissionsRequired\" : [ \"sample.needed\" ]," + LS
    + "      \"permissionsDesired\" : [ \"sample.extra\" ]," + LS
    + "      \"modulePermissions\" : [ \"sample.modperm\" ]" + LS
    + "    } ]" + LS
    + "  }, {" + LS
    + "    \"id\" : \"_tenant\"," + LS
    + "    \"version\" : \"1.0\"," + LS
    + "    \"interfaceType\" : \"system\"," + LS
    + "    \"handlers\" : [ {" + LS
    + "      \"methods\" : [ \"POST\", \"DELETE\" ]," + LS
    + "      \"path\" : \"/_/tenant\"," + LS
    + "      \"level\" : \"10\"," + LS
    + "      \"type\" : \"system\"" + LS
    + "    } ]" + LS
    + "  } ]," + LS
    + "  \"filters\" : [ {" + LS
    + "    \"methods\" : [ \"*\" ]," + LS
    + "    \"pathPattern\" : \"/*\"," + LS
    + "    \"rewritePath\" : \"/events\"," + LS
    + "    \"type\" : \"request-response\"" + LS
    + "  } ]" + LS
    + "}";

  try {
    final ModuleDescriptor md = Json.decodeValue(docModuleDescriptor,
      ModuleDescriptor.class);
    String pretty = Json.encodePrettily(md);
    assertEquals(docModuleDescriptor, pretty);
    final ModuleInstance mi = new ModuleInstance(md, md.getFilters()[0], "/test/123", HttpMethod.GET, true);
    assertEquals("/events/test/123", mi.getPath());
  } catch (DecodeException ex) {
    ex.printStackTrace();
    fail = 400;
  }
  assertEquals(0, fail);
}
 
Example 8
Source File: BeanTest.java    From okapi with Apache License 2.0 4 votes vote down vote up
@Test
public void testModuleDescriptorTimers() {
  int fail = 0;

  final String docModuleDescriptor = "{" + LS
    + "  \"id\" : \"sample-module-1\"," + LS
    + "  \"provides\" : [ {" + LS
    + "    \"id\" : \"_timer\"," + LS
    + "    \"version\" : \"1.0\"," + LS
    + "    \"handlers\" : [ {" + LS
    + "      \"methods\" : [ \"GET\" ]," + LS
    + "      \"pathPattern\" : \"/test\"," + LS
    + "      \"delay\" : \"1\"," + LS
    + "      \"unit\" : \"second\"" + LS
    + "    }, {" + LS
    + "      \"methods\" : [ \"GET\" ]," + LS
    + "      \"pathPattern\" : \"/test\"," + LS
    + "      \"delay\" : \"1\"," + LS
    + "      \"unit\" : \"minute\"" + LS
    + "    }, {" + LS
    + "      \"methods\" : [ \"GET\" ]," + LS
    + "      \"pathPattern\" : \"/test\"," + LS
    + "      \"delay\" : \"1\"," + LS
    + "      \"unit\" : \"hour\"" + LS
    + "    }, {" + LS
    + "      \"methods\" : [ \"GET\" ]," + LS
    + "      \"pathPattern\" : \"/test\"," + LS
    + "      \"delay\" : \"1\"," + LS
    + "      \"unit\" : \"day\"" + LS
    + "    }, {" + LS
    + "      \"methods\" : [ \"GET\" ]," + LS
    + "      \"pathPattern\" : \"/test\"," + LS
    + "      \"delay\" : \"1\"" + LS
    + "    } ]" + LS
    + "  } ]" + LS
    + "}";

  try {
    final ModuleDescriptor md = Json.decodeValue(docModuleDescriptor,
      ModuleDescriptor.class);
    String pretty = Json.encodePrettily(md);
  } catch (DecodeException ex) {
    ex.printStackTrace();
    fail = 400;
  }
  assertEquals(0, fail);
}