Example #1
0
 /** java.util.HashSet#SerializationTest */
 public void test_Serialization() throws Exception {
   HashSet<String> hs = new HashSet<String>();
   hs.add("hello");
   hs.add("world");
   SerializationTest.verifySelf(hs, comparator);
   SerializationTest.verifyGolden(this, hs, comparator);
 }
Example #2
0
  /**
   * @tests serialization/deserialization compatibility.
   *     <p>Test serialization of normal instance of Level. It is expected that the deserialized
   *     level object should be equal to the original one.
   */
  public void testSerialization_InstanceLevel() throws Exception {

    // tests that objects are the same
    Level[] objectsToTest = new Level[] {Level.parse("550")};

    SerializationTest.verifySelf(objectsToTest, SerializationTest.SAME_COMPARATOR);

    // tests that objects are the equals
    objectsToTest =
        new Level[] {new MockLevel("123", 123, "bundle"), new MockLevel("123", 123, null)};

    SerializationTest.verifySelf(objectsToTest, LEVEL_COMPARATOR);
  }
  public void test_asListTvararg() throws Exception {
    List<String> stringsList = Arrays.asList("0", "1");
    assertEquals(2, stringsList.size());
    assertEquals("0", stringsList.get(0));
    assertEquals("1", stringsList.get(1));
    assertTrue(stringsList instanceof RandomAccess);
    assertTrue(stringsList instanceof Serializable);

    assertEquals(stringsList, SerializationTest.copySerializable((Serializable) stringsList));

    // test from javadoc
    List<String> stooges = Arrays.asList("Larry", "Moe", "Curly");
    assertEquals(3, stooges.size());
    assertEquals("Larry", stooges.get(0));
    assertEquals("Moe", stooges.get(1));
    assertEquals("Curly", stooges.get(2));

    stringsList = Arrays.asList((String) null);
    assertEquals(1, stringsList.size());
    assertEquals((String) null, stringsList.get(0));

    try {
      Arrays.asList((Object[]) null);
      fail("No NPE");
    } catch (NullPointerException e) {
    }
  }
  @TestTargetNew(
      level = TestLevel.COMPLETE,
      notes = "",
      method = "!SerializationGolden",
      args = {})
  public void testSerialization_Compatibility() throws Exception {
    UnresolvedPermission up =
        new UnresolvedPermission("java.security.SecurityPermission", "a.b.c", "actions", null);
    assertEquals("java.security.SecurityPermission", up.getUnresolvedType());
    assertEquals("a.b.c", up.getUnresolvedName());
    assertEquals("actions", up.getUnresolvedActions());
    assertNull(up.getUnresolvedCerts());

    SerializationTest.verifyGolden(
        this,
        up,
        new SerializableAssert() {
          public void assertDeserialized(Serializable orig, Serializable ser) {
            UnresolvedPermission deserializedUp = (UnresolvedPermission) ser;
            assertEquals("java.security.SecurityPermission", deserializedUp.getUnresolvedType());
            assertEquals("a.b.c", deserializedUp.getUnresolvedName());
            assertEquals("actions", deserializedUp.getUnresolvedActions());
            assertNull(deserializedUp.getUnresolvedCerts());
          }
        });
  }
  /** @tests serialization/deserialization compatibility with RI. */
  @TestTargetNew(
      level = TestLevel.COMPLETE,
      notes = "Verifies serialization/deserialization compatibility.",
      method = "!SerializationGolden",
      args = {})
  public void testSerializationCompatibility() throws Exception {

    SerializationTest.verifyGolden(this, new InvalidMarkException());
  }
  /** @tests serialization/deserialization compatibility with RI. */
  public void testSerializationCompatibility() throws Exception {

    SQLException nextSQLException = new SQLException("nextReason", "nextSQLState", 33);

    int vendorCode = 10;
    SQLException object = new SQLException("reason", "SQLState", vendorCode);

    object.setNextException(nextSQLException);

    SerializationTest.verifyGolden(this, object, SQLEXCEPTION_COMPARATOR);
  }
  /** @tests serialization/deserialization compatibility with RI. */
  @TestTargets({
    @TestTargetNew(
        level = TestLevel.COMPLETE,
        notes = "Verifies serialization/deserialization compatibility.",
        method = "!SerializationGolden",
        args = {}),
    @TestTargetNew(
        level = TestLevel.PARTIAL_COMPLETE,
        notes = "Verifies serialization/deserialization compatibility.",
        method = "FileLockInterruptionException",
        args = {})
  })
  public void testSerializationCompatibility() throws Exception {

    SerializationTest.verifyGolden(this, new FileLockInterruptionException());
  }
 /** @test serialization/deserialization compatibility with RI. */
 public void test_compatibilitySerialization() throws Exception {
   SerializationTest.verifyGolden(this, sQLNonTransientException);
 }
 /** @test serialization/deserialization compatibility. */
 public void test_serialization() throws Exception {
   SerializationTest.verifySelf(sQLNonTransientException);
 }
 /**
  * @tests serialization/deserialization compatibility with RI.
  * @since 1.6
  */
 public void testSerializationCompatibility() throws Exception {
   String errorMsg = "java.io.IOError";
   IOError e = new IOError(new Throwable(errorMsg));
   SerializationTest.verifyGolden(this, e);
 }
 /**
  * @tests serialization/deserialization.
  * @since 1.6
  */
 public void testSerializationSelf() throws Exception {
   String errorMsg = "java.io.IOError";
   IOError e = new IOError(new Throwable(errorMsg));
   SerializationTest.verifySelf(e);
 }
Example #12
0
  /** @tests serialization/deserialization compatibility with RI. */
  public void testSerializationCompatibility() throws Exception {

    SerializationTest.verifyGolden(this, new MockLevel("123", 123, "bundle"), LEVEL_COMPARATOR);
  }
Example #13
0
  /**
   * @tests serialization/deserialization compatibility.
   *     <p>Test serialization of pre-defined const levels. It is expected that the deserialized
   *     cost level should be the same instance as the existing one.
   */
  public void testSerialization_ConstLevel() throws Exception {

    SerializationTest.verifySelf(Level.ALL, SerializationTest.SAME_COMPARATOR);
  }
 /** @tests serialization/deserialization compatibility. */
 public void testSerializationSelf() throws Exception {
   SQLException object = new SQLException();
   SerializationTest.verifySelf(object, SQLEXCEPTION_COMPARATOR);
 }