Merge branch '2.7.x'
This commit is contained in:
		
						commit
						a1b1377733
					
				| 
						 | 
				
			
			@ -35,6 +35,7 @@ import de.flapdoodle.embed.process.config.store.DownloadConfig;
 | 
			
		|||
import org.bson.Document;
 | 
			
		||||
import org.junit.jupiter.api.AfterEach;
 | 
			
		||||
import org.junit.jupiter.api.Test;
 | 
			
		||||
import org.junit.jupiter.api.condition.OS;
 | 
			
		||||
import org.junit.jupiter.api.io.TempDir;
 | 
			
		||||
 | 
			
		||||
import org.springframework.beans.DirectFieldAccessor;
 | 
			
		||||
| 
						 | 
				
			
			@ -44,6 +45,7 @@ import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoCon
 | 
			
		|||
import org.springframework.boot.autoconfigure.data.mongo.MongoDataAutoConfiguration;
 | 
			
		||||
import org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration;
 | 
			
		||||
import org.springframework.boot.test.util.TestPropertyValues;
 | 
			
		||||
import org.springframework.boot.testsupport.junit.DisabledOnOs;
 | 
			
		||||
import org.springframework.context.ConfigurableApplicationContext;
 | 
			
		||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
 | 
			
		||||
import org.springframework.context.annotation.Bean;
 | 
			
		||||
| 
						 | 
				
			
			@ -63,6 +65,9 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy;
 | 
			
		|||
 * @author Issam El-atif
 | 
			
		||||
 * @author Chris Bono
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
@DisabledOnOs(os = OS.LINUX, architecture = "aarch64",
 | 
			
		||||
		disabledReason = "Embedded Mongo doesn't support Linux aarch64, see https://github.com/flapdoodle-oss/de.flapdoodle.embed.mongo/issues/379")
 | 
			
		||||
class EmbeddedMongoAutoConfigurationTests {
 | 
			
		||||
 | 
			
		||||
	private AnnotationConfigApplicationContext context;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -0,0 +1,59 @@
 | 
			
		|||
/*
 | 
			
		||||
 * Copyright 2012-2022 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
 | 
			
		||||
 *
 | 
			
		||||
 *      https://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.boot.testsupport.junit;
 | 
			
		||||
 | 
			
		||||
import java.lang.annotation.ElementType;
 | 
			
		||||
import java.lang.annotation.Repeatable;
 | 
			
		||||
import java.lang.annotation.Retention;
 | 
			
		||||
import java.lang.annotation.RetentionPolicy;
 | 
			
		||||
import java.lang.annotation.Target;
 | 
			
		||||
 | 
			
		||||
import org.junit.jupiter.api.condition.OS;
 | 
			
		||||
import org.junit.jupiter.api.extension.ExtendWith;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Improves JUnit5's {@link org.junit.jupiter.api.condition.DisabledOnOs} by adding an
 | 
			
		||||
 * architecture check and making it repeatable.
 | 
			
		||||
 *
 | 
			
		||||
 * @author Moritz Halbritter
 | 
			
		||||
 * @since 2.5.11
 | 
			
		||||
 */
 | 
			
		||||
@Target({ ElementType.TYPE, ElementType.METHOD })
 | 
			
		||||
@Retention(RetentionPolicy.RUNTIME)
 | 
			
		||||
@ExtendWith(DisabledOnOsCondition.class)
 | 
			
		||||
@Repeatable(DisabledOnOsRepeatable.class)
 | 
			
