From 5dec9172d94bb7cdb72eba74f19cdce53f85b127 Mon Sep 17 00:00:00 2001 From: Joe Buck Date: Thu, 1 Nov 2012 17:14:10 -0700 Subject: [PATCH] Moving test java files into a proper heirarchy. Moving the compilation of tests classes from build.xml to Makefile and editing configure.ac to look for the junit4 jar in the default location of /usr/share/java. It is still possible to build and run tests from build.xml as well as Makefile. Signed-off-by: Joe Buck Reviewed-by: Noah Watkins --- configure.ac | 9 ++++ src/java/Makefile.am | 32 +++++++++++++-- src/java/README | 18 +++++--- src/java/build.xml | 41 ++++++++++--------- .../ceph/fs}/CephDoubleMountTest.java | 3 +- .../ceph/fs}/CephMountCreateTest.java | 4 +- .../test/{ => com/ceph/fs}/CephMountTest.java | 5 ++- .../{ => com/ceph/fs}/CephUnmountedTest.java | 4 +- 8 files changed, 79 insertions(+), 37 deletions(-) rename src/java/test/{ => com/ceph/fs}/CephDoubleMountTest.java (98%) rename src/java/test/{ => com/ceph/fs}/CephMountCreateTest.java (99%) rename src/java/test/{ => com/ceph/fs}/CephMountTest.java (99%) rename src/java/test/{ => com/ceph/fs}/CephUnmountedTest.java (99%) diff --git a/configure.ac b/configure.ac index 26b720748f11d..0d5eb9a38d9df 100644 --- a/configure.ac +++ b/configure.ac @@ -283,6 +283,15 @@ AS_IF([test "x$enable_cephfs_java" = "xyes"], [ AS_IF([test -r "$jnih"], [ EXTRA_JDK_INC_DIR=`dirname $jnih`])]) + # cephfs_java_test only makes sense if java is already turned on + # setup CLASSPATH for Debian default junit4.jar package + AS_IF([test "x$with_debug" = "xyes"], [ + dir='/usr/share/java' + junit4_jar=`find $dir -name junit4.jar | head -n 1` + AS_IF([test -r "$junit4_jar"], [ + EXTRA_CLASSPATH_JAR=`dirname $junit4_jar`/junit4.jar + AC_SUBST(EXTRA_CLASSPATH_JAR)])]) + # Check for Java programs: javac, javah, jar PATH_save=$PATH PATH="$PATH:$EXTRA_JDK_BIN_DIR" diff --git a/src/java/Makefile.am b/src/java/Makefile.am index d05df99d18690..cb04d0de6c840 100644 --- a/src/java/Makefile.am +++ b/src/java/Makefile.am @@ -25,7 +25,7 @@ JAVA_H = native/com_ceph_fs_CephMount.h CEPH_PROXY=java/com/ceph/fs/CephMount.class $(CEPH_PROXY): $(JAVA_SRC) - export CLASSPATH=java/ ; + export CLASSPATH=java/ ; \ $(JAVAC) -source 1.5 -target 1.5 java/com/ceph/fs/*.java $(JAVA_H): $(CEPH_PROXY) @@ -33,13 +33,37 @@ $(JAVA_H): $(CEPH_PROXY) $(JAVAH) -jni -o $@ com.ceph.fs.CephMount libcephfs.jar: $(CEPH_PROXY) - $(JAR) cf $@ $(JAVA_CLASSES:%=-C java %) # $(ESCAPED_JAVA_CLASSES:%=-C java %) + $(JAR) cf $@ $(JAVA_CLASSES:%=-C java %) javadir = $(libdir) java_DATA = libcephfs.jar +CLEANFILES = -rf java/com/ceph/fs/*.class $(JAVA_H) libcephfs.jar + BUILT_SOURCES = $(JAVA_H) -CLEANFILES = -rf java/com/ceph/fs/*.class $(JAVA_H) libcephfs.jar +# build the tests if *both* --enable-cephfs-java and --with-debug were specifed +if WITH_DEBUG + +JAVA_TEST_CLASSES = $(JAVA_TEST_SRC:test/%.java=%.class) + +JAVA_TEST_SRC = \ + test/com/ceph/fs/CephDoubleMountTest.java \ + test/com/ceph/fs/CephMountCreateTest.java \ + test/com/ceph/fs/CephMountTest.java \ + test/com/ceph/fs/CephUnmountedTest.java + +EXTRA_DIST += $(JAVA_TEST_SRC) + +java_test_src: $(JAVA_TEST_SRC) $(CEPH_PROXY) + export CLASSPATH=$(CLASSPATH):$(EXTRA_CLASSPATH_JAR):java/:test/ ; \ + $(JAVAC) -source 1.5 -target 1.5 test/com/ceph/fs/*.java + +libcephfs-test.jar: java_test_src + $(JAR) cf $@ $(JAVA_TEST_CLASSES:%=-C test %) + +java_DATA += libcephfs-test.jar -endif +CLEANFILES += test/com/ceph/fs/*.class libcephfs-test.jar +endif # WITH_DEBUG +endif #ENABLE_CEPHFS_JAVA diff --git a/src/java/README b/src/java/README index ca39a442c8b3b..0ffede3486f40 100644 --- a/src/java/README +++ b/src/java/README @@ -15,25 +15,31 @@ Autotools handles the build using the configure flag --enable-cephfs-java Testing ------- -These tests assume a live cluster, and depend on JUnit and Ant. +These tests assume a live cluster, and depend on JUnit4 and Ant. -To run the tests make sure that the JUnit JAR is available in the lib/ -directory. For example: +To run the tests make sure that the JUnit4 JAR is installed. +Install it via a package manager or like this: $ mkdir lib $ cd lib - $ curl -O https://github.com/downloads/KentBeck/junit/junit-4.8.2.jar + $ wget https://github.com/downloads/KentBeck/junit/junit-4.8.2.jar + +And then add the jar to the CLASSPATH. +*NOTE* for now, configure is only looking for this jar in the +/usr/share/java directory as junit4.jar. So create a softlink +to that location from wherever the junit jar is installed. Ant is used to run the unit test (apt-get install ant). For example: $ cd src/ $ ./vstart -d -n --localhost $ cd java - $ CEPHFS_CONF=../ceph.conf ant test + $ CEPHFS_CONF=../ceph.conf CLASSPATH=/usr/share/java/junit4.jar ant test 1. The tests depend on the compiled wrappers. If the wrappers are installed as part of a package (e.g. Debian package) then this should 'just work'. Ant will -also look in the current directory for 'libcephfs.jar' and in ../.libs for the +also look in the current directory for 'libcephfs.jar' and 'libcephfs-test.jar'; +and in ../.libs for the JNI library. If all else fails, set the environment variables CEPHFS_JAR, and CEPHFS_JNI_LIB accordingly. diff --git a/src/java/build.xml b/src/java/build.xml index 119a187034fd8..51f8aec92b511 100644 --- a/src/java/build.xml +++ b/src/java/build.xml @@ -5,61 +5,62 @@ - - - + - + + + - + + + - - + + - - - + + + - + + + + - - - - - + - - - + + + diff --git a/src/java/test/CephDoubleMountTest.java b/src/java/test/com/ceph/fs/CephDoubleMountTest.java similarity index 98% rename from src/java/test/CephDoubleMountTest.java rename to src/java/test/com/ceph/fs/CephDoubleMountTest.java index 647d9c35ada30..62ca1cb8930fb 100644 --- a/src/java/test/CephDoubleMountTest.java +++ b/src/java/test/com/ceph/fs/CephDoubleMountTest.java @@ -17,13 +17,14 @@ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ +package com.ceph.fs; + import java.io.FileNotFoundException; import java.io.IOException; import java.util.UUID; import org.junit.*; import static org.junit.Assert.*; -import com.ceph.fs.*; public class CephDoubleMountTest { diff --git a/src/java/test/CephMountCreateTest.java b/src/java/test/com/ceph/fs/CephMountCreateTest.java similarity index 99% rename from src/java/test/CephMountCreateTest.java rename to src/java/test/com/ceph/fs/CephMountCreateTest.java index c5e5b36c2fd48..9df9342571fd3 100644 --- a/src/java/test/CephMountCreateTest.java +++ b/src/java/test/com/ceph/fs/CephMountCreateTest.java @@ -17,13 +17,13 @@ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ +package com.ceph.fs; + import java.io.FileNotFoundException; import org.junit.*; import java.util.UUID; import static org.junit.Assert.*; -import com.ceph.fs.*; - /* * This tests the mount root dir functionality. It creates an empty * directory in the real root, then it re-mounts the file system diff --git a/src/java/test/CephMountTest.java b/src/java/test/com/ceph/fs/CephMountTest.java similarity index 99% rename from src/java/test/CephMountTest.java rename to src/java/test/com/ceph/fs/CephMountTest.java index 0b0d1a2915cf0..b6e58231b9e4c 100644 --- a/src/java/test/CephMountTest.java +++ b/src/java/test/com/ceph/fs/CephMountTest.java @@ -17,14 +17,15 @@ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ + +package com.ceph.fs; + import java.io.FileNotFoundException; import java.io.IOException; import java.util.UUID; import org.junit.*; import static org.junit.Assert.*; -import com.ceph.fs.*; - /* * Coverage * - Everything is covered in at least success cases. diff --git a/src/java/test/CephUnmountedTest.java b/src/java/test/com/ceph/fs/CephUnmountedTest.java similarity index 99% rename from src/java/test/CephUnmountedTest.java rename to src/java/test/com/ceph/fs/CephUnmountedTest.java index 8eeb2d1b23de9..79f9d7ac18ca4 100644 --- a/src/java/test/CephUnmountedTest.java +++ b/src/java/test/com/ceph/fs/CephUnmountedTest.java @@ -17,11 +17,11 @@ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ +package com.ceph.fs; + import org.junit.*; import static org.junit.Assert.*; -import com.ceph.fs.*; - public class CephUnmountedTest { private CephMount mount; -- 2.39.5