Java Code Examples for com.google.common.testing.SerializableTester#reserializeAndAssert()

The following examples show how to use com.google.common.testing.SerializableTester#reserializeAndAssert() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: UBinaryTest.java    From Refaster with Apache License 2.0 6 votes vote down vote up
@Test
public void serialization() {
  ULiteral oneLit = ULiteral.intLit(1);
  ULiteral twoLit = ULiteral.intLit(2);
  ULiteral piLit = ULiteral.doubleLit(Math.PI);
  ULiteral trueLit = ULiteral.booleanLit(true);
  ULiteral falseLit = ULiteral.booleanLit(false);

  SerializableTester.reserializeAndAssert(UBinary.create(Kind.PLUS, oneLit, twoLit));
  SerializableTester.reserializeAndAssert(UBinary.create(Kind.PLUS, oneLit, piLit));
  SerializableTester.reserializeAndAssert(UBinary.create(Kind.PLUS, piLit, twoLit));
  SerializableTester.reserializeAndAssert(UBinary.create(Kind.MINUS, oneLit, twoLit));
  SerializableTester.reserializeAndAssert(UBinary.create(Kind.XOR, oneLit, twoLit));
  SerializableTester.reserializeAndAssert(UBinary.create(Kind.CONDITIONAL_OR, trueLit, falseLit));
  SerializableTester.reserializeAndAssert(UBinary.create(Kind.OR, trueLit, falseLit));
}
 
Example 2
Source File: UClassTypeTest.java    From Refaster with Apache License 2.0 5 votes vote down vote up
@Test
public void serialization() {
  UClassType stringType = UClassType.create("java.lang.String");
  UClassType integerType = UClassType.create("java.lang.Integer");
  SerializableTester.reserializeAndAssert(stringType);
  SerializableTester.reserializeAndAssert(integerType);
  SerializableTester.reserializeAndAssert(
      UClassType.create("java.util.List", stringType));
  SerializableTester.reserializeAndAssert(
      UClassType.create("java.util.List", integerType));
  SerializableTester.reserializeAndAssert(
      UClassType.create("java.util.Map", stringType, stringType));
}
 
Example 3
Source File: UMethodInvocationTest.java    From Refaster with Apache License 2.0 5 votes vote down vote up
@Test
public void serialization() {
  SerializableTester.reserializeAndAssert(UMethodInvocation.create(
      UMemberSelect.create(ULiteral.stringLit("foo"), 
          "indexOf", 
          UMethodType.create(UPrimitiveType.INT, UPrimitiveType.INT)), 
      ULiteral.charLit('a')));
}
 
Example 4
Source File: TestCuckooFilter.java    From CuckooFilter4J with Apache License 2.0 5 votes vote down vote up
@Test
public void testSerializePartFull() {
	CuckooFilter<Integer> filter = new CuckooFilter.Builder<>(Funnels.integerFunnel(), 2000000)
			.withFalsePositiveRate(0.01).withHashAlgorithm(Algorithm.Murmur3_32).build();
	for (int i = 0; i < 1000000; i++) {
		assertTrue(filter.put(i));
	}
	SerializableTester.reserializeAndAssert(filter);
}
 
Example 5
Source File: TestCuckooFilter.java    From CuckooFilter4J with Apache License 2.0 5 votes vote down vote up
@Test
public void testSerializeFull() {
	CuckooFilter<Integer> filter = new CuckooFilter.Builder<>(Funnels.integerFunnel(), 2000000)
			.withFalsePositiveRate(0.01).withHashAlgorithm(Algorithm.Murmur3_32).build();
	for (int i = 0;; i++) {
		if (!filter.put(i))
			break;
	}
	SerializableTester.reserializeAndAssert(filter);
}
 
Example 6
Source File: UEnhancedForLoopTest.java    From Refaster with Apache License 2.0 5 votes vote down vote up
@Test
public void serialization() {
  SerializableTester.reserializeAndAssert(UEnhancedForLoop.create(
      UVariableDecl.create("c", UPrimitiveTypeTree.CHAR, null), 
      UMethodInvocation.create(UMemberSelect.create(ULiteral.stringLit("foo"), "toCharArray", 
          UMethodType.create(UArrayType.create(UPrimitiveType.CHAR)))), USkip.INSTANCE));
}
 
Example 7
Source File: UIfTest.java    From Refaster with Apache License 2.0 5 votes vote down vote up
@Test
public void serialization() {
  SerializableTester.reserializeAndAssert(UIf.create(
      UFreeIdent.create("cond"), 
      UBlock.create(UExpressionStatement.create(
          UAssign.create(UFreeIdent.create("x"), UFreeIdent.create("y")))), 
      UBlock.create(UExpressionStatement.create(
          UAssign.create(UFreeIdent.create("x"), UFreeIdent.create("z"))))));
}
 
