use of io.vertx.core.json.JsonObject in project vert.x by eclipse.
the class DatagramTest method testDefaultJsonOptions.
@Test
public void testDefaultJsonOptions() {
DatagramSocketOptions def = new DatagramSocketOptions();
DatagramSocketOptions json = new DatagramSocketOptions(new JsonObject());
assertEquals(def.isBroadcast(), json.isBroadcast());
assertEquals(def.isLoopbackModeDisabled(), json.isLoopbackModeDisabled());
assertEquals(def.getMulticastTimeToLive(), json.getMulticastTimeToLive());
assertEquals(def.getMulticastNetworkInterface(), json.getMulticastNetworkInterface());
assertEquals(def.isIpV6(), json.isIpV6());
}
use of io.vertx.core.json.JsonObject in project vert.x by eclipse.
the class DeploymentTest method testCopyOptions.
@Test
public void testCopyOptions() {
DeploymentOptions options = new DeploymentOptions();
JsonObject config = new JsonObject().put("foo", "bar");
Random rand = new Random();
boolean worker = rand.nextBoolean();
boolean multiThreaded = rand.nextBoolean();
String isolationGroup = TestUtils.randomAlphaString(100);
boolean ha = rand.nextBoolean();
List<String> cp = Arrays.asList("foo", "bar");
List<String> isol = Arrays.asList("com.foo.MyClass", "org.foo.*");
String poolName = TestUtils.randomAlphaString(10);
int poolSize = TestUtils.randomPositiveInt();
long maxWorkerExecuteTime = TestUtils.randomPositiveLong();
options.setConfig(config);
options.setWorker(worker);
options.setMultiThreaded(multiThreaded);
options.setIsolationGroup(isolationGroup);
options.setHa(ha);
options.setExtraClasspath(cp);
options.setIsolatedClasses(isol);
options.setWorkerPoolName(poolName);
options.setWorkerPoolSize(poolSize);
options.setMaxWorkerExecuteTime(maxWorkerExecuteTime);
DeploymentOptions copy = new DeploymentOptions(options);
assertEquals(worker, copy.isWorker());
assertEquals(multiThreaded, copy.isMultiThreaded());
assertEquals(isolationGroup, copy.getIsolationGroup());
assertNotSame(config, copy.getConfig());
assertEquals("bar", copy.getConfig().getString("foo"));
assertEquals(ha, copy.isHa());
assertEquals(cp, copy.getExtraClasspath());
assertNotSame(cp, copy.getExtraClasspath());
assertEquals(isol, copy.getIsolatedClasses());
assertNotSame(isol, copy.getIsolatedClasses());
assertEquals(poolName, copy.getWorkerPoolName());
assertEquals(poolSize, copy.getWorkerPoolSize());
assertEquals(maxWorkerExecuteTime, copy.getMaxWorkerExecuteTime());
}
use of io.vertx.core.json.JsonObject in project vert.x by eclipse.
the class DeploymentTest method testOptions.
@Test
public void testOptions() {
DeploymentOptions options = new DeploymentOptions();
assertNull(options.getConfig());
JsonObject config = new JsonObject().put("foo", "bar").put("obj", new JsonObject().put("quux", 123));
assertEquals(options, options.setConfig(config));
assertEquals(config, options.getConfig());
assertFalse(options.isWorker());
assertEquals(options, options.setWorker(true));
assertTrue(options.isWorker());
assertFalse(options.isMultiThreaded());
assertEquals(options, options.setMultiThreaded(true));
assertTrue(options.isMultiThreaded());
assertNull(options.getIsolationGroup());
String rand = TestUtils.randomUnicodeString(1000);
assertEquals(options, options.setIsolationGroup(rand));
assertEquals(rand, options.getIsolationGroup());
assertFalse(options.isHa());
assertEquals(options, options.setHa(true));
assertTrue(options.isHa());
assertNull(options.getExtraClasspath());
List<String> cp = Arrays.asList("foo", "bar");
assertEquals(options, options.setExtraClasspath(cp));
assertNull(options.getIsolatedClasses());
List<String> isol = Arrays.asList("com.foo.MyClass", "org.foo.*");
assertEquals(options, options.setIsolatedClasses(isol));
assertSame(isol, options.getIsolatedClasses());
String workerPoolName = TestUtils.randomAlphaString(10);
assertEquals(options, options.setWorkerPoolName(workerPoolName));
assertEquals(workerPoolName, options.getWorkerPoolName());
int workerPoolSize = TestUtils.randomPositiveInt();
assertEquals(options, options.setWorkerPoolSize(workerPoolSize));
assertEquals(workerPoolSize, options.getWorkerPoolSize());
long maxWorkerExecuteTime = TestUtils.randomPositiveLong();
assertEquals(options, options.setMaxWorkerExecuteTime(maxWorkerExecuteTime));
assertEquals(maxWorkerExecuteTime, options.getMaxWorkerExecuteTime());
}
use of io.vertx.core.json.JsonObject in project vert.x by eclipse.
the class DeploymentTest method testJsonOptions.
@Test
public void testJsonOptions() {
JsonObject config = new JsonObject().put("foo", "bar");
Random rand = new Random();
boolean worker = rand.nextBoolean();
boolean multiThreaded = rand.nextBoolean();
String isolationGroup = TestUtils.randomAlphaString(100);
boolean ha = rand.nextBoolean();
List<String> cp = Arrays.asList("foo", "bar");
List<String> isol = Arrays.asList("com.foo.MyClass", "org.foo.*");
String poolName = TestUtils.randomAlphaString(10);
int poolSize = TestUtils.randomPositiveInt();
long maxWorkerExecuteTime = TestUtils.randomPositiveLong();
JsonObject json = new JsonObject();
json.put("config", config);
json.put("worker", worker);
json.put("multiThreaded", multiThreaded);
json.put("isolationGroup", isolationGroup);
json.put("ha", ha);
json.put("extraClasspath", new JsonArray(cp));
json.put("isolatedClasses", new JsonArray(isol));
json.put("workerPoolName", poolName);
json.put("workerPoolSize", poolSize);
json.put("maxWorkerExecuteTime", maxWorkerExecuteTime);
DeploymentOptions options = new DeploymentOptions(json);
assertEquals(worker, options.isWorker());
assertEquals(multiThreaded, options.isMultiThreaded());
assertEquals(isolationGroup, options.getIsolationGroup());
assertEquals("bar", options.getConfig().getString("foo"));
assertEquals(ha, options.isHa());
assertEquals(cp, options.getExtraClasspath());
assertEquals(isol, options.getIsolatedClasses());
assertEquals(poolName, options.getWorkerPoolName());
assertEquals(poolSize, options.getWorkerPoolSize());
assertEquals(maxWorkerExecuteTime, options.getMaxWorkerExecuteTime());
}
use of io.vertx.core.json.JsonObject in project vert.x by eclipse.
the class DeploymentTest method testDeployWorkerWithConfig.
@Test
public void testDeployWorkerWithConfig() throws Exception {
MyVerticle verticle = new MyVerticle();
JsonObject conf = generateJSONObject();
vertx.deployVerticle(verticle, new DeploymentOptions().setConfig(conf).setWorker(true), ar -> {
assertDeployment(1, verticle, conf, ar);
assertFalse(verticle.startContext.isMultiThreadedWorkerContext());
assertTrue(verticle.startContext.isWorkerContext());
assertFalse(verticle.startContext.isEventLoopContext());
vertx.undeploy(ar.result(), ar2 -> {
assertTrue(ar2.succeeded());
assertEquals(verticle.startContext, verticle.stopContext);
testComplete();
});
});
await();
}
Aggregations