当前位置: 首页>>代码示例>>Java>>正文


Java TestUtils.randomAlphaString方法代码示例

本文整理汇总了Java中io.vertx.test.core.TestUtils.randomAlphaString方法的典型用法代码示例。如果您正苦于以下问题:Java TestUtils.randomAlphaString方法的具体用法?Java TestUtils.randomAlphaString怎么用?Java TestUtils.randomAlphaString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在io.vertx.test.core.TestUtils的用法示例。


在下文中一共展示了TestUtils.randomAlphaString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testCopyOptions

import io.vertx.test.core.TestUtils; //导入方法依赖的package包/类
@org.junit.Test
public void testCopyOptions() {
  TestOptions options = new TestOptions();
  long timeout = TestUtils.randomLong();
  Boolean useEventLoop = randomBoolean();
  String to = TestUtils.randomAlphaString(10);
  String at = TestUtils.randomAlphaString(10);
  String format = TestUtils.randomAlphaString(10);
  ReportOptions reporter = new ReportOptions().setTo(to).setFormat(format);
  options.setUseEventLoop(useEventLoop).setTimeout(timeout).addReporter(reporter);
  TestOptions copy = new TestOptions(options);
  options.setTimeout(TestUtils.randomLong());
  options.setUseEventLoop(randomBoolean());
  reporter.setTo(TestUtils.randomAlphaString(10));
  reporter.setFormat(TestUtils.randomAlphaString(10));
  options.getReporters().clear();
  assertEquals(timeout, copy.getTimeout());
  assertEquals(useEventLoop, copy.isUseEventLoop());
  assertEquals(1, copy.getReporters().size());
  assertEquals(to, copy.getReporters().get(0).getTo());
  assertEquals(format, copy.getReporters().get(0).getFormat());
}
 
开发者ID:vert-x3,项目名称:vertx-unit,代码行数:23,代码来源:OptionsTest.java

示例2: testJsonOptions

import io.vertx.test.core.TestUtils; //导入方法依赖的package包/类
@org.junit.Test
public void testJsonOptions() {
  JsonObject json = new JsonObject();
  long timeout = TestUtils.randomLong();
  Boolean useEventLoop = randomBoolean();
  String to = TestUtils.randomAlphaString(10);
  String at = TestUtils.randomAlphaString(10);
  String format = TestUtils.randomAlphaString(10);
  json.put("timeout", timeout);
  if (useEventLoop != null) {
    json.put("useEventLoop", useEventLoop);
  }
  json.put("reporters", new JsonArray().
      add(new JsonObject().
          put("to", to).
          put("at", at).
          put("format", format)));
  TestOptions options = new TestOptions(json);
  assertEquals(timeout, options.getTimeout());
  assertEquals(useEventLoop, options.isUseEventLoop());
  assertEquals(1, options.getReporters().size());
  assertEquals(to, options.getReporters().get(0).getTo());
  assertEquals(format, options.getReporters().get(0).getFormat());
}
 
开发者ID:vert-x3,项目名称:vertx-unit,代码行数:25,代码来源:OptionsTest.java

示例3: testNamedHttpClientMetrics

import io.vertx.test.core.TestUtils; //导入方法依赖的package包/类
@Test
public void testNamedHttpClientMetrics() throws Exception {
  String name = TestUtils.randomAlphaString(10);
  HttpClient client = vertx.createHttpClient(new HttpClientOptions().setMetricsName(name));
  HttpServer server = vertx.createHttpServer(new HttpServerOptions().setHost("localhost").setPort(8080)).requestHandler(req -> {
    req.response().end();
  }).listen(ar -> {
    assertTrue(ar.succeeded());
    client.request(HttpMethod.GET, 8080, "localhost", "/file", resp -> {
      resp.bodyHandler(buff -> {
        testComplete();
      });
    }).end();
  });

  await();

  String baseName = "vertx.http.clients." + name;
  JsonObject metrics = metricsService.getMetricsSnapshot(baseName);
  assertCount(metrics.getJsonObject(baseName + ".bytes-read"), 1L);

  cleanup(client);
  cleanup(server);
}
 
开发者ID:vert-x3,项目名称:vertx-dropwizard-metrics,代码行数:25,代码来源:MetricsTest.java

示例4: testCopyOptions

