Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/java/util/Properties/LoadParsing2.java
41149 views
1
/*
2
* Copyright (c) 2018, 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 4881291 4094886
27
* @summary checks for processing errors in properties.load
28
*/
29
30
import java.io.File;
31
import java.io.FileInputStream;
32
import java.io.InputStream;
33
import java.io.InputStreamReader;
34
import java.util.Properties;
35
36
public class LoadParsing2 {
37
public static void main(String[] argv) throws Exception {
38
for (int i = 0; i < dfiles.length; i++) {
39
test(dfiles[i], keys[i], values[i], true);
40
test(dfiles[i], keys[i], values[i], false);
41
}
42
}
43
44
private static Properties getLoadedProperties(InputStream is,
45
boolean doStream)
46
throws Exception
47
{
48
Properties props = new Properties();
49
if (doStream)
50
props.load(is);
51
else
52
props.load(new InputStreamReader(is, "UTF-8"));
53
return props;
54
}
55
56
private static void test(String fnData,
57
String[] keys,
58
String[] values,
59
boolean doStream)
60
throws Exception
61
{
62
File f = new File(System.getProperty("test.src", "."), fnData);
63
FileInputStream myIn = new FileInputStream(f);
64
Properties myProps = getLoadedProperties(myIn, doStream);
65
for (int i = 0; i < keys.length; i++) {
66
if (!myProps.getProperty(keys[i]).equals(values[i])) {
67
throw new RuntimeException("Test1: Bad parsing at " + i);
68
}
69
}
70
}
71
72
static String[] keys1 = {
73
"\\",
74
"\\:key12",
75
"key16 b",
76
"key14_asdfa",
77
"\\\\",
78
"key8notassign",
79
"key17",
80
"key15",
81
"keyabcdef",
82
"key13dialog.3",
83
"key7",
84
"key6",
85
"key5",
86
"key3",
87
"key2",
88
"key1",
89
"key9 Term",
90
"key0"
91
};
92
93
static String[] keys2 = {
94
"key1",
95
"key2"
96
};
97
98
static String[] keys3 = {
99
"key1",
100
"key2"
101
};
102
103
static String[] values1 = {
104
"key10=bar",
105
"bar2",
106
" abcdef",
107
"",
108
"key11=bar2",
109
"abcdef",
110
"#barbaz",
111
" abcdef",
112
"",
113
"",
114
"Symbol,SYMBOL_CHARSET ",
115
"WingDings,SYMBOL_CHARSET \\abc",
116
"==Arial,ANSI_CHARSET",
117
"",
118
"= abcde",
119
"value1",
120
"ABCDE",
121
"abcd"
122
};
123
124
static String[] values2 = {
125
"-monotype-timesnewroman-regular-r---*-%d-*-*-p-*-iso8859-1serif.1a-monotype-timesnewroman-regular-r-normal--*-%d-*-*-p-*-iso8859-2serif.2a-b&h-LucidaBrightLat4-Normal-r-normal--*-%d-*-*-p-*-iso8859-4serif.3a-monotype-times-regular-r-normal--*-%d-*-*-p-*-iso8859-5serif.4a-monotype-timesnewromangreek-regular-r-normal--*-%d-*-*-p-*-iso8859-7serif.5a-monotype-times-regular-r-normal--*-%d-*-*-p-*-iso8859-9serif.6a-monotype-times-regular-r-normal--*-%d-*-*-p-*-iso8859-15serif.7a-hanyi-ming-medium-r-normal--*-%d-*-*-m-*-big5-1serif.8a-sun-song-medium-r-normal--*-%d-*-*-c-*-gb2312.1980-0serif.9a-ricoh-hgminchol-medium-r-normal--*-%d-*-*-m-*-jisx0201.1976-0serif.10a-ricoh-hgminchol-medium-r-normal--*-%d-*-*-m-*-jisx0208.1983-0serif.11a-ricoh-heiseimin-w3-r-normal--*-%d-*-*-m-*-jisx0212.1990-0serif.12a-hanyang-myeongjo-medium-r-normal--*-%d-*-*-m-*-ksc5601.1992-3serif.13a-urw-itczapfdingbats-medium-r-normal--*-%d-*-*-p-*-sun-fontspecificserif.14a-*-symbol-medium-r-normal--*-%d-*-*-p-*-sun-fontspecificbserif.italic.0=-monotype-timesbnewbroman-regular-i---*-%d-*-*-p-*-iso8859-1bserif.italic.1=-monotype-timesbnewbroman-regular-i-normal-italic-*-%d-*-*-p-*-iso8859-2",
126
"-b&h-LucidaBrightLat4-normal-i-normal-Italic-*-%d-*-*-p-*-iso8859-4"
127
};
128
129
static String[] values3 = {
130
"-monotype-times new roman-regular-r---*-%d-*-*-p-*-iso8859-1, -monotype-times new roman-regular-r-normal--*-%d-*-*-p-*-iso8859-2, -b&h-LucidaBrightLat4-Normal-r-normal--*-%d-*-*-p-*-iso8859-4, -monotype-times-regular-r-normal--*-%d-*-*-p-*-iso8859-5, -monotype-times new roman greek-regular-r-normal--*-%d-*-*-p-*-iso8859-7, -monotype-times-regular-r-normal--*-%d-*-*-p-*-iso8859-9, -monotype-times-regular-r-normal--*-%d-*-*-p-*-iso8859-15, -hanyi-ming-medium-r-normal--*-%d-*-*-m-*-big5-1, -sun-song-medium-r-normal--*-%d-*-*-c-*-gb2312.1980-0, -ricoh-hg gothic b-medium-r-normal--*-%d-*-*-m-*-jisx0201.1976-0, -ricoh-hg gothic b-medium-r-normal-*-*-%d-*-*-m-*-jisx0208.1983-0, -ricoh-heiseimin-w3-r-normal--*-%d-*-*-m-*-jisx0212.1990-0, -hanyang-myeongjo-medium-r-normal--*-%d-*-*-m-*-ksc5601.1992-3",
131
"-monotype-times new roman-regular-i---*-%d-*-*-p-*-iso8859-1, -monotype-times new roman-regular-i-normal-italic-*-%d-*-*-p-*-iso8859-2, -b&h-LucidaBrightLat4-normal-i-normal-Italic-*-%d-*-*-p-*-iso8859-4, -monotype-times-regular-i-normal-italic-*-%d-*-*-p-*-iso8859-5, -monotype-times new roman greek-regular-i-normal--*-%d-*-*-p-*-iso8859-7, -monotype-times-regular-i-normal-italic-*-%d-*-*-p-*-iso8859-9, -monotype-times-regular-i-normal--*-%d-*-*-p-*-iso8859-15, -hanyi-ming-medium-r-normal--*-%d-*-*-m-*-big5-1, -sun-song-medium-r-normal--*-%d-*-*-c-*-gb2312.1980-0, -ricoh-hg gothic b-medium-r-normal--*-%d-*-*-m-*-jisx0201.1976-0, -ricoh-hg gothic b-medium-r-normal-*-*-%d-*-*-m-*-jisx0208.1983-0, -ricoh-heiseimin-w3-r-normal--*-%d-*-*-m-*-jisx0212.1990-0, -hanyang-myeongjo-medium-r-normal--*-%d-*-*-m-*-ksc5601.1992-3"
132
};
133
134
static String[][] keys = {keys1, keys1, keys2, keys2, keys3};
135
static String[][] values = {values1, values1, values2, values2, values3};
136
static String[] dfiles = {
137
"testData1",
138
"testData1.dos",
139
"testData2",
140
"testData2.dos",
141
"testData3.dos"
142
};
143
}
144
145