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 String dbSchemaVersion
= 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 whenConnectingToAnActiveServerThenConnectSuccessfully() {
65 // check if active server throws the right exception
66 CdmRemoteSource activeCrs
= CdmRemoteSource
.NewInstance(sourceName
,
70 NomenclaturalCode
.ICNAFP
);
71 String dbSchemaVersion
= "";
73 dbSchemaVersion
= activeCrs
.getDbSchemaVersion();
74 } catch (CdmSourceException e
) {
75 Assert
.fail("getDbSchemaVersion() on active cdm server should not have thrown CdmSourceException");
77 logger
.info("dbSchemaVersion is " + dbSchemaVersion
);
80 boolean isDbEmpty
= false;
82 isDbEmpty
= activeCrs
.isDbEmpty();
83 } catch (CdmSourceException e
) {
84 Assert
.fail("isDbEmpty() on active cdm server should not have thrown CdmSourceException");
86 Assert
.assertFalse(isDbEmpty
);
91 isDbEmpty
= activeCrs
.checkConnection();
92 } catch (CdmSourceException e
) {
93 Assert
.fail("checkConnection() on active cdm server should not have thrown CdmSourceException");
95 Assert
.assertTrue(check
);