diff options
| author | Alex Rudyy <orudyy@apache.org> | 2015-04-15 09:47:28 +0000 |
|---|---|---|
| committer | Alex Rudyy <orudyy@apache.org> | 2015-04-15 09:47:28 +0000 |
| commit | 0a0baee45ebcff44635907d457c4ff6810b09c87 (patch) | |
| tree | 8bfb0f9eddbc23cff88af69be80ab3ce7d47011c /qpid/java/broker-plugins/jdbc-store/src/test | |
| parent | 54aa3d7070da16ce55c28ccad3f7d0871479e461 (diff) | |
| download | qpid-python-0a0baee45ebcff44635907d457c4ff6810b09c87.tar.gz | |
QPID-6481: Move java source tree to top level
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1673693 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/java/broker-plugins/jdbc-store/src/test')
2 files changed, 0 insertions, 252 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 deleted file mode 100644 index 67e9960ca7..0000000000 --- a/qpid/java/broker-plugins/jdbc-store/src/test/java/org/apache/qpid/server/store/jdbc/JDBCDetailsTest.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * 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 diff --git a/qpid/java/broker-plugins/jdbc-store/src/test/java/org/apache/qpid/server/store/jdbc/JDBCMessageStoreTest.java b/qpid/java/broker-plugins/jdbc-store/src/test/java/org/apache/qpid/server/store/jdbc/JDBCMessageStoreTest.java deleted file mode 100644 index 3a85ae3257..0000000000 --- a/qpid/java/broker-plugins/jdbc-store/src/test/java/org/apache/qpid/server/store/jdbc/JDBCMessageStoreTest.java +++ /dev/null @@ -1,158 +0,0 @@ -/* - * - * 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 static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -import java.sql.Connection; -import java.sql.DatabaseMetaData; -import java.sql.DriverManager; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.HashSet; -import java.util.Set; - -import org.apache.qpid.server.model.VirtualHost; -import org.apache.qpid.server.store.MessageStore; -import org.apache.qpid.server.store.MessageStoreTestCase; -import org.apache.qpid.server.virtualhost.jdbc.JDBCVirtualHost; - -public class JDBCMessageStoreTest extends MessageStoreTestCase -{ - private String _connectionURL; - - @Override - public void tearDown() throws Exception - { - try - { - shutdownDerby(); - } - finally - { - super.tearDown(); - } - } - - public void testOnDelete() throws Exception - { - Set<String> expectedTables = GenericJDBCMessageStore.MESSAGE_STORE_TABLE_NAMES; - assertTablesExist(expectedTables, true); - getStore().closeMessageStore(); - assertTablesExist(expectedTables, true); - getStore().onDelete(mock(JDBCVirtualHost.class)); - assertTablesExist(expectedTables, false); - } - - @Override - protected VirtualHost createVirtualHost() - { - _connectionURL = "jdbc:derby:memory:/" + getTestName() + ";create=true"; - - final JDBCVirtualHost jdbcVirtualHost = mock(JDBCVirtualHost.class); - when(jdbcVirtualHost.getConnectionUrl()).thenReturn(_connectionURL); - when(jdbcVirtualHost.getUsername()).thenReturn("test"); - when(jdbcVirtualHost.getPassword()).thenReturn("pass"); - return jdbcVirtualHost; - } - - - @Override - protected MessageStore createMessageStore() - { - return new GenericJDBCMessageStore(); - } - - private void assertTablesExist(Set<String> expectedTables, boolean exists) throws SQLException - { - Set<String> existingTables = getTableNames(); - for (String tableName : expectedTables) - { - assertEquals("Table " + tableName + (exists ? " is not found" : " actually exist"), exists, - existingTables.contains(tableName)); - } - } - - private Set<String> getTableNames() throws SQLException - { - Set<String> tableNames = new HashSet<String>(); - Connection conn = null; - try - { - conn = openConnection(); - DatabaseMetaData metaData = conn.getMetaData(); - ResultSet tables = metaData.getTables(null, null, null, new String[] { "TABLE" }); - try - { - while (tables.next()) - { - tableNames.add(tables.getString("TABLE_NAME")); - } - } - finally - { - tables.close(); - } - } - finally - { - if (conn != null) - { - conn.close(); - } - } - return tableNames; - } - - private Connection openConnection() throws SQLException - { - return DriverManager.getConnection(_connectionURL); - } - - - private void shutdownDerby() throws SQLException - { - Connection connection = null; - try - { - connection = DriverManager.getConnection("jdbc:derby:memory:/" + getTestName() + ";shutdown=true"); - } - catch(SQLException e) - { - if (e.getSQLState().equalsIgnoreCase("08006")) - { - //expected and represents a clean shutdown of this database only, do nothing. - } - else - { - throw e; - } - } - finally - { - if (connection != null) - { - connection.close(); - } - } - } -} |
