01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17:
18: /**
19: * @author Vera Y. Petrashkova
20: * @version $Revision$
21: */package org.apache.harmony.security.tests.java.security;
22:
23: import java.security.*;
24: import java.security.cert.Certificate;
25:
26: import org.apache.harmony.security.tests.support.cert.MyCertificate;
27:
28: import junit.framework.TestCase;
29:
30: /**
31: * Tests for <code>KeyStore.TrustedCertificateEntry</code> class constructor and methods
32: *
33: */
34:
35: public class KSTrustedCertificateEntryTest extends TestCase {
36:
37: /**
38: * Test for <codfe>KeyStore.TrustedCertificateEntry(Certificate trustCert)</code>
39: * constructor
40: * Assertion: throws NullPointerException when trustCert is null
41: */
42: public void testTrustedCertificateEntry() {
43: Certificate cert = null;
44: try {
45: new KeyStore.TrustedCertificateEntry(cert);
46: fail("NullPointerException must be thrown when trustCert is null");
47: } catch (NullPointerException e) {
48: }
49: }
50:
51: /**
52: * Test for <codfe>getTrustedCertificate()</code> method
53: * Assertion: returns trusted Certificate from goven entry
54: */
55: public void testGetTrustedCertificate() {
56: Certificate cert = new MyCertificate("TEST", new byte[10]);
57: KeyStore.TrustedCertificateEntry ksTCE = new KeyStore.TrustedCertificateEntry(
58: cert);
59: assertEquals("Incorrect certificate", cert, ksTCE
60: .getTrustedCertificate());
61: }
62:
63: /**
64: * Test for <codfe>toString()</code> method
65: * Assertion: returns non null string
66: */
67: public void testToString() {
68: Certificate cert = new MyCertificate("TEST", new byte[10]);
69: KeyStore.TrustedCertificateEntry ksTCE = new KeyStore.TrustedCertificateEntry(
70: cert);
71: assertNotNull("toString() returns null string", ksTCE
72: .toString());
73: }
74: }
|