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 Boris V. Kuznetsov
20: * @version $Revision$
21: */package org.apache.harmony.security.tests.java.security;
22:
23: import java.security.Provider;
24: import java.util.HashMap;
25:
26: import junit.framework.TestCase;
27:
28: /**
29: * Tests for <code>Provider.Service</code> constructor and methods
30: *
31: */
32: public class ProviderService_ImplTest extends TestCase {
33:
34: /*
35: * Class under test for String toString()
36: */
37: public void testToString() {
38: Provider p = new MyProvider();
39: Provider.Service s = new Provider.Service(p, "type",
40: "algorithm", "className", null, null);
41: assertEquals("first toString() failed",
42: "Provider MyProvider Service type.algorithm className",
43: s.toString());
44:
45: HashMap hm = new HashMap();
46: hm.put("attribute", "value");
47: hm.put("KeySize", "1024");
48: hm.put("AAA", "BBB");
49:
50: s = new Provider.Service(p, "type", "algorithm", "className",
51: null, hm);
52: assertTrue("second toString() failed", s.toString().startsWith(
53: "Provider MyProvider Service type.algorithm className\n"
54: + "Attributes "));
55: }
56:
57: class MyProvider extends Provider {
58: MyProvider() {
59: super ("MyProvider", 1.0, "Provider for testing");
60: put("MessageDigest.SHA-1", "SomeClassName");
61: }
62: }
63: }
|