This commit is contained in:
31
jwo-test/build.gradle
Normal file
31
jwo-test/build.gradle
Normal file
@@ -0,0 +1,31 @@
|
||||
plugins {
|
||||
id 'java-library'
|
||||
alias(catalog.plugins.lombok)
|
||||
}
|
||||
|
||||
import org.gradle.api.attributes.LibraryElements
|
||||
import static org.gradle.api.attributes.LibraryElements.LIBRARY_ELEMENTS_ATTRIBUTE
|
||||
import static org.gradle.api.attributes.LibraryElements.JAR
|
||||
|
||||
configurations {
|
||||
testImplementation {
|
||||
attributes {
|
||||
attribute(LIBRARY_ELEMENTS_ATTRIBUTE, project.objects.named(LibraryElements.class, JAR))
|
||||
}
|
||||
}
|
||||
|
||||
testRuntimeClasspath {
|
||||
attributes {
|
||||
attribute(LIBRARY_ELEMENTS_ATTRIBUTE, project.objects.named(LibraryElements.class, JAR))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
java {
|
||||
modularity.inferModulePath = true
|
||||
}
|
||||
|
||||
dependencies {
|
||||
testImplementation project(':jwo-test-module')
|
||||
testImplementation project(':')
|
||||
}
|
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