This commit is contained in:
6
jwo-test/src/test/java/module-info.java
Normal file
6
jwo-test/src/test/java/module-info.java
Normal file
@@ -0,0 +1,6 @@
|
||||
open module net.woggioni.jwo.unit.test {
|
||||
requires net.woggioni.jwo;
|
||||
requires net.woggioni.jwo.test.module;
|
||||
requires org.junit.jupiter.api;
|
||||
requires static lombok;
|
||||
}
|
@@ -0,0 +1,29 @@
|
||||
package net.woggioni.jwo.test;
|
||||
|
||||
import lombok.SneakyThrows;
|
||||
import net.woggioni.jwo.JWO;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
public class JpmsUrlTest {
|
||||
@Test
|
||||
@SneakyThrows
|
||||
public void test() {
|
||||
JWO.registerUrlProtocolHandler();
|
||||
final var module = getClass().getModule();
|
||||
final var url = new URL("jpms://net.woggioni.jwo.test.module/my/test/resource/file.txt");
|
||||
System.out.println(module.getName());
|
||||
System.out.println(url.getHost());
|
||||
System.out.println(url.getPath());
|
||||
final var baos = new ByteArrayOutputStream();
|
||||
try(final var is = url.openConnection().getInputStream()) {
|
||||
JWO.copy(is, baos);
|
||||
}
|
||||
final var content = baos.toString(StandardCharsets.UTF_8);
|
||||
Assertions.assertEquals("test", content);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user