Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/java/io/Serializable/class/NonSerializableTest.java
41154 views
1
/*
2
* Copyright (c) 2017, 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 4075221
27
* @library /test/lib
28
* @build jdk.test.lib.compiler.CompilerUtils
29
* jdk.test.lib.Utils
30
* jdk.test.lib.Asserts
31
* jdk.test.lib.JDKToolFinder
32
* jdk.test.lib.JDKToolLauncher
33
* jdk.test.lib.Platform
34
* jdk.test.lib.process.*
35
* @run testng/timeout=300 NonSerializableTest
36
* @summary Enable serialize of nonSerializable Class descriptor.
37
*/
38
39
import java.nio.file.Paths;
40
import java.util.Arrays;
41
42
import org.testng.annotations.DataProvider;
43
import org.testng.annotations.BeforeClass;
44
import org.testng.annotations.Test;
45
import static org.testng.Assert.assertTrue;
46
import static org.testng.Assert.assertEquals;
47
48
import jdk.test.lib.compiler.CompilerUtils;
49
import jdk.test.lib.process.ProcessTools;
50
51
52
public class NonSerializableTest {
53
54
@BeforeClass
55
public void setup() throws Exception {
56
boolean b = CompilerUtils.compile(
57
Paths.get(System.getProperty("test.src"), "TestEntry.java"),
58
Paths.get(System.getProperty("user.dir")));
59
assertTrue(b, "Compilation failed");
60
}
61
62
@DataProvider
63
public Object[][] provider() {
64
return new String[][][] {
65
// Write NonSerial1, Read NonSerial1
66
{{"NonSerialA_1", "-cp", ".", "TestEntry", "-s", "A"}},
67
{{"NonSerialA_1", "-cp", ".", "TestEntry", "-d"}},
68
69
// Write NonSerial1, Read NonSerial2
70
{{"NonSerialA_1", "-cp", ".", "TestEntry", "-s", "A"}},
71
{{"NonSerialA_2", "-cp", ".", "TestEntry", "-d"}},
72
73
// Write NonSerial1, Read Serial1
74
{{"NonSerialA_1", "-cp", ".", "TestEntry", "-s", "A"}},
75
{{"SerialA_1", "-cp", ".", "TestEntry", "-d"}},
76
77
// Write Serial1, Read NonSerial1
78
{{"SerialA_1", "-cp", ".", "TestEntry", "-s", "A"}},
79
{{"NonSerialA_1", "-cp", ".", "TestEntry", "-doe"}},
80
81
// Write Serial1, Read Serial2
82
{{"SerialA_1", "-cp", ".", "TestEntry", "-s", "A"}},
83
{{"SerialA_2", "-cp", ".", "TestEntry", "-d"}},
84
85
// Write Serial2, Read Serial1
86
{{"SerialA_2", "-cp", ".", "TestEntry", "-s", "A"}},
87
{{"SerialA_1", "-cp", ".", "TestEntry", "-d"}},
88
89
// Write Serial1, Read Serial3
90
{{"SerialA_1", "-cp", ".", "TestEntry", "-s", "A"}},
91
{{"SerialA_3", "-cp", ".", "TestEntry", "-de"}},
92
93
// Write Serial3, Read Serial1
94
{{"SerialA_3", "-cp", ".", "TestEntry", "-s", "A"}},
95
{{"SerialA_1", "-cp", ".", "TestEntry", "-de"}},
96
};
97
}
98
99
@Test(dataProvider="provider")
100
public void test(String[] args) throws Exception {
101
boolean b = CompilerUtils.compile(Paths.get(System.getProperty("test.src"), args[0]),
102
Paths.get(System.getProperty("user.dir")));
103
assertTrue(b, "Compilation failed");
104
String params[] = Arrays.copyOfRange(args, 1, args.length);
105
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(params);
106
Process p = ProcessTools.startProcess("Serializable Test", pb);
107
int exitValue = p.waitFor();
108
assertEquals(exitValue, 0, "Test failed");
109
}
110
}
111
112