equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 2001, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2001, 2019, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
24 /* |
24 /* |
25 * @test |
25 * @test |
26 * @bug 4423074 |
26 * @bug 4423074 |
27 * @summary Need to rebase all the duplicated classes from Merlin. |
27 * @summary Need to rebase all the duplicated classes from Merlin. |
28 * This test will check out http POST |
28 * This test will check out http POST |
29 * @modules java.base/sun.net.www.protocol.https java.base/com.sun.net.ssl.internal.www.protocol.https |
29 * @modules java.base/sun.net.www.protocol.https |
30 */ |
30 */ |
31 import java.net.*; |
31 import java.net.*; |
32 import java.util.*; |
32 import java.util.*; |
33 import java.lang.reflect.*; |
33 import java.lang.reflect.*; |
34 import sun.net.www.protocol.https.HttpsURLConnectionImpl; |
34 import sun.net.www.protocol.https.HttpsURLConnectionImpl; |
35 import com.sun.net.ssl.internal.www.protocol.https.HttpsURLConnectionOldImpl; |
|
36 |
35 |
37 public class CheckMethods { |
36 public class CheckMethods { |
38 static boolean debug = false; |
37 static boolean debug = false; |
39 static class MethodSignature { |
38 static class MethodSignature { |
40 String name; |
39 String name; |
83 sb.append(")"); |
82 sb.append(")"); |
84 return sb.toString(); |
83 return sb.toString(); |
85 } |
84 } |
86 } |
85 } |
87 |
86 |
88 // check HttpsURLConnectionImpl and HttpsURLConnectionOldImpl |
87 // check HttpsURLConnectionImpl contain all public and protected methods |
89 // contain all public and protected methods defined in |
88 // defined in HttpURLConnection and URLConnection |
90 // HttpURLConnection and URLConnection |
|
91 public static void main(String[] args) { |
89 public static void main(String[] args) { |
92 ArrayList allMethods = new ArrayList( |
90 ArrayList allMethods = new ArrayList( |
93 Arrays.asList(HttpURLConnection.class.getDeclaredMethods())); |
91 Arrays.asList(HttpURLConnection.class.getDeclaredMethods())); |
94 allMethods.addAll(Arrays.asList(URLConnection.class.getDeclaredMethods())); |
92 allMethods.addAll(Arrays.asList(URLConnection.class.getDeclaredMethods())); |
95 ArrayList allMethodSignatures = new ArrayList(); |
93 ArrayList allMethodSignatures = new ArrayList(); |
119 |
117 |
120 if (!httpsMethodSignatures.containsAll(allMethodSignatures)) { |
118 if (!httpsMethodSignatures.containsAll(allMethodSignatures)) { |
121 throw new RuntimeException("Method definition test failed on HttpsURLConnectionImpl"); |
119 throw new RuntimeException("Method definition test failed on HttpsURLConnectionImpl"); |
122 } |
120 } |
123 |
121 |
124 // testing HttpsURLConnectionOldImpl |
|
125 List httpsOldMethods = |
|
126 Arrays.asList(HttpsURLConnectionOldImpl.class.getDeclaredMethods()); |
|
127 |
|
128 ArrayList httpsOldMethodSignatures = new ArrayList(); |
|
129 for (Iterator itr = httpsOldMethods.iterator(); itr.hasNext(); ) { |
|
130 Method m = (Method)itr.next(); |
|
131 if (!Modifier.isStatic(m.getModifiers())) { |
|
132 httpsOldMethodSignatures.add( |
|
133 new MethodSignature(m.getName(), m.getParameterTypes())); |
|
134 } |
|
135 } |
|
136 |
|
137 if (!httpsOldMethodSignatures.containsAll(allMethodSignatures)) { |
|
138 throw new RuntimeException("Method definition test failed" + |
|
139 " on HttpsURLConnectionOldImpl"); |
|
140 } |
|
141 |
|
142 // testing for non static public field |
122 // testing for non static public field |
143 ArrayList allFields = new ArrayList( |
123 ArrayList allFields = new ArrayList( |
144 Arrays.asList(URLConnection.class.getFields())); |
124 Arrays.asList(URLConnection.class.getFields())); |
145 allFields.addAll(Arrays.asList(HttpURLConnection.class.getFields())); |
125 allFields.addAll(Arrays.asList(HttpURLConnection.class.getFields())); |
146 |
126 |