1 // $Id: getInstance14.java,v 1.3 2006/01/02 14:02:58 raif Exp $ |
|
2 // |
|
3 // Copyright (C) 2003, Free Software Foundation, Inc. |
|
4 // |
|
5 // This file is part of Mauve. |
|
6 // |
|
7 // Mauve is free software; you can redistribute it and/or modify |
|
8 // it under the terms of the GNU General Public License as published by |
|
9 // the Free Software Foundation; either version 2, or (at your option) |
|
10 // any later version. |
|
11 // |
|
12 // Mauve is distributed in the hope that it will be useful, |
|
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
15 // GNU General Public License for more details. |
|
16 // |
|
17 // You should have received a copy of the GNU General Public License |
|
18 // along with Mauve; see the file COPYING. If not, write to |
|
19 // the Free Software Foundation, 59 Temple Place - Suite 330, |
|
20 // Boston, MA 02111-1307, USA. |
|
21 // |
|
22 // Tags: JDK1.4 |
|
23 // Uses: MauveDigest |
|
24 |
|
25 package gnu.testlet.java.security.MessageDigest; |
|
26 import gnu.testlet.Testlet; |
|
27 import gnu.testlet.TestHarness; |
|
28 |
|
29 import java.security.GeneralSecurityException; |
|
30 import java.security.MessageDigest; |
|
31 import java.security.Provider; |
|
32 import java.security.NoSuchAlgorithmException; |
|
33 import java.security.Security; |
|
34 |
|
35 public class getInstance14 extends Provider implements Testlet |
|
36 { |
|
37 public getInstance14() |
|
38 { |
|
39 super("MessageDigest", 1.0, ""); |
|
40 |
|
41 put("MessageDigest.foo", |
|
42 "gnu.testlet.java.security.MessageDigest.MauveDigest"); |
|
43 put("Alg.Alias.MessageDigest.bar", "foo"); |
|
44 } |
|
45 |
|
46 public void test (TestHarness harness) |
|
47 { |
|
48 harness.checkPoint ("MessageDigest"); |
|
49 |
|
50 MessageDigest spi; |
|
51 Provider provider = this; |
|
52 Security.addProvider(provider); |
|
53 String signature; |
|
54 |
|
55 spi = null; |
|
56 signature = "getInstance(\"foo\", \" MessageDigest \")"; |
|
57 try |
|
58 { |
|
59 spi = MessageDigest.getInstance("foo", " MessageDigest "); |
|
60 harness.check(spi != null, signature); |
|
61 } |
|
62 catch (GeneralSecurityException x) |
|
63 { |
|
64 harness.fail(signature); |
|
65 harness.debug(x); |
|
66 } |
|
67 |
|
68 spi = null; |
|
69 signature = "getInstance(\"foo\", provider)"; |
|
70 try |
|
71 { |
|
72 spi = MessageDigest.getInstance("foo", provider); |
|
73 harness.check(spi != null, signature); |
|
74 } |
|
75 catch (NoSuchAlgorithmException x) |
|
76 { |
|
77 harness.fail(signature); |
|
78 harness.debug(x); |
|
79 } |
|
80 |
|
81 spi = null; |
|
82 signature = "getInstance(\" foo \", provider)"; |
|
83 try |
|
84 { |
|
85 spi = MessageDigest.getInstance(" foo ", provider); |
|
86 harness.check(spi != null, signature); |
|
87 } |
|
88 catch (NoSuchAlgorithmException x) |
|
89 { |
|
90 harness.fail(signature); |
|
91 harness.debug(x); |
|
92 } |
|
93 |
|
94 spi = null; |
|
95 signature = "getInstance(\"FOO\", provider)"; |
|
96 try |
|
97 { |
|
98 spi = MessageDigest.getInstance("FOO", provider); |
|
99 harness.check(spi != null, signature); |
|
100 } |
|
101 catch (NoSuchAlgorithmException x) |
|
102 { |
|
103 harness.fail(signature); |
|
104 harness.debug(x); |
|
105 } |
|
106 |
|
107 spi = null; |
|
108 signature = "getInstance(\"bar\", provider)"; |
|
109 try |
|
110 { |
|
111 spi = MessageDigest.getInstance("bar", provider); |
|
112 harness.check(spi != null, signature); |
|
113 } |
|
114 catch (NoSuchAlgorithmException x) |
|
115 { |
|
116 harness.fail(signature); |
|
117 harness.debug(x); |
|
118 } |
|
119 |
|
120 spi = null; |
|
121 signature = "getInstance(\"BAR\", provider)"; |
|
122 try |
|
123 { |
|
124 spi = MessageDigest.getInstance("BAR", provider); |
|
125 harness.check(spi != null, signature); |
|
126 } |
|
127 catch (NoSuchAlgorithmException x) |
|
128 { |
|
129 harness.fail(signature); |
|
130 harness.debug(x); |
|
131 } |
|
132 } |
|
133 } |
|