#4073 Initial implementation of local cdm-server
authorCherian Mathew <c.mathew@bgbm.org>
Mon, 24 Aug 2015 09:13:33 +0000 (11:13 +0200)
committerCherian Mathew <c.mathew@bgbm.org>
Mon, 24 Aug 2015 09:58:20 +0000 (11:58 +0200)
eu.etaxonomy.taxeditor.cdmlib/src/main/java/eu/etaxonomy/taxeditor/remoting/source/CdmServerInfo.java
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/TaxonEditorInput.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/RemotingLoginDialog.java
eu.etaxonomy.taxeditor.test/META-INF/MANIFEST.MF
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/CdmRemoteSourceTest.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 134d4f6870974457a8f13660568ae9282cd7b034..e599f2a0e38dedb04f920bfea8c6ab4d1eef5c87 100644 (file)
@@ -28,6 +28,8 @@ import org.json.JSONException;
 import org.json.JSONObject;
 
 import eu.etaxonomy.cdm.config.CdmSourceException;
+import eu.etaxonomy.cdm.database.CdmPersistentDataSource;
+import eu.etaxonomy.cdm.database.ICdmDataSource;
 import eu.etaxonomy.taxeditor.remoting.server.CDMServerException;
 
 /**
@@ -48,9 +50,9 @@ public class CdmServerInfo {
     private final static String NAME_TEST = "edit-test";
     private final static String SERVER_TEST = "test.e-taxonomy.eu";
 
-    private final static String SERVER_LOCALHOST = "localhost";
+    public final static String SERVER_LOCALHOST = "localhost";
     private final static String NAME_LOCALHOST = "localhost";
-    private final static String NAME_LOCALHOST_MGD = "localhost mgd.";
+    public final static String NAME_LOCALHOST_MGD = "localhost mgd.";
 
     private final static String NAME_LOCALHOST_DEV = "localhost-dev";
     private final static String NAME_INSTANCE_LOCALHOST_DEV = "local-dev";
@@ -63,6 +65,7 @@ public class CdmServerInfo {
     private final int port;
     private final List<CdmInstanceInfo> instances;
 
+    private static List<CdmServerInfo> cdmServerInfoList;
 
     public CdmServerInfo(String name, String server, int port) {
         this.name = name;
@@ -80,10 +83,24 @@ public class CdmServerInfo {
     }
 
     public boolean isLocalhost() {
-        return name.startsWith(SERVER_LOCALHOST_DEV);
+        return name.startsWith(SERVER_LOCALHOST);
     }
+
+    public boolean isLocalhostMgd() {
+        return NAME_LOCALHOST_MGD.equals(name);
+    }
+
     public void refreshInstances() throws CDMServerException {
         instances.clear();
+        if(isLocalhostMgd()) {
+            addInstancesFromDataSourcesConfig();
+        } else {
+            addInstancesViaHttp();
+        }
+
+    }
+
+    public void addInstancesViaHttp() throws CDMServerException {
         String url = "http://" + server + ":" + String.valueOf(port) + "/" + CDMSERVER_PREFIX + "/instances.jsp";
 
         HttpClient client = new DefaultHttpClient();
@@ -138,6 +155,14 @@ public class CdmServerInfo {
                 throw new CDMServerException(e);
             }
         }
+    }
+
+    public void addInstancesFromDataSourcesConfig() {
+
+        for(ICdmDataSource dataSource : CdmPersistentDataSource.getAllDataSources()){
+            logger.warn("Adding local instance " + dataSource.getName());
+            addInstance(dataSource.getName(), dataSource.getName());
+        }
 
     }
 
@@ -196,12 +221,14 @@ public class CdmServerInfo {
     }
 
     public static List<CdmServerInfo> getCdmServers() {
-        List<CdmServerInfo> cdmServerInfoList = new ArrayList<CdmServerInfo>();
-        cdmServerInfoList.add(new CdmServerInfo(NAME_PRODUCTION, SERVER_PRODUCTION, 80));
-        cdmServerInfoList.add(new CdmServerInfo(NAME_INTEGRATION, SERVER_INTEGRATION, 80));
-        cdmServerInfoList.add(new CdmServerInfo(NAME_TEST, SERVER_TEST, 80));
-        cdmServerInfoList.add(new CdmServerInfo(NAME_LOCALHOST, SERVER_LOCALHOST, 8080));
-        cdmServerInfoList.add(new CdmServerInfo(NAME_LOCALHOST_MGD, SERVER_LOCALHOST,8080));
+        if(cdmServerInfoList == null) {
+            cdmServerInfoList = new ArrayList<CdmServerInfo>();
+            cdmServerInfoList.add(new CdmServerInfo(NAME_PRODUCTION, SERVER_PRODUCTION, 80));
+            cdmServerInfoList.add(new CdmServerInfo(NAME_INTEGRATION, SERVER_INTEGRATION, 80));
+            cdmServerInfoList.add(new CdmServerInfo(NAME_TEST, SERVER_TEST, 80));
+            cdmServerInfoList.add(new CdmServerInfo(NAME_LOCALHOST, SERVER_LOCALHOST, 8080));
+            cdmServerInfoList.add(new CdmServerInfo(NAME_LOCALHOST_MGD, SERVER_LOCALHOST,8080));
+        }
         return cdmServerInfoList;
     }
 
@@ -248,6 +275,12 @@ public class CdmServerInfo {
 
     public class CdmInstanceInfo {
         private final String name;
+
+        /**
+         * The full path of the instance including the the prefix (if any).
+         * E.g. for an EDIT instance this would be something like "cdmserver/remoting"
+         * For a managed local server this would simply be "remoting"
+         */
         private final String basePath;
 
 
