Add spring-batch- to module directory names (so folks can use mvn eclipse:eclipse if they want to).
BATCH-238: Remove hibernate support for the Daos.
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package org.springframework.batch.core;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
public abstract class AbstractExceptionTests extends TestCase {
|
||||
|
||||
public void testExceptionString() throws Exception {
|
||||
Exception exception = getException("foo");
|
||||
assertEquals("foo", exception.getMessage());
|
||||
}
|
||||
|
||||
public void testExceptionStringThrowable() throws Exception {
|
||||
Exception exception = getException("foo", new IllegalStateException());
|
||||
assertEquals("foo", exception.getMessage().substring(0, 3));
|
||||
}
|
||||
|
||||
public abstract Exception getException(String msg) throws Exception;
|
||||
|
||||
public abstract Exception getException(String msg, Throwable t) throws Exception;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
package org.springframework.batch.core.configuration;
|
||||
|
||||
import org.springframework.batch.core.AbstractExceptionTests;
|
||||
import org.springframework.batch.core.configuration.DuplicateJobConfigurationException;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
*
|
||||
*/
|
||||
public class DuplicateJobConfigurationExceptionTests extends AbstractExceptionTests {
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String)
|
||||
*/
|
||||
public Exception getException(String msg) throws Exception {
|
||||
return new DuplicateJobConfigurationException(msg);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String,
|
||||
* java.lang.Throwable)
|
||||
*/
|
||||
public Exception getException(String msg, Throwable t) throws Exception {
|
||||
return new DuplicateJobConfigurationException(msg, t);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
package org.springframework.batch.core.configuration;
|
||||
|
||||
import org.springframework.batch.core.AbstractExceptionTests;
|
||||
import org.springframework.batch.core.configuration.JobConfigurationException;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
*
|
||||
*/
|
||||
public class JobConfigurationExceptionTests extends AbstractExceptionTests {
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String)
|
||||
*/
|
||||
public Exception getException(String msg) throws Exception {
|
||||
return new JobConfigurationException(msg);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String,
|
||||
* java.lang.Throwable)
|
||||
*/
|
||||
public Exception getException(String msg, Throwable t) throws Exception {
|
||||
return new JobConfigurationException(msg, t);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
package org.springframework.batch.core.configuration;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
*
|
||||
*/
|
||||
public class JobConfigurationTests extends TestCase {
|
||||
|
||||
JobConfiguration configuration = new JobConfiguration("job");
|
||||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link org.springframework.batch.core.configuration.JobConfiguration#JobConfiguration()}.
|
||||
*/
|
||||
public void testJobConfiguration() {
|
||||
configuration = new JobConfiguration();
|
||||
assertNull(configuration.getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link org.springframework.batch.core.configuration.JobConfiguration#setBeanName(java.lang.String)}.
|
||||
*/
|
||||
public void testSetBeanName() {
|
||||
configuration.setBeanName("foo");
|
||||
assertEquals("job", configuration.getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link org.springframework.batch.core.configuration.JobConfiguration#setBeanName(java.lang.String)}.
|
||||
*/
|
||||
public void testSetBeanNameWithNullName() {
|
||||
configuration = new JobConfiguration(null);
|
||||
assertEquals(null, configuration.getName());
|
||||
configuration.setBeanName("foo");
|
||||
assertEquals("foo", configuration.getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link org.springframework.batch.core.configuration.JobConfiguration#setSteps(java.util.List)}.
|
||||
*/
|
||||
public void testSetSteps() {
|
||||
configuration.setSteps(Collections.singletonList(new StepConfigurationSupport("step")));
|
||||
assertEquals(1, configuration.getStepConfigurations().size());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link org.springframework.batch.core.configuration.JobConfiguration#addStep(org.springframework.batch.core.configuration.StepConfiguration)}.
|
||||
*/
|
||||
public void testAddStep() {
|
||||
configuration.addStep(new StepConfigurationSupport("step"));
|
||||
assertEquals(1, configuration.getStepConfigurations().size());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link org.springframework.batch.core.configuration.JobConfiguration#setStartLimit(int)}.
|
||||
*/
|
||||
public void testSetStartLimit() {
|
||||
assertEquals(Integer.MAX_VALUE, configuration.getStartLimit());
|
||||
configuration.setStartLimit(10);
|
||||
assertEquals(10, configuration.getStartLimit());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link org.springframework.batch.core.configuration.JobConfiguration#setRestartable(boolean)}.
|
||||
*/
|
||||
public void testSetRestartable() {
|
||||
assertFalse(configuration.isRestartable());
|
||||
configuration.setRestartable(true);
|
||||
assertTrue(configuration.isRestartable());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
package org.springframework.batch.core.configuration;
|
||||
|
||||
import org.springframework.batch.core.AbstractExceptionTests;
|
||||
import org.springframework.batch.core.configuration.NoSuchJobConfigurationException;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
*
|
||||
*/
|
||||
public class NoSuchJobConfigurationExceptionTests extends AbstractExceptionTests {
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String)
|
||||
*/
|
||||
public Exception getException(String msg) throws Exception {
|
||||
return new NoSuchJobConfigurationException(msg);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String,
|
||||
* java.lang.Throwable)
|
||||
*/
|
||||
public Exception getException(String msg, Throwable t) throws Exception {
|
||||
return new NoSuchJobConfigurationException(msg, t);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package org.springframework.batch.core.configuration;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.springframework.beans.factory.config.ConstructorArgumentValues;
|
||||
import org.springframework.beans.factory.support.ChildBeanDefinition;
|
||||
import org.springframework.beans.factory.support.RootBeanDefinition;
|
||||
import org.springframework.context.support.GenericApplicationContext;
|
||||
import org.springframework.context.support.StaticApplicationContext;
|
||||
|
||||
public class SpringBeanJobConfigurationTests extends TestCase {
|
||||
|
||||
public void testBeanName() throws Exception {
|
||||
StaticApplicationContext context = new StaticApplicationContext();
|
||||
JobConfiguration configuration = new JobConfiguration();
|
||||
context.getAutowireCapableBeanFactory().initializeBean(configuration,
|
||||
"bean");
|
||||
assertNotNull(configuration.getName());
|
||||
configuration.setBeanName("foo");
|
||||
context.getAutowireCapableBeanFactory().initializeBean(configuration,
|
||||
"bean");
|
||||
assertEquals("bean", configuration.getName());
|
||||
}
|
||||
|
||||
public void testBeanNameWithBeanDefinition() throws Exception {
|
||||
GenericApplicationContext context = new GenericApplicationContext();
|
||||
ConstructorArgumentValues args = new ConstructorArgumentValues();
|
||||
args.addGenericArgumentValue("foo");
|
||||
context.registerBeanDefinition("bean", new RootBeanDefinition(
|
||||
JobConfiguration.class, args, null));
|
||||
JobConfiguration configuration = (JobConfiguration) context
|
||||
.getBean("bean");
|
||||
assertNotNull(configuration.getName());
|
||||
assertEquals("foo", configuration.getName());
|
||||
configuration.setBeanName("bar");
|
||||
assertEquals("foo", configuration.getName());
|
||||
}
|
||||
|
||||
public void testBeanNameWithParentBeanDefinition() throws Exception {
|
||||
GenericApplicationContext context = new GenericApplicationContext();
|
||||
ConstructorArgumentValues args = new ConstructorArgumentValues();
|
||||
args.addGenericArgumentValue("bar");
|
||||
context.registerBeanDefinition("parent", new RootBeanDefinition(
|
||||
JobConfiguration.class, args, null));
|
||||
context.registerBeanDefinition("bean", new ChildBeanDefinition("parent"));
|
||||
JobConfiguration configuration = (JobConfiguration) context
|
||||
.getBean("bean");
|
||||
assertNotNull(configuration.getName());
|
||||
assertEquals("bar", configuration.getName());
|
||||
configuration.setBeanName("foo");
|
||||
assertEquals("bar", configuration.getName());
|
||||
configuration.setName("foo");
|
||||
assertEquals("foo", configuration.getName());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
package org.springframework.batch.core.configuration;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.springframework.batch.core.tasklet.Tasklet;
|
||||
import org.springframework.batch.repeat.ExitStatus;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
*
|
||||
*/
|
||||
public class StepConfigurationSupportTests extends TestCase {
|
||||
|
||||
private StepConfigurationSupport configuration = new StepConfigurationSupport("step");
|
||||
|
||||
/**
|
||||
* Test method for {@link org.springframework.batch.core.configuration.StepConfigurationSupport#StepConfigurationSupport()}.
|
||||
*/
|
||||
public void testStepConfigurationSupport() {
|
||||
configuration = new StepConfigurationSupport();
|
||||
assertNull(configuration.getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link org.springframework.batch.core.configuration.StepConfigurationSupport#getName()}.
|
||||
*/
|
||||
public void testGetName() {
|
||||
assertEquals("step", configuration.getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link org.springframework.batch.core.configuration.StepConfigurationSupport#getStartLimit()}.
|
||||
*/
|
||||
public void testGetStartLimit() {
|
||||
assertEquals(Integer.MAX_VALUE, configuration.getStartLimit());
|
||||
configuration.setStartLimit(10);
|
||||
assertEquals(10, configuration.getStartLimit());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link org.springframework.batch.core.configuration.StepConfigurationSupport#getTasklet()}.
|
||||
*/
|
||||
public void testGetTasklet() {
|
||||
assertEquals(null, configuration.getTasklet());
|
||||
Tasklet tasklet = new Tasklet() {
|
||||
public ExitStatus execute() throws Exception {
|
||||
return ExitStatus.FINISHED;
|
||||
}
|
||||
};
|
||||
configuration.setTasklet(tasklet);
|
||||
assertEquals(tasklet, configuration.getTasklet());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link org.springframework.batch.core.configuration.StepConfigurationSupport#isAllowStartIfComplete()}.
|
||||
*/
|
||||
public void testShouldAllowStartIfComplete() {
|
||||
assertEquals(false, configuration.isAllowStartIfComplete());
|
||||
configuration.setAllowStartIfComplete(true);
|
||||
assertEquals(true, configuration.isAllowStartIfComplete());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
package org.springframework.batch.core.domain;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
*
|
||||
*/
|
||||
public class BatchStatusTests extends TestCase {
|
||||
|
||||
/**
|
||||
* Test method for {@link org.springframework.batch.core.domain.BatchStatus#toString()}.
|
||||
*/
|
||||
public void testToString() {
|
||||
assertEquals("FAILED", BatchStatus.FAILED.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link org.springframework.batch.core.domain.BatchStatus#getStatus(java.lang.String)}.
|
||||
*/
|
||||
public void testGetStatus() {
|
||||
assertEquals(BatchStatus.FAILED, BatchStatus.getStatus(BatchStatus.FAILED.toString()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link org.springframework.batch.core.domain.BatchStatus#getStatus(java.lang.String)}.
|
||||
*/
|
||||
public void testGetStatusWrongCode() {
|
||||
assertEquals(null, BatchStatus.getStatus("foo"));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
package org.springframework.batch.core.domain;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
*
|
||||
*/
|
||||
public class EntityTests extends TestCase {
|
||||
|
||||
Entity entity = new Entity(new Long(11));
|
||||
|
||||
/**
|
||||
* Test method for {@link org.springframework.batch.core.domain.Entity#hashCode()}.
|
||||
*/
|
||||
public void testHashCode() {
|
||||
assertEquals(entity.hashCode(), new Entity(entity.getId()).hashCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link org.springframework.batch.core.domain.Entity#hashCode()}.
|
||||
*/
|
||||
public void testHashCodeNullId() {
|
||||
int withoutNull = entity.hashCode();
|
||||
entity.setId(null);
|
||||
int withNull = entity.hashCode();
|
||||
assertTrue(withoutNull!=withNull);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link org.springframework.batch.core.domain.Entity#getVersion()}.
|
||||
*/
|
||||
public void testGetVersion() {
|
||||
assertEquals(null, entity.getVersion());
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
public void testToString() throws Exception {
|
||||
Entity job = new Entity();
|
||||
assertTrue(job.toString().indexOf("id=null") >= 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link org.springframework.batch.core.domain.Entity#equals(java.lang.Object)}.
|
||||
*/
|
||||
public void testEqualsSelf() {
|
||||
assertEquals(entity, entity);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link org.springframework.batch.core.domain.Entity#equals(java.lang.Object)}.
|
||||
*/
|
||||
public void testEqualsSelfWithNullId() {
|
||||
entity = new Entity(null);
|
||||
assertEquals(entity, entity);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link org.springframework.batch.core.domain.Entity#equals(java.lang.Object)}.
|
||||
*/
|
||||
public void testEqualsEntityWithNullId() {
|
||||
entity = new Entity(null);
|
||||
assertNotSame(entity, new Entity(null));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link org.springframework.batch.core.domain.Entity#equals(java.lang.Object)}.
|
||||
*/
|
||||
public void testEqualsEntity() {
|
||||
assertEquals(entity, new Entity(entity.getId()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link org.springframework.batch.core.domain.Entity#equals(java.lang.Object)}.
|
||||
*/
|
||||
public void testEqualsEntityWrongId() {
|
||||
assertFalse(entity.equals(new Entity()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link org.springframework.batch.core.domain.Entity#equals(java.lang.Object)}.
|
||||
*/
|
||||
public void testEqualsObject() {
|
||||
assertFalse(entity.equals(new Object()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link org.springframework.batch.core.domain.Entity#equals(java.lang.Object)}.
|
||||
*/
|
||||
public void testEqualsNull() {
|
||||
assertFalse(entity.equals(null));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,150 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
package org.springframework.batch.core.domain;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.springframework.batch.core.runtime.SimpleJobIdentifier;
|
||||
import org.springframework.batch.repeat.ExitStatus;
|
||||
import org.springframework.batch.repeat.context.RepeatContextSupport;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
*
|
||||
*/
|
||||
public class JobExecutionTests extends TestCase {
|
||||
|
||||
private JobExecution execution = new JobExecution(new JobInstance(null, new Long(11)));
|
||||
private JobExecution context = new JobExecution(new JobInstance(new SimpleJobIdentifier("foo"), new Long(11)));
|
||||
|
||||
/**
|
||||
* Test method for {@link org.springframework.batch.core.domain.JobExecution#JobExecution()}.
|
||||
*/
|
||||
public void testJobExecution() {
|
||||
assertNull(new JobExecution().getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link org.springframework.batch.core.domain.JobExecution#getEndTime()}.
|
||||
*/
|
||||
public void testGetEndTime() {
|
||||
assertNull(execution.getEndTime());
|
||||
execution.setEndTime(new Timestamp(100L));
|
||||
assertEquals(100L, execution.getEndTime().getTime());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link org.springframework.batch.core.domain.JobExecution#getStartTime()}.
|
||||
*/
|
||||
public void testGetStartTime() {
|
||||
assertNotNull(execution.getStartTime());
|
||||
execution.setStartTime(new Timestamp(0L));
|
||||
assertEquals(0L, execution.getStartTime().getTime());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link org.springframework.batch.core.domain.JobExecution#getStatus()}.
|
||||
*/
|
||||
public void testGetStatus() {
|
||||
assertEquals(BatchStatus.STARTING, execution.getStatus());
|
||||
execution.setStatus(BatchStatus.COMPLETED);
|
||||
assertEquals(BatchStatus.COMPLETED, execution.getStatus());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link org.springframework.batch.core.domain.JobExecution#getJobId()}.
|
||||
*/
|
||||
public void testGetJobId() {
|
||||
assertEquals(11, execution.getJobId().longValue());
|
||||
execution = new JobExecution(new JobInstance(null, new Long(23)));
|
||||
assertEquals(23, execution.getJobId().longValue());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link org.springframework.batch.core.domain.JobExecution#getJobId()}.
|
||||
*/
|
||||
public void testGetJobIdForNullJob() {
|
||||
execution = new JobExecution(null);
|
||||
assertEquals(null, execution.getJobId());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link org.springframework.batch.core.domain.JobExecution#getJobId()}.
|
||||
*/
|
||||
public void testGetJob() {
|
||||
assertNotNull(execution.getJob());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link org.springframework.batch.core.domain.JobExecution#getExitStatus()}.
|
||||
*/
|
||||
public void testGetExitCode() {
|
||||
assertEquals(ExitStatus.UNKNOWN, execution.getExitStatus());
|
||||
execution.setExitStatus(new ExitStatus(true, "23"));
|
||||
assertEquals("23", execution.getExitStatus().getExitCode());
|
||||
}
|
||||
|
||||
public void testContextContainsInfo() throws Exception {
|
||||
assertEquals("foo", context.getJob().getIdentifier().getName());
|
||||
}
|
||||
|
||||
public void testNullContexts() throws Exception {
|
||||
assertEquals(0, context.getStepContexts().size());
|
||||
assertEquals(0, context.getChunkContexts().size());
|
||||
}
|
||||
|
||||
public void testStepContext() throws Exception {
|
||||
context.registerStepContext(new RepeatContextSupport(null));
|
||||
assertEquals(1, context.getStepContexts().size());
|
||||
}
|
||||
|
||||
public void testAddAndRemoveStepContext() throws Exception {
|
||||
context.registerStepContext(new RepeatContextSupport(null));
|
||||
assertEquals(1, context.getStepContexts().size());
|
||||
context.unregisterStepContext(new RepeatContextSupport(null));
|
||||
assertEquals(0, context.getStepContexts().size());
|
||||
}
|
||||
|
||||
public void testAddAndRemoveStepExecution() throws Exception {
|
||||
assertEquals(0, context.getStepExecutions().size());
|
||||
context.registerStepExecution(new StepExecution(null, null));
|
||||
assertEquals(1, context.getStepExecutions().size());
|
||||
}
|
||||
|
||||
public void testAddAndRemoveChunkContext() throws Exception {
|
||||
context.registerChunkContext(new RepeatContextSupport(null));
|
||||
assertEquals(1, context.getChunkContexts().size());
|
||||
context.unregisterChunkContext(new RepeatContextSupport(null));
|
||||
assertEquals(0, context.getChunkContexts().size());
|
||||
}
|
||||
|
||||
public void testRemoveChunkContext() throws Exception {
|
||||
context.unregisterChunkContext(new RepeatContextSupport(null));
|
||||
assertEquals(0, context.getChunkContexts().size());
|
||||
}
|
||||
|
||||
public void testToString() throws Exception {
|
||||
assertTrue("JobExecution string does not contain id", context.toString().indexOf("id=")>=0);
|
||||
assertTrue("JobExecution string does not contain name: "+context, context.toString().indexOf("foo")>=0);
|
||||
}
|
||||
|
||||
public void testToStringWithNullJob() throws Exception {
|
||||
context = new JobExecution();
|
||||
assertTrue("JobExecution string does not contain id", context.toString().indexOf("id=")>=0);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
package org.springframework.batch.core.domain;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
import org.springframework.batch.core.runtime.SimpleJobIdentifier;
|
||||
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
/**
|
||||
* @author dsyer
|
||||
*
|
||||
*/
|
||||
public class JobInstanceTests extends TestCase {
|
||||
|
||||
private JobInstance instance = new JobInstance(null, new Long(11));
|
||||
|
||||
/**
|
||||
* Test method for {@link org.springframework.batch.core.domain.JobInstance#JobInstance()}.
|
||||
*/
|
||||
public void testJobInstance() {
|
||||
assertNull(new JobInstance(null).getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link org.springframework.batch.core.domain.JobInstance#getStatus()}.
|
||||
*/
|
||||
public void testGetStatus() {
|
||||
assertNull(instance.getStatus());
|
||||
instance.setStatus(BatchStatus.COMPLETED);
|
||||
assertNotNull(instance.getStatus());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link org.springframework.batch.core.domain.JobInstance#getSteps()}.
|
||||
*/
|
||||
public void testGetSteps() {
|
||||
assertEquals(0, instance.getSteps().size());
|
||||
instance.setSteps(Collections.singletonList(new StepInstance()));
|
||||
assertEquals(1, instance.getSteps().size());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link org.springframework.batch.core.domain.JobInstance#addStep(org.springframework.batch.core.domain.StepInstance)}.
|
||||
*/
|
||||
public void testAddStep() {
|
||||
instance.addStep(new StepInstance());
|
||||
assertEquals(1, instance.getSteps().size());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link org.springframework.batch.core.domain.JobInstance#getJobExecutionCount()}.
|
||||
*/
|
||||
public void testGetJobExecutionCount() {
|
||||
assertEquals(0, instance.getJobExecutionCount());
|
||||
instance.setJobExecutionCount(22);
|
||||
assertEquals(22, instance.getJobExecutionCount());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link org.springframework.batch.core.domain.JobInstance#getIdentifier()}.
|
||||
*/
|
||||
public void testGetIdentifier() {
|
||||
assertEquals(null, instance.getIdentifier());
|
||||
instance = new JobInstance(new SimpleJobIdentifier("foo"));
|
||||
assertEquals("foo", instance.getIdentifier().getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link org.springframework.batch.core.domain.JobInstance#getIdentifier()}.
|
||||
*/
|
||||
public void testGetName() {
|
||||
assertEquals(null, instance.getName());
|
||||
instance = new JobInstance(new SimpleJobIdentifier("foo"));
|
||||
assertEquals("foo", instance.getName());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,220 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
package org.springframework.batch.core.domain;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.springframework.batch.repeat.ExitStatus;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
*
|
||||
*/
|
||||
public class StepExecutionTests extends TestCase {
|
||||
|
||||
private StepExecution execution = newStepExecution(new Long(11),
|
||||
new Long(23));
|
||||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link org.springframework.batch.core.domain.JobExecution#JobExecution()}.
|
||||
*/
|
||||
public void testStepExecution() {
|
||||
assertNull(new StepExecution().getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link org.springframework.batch.core.domain.JobExecution#getEndTime()}.
|
||||
*/
|
||||
public void testGetEndTime() {
|
||||
assertNull(execution.getEndTime());
|
||||
execution.setEndTime(new Timestamp(0L));
|
||||
assertEquals(0L, execution.getEndTime().getTime());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link org.springframework.batch.core.domain.JobExecution#getStartTime()}.
|
||||
*/
|
||||
public void testGetStartTime() {
|
||||
assertNotNull(execution.getStartTime());
|
||||
execution.setStartTime(new Timestamp(10L));
|
||||
assertEquals(10L, execution.getStartTime().getTime());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link org.springframework.batch.core.domain.JobExecution#getStatus()}.
|
||||
*/
|
||||
public void testGetStatus() {
|
||||
assertEquals(BatchStatus.STARTING, execution.getStatus());
|
||||
execution.setStatus(BatchStatus.COMPLETED);
|
||||
assertEquals(BatchStatus.COMPLETED, execution.getStatus());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link org.springframework.batch.core.domain.JobExecution#getJobId()}.
|
||||
*/
|
||||
public void testGetJobId() {
|
||||
assertEquals(23, execution.getJobExecutionId().longValue());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link org.springframework.batch.core.domain.JobExecution#getExitStatus()}.
|
||||
*/
|
||||
public void testGetExitCode() {
|
||||
assertEquals(ExitStatus.UNKNOWN, execution.getExitStatus());
|
||||
execution.setExitStatus(ExitStatus.FINISHED);
|
||||
assertEquals(ExitStatus.FINISHED, execution.getExitStatus());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link org.springframework.batch.core.domain.StepExecution#incrementCommitCount()}.
|
||||
*/
|
||||
public void testIncrementCommitCount() {
|
||||
int before = execution.getCommitCount().intValue();
|
||||
execution.incrementCommitCount();
|
||||
int after = execution.getCommitCount().intValue();
|
||||
assertEquals(before + 1, after);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link org.springframework.batch.core.domain.StepExecution#incrementTaskCount()}.
|
||||
*/
|
||||
public void testIncrementLuwCount() {
|
||||
int before = execution.getTaskCount().intValue();
|
||||
execution.incrementTaskCount();
|
||||
int after = execution.getTaskCount().intValue();
|
||||
assertEquals(before + 1, after);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link org.springframework.batch.core.domain.StepExecution#incrementRollbackCount()}.
|
||||
*/
|
||||
public void testIncrementRollbackCount() {
|
||||
int before = execution.getRollbackCount().intValue();
|
||||
execution.incrementRollbackCount();
|
||||
int after = execution.getRollbackCount().intValue();
|
||||
assertEquals(before + 1, after);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link org.springframework.batch.core.domain.StepExecution#getCommitCount()}.
|
||||
*/
|
||||
public void testGetCommitCount() {
|
||||
execution.setCommitCount(123);
|
||||
assertEquals(123, execution.getCommitCount().intValue());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link org.springframework.batch.core.domain.StepExecution#getTaskCount()}.
|
||||
*/
|
||||
public void testGetTaskCount() {
|
||||
execution.setTaskCount(123);
|
||||
assertEquals(123, execution.getTaskCount().intValue());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link org.springframework.batch.core.domain.StepExecution#getRollbackCount()}.
|
||||
*/
|
||||
public void testGetRollbackCount() {
|
||||
execution.setRollbackCount(123);
|
||||
assertEquals(123, execution.getRollbackCount().intValue());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link org.springframework.batch.core.domain.StepExecution#getStepId()}.
|
||||
*/
|
||||
public void testGetStepId() {
|
||||
assertEquals(11, execution.getStepId().longValue());
|
||||
}
|
||||
|
||||
public void testToString() throws Exception {
|
||||
assertTrue("Should contain task count: " + execution.toString(),
|
||||
execution.toString().indexOf("task") >= 0);
|
||||
assertTrue("Should contain commit count: " + execution.toString(),
|
||||
execution.toString().indexOf("commit") >= 0);
|
||||
assertTrue("Should contain rollback count: " + execution.toString(),
|
||||
execution.toString().indexOf("rollback") >= 0);
|
||||
}
|
||||
|
||||
public void testStatistics() throws Exception {
|
||||
assertNotNull(execution.getStatistics());
|
||||
execution.setStatistics(new Properties() {
|
||||
{
|
||||
setProperty("foo", "bar");
|
||||
}
|
||||
});
|
||||
assertEquals("bar", execution.getStatistics().getProperty("foo"));
|
||||
}
|
||||
|
||||
public void testEqualsWithSameIdentifier() throws Exception {
|
||||
StepExecution step1 = newStepExecution(new Long(100), new Long(11));
|
||||
StepExecution step2 = newStepExecution(new Long(100), new Long(11));
|
||||
assertEquals(step1, step2);
|
||||
}
|
||||
|
||||
public void testEqualsWithNull() throws Exception {
|
||||
StepExecution step = newStepExecution(new Long(100), new Long(11));
|
||||
assertFalse(step.equals(null));
|
||||
}
|
||||
|
||||
public void testEqualsWithNullIdentifiers() throws Exception {
|
||||
StepExecution step = newStepExecution(new Long(100), new Long(11));
|
||||
assertFalse(step.equals(new StepExecution()));
|
||||
}
|
||||
|
||||
public void testEqualsWithNullJob() throws Exception {
|
||||
StepExecution step = newStepExecution(null, new Long(11));
|
||||
assertFalse(step.equals(new StepExecution()));
|
||||
}
|
||||
|
||||
public void testEqualsWithNullStep() throws Exception {
|
||||
StepExecution step = newStepExecution(new Long(11), null);
|
||||
assertFalse(step.equals(new StepExecution()));
|
||||
}
|
||||
|
||||
public void testHashCode() throws Exception {
|
||||
assertTrue("Hash code same as parent", new Entity(execution.getId())
|
||||
.hashCode() != execution.hashCode());
|
||||
}
|
||||
|
||||
public void testHashCodeWithNullIds() throws Exception {
|
||||
assertTrue("Hash code not same as parent",
|
||||
new Entity(execution.getId()).hashCode() != new StepExecution()
|
||||
.hashCode());
|
||||
}
|
||||
|
||||
private StepExecution newStepExecution(Long long1, Long long2) {
|
||||
JobInstance job = new JobInstance(null);
|
||||
StepInstance step = new StepInstance(job, "foo", long1);
|
||||
StepExecution execution = new StepExecution(step, new JobExecution(job, long2));
|
||||
return execution;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
package org.springframework.batch.core.domain;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
import org.springframework.batch.restart.GenericRestartData;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
*
|
||||
*/
|
||||
public class StepInstanceTests extends TestCase {
|
||||
|
||||
StepInstance instance = new StepInstance(new Long(13));
|
||||
|
||||
/**
|
||||
* Test method for {@link org.springframework.batch.core.domain.StepInstance#StepInstance()}.
|
||||
*/
|
||||
public void testStepInstance() {
|
||||
assertNull(new StepInstance().getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link org.springframework.batch.core.domain.StepInstance#getStepExecutionCount()}.
|
||||
*/
|
||||
public void testGetStepExecutionCount() {
|
||||
assertEquals(0, instance.getStepExecutionCount());
|
||||
instance.setStepExecutionCount(23);
|
||||
assertEquals(23, instance.getStepExecutionCount());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link org.springframework.batch.core.domain.StepInstance#getRestartData()}.
|
||||
*/
|
||||
public void testGetRestartData() {
|
||||
assertNotNull(instance.getRestartData());
|
||||
assertTrue(instance.getRestartData().getProperties().isEmpty());
|
||||
instance.setRestartData(new GenericRestartData(new Properties() {{
|
||||
setProperty("foo", "bar");
|
||||
}}));
|
||||
assertEquals("bar", instance.getRestartData().getProperties().getProperty("foo"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link org.springframework.batch.core.domain.StepInstance#getStatus()}.
|
||||
*/
|
||||
public void testGetStatus() {
|
||||
assertEquals(null, instance.getStatus());
|
||||
instance.setStatus(BatchStatus.COMPLETED);
|
||||
assertEquals(BatchStatus.COMPLETED, instance.getStatus());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link org.springframework.batch.core.domain.StepInstance#getJob()}.
|
||||
*/
|
||||
public void testGetJob() {
|
||||
assertEquals(null, instance.getJob());
|
||||
JobInstance job = new JobInstance(null);
|
||||
instance = new StepInstance(job, null);
|
||||
assertEquals(job, instance.getJob());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link org.springframework.batch.core.domain.StepInstance#getName()}.
|
||||
*/
|
||||
public void testGetName() {
|
||||
assertEquals(null, instance.getName());
|
||||
instance = new StepInstance(null, "foo");
|
||||
assertEquals("foo", instance.getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link org.springframework.batch.core.domain.StepInstance#getJobId()}.
|
||||
*/
|
||||
public void testGetJobId() {
|
||||
assertEquals(null, instance.getJobId());
|
||||
instance = new StepInstance(new JobInstance(null, new Long(23)), null);
|
||||
assertEquals(23, instance.getJobId().longValue());
|
||||
}
|
||||
|
||||
public void testEqualsWithSameIdentifier() throws Exception {
|
||||
JobInstance job = new JobInstance(null, new Long(100));
|
||||
StepInstance step1 = new StepInstance(job, "foo", new Long(0));
|
||||
StepInstance step2 = new StepInstance(job, "foo", new Long(0));
|
||||
assertEquals(step1, step2);
|
||||
}
|
||||
|
||||
public void testToString() throws Exception {
|
||||
assertTrue("Should contain name", instance.toString().indexOf("name=")>=0);
|
||||
assertTrue("Should contain status", instance.toString().indexOf("status=")>=0);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
package org.springframework.batch.core.executor;
|
||||
|
||||
import org.springframework.batch.core.AbstractExceptionTests;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
*
|
||||
*/
|
||||
public class JobExecutionExceptionTests extends AbstractExceptionTests {
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String)
|
||||
*/
|
||||
public Exception getException(String msg) throws Exception {
|
||||
return new JobExecutionException(msg);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String, java.lang.Throwable)
|
||||
*/
|
||||
public Exception getException(String msg, Throwable t) throws Exception {
|
||||
return new JobExecutionException(msg, t);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
package org.springframework.batch.core.executor;
|
||||
|
||||
import org.springframework.batch.core.AbstractExceptionTests;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
*
|
||||
*/
|
||||
public class StepInterruptedExceptionTests extends AbstractExceptionTests {
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String)
|
||||
*/
|
||||
public Exception getException(String msg) throws Exception {
|
||||
return new StepInterruptedException(msg);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String, java.lang.Throwable)
|
||||
*/
|
||||
public Exception getException(String msg, Throwable t) throws Exception {
|
||||
return new RuntimeException(msg, t);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
package org.springframework.batch.core.repository;
|
||||
|
||||
import org.springframework.batch.core.AbstractExceptionTests;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
*
|
||||
*/
|
||||
public class BatchRestartExceptionTests extends AbstractExceptionTests {
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String)
|
||||
*/
|
||||
public Exception getException(String msg) throws Exception {
|
||||
return new BatchRestartException(msg);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String,
|
||||
* java.lang.Throwable)
|
||||
*/
|
||||
public Exception getException(String msg, Throwable t) throws Exception {
|
||||
return new BatchRestartException(msg, t);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
package org.springframework.batch.core.repository;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
*
|
||||
*/
|
||||
public class NoSuchBatchDomainObjectExceptionTests extends TestCase {
|
||||
|
||||
public void testCreateException() throws Exception {
|
||||
NoSuchBatchDomainObjectException e = new NoSuchBatchDomainObjectException("Foo");
|
||||
assertEquals("Foo", e.getMessage());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package org.springframework.batch.core.runtime;
|
||||
|
||||
import org.springframework.batch.core.domain.JobIdentifier;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
public class SimpleJobIdentifierFactoryTests extends TestCase {
|
||||
|
||||
public void testGetJobIdentifier() {
|
||||
JobIdentifier jobIdentifier = new SimpleJobIdentifierFactory().getJobIdentifier("foo");
|
||||
assertEquals("foo", jobIdentifier.getName());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
package org.springframework.batch.core.runtime;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
*
|
||||
*/
|
||||
public class SimpleJobIdentifierTests extends TestCase {
|
||||
|
||||
private SimpleJobIdentifier identifier = new SimpleJobIdentifier("foo");
|
||||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link org.springframework.batch.core.runtime.SimpleJobIdentifier#SimpleJobIdentifier()}.
|
||||
*/
|
||||
public void testSimpleJobIdentifier() {
|
||||
assertNull(new SimpleJobIdentifier().getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link org.springframework.batch.core.runtime.SimpleJobIdentifier#getName()}.
|
||||
*/
|
||||
public void testGetName() {
|
||||
assertEquals("foo", identifier.getName());
|
||||
identifier.setName("bar");
|
||||
assertEquals("bar", identifier.getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link org.springframework.batch.core.runtime.SimpleJobIdentifier#toString()}.
|
||||
*/
|
||||
public void testToString() {
|
||||
assertTrue("SimpleJobIdentifier toString should contain name: " + identifier.toString(), identifier.toString()
|
||||
.indexOf("name=") >= 0);
|
||||
}
|
||||
|
||||
public void testEquals(){
|
||||
SimpleJobIdentifier testIdentifier = new SimpleJobIdentifier("foo");
|
||||
assertEquals(testIdentifier,identifier);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user