aboutsummaryrefslogtreecommitdiff
path: root/java/org
diff options
context:
space:
mode:
authorEugene Kliuchnikov <eustas@google.com>2018-06-04 17:53:16 +0200
committerGitHub <noreply@github.com>2018-06-04 17:53:16 +0200
commit1e7ea1d8e61b7cd51149a2dd491bc86ff8ef460c (patch)
tree254df89394022cf8d5abe6070483887ebd98d6a1 /java/org
parent29dc2cce9090d6c92c908116e11373bc7fdc8ad1 (diff)
downloadbrotli-1e7ea1d8e61b7cd51149a2dd491bc86ff8ef460c.zip
brotli-1e7ea1d8e61b7cd51149a2dd491bc86ff8ef460c.tar.gz
brotli-1e7ea1d8e61b7cd51149a2dd491bc86ff8ef460c.tar.bz2
Inverse bazel project/workspace tree (#677)
* Inverse bazel workspace tree. Now each subproject directly depends on root (c) project. This helps to mitigate Bazel bug bazelbuild/bazel#2391; short summary: Bazel does not work if referenced subproject `WORKSPACE` uses any repositories that embedding project does not. Bright side: building C project is much faster; no need to download closure, go and JDK...
Diffstat (limited to 'java/org')
-rw-r--r--java/org/brotli/dec/DictionaryData.java1
-rw-r--r--java/org/brotli/integration/BUILD20
-rw-r--r--java/org/brotli/wrapper/common/BUILD38
-rw-r--r--java/org/brotli/wrapper/common/SetRfcDictionaryTest.java37
-rw-r--r--java/org/brotli/wrapper/dec/BUILD41
-rw-r--r--java/org/brotli/wrapper/enc/BUILD45
6 files changed, 75 insertions, 107 deletions
diff --git a/java/org/brotli/dec/DictionaryData.java b/java/org/brotli/dec/DictionaryData.java
index 2355b28..a65e812 100644
--- a/java/org/brotli/dec/DictionaryData.java
+++ b/java/org/brotli/dec/DictionaryData.java
@@ -53,6 +53,7 @@ final class DictionaryData {
static {
ByteBuffer dictionary = ByteBuffer.allocateDirect(122784);
unpackDictionaryData(dictionary, DATA0, DATA1, SKIP_FLIP);
+ dictionary.flip();
Dictionary.setData(dictionary.asReadOnlyBuffer());
}
}
diff --git a/java/org/brotli/integration/BUILD b/java/org/brotli/integration/BUILD
index fc49e28..5b77325 100644
--- a/java/org/brotli/integration/BUILD
+++ b/java/org/brotli/integration/BUILD
@@ -5,9 +5,9 @@ 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__",
+ "//org/brotli/wrapper/common:__pkg__",
+ "//org/brotli/wrapper/dec:__pkg__",
+ "//org/brotli/wrapper/enc:__pkg__",
],
)
@@ -15,8 +15,8 @@ java_library(
name = "bundle_helper",
srcs = ["BundleHelper.java"],
visibility = [
- "//java/org/brotli/wrapper/dec:__pkg__",
- "//java/org/brotli/wrapper/enc:__pkg__",
+ "//org/brotli/wrapper/dec:__pkg__",
+ "//org/brotli/wrapper/enc:__pkg__",
],
)
@@ -25,7 +25,7 @@ java_library(
srcs = ["BundleChecker.java"],
deps = [
":bundle_helper",
- "//java/org/brotli/dec",
+ "//org/brotli/dec",
],
)
@@ -37,7 +37,7 @@ java_binary(
java_test(
name = "bundle_checker_data_test",
- args = ["java/org/brotli/integration/test_data.zip"],
+ args = ["org/brotli/integration/test_data.zip"],
data = ["test_data.zip"],
main_class = "org.brotli.integration.BundleChecker",
use_testrunner = 0,
@@ -48,7 +48,7 @@ java_test(
name = "bundle_checker_fuzz_test",
args = [
"-s",
- "java/org/brotli/integration/fuzz_data.zip",
+ "org/brotli/integration/fuzz_data.zip",
],
data = ["fuzz_data.zip"],
main_class = "org.brotli.integration.BundleChecker",
@@ -60,7 +60,7 @@ filegroup(
name = "test_data",
srcs = ["test_data.zip"],
visibility = [
- "//java/org/brotli/wrapper/dec:__pkg__",
+ "//org/brotli/wrapper/dec:__pkg__",
],
)
@@ -68,6 +68,6 @@ filegroup(
name = "test_corpus",
srcs = ["test_corpus.zip"],
visibility = [
- "//java/org/brotli/wrapper/enc:__pkg__",
+ "//org/brotli/wrapper/enc:__pkg__",
],
)
diff --git a/java/org/brotli/wrapper/common/BUILD b/java/org/brotli/wrapper/common/BUILD
index 8816a20..48b02f3 100644
--- a/java/org/brotli/wrapper/common/BUILD
+++ b/java/org/brotli/wrapper/common/BUILD
@@ -20,45 +20,41 @@ java_library(
),
)
+java_library(
+ name = "test_lib",
+ testonly = 1,
+ srcs = glob(["*Test*.java"]),
+ deps = [
+ ":common",
+ "//org/brotli/dec",
+ "//org/brotli/integration:brotli_jni_test_base",
+ "//org/brotli/wrapper/dec",
+ "@junit_junit//jar",
+ ],
+)
+
java_test(
name = "SetZeroDictionaryTest",
+ test_class = "org.brotli.wrapper.common.SetZeroDictionaryTest",
size = "small",
- srcs = ["SetZeroDictionaryTest.java"],
data = [
":brotli_jni_no_dictionary_data", # Bazel JNI workaround
],
jvm_flags = [
"-DBROTLI_JNI_LIBRARY=$(location :brotli_jni_no_dictionary_data)",
],
- deps = [
- ":common",
- "//java/org/brotli/integration:brotli_jni_test_base",
- "//java/org/brotli/wrapper/dec",
- "@junit_junit//jar",
- ],
-)
-
-filegroup(
- name = "rfc_dictionary",
- srcs = ["//:dictionary"],
+ runtime_deps = [":test_lib"],
)
java_test(
name = "SetRfcDictionaryTest",
+ test_class = "org.brotli.wrapper.common.SetRfcDictionaryTest",
size = "small",
- srcs = ["SetRfcDictionaryTest.java"],
data = [
- ":rfc_dictionary",
":brotli_jni_no_dictionary_data", # Bazel JNI workaround
],
jvm_flags = [
- "-DRFC_DICTIONARY=$(location :rfc_dictionary)",
"-DBROTLI_JNI_LIBRARY=$(location :brotli_jni_no_dictionary_data)",
],
- deps = [
- ":common",
- "//java/org/brotli/integration:brotli_jni_test_base",
- "//java/org/brotli/wrapper/dec",
- "@junit_junit//jar",
- ],
+ runtime_deps = [":test_lib"],
)
diff --git a/java/org/brotli/wrapper/common/SetRfcDictionaryTest.java b/java/org/brotli/wrapper/common/SetRfcDictionaryTest.java
index 0c20f1c..8aecf5f 100644
--- a/java/org/brotli/wrapper/common/SetRfcDictionaryTest.java
+++ b/java/org/brotli/wrapper/common/SetRfcDictionaryTest.java
@@ -11,11 +11,12 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
+import org.brotli.dec.Dictionary;
import org.brotli.integration.BrotliJniTestBase;
import org.brotli.wrapper.dec.BrotliInputStream;
import java.io.ByteArrayInputStream;
-import java.io.FileInputStream;
import java.io.IOException;
+import java.nio.ByteBuffer;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import org.junit.Test;
@@ -29,35 +30,18 @@ import org.junit.runners.JUnit4;
public class SetRfcDictionaryTest extends BrotliJniTestBase {
@Test
- public void testRfcDictionaryChecksums() throws IOException, NoSuchAlgorithmException {
- FileInputStream dictionary = new FileInputStream(System.getProperty("RFC_DICTIONARY"));
- byte[] data = new byte[BrotliCommon.RFC_DICTIONARY_SIZE + 1];
- int offset = 0;
- try {
- int readBytes;
- while ((readBytes = dictionary.read(data, offset, data.length - offset)) != -1) {
- offset += readBytes;
- if (offset > BrotliCommon.RFC_DICTIONARY_SIZE) {
- break;
- }
- }
- } finally {
- dictionary.close();
- }
- if (offset != BrotliCommon.RFC_DICTIONARY_SIZE) {
- fail("dictionary size mismatch");
- }
-
+ public void testRfcDictionaryChecksums() throws NoSuchAlgorithmException {
+ System.err.println(Dictionary.getData().slice().remaining());
MessageDigest md5 = MessageDigest.getInstance("MD5");
- md5.update(data, 0, offset);
+ md5.update(Dictionary.getData().slice());
assertTrue(BrotliCommon.checkDictionaryDataMd5(md5.digest()));
MessageDigest sha1 = MessageDigest.getInstance("SHA-1");
- sha1.update(data, 0, offset);
+ sha1.update(Dictionary.getData().slice());
assertTrue(BrotliCommon.checkDictionaryDataSha1(sha1.digest()));
MessageDigest sha256 = MessageDigest.getInstance("SHA-256");
- sha256.update(data, 0, offset);
+ sha256.update(Dictionary.getData().slice());
assertTrue(BrotliCommon.checkDictionaryDataSha256(sha256.digest()));
}
@@ -66,12 +50,7 @@ public class SetRfcDictionaryTest extends BrotliJniTestBase {
/* "leftdatadataleft" encoded with dictionary words. */
byte[] data = {27, 15, 0, 0, 0, 0, -128, -29, -76, 13, 0, 0, 7, 91, 38, 49, 64, 2, 0, -32, 78,
27, 65, -128, 32, 80, 16, 36, 8, 6};
- FileInputStream dictionary = new FileInputStream(System.getProperty("RFC_DICTIONARY"));
- try {
- BrotliCommon.setDictionaryData(dictionary);
- } finally {
- dictionary.close();
- }
+ BrotliCommon.setDictionaryData(Dictionary.getData());
BrotliInputStream decoder = new BrotliInputStream(new ByteArrayInputStream(data));
byte[] output = new byte[17];
diff --git a/java/org/brotli/wrapper/dec/BUILD b/java/org/brotli/wrapper/dec/BUILD
index c8808fa..fcf0dbf 100644
--- a/java/org/brotli/wrapper/dec/BUILD
+++ b/java/org/brotli/wrapper/dec/BUILD
@@ -15,6 +15,18 @@ java_library(
),
)
+java_library(
+ name = "test_lib",
+ testonly = 1,
+ srcs = glob(["*Test*.java"]),
+ deps = [
+ ":dec",
+ "//org/brotli/integration:brotli_jni_test_base",
+ "//org/brotli/integration:bundle_helper",
+ "@junit_junit//jar",
+ ],
+)
+
filegroup(
name = "brotli_jni",
srcs = ["//:brotli_jni.dll"],
@@ -22,13 +34,13 @@ filegroup(
filegroup(
name = "test_bundle",
- srcs = ["//java/org/brotli/integration:test_data"],
+ srcs = ["//org/brotli/integration:test_data"],
)
java_test(
name = "BrotliDecoderChannelTest",
+ test_class = "org.brotli.wrapper.dec.BrotliDecoderChannelTest",
size = "large",
- srcs = ["BrotliDecoderChannelTest.java"],
data = [
":brotli_jni", # Bazel JNI workaround
":test_bundle",
@@ -37,18 +49,13 @@ java_test(
"-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",
- ],
+ runtime_deps = [":test_lib"],
)
java_test(
name = "BrotliInputStreamTest",
+ test_class = "org.brotli.wrapper.dec.BrotliInputStreamTest",
size = "large",
- srcs = ["BrotliInputStreamTest.java"],
data = [
":brotli_jni", # Bazel JNI workaround
":test_bundle",
@@ -57,18 +64,13 @@ java_test(
"-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",
- ],
+ runtime_deps = [":test_lib"],
)
java_test(
name = "DecoderTest",
+ test_class = "org.brotli.wrapper.dec.DecoderTest",
size = "large",
- srcs = ["DecoderTest.java"],
data = [
":brotli_jni", # Bazel JNI workaround
":test_bundle",
@@ -77,10 +79,5 @@ java_test(
"-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",
- ],
+ runtime_deps = [":test_lib"],
)
diff --git a/java/org/brotli/wrapper/enc/BUILD b/java/org/brotli/wrapper/enc/BUILD
index 6ea048c..42ad23e 100644
--- a/java/org/brotli/wrapper/enc/BUILD
+++ b/java/org/brotli/wrapper/enc/BUILD
@@ -20,15 +20,28 @@ java_library(
),
)
+java_library(
+ name = "test_lib",
+ testonly = 1,
+ srcs = glob(["*Test*.java"]),
+ deps = [
+ ":enc",
+ "//org/brotli/integration:brotli_jni_test_base",
+ "//org/brotli/integration:bundle_helper",
+ "//org/brotli/wrapper/dec",
+ "@junit_junit//jar",
+ ],
+)
+
filegroup(
name = "test_bundle",
- srcs = ["//java/org/brotli/integration:test_corpus"],
+ srcs = ["//org/brotli/integration:test_corpus"],
)
java_test(
name = "BrotliEncoderChannelTest",
+ test_class = "org.brotli.wrapper.enc.BrotliEncoderChannelTest",
size = "large",
- srcs = ["BrotliEncoderChannelTest.java"],
data = [
":brotli_jni", # Bazel JNI workaround
":test_bundle",
@@ -38,19 +51,13 @@ java_test(
"-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",
- ],
+ runtime_deps = [":test_lib"],
)
java_test(
name = "BrotliOutputStreamTest",
+ test_class = "org.brotli.wrapper.enc.BrotliOutputStreamTest",
size = "large",
- srcs = ["BrotliOutputStreamTest.java"],
data = [
":brotli_jni", # Bazel JNI workaround
":test_bundle",
@@ -60,19 +67,13 @@ java_test(
"-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",
- ],
+ runtime_deps = [":test_lib"],
)
java_test(
name = "EncoderTest",
+ test_class = "org.brotli.wrapper.enc.EncoderTest",
size = "large",
- srcs = ["EncoderTest.java"],
data = [
":brotli_jni", # Bazel JNI workaround
":test_bundle",
@@ -82,11 +83,5 @@ java_test(
"-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",
- ],
+ runtime_deps = [":test_lib"],
)