+++ /dev/null
-/**
-* Copyright (C) 2014 EDIT
-* European Distributed Institute of Taxonomy
-* http://www.e-taxonomy.eu
-*
-* The contents of this file are subject to the Mozilla Public License Version 1.1
-* See LICENSE.TXT at the top of this package for the full license terms.
-*/
-package eu.etaxonomy.taxeditor.httpinvoker;
-
-import org.apache.log4j.Level;
-import org.apache.log4j.Logger;
-import org.junit.Assert;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.springframework.remoting.RemoteAccessException;
-
-import eu.etaxonomy.cdm.config.CdmSourceException;
-import eu.etaxonomy.cdm.model.name.NomenclaturalCode;
-import eu.etaxonomy.cdm.remote.CdmRemoteSource;
-import eu.etaxonomy.taxeditor.lazyloading.RemotePersistentCollectionTest;
-
-public class CdmRemoteSourceTest extends BaseRemotingTest {
- private static final Logger logger = Logger.getLogger(RemotePersistentCollectionTest.class);
-
-
- @BeforeClass
- public static void initialize() {
-
- Logger.getRootLogger().setLevel(Level.INFO);
-
- }
-
- @Test
- public void whenConnectingToInactiveServerThenFailToConnect() {
- // check if non-active server throws the right exception
- CdmRemoteSource inactiveCrs = CdmRemoteSource.NewInstance(CDMServer.getInstance().getName(),
- CDMServer.getInstance().getHost(),
- 808080,
- CDMServer.getInstance().getContextPath(),
- NomenclaturalCode.ICNAFP);
- try {
- inactiveCrs.getDbSchemaVersion();
- Assert.fail("getDbSchemaVersion() on inactive cdm server should have thrown RemoteAccessException");
- } catch(CdmSourceException cse) {
- Assert.fail("getDbSchemaVersion() on inactive cdm server should have thrown RemoteAccessException and not CdmSourceException");
- } catch(RemoteAccessException rae){
-
- }
-
- try {
- inactiveCrs.isDbEmpty();
- Assert.fail("isDbEmpty() on inactive cdm server should have thrown RemoteAccessException");
- } catch(CdmSourceException cse) {
- Assert.fail("isDbEmpty() on inactive cdm server should have thrown RemoteAccessException and not CdmSourceException");
- } catch(RemoteAccessException rae){
-
- }
-
- try {
- inactiveCrs.checkConnection();
- Assert.fail("checkConnection() on inactive cdm server should have thrown RemoteAccessException");
- } catch(CdmSourceException cse) {
- Assert.fail("checkConnection() on inactive cdm server should have thrown RemoteAccessException and not CdmSourceException");
- } catch(RemoteAccessException rae){
-
- }
-
- }
-
- @Test
- public void whenConnectingToAnActiveServerWithServicesBlockedThenFailToAccessServices() {
-
- }
-
- @Test
- public void whenConnectingToAnActiveServerThenConnectSuccessfully() {
- // check if active server throws the right exception
- CdmRemoteSource activeCrs = CdmRemoteSource.NewInstance(CDMServer.getInstance().getName(),
- CDMServer.getInstance().getHost(),
- CDMServer.getInstance().getPort(),
- CDMServer.getInstance().getContextPath(),
- NomenclaturalCode.ICNAFP);
- String dbSchemaVersion = "";
- try {
- dbSchemaVersion = activeCrs.getDbSchemaVersion();
- } catch (CdmSourceException e) {
- Assert.fail("getDbSchemaVersion() on active cdm server should not have thrown CdmSourceException");
- }
- logger.info("dbSchemaVersion is " + dbSchemaVersion);
-
-
- boolean isDbEmpty = false;
- try {
- isDbEmpty = activeCrs.isDbEmpty();
- } catch (CdmSourceException e) {
- Assert.fail("isDbEmpty() on active cdm server should not have thrown CdmSourceException");
- }
- Assert.assertFalse(isDbEmpty);
-
-
- boolean check = true;
- try {
- isDbEmpty = activeCrs.checkConnection();
- } catch (CdmSourceException e) {
- Assert.fail("checkConnection() on active cdm server should not have thrown CdmSourceException");
- }
- Assert.assertTrue(check);
-
- }
-
-}