Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openj9
Path: blob/master/test/functional/CacheManagement/src/tests/sharedclasses/options/TestControlDirCacheDir01.java
6005 views
1
/*******************************************************************************
2
* Copyright (c) 2010, 2019 IBM Corp. and others
3
*
4
* This program and the accompanying materials are made available under
5
* the terms of the Eclipse Public License 2.0 which accompanies this
6
* distribution and is available at https://www.eclipse.org/legal/epl-2.0/
7
* or the Apache License, Version 2.0 which accompanies this distribution and
8
* is available at https://www.apache.org/licenses/LICENSE-2.0.
9
*
10
* This Source Code may also be made available under the following
11
* Secondary Licenses when the conditions for such availability set
12
* forth in the Eclipse Public License, v. 2.0 are satisfied: GNU
13
* General Public License, version 2 with the GNU Classpath
14
* Exception [1] and GNU General Public License, version 2 with the
15
* OpenJDK Assembly Exception [2].
16
*
17
* [1] https://www.gnu.org/software/classpath/license.html
18
* [2] http://openjdk.java.net/legal/assembly-exception.html
19
*
20
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 OR LicenseRef-GPL-2.0 WITH Assembly-exception
21
*******************************************************************************/
22
23
package tests.sharedclasses.options;
24
25
import tests.sharedclasses.TestUtils;
26
27
/*
28
* Check that controlDir and cacheDir work the same. Set the cacheDir, create a persistent cache and use it
29
* then reset cacheDir and point controlDir at the same place and check we can see the same cache.
30
*/
31
public class TestControlDirCacheDir01 extends TestUtils {
32
public static void main(String[] args) {
33
runDestroyAllCaches();
34
if (isMVS())
35
{
36
//this test checks persistent and non persistent cahces ... zos only has nonpersistent ... so we assume other tests cover this
37
return;
38
}
39
String dir = createTemporaryDirectory("TestControlDirCacheDir01");
40
String currentCacheDir = getCacheDir();
41
String currentControlDir = getControlDir();
42
try {
43
//tidy up default area
44
setCacheDir(null);setControlDir(null);
45
runDestroyAllCaches();
46
setCacheDir(currentCacheDir);setControlDir(currentControlDir);
47
48
setCacheDir(dir);
49
50
runDestroyAllCaches();
51
createPersistentCache("Foo");
52
runSimpleJavaProgramWithPersistentCache("Foo");
53
checkForSuccessfulPersistentCacheOpenMessage("Foo");
54
checkFileExistsForPersistentCache("Foo");
55
56
setCacheDir(null);
57
checkFileDoesNotExistForPersistentCache("Foo");
58
59
setControlDir(dir);
60
checkFileExistsForPersistentCache("Foo");
61
62
runSimpleJavaProgramWithPersistentCache("Foo");
63
checkForSuccessfulPersistentCacheOpenMessage("Foo");
64
65
// Delete the cache and check it has vanished when viewed via cacheDir
66
destroyPersistentCache("Foo");
67
setControlDir(null);
68
setCacheDir(dir);
69
checkFileDoesNotExistForPersistentCache("Foo");
70
} finally {
71
runDestroyAllCaches();
72
setCacheDir(currentCacheDir);
73
setControlDir(currentControlDir);
74
deleteTemporaryDirectory(dir);
75
}
76
}
77
//
78
// public static String createTemporaryDirectory() {
79
// try {
80
// File f = File.createTempFile("testSC","dir");
81
// if (!f.delete()) fail("Couldn't create the temp dir");
82
// if (!f.mkdir()) fail("Couldnt create the temp dir");
83
// return f.getAbsolutePath();
84
// } catch (IOException e) {
85
// fail("Couldnt create temp dir: "+e);
86
// return null;
87
// }
88
// }
89
}
90
91