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


Java SerializableTester.reserialize方法代码示例

本文整理汇总了Java中com.google.common.testing.SerializableTester.reserialize方法的典型用法代码示例。如果您正苦于以下问题:Java SerializableTester.reserialize方法的具体用法?Java SerializableTester.reserialize怎么用?Java SerializableTester.reserialize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.common.testing.SerializableTester的用法示例。


在下文中一共展示了SerializableTester.reserialize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testSerializable

import com.google.common.testing.SerializableTester; //导入方法依赖的package包/类
public <A extends Iterable<? extends String>, B extends A> void testSerializable() {
  reserialize(TypeToken.of(String.class));
  reserialize(TypeToken.of(String.class).getTypes());
  reserialize(TypeToken.of(String.class).getTypes().classes());
  reserialize(TypeToken.of(String.class).getTypes().interfaces());
  reserialize(TypeToken.of(String.class).getTypes().rawTypes());
  reserialize(TypeToken.of(String.class).getTypes().classes().rawTypes());
  reserialize(TypeToken.of(String.class).getTypes().interfaces().rawTypes());
  reserialize(new TypeToken<int[]>() {});
  reserialize(new TypeToken<Map<String, Integer>>() {});
  reserialize(new IKnowMyType<Map<? super String, ? extends int[]>>() {}.type());
  reserialize(TypeToken.of(new TypeCapture<B>() {}.capture()).getTypes().rawTypes());
  try {
    SerializableTester.reserialize(TypeToken.of(new TypeCapture<B>() {}.capture()));
    fail();
  } catch (RuntimeException expected) {}
}
 
开发者ID:paul-hammant,项目名称:googles-monorepo-demo,代码行数:18,代码来源:TypeTokenTest.java

示例2: testSerialization

import com.google.common.testing.SerializableTester; //导入方法依赖的package包/类
@GwtIncompatible // SerializableTester
public void testSerialization() {
  Multimap<String, Integer> multimap = createMultimap();
  SerializableTester.reserializeAndAssert(multimap);
  assertEquals(multimap.size(),
      SerializableTester.reserialize(multimap).size());
  SerializableTester.reserializeAndAssert(multimap.get("foo"));
  LenientSerializableTester.reserializeAndAssertLenient(multimap.keySet());
  LenientSerializableTester.reserializeAndAssertLenient(multimap.keys());
  SerializableTester.reserializeAndAssert(multimap.asMap());
  Collection<Integer> valuesCopy
      = SerializableTester.reserialize(multimap.values());
  assertEquals(HashMultiset.create(multimap.values()),
      HashMultiset.create(valuesCopy));
}
 
开发者ID:paul-hammant,项目名称:googles-monorepo-demo,代码行数:16,代码来源:ImmutableListMultimapTest.java

示例3: testSerialization

