Here are the examples of the java api ht.lib taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
3 Examples
18
Source : HashesTest.java
with GNU General Public License v2.0
from hzio
with GNU General Public License v2.0
from hzio
@Test
public static void multiBaseModules() throws IOException {
Path dest = Paths.get("test2");
HashesTest ht = new HashesTest(dest);
/*
* y2 -----------> y1
* |______
* | |
* V V
* z3 -> z2
* | |
* | V
* |---> z1
*/
ht.makeModule("z1");
ht.makeModule("z2", "z1");
ht.makeModule("z3", "z1", "z2");
ht.makeModule("y1");
ht.makeModule("y2", "y1", "z2", "z3");
Set<String> ys = Set.of("y1", "y2");
Set<String> zs = Set.of("z1", "z2", "z3");
// create JMOD files
Stream.concat(ys.stream(), zs.stream()).forEach(ht::makeJmod);
// run jmod hash command
runJmod(List.of("hash", "--module-path", ht.lib.toString(), "--hash-modules", ".*"));
/*
* z1 and y1 are the modules with hashes recorded.
*/
ht.checkHashes("y1", "y2");
ht.checkHashes("z1", "z2", "z3", "y2");
Stream.concat(ys.stream(), zs.stream()).filter(mn -> !mn.equals("y1") && !mn.equals("z1")).forEach(mn -> replacedertTrue(ht.hashes(mn) == null));
}
18
Source : HashesTest.java
with GNU General Public License v2.0
from hzio
with GNU General Public License v2.0
from hzio
@Test
public static void test() throws IOException {
Path dest = Paths.get("test");
HashesTest ht = new HashesTest(dest);
// create modules for test cases
ht.makeModule("m2");
ht.makeModule("m3");
ht.makeModule("m1", "m2", "m3");
ht.makeModule("org.bar", TRANSITIVE, "m1");
ht.makeModule("org.foo", TRANSITIVE, "org.bar");
// create JMOD for m1, m2, m3
ht.makeJmod("m2");
ht.makeJmod("m3");
// no hash is recorded since m1 has outgoing edges
ht.jmodHashModules("m1", ".*");
// no hash is recorded in m1, m2, m3
replacedertTrue(ht.hashes("m1") == null);
replacedertTrue(ht.hashes("m2") == null);
replacedertTrue(ht.hashes("m3") == null);
// hash m1 in m2
ht.jmodHashModules("m2", "m1");
ht.checkHashes("m2", "m1");
// hash m1 in m2
ht.jmodHashModules("m2", ".*");
ht.checkHashes("m2", "m1");
// create m2.jmod with no hash
ht.makeJmod("m2");
// run jmod hash command to hash m1 in m2 and m3
runJmod(List.of("hash", "--module-path", ht.lib.toString(), "--hash-modules", ".*"));
ht.checkHashes("m2", "m1");
ht.checkHashes("m3", "m1");
// check transitive requires
ht.makeJmod("org.bar");
ht.makeJmod("org.foo");
ht.jmodHashModules("org.bar", "org.*");
ht.checkHashes("org.bar", "org.foo");
ht.jmodHashModules("m3", ".*");
ht.checkHashes("m3", "org.foo", "org.bar", "m1");
}
17
Source : HashesTest.java
with GNU General Public License v2.0
from hzio
with GNU General Public License v2.0
from hzio
@Test
public static void mixJmodAndJarFile() throws IOException {
Path dest = Paths.get("test3");
HashesTest ht = new HashesTest(dest);
/*
* j3 -----------> j2
* |______
* | |
* V V
* m3 -> m2
* | |
* | V
* |---> m1 -> j1 -> jdk.jlink
*/
ht.makeModule("j1");
ht.makeModule("j2");
ht.makeModule("m1", "j1");
ht.makeModule("m2", "m1");
ht.makeModule("m3", "m1", "m2");
ht.makeModule("j3", "j2", "m2", "m3");
Set<String> jars = Set.of("j1", "j2", "j3");
Set<String> jmods = Set.of("m1", "m2", "m3");
// create JMOD and JAR files
jars.forEach(ht::makeJar);
jmods.forEach(ht::makeJmod);
// run jmod hash command
runJmod(List.of("hash", "--module-path", ht.lib.toString(), "--hash-modules", "^j.*|^m.*"));
/*
* j1 and j2 are the modules with hashes recorded.
*/
ht.checkHashes("j2", "j3");
ht.checkHashes("j1", "m1", "m2", "m3", "j3");
Stream.concat(jars.stream(), jmods.stream()).filter(mn -> !mn.equals("j1") && !mn.equals("j2")).forEach(mn -> replacedertTrue(ht.hashes(mn) == null));
}