Project

General

Profile

Download (2.67 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.assertEquals;
13

    
14
import org.apache.logging.log4j.LogManager;import org.apache.logging.log4j.Logger;
15
import org.junit.After;
16
import org.junit.Before;
17
import org.junit.BeforeClass;
18
import org.junit.Test;
19

    
20
import eu.etaxonomy.cdm.database.CdmDataSource;
21
import eu.etaxonomy.cdm.database.CdmPersistentDataSource;
22
import eu.etaxonomy.cdm.database.DatabaseTypeEnum;
23

    
24
/**
25
 * @author a.mueller
26
 * @since 18.12.2008
27
 * @version 1.0
28
 */
29
public class OracleDatabaseTypeTest {
30
	@SuppressWarnings("unused")
31
	private static final Logger logger = LogManager.getLogger(OracleDatabaseTypeTest.class);
32
	
33
	static DatabaseTypeEnum enumType;
34
	
35
	CdmPersistentDataSource dataSource;
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.Oracle;
48
	}
49

    
50
	/**
51
	 * @throws java.lang.Exception
52
	 */
53
	@Before
54
	public void setUp() throws Exception {
55
		server = "server";
56
		dbName = "db";
57
		port = 80;
58
		username = "user";
59
		password = "wd";
60
		dataSource = CdmPersistentDataSource.save(
61
				"oracleTest", 
62
				CdmDataSource.NewInstance(enumType, server, dbName, port, username, password));
63
	}
64

    
65
	/**
66
	 * @throws java.lang.Exception
67
	 */
68
	@After
69
	public void tearDown() throws Exception {
70
	}
71

    
72

    
73
	@Test
74
	public void testGetConnectionStringICdmDataSource() {
75
		String expected = "jdbc:oracle:thin:@" + server + ":" + port + ":" + dbName ;
76
		assertEquals(expected, enumType.getConnectionString(dataSource));
77
	}
78
	
79
	@Test
80
	public void testGetConnectionStringICdmDataSourceInt() {
81
		port = 357;
82
		String expected = "jdbc:oracle:thin:@" + server + ":" + port + ":" + dbName ;
83
		assertEquals(expected, ((OracleDatabaseType)enumType.getDatabaseType()).getConnectionString(dataSource, port));
84
	}
85

    
86
	@Test
87
	public void testGetDatabaseNameByConnectionString() {
88
		assertEquals(dbName, dataSource.getDatabase());
89
	}
90

    
91

    
92
	@Test
93
	public void testGetServerNameByConnectionStringString() {
94
		assertEquals(server, dataSource.getServer());
95
	}
96

    
97
	/**
98
	 * Test method for {@link eu.etaxonomy.cdm.database.types.DatabaseTypeBase#getPortByConnectionString(java.lang.String)}.
99
	 */
100
	@Test
101
	public void testGetPortByConnectionStringString() {
102
		assertEquals(port, dataSource.getPort());
103
	}
104
}
(2-2/6)