Project

General

Profile

Download (3.77 KB) Statistics
| Branch: | Tag: | Revision:
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.logging.log4j.LogManager;import org.apache.logging.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 SqlServer2000DatabaseTypeTest {
31
	@SuppressWarnings("unused")
32
	private static final Logger logger = LogManager.getLogger(SqlServer2000DatabaseTypeTest.class);
33
	
34
	CdmPersistentDataSource dataSource;
35
	static DatabaseTypeEnum enumType;
36
	String server; 
37
	String dbName;
38
	int port;
39
	String username;
40
	String password;
41
	
42
	/**
43
	 * @throws java.lang.Exception
44
	 */
45
	@BeforeClass
46
	public static void setUpBeforeClass() throws Exception {
47
		enumType = DatabaseTypeEnum.SqlServer2005;
48
	}
49

    
50
	/**
51
	 * @throws java.lang.Exception
52
	 */
53
	@AfterClass
54
	public static void tearDownAfterClass() throws Exception {
55
	}
56

    
57
	/**
58
	 * @throws java.lang.Exception
59
	 */
60
	@Before
61
	public void setUp() throws Exception {
62
		server = "server";
63
		dbName = "db";
64
		port = 80;
65
		username = "user";
66
		password = "wd";
67
		dataSource = CdmPersistentDataSource.save(
68
				"postgreSqlTest", 
69
				CdmDataSource.NewInstance(enumType, server, dbName, port, username, password));
70
	}
71

    
72
	/**
73
	 * @throws java.lang.Exception
74
	 */
75
	@After
76
	public void tearDown() throws Exception {
77
	}
78

    
79
	/**
80
	 * Test method for {@link eu.etaxonomy.cdm.database.types.PostgreSQLDatabaseType#getConnectionString(eu.etaxonomy.cdm.database.ICdmDataSource)}.
81
	 */
82
	@Test
83
	public void testGetConnectionStringICdmDataSource() {
84
		//OLD: String expected = "jdbc:microsoft:sqlserver://" + server + ":" + port + ";databaseName=" + dbName + ";SelectMethod=cursor";
85
		String expected = "jdbc:sqlserver://" + server + ":" + port + ";databaseName=" + dbName + ";SelectMethod=cursor";
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
		//OLD: String expected = "jdbc:microsoft:sqlserver://" + server + ":" + port + ";databaseName=" + dbName + ";SelectMethod=cursor";
96
		String expected = "jdbc:sqlserver://" + server + ":" + port + ";databaseName=" + dbName + ";SelectMethod=cursor";
97
		assertEquals(expected, ((SqlServer2005DatabaseType)enumType.getDatabaseType()).getConnectionString(dataSource, port));
98
	}
99

    
100
	/**
101
	 * Test method for {@link eu.etaxonomy.cdm.database.types.PostgreSQLDatabaseType#getDatabaseNameByConnectionString(java.lang.String)}.
102
	 */
103
	@Test
104
	public void testGetDatabaseNameByConnectionString() {
105
		assertEquals(dbName, dataSource.getDatabase());
106
	}
107

    
108
	/**
109
	 * Test method for {@link eu.etaxonomy.cdm.database.types.DatabaseTypeBase#getServerNameByConnectionString(java.lang.String)}.
110
	 */
111
	@Test
112
	public void testGetServerNameByConnectionStringString() {
113
		assertEquals(server, dataSource.getServer());
114
	}
115

    
116
	/**
117
	 * Test method for {@link eu.etaxonomy.cdm.database.types.DatabaseTypeBase#getPortByConnectionString(java.lang.String)}.
118
	 */
119
	@Test
120
	public void testGetPortByConnectionStringString() {
121
		assertEquals(port, dataSource.getPort());
122
	}
123
}
(4-4/6)