import io.vertx.test.core.TestUtils; //导入方法依赖的package包/类
@Test
public void testCopyOptions() {
  DropwizardMetricsOptions options = new DropwizardMetricsOptions();

  Random rand = new Random();
  boolean metricsEnabled = rand.nextBoolean();
  boolean jmxEnabled = rand.nextBoolean();
  String jmxDomain = TestUtils.randomAlphaString(100);
  String name = TestUtils.randomAlphaString(100);
  String configPath = TestUtils.randomAlphaString(100);
  options.setEnabled(metricsEnabled);
  options.setJmxEnabled(jmxEnabled);
  options.setJmxDomain(jmxDomain);
  options.setRegistryName(name);
  options.setConfigPath(configPath);
  options = new DropwizardMetricsOptions(options);
  assertEquals(metricsEnabled || jmxEnabled, options.isEnabled());
  assertEquals(jmxEnabled, options.isJmxEnabled());
  assertEquals(jmxDomain, options.getJmxDomain());
  assertEquals(name, options.getRegistryName());
  assertEquals(configPath, options.getConfigPath());
}
 
开发者ID:vert-x3,项目名称:vertx-dropwizard-metrics,代码行数:23,代码来源:MetricsOptionsTest.java

示例5: testJsonOptions

import io.vertx.test.core.TestUtils; //导入方法依赖的package包/类
@Test
public void testJsonOptions() {
  DropwizardMetricsOptions options = new DropwizardMetricsOptions(new JsonObject());
  assertFalse(options.isEnabled());
  assertFalse(options.isJmxEnabled());
  assertNull(options.getJmxDomain());
  assertNull(options.getRegistryName());
  Random rand = new Random();
  boolean metricsEnabled = rand.nextBoolean();
  boolean jmxEnabled = rand.nextBoolean();
  String jmxDomain = TestUtils.randomAlphaString(100);
  String registryName = TestUtils.randomAlphaString(100);
  String configPath = TestUtils.randomAlphaString(100);
  options = new DropwizardMetricsOptions(new JsonObject().
    put("enabled", metricsEnabled).
    put("registryName", registryName).
    put("jmxEnabled", jmxEnabled).
    put("jmxDomain", jmxDomain).
    put("configPath", configPath)
  );
  assertEquals(metricsEnabled, options.isEnabled());
  assertEquals(registryName, options.getRegistryName());
  assertEquals(jmxEnabled, options.isJmxEnabled());
  assertEquals(jmxDomain, options.getJmxDomain());
}
 
开发者ID:vert-x3,项目名称:vertx-dropwizard-metrics,代码行数:26,代码来源:MetricsOptionsTest.java

示例6: testInsertNoCollection

import io.vertx.test.core.TestUtils; //导入方法依赖的package包/类
@Test
public void testInsertNoCollection() {
  String collection = randomCollection();
  String random = TestUtils.randomAlphaString(20);
  mongoClient.insert(collection, new JsonObject().put("foo", random), onSuccess(id -> {
    assertNotNull(id);
    mongoClient.find(collection, new JsonObject(), onSuccess(docs -> {
      assertNotNull(docs);
      assertEquals(1, docs.size());
      assertEquals(random, docs.get(0).getString("foo"));
      testComplete();
    }));
  }));

  await();
}
 
开发者ID:vert-x3,项目名称:vertx-mongo-client,代码行数:17,代码来源:MongoClientTestBase.java

示例7: testSimpleAuthWithSource

import io.vertx.test.core.TestUtils; //导入方法依赖的package包/类
@Test
public void testSimpleAuthWithSource() {
  JsonObject config = new JsonObject();
  String username = TestUtils.randomAlphaString(8);
  String password = TestUtils.randomAlphaString(20);
  String authSource = TestUtils.randomAlphaString(10);
  config.put("username", username);
  config.put("password", password);
  config.put("authSource", authSource);

  List<MongoCredential> credentials = new CredentialListParser(null, config).credentials();
  assertEquals(1, credentials.size());
  MongoCredential credential = credentials.get(0);
  assertEquals(username, credential.getUserName());
  assertArrayEquals(password.toCharArray(), credential.getPassword());
  assertEquals(authSource, credential.getSource());
}
 
开发者ID:vert-x3,项目名称:vertx-mongo-client,代码行数:18,代码来源:CredentialListParserTest.java

示例8: testAuth_GSSAPI_WithServiceName

import io.vertx.test.core.TestUtils; //导入方法依赖的package包/类
@Test
public void testAuth_GSSAPI_WithServiceName() {
  JsonObject config = new JsonObject();
  String username = TestUtils.randomAlphaString(8);
  String authSource = TestUtils.randomAlphaString(10);
  String serviceName = TestUtils.randomAlphaString(11);
  config.put("username", username);
  config.put("authSource", authSource);
  config.put("authMechanism", "GSSAPI");
  config.put("gssapiServiceName", serviceName);

  List<MongoCredential> credentials = new CredentialListParser(null, config).credentials();
  assertEquals(1, credentials.size());
  MongoCredential credential = credentials.get(0);
  assertEquals(username, credential.getUserName());
  assertNotEquals(authSource, credential.getSource()); // It should ignore the source we pass in

  assertEquals(AuthenticationMechanism.GSSAPI, credential.getAuthenticationMechanism());
  assertEquals(serviceName, credential.getMechanismProperty("SERVICE_NAME", null));
}
 
