You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by jb...@apache.org on 2012/01/28 05:28:10 UTC
[5/5] git commit: test to expose missing dependencies
test to expose missing dependencies
Patch by eevans; reviewed by Dave Brosius for CASSANDRA-3665
Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/32075c4a
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/32075c4a
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/32075c4a
Branch: refs/heads/trunk
Commit: 32075c4aecf06bf28cc415ea5ae3fa3cbc805983
Parents: 2a1ec27
Author: Eric Evans <ee...@apache.org>
Authored: Thu Jan 26 16:02:34 2012 -0600
Committer: Eric Evans <ee...@apache.org>
Committed: Fri Jan 27 13:52:33 2012 -0600
----------------------------------------------------------------------
build.xml | 25 ++++++++
.../apache/cassandra/cql/jdbc/ClientUtilsTest.java | 48 +++++++++++++++
2 files changed, 73 insertions(+), 0 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cassandra/blob/32075c4a/build.xml
----------------------------------------------------------------------
diff --git a/build.xml b/build.xml
index 7169ff0..07a8af6 100644
--- a/build.xml
+++ b/build.xml
@@ -1038,6 +1038,31 @@ url=${svn.entry.url}?pathrev=${svn.entry.commit.revision}
</sequential>
</macrodef>
+ <!--
+ This test target is a bit different. It's purpose is to exercise the
+ clientutil jar in order to expose any new dependencies. For that
+ reason we use the classes from the jar, and a carefully constructed
+ classpath which only contains what we expect users to need.
+ -->
+ <target name="test-clientutil-jar" depends="build-test,jar" description="Test clientutil jar">
+ <junit>
+ <test name="org.apache.cassandra.cql.jdbc.ClientUtilsTest" />
+ <formatter type="brief" usefile="false" />
+ <classpath>
+ <pathelement location="${test.classes}" />
+ <pathelement location="${build.dir}/${ant.project.name}-clientutil-${version}.jar" />
+
+ <fileset dir="${build.dir.lib}">
+ <include name="**/junit*.jar" />
+ </fileset>
+ <fileset dir="${build.lib}">
+ <include name="**/guava*.jar" />
+ <include name="**/commons-lang*.jar" />
+ </fileset>
+ </classpath>
+ </junit>
+ </target>
+
<target name="test" depends="build-test" description="Execute unit tests">
<testmacro suitename="unit" inputdir="${test.unit.src}" timeout="60000">
<jvmarg value="-Dlegacy-sstable-root=${test.data}/legacy-sstables"/>
http://git-wip-us.apache.org/repos/asf/cassandra/blob/32075c4a/test/unit/org/apache/cassandra/cql/jdbc/ClientUtilsTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/cql/jdbc/ClientUtilsTest.java b/test/unit/org/apache/cassandra/cql/jdbc/ClientUtilsTest.java
new file mode 100644
index 0000000..c98b1d9
--- /dev/null
+++ b/test/unit/org/apache/cassandra/cql/jdbc/ClientUtilsTest.java
@@ -0,0 +1,48 @@
+package org.apache.cassandra.cql.jdbc;
+
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.nio.ByteBuffer;
+import java.sql.Date;
+import java.util.UUID;
+
+import org.apache.cassandra.utils.UUIDGen;
+import org.junit.Test;
+
+public class ClientUtilsTest
+{
+ /** Exercises the classes in the clientutil jar to expose missing dependencies. */
+ @Test
+ public void test() throws UnknownHostException
+ {
+ JdbcAscii.instance.compose(JdbcAscii.instance.decompose("string"));
+ JdbcBoolean.instance.compose(JdbcBoolean.instance.decompose(true));
+ JdbcBytes.instance.compose(JdbcBytes.instance.decompose(ByteBuffer.wrap("string".getBytes())));
+ JdbcDate.instance.compose(JdbcDate.instance.decompose(new Date(System.currentTimeMillis())));
+ JdbcDecimal.instance.compose(JdbcDecimal.instance.decompose(new BigDecimal(1)));
+ JdbcDouble.instance.compose(JdbcDouble.instance.decompose(new Double(1.0d)));
+ JdbcFloat.instance.compose(JdbcFloat.instance.decompose(new Float(1.0f)));
+ JdbcInt32.instance.compose(JdbcInt32.instance.decompose(1));
+ JdbcInteger.instance.compose(JdbcInteger.instance.decompose(new BigInteger("1")));
+ JdbcLong.instance.compose(JdbcLong.instance.decompose(1L));
+ JdbcUTF8.instance.compose(JdbcUTF8.instance.decompose("string"));
+
+ // UUIDGen
+ UUID uuid = UUIDGen.makeType1UUIDFromHost(InetAddress.getLocalHost());
+ JdbcTimeUUID.instance.compose(JdbcTimeUUID.instance.decompose(uuid));
+ JdbcUUID.instance.compose(JdbcUUID.instance.decompose(uuid));
+ JdbcLexicalUUID.instance.compose(JdbcLexicalUUID.instance.decompose(uuid));
+
+ // Raise a MarshalException
+ try
+ {
+ JdbcLexicalUUID.instance.getString(ByteBuffer.wrap("notauuid".getBytes()));
+ }
+ catch (MarshalException me)
+ {
+ // Success
+ }
+ }
+}