-// $Id$
/**
* Copyright (C) 2014 EDIT
* European Distributed Institute of Taxonomy
*/
package eu.etaxonomy.taxeditor.httpinvoker;
-import org.apache.log4j.Logger;
+import java.io.File;
+import java.io.IOException;
+import java.net.URISyntaxException;
+import java.net.URL;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.Platform;
import org.junit.Assert;
+import org.junit.Ignore;
import org.junit.Test;
-import org.unitils.UnitilsJUnit4;
+import org.osgi.framework.Bundle;
-import eu.etaxonomy.taxeditor.remoting.server.CDMServerException;
+import eu.etaxonomy.taxeditor.local.CdmServer;
+import eu.etaxonomy.taxeditor.remoting.server.CdmServerUtils;
+import eu.etaxonomy.taxeditor.workbench.datasource.CdmEmbeddedServerException;
+import eu.etaxonomy.taxeditor.workbench.datasource.ICdmServerError;
/**
* @author cmathew
* @date 6 Oct 2014
- *
*/
-public class CdmServerTest extends UnitilsJUnit4 {
- private static final Logger logger = Logger.getLogger(CdmServerTest.class);
+public class CdmServerTest extends TestConfig {
+ @SuppressWarnings("unused")
+ private static final Logger logger = LogManager.getLogger(CdmServerTest.class);
@Test
- public void startCdmServer() throws CDMServerException {
- CDMServer.getInstance().start();
+ public void generateConfigFile() throws IOException {
+ String mgdServerConfigFileName = "test.mgd.datasources.xml";
+ String config = CdmServerUtils.convertEditorToServerConfig();
+ CdmServerUtils.writeManagedServerConfig(config, mgdServerConfigFileName);
}
@Test
- public void stopCdmServer() {
- try {
- CDMServer.getInstance().stop(true);
- } catch (Exception e) {
+ @Ignore
+ //FIXME: remove @ignore and fix test #5632
+ public void manageCdmServer() throws IOException, URISyntaxException, CdmEmbeddedServerException {
+ Bundle bundle = Platform.getBundle("eu.etaxonomy.taxeditor.test");
+ URL mgdDatasourcesConfigURL = bundle.getEntry("src/test/resources/.cdmLibrary/writableResources/mgd.datasources.xml");
+ File mgdDatasourcesConfigFile = new File(FileLocator.resolve(mgdDatasourcesConfigURL).toURI());
+ try{
+ CdmServer cdmServer = new CdmServer("cdmTest", mgdDatasourcesConfigFile);
+ cdmServer.start(new ICdmServerError() {
+ @Override
+ public void handleError(Throwable t) {
+ Assert.fail("Error starting server. Reason : " + t.getMessage());
+ }
+ });
+ cdmServer.stop();
+ }catch( CdmEmbeddedServerException cese){
+ cese.printStackTrace();
+ Assert.fail("Error instantiating server. Reason: " + cese.getMessage());
+ }catch (Exception e) {
e.printStackTrace();
- Assert.fail("Server could not be stopped. Reason : " + e.getMessage());
+ Assert.fail("Error stopping server. Reason : " + e.getMessage());
}
}
-
}