Project

General

Profile

Download (2.21 KB) Statistics
| Branch: | Tag: | Revision:
1
// $Id$
2
/**
3
* Copyright (C) 2014 EDIT
4
* European Distributed Institute of Taxonomy
5
* http://www.e-taxonomy.eu
6
*
7
* The contents of this file are subject to the Mozilla Public License Version 1.1
8
* See LICENSE.TXT at the top of this package for the full license terms.
9
*/
10
package eu.etaxonomy.taxeditor.httpinvoker;
11

    
12
import java.io.File;
13
import java.io.IOException;
14
import java.net.URISyntaxException;
15
import java.net.URL;
16

    
17
import org.apache.log4j.Logger;
18
import org.eclipse.core.runtime.FileLocator;
19
import org.eclipse.core.runtime.Platform;
20
import org.junit.Assert;
21
import org.junit.Test;
22
import org.osgi.framework.Bundle;
23

    
24
import eu.etaxonomy.taxeditor.remoting.server.CDMServerUtils;
25
import eu.etaxonomy.taxeditor.webapp.CDMEmbeddedServerException;
26
import eu.etaxonomy.taxeditor.webapp.CDMServer;
27
import eu.etaxonomy.taxeditor.webapp.ICDMServerError;
28

    
29

    
30
/**
31
 * @author cmathew
32
 * @date 6 Oct 2014
33
 *
34
 */
35
public class CdmServerTest extends TestConfig {
36
    private static final Logger logger = Logger.getLogger(CdmServerTest.class);
37

    
38

    
39

    
40
    @Test
41
    public void generateConfigFile() throws IOException {
42
        String mgdServerConfigFileName = "test.mgd.datasources.xml";
43
        String config = CDMServerUtils.convertEditorToServerConfig();
44
        CDMServerUtils.writeManagedServerConfig(config, mgdServerConfigFileName);
45
    }
46

    
47
    @Test
48
    public void manageCdmServer() throws IOException, URISyntaxException, CDMEmbeddedServerException {
49
        Bundle bundle = Platform.getBundle("eu.etaxonomy.taxeditor.test");
50
        URL mgdDatasourcesConfigURL = bundle.getEntry("src/test/resources/.cdmLibrary/writableResources/mgd.datasources.xml");
51
        File mgdDatasourcesConfigFile = new File(FileLocator.resolve(mgdDatasourcesConfigURL).toURI());
52
        CDMServer cdmServer = new CDMServer("cdmTest", mgdDatasourcesConfigFile);
53
        cdmServer.start(new ICDMServerError() {
54
            @Override
55
            public void handleError(Throwable t) {
56
                Assert.fail("Error starting server. Reason : " + t.getMessage());
57
            }
58
        });
59
        try {
60
            cdmServer.stop();
61
        } catch (Exception e) {
62
            e.printStackTrace();
63
            Assert.fail("Error stopping server. Reason : " + e.getMessage());
64
        }
65
    }
66
}
(4-4/9)