Skip to content
This repository has been archived by the owner on Mar 2, 2020. It is now read-only.

Commit

Permalink
Merge pull request #242 from junkerm/develop
Browse files Browse the repository at this point in the history
v0.2.1
  • Loading branch information
junkerm authored Jul 25, 2018
2 parents bdf2b6b + b130838 commit eeb41a3
Show file tree
Hide file tree
Showing 124 changed files with 22,619 additions and 22,221 deletions.
43,257 changes: 21,892 additions & 21,365 deletions bundles/cnf/localrepo/index.xml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bundles/cnf/localrepo/index.xml.sha
Original file line number Diff line number Diff line change
@@ -1 +1 @@
209e668de72134c5cf18b21341c136d64a15e45fe72c529d30c456840db44b43
b2dbf9ecd6b0a4eebe8816f45c59ad40a98f682eeae6e5a2b2f3ded32841ff5c
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion bundles/cnf/releaserepo/index.xml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
<?xml version='1.0' encoding='UTF-8'?>
<repository xmlns="http://www.osgi.org/xmlns/repository/v1.0.0" name="Release" increment="1531494541751"/>
<repository xmlns="http://www.osgi.org/xmlns/repository/v1.0.0" name="Release" increment="1531654341662"/>
2 changes: 1 addition & 1 deletion bundles/cnf/releaserepo/index.xml.sha
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ade5eb958cf0e91aea6531a30eaf9d0933ce086c260ef2338d1d6a06f6d592dd
ac2a878e71e3964eac062550754c59507b3b86b848724548581b68e9493f6c0a
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.util.Dictionary;
import java.util.Hashtable;