Example 8
Source File: CuckooFilterTest.java    From guava-probably with Apache License 2.0 5 votes vote down vote up
@Test
public void javaSerialization() {
  CuckooFilter<byte[]> cf = CuckooFilter.create(Funnels.byteArrayFunnel(), 100);
  for (int i = 0; i < 10; i++) {
    cf.add(Ints.toByteArray(i));
  }

  CuckooFilter<byte[]> copy = SerializableTester.reserialize(cf);
  for (int i = 0; i < 10; i++) {
    assertTrue(copy.contains(Ints.toByteArray(i)));
  }
  assertEquals(cf.currentFpp(), copy.currentFpp());

  SerializableTester.reserializeAndAssert(cf);
}
 
Example 9
Source File: FunctionsTest.java    From durian with Apache License 2.0 5 votes vote down vote up
@GwtIncompatible("SerializableTester")
private static <Y> void checkCanReserializeSingleton(Function<? super String, Y> f) {
	Function<? super String, Y> g = SerializableTester.reserializeAndAssert(f);
	assertSame(f, g);
	for (Integer i = 1; i < 5; i++) {
		assertEquals(f.apply(i.toString()), g.apply(i.toString()));
	}
}
 
Example 10
Source File: UAssignTest.java    From Refaster with Apache License 2.0 4 votes vote down vote up
@Test
public void serialization() {
  SerializableTester.reserializeAndAssert(
      UAssign.create(UFreeIdent.create("foo"), ULiteral.intLit(5)));
}
 
Example 11
Source File: UAnnotationTest.java    From Refaster with Apache License 2.0 4 votes vote down vote up
@Test
public void serialization() {
  SerializableTester.reserializeAndAssert(
      UAnnotation.create(
          UClassIdent.create("java.lang.SuppressWarnings"), ULiteral.stringLit("cast")));
}
 
Example 12
Source File: UTypeVarIdentTest.java    From Refaster with Apache License 2.0 4 votes vote down vote up
@Test
public void serialization() {
  SerializableTester.reserializeAndAssert(UTypeVarIdent.create("E"));
}
 
Example 13
Source File: UAssignOpTest.java    From Refaster with Apache License 2.0 4 votes vote down vote up
@Test
public void serialization() {
  SerializableTester.reserializeAndAssert(
      UAssignOp.create(UFreeIdent.create("x"), Kind.PLUS_ASSIGNMENT, ULiteral.intLit(2)));
}
 
Example 14
Source File: UClassIdentTest.java    From Refaster with Apache License 2.0 4 votes vote down vote up
@Test
public void serialization() {
  SerializableTester.reserializeAndAssert(UClassIdent.create("java.math.BigInteger"));
}
 
Example 15
Source File: UUnaryTest.java    From Refaster with Apache License 2.0 4 votes vote down vote up
@Test
public void serialization() {
  SerializableTester.reserializeAndAssert(
      UUnary.create(Kind.BITWISE_COMPLEMENT, ULiteral.intLit(7)));
}
 
Example 16
Source File: CuckooFilterTest.java    From guava-probably with Apache License 2.0 4 votes vote down vote up
@Test
public void serializationWithCustomFunnel() {
  SerializableTester.reserializeAndAssert(CuckooFilter.create(new CustomFunnel(), 100));
}
 
Example 17
Source File: CuckooFilterTest.java    From guava-probably with Apache License 2.0 4 votes vote down vote up
@Test
public void serializationWithCustomFunnel() {
  SerializableTester.reserializeAndAssert(CuckooFilter.create(new CustomFunnel(), 100));
}
 
Example 18
Source File: UReturnTest.java    From Refaster with Apache License 2.0 4 votes vote down vote up
@Test
public void serialization() {
  SerializableTester.reserializeAndAssert(UReturn.create(ULiteral.stringLit("foo")));
}
 
Example 19
Source File: UPrimitiveTypeTreeTest.java    From Refaster with Apache License 2.0 4 votes vote down vote up
@Test
public void serialization() {
  SerializableTester.reserializeAndAssert(UPrimitiveTypeTree.INT);
}
 
Example 20
Source File: USynchronizedTest.java    From Refaster with Apache License 2.0 4 votes vote down vote up
@Test
public void serialization() {
  SerializableTester.reserializeAndAssert(
      USynchronized.create(UFreeIdent.create("foo"), UBlock.create()));
}