Search in sources :

Example 1 with FileSystemOptions

use of io.vertx.core.file.FileSystemOptions in project vert.x by eclipse.

the class VertxOptionsTest method testJsonOptions.

@Test
public void testJsonOptions() {
    VertxOptions options = new VertxOptions(new JsonObject());
    assertEquals(0, options.getEventBusOptions().getPort());
    assertEquals(-1, options.getEventBusOptions().getClusterPublicPort());
    assertEquals(20000, options.getEventBusOptions().getClusterPingInterval());
    assertEquals(20000, options.getEventBusOptions().getClusterPingReplyInterval());
    assertEquals(2 * Runtime.getRuntime().availableProcessors(), options.getEventLoopPoolSize());
    assertEquals(20, options.getInternalBlockingPoolSize());
    assertEquals(20, options.getWorkerPoolSize());
    assertEquals(1000, options.getBlockedThreadCheckInterval());
    assertNull(options.getEventBusOptions().getHost());
    assertNull(options.getEventBusOptions().getClusterPublicHost());
    assertEquals(null, options.getClusterManager());
    assertEquals(2000l * 1000000, options.getMaxEventLoopExecuteTime());
    assertEquals(1l * 60 * 1000 * 1000000, options.getMaxWorkerExecuteTime());
    assertFalse(options.isHAEnabled());
    assertEquals(1, options.getQuorumSize());
    assertEquals(VertxOptions.DEFAULT_HA_GROUP, options.getHAGroup());
    assertNotNull(options.getMetricsOptions());
    assertEquals(5000000000l, options.getWarningExceptionTime());
    assertEquals(TimeUnit.NANOSECONDS, options.getMaxEventLoopExecuteTimeUnit());
    assertEquals(TimeUnit.NANOSECONDS, options.getMaxWorkerExecuteTimeUnit());
    assertEquals(TimeUnit.NANOSECONDS, options.getWarningExceptionTimeUnit());
    assertEquals(TimeUnit.MILLISECONDS, options.getBlockedThreadCheckIntervalUnit());
    int clusterPort = TestUtils.randomPortInt();
    int clusterPublicPort = TestUtils.randomPortInt();
    int eventLoopPoolSize = TestUtils.randomPositiveInt();
    int internalBlockingPoolSize = TestUtils.randomPositiveInt();
    int workerPoolSize = TestUtils.randomPositiveInt();
    int blockedThreadCheckInterval = TestUtils.randomPositiveInt();
    String clusterHost = TestUtils.randomAlphaString(100);
    String clusterPublicHost = TestUtils.randomAlphaString(100);
    long clusterPingInterval = TestUtils.randomPositiveLong();
    long clusterPingReplyInterval = TestUtils.randomPositiveLong();
    int maxEventLoopExecuteTime = TestUtils.randomPositiveInt();
    int maxWorkerExecuteTime = TestUtils.randomPositiveInt();
    int proxyOperationTimeout = TestUtils.randomPositiveInt();
    long warningExceptionTime = TestUtils.randomPositiveLong();
    Random rand = new Random();
    boolean haEnabled = rand.nextBoolean();
    boolean fileResolverCachingEnabled = rand.nextBoolean();
    int quorumSize = TestUtils.randomShort() + 1;
    String haGroup = TestUtils.randomAlphaString(100);
    boolean classPathResolvingEnabled = rand.nextBoolean();
    boolean metricsEnabled = rand.nextBoolean();
    boolean jmxEnabled = rand.nextBoolean();
    String jmxDomain = TestUtils.randomAlphaString(100);
    TimeUnit maxEventLoopExecuteTimeUnit = TimeUnit.SECONDS;
    TimeUnit maxWorkerExecuteTimeUnit = TimeUnit.MILLISECONDS;
    TimeUnit warningExceptionTimeUnit = TimeUnit.MINUTES;
    TimeUnit blockedThreadCheckIntervalUnit = TimeUnit.MINUTES;
    options = new VertxOptions(new JsonObject().put("eventBusOptions", new JsonObject().put("port", clusterPort).put("clusterPublicPort", clusterPublicPort).put("host", clusterHost).put("clusterPublicHost", clusterPublicHost).put("clusterPingInterval", clusterPingInterval).put("clusterPingReplyInterval", clusterPingReplyInterval)).put("eventLoopPoolSize", eventLoopPoolSize).put("internalBlockingPoolSize", internalBlockingPoolSize).put("workerPoolSize", workerPoolSize).put("blockedThreadCheckInterval", blockedThreadCheckInterval).put("maxEventLoopExecuteTime", maxEventLoopExecuteTime).put("maxWorkerExecuteTime", maxWorkerExecuteTime).put("proxyOperationTimeout", proxyOperationTimeout).put("haEnabled", haEnabled).put("fileResolverCachingEnabled", fileResolverCachingEnabled).put("quorumSize", quorumSize).put("haGroup", haGroup).put("warningExceptionTime", warningExceptionTime).put("fileSystemOptions", new JsonObject().put("classPathResolvingEnabled", classPathResolvingEnabled).put("fileCachingEnabled", fileResolverCachingEnabled)).put("metricsOptions", new JsonObject().put("enabled", metricsEnabled).put("jmxEnabled", jmxEnabled).put("jmxDomain", jmxDomain)).put("tracingOptions", new JsonObject()).put("maxEventLoopExecuteTimeUnit", maxEventLoopExecuteTimeUnit).put("maxWorkerExecuteTimeUnit", maxWorkerExecuteTimeUnit).put("warningExceptionTimeUnit", warningExceptionTimeUnit).put("blockedThreadCheckIntervalUnit", blockedThreadCheckIntervalUnit));
    assertEquals(clusterPort, options.getEventBusOptions().getPort());
    assertEquals(clusterPublicPort, options.getEventBusOptions().getClusterPublicPort());
    assertEquals(clusterPublicHost, options.getEventBusOptions().getClusterPublicHost());
    assertEquals(clusterPingInterval, options.getEventBusOptions().getClusterPingInterval());
    assertEquals(clusterPingReplyInterval, options.getEventBusOptions().getClusterPingReplyInterval());
    assertEquals(eventLoopPoolSize, options.getEventLoopPoolSize());
    assertEquals(internalBlockingPoolSize, options.getInternalBlockingPoolSize());
    assertEquals(workerPoolSize, options.getWorkerPoolSize());
    assertEquals(blockedThreadCheckInterval, options.getBlockedThreadCheckInterval());
    assertEquals(clusterHost, options.getEventBusOptions().getHost());
    assertEquals(null, options.getClusterManager());
    assertEquals(maxEventLoopExecuteTime, options.getMaxEventLoopExecuteTime());
    assertEquals(maxWorkerExecuteTime, options.getMaxWorkerExecuteTime());
    assertEquals(haEnabled, options.isHAEnabled());
    assertEquals(quorumSize, options.getQuorumSize());
    assertEquals(haGroup, options.getHAGroup());
    FileSystemOptions fileSystemOptions = options.getFileSystemOptions();
    assertEquals(classPathResolvingEnabled, fileSystemOptions.isClassPathResolvingEnabled());
    assertEquals(fileResolverCachingEnabled, fileSystemOptions.isFileCachingEnabled());
    MetricsOptions metricsOptions = options.getMetricsOptions();
    assertEquals(metricsEnabled, metricsOptions.isEnabled());
    assertNotNull(options.getTracingOptions());
    assertEquals(warningExceptionTime, options.getWarningExceptionTime());
    assertEquals(maxEventLoopExecuteTimeUnit, options.getMaxEventLoopExecuteTimeUnit());
    assertEquals(maxWorkerExecuteTimeUnit, options.getMaxWorkerExecuteTimeUnit());
    assertEquals(warningExceptionTimeUnit, options.getWarningExceptionTimeUnit());
    assertEquals(blockedThreadCheckIntervalUnit, options.getBlockedThreadCheckIntervalUnit());
}
Also used : MetricsOptions(io.vertx.core.metrics.MetricsOptions) Random(java.util.Random) JsonObject(io.vertx.core.json.JsonObject) TimeUnit(java.util.concurrent.TimeUnit) FileSystemOptions(io.vertx.core.file.FileSystemOptions) Test(org.junit.Test)

Aggregations

FileSystemOptions (io.vertx.core.file.FileSystemOptions)1 JsonObject (io.vertx.core.json.JsonObject)1 MetricsOptions (io.vertx.core.metrics.MetricsOptions)1 Random (java.util.Random)1 TimeUnit (java.util.concurrent.TimeUnit)1 Test (org.junit.Test)1