本文整理汇总了Java中org.hamcrest.core.IsSame类的典型用法代码示例。如果您正苦于以下问题:Java IsSame类的具体用法?Java IsSame怎么用?Java IsSame使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IsSame类属于org.hamcrest.core包,在下文中一共展示了IsSame类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: shiftingInstanceSerialization
import org.hamcrest.core.IsSame; //导入依赖的package包/类
@Test
public void shiftingInstanceSerialization() throws Exception {
Portability<Serializable> p = new SerializablePortability();
System.out.println(Arrays.toString(Foo_W.class.getDeclaredClasses()));
System.out.println(Foo_W.c.getClass().getEnclosingClass());
ClassLoader wLoader = createClassNameRewritingLoader(Foo_W.class);
ClassLoader rLoader = createClassNameRewritingLoader(Foo_R.class);
Class<?> wClass = wLoader.loadClass(newClassName(Foo_W.class));
Class<?> rClass = rLoader.loadClass(newClassName(Foo_R.class));
Object[] wInstances = wClass.getEnumConstants();
Object[] rInstances = rClass.getEnumConstants();
pushTccl(rLoader);
try {
for (int i = 0; i < wInstances.length; i++) {
Assert.assertThat(p.decode(p.encode((Serializable) wInstances[i])), IsSame.sameInstance(rInstances[i]));
}
} finally {
popTccl();
}
}
示例2: shiftingInstanceSerialization
import org.hamcrest.core.IsSame; //导入依赖的package包/类
@Test
public void shiftingInstanceSerialization() throws ClassNotFoundException {
@SuppressWarnings("unchecked")
StatefulSerializer<Serializable> s = new CompactJavaSerializer(null);
s.init(new TransientStateRepository());
ClassLoader wLoader = createClassNameRewritingLoader(Foo_W.class);
ClassLoader rLoader = createClassNameRewritingLoader(Foo_R.class);
Class<?> wClass = wLoader.loadClass(newClassName(Foo_W.class));
Class<?> rClass = rLoader.loadClass(newClassName(Foo_R.class));
Object[] wInstances = wClass.getEnumConstants();
Object[] rInstances = rClass.getEnumConstants();
pushTccl(rLoader);
try {
for (int i = 0; i < wInstances.length; i++) {
Assert.assertThat(s.read(s.serialize((Serializable) wInstances[i])), IsSame.sameInstance(rInstances[i]));
}
} finally {
popTccl();
}
}
示例3: testSupportsMultipleAuthoritativeTierProviders
import org.hamcrest.core.IsSame; //导入依赖的package包/类
@Test
public void testSupportsMultipleAuthoritativeTierProviders() throws Exception {
ServiceLocator.DependencySet dependencySet = dependencySet();
OnHeapStore.Provider cachingTierProvider = new OnHeapStore.Provider();
OffHeapStore.Provider authoritativeTierProvider = new OffHeapStore.Provider();
OffHeapDiskStore.Provider diskStoreProvider = new OffHeapDiskStore.Provider();
dependencySet.with(cachingTierProvider);
dependencySet.with(authoritativeTierProvider);
dependencySet.with(diskStoreProvider);
dependencySet.with(mock(DiskResourceService.class));
ServiceLocator serviceLocator = dependencySet.build();
serviceLocator.startAllServices();
assertThat(serviceLocator.getServicesOfType(CachingTier.Provider.class),
IsCollectionContaining.<CachingTier.Provider>hasItem(IsSame.<CachingTier.Provider>sameInstance(cachingTierProvider)));
assertThat(serviceLocator.getServicesOfType(AuthoritativeTier.Provider.class),
IsCollectionContaining.<AuthoritativeTier.Provider>hasItem(IsSame.<AuthoritativeTier.Provider>sameInstance(authoritativeTierProvider)));
assertThat(serviceLocator.getServicesOfType(OffHeapDiskStore.Provider.class),
IsCollectionContaining.<OffHeapDiskStore.Provider>hasItem(IsSame.<OffHeapDiskStore.Provider>sameInstance(diskStoreProvider)));
}
示例4: delegatesFindByNamePrefixToRepository
import org.hamcrest.core.IsSame; //导入依赖的package包/类
@Test
public void delegatesFindByNamePrefixToRepository() {
final List<AbTestConfiguration> abTestConfigurations = newArrayList(configuration);
when(repository.findByNameStartsWith(eq(NAME), any(PageRequest.class))).thenReturn(abTestConfigurations);
assertThat(service.findByNamePrefix(NAME), IsSame.sameInstance(abTestConfigurations));
verify(repository).findByNameStartsWith(eq(NAME), any(PageRequest.class));
}
示例5: testPrimitiveClasses
import org.hamcrest.core.IsSame; //导入依赖的package包/类
@Test
public void testPrimitiveClasses() {
Portability<Serializable> p = new SerializablePortability();
Class[] out = (Class[]) p.decode(p.encode(PRIMITIVE_CLASSES));
Assert.assertThat(out, IsNot.not(IsSame.sameInstance(PRIMITIVE_CLASSES)));
Assert.assertThat(out, IsEqual.equalTo(PRIMITIVE_CLASSES));
}
示例6: basicInstanceSerialization
import org.hamcrest.core.IsSame; //导入依赖的package包/类
@Test
public void basicInstanceSerialization() {
Portability<Serializable> p = new SerializablePortability();
Assert.assertThat(p.decode(p.encode(People.Alice)), IsSame.sameInstance(People.Alice));
Assert.assertThat(p.decode(p.encode(People.Bob)), IsSame.sameInstance(People.Bob));
Assert.assertThat(p.decode(p.encode(People.Eve)), IsSame.sameInstance(People.Eve));
}
示例7: classSerialization
import org.hamcrest.core.IsSame; //导入依赖的package包/类
@Test
public void classSerialization() {
Portability<Serializable> p = new SerializablePortability();
Assert.assertThat(p.decode(p.encode(Enum.class)), IsSame.sameInstance(Enum.class));
Assert.assertThat(p.decode(p.encode(Dogs.Handel.getClass())), IsSame.sameInstance(Dogs.Handel.getClass()));
Assert.assertThat(p.decode(p.encode(Dogs.Cassie.getClass())), IsSame.sameInstance(Dogs.Cassie.getClass()));
Assert.assertThat(p.decode(p.encode(Dogs.Penny.getClass())), IsSame.sameInstance(Dogs.Penny.getClass()));
}
示例8: shouldReturnProxyTarget
import org.hamcrest.core.IsSame; //导入依赖的package包/类
@Test
public void shouldReturnProxyTarget() {
Object bean = new Object();
TestProxy proxy = new TestProxy(bean);
Object target = MotechProxyUtils.getTargetIfProxied(proxy);
assertThat(target, IsSame.sameInstance(bean));
}
示例9: testCopyingOfExistingConfiguration
import org.hamcrest.core.IsSame; //导入依赖的package包/类
@Test
public void testCopyingOfExistingConfiguration() {
Class<Integer> keyClass = Integer.class;
Class<String> valueClass = String.class;
ClassLoader loader = mock(ClassLoader.class);
@SuppressWarnings("unchecked")
EvictionAdvisor<Integer, String> eviction = mock(EvictionAdvisor.class);
@SuppressWarnings("unchecked")
ExpiryPolicy<Integer, String> expiry = mock(ExpiryPolicy.class);
ServiceConfiguration<?> service = mock(ServiceConfiguration.class);
CacheConfiguration<Integer, String> configuration = CacheConfigurationBuilder.newCacheConfigurationBuilder(Integer.class, String.class, heap(10))
.withClassLoader(loader)
.withEvictionAdvisor(eviction)
.withExpiry(expiry)
.add(service)
.build();
CacheConfiguration<Integer, String> copy = CacheConfigurationBuilder.newCacheConfigurationBuilder(configuration).build();
assertThat(copy.getKeyType(), equalTo(keyClass));
assertThat(copy.getValueType(), equalTo(valueClass));
assertThat(copy.getClassLoader(), equalTo(loader));
assertThat(copy.getEvictionAdvisor(), IsSame.<EvictionAdvisor<?, ?>>sameInstance(eviction));
assertThat(copy.getExpiryPolicy(), IsSame.<ExpiryPolicy<?, ?>>sameInstance(expiry));
assertThat(copy.getServiceConfigurations(), contains(IsSame.<ServiceConfiguration<?>>sameInstance(service)));
}
示例10: testPrimitiveClasses
import org.hamcrest.core.IsSame; //导入依赖的package包/类
@Test
public void testPrimitiveClasses() throws ClassNotFoundException {
@SuppressWarnings("unchecked")
StatefulSerializer<Serializable> s = new CompactJavaSerializer(null);
s.init(new TransientStateRepository());
Class[] out = (Class[]) s.read(s.serialize(PRIMITIVE_CLASSES));
Assert.assertThat(out, IsNot.not(IsSame.sameInstance(PRIMITIVE_CLASSES)));
Assert.assertThat(out, IsEqual.equalTo(PRIMITIVE_CLASSES));
}
示例11: basicInstanceSerialization
import org.hamcrest.core.IsSame; //导入依赖的package包/类
@Test
public void basicInstanceSerialization() throws ClassNotFoundException {
@SuppressWarnings("unchecked")
StatefulSerializer<Serializable> s = new CompactJavaSerializer(null);
s.init(new TransientStateRepository());
Assert.assertThat(s.read(s.serialize(People.Alice)), IsSame.<Serializable>sameInstance(People.Alice));
Assert.assertThat(s.read(s.serialize(People.Bob)), IsSame.<Serializable>sameInstance(People.Bob));
Assert.assertThat(s.read(s.serialize(People.Eve)), IsSame.<Serializable>sameInstance(People.Eve));
}
示例12: classSerialization
import org.hamcrest.core.IsSame; //导入依赖的package包/类
@Test
public void classSerialization() throws ClassNotFoundException {
@SuppressWarnings("unchecked")
StatefulSerializer<Serializable> s = new CompactJavaSerializer(null);
s.init(new TransientStateRepository());
Assert.assertThat(s.read(s.serialize(Enum.class)), IsSame.<Serializable>sameInstance(Enum.class));
Assert.assertThat(s.read(s.serialize(Dogs.Handel.getClass())), IsSame.<Serializable>sameInstance(Dogs.Handel.getClass()));
Assert.assertThat(s.read(s.serialize(Dogs.Cassie.getClass())), IsSame.<Serializable>sameInstance(Dogs.Cassie.getClass()));
Assert.assertThat(s.read(s.serialize(Dogs.Penny.getClass())), IsSame.<Serializable>sameInstance(Dogs.Penny.getClass()));
}
示例13: testSameInstance
import org.hamcrest.core.IsSame; //导入依赖的package包/类
@Test
public void testSameInstance() throws InterruptedException {
ServerManager server = kurentoClient.getServerManager();
ServerManager server2 = kurentoClient.getServerManager();
assertThat(server, IsSame.sameInstance(server2));
}
示例14: hamcrest_core_isSame_string
import org.hamcrest.core.IsSame; //导入依赖的package包/类
@Test
public void hamcrest_core_isSame_string () {
String wiBrewery = "Capital Brewery";
String wiRegionalBrewery = "Capital Brewery";
assertThat(wiRegionalBrewery, IsSame.<String>sameInstance(wiBrewery));
}
示例15: testPasswordChange
import org.hamcrest.core.IsSame; //导入依赖的package包/类
@Test
public void testPasswordChange() {
final User user = new User();
user.setFullname("Bill Joy");
when(userManagementService.get("abc")).thenReturn(user);
final ModelAndView mav = sut.passwordChange("abc");
assertThat(mav.getModel().get("user"), IsSame.sameInstance(user));
}