001/* 002 * Copyright 2012-2018 the original author or authors. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 017package org.springframework.boot.test.context.runner; 018 019import java.util.List; 020import java.util.function.Supplier; 021 022import org.springframework.boot.context.annotation.Configurations; 023import org.springframework.boot.test.context.assertj.AssertableReactiveWebApplicationContext; 024import org.springframework.boot.test.util.TestPropertyValues; 025import org.springframework.boot.web.reactive.context.AnnotationConfigReactiveWebApplicationContext; 026import org.springframework.boot.web.reactive.context.ConfigurableReactiveWebApplicationContext; 027import org.springframework.context.ApplicationContext; 028import org.springframework.context.ApplicationContextInitializer; 029 030/** 031 * An {@link AbstractApplicationContextRunner ApplicationContext runner} for a 032 * {@link ConfigurableReactiveWebApplicationContext}. 033 * <p> 034 * See {@link AbstractApplicationContextRunner} for details. 035 * 036 * @author Andy Wilkinson 037 * @author Stephane Nicoll 038 * @author Phillip Webb 039 * @since 2.0.0 040 */ 041public final class ReactiveWebApplicationContextRunner extends 042 AbstractApplicationContextRunner<ReactiveWebApplicationContextRunner, ConfigurableReactiveWebApplicationContext, AssertableReactiveWebApplicationContext> { 043 044 /** 045 * Create a new {@link ReactiveWebApplicationContextRunner} instance using a 046 * {@link AnnotationConfigReactiveWebApplicationContext} as the underlying source. 047 */ 048 public ReactiveWebApplicationContextRunner() { 049 this(AnnotationConfigReactiveWebApplicationContext::new); 050 } 051 052 /** 053 * Create a new {@link ApplicationContextRunner} instance using the specified 054 * {@code contextFactory} as the underlying source. 055 * @param contextFactory a supplier that returns a new instance on each call 056 */ 057 public ReactiveWebApplicationContextRunner( 058 Supplier<ConfigurableReactiveWebApplicationContext> contextFactory) { 059 super(contextFactory); 060 } 061 062 private ReactiveWebApplicationContextRunner( 063 Supplier<ConfigurableReactiveWebApplicationContext> contextFactory, 064 List<ApplicationContextInitializer<? super ConfigurableReactiveWebApplicationContext>> initializers, 065 TestPropertyValues environmentProperties, TestPropertyValues systemProperties, 066 ClassLoader classLoader, ApplicationContext parent, 067 List<Configurations> configurations) { 068 super(contextFactory, initializers, environmentProperties, systemProperties, 069 classLoader, parent, configurations); 070 } 071 072 @Override 073 protected ReactiveWebApplicationContextRunner newInstance( 074 Supplier<ConfigurableReactiveWebApplicationContext> contextFactory, 075 List<ApplicationContextInitializer<? super ConfigurableReactiveWebApplicationContext>> initializers, 076 TestPropertyValues environmentProperties, TestPropertyValues systemProperties, 077 ClassLoader classLoader, ApplicationContext parent, 078 List<Configurations> configurations) { 079 return new ReactiveWebApplicationContextRunner(contextFactory, initializers, 080 environmentProperties, systemProperties, classLoader, parent, 081 configurations); 082 } 083 084}