/*
 * Copyright 2011-2015 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.rahn.finances.services.config;

import static org.hamcrest.Matchers.notNullValue;
import static org.junit.Assert.assertThat;
import static org.springframework.boot.SpringApplication.run;
import static org.springframework.boot.context.properties.ConfigurationPropertiesBindingPostProcessor.VALIDATOR_BEAN_NAME;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.test.SpringApplicationConfiguration;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Import;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.validation.Errors;
import org.springframework.validation.Validator;

import de.rahn.finances.services.SecuritiesService;
import de.rahn.finances.services.config.ServicesConfigurationTest.Appication;

/**
 * Test der Spring Configuration.
 * 
 * @author Frank W. Rahn
 */
@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = Appication.class)
public class ServicesConfigurationTest {

	@SpringBootApplication
	@Import(ServicesConfiguration.class)
	static class Appication {
		public static void main(String[] args) throws Exception {
			run(Appication.class, args);
		}

		/**
		 * @return eine NO_OPT {@link Validator}
		 */
		@Bean(name = VALIDATOR_BEAN_NAME)
		public Validator validator() {
			return new Validator() {

				/**
				 * {@inheritDoc}
				 * 
				 * @see Validator#validate(Object, Errors)
				 */
				@Override
				public void validate(Object target, Errors errors) {
					// Leer
				}

				/**
				 * {@inheritDoc}
				 * 
				 * @see Validator#supports(Class)
				 */
				@Override
				public boolean supports(Class<?> clazz) {
					return false;
				}
			};
		}
	}

	@Autowired
	private SecuritiesService service;

	/**
	 * Test, ob ein {@link ApplicationContext} erstellt werden kann.
	 */
	@Test
	public void testSpringConfiguration() {
		assertThat(service, notNullValue());
	}

}
@@ -1569,16 +1569,76 @@
 ervice;%0A
+import de.rahn.finances.services.SecurityNotFoundException;%0A
 import d
@@ -1707,16 +1707,16 @@
 cation;%0A
-
 %0A/**%0A * 
@@ -1748,17 +1748,16 @@
 tion.%0A *
- 
 %0A * @aut
@@ -2286,33 +2286,32 @@
 heritDoc%7D%0A%09%09%09%09 *
- 
 %0A%09%09%09%09 * @see Val
@@ -2476,17 +2476,16 @@
 %7D%0A%09%09%09%09 *
- 
 %0A%09%09%09%09 * 
@@ -2753,16 +2753,60 @@
 /%0A%09@Test
+(expected = SecurityNotFoundException.class)
 %0A%09public
@@ -2834,16 +2834,19 @@
 guration
+_01
 () %7B%0A%09%09a
@@ -2880,14 +2880,46 @@
 alue());
+%0A%0A%09%09service.getSecurity(%224711%22);
 %0A%09%7D%0A%0A%7D

Test verbessert