RemoveProviderByIdentity.java revision 0:37a05a11f281
1163854Sjulian/*
2163854Sjulian * Copyright 1999 Sun Microsystems, Inc.  All Rights Reserved.
3163854Sjulian * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4163854Sjulian *
5163854Sjulian * This code is free software; you can redistribute it and/or modify it
6163854Sjulian * under the terms of the GNU General Public License version 2 only, as
7163854Sjulian * published by the Free Software Foundation.
8163854Sjulian *
9163854Sjulian * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
20 * CA 95054 USA or visit www.sun.com if you need additional information or
21 * have any questions.
22 */
23
24/*
25 * @test
26 * @bug 4208414
27 * @summary Providers should be removed "by-identity" - not "by-value"
28 */
29
30import java.security.*;
31
32public class RemoveProviderByIdentity {
33
34    public static void main(String[] args) throws Exception {
35        String PROVIDER_NAME = "myprovider";
36
37        Security.addProvider(new MyProvider(PROVIDER_NAME, 1, "test"));
38        if (Security.getProvider(PROVIDER_NAME) == null)
39            throw new Exception("provider not registered");
40
41        Security.removeProvider(PROVIDER_NAME);
42        if (Security.getProvider(PROVIDER_NAME) != null)
43            throw new Exception("provider not removed");
44    }
45}
46
47class MyProvider extends Provider {
48    public MyProvider(String name, double version, String info) {
49        super(name, version, info);
50        put("Signature.sigalg", "sigimpl");
51    }
52}
53