Project

General

Profile

« Previous | Next » 

Revision 388959b4

Added by Cherian Mathew about 10 years ago

cdm.datasources.xml : added test sources settings file
CdmRemoteSourceTest, RemoteLazyLoadingTest : updated tests
HttpInvokerServicesTest, CdmPersistentRemoteSourceTest, CdmApplicationRemoteControllerTest : new test classes for remoting
RemoteApplicationConfigurationTest : no longer a real test, but a super class for remote tests

View differences:

eu.etaxonomy.taxeditor.cdmlib/src/test/java/eu/etaxonomy/taxeditor/remoting/CdmRemoteSourceTest.java
1
/**
2
* Copyright (C) 2014 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
*/
1 9
package eu.etaxonomy.taxeditor.remoting;
2 10

  
3 11
import org.apache.log4j.Level;
......
16 24

  
17 25
public class CdmRemoteSourceTest extends UnitilsJUnit4 {
18 26
	private static final Logger logger = Logger.getLogger(RemotePersistentCollectionTest.class);
19
	@Rule
20
	public ExpectedException exception = ExpectedException.none();
27

  
21 28
	
22 29
	@BeforeClass
23 30
	public static void initialize() {
......
26 33
	}
27 34
	
28 35
	@Test
29
	public void localCdmRemoteSourceConnectionTest() {
36
	public void whenConnectingToInactiveServerThenFailToConnect() {
30 37
		// check if non-active server throws the right exception
31
		CdmRemoteSource crs = CdmRemoteSource.NewInstance("local", "127.0.0.1", 808080, "", NomenclaturalCode.ICNAFP);
38
		CdmRemoteSource inactiveCrs = CdmRemoteSource.NewInstance("local", "127.0.0.1", 808080, "", NomenclaturalCode.ICNAFP);
32 39
		try {
33
			crs.getDbSchemaVersion();
40
			inactiveCrs.getDbSchemaVersion();
34 41
			Assert.fail("getDbSchemaVersion() on inactive cdm server should have thrown RemoteAccessException");
35 42
		} catch(CdmSourceException cse) {
36 43
			Assert.fail("getDbSchemaVersion() on inactive cdm server should have thrown RemoteAccessException and not CdmSourceException");
......
39 46
		}
40 47
		
41 48
		try {
42
			crs.isDbEmpty();
49
			inactiveCrs.isDbEmpty();
43 50
			Assert.fail("isDbEmpty() on inactive cdm server should have thrown RemoteAccessException");
44 51
		} catch(CdmSourceException cse) {
45 52
			Assert.fail("isDbEmpty() on inactive cdm server should have thrown RemoteAccessException and not CdmSourceException");
......
48 55
		}
49 56
		
50 57
		try {
51
			crs.checkConnection();
58
			inactiveCrs.checkConnection();
52 59
			Assert.fail("checkConnection() on inactive cdm server should have thrown RemoteAccessException");
53 60
		} catch(CdmSourceException cse) {
54 61
			Assert.fail("checkConnection() on inactive cdm server should have thrown RemoteAccessException and not CdmSourceException");
......
56 63
			
57 64
		}
58 65
		
66
	}
67
	
68
	@Test
69
	public void whenConnectingToAnActiveServerWithServicesBlockedThenFailToAccessServices() {
70
		
71
	}
72
	
73
	@Test
74
	public void whenConnectingToAnActiveServerThenConnectSuccessfully() {
59 75
		// check if active server throws the right exception
60
		crs = CdmRemoteSource.NewInstance("local", "127.0.0.1", 8080, "", NomenclaturalCode.ICNAFP);
76
		CdmRemoteSource activeCrs = CdmRemoteSource.NewInstance("local", "127.0.0.1", 8080, "", NomenclaturalCode.ICNAFP);
61 77
		String dbSchemaVersion = "";
62 78
		try {
63
			dbSchemaVersion = crs.getDbSchemaVersion();
79
			dbSchemaVersion = activeCrs.getDbSchemaVersion();
64 80
		} catch (CdmSourceException e) {
65 81
			Assert.fail("getDbSchemaVersion() on active cdm server should not have thrown CdmSourceException");
66 82
		}
......
69 85

  
70 86
		boolean isDbEmpty = false;
71 87
		try {
72
			isDbEmpty = crs.isDbEmpty();
88
			isDbEmpty = activeCrs.isDbEmpty();
73 89
		} catch (CdmSourceException e) {
74 90
			Assert.fail("isDbEmpty() on active cdm server should not have thrown CdmSourceException");
75 91
		}
......
78 94
		
79 95
		boolean check = true;
80 96
		try {
81
			isDbEmpty = crs.checkConnection();
97
			isDbEmpty = activeCrs.checkConnection();
82 98
		} catch (CdmSourceException e) {
83 99
			Assert.fail("checkConnection() on active cdm server should not have thrown CdmSourceException");
84 100
		}

Also available in: Unified diff