		||||
public @interface DisabledOnOs {
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * See {@link org.junit.jupiter.api.condition.DisabledOnOs#value()}.
 | 
			
		||||
	 * @return os
 | 
			
		||||
	 */
 | 
			
		||||
	OS os();
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Architecture of the operating system.
 | 
			
		||||
	 * @return architecture
 | 
			
		||||
	 */
 | 
			
		||||
	String architecture();
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * See {@link org.junit.jupiter.api.condition.DisabledOnOs#disabledReason()}.
 | 
			
		||||
	 * @return disabled reason
 | 
			
		||||
	 */
 | 
			
		||||
	String disabledReason() default "";
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,58 @@
 | 
			
		|||
/*
 | 
			
		||||
 * Copyright 2012-2022 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
 | 
			
		||||
 *
 | 
			
		||||
 *      https://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.boot.testsupport.junit;
 | 
			
		||||
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
import org.junit.jupiter.api.extension.ConditionEvaluationResult;
 | 
			
		||||
import org.junit.jupiter.api.extension.ExecutionCondition;
 | 
			
		||||
import org.junit.jupiter.api.extension.ExtensionContext;
 | 
			
		||||
import org.junit.platform.commons.util.AnnotationUtils;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Evaluates {@link DisabledOnOs}.
 | 
			
		||||
 *
 | 
			
		||||
 * @author Moritz Halbritter
 | 
			
		||||
 */
 | 
			
		||||
class DisabledOnOsCondition implements ExecutionCondition {
 | 
			
		||||
 | 
			
		||||
	@Override
 | 
			
		||||
	public ConditionEvaluationResult evaluateExecutionCondition(ExtensionContext context) {
 | 
			
		||||
		List<DisabledOnOs> annotations = AnnotationUtils.findRepeatableAnnotations(context.getElement(),
 | 
			
		||||
				DisabledOnOs.class);
 | 
			
		||||
		if (annotations.isEmpty()) {
 | 
			
		||||
			return ConditionEvaluationResult.enabled("No @DisabledOnOs found");
 | 
			
		||||
		}
 | 
			
		||||
		return evaluate(annotations);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	private ConditionEvaluationResult evaluate(List<DisabledOnOs> annotations) {
 | 
			
		||||
		String architecture = System.getProperty("os.arch");
 | 
			
		||||
		String os = System.getProperty("os.name");
 | 
			
		||||
		for (DisabledOnOs annotation : annotations) {
 | 
			
		||||
			if (annotation.os().isCurrentOs() && annotation.architecture().equals(architecture)) {
 | 
			
		||||
				String reason = annotation.disabledReason().isEmpty()
 | 
			
		||||
						? String.format("Disabled on OS = %s, architecture = %s", os, architecture)
 | 
			
		||||
						: annotation.disabledReason();
 | 
			
		||||
				return ConditionEvaluationResult.disabled(reason);
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		return ConditionEvaluationResult
 | 
			
		||||
				.enabled(String.format("Enabled on OS = %s, architecture = %s", os, architecture));
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,39 @@
 | 
			
		|||
/*
 | 
			
		||||
 * Copyright 2012-2022 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
 | 
			
		||||
 *
 | 
			
		||||
 *      https://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.boot.testsupport.junit;
 | 
			
		||||
 | 
			
		||||
import java.lang.annotation.ElementType;
 | 
			
		||||
import java.lang.annotation.Retention;
 | 
			
		||||
import java.lang.annotation.RetentionPolicy;
 | 
			
		||||
import java.lang.annotation.Target;
 | 
			
		||||
 | 
			
		||||
import org.junit.jupiter.api.extension.ExtendWith;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Repeatable container for {@link DisabledOnOs}.
 | 
			
		||||
 *
 | 
			
		||||
 * @author Moritz Halbritter
 | 
			
		||||
 * @since 2.5.10
 | 
			
		||||
 */
 | 
			
		||||
@Target({ ElementType.TYPE, ElementType.METHOD })
 | 
			
		||||
@Retention(RetentionPolicy.RUNTIME)
 | 
			
		||||
@ExtendWith(DisabledOnOsCondition.class)
 | 
			
		||||
public @interface DisabledOnOsRepeatable {
 | 
			
		||||
 | 
			
		||||
	DisabledOnOs[] value();
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
/*
 | 
			
		||||
 * Copyright 2012-2019 the original author or authors.
 | 
			
		||||
 * Copyright 2012-2022 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.
 | 
			
		||||
| 
						 | 
				
			
			@ -28,7 +28,9 @@ import org.eclipse.jetty.server.Server;
 | 
			
		|||
import org.eclipse.jetty.server.SslConnectionFactory;
 | 
			
		||||
import org.eclipse.jetty.util.ssl.SslContextFactory;
 | 
			
		||||
import org.junit.jupiter.api.Test;
 | 
			
		||||
import org.junit.jupiter.api.condition.OS;
 | 
			
		||||
 | 
			
		||||
import org.springframework.boot.testsupport.junit.DisabledOnOs;
 | 
			
		||||
import org.springframework.boot.web.server.Http2;
 | 
			
		||||
import org.springframework.boot.web.server.Ssl;
 | 
			
		||||
import org.springframework.boot.web.server.WebServerException;
 | 
			
		||||
| 
						 | 
				
			
			@ -55,6 +57,8 @@ class SslServerCustomizerTests {
 | 
			
		|||
 | 
			
		||||
	@Test
 | 
			
		||||
	@SuppressWarnings("rawtypes")
 | 
			
		||||
	@DisabledOnOs(os = OS.LINUX, architecture = "aarch64",
 | 
			
		||||
			disabledReason = "conscrypt doesn't support Linux aarch64, see https://github.com/google/conscrypt/issues/1051")
 | 
			
		||||
	void whenHttp2IsEnabledServerConnectorsHasSslAlpnH2AndHttpConnectionFactories() {
 | 
			
		||||
		Http2 http2 = new Http2();
 | 
			
		||||
		http2.setEnabled(true);
 | 
			
		||||
| 
						 | 
				
			
			@ -67,6 +71,8 @@ class SslServerCustomizerTests {
 | 
			
		|||
	}
 | 
			
		||||
 | 
			
		||||
	@Test
 | 
			
		||||
	@DisabledOnOs(os = OS.LINUX, architecture = "aarch64",
 | 
			
		||||
			disabledReason = "conscrypt doesn't support Linux aarch64, see https://github.com/google/conscrypt/issues/1051")
 | 
			
		||||
	void alpnConnectionFactoryHasNullDefaultProtocolToAllowNegotiationToHttp11() {
 | 
			
		||||
		Http2 http2 = new Http2();
 | 
			
		||||
		http2.setEnabled(true);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue