Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/javax/management/loading/MLetContentTest.java
41152 views
1
/*
2
* Copyright (c) 2004, 2015, Oracle and/or its affiliates. All rights reserved.
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
*
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
7
* published by the Free Software Foundation.
8
*
9
* 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20
* or visit www.oracle.com if you need additional information or have any
21
* questions.
22
*/
23
24
/*
25
* @test
26
* @bug 4796780
27
* @summary The class MLetContentTest becomes public
28
* @author Shanliang JIANG
29
*
30
* @run clean MLetContentTest
31
* @run build MLetContentTest
32
* @run main MLetContentTest
33
*/
34
35
import java.util.*;
36
import java.net.*;
37
38
import javax.management.loading.*;
39
40
public class MLetContentTest {
41
public static void main(String[] args) throws Exception {
42
System.out.println(">>> General test for the public class MLetContent.");
43
44
Map<String,String> attributes = new HashMap();
45
attributes.put("archive", archive);
46
attributes.put("Archive", "hahaha");
47
48
attributes.put("code", code);
49
attributes.put("codE", "hihi");
50
51
attributes.put("object", object);
52
attributes.put("obJect", "toto");
53
54
attributes.put("name", name);
55
attributes.put("NAME", "titi");
56
57
attributes.put("version", version);
58
attributes.put("VeRsIoN", "tttt");
59
60
List<String> types = new ArrayList();
61
types.add("my type");
62
63
List<String> values = new ArrayList();
64
values.add("my values");
65
66
URL url = new URL(baseUrl+myfile);
67
MLetContent content = new MLetContent(url, attributes, types, values);
68
69
if (!attributes.equals(content.getAttributes())) {
70
throw new RuntimeException("The user specific attributes are changed.");
71
}
72
73
if (!url.equals(content.getDocumentBase())) {
74
throw new RuntimeException("The user specific document bas is changed.");
75
}
76
77
if (!archive.equals(content.getJarFiles())) {
78
throw new RuntimeException("The user specific archive files are changed.");
79
}
80
81
if (!code.equals(content.getCode())) {
82
throw new RuntimeException("The user specific code is changed.");
83
}
84
85
if (!object.equals(content.getSerializedObject())) {
86
throw new RuntimeException("The user specific object is changed.");
87
}
88
89
if (!name.equals(content.getName())) {
90
throw new RuntimeException("The user specific name is changed.");
91
}
92
93
if (!version.equals(content.getVersion())) {
94
throw new RuntimeException("The user specific version is changed.");
95
}
96
97
if (!types.equals(content.getParameterTypes())) {
98
throw new RuntimeException("The user specific types are changed.");
99
}
100
101
if (!values.equals(content.getParameterValues())) {
102
throw new RuntimeException("The user specific values are changed.");
103
}
104
105
if (!baseUrl.equals(content.getCodeBase().toString())) {
106
throw new RuntimeException("The user specific base url are changed.");
107
}
108
109
url = new URL(baseUrl);
110
attributes.put("codebase", codebase);
111
content = new MLetContent(url, attributes, types, values);
112
113
if (!content.getCodeBase().toString().equals(baseUrl+codebase)) {
114
throw new RuntimeException("The user specific base url are changed.");
115
}
116
117
final MyMLet myMlet = new MyMLet();
118
119
if (myMlet.check(null, null, null, content) != content.getCodeBase()) {
120
throw new RuntimeException("Failed to overrid the protected methed check");
121
}
122
123
System.out.println(">>> The test is well passed.");
124
}
125
126
private static class MyMLet extends MLet {
127
public URL check(String version,
128
URL codebase,
129
String jarfile,
130
MLetContent content) {
131
return content.getCodeBase();
132
}
133
}
134
135
private static final String archive = "my jarfile";
136
private static final String code = "my code";
137
private static final String object = "my object";
138
private static final String name = "my name";
139
private static final String version = "my version";
140
141
private static final String myfile = "My file";
142
private static final String baseUrl = "file:/tmp/test/";
143
144
private final static String codebase = "my code base/";
145
}
146
147