1
|
/**
|
2
|
* Copyright (C) 2007 EDIT
|
3
|
* European Distributed Institute of Taxonomy
|
4
|
* http://www.e-taxonomy.eu
|
5
|
*
|
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.
|
8
|
*/
|
9
|
|
10
|
package eu.etaxonomy.cdm.database.types;
|
11
|
|
12
|
import static org.junit.Assert.*;
|
13
|
|
14
|
import org.apache.log4j.Logger;
|
15
|
import org.junit.After;
|
16
|
import org.junit.AfterClass;
|
17
|
import org.junit.Before;
|
18
|
import org.junit.BeforeClass;
|
19
|
import org.junit.Test;
|
20
|
|
21
|
import eu.etaxonomy.cdm.database.CdmDataSource;
|
22
|
import eu.etaxonomy.cdm.database.CdmPersistentDataSource;
|
23
|
import eu.etaxonomy.cdm.database.DatabaseTypeEnum;
|
24
|
|
25
|
/**
|
26
|
* @author a.mueller
|
27
|
* @since 18.12.2008
|
28
|
* @version 1.0
|
29
|
*/
|
30
|
public class SybaseDatabaseTypeTest {
|
31
|
@SuppressWarnings("unused")
|
32
|
private static final Logger logger = Logger.getLogger(SybaseDatabaseTypeTest.class);
|
33
|
|
34
|
static DatabaseTypeEnum enumType;
|
35
|
|
36
|
CdmPersistentDataSource dataSource;
|
37
|
String server;
|
38
|
String dbName;
|
39
|
int port;
|
40
|
String username;
|
41
|
String password;
|
42
|
|
43
|
/**
|
44
|
* @throws java.lang.Exception
|
45
|
*/
|
46
|
@BeforeClass
|
47
|
public static void setUpBeforeClass() throws Exception {
|
48
|
enumType = DatabaseTypeEnum.Sybase;
|
49
|
}
|
50
|
|
51
|
/**
|
52
|
* @throws java.lang.Exception
|
53
|
*/
|
54
|
@AfterClass
|
55
|
public static void tearDownAfterClass() throws Exception {
|
56
|
}
|
57
|
|
58
|
/**
|
59
|
* @throws java.lang.Exception
|
60
|
*/
|
61
|
@Before
|
62
|
public void setUp() throws Exception {
|
63
|
server = "server";
|
64
|
dbName = "db";
|
65
|
port = 80;
|
66
|
username = "user";
|
67
|
password = "wd";
|
68
|
dataSource = CdmPersistentDataSource.save(
|
69
|
"sybaseTest",
|
70
|
CdmDataSource.NewInstance(enumType, server, dbName, port, username, password));
|
71
|
}
|
72
|
|
73
|
/**
|
74
|
* @throws java.lang.Exception
|
75
|
*/
|
76
|
@After
|
77
|
public void tearDown() throws Exception {
|
78
|
}
|
79
|
|
80
|
/**
|
81
|
* Test method for {@link eu.etaxonomy.cdm.database.types.PostgreSQLDatabaseType#getConnectionString(eu.etaxonomy.cdm.database.ICdmDataSource)}.
|
82
|
*/
|
83
|
@Test
|
84
|
public void testGetConnectionStringICdmDataSource() {
|
85
|
String expected = "jdbc:sybase:Tds:" + server + ":" + port + "/" + dbName;
|
86
|
assertEquals(expected, enumType.getConnectionString(dataSource));
|
87
|
}
|
88
|
|
89
|
/**
|
90
|
* Test method for {@link eu.etaxonomy.cdm.database.types.PostgreSQLDatabaseType#getConnectionString(eu.etaxonomy.cdm.database.ICdmDataSource, int)}.
|
91
|
*/
|
92
|
@Test
|
93
|
public void testGetConnectionStringICdmDataSourceInt() {
|
94
|
port = 357;
|
95
|
String expected = "jdbc:sybase:Tds:" + server + ":" + port + "/" + dbName;
|
96
|
assertEquals(expected,((SybaseDatabaseType)enumType.getDatabaseType()).getConnectionString(dataSource, port));
|
97
|
}
|
98
|
|
99
|
/**
|
100
|
* Test method for {@link eu.etaxonomy.cdm.database.types.PostgreSQLDatabaseType#getDatabaseNameByConnectionString(java.lang.String)}.
|
101
|
*/
|
102
|
@Test
|
103
|
public void testGetDatabaseNameByConnectionString() {
|
104
|
assertEquals(dbName, dataSource.getDatabase());
|
105
|
}
|
106
|
|
107
|
/**
|
108
|
* Test method for {@link eu.etaxonomy.cdm.database.types.DatabaseTypeBase#getServerNameByConnectionString(java.lang.String)}.
|
109
|
*/
|
110
|
@Test
|
111
|
public void testGetServerNameByConnectionStringString() {
|
112
|
assertEquals(server, dataSource.getServer());
|
113
|
}
|
114
|
|
115
|
/**
|
116
|
* Test method for {@link eu.etaxonomy.cdm.database.types.DatabaseTypeBase#getPortByConnectionString(java.lang.String)}.
|
117
|
*/
|
118
|
@Test
|
119
|
public void testGetPortByConnectionStringString() {
|
120
|
assertEquals(port, dataSource.getPort());
|
121
|
}
|
122
|
}
|