Skip to content

Commit

Permalink
port all tests to junit 4 and run integration tests through filters a…
Browse files Browse the repository at this point in the history
…nd http.
  • Loading branch information
chenson42 committed Aug 5, 2008
1 parent d72a7e9 commit 912d5bc
Show file tree
Hide file tree
Showing 51 changed files with 2,070 additions and 1,653 deletions.
32 changes: 8 additions & 24 deletions symmetric/pom.xml
@@ -1,4 +1,5 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.jumpmind.symmetric</groupId>
<artifactId>symmetric</artifactId>
Expand All @@ -14,7 +15,9 @@
</description>
<scm>
<connection>scm:svn:https://symmetricds.svn.sourceforge.net/svnroot/symmetricds/trunk/symmetric/</connection>
<developerConnection>scm:svn:https://symmetricds.svn.sourceforge.net/svnroot/symmetricds/trunk/symmetric/</developerConnection>
<developerConnection>
scm:svn:https://symmetricds.svn.sourceforge.net/svnroot/symmetricds/trunk/symmetric/
</developerConnection>
<url>https://symmetricds.svn.sourceforge.net/svnroot/symmetricds/trunk/symmetric/</url>
</scm>
<issueManagement>
Expand Down Expand Up @@ -169,14 +172,6 @@
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<forkMode>once</forkMode>
<systemProperties>
<property>
<name>javassist-write-dir</name>
<value>target/transformed-classes</value>
</property>
</systemProperties>
<groups>continuous,integration,mysql</groups>
<additionalClasspathElements>
<additionalClasspathElement>
${user.home}\.symmetricds\lib\ojdbc6.jar
Expand All @@ -188,6 +183,9 @@
${user.home}\.symmetricds\lib\ojdbc14.jar
</additionalClasspathElement>
</additionalClasspathElements>
<includes>
<include>**/*TestSuite.java</include>
</includes>
</configuration>
</plugin>
<plugin>
Expand Down Expand Up @@ -314,20 +312,6 @@
include JSF, Servlet API, JSP API, EL, JPA API.
-->

<!-- Test NG -->
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>5.8</version>
<classifier>jdk15</classifier>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
Expand Down
Expand Up @@ -48,9 +48,16 @@ public class SymmetricEngineContextLoaderListener extends ContextLoaderListener
static final String SYMMETRIC_SPRING_LOCATION = "classpath:/symmetric.xml";

static final Log logger = LogFactory.getLog(SymmetricEngineContextLoaderListener.class);

SymmetricEngine engine = null;

public SymmetricEngineContextLoaderListener() {
}

public SymmetricEngineContextLoaderListener(SymmetricEngine engine) {
this.engine = engine;
}

@Override
final public void contextInitialized(ServletContextEvent event) {
try {
Expand All @@ -67,8 +74,18 @@ final public void contextInitialized(ServletContextEvent event) {
}
}

@Override
public void contextDestroyed(ServletContextEvent event) {
if (engine != null) {
engine.stop();
engine = null;
}
}

protected void createConfigureAndStartEngine(ApplicationContext ctx) {
this.engine = new SymmetricEngine(ctx);
if (this.engine == null) {
this.engine = new SymmetricEngine(ctx);
}
engine.start();
}

Expand Down
Expand Up @@ -21,6 +21,7 @@

import javax.management.Attribute;
import javax.management.MBeanServer;
import javax.management.MalformedObjectNameException;
import javax.management.ObjectName;

import mx4j.tools.adaptor.http.HttpAdaptor;
Expand Down Expand Up @@ -54,9 +55,14 @@ public class SymmetricWebServer {
protected Server server;

protected boolean join = true;

protected String webHome = "/sync";

public SymmetricWebServer() {}

public SymmetricWebServer(SymmetricEngine engine) {
this.contextListener = new SymmetricEngineContextLoaderListener(engine);
}
public void start(int port, String propertiesUrl) throws Exception {
System.setProperty(Constants.OVERRIDE_PROPERTIES_FILE_1, propertiesUrl);
start(port);
Expand Down Expand Up @@ -95,29 +101,53 @@ public void start(int port) throws Exception {
logger.info("About to start SymmetricDS web server on port " + port);
server.start();

IParameterService parameterService = AppUtils.find(Constants.PARAMETER_SERVICE, getEngine());
registerHttpJmxAdaptor(port + 1);

if (join) {
server.join();
}
}

protected void registerHttpJmxAdaptor(int jmxPort) throws Exception {
IParameterService parameterService = AppUtils.find(Constants.PARAMETER_SERVICE, getEngine());
if (parameterService.is(ParameterConstants.JMX_HTTP_CONSOLE_ENABLED)) {
final int JMX_PORT = port + 1;
logger.info("Starting JMX HTTP console on port " + JMX_PORT);
logger.info("Starting JMX HTTP console on port " + jmxPort);
MBeanServer mbeanServer = AppUtils.find(Constants.MBEAN_SERVER, getEngine());

ObjectName name = new ObjectName("Server:name=HttpAdaptor");
ObjectName name = getHttpJmxAdaptorName();
mbeanServer.createMBean(HttpAdaptor.class.getName(), name);
mbeanServer.setAttribute(name, new Attribute("Port", new Integer(JMX_PORT)));
ObjectName processorName = new ObjectName("Server:name=XSLTProcessor");
mbeanServer.setAttribute(name, new Attribute("Port", new Integer(jmxPort)));
ObjectName processorName = getXslJmxAdaptorName();
mbeanServer.createMBean(XSLTProcessor.class.getName(), processorName);
mbeanServer.setAttribute(name, new Attribute("ProcessorName", processorName));
mbeanServer.invoke(name, "start", null, null);
}
}

if (join) {
server.join();
protected ObjectName getHttpJmxAdaptorName() throws MalformedObjectNameException {
return new ObjectName("Server:name=HttpAdaptor");
}

protected ObjectName getXslJmxAdaptorName() throws MalformedObjectNameException {
return new ObjectName("Server:name=XSLTProcessor");
}


protected void removeHttpJmxAdaptor() {
IParameterService parameterService = AppUtils.find(Constants.PARAMETER_SERVICE, getEngine());
if (parameterService.is(ParameterConstants.JMX_HTTP_CONSOLE_ENABLED)) {
try {
MBeanServer mbeanServer = AppUtils.find(Constants.MBEAN_SERVER, getEngine());
mbeanServer.unregisterMBean(getHttpJmxAdaptorName());
mbeanServer.unregisterMBean(getXslJmxAdaptorName());
} catch (Exception e) {
logger.warn("Could not unregister the JMX HTTP Adaptor");
}
}
}

public void stop() throws Exception {
if (server != null) {
removeHttpJmxAdaptor();
server.stop();
}
}
Expand Down
Expand Up @@ -228,6 +228,8 @@ public void validateConfiguration() {
if (!loadFromScriptIfProvided()) {
logger
.info("Could not find my identity in the database and this node is configured as a registration server. We are auto inserting the required rows to begin operation.");
// TODO
//nodeService.insertIdentity();
}
} else {
throw new IllegalStateException(
Expand Down

This file was deleted.

0 comments on commit 912d5bc

Please sign in to comment.