[BATCH-63] More test changes

This commit is contained in:
nebhale
2008-02-22 14:45:24 +00:00
parent a13214b9d5
commit dfa783aff8
4 changed files with 182 additions and 5 deletions

View File

@@ -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");
}
}

View File

@@ -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());
}
}

View File

@@ -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();
}
}