import org.eclipse.net4j.util.StringUtil;
import org.osgi.service.cm.ConfigurationAdmin;
import org.osgi.service.component.annotations.Activate;
import org.osgi.service.component.annotations.Component;
Expand All @@ -20,6 +21,8 @@ public class SpecmateCDOServerConfig {

public static final String KEY_SERVER_PORT = "cdo.serverPort";
public static final String KEY_REPOSITORY_NAME = "cdo.repositoryName";
public static final String KEY_CDO_USER = "cdo.user";
public static final String KEY_CDO_PASSWORD = "cdo.password";

private ConfigurationAdmin configurationAdmin;

Expand All @@ -31,15 +34,24 @@ public class SpecmateCDOServerConfig {

private String repositoryName;

private String cdoUser;

private String cdoPassword;

@Activate
private void activate() throws SpecmateException {
this.serverPort = configService.getConfigurationProperty(KEY_SERVER_PORT);
this.repositoryName = configService.getConfigurationProperty(KEY_REPOSITORY_NAME);
this.cdoUser = configService.getConfigurationProperty(KEY_CDO_USER);
this.cdoPassword = configService.getConfigurationProperty(KEY_CDO_PASSWORD);

Dictionary<String, Object> properties = new Hashtable<>();
if (serverPort != null && this.repositoryName != null) {
if (!StringUtil.isEmpty(serverPort) && !StringUtil.isEmpty(repositoryName) && !StringUtil.isEmpty(cdoUser)
&& !StringUtil.isEmpty(cdoPassword)) {
properties.put(KEY_SERVER_PORT, serverPort);
properties.put(KEY_REPOSITORY_NAME, repositoryName);
properties.put(KEY_CDO_USER, cdoUser);
properties.put(KEY_CDO_PASSWORD, cdoPassword);
logService.log(LogService.LOG_DEBUG,
"Configuring CDO with:\n" + OSGiUtil.configDictionaryToString(properties));
OSGiUtil.configureService(configurationAdmin, PID, properties);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,15 @@
import org.eclipse.emf.cdo.server.CDOServerUtil;
import org.eclipse.emf.cdo.server.IRepository;
import org.eclipse.emf.cdo.server.net4j.CDONet4jServerUtil;
import org.eclipse.emf.cdo.spi.server.InternalRepository;
import org.eclipse.emf.cdo.spi.server.InternalSessionManager;
import org.eclipse.net4j.Net4jUtil;
import org.eclipse.net4j.acceptor.IAcceptor;
import org.eclipse.net4j.tcp.TCPUtil;
import org.eclipse.net4j.util.StringUtil;
import org.eclipse.net4j.util.container.IPluginContainer;
import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
import org.eclipse.net4j.util.security.IAuthenticator;
import org.osgi.service.component.annotations.Activate;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.ConfigurationPolicy;
Expand All @@ -36,7 +39,7 @@ public class SpecmateCDOServer implements DBConfigChangedCallback, ICDOServer {
private IAcceptor acceptorTCP;

/** The CDO repository */
private IRepository repository;
private InternalRepository repository;

/** The CDO container */
private IPluginContainer container;
Expand All @@ -49,6 +52,10 @@ public class SpecmateCDOServer implements DBConfigChangedCallback, ICDOServer {

private String repositoryName;

private String cdoUser;

private String cdoPassword;

@Activate
public void activate(Map<String, Object> properties) throws SpecmateValidationException, SpecmateException {
readConfig(properties);
Expand All @@ -74,10 +81,21 @@ private void readConfig(Map<String, Object> properties) throws SpecmateValidatio
} catch (Exception e) {
throw new SpecmateValidationException("Invalid port format: " + portString);
}

this.repositoryName = (String) properties.get(SpecmateCDOServerConfig.KEY_REPOSITORY_NAME);
if (StringUtil.isEmpty(this.repositoryName)) {
throw new SpecmateValidationException("No repository name given");
}

this.cdoUser = (String) properties.get(SpecmateCDOServerConfig.KEY_CDO_USER);
if (StringUtil.isEmpty(this.cdoUser)) {
throw new SpecmateValidationException("No CDO user name given");
}

this.cdoPassword = (String) properties.get(SpecmateCDOServerConfig.KEY_CDO_PASSWORD);
if (StringUtil.isEmpty(this.cdoPassword)) {
throw new SpecmateValidationException("No CDO password given");
}
}

/**
Expand Down Expand Up @@ -119,7 +137,20 @@ private void createRepository() throws SpecmateException {
props.put(IRepository.Props.OVERRIDE_UUID, "specmate");
props.put(IRepository.Props.SUPPORTING_AUDITS, "true");
props.put(IRepository.Props.SUPPORTING_BRANCHES, "true");
this.repository = CDOServerUtil.createRepository(this.repositoryName, dbProviderService.createStore(), props);

this.repository = (InternalRepository) CDOServerUtil.createRepository(this.repositoryName,
dbProviderService.createStore(), props);

InternalSessionManager sessionManager = (InternalSessionManager) CDOServerUtil.createSessionManager();
sessionManager.setAuthenticator(new IAuthenticator() {
@Override
public void authenticate(String userID, char[] password) throws SecurityException {
if (!cdoUser.equals(userID) || !cdoPassword.equals(new String(password))) {
throw new SecurityException();
}
}
});
repository.setSessionManager(sessionManager);
CDOServerUtil.addRepository(IPluginContainer.INSTANCE, repository);
}

Expand Down
4 changes: 2 additions & 2 deletions bundles/specmate-config/bnd.bnd
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Private-Package: com.specmate.config.internal
Private-Package: com.specmate.config.internal
-buildpath: \
org.eclipse.osgi.services,\
specmate-common;version=latest,\
org.apache.commons.lang3,\
osgi.core,\
specmate-config-api;version=latest
specmate-config-api;version=latest
Include-Resource: config=config
22 changes: 16 additions & 6 deletions bundles/specmate-config/config/specmate-config.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,37 +4,47 @@ logging.level = info

# CDO Persistency Settings
## CDO Common
### Repository name, in case of Oracle, must be identical to the schema name
cdo.repositoryName = specmate_repository
cdo.user = cdoUser
cdo.password = cdoPass

## CDO Server
### TCP port where the CDO server should listen
cdo.serverPort = 2036

## CDO Client
### Name of the CDO resource to use
cdo.resourceName = specmate_resource
### CDO host to connect to. If client and server are started in same process, should match cdo.serverPort
cdo.host = localhost:2036

## H2
### JDBC connection string for the H2 database
h2.jdbcConnection = jdbc:h2:./database/specmate


## Oracle
#oracle.cdoRepositoryName =
#oracle.cdoResourceName =
#oracle.cdoJDBCConnection =
### JDBC connection string for the oracle database
#oracle.jdbcConnection =

#oracle.username =
#oracle.password =

# Connectors General Settings
connectorPollTime = 20000
## Time in seconds between polling the connectors, set to -1 to disable polling, default: 20
connectorPollTime = 20

# Sarch Service
search.allowedFields = extId, type, name, description
search.lucene.location = ./database/lucene
search.maxResults = 500
search.maxResults = 100

# Projects
## List of project names, each project listed here needs to be configured below
project.projects = ppmtest

## Config for project hpproject
## Config for project ppmtest

### Config Connector
project.ppmtest.connector.pid = com.specmate.HPServerProxyConnector
Expand Down
1 change: 1 addition & 0 deletions bundles/specmate-connectors/.classpath
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="bin" path="src"/>
<classpathentry kind="src" output="bin_test" path="test"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="con" path="aQute.bnd.classpath.container"/>
<classpathentry kind="output" path="bin"/>
Expand Down
6 changes: 4 additions & 2 deletions bundles/specmate-connectors/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
/bin/
/generated/
/bin/
/generated/
/test_bin/
/bin_test/
7 changes: 6 additions & 1 deletion bundles/specmate-connectors/bnd.bnd
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,12 @@ Export-Package: \
osgi.core;version=6.0,\
specmate-emfrest-api;version=latest,\
javax.ws.rs-api,\
specmate-auth-api;version=latest
specmate-auth-api;version=latest,\
org.apache.servicemix.bundles.junit;version=4.12,\
org.mockito.mockito-core;version=2.19,\
org.objenesis,\
net.bytebuddy.byte-buddy,\
net.bytebuddy.byte-buddy-agent
Private-Package: \
com.specmate.connectors.internal,\
com.specmate.connectors.internal.config
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,19 @@ public class ConnectorServiceConfig {

/** Configures the connector service. */
@Activate
private void configureConnectorService() throws SpecmateException {
public void configureConnectorService() throws SpecmateException {
Dictionary<String, Object> properties = new Hashtable<>();
Integer connectorsPollTime = Integer.parseInt(configService.getConfigurationProperty(KEY_POLL_TIME, "20"));

// Values < 0 to disable the connectors
if (connectorsPollTime < 0) {
logService.log(LogService.LOG_INFO, "Connectors service disabled.");
return;
}

// Minimum wait time beween polls: 1 second
connectorsPollTime = Math.max(connectorsPollTime, 1);

properties.put(KEY_POLL_TIME, connectorsPollTime);
logService.log(LogService.LOG_DEBUG,
"Configuring Connectors with:\n" + OSGiUtil.configDictionaryToString(properties));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package com.specmate.connectors.test;

import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyZeroInteractions;
import static org.mockito.Mockito.when;

import java.io.IOException;
import java.util.Dictionary;

import org.junit.Test;
import org.mockito.Mockito;
import org.osgi.service.cm.Configuration;
import org.osgi.service.cm.ConfigurationAdmin;
import org.osgi.service.log.LogService;

import com.specmate.common.SpecmateException;
import com.specmate.common.SpecmateValidationException;
import com.specmate.config.api.IConfigService;
import com.specmate.connectors.internal.config.ConnectorServiceConfig;

public class ConnectorServiceTest {

@Test
public void testConnectorServiceDisabling()
throws SpecmateException, SpecmateValidationException, InterruptedException {
ConnectorServiceConfig connectorConfig = new ConnectorServiceConfig();
connectorConfig.setLogService(mock(LogService.class));

IConfigService configServiceMock = mock(IConfigService.class);
when(configServiceMock.getConfigurationProperty(ConnectorServiceConfig.KEY_POLL_TIME, "20")).thenReturn("-1");
connectorConfig.setConfigurationService(configServiceMock);

ConfigurationAdmin configAdminMock = mock(ConfigurationAdmin.class);
connectorConfig.setConfigurationAdmin(configAdminMock);

connectorConfig.configureConnectorService();

verifyZeroInteractions(configAdminMock);
}

@Test
public void testConnectorServiceEnabling()
throws SpecmateException, SpecmateValidationException, InterruptedException, IOException {
ConnectorServiceConfig connectorConfig = new ConnectorServiceConfig();
connectorConfig.setLogService(mock(LogService.class));

IConfigService configServiceMock = mock(IConfigService.class);
when(configServiceMock.getConfigurationProperty(ConnectorServiceConfig.KEY_POLL_TIME, "20")).thenReturn("20");
connectorConfig.setConfigurationService(configServiceMock);

ConfigurationAdmin configAdminMock = mock(ConfigurationAdmin.class);
Configuration configurationMock = mock(Configuration.class);
when(configAdminMock.getConfiguration(Mockito.any(String.class))).thenReturn(configurationMock);
connectorConfig.setConfigurationAdmin(configAdminMock);

connectorConfig.configureConnectorService();

verify(configurationMock, Mockito.atLeastOnce()).update(Mockito.any(Dictionary.class));
}
}
3 changes: 1 addition & 2 deletions bundles/specmate-dbprovider-oracle/bnd.bnd
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
-classpath: jar/oracle-driver-ojdbc-12.1.0.2.jar

-buildpath: \
jar/oracle-driver-ojdbc-12.1.0.2.jar;version=file,\
specmate-dbprovider-api;version=latest,\
specmate-common;version=latest,\
osgi.annotation,\
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

public class IntegrationTestBase {

private static final String CDO_PASSWORD = "pass";
private static final String CDO_USER = "cdo";
private static final String SPECMATE_RESOURCE = "specmate_resource";
private static final String SPECMATE_REPOSITORY = "specmate_repository";
// JUnits creates a new object for every test. Making these fields static
Expand Down Expand Up @@ -56,6 +58,8 @@ private Dictionary<String, Object> getCDOServerProperties() {
Dictionary<String, Object> properties = new Hashtable<>();
properties.put(SpecmateCDOServerConfig.KEY_SERVER_PORT, "2036");
properties.put(SpecmateCDOServerConfig.KEY_REPOSITORY_NAME, SPECMATE_REPOSITORY);
properties.put(SpecmateCDOServerConfig.KEY_CDO_USER, CDO_USER);
properties.put(SpecmateCDOServerConfig.KEY_CDO_PASSWORD, CDO_PASSWORD);

return properties;
}
Expand Down Expand Up @@ -94,6 +98,8 @@ protected Dictionary<String, Object> getPersistencyProperties() {
properties.put(CDOPersistencyServiceConfig.KEY_HOST, "localhost:2036");
properties.put(CDOPersistencyServiceConfig.KEY_REPOSITORY_NAME, SPECMATE_REPOSITORY);
properties.put(CDOPersistencyServiceConfig.KEY_RESOURCE_NAME, SPECMATE_RESOURCE);
properties.put(CDOPersistencyServiceConfig.KEY_CDO_USER, CDO_USER);
properties.put(CDOPersistencyServiceConfig.KEY_CDO_PASSWORD, CDO_PASSWORD);

return properties;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ public abstract class MigrationTestBase {

private static final String SPECMATE_RESOURCE = "specmate_resource";
private static final String SPECMATE_REPOSITORY = "specmate_repository";
private static final String CDO_USER = "cdo";
private static final String CDO_PASSWORD = "pass";

public MigrationTestBase(String dbname, String testModelName) throws Exception {
this.dbname = dbname;
Expand Down Expand Up @@ -76,6 +78,8 @@ private Dictionary<String, Object> getCDOServerProperties() {
Dictionary<String, Object> properties = new Hashtable<>();
properties.put(SpecmateCDOServerConfig.KEY_SERVER_PORT, "2036");
properties.put(SpecmateCDOServerConfig.KEY_REPOSITORY_NAME, SPECMATE_REPOSITORY);
properties.put(SpecmateCDOServerConfig.KEY_CDO_USER, CDO_USER);
properties.put(SpecmateCDOServerConfig.KEY_CDO_PASSWORD, CDO_PASSWORD);

return properties;
}
Expand Down Expand Up @@ -153,6 +157,8 @@ protected Dictionary<String, Object> getPersistencyProperties() {
properties.put(CDOPersistencyServiceConfig.KEY_HOST, "localhost:2036");
properties.put(CDOPersistencyServiceConfig.KEY_REPOSITORY_NAME, SPECMATE_REPOSITORY);
properties.put(CDOPersistencyServiceConfig.KEY_RESOURCE_NAME, SPECMATE_RESOURCE);
properties.put(CDOPersistencyServiceConfig.KEY_CDO_USER, CDO_USER);
properties.put(CDOPersistencyServiceConfig.KEY_CDO_PASSWORD, CDO_PASSWORD);

return properties;
}
Expand Down
Loading

0 comments on commit eeb41a3

Please sign in to comment.