io.airlift.testing.Assertions.assertInstanceOf()方法的使用及代码示例

x33g5p2x  于11个月前 转载在 其他  
字(10.8k)|赞(0)|评价(0)|浏览(36)

本文整理了Java中io.airlift.testing.Assertions.assertInstanceOf()方法的一些代码示例,展示了Assertions.assertInstanceOf()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Assertions.assertInstanceOf()方法的具体详情如下:
包路径:io.airlift.testing.Assertions
类名称:Assertions
方法名:assertInstanceOf

Assertions.assertInstanceOf介绍

暂无

代码示例

代码示例来源:origin: prestodb/presto

@Test
public void testGetThriftDeserializer()
{
  Properties schema = new Properties();
  schema.setProperty(SERIALIZATION_LIB, ThriftDeserializer.class.getName());
  schema.setProperty(SERIALIZATION_CLASS, IntString.class.getName());
  schema.setProperty(SERIALIZATION_FORMAT, TBinaryProtocol.class.getName());
  assertInstanceOf(getDeserializer(new Configuration(false), schema), ThriftDeserializer.class);
}

代码示例来源:origin: prestodb/presto

protected void assertExpectedTableLayoutHandle(ConnectorTableLayoutHandle actualTableLayoutHandle, ConnectorTableLayoutHandle expectedTableLayoutHandle)
{
  assertInstanceOf(actualTableLayoutHandle, HiveTableLayoutHandle.class);
  assertInstanceOf(expectedTableLayoutHandle, HiveTableLayoutHandle.class);
  HiveTableLayoutHandle actual = (HiveTableLayoutHandle) actualTableLayoutHandle;
  HiveTableLayoutHandle expected = (HiveTableLayoutHandle) expectedTableLayoutHandle;
  assertExpectedPartitions(actual.getPartitions().get(), expected.getPartitions().get());
}

代码示例来源:origin: prestodb/presto

@Test
public void testCustomCredentialsProvider()
    throws Exception
{
  Configuration config = new Configuration();
  config.set(S3_USE_INSTANCE_CREDENTIALS, "false");
  config.set(S3_CREDENTIALS_PROVIDER, TestCredentialsProvider.class.getName());
  try (PrestoS3FileSystem fs = new PrestoS3FileSystem()) {
    fs.initialize(new URI("s3n://test-bucket/"), config);
    assertInstanceOf(getAwsCredentialsProvider(fs), TestCredentialsProvider.class);
  }
}

代码示例来源:origin: prestodb/presto

@Test
public void testEncryptionMaterialsProvider()
    throws Exception
{
  Configuration config = new Configuration();
  config.set(S3_ENCRYPTION_MATERIALS_PROVIDER, TestEncryptionMaterialsProvider.class.getName());
  try (PrestoS3FileSystem fs = new PrestoS3FileSystem()) {
    fs.initialize(new URI("s3n://test-bucket/"), config);
    assertInstanceOf(fs.getS3Client(), AmazonS3EncryptionClient.class);
  }
}

代码示例来源:origin: prestodb/presto

@Test
  public void testGetConnectorFactory()
  {
    AtopPlugin plugin = new AtopPlugin();
    assertInstanceOf(getOnlyElement(plugin.getConnectorFactories()), AtopConnectorFactory.class);
  }
}

代码示例来源:origin: prestodb/presto

@Test
public void testPlugin()
{
  ThriftPlugin plugin = loadPlugin(ThriftPlugin.class);
  ConnectorFactory factory = getOnlyElement(plugin.getConnectorFactories());
  assertInstanceOf(factory, ThriftConnectorFactory.class);
  Map<String, String> config = ImmutableMap.of("presto.thrift.client.addresses", "localhost:7779");
  Connector connector = factory.create("test", config, new TestingConnectorContext());
  assertNotNull(connector);
  assertInstanceOf(connector, ThriftConnector.class);
}

代码示例来源:origin: prestodb/presto

@Test
public void testKMSEncryptionMaterialsProvider()
    throws Exception
{
  Configuration config = new Configuration();
  config.set(S3_KMS_KEY_ID, "test-key-id");
  try (PrestoS3FileSystem fs = new PrestoS3FileSystem()) {
    fs.initialize(new URI("s3n://test-bucket/"), config);
    assertInstanceOf(fs.getS3Client(), AmazonS3EncryptionClient.class);
  }
}

代码示例来源:origin: prestodb/presto

@Test
public void testFailsValidation()
{
  ConstrainedPowerOfTwo object = new ConstrainedPowerOfTwo(11);
  Set<ConstraintViolation<ConstrainedPowerOfTwo>> violations = VALIDATOR.validate(object);
  assertEquals(violations.size(), 2);
  for (ConstraintViolation<ConstrainedPowerOfTwo> violation : violations) {
    assertInstanceOf(violation.getConstraintDescriptor().getAnnotation(), PowerOfTwo.class);
  }
}

代码示例来源:origin: prestodb/presto

@Test
public void testStaticCredentials()
    throws Exception
{
  Configuration config = new Configuration();
  config.set(S3_ACCESS_KEY, "test_secret_access_key");
  config.set(S3_SECRET_KEY, "test_access_key_id");
  // the static credentials should be preferred
  try (PrestoS3FileSystem fs = new PrestoS3FileSystem()) {
    fs.initialize(new URI("s3n://test-bucket/"), config);
    assertInstanceOf(getAwsCredentialsProvider(fs), AWSStaticCredentialsProvider.class);
  }
}

代码示例来源:origin: prestodb/presto

@Test
public void testInstanceCredentialsEnabled()
    throws Exception
{
  Configuration config = new Configuration();
  // instance credentials are enabled by default
  try (PrestoS3FileSystem fs = new PrestoS3FileSystem()) {
    fs.initialize(new URI("s3n://test-bucket/"), config);
    assertInstanceOf(getAwsCredentialsProvider(fs), InstanceProfileCredentialsProvider.class);
  }
}

代码示例来源:origin: prestodb/presto

@Test
public void testCompatibleStaticCredentials()
    throws Exception
{
  Configuration config = new Configuration();
  config.set(S3_ACCESS_KEY, "test_secret_access_key");
  config.set(S3_SECRET_KEY, "test_access_key_id");
  config.set(S3_ENDPOINT, "test.example.endpoint.com");
  config.set(S3_SIGNER_TYPE, "S3SignerType");
  // the static credentials should be preferred
  try (PrestoS3FileSystem fs = new PrestoS3FileSystem()) {
    fs.initialize(new URI("s3a://test-bucket/"), config);
    assertInstanceOf(getAwsCredentialsProvider(fs), AWSStaticCredentialsProvider.class);
  }
}

代码示例来源:origin: prestodb/presto

@BeforeClass
public void setup()
    throws Exception
{
  server = new TestingPrestoServer(ImmutableList.of(new TestGenerateTokenFilterModule()));
  httpClient = (JettyHttpClient) server.getInstance(Key.get(HttpClient.class, GenerateTokenFilterTest.class));
  // extract the filter
  List<HttpRequestFilter> filters = httpClient.getRequestFilters();
  assertEquals(filters.size(), 2);
  assertInstanceOf(filters.get(1), GenerateTraceTokenRequestFilter.class);
  filter = (GenerateTraceTokenRequestFilter) filters.get(1);
}

代码示例来源:origin: prestodb/presto

@Test
  public void testStartup()
  {
    RedisPlugin plugin = new RedisPlugin();

    ConnectorFactory factory = getOnlyElement(plugin.getConnectorFactories());
    assertInstanceOf(factory, RedisConnectorFactory.class);

    Connector c = factory.create(
        "test-connector",
        ImmutableMap.<String, String>builder()
            .put("redis.table-names", "test")
            .put("redis.nodes", "localhost:6379")
            .build(),
        new TestingConnectorContext());
    assertNotNull(c);
  }
}

代码示例来源:origin: prestodb/presto

@Test
  public void testSpinup()
  {
    KafkaPlugin plugin = new KafkaPlugin();

    ConnectorFactory factory = getOnlyElement(plugin.getConnectorFactories());
    assertInstanceOf(factory, KafkaConnectorFactory.class);

    Connector c = factory.create(
        "test-connector",
        ImmutableMap.<String, String>builder()
            .put("kafka.table-names", "test")
            .put("kafka.nodes", "localhost:9092")
            .build(),
        new TestingConnectorContext());
    assertNotNull(c);
  }
}

代码示例来源:origin: prestodb/presto

private static void assertCreateConnector(String metastoreUri)
{
  HiveConnectorFactory connectorFactory = new HiveConnectorFactory(
      "hive-test",
      HiveConnector.class.getClassLoader(),
      Optional.empty());
  Map<String, String> config = ImmutableMap.<String, String>builder()
      .put("hive.metastore.uri", metastoreUri)
      .build();
  Connector connector = connectorFactory.create("hive-test", config, new TestingConnectorContext());
  ConnectorTransactionHandle transaction = connector.beginTransaction(READ_UNCOMMITTED, true);
  assertInstanceOf(connector.getMetadata(transaction), ClassLoaderSafeConnectorMetadata.class);
  assertInstanceOf(connector.getSplitManager(), ClassLoaderSafeConnectorSplitManager.class);
  assertInstanceOf(connector.getPageSourceProvider(), ConnectorPageSourceProvider.class);
  connector.commit(transaction);
}

代码示例来源:origin: prestodb/presto

protected void assertExpectedPartitions(List<HivePartition> actualPartitions, Iterable<HivePartition> expectedPartitions)
{
  Map<String, ?> actualById = uniqueIndex(actualPartitions, HivePartition::getPartitionId);
  for (Object expected : expectedPartitions) {
    assertInstanceOf(expected, HivePartition.class);
    HivePartition expectedPartition = (HivePartition) expected;
    Object actual = actualById.get(expectedPartition.getPartitionId());
    assertEquals(actual, expected);
    assertInstanceOf(actual, HivePartition.class);
    HivePartition actualPartition = (HivePartition) actual;
    assertNotNull(actualPartition, "partition " + expectedPartition.getPartitionId());
    assertEquals(actualPartition.getPartitionId(), expectedPartition.getPartitionId());
    assertEquals(actualPartition.getKeys(), expectedPartition.getKeys());
    assertEquals(actualPartition.getTableName(), expectedPartition.getTableName());
  }
}

代码示例来源:origin: prestodb/presto

protected static void assertPageSourceType(ConnectorPageSource pageSource, HiveStorageFormat hiveStorageFormat)
{
  if (pageSource instanceof RecordPageSource) {
    RecordCursor hiveRecordCursor = ((RecordPageSource) pageSource).getCursor();
    hiveRecordCursor = ((HiveRecordCursor) hiveRecordCursor).getRegularColumnRecordCursor();
    if (hiveRecordCursor instanceof HiveCoercionRecordCursor) {
      hiveRecordCursor = ((HiveCoercionRecordCursor) hiveRecordCursor).getRegularColumnRecordCursor();
    }
    assertInstanceOf(hiveRecordCursor, recordCursorType(hiveStorageFormat), hiveStorageFormat.name());
  }
  else {
    assertInstanceOf(((HivePageSource) pageSource).getPageSource(), pageSourceType(hiveStorageFormat), hiveStorageFormat.name());
  }
}

代码示例来源:origin: prestodb/presto

private static void testProjectRange(Block block, Class<? extends Block> expectedResultType, DictionaryAwarePageProjection projection, boolean forceYield)
{
  DriverYieldSignal yieldSignal = new DriverYieldSignal();
  Work<Block> work = projection.project(null, yieldSignal, new Page(block), SelectedPositions.positionsRange(5, 10));
  Block result;
  if (forceYield) {
    result = projectWithYield(work, yieldSignal);
  }
  else {
    assertTrue(work.process());
    result = work.getResult();
  }
  assertBlockEquals(
      BIGINT,
      result,
      block.getRegion(5, 10));
  assertInstanceOf(result, expectedResultType);
}

代码示例来源:origin: prestodb/presto

private static void testProjectList(Block block, Class<? extends Block> expectedResultType, DictionaryAwarePageProjection projection, boolean forceYield)
{
  DriverYieldSignal yieldSignal = new DriverYieldSignal();
  int[] positions = {0, 2, 4, 6, 8, 10};
  Work<Block> work = projection.project(null, yieldSignal, new Page(block), SelectedPositions.positionsList(positions, 0, positions.length));
  Block result;
  if (forceYield) {
    result = projectWithYield(work, yieldSignal);
  }
  else {
    assertTrue(work.process());
    result = work.getResult();
  }
  assertBlockEquals(
      BIGINT,
      result,
      block.copyPositions(positions, 0, positions.length));
  assertInstanceOf(result, expectedResultType);
}

代码示例来源:origin: prestodb/presto

private static void testProjectFastReturnIgnoreYield(Block block, DictionaryAwarePageProjection projection)
{
  DriverYieldSignal yieldSignal = new DriverYieldSignal();
  Work<Block> work = projection.project(null, yieldSignal, new Page(block), SelectedPositions.positionsRange(5, 10));
  yieldSignal.setWithDelay(1, executor);
  yieldSignal.forceYieldForTesting();
  // yield signal is ignored given the block has already been loaded
  assertTrue(work.process());
  Block result = work.getResult();
  yieldSignal.reset();
  assertBlockEquals(
      BIGINT,
      result,
      block.getRegion(5, 10));
  assertInstanceOf(result, DictionaryBlock.class);
}

相关文章