From dfa783aff8f17df85fee1f0efafb1f1bf2f101ed Mon Sep 17 00:00:00 2001 From: nebhale Date: Fri, 22 Feb 2008 14:45:24 +0000 Subject: [PATCH] [BATCH-63] More test changes --- ...org.springframework.ide.eclipse.core.prefs | 38 ++++++++++++ ...tchNamespaceHandlerJobRepositoryTests.java | 62 +++++++++++++++++++ ...BatchNamespaceHandlerTaskletStepTests.java | 30 +++++++-- .../configuration/StubDataSource.java | 57 +++++++++++++++++ 4 files changed, 182 insertions(+), 5 deletions(-) create mode 100644 spring-batch-execution/.settings/org.springframework.ide.eclipse.core.prefs create mode 100644 spring-batch-execution/src/test/java/org/springframework/batch/execution/configuration/BatchNamespaceHandlerJobRepositoryTests.java create mode 100644 spring-batch-execution/src/test/java/org/springframework/batch/execution/configuration/StubDataSource.java diff --git a/spring-batch-execution/.settings/org.springframework.ide.eclipse.core.prefs b/spring-batch-execution/.settings/org.springframework.ide.eclipse.core.prefs new file mode 100644 index 000000000..08dd4f649 --- /dev/null +++ b/spring-batch-execution/.settings/org.springframework.ide.eclipse.core.prefs @@ -0,0 +1,38 @@ +#Wed Feb 20 09:27:35 GMT 2008 +eclipse.preferences.version=1 +org.springframework.ide.eclipse.core.builders.enable.aopreferencemodelbuilder=true +org.springframework.ide.eclipse.core.enable.project.preferences=false +org.springframework.ide.eclipse.core.validator.enable.org.springframework.ide.eclipse.beans.core.beansvalidator=true +org.springframework.ide.eclipse.core.validator.enable.org.springframework.ide.eclipse.core.springvalidator=true +org.springframework.ide.eclipse.core.validator.enable.org.springframework.ide.eclipse.webflow.core.validator=true +org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.beans.core.beanAlias-org.springframework.ide.eclipse.beans.core.beansvalidator=true +org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.beans.core.beanClass-org.springframework.ide.eclipse.beans.core.beansvalidator=true +org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.beans.core.beanConstructorArgument-org.springframework.ide.eclipse.beans.core.beansvalidator=true +org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.beans.core.beanDefinition-org.springframework.ide.eclipse.beans.core.beansvalidator=true +org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.beans.core.beanDefinitionHolder-org.springframework.ide.eclipse.beans.core.beansvalidator=true +org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.beans.core.beanFactory-org.springframework.ide.eclipse.beans.core.beansvalidator=true +org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.beans.core.beanInitDestroyMethod-org.springframework.ide.eclipse.beans.core.beansvalidator=true +org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.beans.core.beanProperty-org.springframework.ide.eclipse.beans.core.beansvalidator=true +org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.beans.core.beanReference-org.springframework.ide.eclipse.beans.core.beansvalidator=true +org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.beans.core.methodOverride-org.springframework.ide.eclipse.beans.core.beansvalidator=true +org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.beans.core.parsingProblems-org.springframework.ide.eclipse.beans.core.beansvalidator=true +org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.beans.core.requiredProperty-org.springframework.ide.eclipse.beans.core.beansvalidator=false +org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.core.springClasspath-org.springframework.ide.eclipse.core.springvalidator=true +org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.webflow.core.validation.action-org.springframework.ide.eclipse.webflow.core.validator=true +org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.webflow.core.validation.actionstate-org.springframework.ide.eclipse.webflow.core.validator=true +org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.webflow.core.validation.attribute-org.springframework.ide.eclipse.webflow.core.validator=true +org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.webflow.core.validation.attributemapper-org.springframework.ide.eclipse.webflow.core.validator=true +org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.webflow.core.validation.beanaction-org.springframework.ide.eclipse.webflow.core.validator=true +org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.webflow.core.validation.evaluationaction-org.springframework.ide.eclipse.webflow.core.validator=true +org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.webflow.core.validation.evaluationresult-org.springframework.ide.eclipse.webflow.core.validator=true +org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.webflow.core.validation.exceptionhandler-org.springframework.ide.eclipse.webflow.core.validator=true +org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.webflow.core.validation.import-org.springframework.ide.eclipse.webflow.core.validator=true +org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.webflow.core.validation.inputattribute-org.springframework.ide.eclipse.webflow.core.validator=true +org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.webflow.core.validation.mapping-org.springframework.ide.eclipse.webflow.core.validator=true +org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.webflow.core.validation.outputattribute-org.springframework.ide.eclipse.webflow.core.validator=true +org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.webflow.core.validation.set-org.springframework.ide.eclipse.webflow.core.validator=true +org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.webflow.core.validation.state-org.springframework.ide.eclipse.webflow.core.validator=true +org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.webflow.core.validation.subflowstate-org.springframework.ide.eclipse.webflow.core.validator=true +org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.webflow.core.validation.transition-org.springframework.ide.eclipse.webflow.core.validator=true +org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.webflow.core.validation.variable-org.springframework.ide.eclipse.webflow.core.validator=true +org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.webflow.core.validation.webflowstate-org.springframework.ide.eclipse.webflow.core.validator=true diff --git a/spring-batch-execution/src/test/java/org/springframework/batch/execution/configuration/BatchNamespaceHandlerJobRepositoryTests.java b/spring-batch-execution/src/test/java/org/springframework/batch/execution/configuration/BatchNamespaceHandlerJobRepositoryTests.java new file mode 100644 index 000000000..4053a825d --- /dev/null +++ b/spring-batch-execution/src/test/java/org/springframework/batch/execution/configuration/BatchNamespaceHandlerJobRepositoryTests.java @@ -0,0 +1,62 @@ +/* + * Copyright 2002-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.execution.configuration; + +import junit.framework.TestCase; + +import org.springframework.beans.factory.parsing.BeanDefinitionParsingException; +import org.springframework.context.support.ClassPathXmlApplicationContext; + +public class BatchNamespaceHandlerJobRepositoryTests extends TestCase { + + private static final String PACKAGE = "org/springframework/batch/execution/configuration/"; + + public void testRepositoryOk() { + new ClassPathXmlApplicationContext(PACKAGE + "BatchNamespaceHandlerJobRepositoryOk.xml"); + } + + public void testRepositoryMissingDataSource() { + try { + new ClassPathXmlApplicationContext(PACKAGE + "BatchNamespaceHandlerJobRepositoryMissingDataSource.xml"); + fail("Expected BeanDefinitionParsingException"); + } catch (BeanDefinitionParsingException e) { } + } + + public void testRepositoryDb2() { + new ClassPathXmlApplicationContext(PACKAGE + "BatchNamespaceHandlerJobRepositoryDb2.xml"); + } + + public void testRepositoryDerby() { + new ClassPathXmlApplicationContext(PACKAGE + "BatchNamespaceHandlerJobRepositoryDerby.xml"); + } + + public void testRepositoryHsql() { + new ClassPathXmlApplicationContext(PACKAGE + "BatchNamespaceHandlerJobRepositoryHsql.xml"); + } + + public void testRepositoryMySql() { + new ClassPathXmlApplicationContext(PACKAGE + "BatchNamespaceHandlerJobRepositoryMySql.xml"); + } + + public void testRepositoryOracle() { + new ClassPathXmlApplicationContext(PACKAGE + "BatchNamespaceHandlerJobRepositoryOracle.xml"); + } + + public void testRepositoryPostgres() { + new ClassPathXmlApplicationContext(PACKAGE + "BatchNamespaceHandlerJobRepositoryPostgres.xml"); + } +} diff --git a/spring-batch-execution/src/test/java/org/springframework/batch/execution/configuration/BatchNamespaceHandlerTaskletStepTests.java b/spring-batch-execution/src/test/java/org/springframework/batch/execution/configuration/BatchNamespaceHandlerTaskletStepTests.java index 8102fcf89..032e63645 100644 --- a/spring-batch-execution/src/test/java/org/springframework/batch/execution/configuration/BatchNamespaceHandlerTaskletStepTests.java +++ b/spring-batch-execution/src/test/java/org/springframework/batch/execution/configuration/BatchNamespaceHandlerTaskletStepTests.java @@ -18,24 +18,44 @@ package org.springframework.batch.execution.configuration; import junit.framework.TestCase; +import org.springframework.batch.execution.step.tasklet.TaskletStep; import org.springframework.beans.factory.parsing.BeanDefinitionParsingException; +import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; public class BatchNamespaceHandlerTaskletStepTests extends TestCase { private static final String PACKAGE = "org/springframework/batch/execution/configuration/"; - public void testNamespaceOk() { + public void testTaskletStepOk() { new ClassPathXmlApplicationContext(PACKAGE + "BatchNamespaceHandlerTaskletStepOk.xml"); } - public void testNamespaceMissingTasklet() { + public void testTaskletStepMissingTasklet() { try { new ClassPathXmlApplicationContext(PACKAGE + "BatchNamespaceHandlerTaskletStepMissingTasklet.xml"); fail("Expected BeanDefinitionParsingException"); - } catch (BeanDefinitionParsingException e) { - - } + } catch (BeanDefinitionParsingException e) { } + } + + public void testTaskletStepRerunAlways() { + ApplicationContext ctx = new ClassPathXmlApplicationContext(PACKAGE + "BatchNamespaceHandlerTaskletStepRerunAlways.xml"); + TaskletStep step = (TaskletStep) ctx.getBean("process"); + assertEquals(Integer.MAX_VALUE, step.getStartLimit()); + assertTrue(step.isAllowStartIfComplete()); + } + + public void testTaskletStepRerunNever() { + ApplicationContext ctx = new ClassPathXmlApplicationContext(PACKAGE + "BatchNamespaceHandlerTaskletStepRerunNever.xml"); + TaskletStep step = (TaskletStep) ctx.getBean("process"); + assertEquals(1, step.getStartLimit()); + assertFalse(step.isAllowStartIfComplete()); } + public void testTaskletStepRerunIncomplete() { + ApplicationContext ctx = new ClassPathXmlApplicationContext(PACKAGE + "BatchNamespaceHandlerTaskletStepRerunIncomplete.xml"); + TaskletStep step = (TaskletStep) ctx.getBean("process"); + assertEquals(Integer.MAX_VALUE, step.getStartLimit()); + assertFalse(step.isAllowStartIfComplete()); + } } diff --git a/spring-batch-execution/src/test/java/org/springframework/batch/execution/configuration/StubDataSource.java b/spring-batch-execution/src/test/java/org/springframework/batch/execution/configuration/StubDataSource.java new file mode 100644 index 000000000..26b721a63 --- /dev/null +++ b/spring-batch-execution/src/test/java/org/springframework/batch/execution/configuration/StubDataSource.java @@ -0,0 +1,57 @@ +/* + * Copyright 2002-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.execution.configuration; + +import java.io.PrintWriter; +import java.sql.Connection; +import java.sql.SQLException; + +import javax.sql.DataSource; + +public class StubDataSource implements DataSource { + + public Connection getConnection() throws SQLException { + // TODO Auto-generated method stub + throw new UnsupportedOperationException(); + } + + public Connection getConnection(String username, String password) throws SQLException { + // TODO Auto-generated method stub + throw new UnsupportedOperationException(); + } + + public PrintWriter getLogWriter() throws SQLException { + // TODO Auto-generated method stub + throw new UnsupportedOperationException(); + } + + public int getLoginTimeout() throws SQLException { + // TODO Auto-generated method stub + throw new UnsupportedOperationException(); + } + + public void setLogWriter(PrintWriter out) throws SQLException { + // TODO Auto-generated method stub + throw new UnsupportedOperationException(); + } + + public void setLoginTimeout(int seconds) throws SQLException { + // TODO Auto-generated method stub + throw new UnsupportedOperationException(); + } + +} \ No newline at end of file