2 * Copyright (C) 2014 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.
9 package eu
.etaxonomy
.taxeditor
.httpinvoker
;
11 import org
.apache
.log4j
.Logger
;
12 import org
.junit
.Assert
;
13 import org
.junit
.Test
;
14 import org
.springframework
.remoting
.RemoteAccessException
;
16 import eu
.etaxonomy
.cdm
.config
.CdmSourceException
;
17 import eu
.etaxonomy
.cdm
.model
.name
.NomenclaturalCode
;
18 import eu
.etaxonomy
.taxeditor
.lazyloading
.RemotePersistentCollectionTest
;
19 import eu
.etaxonomy
.taxeditor
.remoting
.source
.CdmRemoteSource
;
21 public class CdmRemoteSourceTest
extends BaseRemotingTest
{
22 private static final Logger logger
= Logger
.getLogger(RemotePersistentCollectionTest
.class);
26 public void whenConnectingToInactiveServerThenFailToConnect() {
28 // check if non-active server throws the right exception
29 CdmRemoteSource inactiveCrs
= CdmRemoteSource
.NewInstance(sourceName
,
33 NomenclaturalCode
.ICNAFP
);
35 inactiveCrs
.getDbSchemaVersion();
36 Assert
.fail("getDbSchemaVersion() on inactive cdm server should have thrown RemoteAccessException");
37 } catch(CdmSourceException cse
) {
38 Assert
.fail("getDbSchemaVersion() on inactive cdm server should have thrown RemoteAccessException and not CdmSourceException");
39 } catch(RemoteAccessException rae
){
44 inactiveCrs
.isDbEmpty();
45 Assert
.fail("isDbEmpty() on inactive cdm server should have thrown RemoteAccessException");
46 } catch(CdmSourceException cse
) {
47 Assert
.fail("isDbEmpty() on inactive cdm server should have thrown RemoteAccessException and not CdmSourceException");
48 } catch(RemoteAccessException rae
){
53 inactiveCrs
.checkConnection();
54 Assert
.fail("checkConnection() on inactive cdm server should have thrown RemoteAccessException");
55 } catch(CdmSourceException cse
) {
56 Assert
.fail("checkConnection() on inactive cdm server should have thrown RemoteAccessException and not CdmSourceException");
57 } catch(RemoteAccessException rae
){
64 public void whenConnectingToAnActiveServerWithServicesBlockedThenFailToAccessServices() {
69 public void whenConnectingToAnActiveServerThenConnectSuccessfully() {
70 // check if active server throws the right exception
71 CdmRemoteSource activeCrs
= CdmRemoteSource
.NewInstance(sourceName
,
75 NomenclaturalCode
.ICNAFP
);
76 String dbSchemaVersion
= "";
78 dbSchemaVersion
= activeCrs
.getDbSchemaVersion();
79 } catch (CdmSourceException e
) {
80 Assert
.fail("getDbSchemaVersion() on active cdm server should not have thrown CdmSourceException");
82 logger
.info("dbSchemaVersion is " + dbSchemaVersion
);
85 boolean isDbEmpty
= false;
87 isDbEmpty
= activeCrs
.isDbEmpty();
88 } catch (CdmSourceException e
) {
89 Assert
.fail("isDbEmpty() on active cdm server should not have thrown CdmSourceException");
91 Assert
.assertFalse(isDbEmpty
);
96 isDbEmpty
= activeCrs
.checkConnection();
97 } catch (CdmSourceException e
) {
98 Assert
.fail("checkConnection() on active cdm server should not have thrown CdmSourceException");
100 Assert
.assertTrue(check
);