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
.logging
.log4j
.LogManager
;import org
.apache
.logging
.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
.taxeditor
.lazyloading
.RemotePersistentCollectionTest
;
18 import eu
.etaxonomy
.taxeditor
.remoting
.source
.CdmRemoteSource
;
20 public class CdmRemoteSourceTest
extends BaseRemotingTest
{
21 private static final Logger logger
= LogManager
.getLogger(RemotePersistentCollectionTest
.class);
25 public void whenConnectingToInactiveServerThenFailToConnect() {
27 // check if non-active server throws the right exception
28 CdmRemoteSource inactiveCrs
= CdmRemoteSource
.NewInstance(sourceName
,
33 String dbSchemaVersion
= inactiveCrs
.getDbSchemaVersion();
34 Assert
.fail("getDbSchemaVersion() on inactive cdm server should have thrown RemoteAccessException");
35 } catch(CdmSourceException cse
) {
36 Assert
.fail("getDbSchemaVersion() on inactive cdm server should have thrown RemoteAccessException and not CdmSourceException");
37 } catch(RemoteAccessException rae
){
42 inactiveCrs
.isDbEmpty();
43 Assert
.fail("isDbEmpty() on inactive cdm server should have thrown RemoteAccessException");
44 } catch(CdmSourceException cse
) {
45 Assert
.fail("isDbEmpty() on inactive cdm server should have thrown RemoteAccessException and not CdmSourceException");
46 } catch(RemoteAccessException rae
){
51 inactiveCrs
.checkConnection();
52 Assert
.fail("checkConnection() on inactive cdm server should have thrown RemoteAccessException");
53 } catch(CdmSourceException cse
) {
54 Assert
.fail("checkConnection() on inactive cdm server should have thrown RemoteAccessException and not CdmSourceException");
55 } catch(RemoteAccessException rae
){
62 public void whenConnectingToAnActiveServerThenConnectSuccessfully() {
63 // check if active server throws the right exception
64 CdmRemoteSource activeCrs
= CdmRemoteSource
.NewInstance(sourceName
,
68 String dbSchemaVersion
= "";
70 dbSchemaVersion
= activeCrs
.getDbSchemaVersion();
71 } catch (CdmSourceException e
) {
72 Assert
.fail("getDbSchemaVersion() on active cdm server should not have thrown CdmSourceException");
74 logger
.info("dbSchemaVersion is " + dbSchemaVersion
);
77 boolean isDbEmpty
= false;
79 isDbEmpty
= activeCrs
.isDbEmpty();
80 } catch (CdmSourceException e
) {
81 Assert
.fail("isDbEmpty() on active cdm server should not have thrown CdmSourceException");
83 Assert
.assertFalse(isDbEmpty
);
88 isDbEmpty
= activeCrs
.checkConnection();
89 } catch (CdmSourceException e
) {
90 Assert
.fail("checkConnection() on active cdm server should not have thrown CdmSourceException");
92 Assert
.assertTrue(check
);