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


Java SerializableTester类代码示例

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


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

示例1: testCascadingSerialization

import com.google.common.testing.SerializableTester; //导入依赖的package包/类
@SuppressWarnings("unchecked") // varargs
@GwtIncompatible // SerializbleTester
public void testCascadingSerialization() throws Exception {
  // Eclipse says Predicate<Integer>; javac says Predicate<Object>.
  Predicate<? super Integer> nasty = Predicates.not(Predicates.and(
      Predicates.or(
          Predicates.equalTo((Object) 1), Predicates.equalTo(null),
          Predicates.alwaysFalse(), Predicates.alwaysTrue(),
          Predicates.isNull(), Predicates.notNull(),
          Predicates.in(Arrays.asList(1)))));
  assertEvalsToFalse(nasty);

  Predicate<? super Integer> stillNasty =
      SerializableTester.reserializeAndAssert(nasty);

  assertEvalsToFalse(stillNasty);
}
 
开发者ID:paul-hammant,项目名称:googles-monorepo-demo,代码行数:18,代码来源:PredicatesTest.java

示例2: testTreeMultimapNonGeneric

import com.google.common.testing.SerializableTester; //导入依赖的package包/类
@GwtIncompatible // SerializableTester
public void testTreeMultimapNonGeneric() {
  TreeMultimap<LegacyComparable, LegacyComparable> multimap
      = TreeMultimap.create();
  assertEquals(ImmutableMultimap.of(), multimap);
  multimap.put(new LegacyComparable("foo"), new LegacyComparable("f"));
  multimap.put(new LegacyComparable("foo"), new LegacyComparable("o"));
  multimap.put(new LegacyComparable("foo"), new LegacyComparable("o"));
  multimap.put(new LegacyComparable("bar"), new LegacyComparable("b"));
  multimap.put(new LegacyComparable("bar"), new LegacyComparable("a"));
  multimap.put(new LegacyComparable("bar"), new LegacyComparable("r"));
  assertThat(multimap.keySet()).containsExactly(
      new LegacyComparable("bar"), new LegacyComparable("foo")).inOrder();
  assertThat(multimap.values()).containsExactly(
      new LegacyComparable("a"),
      new LegacyComparable("b"),
      new LegacyComparable("r"),
      new LegacyComparable("f"),
      new LegacyComparable("o")).inOrder();
  assertEquals(Ordering.natural(), multimap.keyComparator());
  assertEquals(Ordering.natural(), multimap.valueComparator());
  SerializableTester.reserializeAndAssert(multimap);
}
 
开发者ID:paul-hammant,项目名称:googles-monorepo-demo,代码行数:24,代码来源:TreeMultimapNaturalTest.java

示例3: testLexicographicalComparator