import com.google.common.testing.SerializableTester; //导入方法依赖的package包/类
public void testSerialization() {
  EvictingQueue<String> original = EvictingQueue.create(5);
  original.add("one");
  original.add("two");
  original.add("three");

  EvictingQueue<String> copy = SerializableTester.reserialize(original);
  assertEquals(copy.maxSize, original.maxSize);
  assertEquals("one", copy.remove());
  assertEquals("two", copy.remove());
  assertEquals("three", copy.remove());
  assertTrue(copy.isEmpty());
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:14,代码来源:EvictingQueueTest.java

示例4: serializable

import com.google.common.testing.SerializableTester; //导入方法依赖的package包/类
@Test
public void serializable() {
    ActorCreationRequest expected = makeRequest();
    ActorCreationRequest actual = SerializableTester.reserialize(expected);

    assertThat(expected.getActorConfig(), is(actual.getActorConfig()));
}
 
开发者ID:florentw,项目名称:bench,代码行数:8,代码来源:ActorCreationRequestTest.java

示例5: testSerializationContainingSelf

import com.google.common.testing.SerializableTester; //导入方法依赖的package包/类
@GwtIncompatible // SerializableTester
public void testSerializationContainingSelf() {
  Multiset<Multiset<?>> multiset = HashMultiset.create();
  multiset.add(multiset, 2);
  Multiset<Multiset<?>> copy = SerializableTester.reserialize(multiset);
  assertEquals(2, copy.size());
  assertSame(copy, copy.iterator().next());
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:9,代码来源:HashMultisetTest.java

示例6: reserialize

import com.google.common.testing.SerializableTester; //导入方法依赖的package包/类
@CanIgnoreReturnValue
private static <T> T reserialize(T object) {
  T copy = SerializableTester.reserialize(object);
  new EqualsTester()
      .addEqualityGroup(object, copy)
      .testEquals();
  return copy;
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:9,代码来源:TypeTokenTest.java

示例7: serializable

import com.google.common.testing.SerializableTester; //导入方法依赖的package包/类
@Test
public void serializable() {
    AgentKey expected = AGENT_KEY;
    AgentKey actual = SerializableTester.reserialize(expected);
    assertThat(expected.getName(), is(actual.getName()));
    assertThat(expected, is(actual));
}
 
开发者ID:florentw,项目名称:bench,代码行数:8,代码来源:AgentKeyTest.java

示例8: serializable

import com.google.common.testing.SerializableTester; //导入方法依赖的package包/类
@Test
public void serializable() {
    JgroupsStateKey expected = makeKey();
    JgroupsStateKey actual = SerializableTester.reserialize(expected);

    assertThat(expected, is(actual));
}
 
开发者ID:florentw,项目名称:bench,代码行数:8,代码来源:JgroupsStateKeyTest.java

示例9: serialize_deserialize

import com.google.common.testing.SerializableTester; //导入方法依赖的package包/类
@Test
public void serialize_deserialize() {
    AgentRegistrationMessage received = SerializableTester.reserialize(msg);

    assertThat(received.getCreationTime(), is(msg.getCreationTime()));
    assertThat(received.getKey(), is(msg.getKey()));
    assertThat(received.getEndpoint(), is(msg.getEndpoint()));
    assertNotNull(received.getSystemConfig());
}
 
开发者ID:florentw,项目名称:bench,代码行数:10,代码来源:AgentRegistrationMessageTest.java

示例10: serializable

import com.google.common.testing.SerializableTester; //导入方法依赖的package包/类
@Test
public void serializable() {
    MetricValuesMessage expected = metricValues(3);
    MetricValuesMessage actual = SerializableTester.reserialize(expected);

    assertThat(actual.metrics().size(), is(expected.metrics().size()));
}
 
开发者ID:florentw,项目名称:bench,代码行数:8,代码来源:MetricValuesMessageTest.java

示例11: go

import com.google.common.testing.SerializableTester; //导入方法依赖的package包/类
void go() {
  SerializableTester.reserialize(TypeToken.of(new TypeCapture<T>() {}.capture()));
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:4,代码来源:TypeTokenTest.java

示例12: testEmpty_serialization

import com.google.common.testing.SerializableTester; //导入方法依赖的package包/类
@GwtIncompatible // SerializableTester
public void testEmpty_serialization() {
  SortedSet<String> set = of();
  SortedSet<String> copy = SerializableTester.reserialize(set);
  assertSame(set, copy);
}
 
开发者ID:paul-hammant,项目名称:googles-monorepo-demo,代码行数:7,代码来源:ImmutableSortedSetTest.java

示例13: create

import com.google.common.testing.SerializableTester; //导入方法依赖的package包/类
@Override
public Multiset<E> create(Object... elements) {
  return (Multiset<E>) SerializableTester.reserialize(gen.create(elements));
}
 
开发者ID:paul-hammant,项目名称:googles-monorepo-demo,代码行数:5,代码来源:MultisetTestSuiteBuilder.java

示例14: testSerializationProxyLoading

import com.google.common.testing.SerializableTester; //导入方法依赖的package包/类
public void testSerializationProxyLoading() {
  CacheLoader<Object, Object> loader = new SerializableCacheLoader();
  RemovalListener<Object, Object> listener = new SerializableRemovalListener<Object, Object>();
  SerializableWeigher<Object, Object> weigher = new SerializableWeigher<Object, Object>();
  Ticker ticker = new SerializableTicker();
  @SuppressWarnings("unchecked") // createMock
  LocalLoadingCache<Object, Object> one = (LocalLoadingCache) CacheBuilder.newBuilder()
      .weakKeys()
      .softValues()
      .expireAfterAccess(123, SECONDS)
      .expireAfterWrite(456, MINUTES)
      .maximumWeight(789)
      .weigher(weigher)
      .concurrencyLevel(12)
      .removalListener(listener)
      .ticker(ticker)
      .build(loader);
  // add a non-serializable entry
  one.getUnchecked(new Object());
  assertEquals(1, one.size());
  assertFalse(one.asMap().isEmpty());
  LocalLoadingCache<Object, Object> two = SerializableTester.reserialize(one);
  assertEquals(0, two.size());
  assertTrue(two.asMap().isEmpty());

  LocalCache<Object, Object> localCacheOne = one.localCache;
  LocalCache<Object, Object> localCacheTwo = two.localCache;

  assertEquals(localCacheOne.keyStrength, localCacheTwo.keyStrength);
  assertEquals(localCacheOne.keyStrength, localCacheTwo.keyStrength);
  assertEquals(localCacheOne.valueEquivalence, localCacheTwo.valueEquivalence);
  assertEquals(localCacheOne.valueEquivalence, localCacheTwo.valueEquivalence);
  assertEquals(localCacheOne.maxWeight, localCacheTwo.maxWeight);
  assertEquals(localCacheOne.weigher, localCacheTwo.weigher);
  assertEquals(localCacheOne.expireAfterAccessNanos, localCacheTwo.expireAfterAccessNanos);
  assertEquals(localCacheOne.expireAfterWriteNanos, localCacheTwo.expireAfterWriteNanos);
  assertEquals(localCacheOne.refreshNanos, localCacheTwo.refreshNanos);
  assertEquals(localCacheOne.removalListener, localCacheTwo.removalListener);
  assertEquals(localCacheOne.ticker, localCacheTwo.ticker);

  // serialize the reconstituted version to be sure we haven't lost the ability to reserialize
  LocalLoadingCache<Object, Object> three = SerializableTester.reserialize(two);
  LocalCache<Object, Object> localCacheThree = three.localCache;

  assertEquals(localCacheTwo.defaultLoader, localCacheThree.defaultLoader);
  assertEquals(localCacheTwo.keyStrength, localCacheThree.keyStrength);
  assertEquals(localCacheTwo.keyStrength, localCacheThree.keyStrength);
  assertEquals(localCacheTwo.valueEquivalence, localCacheThree.valueEquivalence);
  assertEquals(localCacheTwo.valueEquivalence, localCacheThree.valueEquivalence);
  assertEquals(localCacheTwo.maxWeight, localCacheThree.maxWeight);
  assertEquals(localCacheTwo.weigher, localCacheThree.weigher);
  assertEquals(localCacheTwo.expireAfterAccessNanos, localCacheThree.expireAfterAccessNanos);
  assertEquals(localCacheTwo.expireAfterWriteNanos, localCacheThree.expireAfterWriteNanos);
  assertEquals(localCacheTwo.removalListener, localCacheThree.removalListener);
  assertEquals(localCacheTwo.ticker, localCacheThree.ticker);
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:57,代码来源:LocalCacheTest.java

示例15: create

import com.google.common.testing.SerializableTester; //导入方法依赖的package包/类
@Override
public Set<E> create(Object... elements) {
  return (Set<E>) SerializableTester.reserialize(gen.create(elements));
}
 
开发者ID:paul-hammant,项目名称:googles-monorepo-demo,代码行数:5,代码来源:SetTestSuiteBuilder.java


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