forked from anatawa12/asar4j
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
83 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ | |
*.kt text | ||
*.json text | ||
*.asar -text | ||
*.zip -text |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
url/src/test/java/com/anatawa12/asar4j/url/ConnectionTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package com.anatawa12.asar4j.url; | ||
|
||
import com.google.common.io.ByteStreams; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.net.URL; | ||
import java.nio.charset.StandardCharsets; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertArrayEquals; | ||
|
||
public class ConnectionTest { | ||
static { | ||
FactoryRegistrar.register(); | ||
} | ||
|
||
@Test | ||
void onFileSystem() throws IOException { | ||
URL asarFile = new File(System.getProperty("com.anatawa12.asar4j.test-asar")).toURI().toURL(); | ||
URL testText = AsarURLStreamHandlerFactory.createUrl(asarFile, "test.txt"); | ||
// link | ||
URL testTextLink = AsarURLStreamHandlerFactory.createUrl(asarFile, "test.txt.1"); | ||
|
||
assertArrayEquals("test text file\n".getBytes(StandardCharsets.UTF_8), | ||
ByteStreams.toByteArray(testText.openStream())); | ||
assertArrayEquals("test text file\n".getBytes(StandardCharsets.UTF_8), | ||
ByteStreams.toByteArray(testTextLink.openStream())); | ||
} | ||
|
||
@Test | ||
void onZipFile() throws IOException { | ||
URL zipFile = new File(System.getProperty("com.anatawa12.asar4j.test-zip")).toURI().toURL(); | ||
URL asarFile = new URL("jar:" + zipFile + "!/test.asar"); | ||
URL testText = AsarURLStreamHandlerFactory.createUrl(asarFile, "test.txt"); | ||
// link | ||
URL testTextLink = AsarURLStreamHandlerFactory.createUrl(asarFile, "test.txt.1"); | ||
|
||
assertArrayEquals("test text file\n".getBytes(StandardCharsets.UTF_8), | ||
ByteStreams.toByteArray(testText.openStream())); | ||
assertArrayEquals("test text file\n".getBytes(StandardCharsets.UTF_8), | ||
ByteStreams.toByteArray(testTextLink.openStream())); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
url/src/test/java/com/anatawa12/asar4j/url/FactoryRegistrar.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.anatawa12.asar4j.url; | ||
|
||
import java.net.URL; | ||
|
||
public class FactoryRegistrar { | ||
static { | ||
URL.setURLStreamHandlerFactory(AsarURLStreamHandlerFactory.INSTANCE); | ||
} | ||
|
||
// run in static initializer | ||
public static void register() { | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
test.zip |
Binary file not shown.