/** * A shortcut to the frequently used <code>is(instanceOf(SomeClass.class))</code>. * <p/> * For example: * <pre>assertThat(cheese, isA(Cheddar.class))</pre> * instead of: * <pre>assertThat(cheese, is(instanceOf(Cheddar.class)))</pre> */ public static <T> org.hamcrest.Matcher<T> isA(java.lang.Class<T> type) { return org.hamcrest.core.Is.<T>isA(type); }
/** * A shortcut to the frequently used <code>is(instanceOf(SomeClass.class))</code>. * <p/> * For example: * <pre>assertThat(cheese, isA(Cheddar.class))</pre> * instead of: * <pre>assertThat(cheese, is(instanceOf(Cheddar.class)))</pre> */ public static <T> org.hamcrest.Matcher<T> isA(java.lang.Class<T> type) { return org.hamcrest.core.Is.<T>isA(type); }
/** * A shortcut to the frequently used <code>is(instanceOf(SomeClass.class))</code>. * <p/> * For example: * <pre>assertThat(cheese, isA(Cheddar.class))</pre> * instead of: * <pre>assertThat(cheese, is(instanceOf(Cheddar.class)))</pre> */ public static <T> org.hamcrest.Matcher<T> isA(java.lang.Class<T> type) { return org.hamcrest.core.Is.<T>isA(type); }
/** * A shortcut to the frequently used <code>is(instanceOf(SomeClass.class))</code>. * For example: * <pre>assertThat(cheese, isA(Cheddar.class))</pre> * instead of: * <pre>assertThat(cheese, is(instanceOf(Cheddar.class)))</pre> */ public static <T> org.hamcrest.Matcher<T> isA(java.lang.Class<?> type) { return org.hamcrest.core.Is.isA(type); }
/** * A shortcut to the frequently used <code>is(instanceOf(SomeClass.class))</code>. * For example: * <pre>assertThat(cheese, isA(Cheddar.class))</pre> * instead of: * <pre>assertThat(cheese, is(instanceOf(Cheddar.class)))</pre> */ public static <T> org.hamcrest.Matcher<T> isA(java.lang.Class<T> type) { return org.hamcrest.core.Is.isA(type); }
@Override @Test public void jmsHandlerMethodFactoryConfiguration() throws JMSException { ApplicationContext context = new ClassPathXmlApplicationContext( "annotation-driven-custom-handler-method-factory.xml", getClass()); thrown.expect(ListenerExecutionFailedException.class); thrown.expectCause(Is.<MethodArgumentNotValidException>isA(MethodArgumentNotValidException.class)); testJmsHandlerMethodFactoryConfiguration(context); }
@Override @Test public void jmsHandlerMethodFactoryConfiguration() throws JMSException { ConfigurableApplicationContext context = new AnnotationConfigApplicationContext( EnableJmsHandlerMethodFactoryConfig.class, ValidationBean.class); thrown.expect(ListenerExecutionFailedException.class); thrown.expectCause(Is.<MethodArgumentNotValidException>isA(MethodArgumentNotValidException.class)); testJmsHandlerMethodFactoryConfiguration(context); }
@SuppressWarnings({ "unchecked", "rawtypes" }) @Test public void providesConvenientShortcutForIsInstanceOf() { final Matcher matcher = isA(Number.class); assertMatches(matcher, 1); assertDoesNotMatch(matcher, new Object()); assertDoesNotMatch(matcher, null); } }
/** * A shortcut to the frequently used <code>is(instanceOf(SomeClass.class))</code>. * For example: * <pre>assertThat(cheese, isA(Cheddar.class))</pre> * instead of: * <pre>assertThat(cheese, is(instanceOf(Cheddar.class)))</pre> */ public static <T> org.hamcrest.Matcher<T> isA(java.lang.Class<T> type) { return org.hamcrest.core.Is.<T>isA(type); }
/** * A shortcut to the frequently used <code>is(instanceOf(SomeClass.class))</code>. * <p/> * For example: * <pre>assertThat(cheese, isA(Cheddar.class))</pre> * instead of: * <pre>assertThat(cheese, is(instanceOf(Cheddar.class)))</pre> */ public static <T> org.hamcrest.Matcher<T> isA(java.lang.Class<T> type) { return org.hamcrest.core.Is.<T>isA(type); }
/** * A shortcut to the frequently used <code>is(instanceOf(SomeClass.class))</code>. * For example: * <pre>assertThat(cheese, isA(Cheddar.class))</pre> * instead of: * <pre>assertThat(cheese, is(instanceOf(Cheddar.class)))</pre> */ public static <T> org.hamcrest.Matcher<T> isA(java.lang.Class<T> type) { return org.hamcrest.core.Is.isA(type); }
/** * Ignore this test, see HBASE-21421 */ @Test @Ignore public void testReportRSWithWrongRegion() throws Exception { final TableName tableName = TableName.valueOf(this.name.getMethodName()); List<HRegionInfo> tableRegions = createTable(tableName); final ServerName sn = ServerName.parseVersionedServerName( ServerName.valueOf("1.example.org", 1, System.currentTimeMillis()).getVersionedBytes()); // make fake request with a region assigned to different RS RegionServerStatusProtos.RegionServerReportRequest.Builder request = makeRSReportRequestWithRegions(sn, tableRegions.get(1)); // sending fake request to master // TODO: replace YouAreDeadException with appropriate exception as and when necessary exception.expect(ServiceException.class); exception.expectCause(isA(YouAreDeadException.class)); RegionServerStatusProtos.RegionServerReportResponse response = master.getMasterRpcServices().regionServerReport(null, request.build()); }
@Test public void shouldRethrowExceptions() { RuntimeException response = allocationFailures.responseTo(FAILURE); assertThat(response.getCause(), is(FAILURE)); assertThat(response, isA(RuntimeException.class)); assertThat(response.getMessage(), containsString("Could not allocate more timestamps")); }
@Test public void shouldConfigureToStart() { // given processEngineConfiguration .setHistoryRemovalTimeProvider(mock(HistoryRemovalTimeProvider.class)) .setHistoryRemovalTimeStrategy(HISTORY_REMOVAL_TIME_STRATEGY_START); // when processEngineConfiguration.initHistoryRemovalTime(); // then assertThat(processEngineConfiguration.getHistoryRemovalTimeStrategy(), is(HISTORY_REMOVAL_TIME_STRATEGY_START)); assertThat(processEngineConfiguration.getHistoryRemovalTimeProvider(), isA(HistoryRemovalTimeProvider.class)); }
@Test public void shouldConfigureToEnd() { // given processEngineConfiguration .setHistoryRemovalTimeProvider(mock(HistoryRemovalTimeProvider.class)) .setHistoryRemovalTimeStrategy(HISTORY_REMOVAL_TIME_STRATEGY_END); // when processEngineConfiguration.initHistoryRemovalTime(); // then assertThat(processEngineConfiguration.getHistoryRemovalTimeStrategy(), is(HISTORY_REMOVAL_TIME_STRATEGY_END)); assertThat(processEngineConfiguration.getHistoryRemovalTimeProvider(), isA(HistoryRemovalTimeProvider.class)); }
@Test public void shouldConfigureToNone() { // given processEngineConfiguration .setHistoryRemovalTimeProvider(mock(HistoryRemovalTimeProvider.class)) .setHistoryRemovalTimeStrategy(HISTORY_REMOVAL_TIME_STRATEGY_NONE); // when processEngineConfiguration.initHistoryRemovalTime(); // then assertThat(processEngineConfiguration.getHistoryRemovalTimeStrategy(), is(HISTORY_REMOVAL_TIME_STRATEGY_NONE)); assertThat(processEngineConfiguration.getHistoryRemovalTimeProvider(), isA(HistoryRemovalTimeProvider.class)); }
@Test public void shouldAutomaticallyConfigure() { // given processEngineConfiguration .setHistoryRemovalTimeProvider(null) .setHistoryRemovalTimeStrategy(null); // when processEngineConfiguration.initHistoryRemovalTime(); // then assertThat(processEngineConfiguration.getHistoryRemovalTimeStrategy(), is(HISTORY_REMOVAL_TIME_STRATEGY_END)); assertThat(processEngineConfiguration.getHistoryRemovalTimeProvider(), isA(HistoryRemovalTimeProvider.class)); }
@Test public void shouldConfigureWithoutProvider() { // given processEngineConfiguration .setHistoryRemovalTimeProvider(null) .setHistoryRemovalTimeStrategy(HISTORY_REMOVAL_TIME_STRATEGY_END); // when processEngineConfiguration.initHistoryRemovalTime(); // then assertThat(processEngineConfiguration.getHistoryRemovalTimeStrategy(), is(HISTORY_REMOVAL_TIME_STRATEGY_END)); assertThat(processEngineConfiguration.getHistoryRemovalTimeProvider(), isA(HistoryRemovalTimeProvider.class)); }
@Test public void shouldConfigureWithNotExistentStrategy() { // given processEngineConfiguration.setHistoryRemovalTimeStrategy("notExistentStrategy"); // then thrown.expect(ProcessEngineException.class); thrown.expectMessage("history removal time strategy must be set to 'start', 'end' or 'none'"); // when processEngineConfiguration.initHistoryRemovalTime(); // assume assertThat(processEngineConfiguration.getHistoryRemovalTimeProvider(), isA(HistoryRemovalTimeProvider.class)); }
@Test public void resolvePollingSourceMetadata() { MetadataResult<ComponentMetadataDescriptor<SourceModel>> sourceMetadata = metadataService.getSourceMetadata(Location.builder().globalName("polling-source").addSourcePart().build()); assertThat(sourceMetadata.get().getModel().getOutput().getType(), (Matcher) isA(StringType.class)); } }