IN PROGRESS - issue BATCH-476: samples cleanup
http://jira.springframework.org/browse/BATCH-476
This commit is contained in:
@@ -1,25 +0,0 @@
|
||||
/*
|
||||
* 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.sample;
|
||||
|
||||
/**
|
||||
* This job differs from FixedLengthImportJob only in internal job, therefore
|
||||
* the test is reused, only the job config location is overridden
|
||||
*/
|
||||
public class SimpleJobFunctionalTests extends FixedLengthImportJobFunctionalTests {
|
||||
|
||||
}
|
||||
@@ -1,57 +0,0 @@
|
||||
package org.springframework.batch.sample.tasklet;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.springframework.batch.item.file.FlatFileItemReader;
|
||||
import org.springframework.batch.sample.dao.TradeDao;
|
||||
import org.springframework.batch.sample.domain.Trade;
|
||||
|
||||
public class SimpleTradeTaskletTests extends TestCase {
|
||||
|
||||
private boolean inputCalled = false;
|
||||
private boolean writerCalled = false;
|
||||
|
||||
public void testReadAndProcess() throws Exception {
|
||||
|
||||
//create input
|
||||
FlatFileItemReader input = new FlatFileItemReader() {
|
||||
|
||||
private boolean done = false;
|
||||
|
||||
public Object read() {
|
||||
if (!done) {
|
||||
Trade trade = new Trade("1234", 5, new BigDecimal(100), "testName");
|
||||
inputCalled = true;
|
||||
done = true;
|
||||
return trade;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
//create writer
|
||||
TradeDao dao = new TradeDao() {
|
||||
public void writeTrade(Trade trade) {
|
||||
assertEquals("1234",trade.getIsin());
|
||||
assertEquals(5, trade.getQuantity());
|
||||
assertEquals(new BigDecimal(100), trade.getPrice());
|
||||
assertEquals("testName", trade.getCustomer());
|
||||
writerCalled = true;
|
||||
}
|
||||
};
|
||||
|
||||
//create module
|
||||
SimpleTradeWriter module = new SimpleTradeWriter();
|
||||
module.setTradeDao(dao);
|
||||
|
||||
module.write(input.read());
|
||||
|
||||
//verify whether input and writer were called
|
||||
assertTrue(inputCalled);
|
||||
assertTrue(writerCalled);
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user