/*
 * Copyright 2014 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 de.codecentric.batch.test;

import static org.junit.Assert.assertEquals;

import java.io.File;

import org.apache.commons.io.FileUtils;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.batch.core.BatchStatus;
import org.springframework.batch.core.JobParameters;
import org.springframework.batch.core.launch.JobOperator;
import org.springframework.batch.core.repository.JobRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import de.codecentric.batch.TestConfiguration;

@ContextConfiguration(classes = { TestConfiguration.class })
@RunWith(SpringJUnit4ClassRunner.class)
public class FlatFileJobTest {

	@Autowired
	private JobOperator jobOperator;

	@Autowired
	private JobRepository jobRepository;

	@Test
	public void runJavaConfigJob() throws Exception {
		File file = new File("target/out-javaconfig.txt");
		file.delete();
		jobOperator.start("flatFileJob", "");
		while (jobRepository.getLastJobExecution("flatFileJob", new JobParameters()).getStatus().isRunning()) {
			Thread.sleep(100);
		}
		assertEquals(BatchStatus.COMPLETED, jobRepository.getLastJobExecution("flatFileJob", new JobParameters()).getStatus());
		assertEquals(3, FileUtils.readLines(file).size());
	}

	@Test
	public void runXmlJob() throws Exception {
		File file = new File("target/out-xmlconfig.txt");
		file.delete();
		jobOperator.start("flatFileJobXml", "");
		while (jobRepository.getLastJobExecution("flatFileJobXml", new JobParameters()).getStatus().isRunning()) {
			Thread.sleep(100);
		}
		assertEquals(BatchStatus.COMPLETED, jobRepository.getLastJobExecution("flatFileJobXml", new JobParameters()).getStatus());
		assertEquals(10, FileUtils.readLines(file).size());
	}

}

@@ -1130,28 +1130,35 @@
 ork.
-test.context.Context
+boot.test.SpringApplication
 Conf
@@ -1294,15 +1294,25 @@
 ;%0A%0A@
-Context
+SpringApplication
 Conf
@@ -1332,13 +1332,9 @@
 sses
- = %7B 
+=
 Test
@@ -1356,10 +1356,8 @@
 lass
- %7D
 )%0A@R

Move completely to @SpringApplicationConfiguration in Tests