aboutsummaryrefslogtreecommitdiff
path: root/java
diff options
context:
space:
mode:
Diffstat (limited to 'java')
-rwxr-xr-xjava/org/brotli/integration/BUILD10
-rwxr-xr-xjava/org/brotli/integration/BrotliJniTestBase.java13
-rwxr-xr-xjava/org/brotli/wrapper/common/BUILD37
-rwxr-xr-xjava/org/brotli/wrapper/common/SetRfcDictionaryTest.java9
-rwxr-xr-xjava/org/brotli/wrapper/common/SetZeroDictionaryTest.java9
-rwxr-xr-xjava/org/brotli/wrapper/dec/BUILD33
-rwxr-xr-xjava/org/brotli/wrapper/dec/BrotliDecoderChannelTest.java9
-rwxr-xr-xjava/org/brotli/wrapper/dec/BrotliInputStreamTest.java9
-rwxr-xr-xjava/org/brotli/wrapper/dec/DecoderTest.java9
-rwxr-xr-xjava/org/brotli/wrapper/enc/BUILD33
-rwxr-xr-xjava/org/brotli/wrapper/enc/BrotliEncoderChannelTest.java9
-rwxr-xr-xjava/org/brotli/wrapper/enc/BrotliOutputStreamTest.java9
-rwxr-xr-xjava/org/brotli/wrapper/enc/EncoderTest.java10
13 files changed, 103 insertions, 96 deletions
diff --git a/java/org/brotli/integration/BUILD b/java/org/brotli/integration/BUILD
index ac9bc2c..fc49e28 100755
--- a/java/org/brotli/integration/BUILD
+++ b/java/org/brotli/integration/BUILD
@@ -2,6 +2,16 @@
# Integration test runner + corpus for Java port of Brotli decoder.
java_library(
+ name = "brotli_jni_test_base",
+ srcs = ["BrotliJniTestBase.java"],
+ visibility = [
+ "//java/org/brotli/wrapper/common:__pkg__",
+ "//java/org/brotli/wrapper/dec:__pkg__",
+ "//java/org/brotli/wrapper/enc:__pkg__",
+ ],
+)
+
+java_library(
name = "bundle_helper",
srcs = ["BundleHelper.java"],
visibility = [
diff --git a/java/org/brotli/integration/BrotliJniTestBase.java b/java/org/brotli/integration/BrotliJniTestBase.java
new file mode 100755
index 0000000..4d699d5
--- /dev/null
+++ b/java/org/brotli/integration/BrotliJniTestBase.java
@@ -0,0 +1,13 @@
+package org.brotli.integration;
+
+/**
+ * Optionally loads brotli JNI wrapper native library.
+ */
+public class BrotliJniTestBase {
+ static {
+ String jniLibrary = System.getProperty("BROTLI_JNI_LIBRARY");
+ if (jniLibrary != null) {
+ System.load(new java.io.File(jniLibrary).getAbsolutePath());
+ }
+ }
+} \ No newline at end of file
diff --git a/java/org/brotli/wrapper/common/BUILD b/java/org/brotli/wrapper/common/BUILD
index 8623272..8816a20 100755
--- a/java/org/brotli/wrapper/common/BUILD
+++ b/java/org/brotli/wrapper/common/BUILD
@@ -7,37 +7,32 @@ filegroup(
srcs = ["common_jni.cc"],
)
-#########################################
-# WARNING: do not depend on this target!
-#########################################
-java_library(
- name = "common_no_dictionary_data",
- srcs = glob(
- ["*.java"],
- exclude = ["*Test*.java"],
- ),
- deps = ["//:jni_no_dictionary_data"],
+filegroup(
+ name = "brotli_jni_no_dictionary_data",
+ srcs = ["//:brotli_jni_no_dictionary_data.dll"],
)
-#########################################
-# WARNING: do not depend on this target!
-#########################################
java_library(
name = "common",
srcs = glob(
["*.java"],
exclude = ["*Test*.java"],
),
- deps = ["//:jni"],
)
java_test(
name = "SetZeroDictionaryTest",
size = "small",
srcs = ["SetZeroDictionaryTest.java"],
- data = ["//:jni_no_dictionary_data"], # Bazel JNI workaround
+ data = [
+ ":brotli_jni_no_dictionary_data", # Bazel JNI workaround
+ ],
+ jvm_flags = [
+ "-DBROTLI_JNI_LIBRARY=$(location :brotli_jni_no_dictionary_data)",
+ ],
deps = [
- ":common_no_dictionary_data",
+ ":common",
+ "//java/org/brotli/integration:brotli_jni_test_base",
"//java/org/brotli/wrapper/dec",
"@junit_junit//jar",
],
@@ -54,11 +49,15 @@ java_test(
srcs = ["SetRfcDictionaryTest.java"],
data = [
":rfc_dictionary",
- "//:jni_no_dictionary_data", # Bazel JNI workaround
+ ":brotli_jni_no_dictionary_data", # Bazel JNI workaround
+ ],
+ jvm_flags = [
+ "-DRFC_DICTIONARY=$(location :rfc_dictionary)",
+ "-DBROTLI_JNI_LIBRARY=$(location :brotli_jni_no_dictionary_data)",
],
- jvm_flags = ["-DRFC_DICTIONARY=$(location :rfc_dictionary)"],
deps = [
- ":common_no_dictionary_data",
+ ":common",
+ "//java/org/brotli/integration:brotli_jni_test_base",
"//java/org/brotli/wrapper/dec",
"@junit_junit//jar",
],
diff --git a/java/org/brotli/wrapper/common/SetRfcDictionaryTest.java b/java/org/brotli/wrapper/common/SetRfcDictionaryTest.java
index 8577800..0c20f1c 100755
--- a/java/org/brotli/wrapper/common/SetRfcDictionaryTest.java
+++ b/java/org/brotli/wrapper/common/SetRfcDictionaryTest.java
@@ -11,6 +11,7 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
+import org.brotli.integration.BrotliJniTestBase;
import org.brotli.wrapper.dec.BrotliInputStream;
import java.io.ByteArrayInputStream;
import java.io.FileInputStream;
@@ -25,13 +26,7 @@ import org.junit.runners.JUnit4;
* Tests for {@link BrotliCommon}.
*/
@RunWith(JUnit4.class)
-public class SetRfcDictionaryTest {
-
- // TODO: remove when Bazel get JNI support.
- static {
- System.load(new java.io.File(new java.io.File(System.getProperty("java.library.path")),
- "liblibjni_Uno_Udictionary_Udata.so").getAbsolutePath());
- }
+public class SetRfcDictionaryTest extends BrotliJniTestBase {
@Test
public void testRfcDictionaryChecksums() throws IOException, NoSuchAlgorithmException {
diff --git a/java/org/brotli/wrapper/common/SetZeroDictionaryTest.java b/java/org/brotli/wrapper/common/SetZeroDictionaryTest.java
index 9046e31..669939c 100755
--- a/java/org/brotli/wrapper/common/SetZeroDictionaryTest.java
+++ b/java/org/brotli/wrapper/common/SetZeroDictionaryTest.java
@@ -9,6 +9,7 @@ package org.brotli.wrapper.common;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
+import org.brotli.integration.BrotliJniTestBase;
import org.brotli.wrapper.dec.BrotliInputStream;
import java.io.ByteArrayInputStream;
import java.io.IOException;
@@ -20,13 +21,7 @@ import org.junit.runners.JUnit4;
* Tests for {@link BrotliCommon}.
*/
@RunWith(JUnit4.class)
-public class SetZeroDictionaryTest {
-
- // TODO: remove when Bazel get JNI support.
- static {
- System.load(new java.io.File(new java.io.File(System.getProperty("java.library.path")),
- "liblibjni_Uno_Udictionary_Udata.so").getAbsolutePath());
- }
+public class SetZeroDictionaryTest extends BrotliJniTestBase {
@Test
public void testZeroDictionary() throws IOException {
diff --git a/java/org/brotli/wrapper/dec/BUILD b/java/org/brotli/wrapper/dec/BUILD
index 58ab3d4..c8808fa 100755
--- a/java/org/brotli/wrapper/dec/BUILD
+++ b/java/org/brotli/wrapper/dec/BUILD
@@ -7,16 +7,17 @@ filegroup(
srcs = ["decoder_jni.cc"],
)
-#########################################
-# WARNING: do not depend on this target!
-#########################################
java_library(
name = "dec",
srcs = glob(
["*.java"],
exclude = ["*Test*.java"],
),
- deps = ["//:jni"],
+)
+
+filegroup(
+ name = "brotli_jni",
+ srcs = ["//:brotli_jni.dll"],
)
filegroup(
@@ -29,12 +30,16 @@ java_test(
size = "large",
srcs = ["BrotliDecoderChannelTest.java"],
data = [
+ ":brotli_jni", # Bazel JNI workaround
":test_bundle",
- "//:jni", # Bazel JNI workaround
],
- jvm_flags = ["-DTEST_BUNDLE=$(location :test_bundle)"],
+ jvm_flags = [
+ "-DBROTLI_JNI_LIBRARY=$(location :brotli_jni)",
+ "-DTEST_BUNDLE=$(location :test_bundle)",
+ ],
deps = [
":dec",
+ "//java/org/brotli/integration:brotli_jni_test_base",
"//java/org/brotli/integration:bundle_helper",
"@junit_junit//jar",
],
@@ -45,12 +50,16 @@ java_test(
size = "large",
srcs = ["BrotliInputStreamTest.java"],
data = [
+ ":brotli_jni", # Bazel JNI workaround
":test_bundle",
- "//:jni", # Bazel JNI workaround
],
- jvm_flags = ["-DTEST_BUNDLE=$(location :test_bundle)"],
+ jvm_flags = [
+ "-DBROTLI_JNI_LIBRARY=$(location :brotli_jni)",
+ "-DTEST_BUNDLE=$(location :test_bundle)",
+ ],
deps = [
":dec",
+ "//java/org/brotli/integration:brotli_jni_test_base",
"//java/org/brotli/integration:bundle_helper",
"@junit_junit//jar",
],
@@ -61,12 +70,16 @@ java_test(
size = "large",
srcs = ["DecoderTest.java"],
data = [
+ ":brotli_jni", # Bazel JNI workaround
":test_bundle",
- "//:jni", # Bazel JNI workaround
],
- jvm_flags = ["-DTEST_BUNDLE=$(location :test_bundle)"],
+ jvm_flags = [
+ "-DBROTLI_JNI_LIBRARY=$(location :brotli_jni)",
+ "-DTEST_BUNDLE=$(location :test_bundle)",
+ ],
deps = [
":dec",
+ "//java/org/brotli/integration:brotli_jni_test_base",
"//java/org/brotli/integration:bundle_helper",
"@junit_junit//jar",
],
diff --git a/java/org/brotli/wrapper/dec/BrotliDecoderChannelTest.java b/java/org/brotli/wrapper/dec/BrotliDecoderChannelTest.java
index b6fc036..71d8f68 100755
--- a/java/org/brotli/wrapper/dec/BrotliDecoderChannelTest.java
+++ b/java/org/brotli/wrapper/dec/BrotliDecoderChannelTest.java
@@ -8,6 +8,7 @@ package org.brotli.wrapper.dec;
import static org.junit.Assert.assertEquals;
+import org.brotli.integration.BrotliJniTestBase;
import org.brotli.integration.BundleHelper;
import java.io.ByteArrayInputStream;
import java.io.FileInputStream;
@@ -23,13 +24,7 @@ import org.junit.runners.AllTests;
/** Tests for {@link org.brotli.wrapper.dec.BrotliDecoderChannel}. */
@RunWith(AllTests.class)
-public class BrotliDecoderChannelTest {
-
- // TODO: remove when Bazel get JNI support.
- static {
- System.load(new java.io.File(new java.io.File(System.getProperty("java.library.path")),
- "liblibjni.so").getAbsolutePath());
- }
+public class BrotliDecoderChannelTest extends BrotliJniTestBase {
static InputStream getBundle() throws IOException {
return new FileInputStream(System.getProperty("TEST_BUNDLE"));
diff --git a/java/org/brotli/wrapper/dec/BrotliInputStreamTest.java b/java/org/brotli/wrapper/dec/BrotliInputStreamTest.java
index aec26a0..5da7115 100755
--- a/java/org/brotli/wrapper/dec/BrotliInputStreamTest.java
+++ b/java/org/brotli/wrapper/dec/BrotliInputStreamTest.java
@@ -8,6 +8,7 @@ package org.brotli.wrapper.dec;
import static org.junit.Assert.assertEquals;
+import org.brotli.integration.BrotliJniTestBase;
import org.brotli.integration.BundleHelper;
import java.io.ByteArrayInputStream;
import java.io.FileInputStream;
@@ -21,13 +22,7 @@ import org.junit.runners.AllTests;
/** Tests for {@link org.brotli.wrapper.dec.BrotliInputStream}. */
@RunWith(AllTests.class)
-public class BrotliInputStreamTest {
-
- // TODO: remove when Bazel get JNI support.
- static {
- System.load(new java.io.File(new java.io.File(System.getProperty("java.library.path")),
- "liblibjni.so").getAbsolutePath());
- }
+public class BrotliInputStreamTest extends BrotliJniTestBase {
static InputStream getBundle() throws IOException {
return new FileInputStream(System.getProperty("TEST_BUNDLE"));
diff --git a/java/org/brotli/wrapper/dec/DecoderTest.java b/java/org/brotli/wrapper/dec/DecoderTest.java
index 0a8970f..74b77d3 100755
--- a/java/org/brotli/wrapper/dec/DecoderTest.java
+++ b/java/org/brotli/wrapper/dec/DecoderTest.java
@@ -8,6 +8,7 @@ package org.brotli.wrapper.dec;
import static org.junit.Assert.assertEquals;
+import org.brotli.integration.BrotliJniTestBase;
import org.brotli.integration.BundleHelper;
import java.io.ByteArrayInputStream;
import java.io.FileInputStream;
@@ -21,13 +22,7 @@ import org.junit.runners.AllTests;
/** Tests for {@link org.brotli.wrapper.dec.Decoder}. */
@RunWith(AllTests.class)
-public class DecoderTest {
-
- // TODO: remove when Bazel get JNI support.
- static {
- System.load(new java.io.File(new java.io.File(System.getProperty("java.library.path")),
- "liblibjni.so").getAbsolutePath());
- }
+public class DecoderTest extends BrotliJniTestBase {
static InputStream getBundle() throws IOException {
return new FileInputStream(System.getProperty("TEST_BUNDLE"));
diff --git a/java/org/brotli/wrapper/enc/BUILD b/java/org/brotli/wrapper/enc/BUILD
index 39b1b37..6ea048c 100755
--- a/java/org/brotli/wrapper/enc/BUILD
+++ b/java/org/brotli/wrapper/enc/BUILD
@@ -7,16 +7,17 @@ filegroup(
srcs = ["encoder_jni.cc"],
)
-#########################################
-# WARNING: do not depend on this target!
-#########################################
+filegroup(
+ name = "brotli_jni",
+ srcs = ["//:brotli_jni.dll"],
+)
+
java_library(
name = "enc",
srcs = glob(
["*.java"],
exclude = ["*Test*.java"],
),
- deps = ["//:jni"],
)
filegroup(
@@ -29,13 +30,17 @@ java_test(
size = "large",
srcs = ["BrotliEncoderChannelTest.java"],
data = [
+ ":brotli_jni", # Bazel JNI workaround
":test_bundle",
- "//:jni", # Bazel JNI workaround
],
- jvm_flags = ["-DTEST_BUNDLE=$(location :test_bundle)"],
+ jvm_flags = [
+ "-DBROTLI_JNI_LIBRARY=$(location :brotli_jni)",
+ "-DTEST_BUNDLE=$(location :test_bundle)",
+ ],
shard_count = 15,
deps = [
":enc",
+ "//java/org/brotli/integration:brotli_jni_test_base",
"//java/org/brotli/integration:bundle_helper",
"//java/org/brotli/wrapper/dec",
"@junit_junit//jar",
@@ -47,13 +52,17 @@ java_test(
size = "large",
srcs = ["BrotliOutputStreamTest.java"],
data = [
+ ":brotli_jni", # Bazel JNI workaround
":test_bundle",
- "//:jni", # Bazel JNI workaround
],
- jvm_flags = ["-DTEST_BUNDLE=$(location :test_bundle)"],
+ jvm_flags = [
+ "-DBROTLI_JNI_LIBRARY=$(location :brotli_jni)",
+ "-DTEST_BUNDLE=$(location :test_bundle)",
+ ],
shard_count = 15,
deps = [
":enc",
+ "//java/org/brotli/integration:brotli_jni_test_base",
"//java/org/brotli/integration:bundle_helper",
"//java/org/brotli/wrapper/dec",
"@junit_junit//jar",
@@ -65,13 +74,17 @@ java_test(
size = "large",
srcs = ["EncoderTest.java"],
data = [
+ ":brotli_jni", # Bazel JNI workaround
":test_bundle",
- "//:jni", # Bazel JNI workaround
],
- jvm_flags = ["-DTEST_BUNDLE=$(location :test_bundle)"],
+ jvm_flags = [
+ "-DBROTLI_JNI_LIBRARY=$(location :brotli_jni)",
+ "-DTEST_BUNDLE=$(location :test_bundle)",
+ ],
shard_count = 15,
deps = [
":enc",
+ "//java/org/brotli/integration:brotli_jni_test_base",
"//java/org/brotli/integration:bundle_helper",
"//java/org/brotli/wrapper/dec",
"@junit_junit//jar",
diff --git a/java/org/brotli/wrapper/enc/BrotliEncoderChannelTest.java b/java/org/brotli/wrapper/enc/BrotliEncoderChannelTest.java
index 1ab7599..2492589 100755
--- a/java/org/brotli/wrapper/enc/BrotliEncoderChannelTest.java
+++ b/java/org/brotli/wrapper/enc/BrotliEncoderChannelTest.java
@@ -2,6 +2,7 @@ package org.brotli.wrapper.enc;
import static org.junit.Assert.assertEquals;
+import org.brotli.integration.BrotliJniTestBase;
import org.brotli.integration.BundleHelper;
import org.brotli.wrapper.dec.BrotliInputStream;
import java.io.ByteArrayInputStream;
@@ -20,19 +21,13 @@ import org.junit.runners.AllTests;
/** Tests for {@link org.brotli.wrapper.enc.BrotliEncoderChannel}. */
@RunWith(AllTests.class)
-public class BrotliEncoderChannelTest {
+public class BrotliEncoderChannelTest extends BrotliJniTestBase {
private enum TestMode {
WRITE_ALL,
WRITE_CHUNKS
}
- // TODO: remove when Bazel get JNI support.
- static {
- System.load(new java.io.File(new java.io.File(System.getProperty("java.library.path")),
- "liblibjni.so").getAbsolutePath());
- }
-
private static final int CHUNK_SIZE = 256;
static InputStream getBundle() throws IOException {
diff --git a/java/org/brotli/wrapper/enc/BrotliOutputStreamTest.java b/java/org/brotli/wrapper/enc/BrotliOutputStreamTest.java
index a436e81..699b4b2 100755
--- a/java/org/brotli/wrapper/enc/BrotliOutputStreamTest.java
+++ b/java/org/brotli/wrapper/enc/BrotliOutputStreamTest.java
@@ -2,6 +2,7 @@ package org.brotli.wrapper.enc;
import static org.junit.Assert.assertEquals;
+import org.brotli.integration.BrotliJniTestBase;
import org.brotli.integration.BundleHelper;
import org.brotli.wrapper.dec.BrotliInputStream;
import java.io.ByteArrayInputStream;
@@ -18,7 +19,7 @@ import org.junit.runners.AllTests;
/** Tests for {@link org.brotli.wrapper.enc.BrotliOutputStream}. */
@RunWith(AllTests.class)
-public class BrotliOutputStreamTest {
+public class BrotliOutputStreamTest extends BrotliJniTestBase {
private enum TestMode {
WRITE_ALL,
@@ -26,12 +27,6 @@ public class BrotliOutputStreamTest {
WRITE_BYTE
}
- // TODO: remove when Bazel get JNI support.
- static {
- System.load(new java.io.File(new java.io.File(System.getProperty("java.library.path")),
- "liblibjni.so").getAbsolutePath());
- }
-
private static final int CHUNK_SIZE = 256;
static InputStream getBundle() throws IOException {
diff --git a/java/org/brotli/wrapper/enc/EncoderTest.java b/java/org/brotli/wrapper/enc/EncoderTest.java
index 0c26882..18ed647 100755
--- a/java/org/brotli/wrapper/enc/EncoderTest.java
+++ b/java/org/brotli/wrapper/enc/EncoderTest.java
@@ -2,6 +2,7 @@ package org.brotli.wrapper.enc;
import static org.junit.Assert.assertEquals;
+import org.brotli.integration.BrotliJniTestBase;
import org.brotli.integration.BundleHelper;
import org.brotli.wrapper.dec.BrotliInputStream;
import java.io.ByteArrayInputStream;
@@ -16,14 +17,7 @@ import org.junit.runners.AllTests;
/** Tests for {@link org.brotli.wrapper.enc.Encoder}. */
@RunWith(AllTests.class)
-public class EncoderTest {
-
- // TODO: remove when Bazel get JNI support.
- static {
- System.load(new java.io.File(new java.io.File(System.getProperty("java.library.path")),
- "liblibjni.so").getAbsolutePath());
- }
-
+public class EncoderTest extends BrotliJniTestBase {
static InputStream getBundle() throws IOException {
return new FileInputStream(System.getProperty("TEST_BUNDLE"));
}