Removal of redundant JdkVersion checks in the test suite

Issue: SPR-13312
This commit is contained in:
Juergen Hoeller
2015-08-12 18:42:36 +02:00
parent 6e1567b4b0
commit e0f012f32d
8 changed files with 69 additions and 96 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2014 the original author or authors.
* Copyright 2002-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.
@@ -25,7 +25,6 @@ import java.math.BigDecimal;
import org.junit.Test;
import org.springframework.core.JdkVersion;
import org.springframework.tests.sample.beans.TestBean;
import static org.hamcrest.CoreMatchers.equalTo;
@@ -138,7 +137,7 @@ public class ExtendedBeanInfoTests {
assertThat(hasReadMethodForProperty(bi, "foo"), is(true));
assertThat(hasWriteMethodForProperty(bi, "foo"), is(false));
assertThat(hasIndexedWriteMethodForProperty(bi, "foo"), is(trueUntilJdk17()));
assertThat(hasIndexedWriteMethodForProperty(bi, "foo"), is(false));
BeanInfo ebi = new ExtendedBeanInfo(bi);
@@ -484,7 +483,7 @@ public class ExtendedBeanInfoTests {
assertThat(hasIndexedReadMethodForProperty(bi, "foos"), is(true));
// interesting! standard Inspector picks up non-void return types on indexed write methods by default
assertThat(hasIndexedWriteMethodForProperty(bi, "foos"), is(trueUntilJdk17()));
assertThat(hasIndexedWriteMethodForProperty(bi, "foos"), is(false));
BeanInfo ebi = new ExtendedBeanInfo(Introspector.getBeanInfo(C.class));
@@ -509,13 +508,13 @@ public class ExtendedBeanInfoTests {
assertThat(hasIndexedReadMethodForProperty(bi, "foos"), is(true));
assertThat(hasWriteMethodForProperty(bi, "foos"), is(false));
// again as above, standard Inspector picks up non-void return types on indexed write methods by default
assertThat(hasIndexedWriteMethodForProperty(bi, "foos"), is(trueUntilJdk17()));
assertThat(hasIndexedWriteMethodForProperty(bi, "foos"), is(false));
BeanInfo ebi = new ExtendedBeanInfo(Introspector.getBeanInfo(C.class));
assertThat(hasIndexedReadMethodForProperty(bi, "foos"), is(true));
assertThat(hasWriteMethodForProperty(bi, "foos"), is(false));
assertThat(hasIndexedWriteMethodForProperty(bi, "foos"), is(trueUntilJdk17()));
assertThat(hasIndexedWriteMethodForProperty(bi, "foos"), is(false));
assertThat(hasIndexedReadMethodForProperty(ebi, "foos"), is(true));
assertThat(hasWriteMethodForProperty(ebi, "foos"), is(true));
@@ -719,19 +718,19 @@ public class ExtendedBeanInfoTests {
assertThat(hasReadMethodForProperty(bi, "dateFormat"), is(false));
assertThat(hasWriteMethodForProperty(bi, "dateFormat"), is(false));
assertThat(hasIndexedReadMethodForProperty(bi, "dateFormat"), is(false));
assertThat(hasIndexedWriteMethodForProperty(bi, "dateFormat"), is(trueUntilJdk17()));
assertThat(hasIndexedWriteMethodForProperty(bi, "dateFormat"), is(false));
BeanInfo ebi = new ExtendedBeanInfo(bi);
assertThat(hasReadMethodForProperty(bi, "dateFormat"), is(false));
assertThat(hasWriteMethodForProperty(bi, "dateFormat"), is(false));
assertThat(hasIndexedReadMethodForProperty(bi, "dateFormat"), is(false));
assertThat(hasIndexedWriteMethodForProperty(bi, "dateFormat"), is(trueUntilJdk17()));
assertThat(hasIndexedWriteMethodForProperty(bi, "dateFormat"), is(false));
assertThat(hasReadMethodForProperty(ebi, "dateFormat"), is(false));
assertThat(hasWriteMethodForProperty(ebi, "dateFormat"), is(true));
assertThat(hasIndexedReadMethodForProperty(ebi, "dateFormat"), is(false));
assertThat(hasIndexedWriteMethodForProperty(ebi, "dateFormat"), is(trueUntilJdk17()));
assertThat(hasIndexedWriteMethodForProperty(ebi, "dateFormat"), is(false));
}
@Test
@@ -928,10 +927,6 @@ public class ExtendedBeanInfoTests {
return false;
}
private boolean trueUntilJdk17() {
return JdkVersion.getMajorJavaVersion() < JdkVersion.JAVA_17;
}
interface Spr9453<T> {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2007 the original author or authors.
* Copyright 2002-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.
@@ -24,7 +24,6 @@ import org.junit.Test;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.support.RootBeanDefinition;
import org.springframework.core.JdkVersion;
import static org.junit.Assert.*;
@@ -36,8 +35,7 @@ public class ServiceLoaderTests {
@Test
public void testServiceLoaderFactoryBean() {
if (JdkVersion.getMajorJavaVersion() < JdkVersion.JAVA_16 ||
!ServiceLoader.load(DocumentBuilderFactory.class).iterator().hasNext()){
if (!ServiceLoader.load(DocumentBuilderFactory.class).iterator().hasNext()){
return;
}
@@ -51,8 +49,7 @@ public class ServiceLoaderTests {
@Test
public void testServiceFactoryBean() {
if (JdkVersion.getMajorJavaVersion() < JdkVersion.JAVA_16 ||
!ServiceLoader.load(DocumentBuilderFactory.class).iterator().hasNext()){
if (!ServiceLoader.load(DocumentBuilderFactory.class).iterator().hasNext()){
return;
}
@@ -65,8 +62,7 @@ public class ServiceLoaderTests {
@Test
public void testServiceListFactoryBean() {
if (JdkVersion.getMajorJavaVersion() < JdkVersion.JAVA_16 ||
!ServiceLoader.load(DocumentBuilderFactory.class).iterator().hasNext()){
if (!ServiceLoader.load(DocumentBuilderFactory.class).iterator().hasNext()){
return;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-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.
@@ -20,20 +20,22 @@ import java.beans.IntrospectionException;
import java.beans.PropertyDescriptor;
import java.beans.SimpleBeanInfo;
import junit.framework.TestCase;
import org.junit.Test;
import org.springframework.beans.BeanWrapper;
import org.springframework.beans.BeanWrapperImpl;
import org.springframework.beans.FatalBeanException;
import org.springframework.core.JdkVersion;
import org.springframework.util.Assert;
import static org.junit.Assert.*;
/**
* @author Juergen Hoeller
* @since 06.03.2006
*/
public class BeanInfoTests extends TestCase {
public class BeanInfoTests {
@Test
public void testComplexObject() {
ValueBean bean = new ValueBean();
BeanWrapper bw = new BeanWrapperImpl(bean);
@@ -99,9 +101,7 @@ public class BeanInfoTests extends TestCase {
@Override
public void setAsText(String text) throws IllegalArgumentException {
if (JdkVersion.getMajorJavaVersion() >= JdkVersion.JAVA_15) {
Assert.isTrue(this.target instanceof ValueBean, "Target must be available on JDK 1.5+");
}
Assert.isTrue(this.target instanceof ValueBean, "Target must be available");
super.setAsText(text);
}