Revision a3044475
Added by Cherian Mathew about 10 years ago
.gitattributes | ||
---|---|---|
328 | 328 |
eu.etaxonomy.taxeditor.cdmlib/src/main/resources/eu/etaxonomy/cdm/remotingApplicationContext.xml -text |
329 | 329 |
eu.etaxonomy.taxeditor.cdmlib/src/main/resources/eu/etaxonomy/cdm/remoting_persistence_security.xml -text |
330 | 330 |
eu.etaxonomy.taxeditor.cdmlib/src/main/resources/eu/etaxonomy/cdm/remoting_services_security.xml -text |
331 |
eu.etaxonomy.taxeditor.cdmlib/src/test/java/eu/etaxonomy/taxeditor/remoting/RemoteApplicationConfigurationTest.java -text |
|
331 | 332 |
eu.etaxonomy.taxeditor.cdmlib/src/test/java/eu/etaxonomy/taxeditor/remoting/RemoteLazyLoadingTest.java -text |
333 |
eu.etaxonomy.taxeditor.cdmlib/src/test/java/eu/etaxonomy/taxeditor/remoting/RemotePersistentCollectionTest.java -text |
|
332 | 334 |
eu.etaxonomy.taxeditor.editor/.classpath -text |
333 | 335 |
eu.etaxonomy.taxeditor.editor/.project -text |
334 | 336 |
eu.etaxonomy.taxeditor.editor/META-INF/MANIFEST.MF -text |
eu.etaxonomy.taxeditor.cdmlib/src/test/java/eu/etaxonomy/taxeditor/remoting/RemoteApplicationConfigurationTest.java | ||
---|---|---|
1 |
/** |
|
2 |
* Copyright (C) 2007 EDIT |
|
3 |
* European Distributed Institute of Taxonomy |
|
4 |
* http://www.e-taxonomy.eu |
|
5 |
* |
|
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. |
|
8 |
*/ |
|
9 |
package eu.etaxonomy.taxeditor.remoting; |
|
10 |
|
|
11 |
import org.apache.log4j.Level; |
|
12 |
import org.apache.log4j.Logger; |
|
13 |
import org.hibernate.collection.internal.AbstractPersistentCollection; |
|
14 |
import org.hibernate.proxy.AbstractLazyInitializer; |
|
15 |
import org.junit.Before; |
|
16 |
import org.junit.BeforeClass; |
|
17 |
import org.springframework.core.io.ClassPathResource; |
|
18 |
import org.springframework.core.io.Resource; |
|
19 |
import org.unitils.UnitilsJUnit4; |
|
20 |
|
|
21 |
import eu.etaxonomy.cdm.api.application.CdmApplicationController; |
|
22 |
import eu.etaxonomy.cdm.api.application.ICdmApplicationConfiguration; |
|
23 |
import eu.etaxonomy.cdm.database.CdmPersistentDataSource; |
|
24 |
import eu.etaxonomy.cdm.database.DataSourceNotFoundException; |
|
25 |
import eu.etaxonomy.cdm.database.ICdmDataSource; |
|
26 |
|
|
27 |
/** |
|
28 |
* Base class for remoting tests, responsible mainly for setting up the |
|
29 |
* remote configuration. |
|
30 |
* |
|
31 |
* @author c.mathew |
|
32 |
* @created 13.032014 |
|
33 |
*/ |
|
34 |
|
|
35 |
public class RemoteApplicationConfigurationTest extends UnitilsJUnit4 { |
|
36 |
|
|
37 |
protected static ICdmApplicationConfiguration applicationController; |
|
38 |
/** |
|
39 |
* @throws DataSourceNotFoundException |
|
40 |
*/ |
|
41 |
@BeforeClass |
|
42 |
public static void initializeContext() throws DataSourceNotFoundException { |
|
43 |
|
|
44 |
Resource DEFAULT_APPLICATION_CONTEXT = new ClassPathResource( |
|
45 |
"/eu/etaxonomy/cdm/remotingApplicationContext.xml"); |
|
46 |
//FIXME:Remoting Currently the 'local-cyprus' param does not really do anything. |
|
47 |
// This will just connect to a local runjettyrun cdmserver |
|
48 |
// instance |
|
49 |
ICdmDataSource datasource = CdmPersistentDataSource.NewInstance("local-cyprus"); |
|
50 |
applicationController = |
|
51 |
CdmApplicationController.NewInstance(DEFAULT_APPLICATION_CONTEXT, |
|
52 |
datasource, |
|
53 |
null, |
|
54 |
false, |
|
55 |
null); |
|
56 |
AbstractLazyInitializer.setConfiguration(applicationController); |
|
57 |
AbstractPersistentCollection.setConfiguration(applicationController); |
|
58 |
|
|
59 |
} |
|
60 |
|
|
61 |
} |
eu.etaxonomy.taxeditor.cdmlib/src/test/java/eu/etaxonomy/taxeditor/remoting/RemotePersistentCollectionTest.java | ||
---|---|---|
1 |
/** |
|
2 |
* Copyright (C) 2007 EDIT |
|
3 |
* European Distributed Institute of Taxonomy |
|
4 |
* http://www.e-taxonomy.eu |
|
5 |
* |
|
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. |
|
8 |
*/ |
|
9 |
package eu.etaxonomy.taxeditor.remoting; |
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
import java.util.List; |
|
14 |
|
|
15 |
import org.apache.log4j.Level; |
|
16 |
import org.apache.log4j.Logger; |
|
17 |
import org.junit.Assert; |
|
18 |
import org.junit.BeforeClass; |
|
19 |
import org.junit.Test; |
|
20 |
import org.unitils.UnitilsJUnit4; |
|
21 |
|
|
22 |
import eu.etaxonomy.cdm.api.service.IClassificationService; |
|
23 |
import eu.etaxonomy.cdm.model.taxon.Classification; |
|
24 |
import eu.etaxonomy.cdm.model.taxon.TaxonNode; |
|
25 |
|
|
26 |
/** |
|
27 |
* Test class which tests remoting for persistent collections. |
|
28 |
* |
|
29 |
* @author c.mathew |
|
30 |
* @created 13.032014 |
|
31 |
*/ |
|
32 |
public class RemotePersistentCollectionTest extends RemoteApplicationConfigurationTest { |
|
33 |
private static final Logger logger = Logger.getLogger(RemotePersistentCollectionTest.class); |
|
34 |
|
|
35 |
|
|
36 |
private static IClassificationService classificationService; |
|
37 |
|
|
38 |
@BeforeClass |
|
39 |
public static void initializeServices() { |
|
40 |
Logger.getRootLogger().setLevel(Level.DEBUG); |
|
41 |
classificationService= applicationController.getClassificationService(); |
|
42 |
} |
|
43 |
|
|
44 |
@Test |
|
45 |
public void persistentListTest() { |
|
46 |
|
|
47 |
List<TaxonNode> taxonNodes = classificationService.getAllNodes(); |
|
48 |
logger.debug("classificationService.getAllNodes() size : " + taxonNodes.size()); |
|
49 |
|
|
50 |
int size = taxonNodes.size(); |
|
51 |
logger.info("classification children size : " + size); |
|
52 |
TaxonNode taxonNode = null; |
|
53 |
if(size > 0) { |
|
54 |
taxonNode = taxonNodes.get(0); |
|
55 |
Assert.assertTrue(taxonNodes.contains(taxonNode)); |
|
56 |
|
|
57 |
List childNodes = taxonNode.getChildNodes(); |
|
58 |
//FIXME:Remoting Are we expecting here to first remote initialise the child node list |
|
59 |
// and then get its size or are we expecting to retrieve the size remotely ? |
|
60 |
int childCount = childNodes.size(); |
|
61 |
logger.info("first node child count : " + childCount); |
|
62 |
|
|
63 |
String firstNodeTaxonTitle = taxonNode.getTaxon().getTitleCache(); |
|
64 |
Assert.assertNotNull(firstNodeTaxonTitle); |
|
65 |
logger.info("first node taxon : " + firstNodeTaxonTitle); |
|
66 |
|
|
67 |
if(childCount > 0) { |
|
68 |
|
|
69 |
Assert.assertTrue(taxonNode.getChildNodes().contains(taxonNode.getChildNodes().get(0))); |
|
70 |
//FIXME:Remoting Are we expecting here to first remote initialise the child node list |
|
71 |
// and then get the 0th element or are we expecting to remote initialise |
|
72 |
// the 0th element of the child node list ? |
|
73 |
Assert.assertNotNull(taxonNode.getChildNodes().get(0).getTaxon()); |
|
74 |
Assert.assertNotNull(taxonNode.getChildNodes().get(0).getTaxon()); |
|
75 |
logger.info("first child node : " + taxonNode.getChildNodes().get(0).getTaxon()); |
|
76 |
} |
|
77 |
Assert.assertFalse(taxonNodes.isEmpty()); |
|
78 |
} |
|
79 |
|
|
80 |
Assert.assertNotNull(taxonNode); |
|
81 |
Assert.assertTrue(taxonNodes.contains(taxonNode)); |
|
82 |
|
|
83 |
} |
|
84 |
} |
Also available in: Unified diff
added test class for persistent collections and also a base class for configuringsetting up remote configuration.