当前位置: 首页>>代码示例>>Java>>正文


Java IsSame类代码示例

本文整理汇总了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();
  }
}
 
开发者ID:Terracotta-OSS,项目名称:offheap-store,代码行数:26,代码来源:EnumTest.java

示例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();
  }
}
 
开发者ID:ehcache,项目名称:ehcache3,代码行数:25,代码来源:EnumTest.java

示例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)));
}
 
开发者ID:ehcache,项目名称:ehcache3,代码行数:25,代码来源:ServiceProviderTest.java

示例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));
}
 
开发者ID:ImmobilienScout24,项目名称:switchman,代码行数:8,代码来源:AbTestConfigurationServiceTest.java

示例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));
}
 
开发者ID:Terracotta-OSS,项目名称:offheap-store,代码行数:10,代码来源:BasicSerializationTest.java

示例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));
}
 
开发者ID:Terracotta-OSS,项目名称:offheap-store,代码行数:9,代码来源:EnumTest.java

示例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()));
}
 
开发者ID:Terracotta-OSS,项目名称:offheap-store,代码行数:10,代码来源:EnumTest.java

示例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));
}
 
开发者ID:motech,项目名称:motech,代码行数:8,代码来源:MotechProxyUtilsTest.java

示例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)));
}
 
开发者ID:ehcache,项目名称:ehcache3,代码行数:29,代码来源:CacheConfigurationBuilderTest.java

示例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));
}
 
开发者ID:ehcache,项目名称:ehcache3,代码行数:12,代码来源:BasicSerializationTest.java

示例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));
}
 
开发者ID:ehcache,项目名称:ehcache3,代码行数:11,代码来源:EnumTest.java

示例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()));
}
 
开发者ID:ehcache,项目名称:ehcache3,代码行数:12,代码来源:EnumTest.java

示例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));
}
 
开发者ID:Kurento,项目名称:kurento-java,代码行数:9,代码来源:ServerManagerTest.java

示例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));
}
 
开发者ID:wq19880601,项目名称:java-util-examples,代码行数:9,代码来源:CoreMatchers.java

示例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));
}
 
开发者ID:ttwd80,项目名称:qir,代码行数:9,代码来源:UserManagementControllerTest.java


注:本文中的org.hamcrest.core.IsSame类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。