private static void verifyResponseOkWithEntity(InstanceInfo original, EurekaHttpResponse<InstanceInfo> httpResponse) { assertThat(httpResponse.getStatusCode(), is(equalTo(200))); assertThat(httpResponse.getEntity(), is(notNullValue())); assertThat(EurekaEntityComparators.equal(httpResponse.getEntity(), original), is(true)); }
@Test public void shouldSupportClassHavingNonVoidReturningIndexedSetter() throws IntrospectionException { @SuppressWarnings("unused") class C { public C setFoo(int i, String s) { return this; } } assertThat(factory.getBeanInfo(C.class), notNullValue()); }
@Test public void shouldInvokeAwareMethodsInImportBeanDefinitionRegistrar() { AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(Config.class); context.getBean(MessageSource.class); assertThat(SampleRegistrar.beanFactory, is(context.getBeanFactory())); assertThat(SampleRegistrar.classLoader, is(context.getBeanFactory().getBeanClassLoader())); assertThat(SampleRegistrar.resourceLoader, is(notNullValue())); assertThat(SampleRegistrar.environment, is(context.getEnvironment())); }
@Test public void testCreateCloudDataStore() { given(mockUserCache.isExpired()).willReturn(true); given(mockUserCache.isCached(FAKE_USER_ID)).willReturn(false); UserDataStore userDataStore = userDataStoreFactory.create(FAKE_USER_ID); assertThat(userDataStore, is(notNullValue())); assertThat(userDataStore, is(instanceOf(CloudUserDataStore.class))); verify(mockUserCache).isExpired(); } }
@Test public void serializerSnapshotIsSuccessfullyRead() { TypeSerializerSnapshot<ElementT> snapshot = snapshotUnderTest(); assertThat(snapshot, allOf( notNullValue(), instanceOf(TypeSerializerSnapshot.class) )); }
public void testContainsUserDetailsFragment() { Fragment userDetailsFragment = userDetailsActivity.getFragmentManager().findFragmentById(R.id.fragmentContainer); assertThat(userDetailsFragment, is(notNullValue())); }
@Test public void streamIsEmptyForEmptyValues() { MutablePropertyValues pvs = new MutablePropertyValues(); assertThat(pvs.stream(), notNullValue()); assertThat(pvs.stream().count(), is(0L)); }
@Test public void shouldSupportClassHavingNonVoidReturningSetter() throws IntrospectionException { @SuppressWarnings("unused") class C { public C setFoo(String s) { return this; } } assertThat(factory.getBeanInfo(C.class), notNullValue()); }
@Test public void testCreateDiskDataStore() { given(mockUserCache.isCached(FAKE_USER_ID)).willReturn(true); given(mockUserCache.isExpired()).willReturn(false); UserDataStore userDataStore = userDataStoreFactory.create(FAKE_USER_ID); assertThat(userDataStore, is(notNullValue())); assertThat(userDataStore, is(instanceOf(DiskUserDataStore.class))); verify(mockUserCache).isCached(FAKE_USER_ID); verify(mockUserCache).isExpired(); }
@SuppressWarnings("deprecation") @Test public void movingForward() throws IOException { TypeSerializerSnapshot<ElementT> previousSnapshot = snapshotUnderTest(); TypeSerializer<ElementT> restoredSerializer = previousSnapshot.restoreSerializer(); TypeSerializerSnapshot<ElementT> nextSnapshot = restoredSerializer.snapshotConfiguration(); assertThat(nextSnapshot, instanceOf(testSpecification.snapshotClass)); TypeSerializerSnapshot<ElementT> nextSnapshotDeserialized = writeAndThenReadTheSnapshot(restoredSerializer, nextSnapshot); assertThat(nextSnapshotDeserialized, allOf( notNullValue(), not(instanceOf(TypeSerializerConfigSnapshot.class)) )); }
private static void verifyResponseOkWithEntity(Applications original, EurekaHttpResponse<Applications> httpResponse) { assertThat(httpResponse.getStatusCode(), is(equalTo(200))); assertThat(httpResponse.getEntity(), is(notNullValue())); assertThat(EurekaEntityComparators.equal(httpResponse.getEntity(), original), is(true)); }
public void testContainsUserListFragment() { Fragment userListFragment = userListActivity.getFragmentManager().findFragmentById(R.id.fragmentContainer); assertThat(userListFragment, is(notNullValue())); }
@Test public void streamIsEmptyForEmptySources() { MutablePropertySources sources = new MutablePropertySources(); assertThat(sources.stream(), notNullValue()); assertThat(sources.stream().count(), is(0L)); }
@Test public void autowiringSucceedsWithBFPPAsStaticMethod() { AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(); ctx.register(TestBeanConfig.class, AutowiredConfigWithBFPPAsStaticMethod.class); ctx.refresh(); // static method BFPP does not interfere with lifecycle -> autowiring succeeds assertThat(ctx.getBean(AutowiredConfigWithBFPPAsStaticMethod.class).autowiredTestBean, notNullValue()); }
@Test public void testPositionalParameters() { TransactionUtil2.inTransaction( sessionFactory(), session -> { Query query = session.createQuery( "select i from Item i where name = ?1 or name = ?2" ); for ( Parameter<?> parameter : query.getParameters() ) { assertThat( parameter.getPosition(), notNullValue() ); assertThat( parameter.getPosition(), either( is(1) ).or( is(2) ) ); } } ); } }
@Test public void javaDeserializeFromFlink_1_5_ReflectiveRecord() throws IOException { final String avroSerializerBase64 = "AAAAAQAAAQis7QAFc3IANm9yZy5hcGFjaGUuZmxpbmsuZm9ybWF0cy5hdnJvLnR5cGV1dGlscy5BdnJv\n" + "U2VyaWFsaXplcgAAAAAAAAABAgABTAAEdHlwZXQAEUxqYXZhL2xhbmcvQ2xhc3M7eHIANG9yZy5hcGFj\n" + "aGUuZmxpbmsuYXBpLmNvbW1vbi50eXBldXRpbHMuVHlwZVNlcmlhbGl6ZXIAAAAAAAAAAQIAAHhwdnIA\n" + "Tm9yZy5hcGFjaGUuZmxpbmsuZm9ybWF0cy5hdnJvLnR5cGV1dGlscy5BdnJvU2VyaWFsaXplck1pZ3Jh\n" + "dGlvblRlc3QkU2ltcGxlUG9qbwAAAAAAAAAAAAAAeHA="; TypeSerializer<?> serializer = javaDeserialize(avroSerializerBase64); assertThat(serializer, instanceOf(AvroSerializer.class)); AvroSerializer<?> avroSerializer = (AvroSerializer<?>) javaDeserialize(avroSerializerBase64); assertSame(avroSerializer.getType(), SimplePojo.class); assertThat(avroSerializer.getAvroSchema(), notNullValue()); }
private void assertBeanPropertyValueOf(String propertyName, String expected, DefaultListableBeanFactory factory) { BeanDefinition bean = factory.getBeanDefinition(expected); PropertyValue value = bean.getPropertyValues().getPropertyValue(propertyName); assertThat(value, is(notNullValue())); assertThat(value.getValue().toString(), is(expected)); }
@Test public void proxyingWorksIfInfoReturnsNullEntityManagerInterface() { EntityManagerFactory emf = mock(EntityManagerFactory.class, withSettings().extraInterfaces(EntityManagerFactoryInfo.class)); // EntityManagerFactoryInfo.getEntityManagerInterface returns null assertThat(SharedEntityManagerCreator.createSharedEntityManager(emf), is(notNullValue())); }
@Test public void testSignificantLoad() throws Exception { Assume.group(TestGroup.LONG_RUNNING); // the biggest public class in the JDK (>60k) URL url = getClass().getResource("/java/awt/Component.class"); assertThat(url, notNullValue()); // look at a LOT of items for (int i = 0; i < ITEMS_TO_LOAD; i++) { Resource resource = new UrlResource(url) { @Override public boolean equals(Object obj) { return (obj == this); } @Override public int hashCode() { return System.identityHashCode(this); } }; MetadataReader reader = mrf.getMetadataReader(resource); assertThat(reader, notNullValue()); } // useful for profiling to take snapshots // System.in.read(); }
@Test public void testWordCountText8() { String fName = "bigdata/laptop/text8.gz"; assumeThat("text8 data available", locateFile(fName), is(notNullValue())); // only run if text8 is present Frame fr = parse_test_file(fName, "NA", 0, new byte[]{Vec.T_STR}); try { Map<BufferedString, IcedLong> counts = new WordCountTask().doAll(fr.vec(0))._counts; assertEquals(253854, counts.size()); assertEquals(303L, counts.get(new BufferedString("anarchism"))._val); assertEquals(316376L, counts.get(new BufferedString("to"))._val); assertNotNull(counts); } finally { fr.remove(); } }