Refine search
/** * 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> * */ @Factory public static <T> Matcher<T> isA(Class<T> type) { final Matcher<T> typeMatcher = instanceOf(type); return is(typeMatcher); } }
@Test public void testLogDelegationIsActivated() { assertThat( LOG, instanceOf( Log4DelegatingLogger.class ) ); }
@Test public void testCacheManagerUnwrap() { assertThat(cacheManager.unwrap(org.ehcache.CacheManager.class), is(instanceOf(EhcacheManager.class))); assertThat(cacheManager.unwrap(cacheManager.getClass()), is(instanceOf(Eh107CacheManager.class))); }
@Test public void shouldCreateMetadataPolicyWhenTimestampFieldNotProvided() { assertThat(TimestampExtractionPolicyFactory.create(schemaBuilder.build(), null, null), instanceOf(MetadataTimestampExtractionPolicy.class)); }
@Test public void shouldFailToAddEntitiesWithDifferentVertices() { // Given final Walk.Builder builder = new Walk.Builder(); // When try { builder.entities(ENTITY_A, ENTITY_B); fail("Expecting exception to be thrown when attempting to add an invalid entity."); } catch (final Exception e) { // Then assertThat(e, is(instanceOf(IllegalArgumentException.class))); assertThat(e.getMessage(), containsString("Entities must all have the same vertex.")); } }
private void assertQuerySucceeds(final String sql) { final Statement statement = KSQL_PARSER.buildAst(sql, metaStore).get(0).getStatement(); assertThat(statement, instanceOf(Query.class)); }
@Test // SPR-13443 public void shouldReadInputStreamResource() throws IOException { try (InputStream body = getClass().getResourceAsStream("logo.jpg") ) { MockHttpInputMessage inputMessage = new MockHttpInputMessage(body); inputMessage.getHeaders().setContentType(MediaType.IMAGE_JPEG); inputMessage.getHeaders().setContentDisposition( ContentDisposition.builder("attachment").filename("yourlogo.jpg").build()); Resource actualResource = converter.read(InputStreamResource.class, inputMessage); assertThat(actualResource, instanceOf(InputStreamResource.class)); assertThat(actualResource.getInputStream(), is(body)); assertEquals("yourlogo.jpg", actualResource.getFilename()); } }
@Test public void testSetAttributes() throws Exception { try { mBeanServer.setAttributes(objectName(countMetricName), new AttributeList(1)); fail("setAttributes should have failed"); } catch (Exception e) { assertThat(e.getCause(), instanceOf(UnsupportedOperationException.class)); } }
@Test public void shouldSupportFieldsWithQuotedStrings() { final String field = "my_string_field"; final Schema schema = schemaBuilder .field(field.toUpperCase(), Schema.OPTIONAL_STRING_SCHEMA) .build(); final TimestampExtractionPolicy extractionPolicy = TimestampExtractionPolicyFactory.create(schema, "'"+ field+ "'", "'yyyy-MM-DD'"); assertThat(extractionPolicy, instanceOf(StringTimestampExtractionPolicy.class)); assertThat(extractionPolicy.timestampField(), equalTo(field.toUpperCase())); }
@Test public void shouldFailToAddEntityWithInvalidEdgeSource() { // Given final Walk.Builder builder = new Walk.Builder().edge(EDGE_AB); // When try { builder.entity(ENTITY_A); fail("Expecting exception to be thrown when attempting to add an invalid entity."); } catch (final Exception e) { // Then assertThat(e, is(instanceOf(IllegalArgumentException.class))); assertThat(e.getMessage(), containsString("Entity must be added to correct vertex.")); } }
private void shouldNotAllowDatabasesToUseFilesetsConcurrently( Map<String,String> config ) { GraphDatabaseService db = newDb(); try { new TestGraphDatabaseFactory().newEmbeddedDatabaseBuilder( storeDir() ) .setConfig( config ).newGraphDatabase(); fail(); } catch ( RuntimeException e ) { assertThat( e.getCause().getCause(), instanceOf( StoreLockException.class ) ); } finally { db.shutdown(); } }
/** * 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> Matcher<T> isA(Class<?> type) { return is(IsInstanceOf.<T>instanceOf(type)); } }
@Test public void testCacheUnwrap() { MutableConfiguration<String, String> configuration = new MutableConfiguration<>(); configuration.setTypes(String.class, String.class); Cache<String, String> cache = cacheManager.createCache("cache", configuration); assertThat(cache.unwrap(org.ehcache.Cache.class), is(instanceOf(org.ehcache.Cache.class))); assertThat(cache.unwrap(cache.getClass()), is(instanceOf(Eh107Cache.class))); cacheManager.close(); }
@Test public void testInvoke() throws Exception { try { mBeanServer.invoke(objectName(countMetricName), "something", null, null); fail("invoke should have failed"); } catch (RuntimeMBeanException e) { assertThat(e.getCause(), instanceOf(UnsupportedOperationException.class)); } }
@Test public void shouldCreateLongTimestampPolicyWhenTimestampFieldIsOfTypeLong() { final String timestamp = "timestamp"; final Schema schema = schemaBuilder .field(timestamp.toUpperCase(), Schema.OPTIONAL_INT64_SCHEMA) .build(); final TimestampExtractionPolicy extractionPolicy = TimestampExtractionPolicyFactory.create(schema, timestamp, null); assertThat(extractionPolicy, instanceOf(LongColumnTimestampExtractionPolicy.class)); assertThat(extractionPolicy.timestampField(), equalTo(timestamp.toUpperCase())); }
@Test public void shouldFailToAddEntitiesWithInvalidEdgeSource() { // Given final Walk.Builder builder = new Walk.Builder().edge(EDGE_AB); // When try { builder.entities(ENTITY_A, ENTITY_A); fail("Expecting exception to be thrown when attempting to add an invalid entity."); } catch (final Exception e) { // Then assertThat(e, is(instanceOf(IllegalArgumentException.class))); assertThat(e.getMessage(), containsString("Entity must be added to correct vertex.")); } }
/** * 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> * */ @Factory public static <T> Matcher<T> isA(Class<T> type) { final Matcher<T> typeMatcher = instanceOf(type); return is(typeMatcher); } }
@Test public void testPersistenceConfig() throws Exception { final URL resource = XmlConfigurationTest.class.getResource("/configs/persistence-config.xml"); XmlConfiguration xmlConfig = new XmlConfiguration(new XmlConfiguration(resource)); ServiceCreationConfiguration<?> serviceConfig = xmlConfig.getServiceCreationConfigurations().iterator().next(); assertThat(serviceConfig, instanceOf(DefaultPersistenceConfiguration.class)); DefaultPersistenceConfiguration persistenceConfiguration = (DefaultPersistenceConfiguration)serviceConfig; assertThat(persistenceConfiguration.getRootDirectory(), is(new File(" \n\t/my/caching/persistence directory\r\n "))); }
@Test public void shouldParseSimpleComment() { final String statementString = "--this is a comment.\n" + "SHOW STREAMS;"; final List<PreparedStatement<?>> statements = KSQL_PARSER.buildAst(statementString, metaStore); assertThat(statements, hasSize(1)); assertThat(statements.get(0).getStatement(), is(instanceOf(ListStreams.class))); }
@Test public void shouldCreateStringTimestampPolicyWhenTimestampFieldIsStringTypeAndFormatProvided() { final String field = "my_string_field"; final Schema schema = schemaBuilder .field(field.toUpperCase(), Schema.OPTIONAL_STRING_SCHEMA) .build(); final TimestampExtractionPolicy extractionPolicy = TimestampExtractionPolicyFactory.create(schema, field, "yyyy-MM-DD"); assertThat(extractionPolicy, instanceOf(StringTimestampExtractionPolicy.class)); assertThat(extractionPolicy.timestampField(), equalTo(field.toUpperCase())); }