开发者ID:vert-x3,项目名称:vertx-mongo-client,代码行数:21,代码来源:CredentialListParserTest.java

示例9: testAuth_PLAIN

import io.vertx.test.core.TestUtils; //导入方法依赖的package包/类
@Test
public void testAuth_PLAIN() {
  JsonObject config = new JsonObject();
  String username = TestUtils.randomAlphaString(8);
  String password = TestUtils.randomAlphaString(20);
  String authSource = TestUtils.randomAlphaString(10);
  config.put("username", username);
  config.put("password", password);
  config.put("authSource", authSource);
  config.put("authMechanism", "PLAIN");

  List<MongoCredential> credentials = new CredentialListParser(null, config).credentials();
  assertEquals(1, credentials.size());
  MongoCredential credential = credentials.get(0);
  assertEquals(username, credential.getUserName());
  assertArrayEquals(password.toCharArray(), credential.getPassword());
  assertEquals(authSource, credential.getSource());

  assertEquals(AuthenticationMechanism.PLAIN, credential.getAuthenticationMechanism());
}
 
开发者ID:vert-x3,项目名称:vertx-mongo-client,代码行数:21,代码来源:CredentialListParserTest.java

示例10: testAuth_MONGODB_CR

import io.vertx.test.core.TestUtils; //导入方法依赖的package包/类
@Test
public void testAuth_MONGODB_CR() {
  JsonObject config = new JsonObject();
  String username = TestUtils.randomAlphaString(8);
  String password = TestUtils.randomAlphaString(20);
  String authSource = TestUtils.randomAlphaString(10);
  config.put("username", username);
  config.put("password", password);
  config.put("authSource", authSource);
  config.put("authMechanism", "MONGODB-CR");

  List<MongoCredential> credentials = new CredentialListParser(null, config).credentials();
  assertEquals(1, credentials.size());
  MongoCredential credential = credentials.get(0);
  assertEquals(username, credential.getUserName());
  assertArrayEquals(password.toCharArray(), credential.getPassword());
  assertEquals(authSource, credential.getSource());

  assertEquals(AuthenticationMechanism.MONGODB_CR, credential.getAuthenticationMechanism());
}
 
开发者ID:vert-x3,项目名称:vertx-mongo-client,代码行数:21,代码来源:CredentialListParserTest.java

示例11: testAuth_MONGODB_X509

import io.vertx.test.core.TestUtils; //导入方法依赖的package包/类
@Test
public void testAuth_MONGODB_X509() {
  JsonObject config = new JsonObject();
  String username = TestUtils.randomAlphaString(8);
  String authSource = TestUtils.randomAlphaString(10);
  config.put("username", username);
  config.put("authSource", authSource);
  config.put("authMechanism", "MONGODB-X509");

  List<MongoCredential> credentials = new CredentialListParser(null, config).credentials();
  assertEquals(1, credentials.size());
  MongoCredential credential = credentials.get(0);
  assertEquals(username, credential.getUserName());
  assertNotEquals(authSource, credential.getSource()); // It should ignore the source we pass in

  assertEquals(AuthenticationMechanism.MONGODB_X509, credential.getAuthenticationMechanism());
}
 
开发者ID:vert-x3,项目名称:vertx-mongo-client,代码行数:18,代码来源:CredentialListParserTest.java

示例12: testAuth_SCRAM_SHA_1

import io.vertx.test.core.TestUtils; //导入方法依赖的package包/类
@Test
public void testAuth_SCRAM_SHA_1() {
  JsonObject config = new JsonObject();
  String username = TestUtils.randomAlphaString(8);
  String password = TestUtils.randomAlphaString(20);
  String authSource = TestUtils.randomAlphaString(10);
  config.put("username", username);
  config.put("password", password);
  config.put("authSource", authSource);
  config.put("authMechanism", "SCRAM-SHA-1");

  List<MongoCredential> credentials = new CredentialListParser(null, config).credentials();
  assertEquals(1, credentials.size());
  MongoCredential credential = credentials.get(0);
  assertEquals(username, credential.getUserName());
  assertArrayEquals(password.toCharArray(), credential.getPassword());
  assertEquals(authSource, credential.getSource());

  assertEquals(AuthenticationMechanism.SCRAM_SHA_1, credential.getAuthenticationMechanism());
}
 
