コード例 #1
0
  @TestTargetNew(
      level = TestLevel.COMPLETE,
      notes = "",
      method = "getUnresolvedCerts",
      args = {})
  public void testGetUnresolvedCerts() {
    Certificate[] certificate =
        new java.security.cert.Certificate[] {
          new Certificate(null) {

            @Override
            public byte[] getEncoded() throws CertificateEncodingException {
              // TODO Auto-generated method stub
              return null;
            }

            @Override
            public PublicKey getPublicKey() {
              // TODO Auto-generated method stub
              return null;
            }

            @Override
            public String toString() {
              // TODO Auto-generated method stub
              return null;
            }

            @Override
            public void verify(PublicKey key)
                throws CertificateException, NoSuchAlgorithmException, InvalidKeyException,
                    NoSuchProviderException, SignatureException {
              // TODO Auto-generated method stub

            }

            @Override
            public void verify(PublicKey key, String sigProvider)
                throws CertificateException, NoSuchAlgorithmException, InvalidKeyException,
                    NoSuchProviderException, SignatureException {
              // TODO Auto-generated method stub

            }
          }
        };
    UnresolvedPermission up1 = new UnresolvedPermission("type1", "name1", "action1 @#$%^&*", null);
    UnresolvedPermission up2 = null;
    UnresolvedPermission up3 = new UnresolvedPermission("type3", "name3", "action3", certificate);

    assertNull(up1.getUnresolvedCerts());
    assertTrue(Arrays.equals(certificate, up3.getUnresolvedCerts()));

    try {
      up2.getUnresolvedCerts();
      fail("NullPointerException expected");
    } catch (NullPointerException e) {
      // expected
    }
  }
コード例 #2
0
  @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());
          }
        });
  }
コード例 #3
0
  @TestTargetNew(
      level = TestLevel.COMPLETE,
      notes = "",
      method = "!SerializationSelf",
      args = {})
  public void testSerialization() 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());

    UnresolvedPermission deserializedUp =
        (UnresolvedPermission) SerializationTester.getDeserilizedObject(up);
    assertEquals("java.security.SecurityPermission", deserializedUp.getUnresolvedType());
    assertEquals("a.b.c", deserializedUp.getUnresolvedName());
    assertEquals("actions", deserializedUp.getUnresolvedActions());
    assertNull(deserializedUp.getUnresolvedCerts());
  }