Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openj9
Path: blob/master/test/functional/CacheManagement/src/tests/sharedclasses/options/TestControlDirCacheDir02.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
26
import java.io.File;
27
import java.io.IOException;
28
29
30
import tests.sharedclasses.TestUtils;
31
32
/*
33
* Check that controlDir and cacheDir work the same. Set the cacheDir, create a non-persistent cache and use it
34
* then reset cacheDir and point controlDir at the same place and check we can see the same cache.
35
*/
36
public class TestControlDirCacheDir02 extends TestUtils {
37
public static void main(String[] args) {
38
runDestroyAllCaches();
39
40
String dir = createTemporaryDirectory("TestControlDirCacheDir02");
41
String currentCacheDir = getCacheDir();
42
String currentControlDir = getControlDir();
43
try {
44
// tidyup before we go...
45
setCacheDir(null);setControlDir(null);
46
runDestroyAllCaches();
47
setCacheDir(currentCacheDir);setControlDir(currentControlDir);
48
49
setCacheDir(dir);
50
51
runDestroyAllCaches();
52
createNonPersistentCache("Foo");
53
runSimpleJavaProgramWithNonPersistentCache("Foo");
54
checkForSuccessfulNonPersistentCacheOpenMessage("Foo");
55
checkFileExistsForNonPersistentCache("Foo");
56
57
setCacheDir(null);
58
checkFileDoesNotExistForNonPersistentCache("Foo");
59
60
setControlDir(dir);
61
checkFileExistsForNonPersistentCache("Foo");
62
63
runSimpleJavaProgramWithNonPersistentCache("Foo");
64
checkForSuccessfulNonPersistentCacheOpenMessage("Foo");
65
66
// Delete the cache and check it has vanished when viewed via cacheDir
67
destroyNonPersistentCache("Foo");
68
setControlDir(null);
69
setCacheDir(dir);
70
checkFileDoesNotExistForNonPersistentCache("Foo");
71
} finally {
72
setCacheDir(currentCacheDir);
73
setControlDir(currentControlDir);
74
deleteTemporaryDirectory(dir);
75
}
76
}
77
}
78
79