Correct properties file load and server info test
authorCherian Mathew <c.mathew@bgbm.org>
Mon, 24 Aug 2015 15:17:55 +0000 (17:17 +0200)
committerCherian Mathew <c.mathew@bgbm.org>
Mon, 24 Aug 2015 15:17:55 +0000 (17:17 +0200)
eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/httpinvoker/BaseRemotingTest.java
eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/httpinvoker/CDMServer.java
eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/httpinvoker/CdmServerTest.java
eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/ui/dialogs/CdmServerInfoTest.java

index b8559b1eb7b280f72a0130d84e54e6656ac431cb..18d151ac034becbfbb2a73eced6136b587ebd4f5 100644 (file)
@@ -111,7 +111,8 @@ public abstract class BaseRemotingTest extends UnitilsJUnit4 {
             logger.info("Setting user.home to " + userHomeDirPath);
             System.setProperty(userHomeKey, userHomeDirPath);
 
-            cdmServer = new CDMServer("cdmTest");
+
+            cdmServer = new CDMServer("cdmTest", serverPropertiesURL);
 
 
             if(prop.getProperty("user") != null) {
index be4bd1e828847b2d99f66fd9ab02f6c2161e76c9..2453912f4304cbd405cf340445b6f643e7ad062f 100644 (file)
@@ -33,8 +33,6 @@ import javax.sql.DataSource;
 
 import org.apache.log4j.Logger;
 import org.eclipse.core.runtime.FileLocator;
-import org.eclipse.core.runtime.Platform;
-import org.osgi.framework.Bundle;
 import org.springframework.core.io.ClassPathResource;
 import org.springframework.core.io.Resource;
 import org.unitils.database.annotations.TestDataSource;
@@ -92,21 +90,17 @@ public class CDMServer {
     private File dataSourcesFile;
     private final String dataSourceName;
 
-    public CDMServer(String dataSourceName) throws CDMServerException {
+    public CDMServer(String dataSourceName, URL serverPropertiesURL) throws CDMServerException {
         this.dataSourceName = dataSourceName;
         Properties prop = new Properties();
 
-        Bundle bundle = Platform.getBundle("eu.etaxonomy.taxeditor.cdmlib");
-        URL serverPropertiesURL = bundle.getEntry("src/test/resources/server.properties");
-
         try {
             File serverPropertiesFile = new File(FileLocator.resolve(serverPropertiesURL).toURI());
             InputStream inputStream = new FileInputStream(serverPropertiesFile);
 
-            if (inputStream != null) {
-                prop.load(inputStream);
-                inputStream.close();
-            }
+            prop.load(inputStream);
+            inputStream.close();
+
         } catch (FileNotFoundException e) {
             throw new CDMServerException(e);
         } catch (URISyntaxException e) {
index ca7e11c8a40aa2c7b9c5ced83d6456de3c6c2ee5..ae8b755de17eeda5645e5834180808ac9b20280f 100644 (file)
@@ -9,9 +9,13 @@
 */
 package eu.etaxonomy.taxeditor.httpinvoker;
 
+import java.net.URL;
+
 import org.apache.log4j.Logger;
+import org.eclipse.core.runtime.Platform;
 import org.junit.Assert;
 import org.junit.Test;
+import org.osgi.framework.Bundle;
 import org.unitils.UnitilsJUnit4;
 
 import eu.etaxonomy.taxeditor.remoting.server.CDMServerException;
@@ -27,7 +31,9 @@ public class CdmServerTest extends UnitilsJUnit4 {
 
     @Test
     public void startCdmServer() throws CDMServerException {
-        CDMServer cdmServer = new CDMServer("cdmTest");
+        Bundle bundle = Platform.getBundle("eu.etaxonomy.taxeditor.test");
+        URL serverPropertiesURL = bundle.getEntry("src/test/resources/server.properties");
+        CDMServer cdmServer = new CDMServer("cdmTest", serverPropertiesURL);
         cdmServer .start();
         try {
             cdmServer.stop(true);
index 273e492e158d4758c6cb99f535b64915be071ba9..3cc887d978e818eb04afcf48e99fac5d88339c6c 100644 (file)
@@ -12,7 +12,6 @@ package eu.etaxonomy.taxeditor.ui.dialogs;
 import java.util.List;
 
 import org.junit.Assert;
-import org.junit.Ignore;
 import org.junit.Test;
 import org.unitils.UnitilsJUnit4;
 
@@ -36,12 +35,10 @@ public class CdmServerInfoTest extends UnitilsJUnit4 {
         }
     }
 
-    // FIXME:Remoting this is an integration test and should be run against a
-    //  cdmserver
-    @Ignore
+
     @Test
     public void pingInstancesTest() {
-        CdmServerInfo csii = new CdmServerInfo("localhost", "localhost", 8080);
+        CdmServerInfo csii = new CdmServerInfo("edit-test", "test.e-taxonomy.eu", 8080);
         try {
             csii.refreshInstances();
             List<CdmInstanceInfo> instances = csii.getInstances();
@@ -67,7 +64,7 @@ public class CdmServerInfoTest extends UnitilsJUnit4 {
 
     @Test
     public void refreshInstancesTest() throws CDMServerException {
-        CdmServerInfo cdmServerInfo = new CdmServerInfo(CdmServerInfo.NAME_LOCALHOST_MGD, CdmServerInfo.SERVER_LOCALHOST,8080);
+        CdmServerInfo cdmServerInfo = new CdmServerInfo("edit-test", "test.e-taxonomy.eu", 8080);
         cdmServerInfo.refreshInstances();
         List<CdmInstanceInfo> instances = cdmServerInfo.getInstances();
         Assert.assertTrue(instances != null && !instances.isEmpty());