org.hamcrest.core.IsInstanceOf Java Examples

The following examples show how to use org.hamcrest.core.IsInstanceOf. 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: ClusterTierActiveEntityTest.java    From ehcache3 with Apache License 2.0 6 votes vote down vote up
@Test
public void testValidateServerStore_DedicatedStoresDifferentSizes() throws Exception {
  ClusterTierActiveEntity activeEntity = new ClusterTierActiveEntity(defaultRegistry, defaultConfiguration, DEFAULT_MAPPER);
  activeEntity.createNew();

  TestInvokeContext context = new TestInvokeContext();
  activeEntity.connected(context.getClientDescriptor());

  ServerStoreConfiguration storeConfiguration = new ServerStoreConfigBuilder()
    .dedicated(defaultResource, 2, MemoryUnit.MEGABYTES)
    .build();

  String expectedMessageContent = "Existing ServerStore configuration is not compatible with the desired configuration: " +
                                  "\n\t" +
                                  "resourcePoolType existing: " +
                                  defaultStoreConfiguration.getPoolAllocation() +
                                  ", desired: " +
                                  storeConfiguration.getPoolAllocation();

  assertThat(activeEntity.invokeActive(context, new LifecycleMessage.ValidateServerStore(defaultStoreName, storeConfiguration)),
    failsWith(both(IsInstanceOf.any(InvalidServerStoreConfigurationException.class)).and(withMessage(containsString(expectedMessageContent)))));
}
 
Example #2
Source File: GeoCityLookupTest.java    From gcp-ingestion with Mozilla Public License 2.0 6 votes vote down vote up
@Test
public void testThrowsOnMissingCityFilter() throws Exception {
  thrown.expectCause(IsInstanceOf.instanceOf(UncheckedIOException.class));

  final List<String> input = Arrays
      .asList("{\"attributeMap\":{\"host\":\"test\"},\"payload\":\"dGVzdA==\"}");

  pipeline //
      .apply(Create.of(input)) //
      .apply(InputFileFormat.json.decode()) //
      .apply(
          GeoCityLookup.of(pipeline.newProvider(MMDB), pipeline.newProvider("missing-file.txt")));

  GeoCityLookup.clearSingletonsForTests();
  pipeline.run();
}
 
Example #3
Source File: TaskTest.java    From ews-java-api with MIT License 6 votes vote down vote up
/**
 * Test for checking if the value changes in case of a thrown exception
 *
 * @throws Exception
 */
@Test
public void testDontChangeValueOnException() throws Exception {
  // set valid value
  final Double targetValue = 50.5;
  taskMock.setPercentComplete(targetValue);

  assertThat(taskMock.getPercentComplete(), IsNot.not(IsNull.nullValue()));
  assertThat(taskMock.getPercentComplete(), IsInstanceOf.instanceOf(Double.class));
  assertThat(taskMock.getPercentComplete(), IsEqual.equalTo(targetValue));

  final Double invalidValue = -0.1;
  try {
    taskMock.setPercentComplete(invalidValue);
  } catch (IllegalArgumentException ex) {
    // ignored
  }

  assertThat(taskMock.getPercentComplete(), IsNot.not(IsNull.nullValue()));
  assertThat(taskMock.getPercentComplete(), IsInstanceOf.instanceOf(Double.class));
  assertThat(taskMock.getPercentComplete(), IsEqual.equalTo(targetValue));
}
 
Example #4
Source File: ClusterTierActiveEntityTest.java    From ehcache3 with Apache License 2.0 6 votes vote down vote up
@Test
public void testValidateServerStore_DedicatedStoreResourceNamesDifferent() throws Exception {
  ClusterTierActiveEntity activeEntity = new ClusterTierActiveEntity(defaultRegistry, defaultConfiguration, DEFAULT_MAPPER);
  activeEntity.createNew();

  TestInvokeContext context = new TestInvokeContext();
  activeEntity.connected(context.getClientDescriptor());

  ServerStoreConfiguration storeConfiguration = new ServerStoreConfigBuilder()
    .dedicated("otherResource", 1, MemoryUnit.MEGABYTES)
    .build();

  String expectedMessageContent = "Existing ServerStore configuration is not compatible with the desired configuration: " +
                                  "\n\t" +
                                  "resourcePoolType existing: " +
                                  defaultStoreConfiguration.getPoolAllocation() +
                                  ", desired: " +
                                  storeConfiguration.getPoolAllocation();

  assertThat(activeEntity.invokeActive(context, new LifecycleMessage.ValidateServerStore(defaultStoreName, storeConfiguration)),
    failsWith(both(IsInstanceOf.any(InvalidServerStoreConfigurationException.class)).and(withMessage(containsString(expectedMessageContent)))));
}
 
Example #5
Source File: GeoCityLookupTest.java    From gcp-ingestion with Mozilla Public License 2.0 6 votes vote down vote up
@Test
public void testThrowsOnInvalidCityFilter() throws Exception {
  thrown.expectCause(IsInstanceOf.instanceOf(IllegalStateException.class));

  final List<String> input = Arrays
      .asList("{\"attributeMap\":{\"host\":\"test\"},\"payload\":\"dGVzdA==\"}");

  pipeline //
      .apply(Create.of(input)) //
      .apply(InputFileFormat.json.decode()) //
      .apply(GeoCityLookup.of(pipeline.newProvider(MMDB),
          pipeline.newProvider("src/test/resources/cityFilters/invalid.txt")));

  GeoCityLookup.clearSingletonsForTests();
  pipeline.run();
}
 
Example #6
Source File: NegativeTransactionProcessorTest.java    From eosio-java with MIT License 6 votes vote down vote up
@Test
public void prepare_thenFailWithGetInfoError() throws TransactionPrepareError {
    exceptionRule.expect(TransactionPrepareRpcError.class);
    exceptionRule.expectMessage(ErrorConstants.TRANSACTION_PROCESSOR_RPC_GET_INFO);
    exceptionRule.expectCause(IsInstanceOf.<EosioError>instanceOf(GetInfoRpcError.class));

    try {
        // Mock RpcProvider to throw exception
        when(this.mockedRpcProvider.getInfo()).thenThrow(new GetInfoRpcError());
    } catch (GetInfoRpcError getInfoRpcError) {
        getInfoRpcError.printStackTrace();
        fail("Exception should not be thrown here for mocking getInfo");
    }

    TransactionProcessor processor = session.getTransactionProcessor();
    processor.prepare(this.defaultActions());
}
 
Example #7
Source File: ConfigServicePropertySourceLocatorTests.java    From spring-cloud-config with Apache License 2.0 6 votes vote down vote up
@Test
public void failFastWhenNotFound() throws Exception {
	ClientHttpRequestFactory requestFactory = Mockito
			.mock(ClientHttpRequestFactory.class);
	ClientHttpRequest request = Mockito.mock(ClientHttpRequest.class);
	ClientHttpResponse response = Mockito.mock(ClientHttpResponse.class);
	Mockito.when(requestFactory.createRequest(Mockito.any(URI.class),
			Mockito.any(HttpMethod.class))).thenReturn(request);
	RestTemplate restTemplate = new RestTemplate(requestFactory);
	ConfigClientProperties defaults = new ConfigClientProperties(this.environment);
	defaults.setFailFast(true);
	this.locator = new ConfigServicePropertySourceLocator(defaults);
	Mockito.when(request.getHeaders()).thenReturn(new HttpHeaders());
	Mockito.when(request.execute()).thenReturn(response);
	HttpHeaders headers = new HttpHeaders();
	headers.setContentType(MediaType.APPLICATION_JSON);
	Mockito.when(response.getHeaders()).thenReturn(headers);
	Mockito.when(response.getStatusCode()).thenReturn(HttpStatus.NOT_FOUND);
	Mockito.when(response.getBody())
			.thenReturn(new ByteArrayInputStream("".getBytes()));
	this.locator.setRestTemplate(restTemplate);
	this.expected
			.expectCause(IsInstanceOf.instanceOf(IllegalArgumentException.class));
	this.expected.expectMessage("fail fast property is set");
	this.locator.locateCollection(this.environment);
}
 
Example #8
Source File: ExceptionUtilsTest.java    From symbol-sdk-java with Apache License 2.0 6 votes vote down vote up
@Test
public void propagateMapsInterruptedExceptionToIllegalStateException()
    throws InterruptedException {
    // Arrange:
    final InterruptedExceptionTestRunner runner =
        new InterruptedExceptionTestRunner(
            () ->
                ExceptionUtils.propagate(
                    () -> {
                        Thread.sleep(1000);
                        return null;
                    }));

    // Act:
    runner.run();

    // Assert:
    MatcherAssert.assertThat(runner.getUnhandledException(), IsNull.notNullValue());
    MatcherAssert.assertThat(
        runner.getUnhandledException(), IsInstanceOf.instanceOf(IllegalStateException.class));
}
 
Example #9
Source File: ConfigServicePropertySourceLocatorTests.java    From spring-cloud-config with Apache License 2.0 6 votes vote down vote up
@Test
public void sunnyDayWithNoSuchLabelAndFailFast() {
	ConfigClientProperties defaults = new ConfigClientProperties(this.environment);
	defaults.setFailFast(true);
	this.locator = new ConfigServicePropertySourceLocator(defaults);
	mockRequestResponseWithLabel(
			new ResponseEntity<>((Void) null, HttpStatus.NOT_FOUND),
			"release(_)v1.0.0");
	this.locator.setRestTemplate(this.restTemplate);
	TestPropertyValues.of("spring.cloud.config.label:release/v1.0.1")
			.applyTo(this.environment);
	this.expected.expect(IsInstanceOf.instanceOf(IllegalStateException.class));
	this.expected.expectMessage(
			"Could not locate PropertySource and the fail fast property is set, failing: None of labels [release/v1.0.1] found");
	this.locator.locateCollection(this.environment);
}
 
Example #10
Source File: AnnotateVariantsITCase.java    From dataflow-java with Apache License 2.0 6 votes vote down vote up
@Test
public void testBadCallSetName() throws Exception {
  thrown.expect(IsInstanceOf.<IllegalArgumentException>instanceOf(NullPointerException.class));
  thrown.expectMessage(containsString("Call set name 'NotInVariantSet' does not correspond to a call "
      + "set id in variant set id 3049512673186936334"));

  String[] ARGS = {
      "--project=" + helper.getTestProject(),
      "--references=chr17:40700000:40800000",
      "--variantSetId=" + helper.PLATINUM_GENOMES_DATASET,
      "--transcriptSetIds=CIjfoPXj9LqPlAEQ5vnql4KewYuSAQ",
      "--variantAnnotationSetIds=CILSqfjtlY6tHxC0nNH-4cu-xlQ",
      "--callSetNames=NotInVariantSet",
      "--output=" + outputPrefix,
      };

  System.out.println(ARGS);

  testBase(ARGS, EXPECTED_RESULT);
}
 
Example #11
Source File: SecureCredentialsManagerTest.java    From Auth0.Android with MIT License 6 votes vote down vote up
@Test
public void shouldClearStoredCredentialsAndFailOnGetCredentialsWhenCryptoExceptionIsThrown() {
    verifyNoMoreInteractions(client);

    Date expiresAt = new Date(CredentialsMock.CURRENT_TIME_MS + 123456L * 1000);
    String storedJson = insertTestCredentials(true, true, true, expiresAt);
    when(crypto.decrypt(storedJson.getBytes())).thenThrow(new CryptoException(null, null));
    manager.getCredentials(callback);

    verify(callback).onFailure(exceptionCaptor.capture());
    CredentialsManagerException exception = exceptionCaptor.getValue();
    assertThat(exception, is(notNullValue()));
    assertThat(exception.getCause(), IsInstanceOf.<Throwable>instanceOf(CryptoException.class));
    assertThat(exception.getMessage(), is("A change on the Lock Screen security settings have deemed the encryption keys invalid and have been recreated. " +
            "Any previously stored content is now lost. Please, try saving the credentials again."));


    verify(storage).remove("com.auth0.credentials");
    verify(storage).remove("com.auth0.credentials_expires_at");
    verify(storage).remove("com.auth0.credentials_can_refresh");
}
 
Example #12
Source File: InMemoryReaderFactoryTest.java    From beam with Apache License 2.0 6 votes vote down vote up
<T> void runTestCreateInMemoryReader(
    List<T> elements, Long start, Long end, int expectedStart, int expectedEnd, Coder<T> coder)
    throws Exception {
  Source cloudSource = createInMemoryCloudSource(elements, start, end, coder);

  NativeReader<?> reader =
      ReaderRegistry.defaultRegistry()
          .create(
              cloudSource,
              PipelineOptionsFactory.create(),
              BatchModeExecutionContext.forTesting(PipelineOptionsFactory.create(), "testStage"),
              TestOperationContext.create());
  Assert.assertThat(reader, new IsInstanceOf(InMemoryReader.class));
  InMemoryReader<?> inMemoryReader = (InMemoryReader<?>) reader;
  Assert.assertEquals(
      InMemoryReaderTest.encodedElements(elements, coder), inMemoryReader.encodedElements);
  Assert.assertEquals(expectedStart, inMemoryReader.startIndex);
  Assert.assertEquals(expectedEnd, inMemoryReader.endIndex);
  Assert.assertEquals(coder, inMemoryReader.coder);
}
 
Example #13
Source File: ShuffleSinkFactoryTest.java    From beam with Apache License 2.0 6 votes vote down vote up
private ShuffleSink runTestCreateShuffleSinkHelper(
    byte[] shuffleWriterConfig,
    String shuffleKind,
    Coder<?> deserializedCoder,
    FullWindowedValueCoder<?> coder)
    throws Exception {
  CloudObject spec = CloudObject.forClassName("ShuffleSink");
  addString(spec, "shuffle_writer_config", encodeBase64String(shuffleWriterConfig));
  addString(spec, "shuffle_kind", shuffleKind);

  PipelineOptions options = PipelineOptionsFactory.create();

  ShuffleSinkFactory factory = new ShuffleSinkFactory();
  Sink<?> sink =
      factory.create(
          spec,
          deserializedCoder,
          options,
          BatchModeExecutionContext.forTesting(options, "testStage"),
          TestOperationContext.create());
  Assert.assertThat(sink, new IsInstanceOf(ShuffleSink.class));
  ShuffleSink shuffleSink = (ShuffleSink) sink;
  Assert.assertArrayEquals(shuffleWriterConfig, shuffleSink.shuffleWriterConfig);
  Assert.assertEquals(coder, shuffleSink.windowedElemCoder);
  return shuffleSink;
}
 
Example #14
Source File: ReaderFactoryTest.java    From beam with Apache License 2.0 6 votes vote down vote up
@Test
public void testCreateReader() throws Exception {
  CloudObject spec = CloudObject.forClass(TestReaderFactory.class);

  Source cloudSource = new Source();
  cloudSource.setSpec(spec);
  cloudSource.setCodec(
      CloudObjects.asCloudObject(BigEndianIntegerCoder.of(), /*sdkComponents=*/ null));

  PipelineOptions options = PipelineOptionsFactory.create();
  ReaderRegistry registry =
      ReaderRegistry.defaultRegistry()
          .register(TestReaderFactory.class.getName(), new TestReaderFactory());
  NativeReader<?> reader =
      registry.create(
          cloudSource,
          PipelineOptionsFactory.create(),
          BatchModeExecutionContext.forTesting(options, "testStage"),
          null);
  Assert.assertThat(reader, new IsInstanceOf(TestReader.class));
}
 
Example #15
Source File: RestTriggerResourceTest.java    From development with Apache License 2.0 6 votes vote down vote up
@Test
public void testAction() throws Exception {
    RestTriggerResource.Action action = new RestTriggerResource()
            .redirectToAction();

    TriggerParameters params = new TriggerParameters();
    params.setId(new Long(1L));

    ContainerRequest request = Mockito.mock(ContainerRequest.class);
    Mockito.when(request.getProperty(Mockito.anyString()))
            .thenReturn(new Integer(CommonParams.VERSION_1));

    Response response = action.getCollection(request, params);
    assertThat(response.getEntity(),
            IsInstanceOf.instanceOf(RepresentationCollection.class));

    assertNull(action.getItem(request, params));
}
 
Example #16
Source File: TestTraversalAddV.java    From sqlg with MIT License 6 votes vote down vote up
@Test
public void shouldDetachVertexWhenAdded() {
    final AtomicBoolean triggered = new AtomicBoolean(false);

    final MutationListener listener = new AbstractMutationListener() {
        @Override
        public void vertexAdded(final Vertex element) {
            Assert.assertThat(element, IsInstanceOf.instanceOf(DetachedVertex.class));
            Assert.assertEquals("thing", element.label());
            Assert.assertEquals("there", element.value("here"));
            triggered.set(true);
        }
    };
    final EventStrategy.Builder builder = EventStrategy.build().addListener(listener);

    builder.eventQueue(new EventStrategy.TransactionalEventQueue(this.sqlgGraph));

    final EventStrategy eventStrategy = builder.create();
    final GraphTraversalSource gts = create(eventStrategy);

    gts.addV("thing").property("here", "there").iterate();
    sqlgGraph.tx().commit();
    Assert.assertThat(triggered.get(), Is.is(true));
}
 
Example #17
Source File: ConfigurationDerivation.java    From ehcache3 with Apache License 2.0 6 votes vote down vote up
@Test
public void withServiceCreation() {
  Configuration configuration = ConfigurationBuilder.newConfigurationBuilder()
    .withCache("cache", CacheConfigurationBuilder.newCacheConfigurationBuilder(Long.class, String.class, ResourcePoolsBuilder.heap(10)))
    .build();

  //tag::withServiceCreation[]
  Configuration withBoundedThreads = configuration.derive()
    .withService(new PooledExecutionServiceConfiguration()
      .addDefaultPool("default", 1, 16))
    .build();
  //end::withServiceCreation[]

  Assert.assertThat(configuration.getServiceCreationConfigurations(), IsNot.not(IsCollectionContaining.hasItem(IsInstanceOf.instanceOf(PooledExecutionServiceConfiguration.class))));
  PooledExecutionServiceConfiguration serviceCreationConfiguration = ServiceUtils.findSingletonAmongst(PooledExecutionServiceConfiguration.class, withBoundedThreads.getServiceCreationConfigurations());
  Assert.assertThat(serviceCreationConfiguration.getDefaultPoolAlias(), Is.is("default"));
  Assert.assertThat(serviceCreationConfiguration.getPoolConfigurations().keySet(), IsIterableContainingInAnyOrder.containsInAnyOrder("default"));
  PooledExecutionServiceConfiguration.PoolConfiguration pool = serviceCreationConfiguration.getPoolConfigurations().get("default");
  Assert.assertThat(pool.minSize(), Is.is(1));
  Assert.assertThat(pool.maxSize(), Is.is(16));
}
 
Example #18
Source File: ConfigurationDerivation.java    From ehcache3 with Apache License 2.0 6 votes vote down vote up
@Test
public void withService() {
  Configuration configuration = ConfigurationBuilder.newConfigurationBuilder()
    .withCache("cache", CacheConfigurationBuilder.newCacheConfigurationBuilder(Long.class, String.class, ResourcePoolsBuilder.heap(10)))
    .build();

  //tag::withService[]
  Configuration withThrowingStrategy = configuration.derive()
    .updateCache("cache", existing -> existing.withService(
      new DefaultResilienceStrategyConfiguration(new ThrowingResilienceStrategy<>())
    ))
    .build();
  //end::withService[]


  Assert.assertThat(configuration.getServiceCreationConfigurations(), IsNot.not(IsCollectionContaining.hasItem(
    IsInstanceOf.instanceOf(DefaultResilienceStrategyConfiguration.class))));

  DefaultResilienceStrategyConfiguration resilienceStrategyConfiguration =
    ServiceUtils.findSingletonAmongst(DefaultResilienceStrategyConfiguration.class,
      withThrowingStrategy.getCacheConfigurations().get("cache").getServiceConfigurations());
  Assert.assertThat(resilienceStrategyConfiguration.getInstance(), IsInstanceOf.instanceOf(ThrowingResilienceStrategy.class));
}
 
Example #19
Source File: BaseTestRuleBasedAuthorizationPlugin.java    From lucene-solr with Apache License 2.0 6 votes vote down vote up
@Test
public void testAllPermissionDeniesActionsWhenUserIsNotCorrectRole() {
  SolrRequestHandler handler = new UpdateRequestHandler();
  assertThat(handler, new IsInstanceOf(PermissionNameProvider.class));
  setUserRole("dev", "dev");
  setUserRole("admin", "admin");
  addPermission("all", "admin");
  checkRules(makeMap("resource", "/update",
      "userPrincipal", "dev",
      "requestType", RequestType.UNKNOWN,
      "collectionRequests", "go",
      "handler", new UpdateRequestHandler(),
      "params", new MapSolrParams(singletonMap("key", "VAL2")))
      , FORBIDDEN);

  handler = new PropertiesRequestHandler();
  assertThat(handler, new IsNot<>(new IsInstanceOf(PermissionNameProvider.class)));
  checkRules(makeMap("resource", "/admin/info/properties",
      "userPrincipal", "dev",
      "requestType", RequestType.UNKNOWN,
      "collectionRequests", "go",
      "handler", handler,
      "params", new MapSolrParams(emptyMap()))
      , FORBIDDEN);
}
 
Example #20
Source File: NegativeTransactionProcessorTest.java    From eosio-java with MIT License 6 votes vote down vote up
@Test
public void prepare_thenFailWithGetBlockError() throws TransactionPrepareError {
    exceptionRule.expect(TransactionPrepareRpcError.class);
    exceptionRule.expectMessage(ErrorConstants.TRANSACTION_PROCESSOR_PREPARE_RPC_GET_BLOCK);
    exceptionRule.expectCause(IsInstanceOf.<EosioError>instanceOf(GetBlockRpcError.class));

    // Mock RpcProvider
    this.mockGetInfoPositively();

    try {
        when(this.mockedRpcProvider.getBlock(any(GetBlockRequest.class))).thenThrow(new GetBlockRpcError());
    } catch (GetBlockRpcError getBlockRpcError) {
        getBlockRpcError.printStackTrace();
        fail("Exception should not be thrown here for mocking getBlock");
    }

    TransactionProcessor processor = session.getTransactionProcessor();
    processor.prepare(this.defaultActions());
}
 
Example #21
Source File: ShuffleReaderFactoryTest.java    From beam with Apache License 2.0 5 votes vote down vote up
<T extends NativeReader> T runTestCreateShuffleReader(
    byte[] shuffleReaderConfig,
    @Nullable String start,
    @Nullable String end,
    CloudObject encoding,
    BatchModeExecutionContext context,
    Class<T> shuffleReaderClass,
    String shuffleSourceAlias)
    throws Exception {
  CloudObject spec = CloudObject.forClassName(shuffleSourceAlias);
  addString(spec, "shuffle_reader_config", encodeBase64String(shuffleReaderConfig));
  if (start != null) {
    addString(spec, "start_shuffle_position", start);
  }
  if (end != null) {
    addString(spec, "end_shuffle_position", end);
  }

  Source cloudSource = new Source();
  cloudSource.setSpec(spec);
  cloudSource.setCodec(encoding);

  NativeReader<?> reader =
      ReaderRegistry.defaultRegistry()
          .create(cloudSource, PipelineOptionsFactory.create(), context, null);
  Assert.assertThat(reader, new IsInstanceOf(shuffleReaderClass));
  return (T) reader;
}
 
Example #22
Source File: AvroByteReaderFactoryTest.java    From beam with Apache License 2.0 5 votes vote down vote up
@Test
public void testCreateRichAvroByteReader() throws Exception {
  Coder<?> coder =
      WindowedValue.getFullCoder(BigEndianIntegerCoder.of(), GlobalWindow.Coder.INSTANCE);
  NativeReader<?> reader =
      runTestCreateAvroReader(
          pathToAvroFile, 200L, 500L, CloudObjects.asCloudObject(coder, /*sdkComponents=*/ null));

  Assert.assertThat(reader, new IsInstanceOf(AvroByteReader.class));
  AvroByteReader avroReader = (AvroByteReader) reader;
  Assert.assertEquals(pathToAvroFile, avroReader.avroSource.getFileOrPatternSpec());
  Assert.assertEquals(200L, avroReader.startPosition);
  Assert.assertEquals(500L, avroReader.endPosition);
  Assert.assertEquals(coder, avroReader.coder);
}
 
Example #23
Source File: SinkRegistryTest.java    From beam with Apache License 2.0 5 votes vote down vote up
@Test
public void testCreatePredefinedSink() throws Exception {
  CloudObject spec = CloudObject.forClassName("AvroSink");
  addString(spec, "filename", "/path/to/file.txt");

  SizeReportingSinkWrapper<?> sink =
      SinkRegistry.defaultRegistry()
          .create(
              spec,
              StringUtf8Coder.of(),
              options,
              BatchModeExecutionContext.forTesting(options, "testStage"),
              TestOperationContext.create());
  Assert.assertThat(sink.getUnderlyingSink(), new IsInstanceOf(AvroByteSink.class));
}
 
Example #24
Source File: AddressUtilsTest.java    From mldht with Mozilla Public License 2.0 5 votes vote down vote up
@Test
public void testMappedBypass() throws UnknownHostException {
	byte[] v4mapped = new byte[16];
	v4mapped[11] = (byte) 0xff;
	v4mapped[10] = (byte) 0xff;
			
	assertThat(InetAddress.getByAddress(v4mapped), IsInstanceOf.instanceOf(Inet4Address.class));
	assertThat(AddressUtils.fromBytesVerbatim(v4mapped), IsInstanceOf.instanceOf(Inet6Address.class));
	
}
 
Example #25
Source File: CryptoEngineTest.java    From nem.core with MIT License 5 votes vote down vote up
@Test
public void canGetCurve() {
	// Act:
	final Curve curve = this.getCryptoEngine().getCurve();

	// Assert:
	Assert.assertThat(curve, IsInstanceOf.instanceOf(Curve.class));
}
 
Example #26
Source File: CryptoEngineTest.java    From nem.core with MIT License 5 votes vote down vote up
@Test
public void canCreateDsaSigner() {
	// Act:
	final CryptoEngine engine = this.getCryptoEngine();
	final DsaSigner signer = engine.createDsaSigner(KeyPair.random(engine));

	// Assert:
	Assert.assertThat(signer, IsInstanceOf.instanceOf(DsaSigner.class));
}
 
Example #27
Source File: CryptoEngineTest.java    From nem.core with MIT License 5 votes vote down vote up
@Test
public void canCreateKeyGenerator() {
	// Act:
	final KeyGenerator keyGenerator = this.getCryptoEngine().createKeyGenerator();

	// Assert:
	Assert.assertThat(keyGenerator, IsInstanceOf.instanceOf(KeyGenerator.class));
}
 
Example #28
Source File: CryptoEngineTest.java    From nem.core with MIT License 5 votes vote down vote up
@Test
public void canCreateKeyAnalyzer() {
	// Act:
	final KeyAnalyzer keyAnalyzer = this.getCryptoEngine().createKeyAnalyzer();

	// Assert:
	Assert.assertThat(keyAnalyzer, IsInstanceOf.instanceOf(KeyAnalyzer.class));
}
 
Example #29
Source File: CryptoEngineTest.java    From nem.core with MIT License 5 votes vote down vote up
@Test
public void canCreateBlockCipher() {
	// Act:
	final CryptoEngine engine = this.getCryptoEngine();
	final BlockCipher blockCipher = engine.createBlockCipher(KeyPair.random(engine), KeyPair.random(engine));

	// Assert:
	Assert.assertThat(blockCipher, IsInstanceOf.instanceOf(BlockCipher.class));
}
 
Example #30
Source File: XMLRPCIntegrationTest.java    From maven-confluence-plugin with Apache License 2.0 5 votes vote down vote up
@Test @Ignore
public void findAttachment() throws Exception {
    
    Model.Page page = confluence.getOrCreatePage("ds", "Tutorial", "test").get();           
    Optional<Model.Attachment> a = confluence.getAttachment( page.getId(), "foto2.jpg", "0").join();

    assertThat( a.isPresent(), IsEqual.equalTo(true) );
    assertThat( a.get(), IsInstanceOf.instanceOf(Attachment.class) );

    System.out.printf( " created=[%tc] creator=[%s] size=[%s]\n", 
            a.get().getCreated(), 
            ((Attachment)a.get()).getCreator(), 
            ((Attachment)a.get()).getFileSize());
}