import com.google.common.testing.SerializableTester; //导入依赖的package包/类
public void testLexicographicalComparator() {
  List<byte[]> ordered = Arrays.asList(
      new byte[] {},
      new byte[] {LEAST},
      new byte[] {LEAST, LEAST},
      new byte[] {LEAST, (byte) 1},
      new byte[] {(byte) 1},
      new byte[] {(byte) 1, LEAST},
      new byte[] {GREATEST, GREATEST - (byte) 1},
      new byte[] {GREATEST, GREATEST},
      new byte[] {GREATEST, GREATEST, GREATEST});

  // The Unsafe implementation if it's available. Otherwise, the Java implementation.
  Comparator<byte[]> comparator = UnsignedBytes.lexicographicalComparator();
  Helpers.testComparator(comparator, ordered);
  assertSame(comparator, SerializableTester.reserialize(comparator));

  // The Java implementation.
  Comparator<byte[]> javaImpl = UnsignedBytes.lexicographicalComparatorJavaImpl();
  Helpers.testComparator(javaImpl, ordered);
  assertSame(javaImpl, SerializableTester.reserialize(javaImpl));
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:23,代码来源:UnsignedBytesTest.java

示例4: testEqualsAndHashCode

import com.google.common.testing.SerializableTester; //导入依赖的package包/类
public void testEqualsAndHashCode() {
  new EqualsTester()
      .addEqualityGroup(
          MANY_VALUES_PAIRED_STATS,
          DUPLICATE_MANY_VALUES_PAIRED_STATS,
          SerializableTester.reserialize(MANY_VALUES_PAIRED_STATS))
      .addEqualityGroup(
          new PairedStats(MANY_VALUES_STATS_ITERABLE, OTHER_MANY_VALUES_STATS, 1.23),
          new PairedStats(MANY_VALUES_STATS_VARARGS, OTHER_MANY_VALUES_STATS, 1.23))
      .addEqualityGroup(
          new PairedStats(OTHER_MANY_VALUES_STATS, MANY_VALUES_STATS_ITERABLE, 1.23))
      .addEqualityGroup(
          new PairedStats(MANY_VALUES_STATS_ITERABLE, MANY_VALUES_STATS_ITERABLE, 1.23))
      .addEqualityGroup(
          new PairedStats(TWO_VALUES_STATS, MANY_VALUES_STATS_ITERABLE, 1.23))
      .addEqualityGroup(
          new PairedStats(MANY_VALUES_STATS_ITERABLE, ONE_VALUE_STATS, 1.23))
      .addEqualityGroup(
          new PairedStats(MANY_VALUES_STATS_ITERABLE, MANY_VALUES_STATS_ITERABLE, 1.234))
      .testEquals();
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:22,代码来源:PairedStatsTest.java

示例5: testEqualsAndHashCode

import com.google.common.testing.SerializableTester; //导入依赖的package包/类
public void testEqualsAndHashCode() {
  new EqualsTester()
      .addEqualityGroup(Stats.of(1.0, 1.0, 5.0, 5.0),
          Stats.of(1.0, 1.0, 5.0, 5.0),
          Stats.of(ImmutableList.of(1.0, 1.0, 5.0, 5.0)),
          Stats.of(ImmutableList.of(1.0, 1.0, 5.0, 5.0).iterator()),
          SerializableTester.reserialize(Stats.of(1.0, 1.0, 5.0, 5.0)))
      .addEqualityGroup(Stats.of(1.0, 5.0))
      .addEqualityGroup(Stats.of(1.0, 5.0, 1.0, 6.0))
      .addEqualityGroup(Stats.of(2.0, 6.0, 2.0, 6.0))
      .addEqualityGroup(new Stats(5, -5.5, 55.5, -5.55, 5.55),
          new Stats(5, -5.5, 55.5, -5.55, 5.55))
      .addEqualityGroup(new Stats(6, -5.5, 55.5, -5.55, 5.55))
      .addEqualityGroup(new Stats(5, -5.6, 55.5, -5.55, 5.55))
      .addEqualityGroup(new Stats(5, -5.5, 55.6, -5.55, 5.55))
      .addEqualityGroup(new Stats(5, -5.5, 55.5, -5.56, 5.55))
      .addEqualityGroup(new Stats(5, -5.5, 55.5, -5.55, 5.56))
      .testEquals();
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:20,代码来源:StatsTest.java

示例6: testForMapWithDefault_includeSerializable

import com.google.common.testing.SerializableTester; //导入依赖的package包/类
@GwtIncompatible // SerializableTester
public void testForMapWithDefault_includeSerializable() {
  Map<String, Integer> map = Maps.newHashMap();
  map.put("One", 1);
  map.put("Three", 3);
  Function<String, Integer> function = Functions.forMap(map, 42);

  assertEquals(1, function.apply("One").intValue());
  assertEquals(42, function.apply("Two").intValue());
  assertEquals(3, function.apply("Three").intValue());

  new EqualsTester()
      .addEqualityGroup(
          function,
          Functions.forMap(map, 42),
          SerializableTester.reserialize(function))
      .addEqualityGroup(Functions.forMap(map))
      .addEqualityGroup(Functions.forMap(map, null))
      .addEqualityGroup(Functions.forMap(map, 43))
      .testEquals();
}
 
开发者ID:paul-hammant,项目名称:googles-monorepo-demo,代码行数:22,代码来源:FunctionsTest.java

示例7: testAsList2Small

import com.google.common.testing.SerializableTester; //导入依赖的package包/类
@GwtIncompatible // SerializableTester
public void testAsList2Small() {
  List<String> list = Lists.asList("foo", "bar", new String[0]);
  assertThat(list).containsExactly("foo", "bar").inOrder();
  assertEquals(2, list.size());
  assertIndexIsOutOfBounds(list, -1);
  assertEquals("foo", list.get(0));
  assertEquals("bar", list.get(1));
  assertIndexIsOutOfBounds(list, 2);
  SerializableTester.reserializeAndAssert(list);
  assertTrue(list instanceof RandomAccess);

  new IteratorTester<String>(5, UNMODIFIABLE, asList("foo", "bar"),
      IteratorTester.KnownOrder.KNOWN_ORDER) {
    @Override protected Iterator<String> newTargetIterator() {
      return Lists.asList("foo", "bar", new String[0]).iterator();
    }
  }.test();
}
 
开发者ID:paul-hammant,项目名称:googles-monorepo-demo,代码行数:20,代码来源:ListsTest.java

示例8: testSortedSerialization

import com.google.common.testing.SerializableTester; //导入依赖的package包/类
@GwtIncompatible // SerializableTester
public void testSortedSerialization() {
  Multimap<String, Integer> multimap = new ImmutableSetMultimap.Builder<String, Integer>()
      .orderKeysBy(Ordering.natural().reverse())
      .orderValuesBy(Ordering.usingToString())
      .put("a", 2)
      .put("a", 10)
      .put("b", 1)
      .build();
  multimap = SerializableTester.reserialize(multimap);
  assertThat(multimap.keySet()).containsExactly("b", "a").inOrder();
  assertThat(multimap.get("a")).containsExactly(10, 2).inOrder();
  assertEquals(Ordering.usingToString(),
      ((ImmutableSortedSet<Integer>) multimap.get("a")).comparator());
  assertEquals(Ordering.usingToString(),
      ((ImmutableSortedSet<Integer>) multimap.get("z")).comparator());
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:18,代码来源:ImmutableSetMultimapTest.java

示例9: serialize_deserialize

import com.google.common.testing.SerializableTester; //导入依赖的package包/类
@Test
public void serialize_deserialize() {
    SystemConfig expected = SystemConfigs.get();
    SystemConfig actual = SerializableTester.reserialize(expected);

    assertThat(expected.getHostName(), is(actual.getHostName()));
    assertThat(expected.getMemoryJson(), is(actual.getMemoryJson()));
    assertThat(expected.getOperatingSystemJson(), is(actual.getOperatingSystemJson()));
    assertThat(expected.getFileSystemJson(), is(actual.getFileSystemJson()));
    assertThat(expected.getProcessorJson(), is(actual.getProcessorJson()));
    assertThat(expected.toString(), is(actual.toString()));
}
 
开发者ID:florentw,项目名称:bench,代码行数:13,代码来源:SystemConfigTest.java

示例10: serializable

import com.google.common.testing.SerializableTester; //导入依赖的package包/类
@Test
public void serializable() {
    JMSEndpoint expected = createEndpoint();

    JMSEndpoint actual = SerializableTester.reserializeAndAssert(expected);

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

示例11: 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

示例12: testSeveral_serialization

import com.google.common.testing.SerializableTester; //导入依赖的package包/类
@GwtIncompatible // SerializableTester
public void testSeveral_serialization() {
  SortedSet<String> set = new SafeTreeSet<String>();
  set.add("a");
  set.add("b");
  set.add("c");
  SortedSet<String> copy = SerializableTester.reserializeAndAssert(set);
  assertEquals(set.comparator(), copy.comparator());
}
 
开发者ID:paul-hammant,项目名称:googles-monorepo-demo,代码行数:10,代码来源:SafeTreeSetTest.java

示例13: testViewSerialization

import com.google.common.testing.SerializableTester; //导入依赖的package包/类
@GwtIncompatible // SerializableTester
public void testViewSerialization() {
  Map<String, Integer> map
      = ImmutableSortedMap.of("one", 1, "two", 2, "three", 3);
  SerializableTester.reserializeAndAssert(map.entrySet());
  SerializableTester.reserializeAndAssert(map.keySet());
  assertEquals(Lists.newArrayList(map.values()),
      Lists.newArrayList(SerializableTester.reserialize(map.values())));
}
 
开发者ID:paul-hammant,项目名称:googles-monorepo-demo,代码行数:10,代码来源:ImmutableSortedMapTest.java

示例14: serialize_deserialize

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

    assertThat(received.getState(), is(outputMessage.getState()));
    assertThat(received.getAgent(), is(outputMessage.getAgent()));
    assertThat(received.getRegistrationMessage(), is(outputMessage.getRegistrationMessage()));
    assertThat(received.getThrowable(), is(outputMessage.getThrowable()));
}
 
开发者ID:florentw,项目名称:bench,代码行数:10,代码来源:AgentLifecycleMessageTest.java

示例15: 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


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