2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
6 * The contents of this file are subject to the Mozilla Public License Version 1.1
7 * See LICENSE.TXT at the top of this package for the full license terms.
10 package eu
.etaxonomy
.cdm
.database
.types
;
12 import static org
.junit
.Assert
.assertEquals
;
14 import org
.apache
.logging
.log4j
.LogManager
;
15 import org
.apache
.logging
.log4j
.Logger
;
16 import org
.junit
.After
;
17 import org
.junit
.AfterClass
;
18 import org
.junit
.Before
;
19 import org
.junit
.BeforeClass
;
20 import org
.junit
.Test
;
22 import eu
.etaxonomy
.cdm
.database
.CdmDataSource
;
23 import eu
.etaxonomy
.cdm
.database
.CdmPersistentDataSource
;
24 import eu
.etaxonomy
.cdm
.database
.DatabaseTypeEnum
;
30 public class ODBCDatabaseTypeTest
{
32 @SuppressWarnings("unused")
33 private static final Logger logger
= LogManager
.getLogger();
35 private static DatabaseTypeEnum enumType
;
37 CdmPersistentDataSource dataSource
;
45 * @throws java.lang.Exception
48 public static void setUpBeforeClass() throws Exception
{
49 enumType
= DatabaseTypeEnum
.ODBC
;
53 * @throws java.lang.Exception
56 public static void tearDownAfterClass() throws Exception
{
60 * @throws java.lang.Exception
63 public void setUp() throws Exception
{
69 dataSource
= CdmPersistentDataSource
.save(
70 "sybaseTest", CdmDataSource
.NewInstance(enumType
, server
, dbName
, port
, username
, password
));
74 * @throws java.lang.Exception
77 public void tearDown() throws Exception
{
81 * Test method for {@link eu.etaxonomy.cdm.database.types.PostgreSQLDatabaseType#getConnectionString(eu.etaxonomy.cdm.database.ICdmDataSource)}.
84 public void testGetConnectionStringICdmDataSource() {
85 String expected
= "jdbc:odbc:" + server
;
86 assertEquals(expected
, enumType
.getConnectionString(dataSource
));
90 * Test method for {@link eu.etaxonomy.cdm.database.types.PostgreSQLDatabaseType#getConnectionString(eu.etaxonomy.cdm.database.ICdmDataSource, int)}.
93 public void testGetConnectionStringICdmDataSourceInt() {
95 String expected
= "jdbc:odbc:" + server
;
96 assertEquals(expected
, ((OdbcDatabaseType
)enumType
.getDatabaseType()).getConnectionString(dataSource
, port
));
100 * Test method for {@link eu.etaxonomy.cdm.database.types.PostgreSQLDatabaseType#getDatabaseNameByConnectionString(java.lang.String)}.
103 public void testGetDatabaseNameByConnectionString() {
105 assertEquals(dbName
, dataSource
.getDatabase());
109 * Test method for {@link eu.etaxonomy.cdm.database.types.DatabaseTypeBase#getServerNameByConnectionString(java.lang.String)}.
112 public void testGetServerNameByConnectionStringString() {
113 assertEquals(server
, dataSource
.getServer());
117 * Test method for {@link eu.etaxonomy.cdm.database.types.DatabaseTypeBase#getPortByConnectionString(java.lang.String)}.
120 public void testGetPortByConnectionStringString() {
122 assertEquals(port
, dataSource
.getPort());