Project

General

Profile

« Previous | Next » 

Revision 7a96337f

Added by Cherian Mathew over 8 years ago

#4073 Add new project for lanuching embedded jetty server using cdmlib webapp

#4073 Add jetty server dependencies

#4073 Add stop start possibility for server

#4073 Add functionality to control managed server in login dialog

#4073 Add start / stop methods for managed server

#4073 Simplify manged server ui

#4073 Fix incorrect stop behaviour, Add mysql jdbc connector jar

#4073 Add webapp to editor project and fix file location issue

#4073 Add error callback for CDM Server start

View differences:

eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/httpinvoker/CdmServerTest.java
9 9
*/
10 10
package eu.etaxonomy.taxeditor.httpinvoker;
11 11

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

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

  
22
import eu.etaxonomy.taxeditor.remoting.server.CDMServerException;
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

  
23 29

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

  
32
    @Ignore // this should be targetting integration or production
38

  
39

  
33 40
    @Test
34
    public void startCdmServer() throws CDMServerException {
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 {
35 49
        Bundle bundle = Platform.getBundle("eu.etaxonomy.taxeditor.test");
36
        URL serverPropertiesURL = bundle.getEntry("src/test/resources/server.properties");
37
        CDMServer cdmServer = new CDMServer("cdmTest", serverPropertiesURL);
38
        cdmServer .start();
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
        });
39 59
        try {
40
            cdmServer.stop(true);
60
            cdmServer.stop();
41 61
        } catch (Exception e) {
42 62
            e.printStackTrace();
43
            Assert.fail("Server could not be stopped. Reason : " + e.getMessage());
63
            Assert.fail("Error stopping server. Reason : " + e.getMessage());
44 64
        }
45 65
    }
46

  
47 66
}

Also available in: Unified diff