eu.etaxonomy.taxeditor.cdmlib/src/main/resources/eu/etaxonomy/cdm/remotingApplicationContext.xml -text
eu.etaxonomy.taxeditor.cdmlib/src/main/resources/eu/etaxonomy/cdm/remoting_persistence_security.xml -text
eu.etaxonomy.taxeditor.cdmlib/src/main/resources/eu/etaxonomy/cdm/remoting_services_security.xml -text
+eu.etaxonomy.taxeditor.cdmlib/src/test/java/eu/etaxonomy/taxeditor/remoting/RemoteApplicationConfigurationTest.java -text
eu.etaxonomy.taxeditor.cdmlib/src/test/java/eu/etaxonomy/taxeditor/remoting/RemoteLazyLoadingTest.java -text
+eu.etaxonomy.taxeditor.cdmlib/src/test/java/eu/etaxonomy/taxeditor/remoting/RemotePersistentCollectionTest.java -text
eu.etaxonomy.taxeditor.editor/.classpath -text
eu.etaxonomy.taxeditor.editor/.project -text
eu.etaxonomy.taxeditor.editor/META-INF/MANIFEST.MF -text
--- /dev/null
+/**
+* Copyright (C) 2007 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.remoting;
+
+import org.apache.log4j.Level;
+import org.apache.log4j.Logger;
+import org.hibernate.collection.internal.AbstractPersistentCollection;
+import org.hibernate.proxy.AbstractLazyInitializer;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.springframework.core.io.ClassPathResource;
+import org.springframework.core.io.Resource;
+import org.unitils.UnitilsJUnit4;
+
+import eu.etaxonomy.cdm.api.application.CdmApplicationController;
+import eu.etaxonomy.cdm.api.application.ICdmApplicationConfiguration;
+import eu.etaxonomy.cdm.database.CdmPersistentDataSource;
+import eu.etaxonomy.cdm.database.DataSourceNotFoundException;
+import eu.etaxonomy.cdm.database.ICdmDataSource;
+
+/**
+ * Base class for remoting tests, responsible mainly for setting up the
+ * remote configuration.
+ *
+ * @author c.mathew
+ * @created 13.032014
+ */
+
+public class RemoteApplicationConfigurationTest extends UnitilsJUnit4 {
+
+ protected static ICdmApplicationConfiguration applicationController;
+ /**
+ * @throws DataSourceNotFoundException
+ */
+ @BeforeClass
+ public static void initializeContext() throws DataSourceNotFoundException {
+
+ Resource DEFAULT_APPLICATION_CONTEXT = new ClassPathResource(
+ "/eu/etaxonomy/cdm/remotingApplicationContext.xml");
+ //FIXME:Remoting Currently the 'local-cyprus' param does not really do anything.
+ // This will just connect to a local runjettyrun cdmserver
+ // instance
+ ICdmDataSource datasource = CdmPersistentDataSource.NewInstance("local-cyprus");
+ applicationController =
+ CdmApplicationController.NewInstance(DEFAULT_APPLICATION_CONTEXT,
+ datasource,
+ null,
+ false,
+ null);
+ AbstractLazyInitializer.setConfiguration(applicationController);
+ AbstractPersistentCollection.setConfiguration(applicationController);
+
+ }
+
+}
--- /dev/null
+/**
+* Copyright (C) 2007 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.remoting;
+
+
+
+import java.util.List;
+
+import org.apache.log4j.Level;
+import org.apache.log4j.Logger;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.unitils.UnitilsJUnit4;
+
+import eu.etaxonomy.cdm.api.service.IClassificationService;
+import eu.etaxonomy.cdm.model.taxon.Classification;
+import eu.etaxonomy.cdm.model.taxon.TaxonNode;
+
+/**
+ * Test class which tests remoting for persistent collections.
+ *
+ * @author c.mathew
+ * @created 13.032014
+ */
+public class RemotePersistentCollectionTest extends RemoteApplicationConfigurationTest {
+ private static final Logger logger = Logger.getLogger(RemotePersistentCollectionTest.class);
+
+
+ private static IClassificationService classificationService;
+
+ @BeforeClass
+ public static void initializeServices() {
+ Logger.getRootLogger().setLevel(Level.DEBUG);
+ classificationService= applicationController.getClassificationService();
+ }
+
+ @Test
+ public void persistentListTest() {
+
+ List<TaxonNode> taxonNodes = classificationService.getAllNodes();
+ logger.debug("classificationService.getAllNodes() size : " + taxonNodes.size());
+
+ int size = taxonNodes.size();
+ logger.info("classification children size : " + size);
+ TaxonNode taxonNode = null;
+ if(size > 0) {
+ taxonNode = taxonNodes.get(0);
+ Assert.assertTrue(taxonNodes.contains(taxonNode));
+
+ List childNodes = taxonNode.getChildNodes();
+ //FIXME:Remoting Are we expecting here to first remote initialise the child node list
+ // and then get its size or are we expecting to retrieve the size remotely ?
+ int childCount = childNodes.size();
+ logger.info("first node child count : " + childCount);
+
+ String firstNodeTaxonTitle = taxonNode.getTaxon().getTitleCache();
+ Assert.assertNotNull(firstNodeTaxonTitle);
+ logger.info("first node taxon : " + firstNodeTaxonTitle);
+
+ if(childCount > 0) {
+
+ Assert.assertTrue(taxonNode.getChildNodes().contains(taxonNode.getChildNodes().get(0)));
+ //FIXME:Remoting Are we expecting here to first remote initialise the child node list
+ // and then get the 0th element or are we expecting to remote initialise
+ // the 0th element of the child node list ?
+ Assert.assertNotNull(taxonNode.getChildNodes().get(0).getTaxon());
+ Assert.assertNotNull(taxonNode.getChildNodes().get(0).getTaxon());
+ logger.info("first child node : " + taxonNode.getChildNodes().get(0).getTaxon());
+ }
+ Assert.assertFalse(taxonNodes.isEmpty());
+ }
+
+ Assert.assertNotNull(taxonNode);
+ Assert.assertTrue(taxonNodes.contains(taxonNode));
+
+ }
+}