summaryrefslogtreecommitdiff
path: root/qpid/java/broker-plugins/jdbc-store/src/test
diff options
context:
space:
mode:
authorKeith Wall <kwall@apache.org>2014-06-18 22:15:54 +0000
committerKeith Wall <kwall@apache.org>2014-06-18 22:15:54 +0000
commitbaa3cc48506e60d86f44577a410fd3683be30014 (patch)
treee334e48db83d6f9209b5a71f76e1b657a35b5710 /qpid/java/broker-plugins/jdbc-store/src/test
parent3a95f8c316e8d81a876094409a5952b3f41b5ba3 (diff)
downloadqpid-python-baa3cc48506e60d86f44577a410fd3683be30014.tar.gz
QPID-5822: [Java Broker] Replace low level BDB/JDBC attributes in fovour of context variables from the model
* BDB attributes environmentConfiguration/replicatedEnvironmentConfiguration removed. User can now specify context variables with the configuration keys that are understood by JE itself. * JDBC attributes bigIntType/bytesForBlob/varBinaryType/blobType are now context variables with names begining qpid.jdbcstore. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1603655 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/java/broker-plugins/jdbc-store/src/test')
-rw-r--r--qpid/java/broker-plugins/jdbc-store/src/test/java/org/apache/qpid/server/store/jdbc/JDBCDetailsTest.java94
1 files changed, 94 insertions, 0 deletions
diff --git a/qpid/java/broker-plugins/jdbc-store/src/test/java/org/apache/qpid/server/store/jdbc/JDBCDetailsTest.java b/qpid/java/broker-plugins/jdbc-store/src/test/java/org/apache/qpid/server/store/jdbc/JDBCDetailsTest.java
new file mode 100644
index 0000000000..67e9960ca7
--- /dev/null
+++ b/qpid/java/broker-plugins/jdbc-store/src/test/java/org/apache/qpid/server/store/jdbc/JDBCDetailsTest.java
@@ -0,0 +1,94 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.qpid.server.store.jdbc;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+import junit.framework.TestCase;
+
+public class JDBCDetailsTest extends TestCase
+{
+ public void testDerby()
+ {
+ JDBCDetails derbyDetails = JDBCDetails.getDetailsForJdbcUrl("jdbc:derby:sample",
+ Collections.<String, String>emptyMap());
+ assertEquals("derby", derbyDetails.getVendor());
+ assertEquals("varchar(%d) for bit data", derbyDetails.getVarBinaryType());
+ assertEquals("bigint", derbyDetails.getBigintType());
+ assertEquals("blob", derbyDetails.getBlobType());
+ assertFalse(derbyDetails.isUseBytesMethodsForBlob());
+
+ assertTrue(derbyDetails.isKnownVendor());
+ assertFalse(derbyDetails.isOverridden());
+ }
+
+ public void testUnknownVendor_UsesFallbackDetails()
+ {
+ JDBCDetails details = JDBCDetails.getDetailsForJdbcUrl("jdbc:homedb:", Collections.<String, String>emptyMap());
+ assertEquals("fallback", details.getVendor());
+ assertEquals("varchar(%d) for bit data", details.getVarBinaryType());
+ assertEquals("bigint", details.getBigintType());
+ assertEquals("blob", details.getBlobType());
+ assertEquals(false, details.isUseBytesMethodsForBlob());
+ assertFalse(details.isOverridden());
+ assertFalse(details.isKnownVendor());
+ }
+
+ public void testDerbyWithOverride()
+ {
+
+ Map<String, String> contextMap = new HashMap<>();
+ contextMap.put(JDBCDetails.CONTEXT_JDBCSTORE_VARBINARYTYPE, "myvarbin");
+
+ JDBCDetails derbyDetails = JDBCDetails.getDetailsForJdbcUrl("jdbc:derby:sample", contextMap);
+ assertEquals("derby", derbyDetails.getVendor());
+ assertEquals("myvarbin", derbyDetails.getVarBinaryType());
+ assertEquals("bigint", derbyDetails.getBigintType());
+ assertEquals("blob", derbyDetails.getBlobType());
+ assertFalse(derbyDetails.isUseBytesMethodsForBlob());
+
+ assertTrue(derbyDetails.isKnownVendor());
+ assertTrue(derbyDetails.isOverridden());
+ }
+
+
+
+
+ public void testRecognisedDriver_AllDetailsProvidedByContext()
+ {
+ Map<String, String> contextMap = new HashMap<>();
+ contextMap.put(JDBCDetails.CONTEXT_JDBCSTORE_VARBINARYTYPE, "myvarbin");
+ contextMap.put(JDBCDetails.CONTEXT_JDBCSTORE_BIGINTTYPE, "mybigint");
+ contextMap.put(JDBCDetails.CONTEXT_JDBCSTORE_BLOBTYPE, "myblob");
+ contextMap.put(JDBCDetails.CONTEXT_JDBCSTORE_USEBYTESFORBLOB, "true");
+
+ JDBCDetails details = JDBCDetails.getDetailsForJdbcUrl("jdbc:sybase:", contextMap);
+ assertEquals("sybase", details.getVendor());
+ assertEquals("myvarbin", details.getVarBinaryType());
+ assertEquals("mybigint", details.getBigintType());
+ assertEquals("myblob", details.getBlobType());
+ assertEquals(true, details.isUseBytesMethodsForBlob());
+ assertTrue(details.isKnownVendor());
+ assertTrue(details.isOverridden());
+ }
+
+} \ No newline at end of file