From 98cb501bc0a5611405d60e79c6b31d61967098a2 Mon Sep 17 00:00:00 2001 From: Adam Retter Date: Sat, 31 Jan 2015 19:43:09 +0000 Subject: [PATCH] Moved Java test classes into src/test/java --- .gitignore | 2 + java/Makefile | 107 +++++++------ java/rocksjni/write_batch.cc | 124 --------------- java/rocksjni/write_batch_test.cc | 148 ++++++++++++++++++ .../org/rocksdb}/AbstractComparatorTest.java | 8 +- .../org/rocksdb}/BackupableDBOptionsTest.java | 3 +- .../java/org/rocksdb}/BackupableDBTest.java | 3 +- .../rocksdb}/BlockBasedTableConfigTest.java | 3 +- .../java/org/rocksdb}/CheckPointTest.java | 6 +- .../org/rocksdb}/ColumnFamilyOptionsTest.java | 3 +- .../java/org/rocksdb}/ColumnFamilyTest.java | 3 +- .../org/rocksdb}/ComparatorOptionsTest.java | 3 +- .../java/org/rocksdb}/ComparatorTest.java | 3 +- .../org/rocksdb}/CompressionOptionsTest.java | 3 +- .../test/java/org/rocksdb}/DBOptionsTest.java | 3 +- .../org/rocksdb}/DirectComparatorTest.java | 3 +- .../java/org/rocksdb}/DirectSliceTest.java | 3 +- .../test/java/org/rocksdb}/FilterTest.java | 3 +- .../test/java/org/rocksdb}/FlushTest.java | 3 +- .../java/org/rocksdb}/InfoLogLevelTest.java | 3 +- .../java/org/rocksdb}/KeyMayExistTest.java | 3 +- .../test/java/org/rocksdb}/MemTableTest.java | 3 +- .../test/java/org/rocksdb}/MergeTest.java | 3 +- .../java/org/rocksdb}/MixedOptionsTest.java | 3 +- .../test/java/org/rocksdb}/OptionsTest.java | 3 +- .../org/rocksdb}/PlainTableConfigTest.java | 5 +- .../org/rocksdb}/PlatformRandomHelper.java | 2 +- .../test/java/org/rocksdb}/ReadOnlyTest.java | 3 +- .../java/org/rocksdb}/ReadOptionsTest.java | 3 +- .../test/java/org/rocksdb}/RocksDBTest.java | 3 +- .../test/java/org/rocksdb}/RocksEnvTest.java | 3 +- .../java/org/rocksdb}/RocksIteratorTest.java | 6 +- .../org/rocksdb}/RocksMemoryResource.java | 3 +- .../test/java/org/rocksdb}/SliceTest.java | 3 +- .../test/java/org/rocksdb}/SnapshotTest.java | 3 +- .../org/rocksdb}/StatisticsCollectorTest.java | 3 +- .../java/org/rocksdb}/StatsCallbackMock.java | 4 +- .../rocksdb}/TransactionLogIteratorTest.java | 3 +- .../test/java/org/rocksdb}/TtlDBTest.java | 3 +- .../test/java/org/rocksdb}/Types.java | 2 +- .../org/rocksdb}/WriteBatchHandlerTest.java | 5 +- .../java/org/rocksdb}/WriteBatchTest.java | 21 ++- .../org/rocksdb}/WriteBatchWithIndexTest.java | 10 +- .../java/org/rocksdb}/WriteOptionsTest.java | 3 +- .../org/rocksdb/test/RocksJunitRunner.java | 0 .../org/rocksdb/util}/EnvironmentTest.java | 3 +- .../java/org/rocksdb/util}/SizeUnitTest.java | 3 +- 47 files changed, 263 insertions(+), 283 deletions(-) create mode 100644 java/rocksjni/write_batch_test.cc rename java/{org/rocksdb/test => src/test/java/org/rocksdb}/AbstractComparatorTest.java (97%) rename java/{org/rocksdb/test => src/test/java/org/rocksdb}/BackupableDBOptionsTest.java (99%) rename java/{org/rocksdb/test => src/test/java/org/rocksdb}/BackupableDBTest.java (99%) rename java/{org/rocksdb/test => src/test/java/org/rocksdb}/BlockBasedTableConfigTest.java (99%) rename java/{org/rocksdb/test => src/test/java/org/rocksdb}/CheckPointTest.java (94%) rename java/{org/rocksdb/test => src/test/java/org/rocksdb}/ColumnFamilyOptionsTest.java (99%) rename java/{org/rocksdb/test => src/test/java/org/rocksdb}/ColumnFamilyTest.java (99%) rename java/{org/rocksdb/test => src/test/java/org/rocksdb}/ComparatorOptionsTest.java (93%) rename java/{org/rocksdb/test => src/test/java/org/rocksdb}/ComparatorTest.java (99%) rename java/{org/rocksdb/test => src/test/java/org/rocksdb}/CompressionOptionsTest.java (91%) rename java/{org/rocksdb/test => src/test/java/org/rocksdb}/DBOptionsTest.java (99%) rename java/{org/rocksdb/test => src/test/java/org/rocksdb}/DirectComparatorTest.java (97%) rename java/{org/rocksdb/test => src/test/java/org/rocksdb}/DirectSliceTest.java (98%) rename java/{org/rocksdb/test => src/test/java/org/rocksdb}/FilterTest.java (96%) rename java/{org/rocksdb/test => src/test/java/org/rocksdb}/FlushTest.java (97%) rename java/{org/rocksdb/test => src/test/java/org/rocksdb}/InfoLogLevelTest.java (98%) rename java/{org/rocksdb/test => src/test/java/org/rocksdb}/KeyMayExistTest.java (98%) rename java/{org/rocksdb/test => src/test/java/org/rocksdb}/MemTableTest.java (98%) rename java/{org/rocksdb/test => src/test/java/org/rocksdb}/MergeTest.java (99%) rename java/{org/rocksdb/test => src/test/java/org/rocksdb}/MixedOptionsTest.java (97%) rename java/{org/rocksdb/test => src/test/java/org/rocksdb}/OptionsTest.java (99%) rename java/{org/rocksdb/test => src/test/java/org/rocksdb}/PlainTableConfigTest.java (95%) rename java/{org/rocksdb/test => src/test/java/org/rocksdb}/PlatformRandomHelper.java (98%) rename java/{org/rocksdb/test => src/test/java/org/rocksdb}/ReadOnlyTest.java (99%) rename java/{org/rocksdb/test => src/test/java/org/rocksdb}/ReadOptionsTest.java (98%) rename java/{org/rocksdb/test => src/test/java/org/rocksdb}/RocksDBTest.java (99%) rename java/{org/rocksdb/test => src/test/java/org/rocksdb}/RocksEnvTest.java (96%) rename java/{org/rocksdb/test => src/test/java/org/rocksdb}/RocksIteratorTest.java (95%) rename java/{org/rocksdb/test => src/test/java/org/rocksdb}/RocksMemoryResource.java (85%) rename java/{org/rocksdb/test => src/test/java/org/rocksdb}/SliceTest.java (98%) rename java/{org/rocksdb/test => src/test/java/org/rocksdb}/SnapshotTest.java (99%) rename java/{org/rocksdb/test => src/test/java/org/rocksdb}/StatisticsCollectorTest.java (97%) rename java/{org/rocksdb/test => src/test/java/org/rocksdb}/StatsCallbackMock.java (93%) rename java/{org/rocksdb/test => src/test/java/org/rocksdb}/TransactionLogIteratorTest.java (99%) rename java/{org/rocksdb/test => src/test/java/org/rocksdb}/TtlDBTest.java (99%) rename java/{org/rocksdb/test => src/test/java/org/rocksdb}/Types.java (97%) rename java/{org/rocksdb/test => src/test/java/org/rocksdb}/WriteBatchHandlerTest.java (98%) rename java/{org/rocksdb/test => src/test/java/org/rocksdb}/WriteBatchTest.java (89%) rename java/{org/rocksdb/test => src/test/java/org/rocksdb}/WriteBatchWithIndexTest.java (95%) rename java/{org/rocksdb/test => src/test/java/org/rocksdb}/WriteOptionsTest.java (94%) rename java/{ => src/test/java}/org/rocksdb/test/RocksJunitRunner.java (100%) rename java/{org/rocksdb/test => src/test/java/org/rocksdb/util}/EnvironmentTest.java (98%) rename java/{org/rocksdb/test => src/test/java/org/rocksdb/util}/SizeUnitTest.java (93%) diff --git a/.gitignore b/.gitignore index dfd3f4924..79e5c994c 100644 --- a/.gitignore +++ b/.gitignore @@ -34,6 +34,8 @@ package/ tags java/out +java/target +java/test-libs java/*.log java/include/org_rocksdb_*.h diff --git a/java/Makefile b/java/Makefile index 8d75ee5e5..a43275c2c 100644 --- a/java/Makefile +++ b/java/Makefile @@ -36,12 +36,13 @@ NATIVE_JAVA_CLASSES = org.rocksdb.AbstractComparator\ org.rocksdb.StringAppendOperator\ org.rocksdb.WriteBatch\ org.rocksdb.WriteBatch.Handler\ - org.rocksdb.test.WriteBatchInternal\ - org.rocksdb.test.WriteBatchTest\ - org.rocksdb.WriteOptions\ + org.rocksdb.WriteOptions\ org.rocksdb.WriteBatchWithIndex\ org.rocksdb.WBWIRocksIterator +NATIVE_JAVA_TEST_CLASSES = org.rocksdb.WriteBatchTest\ + org.rocksdb.WriteBatchTestInternalHelper + ROCKSDB_MAJOR = $(shell egrep "ROCKSDB_MAJOR.[0-9]" ../include/rocksdb/version.h | cut -d ' ' -f 3) ROCKSDB_MINOR = $(shell egrep "ROCKSDB_MINOR.[0-9]" ../include/rocksdb/version.h | cut -d ' ' -f 3) ROCKSDB_PATCH = $(shell egrep "ROCKSDB_PATCH.[0-9]" ../include/rocksdb/version.h | cut -d ' ' -f 3) @@ -53,43 +54,49 @@ ifeq ($(PLATFORM), OS_MACOSX) ROCKSDB_JAR = rocksdbjni-$(ROCKSDB_MAJOR).$(ROCKSDB_MINOR).$(ROCKSDB_PATCH)-osx.jar endif -JAVA_TESTS = org.rocksdb.test.BackupableDBOptionsTest\ - org.rocksdb.test.BackupableDBTest\ - org.rocksdb.test.BlockBasedTableConfigTest\ - org.rocksdb.test.CheckPointTest\ - org.rocksdb.test.ColumnFamilyOptionsTest\ - org.rocksdb.test.ColumnFamilyTest\ - org.rocksdb.test.ComparatorOptionsTest\ - org.rocksdb.test.ComparatorTest\ - org.rocksdb.test.CompressionOptionsTest\ - org.rocksdb.test.DBOptionsTest\ - org.rocksdb.test.DirectComparatorTest\ - org.rocksdb.test.DirectSliceTest\ - org.rocksdb.test.EnvironmentTest\ - org.rocksdb.test.FilterTest\ - org.rocksdb.test.FlushTest\ - org.rocksdb.test.InfoLogLevelTest\ - org.rocksdb.test.KeyMayExistTest\ - org.rocksdb.test.MemTableTest\ - org.rocksdb.test.MergeTest\ - org.rocksdb.test.MixedOptionsTest\ - org.rocksdb.test.OptionsTest\ - org.rocksdb.test.PlainTableConfigTest\ - org.rocksdb.test.ReadOnlyTest\ - org.rocksdb.test.ReadOptionsTest\ - org.rocksdb.test.RocksDBTest\ - org.rocksdb.test.RocksEnvTest\ - org.rocksdb.test.RocksIteratorTest\ - org.rocksdb.test.SizeUnitTest\ - org.rocksdb.test.SliceTest\ - org.rocksdb.test.SnapshotTest\ - org.rocksdb.test.TransactionLogIteratorTest\ - org.rocksdb.test.TtlDBTest\ - org.rocksdb.test.StatisticsCollectorTest\ - org.rocksdb.test.WriteBatchHandlerTest\ - org.rocksdb.test.WriteBatchTest\ - org.rocksdb.test.WriteOptionsTest\ - org.rocksdb.test.WriteBatchWithIndexTest +JAVA_TESTS = org.rocksdb.BackupableDBOptionsTest\ + org.rocksdb.BackupableDBTest\ + org.rocksdb.BlockBasedTableConfigTest\ + org.rocksdb.CheckPointTest\ + org.rocksdb.ColumnFamilyOptionsTest\ + org.rocksdb.ColumnFamilyTest\ + org.rocksdb.ComparatorOptionsTest\ + org.rocksdb.ComparatorTest\ + org.rocksdb.CompressionOptionsTest\ + org.rocksdb.DBOptionsTest\ + org.rocksdb.DirectComparatorTest\ + org.rocksdb.DirectSliceTest\ + org.rocksdb.util.EnvironmentTest\ + org.rocksdb.FilterTest\ + org.rocksdb.FlushTest\ + org.rocksdb.InfoLogLevelTest\ + org.rocksdb.KeyMayExistTest\ + org.rocksdb.MemTableTest\ + org.rocksdb.MergeTest\ + org.rocksdb.MixedOptionsTest\ + org.rocksdb.OptionsTest\ + org.rocksdb.PlainTableConfigTest\ + org.rocksdb.ReadOnlyTest\ + org.rocksdb.ReadOptionsTest\ + org.rocksdb.RocksDBTest\ + org.rocksdb.RocksEnvTest\ + org.rocksdb.RocksIteratorTest\ + org.rocksdb.util.SizeUnitTest\ + org.rocksdb.SliceTest\ + org.rocksdb.SnapshotTest\ + org.rocksdb.TransactionLogIteratorTest\ + org.rocksdb.TtlDBTest\ + org.rocksdb.StatisticsCollectorTest\ + org.rocksdb.WriteBatchHandlerTest\ + org.rocksdb.WriteBatchTest\ + org.rocksdb.WriteOptionsTest\ + org.rocksdb.WriteBatchWithIndexTest + +TEST_SRC = src/test/java +OUTPUT = target +# TODO update after moving main classes +MAIN_CLASSES = . +TEST_CLASSES = $(OUTPUT)/test-classes JAVA_TEST_LIBDIR = ./test-libs/ JAVA_JUNIT_JAR = $(JAVA_TEST_LIBDIR)junit-4.12-beta-2.jar @@ -97,14 +104,14 @@ JAVA_HAMCR_JAR = $(JAVA_TEST_LIBDIR)hamcrest-core-1.3.jar JAVA_MOCKITO_JAR = $(JAVA_TEST_LIBDIR)mockito-all-1.9.5.jar JAVA_CGLIB_JAR = $(JAVA_TEST_LIBDIR)cglib-2.2.2.jar JAVA_ASSERTJ_JAR = $(JAVA_TEST_LIBDIR)assertj-core-1.7.0.jar -JAVA_TESTCLASSPATH = $(ROCKSDB_JAR):$(JAVA_JUNIT_JAR):$(JAVA_HAMCR_JAR):$(JAVA_MOCKITO_JAR):$(JAVA_CGLIB_JAR):$(JAVA_ASSERTJ_JAR):.:./* +JAVA_TESTCLASSPATH = $(JAVA_JUNIT_JAR):$(JAVA_HAMCR_JAR):$(JAVA_MOCKITO_JAR):$(JAVA_CGLIB_JAR):$(JAVA_ASSERTJ_JAR):.:./* clean: -find . -name "*.class" -exec rm {} \; rm -rf include/* rm -rf javadoc/* rm -rf test-libs/ - rm -rf target + rm -rf $(OUTPUT) rm -rf librocksdbjni* rm -f rocksdbjni* @@ -112,11 +119,10 @@ clean: javadocs: mkdir -p javadoc; javadoc -d javadoc -sourcepath . -subpackages org -exclude org.rocksdb.test -javalib: java javadocs +javalib: java java_test javadocs -java: resolve_test_deps +java: javac org/rocksdb/util/*.java org/rocksdb/*.java - javac -cp $(JAVA_TESTCLASSPATH) org/rocksdb/test/*.java @cp ../HISTORY.md ./HISTORY-CPP.md @rm -f ./HISTORY-CPP.md javah -d $(NATIVE_INCLUDE) -jni $(NATIVE_JAVA_CLASSES) @@ -143,8 +149,15 @@ resolve_test_deps: test -s "$(JAVA_CGLIB_JAR)" || curl -k -L -o "$(JAVA_CGLIB_JAR)" http://search.maven.org/remotecontent?filepath=cglib/cglib/2.2.2/cglib-2.2.2.jar test -s "$(JAVA_ASSERTJ_JAR)" || curl -k -L -o "$(JAVA_ASSERTJ_JAR)" http://central.maven.org/maven2/org/assertj/assertj-core/1.7.0/assertj-core-1.7.0.jar -test: java resolve_test_deps - java -ea -Xcheck:jni -Djava.library.path=.:../ -cp "$(JAVA_TESTCLASSPATH)" org.rocksdb.test.RocksJunitRunner $(JAVA_TESTS) +java_test: resolve_test_deps + mkdir -p $(TEST_CLASSES) + javac -cp $(MAIN_CLASSES):$(JAVA_TESTCLASSPATH) -d $(TEST_CLASSES) $(TEST_SRC)/org/rocksdb/*.java + javac -cp $(MAIN_CLASSES):$(JAVA_TESTCLASSPATH) -d $(TEST_CLASSES) $(TEST_SRC)/org/rocksdb/test/*.java + javac -cp $(MAIN_CLASSES):$(JAVA_TESTCLASSPATH) -d $(TEST_CLASSES) $(TEST_SRC)/org/rocksdb/util/*.java + javah -cp $(MAIN_CLASSES):$(TEST_CLASSES) -d $(NATIVE_INCLUDE) -jni $(NATIVE_JAVA_TEST_CLASSES) + +test: java resolve_test_deps java_test + java -ea -Xcheck:jni -Djava.library.path=.:../ -cp "$(MAIN_CLASSES):$(TEST_CLASSES):$(JAVA_TESTCLASSPATH)" org.rocksdb.test.RocksJunitRunner $(JAVA_TESTS) db_bench: java javac org/rocksdb/benchmark/*.java diff --git a/java/rocksjni/write_batch.cc b/java/rocksjni/write_batch.cc index 20eb55407..aa0c2309a 100644 --- a/java/rocksjni/write_batch.cc +++ b/java/rocksjni/write_batch.cc @@ -9,8 +9,6 @@ #include "include/org_rocksdb_WriteBatch.h" #include "include/org_rocksdb_WriteBatch_Handler.h" -#include "include/org_rocksdb_test_WriteBatchInternal.h" -#include "include/org_rocksdb_test_WriteBatchTest.h" #include "rocksjni/portal.h" #include "rocksjni/writebatchhandlerjnicallback.h" #include "rocksdb/db.h" @@ -217,48 +215,6 @@ void Java_org_rocksdb_WriteBatch_disposeInternal( delete reinterpret_cast(handle); } -/* - * Class: org_rocksdb_test_WriteBatchInternal - * Method: setSequence - * Signature: (Lorg/rocksdb/WriteBatch;J)V - */ -void Java_org_rocksdb_test_WriteBatchInternal_setSequence( - JNIEnv* env, jclass jclazz, jobject jobj, jlong jsn) { - rocksdb::WriteBatch* wb = rocksdb::WriteBatchJni::getHandle(env, jobj); - assert(wb != nullptr); - - rocksdb::WriteBatchInternal::SetSequence( - wb, static_cast(jsn)); -} - -/* - * Class: org_rocksdb_test_WriteBatchInternal - * Method: sequence - * Signature: (Lorg/rocksdb/WriteBatch;)J - */ -jlong Java_org_rocksdb_test_WriteBatchInternal_sequence( - JNIEnv* env, jclass jclazz, jobject jobj) { - rocksdb::WriteBatch* wb = rocksdb::WriteBatchJni::getHandle(env, jobj); - assert(wb != nullptr); - - return static_cast(rocksdb::WriteBatchInternal::Sequence(wb)); -} - -/* - * Class: org_rocksdb_test_WriteBatchInternal - * Method: append - * Signature: (Lorg/rocksdb/WriteBatch;Lorg/rocksdb/WriteBatch;)V - */ -void Java_org_rocksdb_test_WriteBatchInternal_append( - JNIEnv* env, jclass jclazz, jobject jwb1, jobject jwb2) { - rocksdb::WriteBatch* wb1 = rocksdb::WriteBatchJni::getHandle(env, jwb1); - assert(wb1 != nullptr); - rocksdb::WriteBatch* wb2 = rocksdb::WriteBatchJni::getHandle(env, jwb2); - assert(wb2 != nullptr); - - rocksdb::WriteBatchInternal::Append(wb1, wb2); -} - /* * Class: org_rocksdb_WriteBatch_Handler * Method: createNewHandler0 @@ -280,83 +236,3 @@ void Java_org_rocksdb_WriteBatch_00024Handler_disposeInternal( JNIEnv* env, jobject jobj, jlong handle) { delete reinterpret_cast(handle); } - -/* - * Class: org_rocksdb_test_WriteBatchTest - * Method: getContents - * Signature: (Lorg/rocksdb/WriteBatch;)[B - */ -jbyteArray Java_org_rocksdb_test_WriteBatchTest_getContents( - JNIEnv* env, jclass jclazz, jobject jobj) { - rocksdb::WriteBatch* b = rocksdb::WriteBatchJni::getHandle(env, jobj); - assert(b != nullptr); - - // todo: Currently the following code is directly copied from - // db/write_bench_test.cc. It could be implemented in java once - // all the necessary components can be accessed via jni api. - - rocksdb::InternalKeyComparator cmp(rocksdb::BytewiseComparator()); - auto factory = std::make_shared(); - rocksdb::Options options; - rocksdb::WriteBuffer wb(options.db_write_buffer_size); - options.memtable_factory = factory; - rocksdb::MemTable* mem = new rocksdb::MemTable( - cmp, rocksdb::ImmutableCFOptions(options), - rocksdb::MutableCFOptions(options, rocksdb::ImmutableCFOptions(options)), - &wb); - mem->Ref(); - std::string state; - rocksdb::ColumnFamilyMemTablesDefault cf_mems_default(mem); - rocksdb::Status s = - rocksdb::WriteBatchInternal::InsertInto(b, &cf_mems_default); - int count = 0; - rocksdb::Arena arena; - rocksdb::ScopedArenaIterator iter(mem->NewIterator( - rocksdb::ReadOptions(), &arena)); - for (iter->SeekToFirst(); iter->Valid(); iter->Next()) { - rocksdb::ParsedInternalKey ikey; - memset(reinterpret_cast(&ikey), 0, sizeof(ikey)); - ASSERT_TRUE(rocksdb::ParseInternalKey(iter->key(), &ikey)); - switch (ikey.type) { - case rocksdb::kTypeValue: - state.append("Put("); - state.append(ikey.user_key.ToString()); - state.append(", "); - state.append(iter->value().ToString()); - state.append(")"); - count++; - break; - case rocksdb::kTypeMerge: - state.append("Merge("); - state.append(ikey.user_key.ToString()); - state.append(", "); - state.append(iter->value().ToString()); - state.append(")"); - count++; - break; - case rocksdb::kTypeDeletion: - state.append("Delete("); - state.append(ikey.user_key.ToString()); - state.append(")"); - count++; - break; - default: - assert(false); - break; - } - state.append("@"); - state.append(rocksdb::NumberToString(ikey.sequence)); - } - if (!s.ok()) { - state.append(s.ToString()); - } else if (count != rocksdb::WriteBatchInternal::Count(b)) { - state.append("CountMismatch()"); - } - delete mem->Unref(); - - jbyteArray jstate = env->NewByteArray(static_cast(state.size())); - env->SetByteArrayRegion(jstate, 0, static_cast(state.size()), - reinterpret_cast(state.c_str())); - - return jstate; -} diff --git a/java/rocksjni/write_batch_test.cc b/java/rocksjni/write_batch_test.cc new file mode 100644 index 000000000..d78178211 --- /dev/null +++ b/java/rocksjni/write_batch_test.cc @@ -0,0 +1,148 @@ +// Copyright (c) 2014, Facebook, Inc. All rights reserved. +// This source code is licensed under the BSD-style license found in the +// LICENSE file in the root directory of this source tree. An additional grant +// of patent rights can be found in the PATENTS file in the same directory. +// +// This file implements the "bridge" between Java and C++ and enables +// calling c++ rocksdb::WriteBatch methods testing from Java side. +#include + +#include "db/memtable.h" +#include "db/write_batch_internal.h" +#include "db/writebuffer.h" +#include "include/org_rocksdb_WriteBatch.h" +#include "include/org_rocksdb_WriteBatch_Handler.h" +#include "include/org_rocksdb_WriteBatchTest.h" +#include "include/org_rocksdb_WriteBatchTestInternalHelper.h" +#include "rocksdb/db.h" +#include "rocksdb/env.h" +#include "rocksdb/immutable_options.h" +#include "rocksdb/memtablerep.h" +#include "rocksdb/status.h" +#include "rocksdb/write_batch.h" +#include "rocksjni/portal.h" +#include "util/logging.h" +#include "util/scoped_arena_iterator.h" +#include "util/testharness.h" + +/* + * Class: org_rocksdb_WriteBatchTest + * Method: getContents + * Signature: (Lorg/rocksdb/WriteBatch;)[B + */ +jbyteArray Java_org_rocksdb_WriteBatchTest_getContents( + JNIEnv* env, jclass jclazz, jobject jobj) { + rocksdb::WriteBatch* b = rocksdb::WriteBatchJni::getHandle(env, jobj); + assert(b != nullptr); + + // todo: Currently the following code is directly copied from + // db/write_bench_test.cc. It could be implemented in java once + // all the necessary components can be accessed via jni api. + + rocksdb::InternalKeyComparator cmp(rocksdb::BytewiseComparator()); + auto factory = std::make_shared(); + rocksdb::Options options; + rocksdb::WriteBuffer wb(options.db_write_buffer_size); + options.memtable_factory = factory; + rocksdb::MemTable* mem = new rocksdb::MemTable( + cmp, rocksdb::ImmutableCFOptions(options), + rocksdb::MutableCFOptions(options, rocksdb::ImmutableCFOptions(options)), + &wb); + mem->Ref(); + std::string state; + rocksdb::ColumnFamilyMemTablesDefault cf_mems_default(mem); + rocksdb::Status s = + rocksdb::WriteBatchInternal::InsertInto(b, &cf_mems_default); + int count = 0; + rocksdb::Arena arena; + rocksdb::ScopedArenaIterator iter(mem->NewIterator( + rocksdb::ReadOptions(), &arena)); + for (iter->SeekToFirst(); iter->Valid(); iter->Next()) { + rocksdb::ParsedInternalKey ikey; + memset(reinterpret_cast(&ikey), 0, sizeof(ikey)); + ASSERT_TRUE(rocksdb::ParseInternalKey(iter->key(), &ikey)); + switch (ikey.type) { + case rocksdb::kTypeValue: + state.append("Put("); + state.append(ikey.user_key.ToString()); + state.append(", "); + state.append(iter->value().ToString()); + state.append(")"); + count++; + break; + case rocksdb::kTypeMerge: + state.append("Merge("); + state.append(ikey.user_key.ToString()); + state.append(", "); + state.append(iter->value().ToString()); + state.append(")"); + count++; + break; + case rocksdb::kTypeDeletion: + state.append("Delete("); + state.append(ikey.user_key.ToString()); + state.append(")"); + count++; + break; + default: + assert(false); + break; + } + state.append("@"); + state.append(rocksdb::NumberToString(ikey.sequence)); + } + if (!s.ok()) { + state.append(s.ToString()); + } else if (count != rocksdb::WriteBatchInternal::Count(b)) { + state.append("CountMismatch()"); + } + delete mem->Unref(); + + jbyteArray jstate = env->NewByteArray(static_cast(state.size())); + env->SetByteArrayRegion(jstate, 0, static_cast(state.size()), + reinterpret_cast(state.c_str())); + + return jstate; +} + +/* + * Class: org_rocksdb_WriteBatchTestInternalHelper + * Method: setSequence + * Signature: (Lorg/rocksdb/WriteBatch;J)V + */ +void Java_org_rocksdb_WriteBatchTestInternalHelper_setSequence( + JNIEnv* env, jclass jclazz, jobject jobj, jlong jsn) { + rocksdb::WriteBatch* wb = rocksdb::WriteBatchJni::getHandle(env, jobj); + assert(wb != nullptr); + + rocksdb::WriteBatchInternal::SetSequence( + wb, static_cast(jsn)); +} + +/* + * Class: org_rocksdb_WriteBatchTestInternalHelper + * Method: sequence + * Signature: (Lorg/rocksdb/WriteBatch;)J + */ +jlong Java_org_rocksdb_WriteBatchTestInternalHelper_sequence( + JNIEnv* env, jclass jclazz, jobject jobj) { + rocksdb::WriteBatch* wb = rocksdb::WriteBatchJni::getHandle(env, jobj); + assert(wb != nullptr); + + return static_cast(rocksdb::WriteBatchInternal::Sequence(wb)); +} + +/* + * Class: org_rocksdb_WriteBatchTestInternalHelper + * Method: append + * Signature: (Lorg/rocksdb/WriteBatch;Lorg/rocksdb/WriteBatch;)V + */ +void Java_org_rocksdb_WriteBatchTestInternalHelper_append( + JNIEnv* env, jclass jclazz, jobject jwb1, jobject jwb2) { + rocksdb::WriteBatch* wb1 = rocksdb::WriteBatchJni::getHandle(env, jwb1); + assert(wb1 != nullptr); + rocksdb::WriteBatch* wb2 = rocksdb::WriteBatchJni::getHandle(env, jwb2); + assert(wb2 != nullptr); + + rocksdb::WriteBatchInternal::Append(wb1, wb2); +} diff --git a/java/org/rocksdb/test/AbstractComparatorTest.java b/java/src/test/java/org/rocksdb/AbstractComparatorTest.java similarity index 97% rename from java/org/rocksdb/test/AbstractComparatorTest.java rename to java/src/test/java/org/rocksdb/AbstractComparatorTest.java index f0281a521..97afb48d1 100644 --- a/java/org/rocksdb/test/AbstractComparatorTest.java +++ b/java/src/test/java/org/rocksdb/AbstractComparatorTest.java @@ -3,9 +3,7 @@ // LICENSE file in the root directory of this source tree. An additional grant // of patent rights can be found in the PATENTS file in the same directory. -package org.rocksdb.test; - -import org.rocksdb.*; +package org.rocksdb; import java.io.IOException; import java.nio.file.*; @@ -14,8 +12,8 @@ import java.util.List; import java.util.Random; import static org.assertj.core.api.Assertions.assertThat; -import static org.rocksdb.test.Types.byteToInt; -import static org.rocksdb.test.Types.intToByte; +import static org.rocksdb.Types.byteToInt; +import static org.rocksdb.Types.intToByte; /** * Abstract tests for both Comparator and DirectComparator diff --git a/java/org/rocksdb/test/BackupableDBOptionsTest.java b/java/src/test/java/org/rocksdb/BackupableDBOptionsTest.java similarity index 99% rename from java/org/rocksdb/test/BackupableDBOptionsTest.java rename to java/src/test/java/org/rocksdb/BackupableDBOptionsTest.java index b7bdc0011..6fe3bd2f0 100644 --- a/java/org/rocksdb/test/BackupableDBOptionsTest.java +++ b/java/src/test/java/org/rocksdb/BackupableDBOptionsTest.java @@ -3,13 +3,12 @@ // LICENSE file in the root directory of this source tree. An additional grant // of patent rights can be found in the PATENTS file in the same directory. -package org.rocksdb.test; +package org.rocksdb; import org.junit.ClassRule; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; -import org.rocksdb.BackupableDBOptions; import java.util.Random; diff --git a/java/org/rocksdb/test/BackupableDBTest.java b/java/src/test/java/org/rocksdb/BackupableDBTest.java similarity index 99% rename from java/org/rocksdb/test/BackupableDBTest.java rename to java/src/test/java/org/rocksdb/BackupableDBTest.java index 2ac2abfa1..3f358bdb7 100644 --- a/java/org/rocksdb/test/BackupableDBTest.java +++ b/java/src/test/java/org/rocksdb/BackupableDBTest.java @@ -3,13 +3,12 @@ // LICENSE file in the root directory of this source tree. An additional grant // of patent rights can be found in the PATENTS file in the same directory. -package org.rocksdb.test; +package org.rocksdb; import org.junit.ClassRule; import org.junit.Rule; import org.junit.Test; import org.junit.rules.TemporaryFolder; -import org.rocksdb.*; import java.util.List; diff --git a/java/org/rocksdb/test/BlockBasedTableConfigTest.java b/java/src/test/java/org/rocksdb/BlockBasedTableConfigTest.java similarity index 99% rename from java/org/rocksdb/test/BlockBasedTableConfigTest.java rename to java/src/test/java/org/rocksdb/BlockBasedTableConfigTest.java index 1172effc8..aacf44054 100644 --- a/java/org/rocksdb/test/BlockBasedTableConfigTest.java +++ b/java/src/test/java/org/rocksdb/BlockBasedTableConfigTest.java @@ -3,11 +3,10 @@ // LICENSE file in the root directory of this source tree. An additional grant // of patent rights can be found in the PATENTS file in the same directory. -package org.rocksdb.test; +package org.rocksdb; import org.junit.ClassRule; import org.junit.Test; -import org.rocksdb.*; import static org.assertj.core.api.Assertions.assertThat; diff --git a/java/org/rocksdb/test/CheckPointTest.java b/java/src/test/java/org/rocksdb/CheckPointTest.java similarity index 94% rename from java/org/rocksdb/test/CheckPointTest.java rename to java/src/test/java/org/rocksdb/CheckPointTest.java index 3891e062e..3081e585a 100644 --- a/java/org/rocksdb/test/CheckPointTest.java +++ b/java/src/test/java/org/rocksdb/CheckPointTest.java @@ -1,14 +1,10 @@ -package org.rocksdb.test; +package org.rocksdb; import org.junit.ClassRule; import org.junit.Rule; import org.junit.Test; import org.junit.rules.TemporaryFolder; -import org.rocksdb.Checkpoint; -import org.rocksdb.Options; -import org.rocksdb.RocksDB; -import org.rocksdb.RocksDBException; import static org.assertj.core.api.Assertions.assertThat; diff --git a/java/org/rocksdb/test/ColumnFamilyOptionsTest.java b/java/src/test/java/org/rocksdb/ColumnFamilyOptionsTest.java similarity index 99% rename from java/org/rocksdb/test/ColumnFamilyOptionsTest.java rename to java/src/test/java/org/rocksdb/ColumnFamilyOptionsTest.java index aae9b5749..4082c602d 100644 --- a/java/org/rocksdb/test/ColumnFamilyOptionsTest.java +++ b/java/src/test/java/org/rocksdb/ColumnFamilyOptionsTest.java @@ -3,11 +3,10 @@ // LICENSE file in the root directory of this source tree. An additional grant // of patent rights can be found in the PATENTS file in the same directory. -package org.rocksdb.test; +package org.rocksdb; import org.junit.ClassRule; import org.junit.Test; -import org.rocksdb.*; import java.util.Properties; import java.util.Random; diff --git a/java/org/rocksdb/test/ColumnFamilyTest.java b/java/src/test/java/org/rocksdb/ColumnFamilyTest.java similarity index 99% rename from java/org/rocksdb/test/ColumnFamilyTest.java rename to java/src/test/java/org/rocksdb/ColumnFamilyTest.java index bf568b5e8..9a860ebe8 100644 --- a/java/org/rocksdb/test/ColumnFamilyTest.java +++ b/java/src/test/java/org/rocksdb/ColumnFamilyTest.java @@ -3,7 +3,7 @@ // LICENSE file in the root directory of this source tree. An additional grant // of patent rights can be found in the PATENTS file in the same directory. -package org.rocksdb.test; +package org.rocksdb; import java.util.HashMap; import java.util.List; @@ -14,7 +14,6 @@ import org.junit.ClassRule; import org.junit.Rule; import org.junit.Test; import org.junit.rules.TemporaryFolder; -import org.rocksdb.*; import static org.assertj.core.api.Assertions.assertThat; diff --git a/java/org/rocksdb/test/ComparatorOptionsTest.java b/java/src/test/java/org/rocksdb/ComparatorOptionsTest.java similarity index 93% rename from java/org/rocksdb/test/ComparatorOptionsTest.java rename to java/src/test/java/org/rocksdb/ComparatorOptionsTest.java index 1064910df..4f8a7d1a6 100644 --- a/java/org/rocksdb/test/ComparatorOptionsTest.java +++ b/java/src/test/java/org/rocksdb/ComparatorOptionsTest.java @@ -3,11 +3,10 @@ // LICENSE file in the root directory of this source tree. An additional grant // of patent rights can be found in the PATENTS file in the same directory. -package org.rocksdb.test; +package org.rocksdb; import org.junit.ClassRule; import org.junit.Test; -import org.rocksdb.ComparatorOptions; import static org.assertj.core.api.Assertions.assertThat; diff --git a/java/org/rocksdb/test/ComparatorTest.java b/java/src/test/java/org/rocksdb/ComparatorTest.java similarity index 99% rename from java/org/rocksdb/test/ComparatorTest.java rename to java/src/test/java/org/rocksdb/ComparatorTest.java index e1bba6a7f..e689a9cf5 100644 --- a/java/org/rocksdb/test/ComparatorTest.java +++ b/java/src/test/java/org/rocksdb/ComparatorTest.java @@ -3,13 +3,12 @@ // LICENSE file in the root directory of this source tree. An additional grant // of patent rights can be found in the PATENTS file in the same directory. -package org.rocksdb.test; +package org.rocksdb; import org.junit.ClassRule; import org.junit.Rule; import org.junit.Test; import org.junit.rules.TemporaryFolder; -import org.rocksdb.*; import java.io.IOException; import java.nio.file.FileSystems; diff --git a/java/org/rocksdb/test/CompressionOptionsTest.java b/java/src/test/java/org/rocksdb/CompressionOptionsTest.java similarity index 91% rename from java/org/rocksdb/test/CompressionOptionsTest.java rename to java/src/test/java/org/rocksdb/CompressionOptionsTest.java index f8aff9268..bff4d5f6c 100644 --- a/java/org/rocksdb/test/CompressionOptionsTest.java +++ b/java/src/test/java/org/rocksdb/CompressionOptionsTest.java @@ -3,10 +3,9 @@ // LICENSE file in the root directory of this source tree. An additional grant // of patent rights can be found in the PATENTS file in the same directory. -package org.rocksdb.test; +package org.rocksdb; import org.junit.Test; -import org.rocksdb.CompressionType; public class CompressionOptionsTest diff --git a/java/org/rocksdb/test/DBOptionsTest.java b/java/src/test/java/org/rocksdb/DBOptionsTest.java similarity index 99% rename from java/org/rocksdb/test/DBOptionsTest.java rename to java/src/test/java/org/rocksdb/DBOptionsTest.java index 858379768..9dab55955 100644 --- a/java/org/rocksdb/test/DBOptionsTest.java +++ b/java/src/test/java/org/rocksdb/DBOptionsTest.java @@ -3,11 +3,10 @@ // LICENSE file in the root directory of this source tree. An additional grant // of patent rights can be found in the PATENTS file in the same directory. -package org.rocksdb.test; +package org.rocksdb; import org.junit.ClassRule; import org.junit.Test; -import org.rocksdb.*; import java.util.Properties; import java.util.Random; diff --git a/java/org/rocksdb/test/DirectComparatorTest.java b/java/src/test/java/org/rocksdb/DirectComparatorTest.java similarity index 97% rename from java/org/rocksdb/test/DirectComparatorTest.java rename to java/src/test/java/org/rocksdb/DirectComparatorTest.java index 328ea0089..be84d6647 100644 --- a/java/org/rocksdb/test/DirectComparatorTest.java +++ b/java/src/test/java/org/rocksdb/DirectComparatorTest.java @@ -3,13 +3,12 @@ // LICENSE file in the root directory of this source tree. An additional grant // of patent rights can be found in the PATENTS file in the same directory. -package org.rocksdb.test; +package org.rocksdb; import org.junit.ClassRule; import org.junit.Rule; import org.junit.Test; import org.junit.rules.TemporaryFolder; -import org.rocksdb.*; import java.io.IOException; import java.nio.file.FileSystems; diff --git a/java/org/rocksdb/test/DirectSliceTest.java b/java/src/test/java/org/rocksdb/DirectSliceTest.java similarity index 98% rename from java/org/rocksdb/test/DirectSliceTest.java rename to java/src/test/java/org/rocksdb/DirectSliceTest.java index 20a44a904..123eed2e7 100644 --- a/java/org/rocksdb/test/DirectSliceTest.java +++ b/java/src/test/java/org/rocksdb/DirectSliceTest.java @@ -2,11 +2,10 @@ // This source code is licensed under the BSD-style license found in the // LICENSE file in the root directory of this source tree. An additional grant // of patent rights can be found in the PATENTS file in the same directory. -package org.rocksdb.test; +package org.rocksdb; import org.junit.ClassRule; import org.junit.Test; -import org.rocksdb.DirectSlice; import java.nio.ByteBuffer; diff --git a/java/org/rocksdb/test/FilterTest.java b/java/src/test/java/org/rocksdb/FilterTest.java similarity index 96% rename from java/org/rocksdb/test/FilterTest.java rename to java/src/test/java/org/rocksdb/FilterTest.java index da4783fbf..36ce37970 100644 --- a/java/org/rocksdb/test/FilterTest.java +++ b/java/src/test/java/org/rocksdb/FilterTest.java @@ -3,11 +3,10 @@ // LICENSE file in the root directory of this source tree. An additional grant // of patent rights can be found in the PATENTS file in the same directory. -package org.rocksdb.test; +package org.rocksdb; import org.junit.ClassRule; import org.junit.Test; -import org.rocksdb.*; public class FilterTest { diff --git a/java/org/rocksdb/test/FlushTest.java b/java/src/test/java/org/rocksdb/FlushTest.java similarity index 97% rename from java/org/rocksdb/test/FlushTest.java rename to java/src/test/java/org/rocksdb/FlushTest.java index 3bfdb3114..94a32d383 100644 --- a/java/org/rocksdb/test/FlushTest.java +++ b/java/src/test/java/org/rocksdb/FlushTest.java @@ -2,13 +2,12 @@ // This source code is licensed under the BSD-style license found in the // LICENSE file in the root directory of this source tree. An additional grant // of patent rights can be found in the PATENTS file in the same directory. -package org.rocksdb.test; +package org.rocksdb; import org.junit.ClassRule; import org.junit.Rule; import org.junit.Test; import org.junit.rules.TemporaryFolder; -import org.rocksdb.*; import static org.assertj.core.api.Assertions.assertThat; diff --git a/java/org/rocksdb/test/InfoLogLevelTest.java b/java/src/test/java/org/rocksdb/InfoLogLevelTest.java similarity index 98% rename from java/org/rocksdb/test/InfoLogLevelTest.java rename to java/src/test/java/org/rocksdb/InfoLogLevelTest.java index 82bf485de..39d1ddd1d 100644 --- a/java/org/rocksdb/test/InfoLogLevelTest.java +++ b/java/src/test/java/org/rocksdb/InfoLogLevelTest.java @@ -1,10 +1,9 @@ -package org.rocksdb.test; +package org.rocksdb; import org.junit.ClassRule; import org.junit.Rule; import org.junit.Test; import org.junit.rules.TemporaryFolder; -import org.rocksdb.*; import java.io.IOException; diff --git a/java/org/rocksdb/test/KeyMayExistTest.java b/java/src/test/java/org/rocksdb/KeyMayExistTest.java similarity index 98% rename from java/org/rocksdb/test/KeyMayExistTest.java rename to java/src/test/java/org/rocksdb/KeyMayExistTest.java index 921a6593c..f29c2f872 100644 --- a/java/org/rocksdb/test/KeyMayExistTest.java +++ b/java/src/test/java/org/rocksdb/KeyMayExistTest.java @@ -2,13 +2,12 @@ // This source code is licensed under the BSD-style license found in the // LICENSE file in the root directory of this source tree. An additional grant // of patent rights can be found in the PATENTS file in the same directory. -package org.rocksdb.test; +package org.rocksdb; import org.junit.ClassRule; import org.junit.Rule; import org.junit.Test; import org.junit.rules.TemporaryFolder; -import org.rocksdb.*; import java.util.ArrayList; import java.util.List; diff --git a/java/org/rocksdb/test/MemTableTest.java b/java/src/test/java/org/rocksdb/MemTableTest.java similarity index 98% rename from java/org/rocksdb/test/MemTableTest.java rename to java/src/test/java/org/rocksdb/MemTableTest.java index dbf6b0bef..bfc898c42 100644 --- a/java/org/rocksdb/test/MemTableTest.java +++ b/java/src/test/java/org/rocksdb/MemTableTest.java @@ -3,11 +3,10 @@ // LICENSE file in the root directory of this source tree. An additional grant // of patent rights can be found in the PATENTS file in the same directory. -package org.rocksdb.test; +package org.rocksdb; import org.junit.ClassRule; import org.junit.Test; -import org.rocksdb.*; import static org.assertj.core.api.Assertions.assertThat; diff --git a/java/org/rocksdb/test/MergeTest.java b/java/src/test/java/org/rocksdb/MergeTest.java similarity index 99% rename from java/org/rocksdb/test/MergeTest.java rename to java/src/test/java/org/rocksdb/MergeTest.java index 9bb882e44..55e8a20cd 100644 --- a/java/org/rocksdb/test/MergeTest.java +++ b/java/src/test/java/org/rocksdb/MergeTest.java @@ -3,7 +3,7 @@ // LICENSE file in the root directory of this source tree. An additional grant // of patent rights can be found in the PATENTS file in the same directory. -package org.rocksdb.test; +package org.rocksdb; import java.util.List; import java.util.ArrayList; @@ -12,7 +12,6 @@ import org.junit.ClassRule; import org.junit.Rule; import org.junit.Test; import org.junit.rules.TemporaryFolder; -import org.rocksdb.*; import static org.assertj.core.api.Assertions.assertThat; diff --git a/java/org/rocksdb/test/MixedOptionsTest.java b/java/src/test/java/org/rocksdb/MixedOptionsTest.java similarity index 97% rename from java/org/rocksdb/test/MixedOptionsTest.java rename to java/src/test/java/org/rocksdb/MixedOptionsTest.java index 528bea2e3..f095e99d8 100644 --- a/java/org/rocksdb/test/MixedOptionsTest.java +++ b/java/src/test/java/org/rocksdb/MixedOptionsTest.java @@ -3,11 +3,10 @@ // LICENSE file in the root directory of this source tree. An additional grant // of patent rights can be found in the PATENTS file in the same directory. -package org.rocksdb.test; +package org.rocksdb; import org.junit.ClassRule; import org.junit.Test; -import org.rocksdb.*; import static org.assertj.core.api.Assertions.assertThat; diff --git a/java/org/rocksdb/test/OptionsTest.java b/java/src/test/java/org/rocksdb/OptionsTest.java similarity index 99% rename from java/org/rocksdb/test/OptionsTest.java rename to java/src/test/java/org/rocksdb/OptionsTest.java index 0e699c406..5b84d2510 100644 --- a/java/org/rocksdb/test/OptionsTest.java +++ b/java/src/test/java/org/rocksdb/OptionsTest.java @@ -3,12 +3,11 @@ // LICENSE file in the root directory of this source tree. An additional grant // of patent rights can be found in the PATENTS file in the same directory. -package org.rocksdb.test; +package org.rocksdb; import java.util.Random; import org.junit.ClassRule; import org.junit.Test; -import org.rocksdb.*; import static org.assertj.core.api.Assertions.assertThat; diff --git a/java/org/rocksdb/test/PlainTableConfigTest.java b/java/src/test/java/org/rocksdb/PlainTableConfigTest.java similarity index 95% rename from java/org/rocksdb/test/PlainTableConfigTest.java rename to java/src/test/java/org/rocksdb/PlainTableConfigTest.java index 72347e7d4..850b050a0 100644 --- a/java/org/rocksdb/test/PlainTableConfigTest.java +++ b/java/src/test/java/org/rocksdb/PlainTableConfigTest.java @@ -3,13 +3,10 @@ // LICENSE file in the root directory of this source tree. An additional grant // of patent rights can be found in the PATENTS file in the same directory. -package org.rocksdb.test; +package org.rocksdb; import org.junit.ClassRule; import org.junit.Test; -import org.rocksdb.EncodingType; -import org.rocksdb.Options; -import org.rocksdb.PlainTableConfig; import static org.assertj.core.api.Assertions.assertThat; diff --git a/java/org/rocksdb/test/PlatformRandomHelper.java b/java/src/test/java/org/rocksdb/PlatformRandomHelper.java similarity index 98% rename from java/org/rocksdb/test/PlatformRandomHelper.java rename to java/src/test/java/org/rocksdb/PlatformRandomHelper.java index d43f4a4f0..0155ce263 100644 --- a/java/org/rocksdb/test/PlatformRandomHelper.java +++ b/java/src/test/java/org/rocksdb/PlatformRandomHelper.java @@ -3,7 +3,7 @@ // LICENSE file in the root directory of this source tree. An additional grant // of patent rights can be found in the PATENTS file in the same directory. -package org.rocksdb.test; +package org.rocksdb; import java.util.Random; diff --git a/java/org/rocksdb/test/ReadOnlyTest.java b/java/src/test/java/org/rocksdb/ReadOnlyTest.java similarity index 99% rename from java/org/rocksdb/test/ReadOnlyTest.java rename to java/src/test/java/org/rocksdb/ReadOnlyTest.java index fce704eb5..a254481e5 100644 --- a/java/org/rocksdb/test/ReadOnlyTest.java +++ b/java/src/test/java/org/rocksdb/ReadOnlyTest.java @@ -2,13 +2,12 @@ // This source code is licensed under the BSD-style license found in the // LICENSE file in the root directory of this source tree. An additional grant // of patent rights can be found in the PATENTS file in the same directory. -package org.rocksdb.test; +package org.rocksdb; import org.junit.ClassRule; import org.junit.Rule; import org.junit.Test; import org.junit.rules.TemporaryFolder; -import org.rocksdb.*; import java.util.ArrayList; import java.util.List; diff --git a/java/org/rocksdb/test/ReadOptionsTest.java b/java/src/test/java/org/rocksdb/ReadOptionsTest.java similarity index 98% rename from java/org/rocksdb/test/ReadOptionsTest.java rename to java/src/test/java/org/rocksdb/ReadOptionsTest.java index 2cf1584a1..af88ce351 100644 --- a/java/org/rocksdb/test/ReadOptionsTest.java +++ b/java/src/test/java/org/rocksdb/ReadOptionsTest.java @@ -3,7 +3,7 @@ // LICENSE file in the root directory of this source tree. An additional grant // of patent rights can be found in the PATENTS file in the same directory. -package org.rocksdb.test; +package org.rocksdb; import java.util.Random; @@ -11,7 +11,6 @@ import org.junit.ClassRule; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; -import org.rocksdb.ReadOptions; import static org.assertj.core.api.Assertions.assertThat; diff --git a/java/org/rocksdb/test/RocksDBTest.java b/java/src/test/java/org/rocksdb/RocksDBTest.java similarity index 99% rename from java/org/rocksdb/test/RocksDBTest.java rename to java/src/test/java/org/rocksdb/RocksDBTest.java index 15dde9856..100db529d 100644 --- a/java/org/rocksdb/test/RocksDBTest.java +++ b/java/src/test/java/org/rocksdb/RocksDBTest.java @@ -2,13 +2,12 @@ // This source code is licensed under the BSD-style license found in the // LICENSE file in the root directory of this source tree. An additional grant // of patent rights can be found in the PATENTS file in the same directory. -package org.rocksdb.test; +package org.rocksdb; import org.junit.ClassRule; import org.junit.Rule; import org.junit.Test; import org.junit.rules.TemporaryFolder; -import org.rocksdb.*; import java.util.ArrayList; import java.util.List; diff --git a/java/org/rocksdb/test/RocksEnvTest.java b/java/src/test/java/org/rocksdb/RocksEnvTest.java similarity index 96% rename from java/org/rocksdb/test/RocksEnvTest.java rename to java/src/test/java/org/rocksdb/RocksEnvTest.java index f55e9042e..6b0b9becc 100644 --- a/java/org/rocksdb/test/RocksEnvTest.java +++ b/java/src/test/java/org/rocksdb/RocksEnvTest.java @@ -3,11 +3,10 @@ // LICENSE file in the root directory of this source tree. An additional grant // of patent rights can be found in the PATENTS file in the same directory. -package org.rocksdb.test; +package org.rocksdb; import org.junit.ClassRule; import org.junit.Test; -import org.rocksdb.RocksEnv; import static org.assertj.core.api.Assertions.assertThat; diff --git a/java/org/rocksdb/test/RocksIteratorTest.java b/java/src/test/java/org/rocksdb/RocksIteratorTest.java similarity index 95% rename from java/org/rocksdb/test/RocksIteratorTest.java rename to java/src/test/java/org/rocksdb/RocksIteratorTest.java index 448e8f397..c5918d8ac 100644 --- a/java/org/rocksdb/test/RocksIteratorTest.java +++ b/java/src/test/java/org/rocksdb/RocksIteratorTest.java @@ -2,16 +2,12 @@ // This source code is licensed under the BSD-style license found in the // LICENSE file in the root directory of this source tree. An additional grant // of patent rights can be found in the PATENTS file in the same directory. -package org.rocksdb.test; +package org.rocksdb; import org.junit.ClassRule; import org.junit.Rule; import org.junit.Test; import org.junit.rules.TemporaryFolder; -import org.rocksdb.Options; -import org.rocksdb.RocksDB; -import org.rocksdb.RocksDBException; -import org.rocksdb.RocksIterator; import static org.assertj.core.api.Assertions.assertThat; diff --git a/java/org/rocksdb/test/RocksMemoryResource.java b/java/src/test/java/org/rocksdb/RocksMemoryResource.java similarity index 85% rename from java/org/rocksdb/test/RocksMemoryResource.java rename to java/src/test/java/org/rocksdb/RocksMemoryResource.java index 51164ad65..de9ba0d6b 100644 --- a/java/org/rocksdb/test/RocksMemoryResource.java +++ b/java/src/test/java/org/rocksdb/RocksMemoryResource.java @@ -1,7 +1,6 @@ -package org.rocksdb.test; +package org.rocksdb; import org.junit.rules.ExternalResource; -import org.rocksdb.RocksDB; /** * Resource to trigger garbage collection after each test diff --git a/java/org/rocksdb/test/SliceTest.java b/java/src/test/java/org/rocksdb/SliceTest.java similarity index 98% rename from java/org/rocksdb/test/SliceTest.java rename to java/src/test/java/org/rocksdb/SliceTest.java index 4b04172f8..16221ef65 100644 --- a/java/org/rocksdb/test/SliceTest.java +++ b/java/src/test/java/org/rocksdb/SliceTest.java @@ -2,11 +2,10 @@ // This source code is licensed under the BSD-style license found in the // LICENSE file in the root directory of this source tree. An additional grant // of patent rights can be found in the PATENTS file in the same directory. -package org.rocksdb.test; +package org.rocksdb; import org.junit.ClassRule; import org.junit.Test; -import org.rocksdb.Slice; import static org.assertj.core.api.Assertions.assertThat; diff --git a/java/org/rocksdb/test/SnapshotTest.java b/java/src/test/java/org/rocksdb/SnapshotTest.java similarity index 99% rename from java/org/rocksdb/test/SnapshotTest.java rename to java/src/test/java/org/rocksdb/SnapshotTest.java index 4aeef44ef..87ccdbcb5 100644 --- a/java/org/rocksdb/test/SnapshotTest.java +++ b/java/src/test/java/org/rocksdb/SnapshotTest.java @@ -2,13 +2,12 @@ // This source code is licensed under the BSD-style license found in the // LICENSE file in the root directory of this source tree. An additional grant // of patent rights can be found in the PATENTS file in the same directory. -package org.rocksdb.test; +package org.rocksdb; import org.junit.ClassRule; import org.junit.Rule; import org.junit.Test; import org.junit.rules.TemporaryFolder; -import org.rocksdb.*; import static org.assertj.core.api.Assertions.assertThat; diff --git a/java/org/rocksdb/test/StatisticsCollectorTest.java b/java/src/test/java/org/rocksdb/StatisticsCollectorTest.java similarity index 97% rename from java/org/rocksdb/test/StatisticsCollectorTest.java rename to java/src/test/java/org/rocksdb/StatisticsCollectorTest.java index ba84857ba..927826d71 100644 --- a/java/org/rocksdb/test/StatisticsCollectorTest.java +++ b/java/src/test/java/org/rocksdb/StatisticsCollectorTest.java @@ -3,7 +3,7 @@ // LICENSE file in the root directory of this source tree. An additional grant // of patent rights can be found in the PATENTS file in the same directory. -package org.rocksdb.test; +package org.rocksdb; import java.util.Collections; @@ -11,7 +11,6 @@ import org.junit.ClassRule; import org.junit.Rule; import org.junit.Test; import org.junit.rules.TemporaryFolder; -import org.rocksdb.*; import static org.assertj.core.api.Assertions.assertThat; diff --git a/java/org/rocksdb/test/StatsCallbackMock.java b/java/src/test/java/org/rocksdb/StatsCallbackMock.java similarity index 93% rename from java/org/rocksdb/test/StatsCallbackMock.java rename to java/src/test/java/org/rocksdb/StatsCallbackMock.java index 4ad2fb7b7..3c5800e42 100644 --- a/java/org/rocksdb/test/StatsCallbackMock.java +++ b/java/src/test/java/org/rocksdb/StatsCallbackMock.java @@ -3,9 +3,7 @@ // LICENSE file in the root directory of this source tree. An additional grant // of patent rights can be found in the PATENTS file in the same directory. -package org.rocksdb.test; - -import org.rocksdb.*; +package org.rocksdb; public class StatsCallbackMock implements StatisticsCollectorCallback { public int tickerCallbackCount = 0; diff --git a/java/org/rocksdb/test/TransactionLogIteratorTest.java b/java/src/test/java/org/rocksdb/TransactionLogIteratorTest.java similarity index 99% rename from java/org/rocksdb/test/TransactionLogIteratorTest.java rename to java/src/test/java/org/rocksdb/TransactionLogIteratorTest.java index 6d700dac9..1de2efdea 100644 --- a/java/org/rocksdb/test/TransactionLogIteratorTest.java +++ b/java/src/test/java/org/rocksdb/TransactionLogIteratorTest.java @@ -1,10 +1,9 @@ -package org.rocksdb.test; +package org.rocksdb; import org.junit.ClassRule; import org.junit.Rule; import org.junit.Test; import org.junit.rules.TemporaryFolder; -import org.rocksdb.*; import static org.assertj.core.api.Assertions.assertThat; diff --git a/java/org/rocksdb/test/TtlDBTest.java b/java/src/test/java/org/rocksdb/TtlDBTest.java similarity index 99% rename from java/org/rocksdb/test/TtlDBTest.java rename to java/src/test/java/org/rocksdb/TtlDBTest.java index 56f7ebc1a..0b816d66a 100644 --- a/java/org/rocksdb/test/TtlDBTest.java +++ b/java/src/test/java/org/rocksdb/TtlDBTest.java @@ -3,13 +3,12 @@ // LICENSE file in the root directory of this source tree. An additional grant // of patent rights can be found in the PATENTS file in the same directory. -package org.rocksdb.test; +package org.rocksdb; import org.junit.ClassRule; import org.junit.Rule; import org.junit.Test; import org.junit.rules.TemporaryFolder; -import org.rocksdb.*; import java.util.ArrayList; import java.util.List; diff --git a/java/org/rocksdb/test/Types.java b/java/src/test/java/org/rocksdb/Types.java similarity index 97% rename from java/org/rocksdb/test/Types.java rename to java/src/test/java/org/rocksdb/Types.java index 22fcd3537..5ad35f463 100644 --- a/java/org/rocksdb/test/Types.java +++ b/java/src/test/java/org/rocksdb/Types.java @@ -3,7 +3,7 @@ // LICENSE file in the root directory of this source tree. An additional grant // of patent rights can be found in the PATENTS file in the same directory. -package org.rocksdb.test; +package org.rocksdb; /** * Simple type conversion methods diff --git a/java/org/rocksdb/test/WriteBatchHandlerTest.java b/java/src/test/java/org/rocksdb/WriteBatchHandlerTest.java similarity index 98% rename from java/org/rocksdb/test/WriteBatchHandlerTest.java rename to java/src/test/java/org/rocksdb/WriteBatchHandlerTest.java index ca26c9275..b09cc9259 100644 --- a/java/org/rocksdb/test/WriteBatchHandlerTest.java +++ b/java/src/test/java/org/rocksdb/WriteBatchHandlerTest.java @@ -3,10 +3,7 @@ // LICENSE file in the root directory of this source tree. An additional grant // of patent rights can be found in the PATENTS file in the same directory. -package org.rocksdb.test; - -import org.rocksdb.RocksDBException; -import org.rocksdb.WriteBatch; +package org.rocksdb; import java.io.IOException; import java.util.ArrayList; diff --git a/java/org/rocksdb/test/WriteBatchTest.java b/java/src/test/java/org/rocksdb/WriteBatchTest.java similarity index 89% rename from java/org/rocksdb/test/WriteBatchTest.java rename to java/src/test/java/org/rocksdb/WriteBatchTest.java index cf855c121..89a9d5405 100644 --- a/java/org/rocksdb/test/WriteBatchTest.java +++ b/java/src/test/java/org/rocksdb/WriteBatchTest.java @@ -6,13 +6,12 @@ // Copyright (c) 2011 The LevelDB Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. See the AUTHORS file for names of contributors. -package org.rocksdb.test; +package org.rocksdb; import org.junit.ClassRule; import org.junit.Rule; import org.junit.Test; import org.junit.rules.TemporaryFolder; -import org.rocksdb.WriteBatch; import java.io.UnsupportedEncodingException; @@ -48,8 +47,8 @@ public class WriteBatchTest { batch.put("foo".getBytes("US-ASCII"), "bar".getBytes("US-ASCII")); batch.remove("box".getBytes("US-ASCII")); batch.put("baz".getBytes("US-ASCII"), "boo".getBytes("US-ASCII")); - WriteBatchInternal.setSequence(batch, 100); - assertThat(WriteBatchInternal.sequence(batch)). + WriteBatchTestInternalHelper.setSequence(batch, 100); + assertThat(WriteBatchTestInternalHelper.sequence(batch)). isNotNull(). isEqualTo(100); assertThat(batch.count()).isEqualTo(3); @@ -64,24 +63,24 @@ public class WriteBatchTest { throws UnsupportedEncodingException { WriteBatch b1 = new WriteBatch(); WriteBatch b2 = new WriteBatch(); - WriteBatchInternal.setSequence(b1, 200); - WriteBatchInternal.setSequence(b2, 300); - WriteBatchInternal.append(b1, b2); + WriteBatchTestInternalHelper.setSequence(b1, 200); + WriteBatchTestInternalHelper.setSequence(b2, 300); + WriteBatchTestInternalHelper.append(b1, b2); assertThat(getContents(b1).length).isEqualTo(0); assertThat(b1.count()).isEqualTo(0); b2.put("a".getBytes("US-ASCII"), "va".getBytes("US-ASCII")); - WriteBatchInternal.append(b1, b2); + WriteBatchTestInternalHelper.append(b1, b2); assertThat("Put(a, va)@200".equals(new String(getContents(b1), "US-ASCII"))); assertThat(b1.count()).isEqualTo(1); b2.clear(); b2.put("b".getBytes("US-ASCII"), "vb".getBytes("US-ASCII")); - WriteBatchInternal.append(b1, b2); + WriteBatchTestInternalHelper.append(b1, b2); assertThat(("Put(a, va)@200" + "Put(b, vb)@201") .equals(new String(getContents(b1), "US-ASCII"))); assertThat(b1.count()).isEqualTo(2); b2.remove("foo".getBytes("US-ASCII")); - WriteBatchInternal.append(b1, b2); + WriteBatchTestInternalHelper.append(b1, b2); assertThat(("Put(a, va)@200" + "Put(b, vb)@202" + "Put(b, vb)@201" + @@ -117,7 +116,7 @@ public class WriteBatchTest { * Package-private class which provides java api to access * c++ WriteBatchInternal. */ -class WriteBatchInternal { +class WriteBatchTestInternalHelper { static native void setSequence(WriteBatch batch, long sn); static native long sequence(WriteBatch batch); static native void append(WriteBatch b1, WriteBatch b2); diff --git a/java/org/rocksdb/test/WriteBatchWithIndexTest.java b/java/src/test/java/org/rocksdb/WriteBatchWithIndexTest.java similarity index 95% rename from java/org/rocksdb/test/WriteBatchWithIndexTest.java rename to java/src/test/java/org/rocksdb/WriteBatchWithIndexTest.java index dac3f1110..f7eed556a 100644 --- a/java/org/rocksdb/test/WriteBatchWithIndexTest.java +++ b/java/src/test/java/org/rocksdb/WriteBatchWithIndexTest.java @@ -7,20 +7,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. See the AUTHORS file for names of contributors. -package org.rocksdb.test; +package org.rocksdb; import org.junit.ClassRule; import org.junit.Rule; import org.junit.Test; import org.junit.rules.TemporaryFolder; -import org.rocksdb.WriteBatchWithIndex; -import org.rocksdb.DirectSlice; -import org.rocksdb.Options; -import org.rocksdb.RocksDB; -import org.rocksdb.RocksDBException; -import org.rocksdb.RocksIterator; -import org.rocksdb.WriteOptions; -import org.rocksdb.WBWIRocksIterator; import java.nio.ByteBuffer; import java.util.ArrayDeque; diff --git a/java/org/rocksdb/test/WriteOptionsTest.java b/java/src/test/java/org/rocksdb/WriteOptionsTest.java similarity index 94% rename from java/org/rocksdb/test/WriteOptionsTest.java rename to java/src/test/java/org/rocksdb/WriteOptionsTest.java index 70a68335d..4d8e6d97e 100644 --- a/java/org/rocksdb/test/WriteOptionsTest.java +++ b/java/src/test/java/org/rocksdb/WriteOptionsTest.java @@ -3,11 +3,10 @@ // LICENSE file in the root directory of this source tree. An additional grant // of patent rights can be found in the PATENTS file in the same directory. -package org.rocksdb.test; +package org.rocksdb; import org.junit.ClassRule; import org.junit.Test; -import org.rocksdb.WriteOptions; import static org.assertj.core.api.Assertions.assertThat; diff --git a/java/org/rocksdb/test/RocksJunitRunner.java b/java/src/test/java/org/rocksdb/test/RocksJunitRunner.java similarity index 100% rename from java/org/rocksdb/test/RocksJunitRunner.java rename to java/src/test/java/org/rocksdb/test/RocksJunitRunner.java diff --git a/java/org/rocksdb/test/EnvironmentTest.java b/java/src/test/java/org/rocksdb/util/EnvironmentTest.java similarity index 98% rename from java/org/rocksdb/test/EnvironmentTest.java rename to java/src/test/java/org/rocksdb/util/EnvironmentTest.java index b5af069da..b8e22bce1 100644 --- a/java/org/rocksdb/test/EnvironmentTest.java +++ b/java/src/test/java/org/rocksdb/util/EnvironmentTest.java @@ -2,10 +2,9 @@ // This source code is licensed under the BSD-style license found in the // LICENSE file in the root directory of this source tree. An additional grant // of patent rights can be found in the PATENTS file in the same directory. -package org.rocksdb.test; +package org.rocksdb.util; import org.junit.Test; -import org.rocksdb.util.Environment; import java.lang.reflect.Field; import java.lang.reflect.Modifier; diff --git a/java/org/rocksdb/test/SizeUnitTest.java b/java/src/test/java/org/rocksdb/util/SizeUnitTest.java similarity index 93% rename from java/org/rocksdb/test/SizeUnitTest.java rename to java/src/test/java/org/rocksdb/util/SizeUnitTest.java index 16f636267..517e1b2b5 100644 --- a/java/org/rocksdb/test/SizeUnitTest.java +++ b/java/src/test/java/org/rocksdb/util/SizeUnitTest.java @@ -2,10 +2,9 @@ // This source code is licensed under the BSD-style license found in the // LICENSE file in the root directory of this source tree. An additional grant // of patent rights can be found in the PATENTS file in the same directory. -package org.rocksdb.test; +package org.rocksdb.util; import org.junit.Test; -import org.rocksdb.util.SizeUnit; import static org.assertj.core.api.Assertions.assertThat;