开发者ID:vert-x3,项目名称:vertx-mongo-client,代码行数:21,代码来源:CredentialListParserTest.java

示例13: setUp

import io.vertx.test.core.TestUtils; //导入方法依赖的package包/类
@Override
public void setUp() throws Exception {
  super.setUp();
  mlClient = MarkLogicClient.create(vertx, getClientConfig());
  mlManagement = MarkLogicManagement.create(vertx, getAdminConfig());
  this.directory = "/test" + TestUtils.randomAlphaString(20) + "/";
  MarklogicOptionsParser parser = new MarklogicOptionsParser(getClientConfig());
  DatabaseClientFactory.Bean configBean = parser.clientBean();
  databaseClient = configBean.newClient();
}
 
开发者ID:etourdot,项目名称:vertx-marklogic,代码行数:11,代码来源:AbstractTestMarklogicDocument.java

示例14: testEndToEnd

import io.vertx.test.core.TestUtils; //导入方法依赖的package包/类
@org.junit.Test
public void testEndToEnd() {
  String testSuiteName = TestUtils.randomAlphaString(10);
  String testCaseName1 = TestUtils.randomAlphaString(10);
  String testCaseName2 = TestUtils.randomAlphaString(10);
  TestReporter testReporter = new TestReporter();
  EventBusCollector collector = EventBusCollector.create(vertx, testReporter);
  MessageConsumer<JsonObject> consumer = vertx.eventBus().consumer("the-address", collector.asMessageHandler());
  consumer.completionHandler(ar -> {
    assertTrue(ar.succeeded());
    TestSuite suite = TestSuite.create(testSuiteName).
        test(testCaseName1, context -> {
        }).test(testCaseName2, context -> context.fail("the_failure"));
    suite.run(vertx, new TestOptions().addReporter(new ReportOptions().setTo("bus:the-address")));
  });
  testReporter.await();
  assertEquals(0, testReporter.exceptions.size());
  assertEquals(2, testReporter.results.size());
  TestResult result1 = testReporter.results.get(0);
  assertEquals(testCaseName1, result1.name());
  assertTrue(result1.succeeded());
  TestResult result2 = testReporter.results.get(1);
  assertEquals(testCaseName2, result2.name());
  assertTrue(result2.failed());
  assertEquals("the_failure", result2.failure().message());
  consumer.unregister();
}
 
开发者ID:vert-x3,项目名称:vertx-unit,代码行数:28,代码来源:EventBusTest.java

示例15: testEndToEndAfterFailure

import io.vertx.test.core.TestUtils; //导入方法依赖的package包/类
@org.junit.Test
public void testEndToEndAfterFailure() {
  long now = System.currentTimeMillis();
  String address = TestUtils.randomAlphaString(10);
  String testSuiteName = TestUtils.randomAlphaString(10);
  String testCaseName = TestUtils.randomAlphaString(10);
  TestReporter testReporter = new TestReporter();
  MessageConsumer<JsonObject> consumer = vertx.eventBus().consumer(address, EventBusCollector.create(vertx, testReporter).asMessageHandler());
  RuntimeException error = new RuntimeException("the_runtime_exception");
  consumer.completionHandler(ar -> {
    assertTrue(ar.succeeded());
    TestSuite suite = TestSuite.create(testSuiteName).
        test(testCaseName, context -> {
          try {
            Thread.sleep(10);
          } catch (InterruptedException ignore) {
          }
        }).after(context -> {
      throw error;
    });
    suite.run(vertx, new TestOptions().addReporter(new ReportOptions().setTo("bus:" + address)));
  });
  testReporter.await();
  assertEquals(1, testReporter.results.size());
  TestResult result1 = testReporter.results.get(0);
  assertEquals(testCaseName, result1.name());
  assertTrue(result1.succeeded());
  assertTrue(result1.beginTime() >= now);
  assertTrue(result1.durationTime() >= 10);
  assertEquals(1, testReporter.exceptions.size());
  Throwable cause = testReporter.exceptions.get(0);
  assertTrue(cause instanceof RuntimeException);
  assertEquals(error.getMessage(), cause.getMessage());
  assertTrue(Arrays.equals(error.getStackTrace(), cause.getStackTrace()));
  consumer.unregister();
}
 
开发者ID:vert-x3,项目名称:vertx-unit,代码行数:37,代码来源:EventBusTest.java


注:本文中的io.vertx.test.core.TestUtils.randomAlphaString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。