ref #9359 upgrade TaxEditor to log4j2
[taxeditor.git] / eu.etaxonomy.taxeditor.test / src / test / java / eu / etaxonomy / taxeditor / httpinvoker / CdmServerTest.java
1 /**
2 * Copyright (C) 2014 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.httpinvoker;
10
11 import java.io.File;
12 import java.io.IOException;
13 import java.net.URISyntaxException;
14 import java.net.URL;
15
16 import org.apache.logging.log4j.LogManager;import org.apache.logging.log4j.Logger;
17 import org.eclipse.core.runtime.FileLocator;
18 import org.eclipse.core.runtime.Platform;
19 import org.junit.Assert;
20 import org.junit.Ignore;
21 import org.junit.Test;
22 import org.osgi.framework.Bundle;
23
24 import eu.etaxonomy.taxeditor.local.CdmServer;
25 import eu.etaxonomy.taxeditor.remoting.server.CdmServerUtils;
26 import eu.etaxonomy.taxeditor.workbench.datasource.CdmEmbeddedServerException;
27 import eu.etaxonomy.taxeditor.workbench.datasource.ICdmServerError;
28
29
30 /**
31 * @author cmathew
32 * @date 6 Oct 2014
33 */
34 public class CdmServerTest extends TestConfig {
35
36 @SuppressWarnings("unused")
37 private static final Logger logger = LogManager.getLogger(CdmServerTest.class);
38
39 @Test
40 public void generateConfigFile() throws IOException {
41 String mgdServerConfigFileName = "test.mgd.datasources.xml";
42 String config = CdmServerUtils.convertEditorToServerConfig();
43 CdmServerUtils.writeManagedServerConfig(config, mgdServerConfigFileName);
44 }
45
46 @Test
47 @Ignore
48 //FIXME: remove @ignore and fix test #5632
49 public void manageCdmServer() throws IOException, URISyntaxException, CdmEmbeddedServerException {
50 Bundle bundle = Platform.getBundle("eu.etaxonomy.taxeditor.test");
51 URL mgdDatasourcesConfigURL = bundle.getEntry("src/test/resources/.cdmLibrary/writableResources/mgd.datasources.xml");
52 File mgdDatasourcesConfigFile = new File(FileLocator.resolve(mgdDatasourcesConfigURL).toURI());
53 try{
54 CdmServer cdmServer = new CdmServer("cdmTest", mgdDatasourcesConfigFile);
55 cdmServer.start(new ICdmServerError() {
56 @Override
57 public void handleError(Throwable t) {
58 Assert.fail("Error starting server. Reason : " + t.getMessage());
59 }
60 });
61 cdmServer.stop();
62 }catch( CdmEmbeddedServerException cese){
63 cese.printStackTrace();
64 Assert.fail("Error instantiating server. Reason: " + cese.getMessage());
65 }catch (Exception e) {
66 e.printStackTrace();
67 Assert.fail("Error stopping server. Reason : " + e.getMessage());
68 }
69 }
70 }