index 8540c7d34bf30503d1b03d66f4196acadb7c96f8..cbfe3cb7cc0e5a8eb9e9b8711262c7b592cdc279 100644 (file)
@@ -10,6 +10,7 @@
 package eu.etaxonomy.taxeditor.editor;
 
 import java.util.Arrays;
+import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
@@ -27,6 +28,7 @@ import eu.etaxonomy.cdm.api.service.IClassificationService;
 import eu.etaxonomy.cdm.api.service.ITaxonNodeService;
 import eu.etaxonomy.cdm.api.service.ITaxonService;
 import eu.etaxonomy.cdm.model.common.CdmBase;
+import eu.etaxonomy.cdm.model.name.HomotypicalGroup;
 import eu.etaxonomy.cdm.model.name.TaxonNameBase;
 import eu.etaxonomy.cdm.model.taxon.ITaxonTreeNode;
 import eu.etaxonomy.cdm.model.taxon.Synonym;
@@ -102,7 +104,7 @@ public class TaxonEditorInput  extends CdmEntitySessionInput implements IEditorI
                 "taxon.rights",
                 "taxon.sources",
                 "taxon.descriptions",
-                "taxon.synonymRelations",
+                "taxon.synonymRelations.relatedFrom.name.homotypicalGroup.typifiedNames",
                 "taxon.relationsToThisTaxon",
                 "taxon.relationsFromThisTaxon",
                 "taxon.taxonNodes",
