Project

General

Profile

« Previous | Next » 

Revision da3cc7e3

Added by Cherian Mathew over 7 years ago

Correct properties file load and server info test

View differences:

eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/httpinvoker/BaseRemotingTest.java
111 111
            logger.info("Setting user.home to " + userHomeDirPath);
112 112
            System.setProperty(userHomeKey, userHomeDirPath);
113 113

  
114
            cdmServer = new CDMServer("cdmTest");
114

  
115
            cdmServer = new CDMServer("cdmTest", serverPropertiesURL);
115 116

  
116 117

  
117 118
            if(prop.getProperty("user") != null) {
eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/httpinvoker/CDMServer.java
33 33

  
34 34
import org.apache.log4j.Logger;
35 35
import org.eclipse.core.runtime.FileLocator;
36
import org.eclipse.core.runtime.Platform;
37
import org.osgi.framework.Bundle;
38 36
import org.springframework.core.io.ClassPathResource;
39 37
import org.springframework.core.io.Resource;
40 38
import org.unitils.database.annotations.TestDataSource;
......
92 90
    private File dataSourcesFile;
93 91
    private final String dataSourceName;
94 92

  
95
    public CDMServer(String dataSourceName) throws CDMServerException {
93
    public CDMServer(String dataSourceName, URL serverPropertiesURL) throws CDMServerException {
96 94
        this.dataSourceName = dataSourceName;
97 95
        Properties prop = new Properties();
98 96

  
99
        Bundle bundle = Platform.getBundle("eu.etaxonomy.taxeditor.cdmlib");
100
        URL serverPropertiesURL = bundle.getEntry("src/test/resources/server.properties");
101

  
102 97
        try {
103 98
            File serverPropertiesFile = new File(FileLocator.resolve(serverPropertiesURL).toURI());
104 99
            InputStream inputStream = new FileInputStream(serverPropertiesFile);
105 100

  
106
            if (inputStream != null) {
107
                prop.load(inputStream);
108
                inputStream.close();
109
            }
101
            prop.load(inputStream);
102
            inputStream.close();
103

  
110 104
        } catch (FileNotFoundException e) {
111 105
            throw new CDMServerException(e);
112 106
        } catch (URISyntaxException e) {
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.net.URL;
13

  
12 14
import org.apache.log4j.Logger;
15
import org.eclipse.core.runtime.Platform;
13 16
import org.junit.Assert;
14 17
import org.junit.Test;
18
import org.osgi.framework.Bundle;
15 19
import org.unitils.UnitilsJUnit4;
16 20

  
17 21
import eu.etaxonomy.taxeditor.remoting.server.CDMServerException;
......
27 31

  
28 32
    @Test
29 33
    public void startCdmServer() throws CDMServerException {
30
        CDMServer cdmServer = new CDMServer("cdmTest");
34
        Bundle bundle = Platform.getBundle("eu.etaxonomy.taxeditor.test");
35
        URL serverPropertiesURL = bundle.getEntry("src/test/resources/server.properties");
36
        CDMServer cdmServer = new CDMServer("cdmTest", serverPropertiesURL);
31 37
        cdmServer .start();
32 38
        try {
33 39
            cdmServer.stop(true);
eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/ui/dialogs/CdmServerInfoTest.java
12 12
import java.util.List;
13 13

  
14 14
import org.junit.Assert;
15
import org.junit.Ignore;
16 15
import org.junit.Test;
17 16
import org.unitils.UnitilsJUnit4;
18 17

  
......
36 35
        }
37 36
    }
38 37

  
39
    // FIXME:Remoting this is an integration test and should be run against a
40
    //  cdmserver
41
    @Ignore
38

  
42 39
    @Test
43 40
    public void pingInstancesTest() {
44
        CdmServerInfo csii = new CdmServerInfo("localhost", "localhost", 8080);
41
        CdmServerInfo csii = new CdmServerInfo("edit-test", "test.e-taxonomy.eu", 8080);
45 42
        try {
46 43
            csii.refreshInstances();
47 44
            List<CdmInstanceInfo> instances = csii.getInstances();
......
67 64

  
68 65
    @Test
69 66
    public void refreshInstancesTest() throws CDMServerException {
70
        CdmServerInfo cdmServerInfo = new CdmServerInfo(CdmServerInfo.NAME_LOCALHOST_MGD, CdmServerInfo.SERVER_LOCALHOST,8080);
67
        CdmServerInfo cdmServerInfo = new CdmServerInfo("edit-test", "test.e-taxonomy.eu", 8080);
71 68
        cdmServerInfo.refreshInstances();
72 69
        List<CdmInstanceInfo> instances = cdmServerInfo.getInstances();
73 70
        Assert.assertTrue(instances != null && !instances.isEmpty());

Also available in: Unified diff