IN PROGRESS - issue BATCH-264: Dependencies among jobs
Refactored SimpleJob and AbstractJob. Also had to fix JobRegistryBackgroundJobRunner to not use stdin for blocking.
This commit is contained in:
@@ -22,7 +22,7 @@ log4j.rootLogger=info, stdout
|
||||
#log4j.logger.org.hibernate.connection.DriverManagerConnectionProvider=trace
|
||||
|
||||
### enable spring
|
||||
log4j.logger.org.springframework=info
|
||||
#log4j.logger.org.springframework=info
|
||||
#log4j.logger.org.springframework.transaction=debug
|
||||
#log4j.logger.org.springframework.jdbc.core=debug
|
||||
#log4j.logger.org.springframework.orm=debug
|
||||
|
||||
30
spring-batch-samples/src/test/java/TestSuite.java
Normal file
30
spring-batch-samples/src/test/java/TestSuite.java
Normal file
@@ -0,0 +1,30 @@
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Suite;
|
||||
import org.springframework.batch.sample.HibernateJobFunctionalTests;
|
||||
import org.springframework.batch.sample.launch.RemoteLauncherTests;
|
||||
|
||||
/*
|
||||
* Copyright 2006-2007 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
*
|
||||
*/
|
||||
@RunWith(Suite.class)
|
||||
@Suite.SuiteClasses( { RemoteLauncherTests.class, HibernateJobFunctionalTests.class })
|
||||
public class TestSuite {
|
||||
|
||||
}
|
||||
@@ -28,7 +28,8 @@ import javax.management.MalformedObjectNameException;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.junit.Before;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.springframework.batch.core.launch.JobOperator;
|
||||
import org.springframework.batch.core.launch.support.JobRegistryBackgroundJobRunner;
|
||||
@@ -42,7 +43,7 @@ import org.springframework.jmx.support.MBeanServerConnectionFactoryBean;
|
||||
*
|
||||
*/
|
||||
public class RemoteLauncherTests {
|
||||
|
||||
|
||||
private static Log logger = LogFactory.getLog(RemoteLauncherTests.class);
|
||||
|
||||
private static List<Exception> errors = new ArrayList<Exception>();
|
||||
@@ -51,6 +52,8 @@ public class RemoteLauncherTests {
|
||||
|
||||
private static JobLoader loader;
|
||||
|
||||
static private Thread thread;
|
||||
|
||||
@Test
|
||||
public void testConnect() throws Exception {
|
||||
String message = errors.isEmpty() ? "" : errors.get(0).getMessage();
|
||||
@@ -63,12 +66,13 @@ public class RemoteLauncherTests {
|
||||
assertEquals(0, errors.size());
|
||||
assertTrue(isConnected());
|
||||
try {
|
||||
launcher.start("foo", "time="+(new Date().getTime()));
|
||||
launcher.start("foo", "time=" + (new Date().getTime()));
|
||||
fail("Expected RuntimeException");
|
||||
} catch (RuntimeException e) {
|
||||
//expected;
|
||||
}
|
||||
catch (RuntimeException e) {
|
||||
// expected;
|
||||
String message = e.getMessage();
|
||||
assertTrue("Wrong message: "+message, message.contains("NoSuchJobException"));
|
||||
assertTrue("Wrong message: " + message, message.contains("NoSuchJobException"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,15 +85,13 @@ public class RemoteLauncherTests {
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see junit.framework.TestCase#setUp()
|
||||
*/
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
if (launcher != null) {
|
||||
return;
|
||||
}
|
||||
@BeforeClass
|
||||
public static void setUp() throws Exception {
|
||||
System.setProperty("com.sun.management.jmxremote", "");
|
||||
Thread thread = new Thread(new Runnable() {
|
||||
thread = new Thread(new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
JobRegistryBackgroundJobRunner.main("adhoc-job-launcher-context.xml", "jobs/adhocLoopJob.xml");
|
||||
@@ -106,6 +108,11 @@ public class RemoteLauncherTests {
|
||||
}
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void cleanUp() {
|
||||
JobRegistryBackgroundJobRunner.stop();
|
||||
}
|
||||
|
||||
private static boolean isConnected() throws Exception {
|
||||
boolean connected = false;
|
||||
if (!JobRegistryBackgroundJobRunner.getErrors().isEmpty()) {
|
||||
@@ -114,7 +121,8 @@ public class RemoteLauncherTests {
|
||||
if (launcher == null) {
|
||||
MBeanServerConnectionFactoryBean connectionFactory = new MBeanServerConnectionFactoryBean();
|
||||
try {
|
||||
launcher = (JobOperator) getMBean(connectionFactory, "spring:service=batch,bean=jobOperator", JobOperator.class);
|
||||
launcher = (JobOperator) getMBean(connectionFactory, "spring:service=batch,bean=jobOperator",
|
||||
JobOperator.class);
|
||||
loader = (JobLoader) getMBean(connectionFactory, "spring:service=batch,bean=jobLoader", JobLoader.class);
|
||||
}
|
||||
catch (MBeanServerNotFoundException e) {
|
||||
@@ -124,7 +132,7 @@ public class RemoteLauncherTests {
|
||||
}
|
||||
try {
|
||||
launcher.getJobNames();
|
||||
connected = loader.getConfigurations().size()>0;
|
||||
connected = loader.getConfigurations().size() > 0;
|
||||
logger.info("Configurations loaded: " + loader.getConfigurations());
|
||||
}
|
||||
catch (InvalidInvocationException e) {
|
||||
@@ -133,8 +141,8 @@ public class RemoteLauncherTests {
|
||||
return connected;
|
||||
}
|
||||
|
||||
private static Object getMBean(MBeanServerConnectionFactoryBean connectionFactory, String objectName, Class<?> interfaceType)
|
||||
throws MalformedObjectNameException {
|
||||
private static Object getMBean(MBeanServerConnectionFactoryBean connectionFactory, String objectName,
|
||||
Class<?> interfaceType) throws MalformedObjectNameException {
|
||||
MBeanProxyFactoryBean factory = new MBeanProxyFactoryBean();
|
||||
factory.setObjectName(objectName);
|
||||
factory.setProxyInterface(interfaceType);
|
||||
|
||||
Reference in New Issue
Block a user