@@ -126,7 +128,29 @@ public class TaxonEditorInput  extends CdmEntitySessionInput implements IEditorI
 
     private void initForTaxonBase(UUID taxonBaseUuid) {
 
-        TaxonBase taxonBase = CdmStore.getService(ITaxonService.class).load(taxonBaseUuid);
+
+        List<String> taxonBasePropertyPaths = Arrays.asList(new String[] {
+                "annotations",
+                "markers",
+                "credits",
+                "extensions",
+                "rights",
+                "sources",
+                "descriptions",
+                "relationsToThisTaxon",
+                "relationsFromThisTaxon",
+                "taxonNodes",
+                "name.status",
+                "name.nomenclaturalReference",
+                "synonymRelations.relatedFrom.name.status.type",
+                "synonymRelations.relatedFrom.name.nomenclaturalReference.inReference",
+                "name.taxonBases",
+                "name.descriptions.descriptionElements",
+                "name.descriptions.markers"
+
+
+        });
+        TaxonBase taxonBase = CdmStore.getService(ITaxonService.class).load(taxonBaseUuid, taxonBasePropertyPaths);
         if (taxonBase != null){
             if(taxonBase.isInstanceOf(Taxon.class)){
                 Taxon taxon = CdmBase.deproxy(taxonBase, Taxon.class);
@@ -476,7 +500,7 @@ public class TaxonEditorInput  extends CdmEntitySessionInput implements IEditorI
 
     @Override
     public Map<Object, List<String>> getPropertyPathsMap() {
-//        Map<Object, List<String>> propertyPathsMap = new HashMap<Object, List<String>>();
+        Map<Object, List<String>> propertyPathsMap = new HashMap<Object, List<String>>();
 //        List<String> taxonNameBasePropertyPaths = Arrays.asList(new String[] {
 //                "status",
 //                "taxonBases.taxonNodes",
@@ -497,8 +521,13 @@ public class TaxonEditorInput  extends CdmEntitySessionInput implements IEditorI
 //                 "taxon.descriptions"
 //         });
 //        propertyPathsMap.put(TaxonNode.class, taxonBasePropertyPaths);
-//        return propertyPathsMap;
-        return null;
+       List<String> homotypicalGroupPropertyPaths = Arrays.asList(new String[] {
+                "typifiedNames.taxonBases.synonymRelations.relatedFrom.name",
+                "typifiedNames.taxonBases.synonymRelations.relatedFrom.name.status"
+        });
+       propertyPathsMap.put(HomotypicalGroup.class, homotypicalGroupPropertyPaths);
+       return propertyPathsMap;
+//        return null;
     }
 
 }
index ef35781c72c25c43ea44561d28acc57f4e600b68..ee7107e088d9dbf088922fc1f260a860e698bbae 100644 (file)
@@ -169,12 +169,6 @@ public class RemotingLoginDialog extends Dialog {
 
         xpndblcmpstAdvanced.setExpanded(false);
 
-        CdmRemoteSource devRemoteSource = CdmServerInfo.getDevServerRemoteSource();
-        if(devRemoteSource != null) {
-            CdmStore.connect(devRemoteSource, this);
-            isDevRemoteSource = true;
-        }
-
         Display display = getParent().getDisplay();
 
         while (!shlConnect.isDisposed()) {
@@ -462,6 +456,16 @@ public class RemotingLoginDialog extends Dialog {
                         }
                         refreshCdmServer();
                         updatePort();
+                        CdmRemoteSource devRemoteSource = CdmServerInfo.getDevServerRemoteSource();
+                        if(devRemoteSource != null) {
+                            String username = System.getProperty("cdm.server.dev.username");
+                            String password = System.getProperty("cdm.server.dev.password");
+                            if(username != null && !username.isEmpty() && password != null && !password.isEmpty()) {
+                                txtLogin.setText(username);
+                                txtPassword.setText(password);
+                                CdmStore.connect(devRemoteSource, RemotingLoginDialog.this);
+                            }
+                        }
                     }
                 });
                 return Status.OK_STATUS;
@@ -683,15 +687,6 @@ public class RemotingLoginDialog extends Dialog {
 
     private void readPrefCredentials() {
         String username, password;
-        if(isDevRemoteSource) {
-            username = System.getProperty("cdm.server.dev.username");
-            password = System.getProperty("cdm.server.dev.password");
-            if(username != null && !username.isEmpty() && password != null && !password.isEmpty()) {
-                txtLogin.setText(username);
-                txtPassword.setText(password);
-                return;
-            }
-        }
         IEclipsePreferences preferences = ConfigurationScope.INSTANCE.getNode(STORE_PREFERENCES_NODE);
         Preferences credentialsPrefs = preferences.node(LOGIN_NODE);
         username = credentialsPrefs.get(getUsernamePrefKey(), "");
@@ -713,7 +708,7 @@ public class RemotingLoginDialog extends Dialog {
 
     private void emptyCredentials() {
         txtLogin.setText("");
-        txtLogin.setText("");
+        txtPassword.setText("");
     }
 
     private String getUsernamePrefKey() {
index efb306994d3cc83dd9e54ac0545a87be9df2c0c7..c59f7b08e4dd59193c1457d1c8a7cdee876bbc03 100644 (file)
@@ -30,5 +30,4 @@ Bundle-ClassPath: .,
  lib/unitils-dbmaintainer-3.4.2.jar,
  lib/unitils-dbunit-3.4.2.jar,
  lib/unitils-spring-3.4.2.jar,
- lib/dbunit-2.4.9.jar
-Export-Package: org.hamcrest
+ lib/dbunit-2.4.9.jar
\ No newline at end of file
index 59a9ad11ce5446cf723f89f5d20cfc1dccd39146..b8559b1eb7b280f72a0130d84e54e6656ac431cb 100644 (file)
@@ -21,7 +21,6 @@ import net.sf.ehcache.CacheManager;
 import org.apache.log4j.Logger;
 import org.eclipse.core.runtime.FileLocator;
 import org.eclipse.core.runtime.Platform;
-import org.junit.AfterClass;
 import org.junit.Assert;
 import org.junit.BeforeClass;
 import org.osgi.framework.Bundle;
@@ -68,10 +67,6 @@ public abstract class BaseRemotingTest extends UnitilsJUnit4 {
     public static final Resource SERVER_PROPERTIES_FILE =
             new ClassPathResource("server.properties");
 
-//    public static final Resource EDITOR_DATASOURCES_FILE =
-//            new ClassPathResource(".cdmLibrary/writableResources/cdm.datasources.xml");
-
-    //private static CdmApplicationRemoteController remoteApplicationController;
     private static ICdmRemoteSource cdmRemoteSource;
     private static CdmPersistentRemoteSource remotePersistentSource;
 
@@ -88,6 +83,8 @@ public abstract class BaseRemotingTest extends UnitilsJUnit4 {
     private static String user = DEFAULT_USER;
     private static String password = DEFAULT_PASSWORD;
 
+    protected static CDMServer cdmServer;
+
     @BeforeClass
     public static void initializeBaseRemotingTest() {
 
@@ -101,36 +98,21 @@ public abstract class BaseRemotingTest extends UnitilsJUnit4 {
             File userHomeDir = new File(FileLocator.resolve(userHomeDirURL).toURI());
             userHomeDirPath = userHomeDir.getAbsolutePath();
 
-
-
-            logger.info("Setting user.home to " + userHomeDirPath);
-            System.setProperty(userHomeKey, userHomeDirPath);
-
-            CDMServer cdmServer = CDMServer.getInstance();
-
-
-            Properties prop = new Properties();
-
             URL serverPropertiesURL = bundle.getEntry("src/test/resources/server.properties");
             File serverPropertiesFile = new File(FileLocator.resolve(serverPropertiesURL).toURI());
             InputStream inputStream = new FileInputStream(serverPropertiesFile);
 
+            Properties prop = new Properties();
             if (inputStream != null) {
                 prop.load(inputStream);
                 inputStream.close();
             }
 
-            if(prop.getProperty("httpPort") != null) {
-                cdmServer.setHttpPort(Integer.valueOf(prop.getProperty("httpPort")));
-            }
+            logger.info("Setting user.home to " + userHomeDirPath);
+            System.setProperty(userHomeKey, userHomeDirPath);
 
-            if(prop.getProperty("stopPort") != null) {
-                cdmServer.setStopPort(Integer.valueOf(prop.getProperty("stopPort")));
-            }
+            cdmServer = new CDMServer("cdmTest");
 
-            if(prop.getProperty("stopKey") != null) {
-                cdmServer.setStopKey(prop.getProperty("stopKey"));
-            }
 
             if(prop.getProperty("user") != null) {
                 user = prop.getProperty("user");
@@ -140,11 +122,10 @@ public abstract class BaseRemotingTest extends UnitilsJUnit4 {
                 password = prop.getProperty("password");
             }
 
-            cdmServer.start();
-            initializeController(CDMServer.getInstance().getName(),
-                    CDMServer.getInstance().getHost(),
-                    CDMServer.getInstance().getPort(),
-                    CDMServer.getInstance().getContextPath(),
+            initializeController(cdmServer.getName(),
+                    cdmServer.getHost(),
+                    cdmServer.getPort(),
+                    cdmServer.getContextPath(),
                     NomenclaturalCode.ICNAFP,
                     user,
                     password);
@@ -234,15 +215,6 @@ public abstract class BaseRemotingTest extends UnitilsJUnit4 {
         return (CdmTransientEntityCacher) getFieldValueViaReflection(getSession(sessionOwner), "cdmTransientEntityCacher");
     }
 
-    @AfterClass
-    public static void cleanup() {
-        try {
-            CDMServer.getInstance().stop();
-        } catch (Exception e) {
-            Assert.fail("Server could not be stopped. Reason : " + e.getMessage());
-        }
-    }
-
 
     protected static Object getFieldValueViaReflection(Object object, String fieldName) {
         Class<?> clazz = object.getClass();
index 4fad3b3732c1687070dac441ad07ab9648bc2a55..be4bd1e828847b2d99f66fd9ab02f6c2161e76c9 100644 (file)
 package eu.etaxonomy.taxeditor.httpinvoker;
 
 import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
 import java.io.IOException;
+import java.io.InputStream;
 import java.io.InputStreamReader;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.util.Properties;
 
 import javax.management.InstanceNotFoundException;
 import javax.management.MBeanException;
@@ -25,10 +32,15 @@ import javax.management.remote.JMXServiceURL;
 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;
 
+import eu.etaxonomy.cdm.database.CdmPersistentDataSource;
+import eu.etaxonomy.cdm.database.ICdmDataSource;
 import eu.etaxonomy.taxeditor.remoting.server.CDMServerException;
 import eu.etaxonomy.taxeditor.remoting.source.CdmRemoteSourceBase;
 
@@ -77,15 +89,50 @@ public class CDMServer {
 
     private boolean serverAlreadyRunning = false;
 
-    private void CDMServer() {}
+    private File dataSourcesFile;
+    private final String dataSourceName;
 
-    public static CDMServer getInstance() {
-        if(cdmServer == null) {
-            cdmServer = new CDMServer();
+    public CDMServer(String dataSourceName) 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();
+            }
+        } catch (FileNotFoundException e) {
+            throw new CDMServerException(e);
+        } catch (URISyntaxException e) {
+            throw new CDMServerException(e);
+        } catch (IOException e) {
+            throw new CDMServerException(e);
         }
-        return cdmServer;
+
+
+
+        if(prop.getProperty("httpPort") != null) {
+            setHttpPort(Integer.valueOf(prop.getProperty("httpPort")));
+        }
+
+        if(prop.getProperty("stopPort") != null) {
+            setStopPort(Integer.valueOf(prop.getProperty("stopPort")));
+        }
+
+        if(prop.getProperty("stopKey") != null) {
+            setStopKey(prop.getProperty("stopKey"));
+        }
+
     }
 
+
+
     public String getName() {
         return name;
     }
@@ -265,7 +312,7 @@ public class CDMServer {
     public void stop(boolean force) throws Exception {
 
         if(!force) {
-            if(!getInstance().isStarted(1)) {
+            if(!cdmServer.isStarted(1)) {
                 logger.info("[CDM-Server] Server already stopped @ " + host + ":" + httpPort );
                 return;
             }
@@ -335,8 +382,26 @@ public class CDMServer {
         } catch (MalformedObjectNameException e) {
             throw new CDMServerException(e);
         }
+    }
 
+    public void convertEditorToServerConfig() {
+        String xmlString = "<?xml version=\"1.0\" encoding=\"UTF-8\"?> " + System.lineSeparator() +
+                "<beans xmlns=\"http://www.springframework.org/schema/beans\"" + System.lineSeparator() +
+                "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"" + System.lineSeparator() +
+                "xmlns:tx=\"http://www.springframework.org/schema/tx\"" + System.lineSeparator() +
+                "xmlns:context=\"http://www.springframework.org/schema/context\"" + System.lineSeparator() +
+                "xsi:schemaLocation=\"http://www.springframework.org/schema/beans   http://www.springframework.org/schema/beans/spring-beans-2.5.xsd" + System.lineSeparator() +
+                "http://www.springframework.org/schema/context   http://www.springframework.org/schema/context/spring-context-2.5.xsd" + System.lineSeparator() +
+                "http://www.springframework.org/schema/tx   http://www.springframework.org/schema/tx/spring-tx-2.5.xsd" + System.lineSeparator() +
+                ">" + System.lineSeparator() +
+                "<bean id=\"dataSourceProperties\" class=\"eu.etaxonomy.cdm.remote.config.DataSourceProperties\">" + System.lineSeparator() +
+                "   <property name=\"propsMap\">" + System.lineSeparator() +
+                "       <map/>" + System.lineSeparator() +
+                "   </property>" + System.lineSeparator() +
+                "</bean>";
+
+        for(ICdmDataSource dataSource : CdmPersistentDataSource.getAllDataSources()) {
 
-
+        }
     }
 }
index 7656a9c0cd84d7bc24c8496d6824e454913ea416..bf4557555c341b2f7a375cf0e69359981b3c05aa 100644 (file)
@@ -24,11 +24,12 @@ public class CdmRemoteSourceTest extends BaseRemotingTest {
 
        @Test
        public void whenConnectingToInactiveServerThenFailToConnect() {
+
                // check if non-active server throws the right exception
-               CdmRemoteSource inactiveCrs = CdmRemoteSource.NewInstance(CDMServer.getInstance().getName(),
-                       CDMServer.getInstance().getHost(),
+               CdmRemoteSource inactiveCrs = CdmRemoteSource.NewInstance(cdmServer.getName(),
+                       cdmServer.getHost(),
                        808080,
-                       CDMServer.getInstance().getContextPath(),
+                       cdmServer.getContextPath(),
                        NomenclaturalCode.ICNAFP);
                try {
                        inactiveCrs.getDbSchemaVersion();
@@ -67,10 +68,10 @@ public class CdmRemoteSourceTest extends BaseRemotingTest {
        @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(),
+               CdmRemoteSource activeCrs = CdmRemoteSource.NewInstance(cdmServer.getName(),
+                       cdmServer.getHost(),
+                       cdmServer.getPort(),
+                       cdmServer.getContextPath(),
                 NomenclaturalCode.ICNAFP);
                String dbSchemaVersion = "";
                try {
index bca8d3530f4e6f16e2eb4e77e6afe482b823b2f5..ca7e11c8a40aa2c7b9c5ced83d6456de3c6c2ee5 100644 (file)
@@ -27,13 +27,10 @@ public class CdmServerTest extends UnitilsJUnit4 {
 
     @Test
     public void startCdmServer() throws CDMServerException {
-        CDMServer.getInstance().start();
-    }
-
-    @Test
-    public void stopCdmServer() {
+        CDMServer cdmServer = new CDMServer("cdmTest");
+        cdmServer .start();
         try {
-            CDMServer.getInstance().stop(true);
+            cdmServer.stop(true);
         } catch (Exception e) {
             e.printStackTrace();
             Assert.fail("Server could not be stopped. Reason : " + e.getMessage());
index ece6f85568dcf70bcdd1e5d68c0c08fd6d99a688..273e492e158d4758c6cb99f535b64915be071ba9 100644 (file)
@@ -64,4 +64,18 @@ public class CdmServerInfoTest extends UnitilsJUnit4 {
 
         }
     }
+
+    @Test
+    public void refreshInstancesTest() throws CDMServerException {
+        CdmServerInfo cdmServerInfo = new CdmServerInfo(CdmServerInfo.NAME_LOCALHOST_MGD, CdmServerInfo.SERVER_LOCALHOST,8080);
+        cdmServerInfo.refreshInstances();
+        List<CdmInstanceInfo> instances = cdmServerInfo.getInstances();
+        Assert.assertTrue(instances != null && !instances.isEmpty());
+    }
+
+    @Test
+    public void convertToServerConfigTest() {
+
+
+    }
 }