Migrate JUnit 3 tests to JUnit 4
This commit migrates all remaining tests from JUnit 3 to JUnit 4, with the exception of Spring's legacy JUnit 3.8 based testing framework that is still in use in the spring-orm module. Issue: SPR-13514
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 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.
|
||||
@@ -18,18 +18,21 @@ package org.springframework.beans.factory.support;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
import org.springframework.tests.sample.beans.TestBean;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* @author Rod Johnson
|
||||
* @author Juergen Hoeller
|
||||
*/
|
||||
public class BeanDefinitionBuilderTests extends TestCase {
|
||||
public class BeanDefinitionBuilderTests {
|
||||
|
||||
public void testBeanClassWithSimpleProperty() {
|
||||
@Test
|
||||
public void beanClassWithSimpleProperty() {
|
||||
String[] dependsOn = new String[] { "A", "B", "C" };
|
||||
BeanDefinitionBuilder bdb = BeanDefinitionBuilder.rootBeanDefinition(TestBean.class);
|
||||
bdb.setScope(BeanDefinition.SCOPE_PROTOTYPE);
|
||||
@@ -45,7 +48,8 @@ public class BeanDefinitionBuilderTests extends TestCase {
|
||||
assertTrue(rbd.getPropertyValues().contains("age"));
|
||||
}
|
||||
|
||||
public void testBeanClassWithFactoryMethod() {
|
||||
@Test
|
||||
public void beanClassWithFactoryMethod() {
|
||||
BeanDefinitionBuilder bdb = BeanDefinitionBuilder.rootBeanDefinition(TestBean.class, "create");
|
||||
RootBeanDefinition rbd = (RootBeanDefinition) bdb.getBeanDefinition();
|
||||
assertTrue(rbd.hasBeanClass());
|
||||
@@ -53,14 +57,16 @@ public class BeanDefinitionBuilderTests extends TestCase {
|
||||
assertEquals("create", rbd.getFactoryMethodName());
|
||||
}
|
||||
|
||||
public void testBeanClassName() {
|
||||
@Test
|
||||
public void beanClassName() {
|
||||
BeanDefinitionBuilder bdb = BeanDefinitionBuilder.rootBeanDefinition(TestBean.class.getName());
|
||||
RootBeanDefinition rbd = (RootBeanDefinition) bdb.getBeanDefinition();
|
||||
assertFalse(rbd.hasBeanClass());
|
||||
assertEquals(TestBean.class.getName(), rbd.getBeanClassName());
|
||||
}
|
||||
|
||||
public void testBeanClassNameWithFactoryMethod() {
|
||||
@Test
|
||||
public void beanClassNameWithFactoryMethod() {
|
||||
BeanDefinitionBuilder bdb = BeanDefinitionBuilder.rootBeanDefinition(TestBean.class.getName(), "create");
|
||||
RootBeanDefinition rbd = (RootBeanDefinition) bdb.getBeanDefinition();
|
||||
assertFalse(rbd.hasBeanClass());
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 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.
|
||||
@@ -16,18 +16,20 @@
|
||||
|
||||
package org.springframework.beans.factory.support;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
import org.springframework.beans.factory.config.BeanDefinitionHolder;
|
||||
import org.springframework.tests.sample.beans.TestBean;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* @author Juergen Hoeller
|
||||
*/
|
||||
public class BeanDefinitionTests extends TestCase {
|
||||
public class BeanDefinitionTests {
|
||||
|
||||
public void testBeanDefinitionEquality() {
|
||||
@Test
|
||||
public void beanDefinitionEquality() {
|
||||
RootBeanDefinition bd = new RootBeanDefinition(TestBean.class);
|
||||
bd.setAbstract(true);
|
||||
bd.setLazyInit(true);
|
||||
@@ -43,7 +45,8 @@ public class BeanDefinitionTests extends TestCase {
|
||||
assertTrue(bd.hashCode() == otherBd.hashCode());
|
||||
}
|
||||
|
||||
public void testBeanDefinitionEqualityWithPropertyValues() {
|
||||
@Test
|
||||
public void beanDefinitionEqualityWithPropertyValues() {
|
||||
RootBeanDefinition bd = new RootBeanDefinition(TestBean.class);
|
||||
bd.getPropertyValues().add("name", "myName");
|
||||
bd.getPropertyValues().add("age", "99");
|
||||
@@ -60,7 +63,8 @@ public class BeanDefinitionTests extends TestCase {
|
||||
assertTrue(bd.hashCode() == otherBd.hashCode());
|
||||
}
|
||||
|
||||
public void testBeanDefinitionEqualityWithConstructorArguments() {
|
||||
@Test
|
||||
public void beanDefinitionEqualityWithConstructorArguments() {
|
||||
RootBeanDefinition bd = new RootBeanDefinition(TestBean.class);
|
||||
bd.getConstructorArgumentValues().addGenericArgumentValue("test");
|
||||
bd.getConstructorArgumentValues().addIndexedArgumentValue(1, new Integer(5));
|
||||
@@ -77,7 +81,8 @@ public class BeanDefinitionTests extends TestCase {
|
||||
assertTrue(bd.hashCode() == otherBd.hashCode());
|
||||
}
|
||||
|
||||
public void testBeanDefinitionEqualityWithTypedConstructorArguments() {
|
||||
@Test
|
||||
public void beanDefinitionEqualityWithTypedConstructorArguments() {
|
||||
RootBeanDefinition bd = new RootBeanDefinition(TestBean.class);
|
||||
bd.getConstructorArgumentValues().addGenericArgumentValue("test", "int");
|
||||
bd.getConstructorArgumentValues().addIndexedArgumentValue(1, new Integer(5), "long");
|
||||
@@ -95,7 +100,8 @@ public class BeanDefinitionTests extends TestCase {
|
||||
assertTrue(bd.hashCode() == otherBd.hashCode());
|
||||
}
|
||||
|
||||
public void testBeanDefinitionHolderEquality() {
|
||||
@Test
|
||||
public void beanDefinitionHolderEquality() {
|
||||
RootBeanDefinition bd = new RootBeanDefinition(TestBean.class);
|
||||
bd.setAbstract(true);
|
||||
bd.setLazyInit(true);
|
||||
@@ -113,7 +119,8 @@ public class BeanDefinitionTests extends TestCase {
|
||||
assertTrue(holder.hashCode() == otherHolder.hashCode());
|
||||
}
|
||||
|
||||
public void testBeanDefinitionMerging() {
|
||||
@Test
|
||||
public void beanDefinitionMerging() {
|
||||
RootBeanDefinition bd = new RootBeanDefinition(TestBean.class);
|
||||
bd.getConstructorArgumentValues().addGenericArgumentValue("test");
|
||||
bd.getConstructorArgumentValues().addIndexedArgumentValue(1, new Integer(5));
|
||||
@@ -124,7 +131,7 @@ public class BeanDefinitionTests extends TestCase {
|
||||
childBd.setParentName("bd");
|
||||
|
||||
RootBeanDefinition mergedBd = new RootBeanDefinition(bd);
|
||||
mergedBd.overrideFrom((BeanDefinition) childBd);
|
||||
mergedBd.overrideFrom(childBd);
|
||||
assertEquals(2, mergedBd.getConstructorArgumentValues().getArgumentCount());
|
||||
assertEquals(2, mergedBd.getPropertyValues().size());
|
||||
assertEquals(bd, mergedBd);
|
||||
|
||||
@@ -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.
|
||||
@@ -18,15 +18,20 @@ package org.springframework.beans.factory.support;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* @author Rick Evans
|
||||
* @author Juergen Hoeller
|
||||
* @author Sam Brannen
|
||||
*/
|
||||
public class ManagedListTests extends TestCase {
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
public class ManagedListTests {
|
||||
|
||||
public void testMergeSunnyDay() {
|
||||
@Test
|
||||
public void mergeSunnyDay() {
|
||||
ManagedList parent = new ManagedList();
|
||||
parent.add("one");
|
||||
parent.add("two");
|
||||
@@ -37,36 +42,30 @@ public class ManagedListTests extends TestCase {
|
||||
assertEquals("merge() obviously did not work.", 3, mergedList.size());
|
||||
}
|
||||
|
||||
public void testMergeWithNullParent() {
|
||||
@Test
|
||||
public void mergeWithNullParent() {
|
||||
ManagedList child = new ManagedList();
|
||||
child.add("one");
|
||||
child.setMergeEnabled(true);
|
||||
assertSame(child, child.merge(null));
|
||||
}
|
||||
|
||||
public void testMergeNotAllowedWhenMergeNotEnabled() {
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void mergeNotAllowedWhenMergeNotEnabled() {
|
||||
ManagedList child = new ManagedList();
|
||||
try {
|
||||
child.merge(null);
|
||||
fail("Must have failed by this point (cannot merge() when the mergeEnabled property is false.");
|
||||
}
|
||||
catch (IllegalStateException expected) {
|
||||
}
|
||||
child.merge(null);
|
||||
}
|
||||
|
||||
public void testMergeWithNonCompatibleParentType() {
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void mergeWithNonCompatibleParentType() {
|
||||
ManagedList child = new ManagedList();
|
||||
child.add("one");
|
||||
child.setMergeEnabled(true);
|
||||
try {
|
||||
child.merge("hello");
|
||||
fail("Must have failed by this point.");
|
||||
}
|
||||
catch (IllegalArgumentException expected) {
|
||||
}
|
||||
child.merge("hello");
|
||||
}
|
||||
|
||||
public void testMergeEmptyChild() {
|
||||
@Test
|
||||
public void mergeEmptyChild() {
|
||||
ManagedList parent = new ManagedList();
|
||||
parent.add("one");
|
||||
parent.add("two");
|
||||
@@ -76,8 +75,9 @@ public class ManagedListTests extends TestCase {
|
||||
assertEquals("merge() obviously did not work.", 2, mergedList.size());
|
||||
}
|
||||
|
||||
public void testMergeChildValuesOverrideTheParents() {
|
||||
// doesn't make a whole lotta sense in the context of a list...
|
||||
@Test
|
||||
public void mergeChildValuesOverrideTheParents() {
|
||||
// doesn't make much sense in the context of a list...
|
||||
ManagedList parent = new ManagedList();
|
||||
parent.add("one");
|
||||
parent.add("two");
|
||||
|
||||
@@ -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.
|
||||
@@ -18,15 +18,20 @@ package org.springframework.beans.factory.support;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* @author Rick Evans
|
||||
* @author Juergen Hoeller
|
||||
* @author Sam Brannen
|
||||
*/
|
||||
public class ManagedMapTests extends TestCase {
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
public class ManagedMapTests {
|
||||
|
||||
public void testMergeSunnyDay() {
|
||||
@Test
|
||||
public void mergeSunnyDay() {
|
||||
ManagedMap parent = new ManagedMap();
|
||||
parent.put("one", "one");
|
||||
parent.put("two", "two");
|
||||
@@ -37,34 +42,27 @@ public class ManagedMapTests extends TestCase {
|
||||
assertEquals("merge() obviously did not work.", 3, mergedMap.size());
|
||||
}
|
||||
|
||||
public void testMergeWithNullParent() {
|
||||
@Test
|
||||
public void mergeWithNullParent() {
|
||||
ManagedMap child = new ManagedMap();
|
||||
child.setMergeEnabled(true);
|
||||
assertSame(child, child.merge(null));
|
||||
}
|
||||
|
||||
public void testMergeWithNonCompatibleParentType() {
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void mergeWithNonCompatibleParentType() {
|
||||
ManagedMap map = new ManagedMap();
|
||||
map.setMergeEnabled(true);
|
||||
try {
|
||||
map.merge("hello");
|
||||
fail("Must have failed by this point.");
|
||||
}
|
||||
catch (IllegalArgumentException expected) {
|
||||
}
|
||||
map.merge("hello");
|
||||
}
|
||||
|
||||
public void testMergeNotAllowedWhenMergeNotEnabled() {
|
||||
ManagedMap map = new ManagedMap();
|
||||
try {
|
||||
map.merge(null);
|
||||
fail("Must have failed by this point (cannot merge() when the mergeEnabled property is false.");
|
||||
}
|
||||
catch (IllegalStateException expected) {
|
||||
}
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void mergeNotAllowedWhenMergeNotEnabled() {
|
||||
new ManagedMap().merge(null);
|
||||
}
|
||||
|
||||
public void testMergeEmptyChild() {
|
||||
@Test
|
||||
public void mergeEmptyChild() {
|
||||
ManagedMap parent = new ManagedMap();
|
||||
parent.put("one", "one");
|
||||
parent.put("two", "two");
|
||||
@@ -74,7 +72,8 @@ public class ManagedMapTests extends TestCase {
|
||||
assertEquals("merge() obviously did not work.", 2, mergedMap.size());
|
||||
}
|
||||
|
||||
public void testMergeChildValuesOverrideTheParents() {
|
||||
@Test
|
||||
public void mergeChildValuesOverrideTheParents() {
|
||||
ManagedMap parent = new ManagedMap();
|
||||
parent.put("one", "one");
|
||||
parent.put("two", "two");
|
||||
|
||||
@@ -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.
|
||||
@@ -18,15 +18,20 @@ package org.springframework.beans.factory.support;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* @author Rick Evans
|
||||
* @author Juergen Hoeller
|
||||
* @author Sam Brannen
|
||||
*/
|
||||
public class ManagedPropertiesTests extends TestCase {
|
||||
@SuppressWarnings("rawtypes")
|
||||
public class ManagedPropertiesTests {
|
||||
|
||||
public void testMergeSunnyDay() {
|
||||
@Test
|
||||
public void mergeSunnyDay() {
|
||||
ManagedProperties parent = new ManagedProperties();
|
||||
parent.setProperty("one", "one");
|
||||
parent.setProperty("two", "two");
|
||||
@@ -37,34 +42,28 @@ public class ManagedPropertiesTests extends TestCase {
|
||||
assertEquals("merge() obviously did not work.", 3, mergedMap.size());
|
||||
}
|
||||
|
||||
public void testMergeWithNullParent() {
|
||||
@Test
|
||||
public void mergeWithNullParent() {
|
||||
ManagedProperties child = new ManagedProperties();
|
||||
child.setMergeEnabled(true);
|
||||
assertSame(child, child.merge(null));
|
||||
}
|
||||
|
||||
public void testMergeWithNonCompatibleParentType() {
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void mergeWithNonCompatibleParentType() {
|
||||
ManagedProperties map = new ManagedProperties();
|
||||
map.setMergeEnabled(true);
|
||||
try {
|
||||
map.merge("hello");
|
||||
fail("Must have failed by this point.");
|
||||
}
|
||||
catch (IllegalArgumentException expected) {
|
||||
}
|
||||
map.merge("hello");
|
||||
}
|
||||
|
||||
public void testMergeNotAllowedWhenMergeNotEnabled() {
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void mergeNotAllowedWhenMergeNotEnabled() {
|
||||
ManagedProperties map = new ManagedProperties();
|
||||
try {
|
||||
map.merge(null);
|
||||
fail("Must have failed by this point (cannot merge() when the mergeEnabled property is false.");
|
||||
}
|
||||
catch (IllegalStateException expected) {
|
||||
}
|
||||
map.merge(null);
|
||||
}
|
||||
|
||||
public void testMergeEmptyChild() {
|
||||
@Test
|
||||
public void mergeEmptyChild() {
|
||||
ManagedProperties parent = new ManagedProperties();
|
||||
parent.setProperty("one", "one");
|
||||
parent.setProperty("two", "two");
|
||||
@@ -74,7 +73,8 @@ public class ManagedPropertiesTests extends TestCase {
|
||||
assertEquals("merge() obviously did not work.", 2, mergedMap.size());
|
||||
}
|
||||
|
||||
public void testMergeChildValuesOverrideTheParents() {
|
||||
@Test
|
||||
public void mergeChildValuesOverrideTheParents() {
|
||||
ManagedProperties parent = new ManagedProperties();
|
||||
parent.setProperty("one", "one");
|
||||
parent.setProperty("two", "two");
|
||||
|
||||
@@ -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.
|
||||
@@ -18,15 +18,20 @@ package org.springframework.beans.factory.support;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* @author Rick Evans
|
||||
* @author Juergen Hoeller
|
||||
* @author Sam Brannen
|
||||
*/
|
||||
public class ManagedSetTests extends TestCase {
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
public class ManagedSetTests {
|
||||
|
||||
public void testMergeSunnyDay() {
|
||||
@Test
|
||||
public void mergeSunnyDay() {
|
||||
ManagedSet parent = new ManagedSet();
|
||||
parent.add("one");
|
||||
parent.add("two");
|
||||
@@ -37,36 +42,29 @@ public class ManagedSetTests extends TestCase {
|
||||
assertEquals("merge() obviously did not work.", 3, mergedSet.size());
|
||||
}
|
||||
|
||||
public void testMergeWithNullParent() {
|
||||
@Test
|
||||
public void mergeWithNullParent() {
|
||||
ManagedSet child = new ManagedSet();
|
||||
child.add("one");
|
||||
child.setMergeEnabled(true);
|
||||
assertSame(child, child.merge(null));
|
||||
}
|
||||
|
||||
public void testMergeNotAllowedWhenMergeNotEnabled() {
|
||||
ManagedSet child = new ManagedSet();
|
||||
try {
|
||||
child.merge(null);
|
||||
fail("Must have failed by this point (cannot merge() when the mergeEnabled property is false.");
|
||||
}
|
||||
catch (IllegalStateException expected) {
|
||||
}
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void mergeNotAllowedWhenMergeNotEnabled() {
|
||||
new ManagedSet().merge(null);
|
||||
}
|
||||
|
||||
public void testMergeWithNonCompatibleParentType() {
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void mergeWithNonCompatibleParentType() {
|
||||
ManagedSet child = new ManagedSet();
|
||||
child.add("one");
|
||||
child.setMergeEnabled(true);
|
||||
try {
|
||||
child.merge("hello");
|
||||
fail("Must have failed by this point.");
|
||||
}
|
||||
catch (IllegalArgumentException expected) {
|
||||
}
|
||||
child.merge("hello");
|
||||
}
|
||||
|
||||
public void testMergeEmptyChild() {
|
||||
@Test
|
||||
public void mergeEmptyChild() {
|
||||
ManagedSet parent = new ManagedSet();
|
||||
parent.add("one");
|
||||
parent.add("two");
|
||||
@@ -76,7 +74,8 @@ public class ManagedSetTests extends TestCase {
|
||||
assertEquals("merge() obviously did not work.", 2, mergedSet.size());
|
||||
}
|
||||
|
||||
public void testMergeChildValuesOverrideTheParents() {
|
||||
@Test
|
||||
public void mergeChildValuesOverrideTheParents() {
|
||||
// asserts that the set contract is not violated during a merge() operation...
|
||||
ManagedSet parent = new ManagedSet();
|
||||
parent.add("one");
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 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.
|
||||
@@ -16,43 +16,45 @@
|
||||
|
||||
package org.springframework.beans.factory.support;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.tests.sample.beans.TestBean;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* @author Rob Harrop
|
||||
*/
|
||||
public class PropertiesBeanDefinitionReaderTests extends TestCase {
|
||||
public class PropertiesBeanDefinitionReaderTests {
|
||||
|
||||
private DefaultListableBeanFactory beanFactory;
|
||||
private final DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();
|
||||
|
||||
private PropertiesBeanDefinitionReader reader;
|
||||
private final PropertiesBeanDefinitionReader reader = new PropertiesBeanDefinitionReader(
|
||||
beanFactory);
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
this.beanFactory = new DefaultListableBeanFactory();
|
||||
this.reader = new PropertiesBeanDefinitionReader(beanFactory);
|
||||
}
|
||||
|
||||
public void testWithSimpleConstructorArg() {
|
||||
@Test
|
||||
public void withSimpleConstructorArg() {
|
||||
this.reader.loadBeanDefinitions(new ClassPathResource("simpleConstructorArg.properties", getClass()));
|
||||
TestBean bean = (TestBean)this.beanFactory.getBean("testBean");
|
||||
assertEquals("Rob Harrop", bean.getName());
|
||||
}
|
||||
|
||||
public void testWithConstructorArgRef() throws Exception {
|
||||
@Test
|
||||
public void withConstructorArgRef() throws Exception {
|
||||
this.reader.loadBeanDefinitions(new ClassPathResource("refConstructorArg.properties", getClass()));
|
||||
TestBean rob = (TestBean)this.beanFactory.getBean("rob");
|
||||
TestBean sally = (TestBean)this.beanFactory.getBean("sally");
|
||||
assertEquals(sally, rob.getSpouse());
|
||||
}
|
||||
|
||||
public void testWithMultipleConstructorsArgs() throws Exception {
|
||||
@Test
|
||||
public void withMultipleConstructorsArgs() throws Exception {
|
||||
this.reader.loadBeanDefinitions(new ClassPathResource("multiConstructorArgs.properties", getClass()));
|
||||
TestBean bean = (TestBean)this.beanFactory.getBean("testBean");
|
||||
assertEquals("Rob Harrop", bean.getName());
|
||||
assertEquals(23, bean.getAge());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 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.
|
||||
@@ -16,31 +16,30 @@
|
||||
|
||||
package org.springframework.beans.factory.wiring;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
|
||||
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
|
||||
import org.springframework.tests.sample.beans.TestBean;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.mockito.BDDMockito.*;
|
||||
|
||||
/**
|
||||
* @author Rick Evans
|
||||
* @author Juergen Hoeller
|
||||
* @author Sam Brannen
|
||||
*/
|
||||
public class BeanConfigurerSupportTests extends TestCase {
|
||||
public class BeanConfigurerSupportTests {
|
||||
|
||||
public void testSupplyIncompatibleBeanFactoryImplementation() throws Exception {
|
||||
try {
|
||||
new StubBeanConfigurerSupport().setBeanFactory(mock(BeanFactory.class));
|
||||
fail("Must have thrown an IllegalArgumentException by this point (incompatible BeanFactory implementation supplied)");
|
||||
}
|
||||
catch (IllegalArgumentException expected) {
|
||||
}
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void supplyIncompatibleBeanFactoryImplementation() throws Exception {
|
||||
new StubBeanConfigurerSupport().setBeanFactory(mock(BeanFactory.class));
|
||||
}
|
||||
|
||||
public void testConfigureBeanDoesNothingIfBeanWiringInfoResolverResolvesToNull() throws Exception {
|
||||
@Test
|
||||
public void configureBeanDoesNothingIfBeanWiringInfoResolverResolvesToNull() throws Exception {
|
||||
TestBean beanInstance = new TestBean();
|
||||
|
||||
BeanWiringInfoResolver resolver = mock(BeanWiringInfoResolver.class);
|
||||
@@ -53,14 +52,16 @@ public class BeanConfigurerSupportTests extends TestCase {
|
||||
assertNull(beanInstance.getName());
|
||||
}
|
||||
|
||||
public void testConfigureBeanDoesNothingIfNoBeanFactoryHasBeenSet() throws Exception {
|
||||
@Test
|
||||
public void configureBeanDoesNothingIfNoBeanFactoryHasBeenSet() throws Exception {
|
||||
TestBean beanInstance = new TestBean();
|
||||
BeanConfigurerSupport configurer = new StubBeanConfigurerSupport();
|
||||
configurer.configureBean(beanInstance);
|
||||
assertNull(beanInstance.getName());
|
||||
}
|
||||
|
||||
public void testConfigureBeanReallyDoesDefaultToUsingTheFullyQualifiedClassNameOfTheSuppliedBeanInstance() throws Exception {
|
||||
@Test
|
||||
public void configureBeanReallyDoesDefaultToUsingTheFullyQualifiedClassNameOfTheSuppliedBeanInstance() throws Exception {
|
||||
TestBean beanInstance = new TestBean();
|
||||
BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition(TestBean.class);
|
||||
builder.addPropertyValue("name", "Harriet Wheeler");
|
||||
@@ -75,7 +76,8 @@ public class BeanConfigurerSupportTests extends TestCase {
|
||||
assertEquals("Bean is evidently not being configured (for some reason)", "Harriet Wheeler", beanInstance.getName());
|
||||
}
|
||||
|
||||
public void testConfigureBeanPerformsAutowiringByNameIfAppropriateBeanWiringInfoResolverIsPluggedIn() throws Exception {
|
||||
@Test
|
||||
public void configureBeanPerformsAutowiringByNameIfAppropriateBeanWiringInfoResolverIsPluggedIn() throws Exception {
|
||||
TestBean beanInstance = new TestBean();
|
||||
// spouse for autowiring by name...
|
||||
BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition(TestBean.class);
|
||||
@@ -94,7 +96,8 @@ public class BeanConfigurerSupportTests extends TestCase {
|
||||
assertEquals("Bean is evidently not being configured (for some reason)", "David Gavurin", beanInstance.getSpouse().getName());
|
||||
}
|
||||
|
||||
public void testConfigureBeanPerformsAutowiringByTypeIfAppropriateBeanWiringInfoResolverIsPluggedIn() throws Exception {
|
||||
@Test
|
||||
public void configureBeanPerformsAutowiringByTypeIfAppropriateBeanWiringInfoResolverIsPluggedIn() throws Exception {
|
||||
TestBean beanInstance = new TestBean();
|
||||
// spouse for autowiring by type...
|
||||
BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition(TestBean.class);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2006 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.
|
||||
@@ -16,76 +16,63 @@
|
||||
|
||||
package org.springframework.beans.factory.wiring;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Unit tests for the BeanWiringInfo class.
|
||||
*
|
||||
* @author Rick Evans
|
||||
* @author Sam Brannen
|
||||
*/
|
||||
public final class BeanWiringInfoTests extends TestCase {
|
||||
public final class BeanWiringInfoTests {
|
||||
|
||||
public void testCtorWithNullBeanName() throws Exception {
|
||||
try {
|
||||
new BeanWiringInfo(null);
|
||||
fail("Must have thrown an IllegalArgumentException by this point (null argument).");
|
||||
}
|
||||
catch (IllegalArgumentException ex) {
|
||||
}
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void ctorWithNullBeanName() throws Exception {
|
||||
new BeanWiringInfo(null);
|
||||
}
|
||||
|
||||
public void testCtorWithWhitespacedBeanName() throws Exception {
|
||||
try {
|
||||
new BeanWiringInfo(" \t");
|
||||
fail("Must have thrown an IllegalArgumentException by this point (bean name has only whitespace).");
|
||||
}
|
||||
catch (IllegalArgumentException ex) {
|
||||
}
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void ctorWithWhitespacedBeanName() throws Exception {
|
||||
new BeanWiringInfo(" \t");
|
||||
}
|
||||
|
||||
public void testCtorWithEmptyBeanName() throws Exception {
|
||||
try {
|
||||
new BeanWiringInfo("");
|
||||
fail("Must have thrown an IllegalArgumentException by this point (bean name is empty).");
|
||||
}
|
||||
catch (IllegalArgumentException ex) {
|
||||
}
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void ctorWithEmptyBeanName() throws Exception {
|
||||
new BeanWiringInfo("");
|
||||
}
|
||||
|
||||
public void testCtorWithNegativeIllegalAutowiringValue() throws Exception {
|
||||
try {
|
||||
new BeanWiringInfo(-1, true);
|
||||
fail("Must have thrown an IllegalArgumentException by this point (out-of-range argument).");
|
||||
}
|
||||
catch (IllegalArgumentException ex) {
|
||||
}
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void ctorWithNegativeIllegalAutowiringValue() throws Exception {
|
||||
new BeanWiringInfo(-1, true);
|
||||
}
|
||||
|
||||
public void testCtorWithPositiveOutOfRangeAutowiringValue() throws Exception {
|
||||
try {
|
||||
new BeanWiringInfo(123871, true);
|
||||
fail("Must have thrown an IllegalArgumentException by this point (out-of-range argument).");
|
||||
}
|
||||
catch (IllegalArgumentException ex) {
|
||||
}
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void ctorWithPositiveOutOfRangeAutowiringValue() throws Exception {
|
||||
new BeanWiringInfo(123871, true);
|
||||
}
|
||||
|
||||
public void testUsingAutowireCtorIndicatesAutowiring() throws Exception {
|
||||
@Test
|
||||
public void usingAutowireCtorIndicatesAutowiring() throws Exception {
|
||||
BeanWiringInfo info = new BeanWiringInfo(BeanWiringInfo.AUTOWIRE_BY_NAME, true);
|
||||
assertTrue(info.indicatesAutowiring());
|
||||
}
|
||||
|
||||
public void testUsingBeanNameCtorDoesNotIndicateAutowiring() throws Exception {
|
||||
@Test
|
||||
public void usingBeanNameCtorDoesNotIndicateAutowiring() throws Exception {
|
||||
BeanWiringInfo info = new BeanWiringInfo("fooService");
|
||||
assertFalse(info.indicatesAutowiring());
|
||||
}
|
||||
|
||||
public void testNoDependencyCheckValueIsPreserved() throws Exception {
|
||||
@Test
|
||||
public void noDependencyCheckValueIsPreserved() throws Exception {
|
||||
BeanWiringInfo info = new BeanWiringInfo(BeanWiringInfo.AUTOWIRE_BY_NAME, true);
|
||||
assertTrue(info.getDependencyCheck());
|
||||
}
|
||||
|
||||
public void testDependencyCheckValueIsPreserved() throws Exception {
|
||||
@Test
|
||||
public void dependencyCheckValueIsPreserved() throws Exception {
|
||||
BeanWiringInfo info = new BeanWiringInfo(BeanWiringInfo.AUTOWIRE_BY_TYPE, false);
|
||||
assertFalse(info.getDependencyCheck());
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2006 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.
|
||||
@@ -16,25 +16,24 @@
|
||||
|
||||
package org.springframework.beans.factory.wiring;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Unit tests for the ClassNameBeanWiringInfoResolver class.
|
||||
*
|
||||
* @author Rick Evans
|
||||
*/
|
||||
public final class ClassNameBeanWiringInfoResolverTests extends TestCase {
|
||||
public final class ClassNameBeanWiringInfoResolverTests {
|
||||
|
||||
public void testResolveWiringInfoWithNullBeanInstance() throws Exception {
|
||||
try {
|
||||
new ClassNameBeanWiringInfoResolver().resolveWiringInfo(null);
|
||||
fail("Must have thrown an IllegalArgumentException by this point (null argument).");
|
||||
}
|
||||
catch (IllegalArgumentException expected) {
|
||||
}
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void resolveWiringInfoWithNullBeanInstance() throws Exception {
|
||||
new ClassNameBeanWiringInfoResolver().resolveWiringInfo(null);
|
||||
}
|
||||
|
||||
public void testResolveWiringInfo() {
|
||||
@Test
|
||||
public void resolveWiringInfo() {
|
||||
ClassNameBeanWiringInfoResolver resolver = new ClassNameBeanWiringInfoResolver();
|
||||
Long beanInstance = new Long(1);
|
||||
BeanWiringInfo info = resolver.resolveWiringInfo(beanInstance);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 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.
|
||||
@@ -19,7 +19,7 @@ package org.springframework.beans.factory.xml;
|
||||
import java.beans.PropertyEditorSupport;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.PropertyBatchUpdateException;
|
||||
@@ -34,21 +34,24 @@ import org.springframework.tests.sample.beans.MustBeInitialized;
|
||||
import org.springframework.tests.sample.beans.TestBean;
|
||||
import org.springframework.tests.sample.beans.factory.DummyFactory;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Subclasses must implement setUp() to initialize bean factory
|
||||
* and any other variables they need.
|
||||
* Subclasses must initialize the bean factory and any other variables they need.
|
||||
*
|
||||
* @author Rod Johnson
|
||||
* @author Juergen Hoeller
|
||||
* @author Sam Brannen
|
||||
*/
|
||||
public abstract class AbstractBeanFactoryTests extends TestCase {
|
||||
public abstract class AbstractBeanFactoryTests {
|
||||
|
||||
protected abstract BeanFactory getBeanFactory();
|
||||
|
||||
/**
|
||||
* Roderick beans inherits from rod, overriding name only.
|
||||
* Roderick bean inherits from rod, overriding name only.
|
||||
*/
|
||||
public void testInheritance() {
|
||||
@Test
|
||||
public void inheritance() {
|
||||
assertTrue(getBeanFactory().containsBean("rod"));
|
||||
assertTrue(getBeanFactory().containsBean("roderick"));
|
||||
TestBean rod = (TestBean) getBeanFactory().getBean("rod");
|
||||
@@ -60,20 +63,16 @@ public abstract class AbstractBeanFactoryTests extends TestCase {
|
||||
assertTrue("roderick.age was inherited", roderick.getAge() == rod.getAge());
|
||||
}
|
||||
|
||||
public void testGetBeanWithNullArg() {
|
||||
try {
|
||||
getBeanFactory().getBean((String) null);
|
||||
fail("Can't get null bean");
|
||||
}
|
||||
catch (IllegalArgumentException ex) {
|
||||
// OK
|
||||
}
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void getBeanWithNullArg() {
|
||||
getBeanFactory().getBean((String) null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that InitializingBean objects receive the afterPropertiesSet() callback
|
||||
*/
|
||||
public void testInitializingBeanCallback() {
|
||||
@Test
|
||||
public void initializingBeanCallback() {
|
||||
MustBeInitialized mbi = (MustBeInitialized) getBeanFactory().getBean("mustBeInitialized");
|
||||
// The dummy business method will throw an exception if the
|
||||
// afterPropertiesSet() callback wasn't invoked
|
||||
@@ -84,7 +83,8 @@ public abstract class AbstractBeanFactoryTests extends TestCase {
|
||||
* Test that InitializingBean/BeanFactoryAware/DisposableBean objects receive the
|
||||
* afterPropertiesSet() callback before BeanFactoryAware callbacks
|
||||
*/
|
||||
public void testLifecycleCallbacks() {
|
||||
@Test
|
||||
public void lifecycleCallbacks() {
|
||||
LifecycleBean lb = (LifecycleBean) getBeanFactory().getBean("lifecycle");
|
||||
assertEquals("lifecycle", lb.getBeanName());
|
||||
// The dummy business method will throw an exception if the
|
||||
@@ -93,32 +93,23 @@ public abstract class AbstractBeanFactoryTests extends TestCase {
|
||||
assertTrue("Not destroyed", !lb.isDestroyed());
|
||||
}
|
||||
|
||||
public void testFindsValidInstance() {
|
||||
try {
|
||||
Object o = getBeanFactory().getBean("rod");
|
||||
assertTrue("Rod bean is a TestBean", o instanceof TestBean);
|
||||
TestBean rod = (TestBean) o;
|
||||
assertTrue("rod.name is Rod", rod.getName().equals("Rod"));
|
||||
assertTrue("rod.age is 31", rod.getAge() == 31);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
fail("Shouldn't throw exception on getting valid instance");
|
||||
}
|
||||
@Test
|
||||
public void findsValidInstance() {
|
||||
Object o = getBeanFactory().getBean("rod");
|
||||
assertTrue("Rod bean is a TestBean", o instanceof TestBean);
|
||||
TestBean rod = (TestBean) o;
|
||||
assertTrue("rod.name is Rod", rod.getName().equals("Rod"));
|
||||
assertTrue("rod.age is 31", rod.getAge() == 31);
|
||||
}
|
||||
|
||||
public void testGetInstanceByMatchingClass() {
|
||||
try {
|
||||
Object o = getBeanFactory().getBean("rod", TestBean.class);
|
||||
assertTrue("Rod bean is a TestBean", o instanceof TestBean);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
fail("Shouldn't throw exception on getting valid instance with matching class");
|
||||
}
|
||||
@Test
|
||||
public void getInstanceByMatchingClass() {
|
||||
Object o = getBeanFactory().getBean("rod", TestBean.class);
|
||||
assertTrue("Rod bean is a TestBean", o instanceof TestBean);
|
||||
}
|
||||
|
||||
public void testGetInstanceByNonmatchingClass() {
|
||||
@Test
|
||||
public void getInstanceByNonmatchingClass() {
|
||||
try {
|
||||
getBeanFactory().getBean("rod", BeanFactory.class);
|
||||
fail("Rod bean is not of type BeanFactory; getBeanInstance(rod, BeanFactory.class) should throw BeanNotOfRequiredTypeException");
|
||||
@@ -130,29 +121,22 @@ public abstract class AbstractBeanFactoryTests extends TestCase {
|
||||
assertTrue("Exception actualType as TestBean.class", TestBean.class.isAssignableFrom(ex.getActualType()));
|
||||
assertTrue("Actual type is correct", ex.getActualType() == getBeanFactory().getBean("rod").getClass());
|
||||
}
|
||||
catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
fail("Shouldn't throw exception on getting valid instance");
|
||||
}
|
||||
}
|
||||
|
||||
public void testGetSharedInstanceByMatchingClass() {
|
||||
try {
|
||||
Object o = getBeanFactory().getBean("rod", TestBean.class);
|
||||
assertTrue("Rod bean is a TestBean", o instanceof TestBean);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
fail("Shouldn't throw exception on getting valid instance with matching class");
|
||||
}
|
||||
}
|
||||
|
||||
public void testGetSharedInstanceByMatchingClassNoCatch() {
|
||||
@Test
|
||||
public void getSharedInstanceByMatchingClass() {
|
||||
Object o = getBeanFactory().getBean("rod", TestBean.class);
|
||||
assertTrue("Rod bean is a TestBean", o instanceof TestBean);
|
||||
}
|
||||
|
||||
public void testGetSharedInstanceByNonmatchingClass() {
|
||||
@Test
|
||||
public void getSharedInstanceByMatchingClassNoCatch() {
|
||||
Object o = getBeanFactory().getBean("rod", TestBean.class);
|
||||
assertTrue("Rod bean is a TestBean", o instanceof TestBean);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getSharedInstanceByNonmatchingClass() {
|
||||
try {
|
||||
getBeanFactory().getBean("rod", BeanFactory.class);
|
||||
fail("Rod bean is not of type BeanFactory; getBeanInstance(rod, BeanFactory.class) should throw BeanNotOfRequiredTypeException");
|
||||
@@ -163,27 +147,19 @@ public abstract class AbstractBeanFactoryTests extends TestCase {
|
||||
assertTrue("Exception requiredType must be BeanFactory.class", ex.getRequiredType().equals(BeanFactory.class));
|
||||
assertTrue("Exception actualType as TestBean.class", TestBean.class.isAssignableFrom(ex.getActualType()));
|
||||
}
|
||||
catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
fail("Shouldn't throw exception on getting valid instance");
|
||||
}
|
||||
}
|
||||
|
||||
public void testSharedInstancesAreEqual() {
|
||||
try {
|
||||
Object o = getBeanFactory().getBean("rod");
|
||||
assertTrue("Rod bean1 is a TestBean", o instanceof TestBean);
|
||||
Object o1 = getBeanFactory().getBean("rod");
|
||||
assertTrue("Rod bean2 is a TestBean", o1 instanceof TestBean);
|
||||
assertTrue("Object equals applies", o == o1);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
fail("Shouldn't throw exception on getting valid instance");
|
||||
}
|
||||
@Test
|
||||
public void sharedInstancesAreEqual() {
|
||||
Object o = getBeanFactory().getBean("rod");
|
||||
assertTrue("Rod bean1 is a TestBean", o instanceof TestBean);
|
||||
Object o1 = getBeanFactory().getBean("rod");
|
||||
assertTrue("Rod bean2 is a TestBean", o1 instanceof TestBean);
|
||||
assertTrue("Object equals applies", o == o1);
|
||||
}
|
||||
|
||||
public void testPrototypeInstancesAreIndependent() {
|
||||
@Test
|
||||
public void prototypeInstancesAreIndependent() {
|
||||
TestBean tb1 = (TestBean) getBeanFactory().getBean("kathy");
|
||||
TestBean tb2 = (TestBean) getBeanFactory().getBean("kathy");
|
||||
assertTrue("ref equal DOES NOT apply", tb1 != tb2);
|
||||
@@ -195,29 +171,18 @@ public abstract class AbstractBeanFactoryTests extends TestCase {
|
||||
assertTrue("object equal now false", !tb1.equals(tb2));
|
||||
}
|
||||
|
||||
public void testNotThere() {
|
||||
@Test(expected = BeansException.class)
|
||||
public void notThere() {
|
||||
assertFalse(getBeanFactory().containsBean("Mr Squiggle"));
|
||||
try {
|
||||
getBeanFactory().getBean("Mr Squiggle");
|
||||
fail("Can't find missing bean");
|
||||
}
|
||||
catch (BeansException ex) {
|
||||
//ex.printStackTrace();
|
||||
//fail("Shouldn't throw exception on getting valid instance");
|
||||
}
|
||||
getBeanFactory().getBean("Mr Squiggle");
|
||||
}
|
||||
|
||||
public void testValidEmpty() {
|
||||
try {
|
||||
Object o = getBeanFactory().getBean("validEmpty");
|
||||
assertTrue("validEmpty bean is a TestBean", o instanceof TestBean);
|
||||
TestBean ve = (TestBean) o;
|
||||
assertTrue("Valid empty has defaults", ve.getName() == null && ve.getAge() == 0 && ve.getSpouse() == null);
|
||||
}
|
||||
catch (BeansException ex) {
|
||||
ex.printStackTrace();
|
||||
fail("Shouldn't throw exception on valid empty");
|
||||
}
|
||||
@Test
|
||||
public void validEmpty() {
|
||||
Object o = getBeanFactory().getBean("validEmpty");
|
||||
assertTrue("validEmpty bean is a TestBean", o instanceof TestBean);
|
||||
TestBean ve = (TestBean) o;
|
||||
assertTrue("Valid empty has defaults", ve.getName() == null && ve.getAge() == 0 && ve.getSpouse() == null);
|
||||
}
|
||||
|
||||
public void xtestTypeMismatch() {
|
||||
@@ -236,12 +201,14 @@ public abstract class AbstractBeanFactoryTests extends TestCase {
|
||||
}
|
||||
}
|
||||
|
||||
public void testGrandparentDefinitionFoundInBeanFactory() throws Exception {
|
||||
@Test
|
||||
public void grandparentDefinitionFoundInBeanFactory() throws Exception {
|
||||
TestBean dad = (TestBean) getBeanFactory().getBean("father");
|
||||
assertTrue("Dad has correct name", dad.getName().equals("Albert"));
|
||||
}
|
||||
|
||||
public void testFactorySingleton() throws Exception {
|
||||
@Test
|
||||
public void factorySingleton() throws Exception {
|
||||
assertTrue(getBeanFactory().isSingleton("&singletonFactory"));
|
||||
assertTrue(getBeanFactory().isSingleton("singletonFactory"));
|
||||
TestBean tb = (TestBean) getBeanFactory().getBean("singletonFactory");
|
||||
@@ -252,7 +219,8 @@ public abstract class AbstractBeanFactoryTests extends TestCase {
|
||||
assertTrue("FactoryBean is BeanFactoryAware", factory.getBeanFactory() != null);
|
||||
}
|
||||
|
||||
public void testFactoryPrototype() throws Exception {
|
||||
@Test
|
||||
public void factoryPrototype() throws Exception {
|
||||
assertTrue(getBeanFactory().isSingleton("&prototypeFactory"));
|
||||
assertFalse(getBeanFactory().isSingleton("prototypeFactory"));
|
||||
TestBean tb = (TestBean) getBeanFactory().getBean("prototypeFactory");
|
||||
@@ -266,16 +234,17 @@ public abstract class AbstractBeanFactoryTests extends TestCase {
|
||||
* This is only possible if we're dealing with a factory
|
||||
* @throws Exception
|
||||
*/
|
||||
public void testGetFactoryItself() throws Exception {
|
||||
DummyFactory factory = (DummyFactory) getBeanFactory().getBean("&singletonFactory");
|
||||
assertTrue(factory != null);
|
||||
@Test
|
||||
public void getFactoryItself() throws Exception {
|
||||
assertNotNull(getBeanFactory().getBean("&singletonFactory"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Check that afterPropertiesSet gets called on factory
|
||||
* @throws Exception
|
||||
*/
|
||||
public void testFactoryIsInitialized() throws Exception {
|
||||
@Test
|
||||
public void factoryIsInitialized() throws Exception {
|
||||
TestBean tb = (TestBean) getBeanFactory().getBean("singletonFactory");
|
||||
assertNotNull(tb);
|
||||
DummyFactory factory = (DummyFactory) getBeanFactory().getBean("&singletonFactory");
|
||||
@@ -283,22 +252,17 @@ public abstract class AbstractBeanFactoryTests extends TestCase {
|
||||
}
|
||||
|
||||
/**
|
||||
* It should be illegal to dereference a normal bean
|
||||
* as a factory
|
||||
* It should be illegal to dereference a normal bean as a factory.
|
||||
*/
|
||||
public void testRejectsFactoryGetOnNormalBean() {
|
||||
try {
|
||||
getBeanFactory().getBean("&rod");
|
||||
fail("Shouldn't permit factory get on normal bean");
|
||||
}
|
||||
catch (BeanIsNotAFactoryException ex) {
|
||||
// Ok
|
||||
}
|
||||
@Test(expected = BeanIsNotAFactoryException.class)
|
||||
public void rejectsFactoryGetOnNormalBean() {
|
||||
getBeanFactory().getBean("&rod");
|
||||
}
|
||||
|
||||
// TODO: refactor in AbstractBeanFactory (tests for AbstractBeanFactory)
|
||||
// and rename this class
|
||||
public void testAliasing() {
|
||||
@Test
|
||||
public void aliasing() {
|
||||
BeanFactory bf = getBeanFactory();
|
||||
if (!(bf instanceof ConfigurableBeanFactory)) {
|
||||
return;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 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.
|
||||
@@ -16,11 +16,15 @@
|
||||
|
||||
package org.springframework.beans.factory.xml;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.beans.factory.FactoryBean;
|
||||
import org.springframework.beans.factory.ListableBeanFactory;
|
||||
import org.springframework.tests.sample.beans.TestBean;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* @author Rod Johnson
|
||||
* @author Juergen Hoeller
|
||||
@@ -39,7 +43,8 @@ public abstract class AbstractListableBeanFactoryTests extends AbstractBeanFacto
|
||||
/**
|
||||
* Subclasses can override this.
|
||||
*/
|
||||
public void testCount() {
|
||||
@Test
|
||||
public void count() {
|
||||
assertCount(13);
|
||||
}
|
||||
|
||||
@@ -48,7 +53,7 @@ public abstract class AbstractListableBeanFactoryTests extends AbstractBeanFacto
|
||||
assertTrue("We should have " + count + " beans, not " + defnames.length, defnames.length == count);
|
||||
}
|
||||
|
||||
public void assertTestBeanCount(int count) {
|
||||
protected void assertTestBeanCount(int count) {
|
||||
String[] defNames = getListableBeanFactory().getBeanNamesForType(TestBean.class, true, false);
|
||||
assertTrue("We should have " + count + " beans for class org.springframework.tests.sample.beans.TestBean, not " +
|
||||
defNames.length, defNames.length == count);
|
||||
@@ -60,7 +65,8 @@ public abstract class AbstractListableBeanFactoryTests extends AbstractBeanFacto
|
||||
names.length == countIncludingFactoryBeans);
|
||||
}
|
||||
|
||||
public void testGetDefinitionsForNoSuchClass() {
|
||||
@Test
|
||||
public void getDefinitionsForNoSuchClass() {
|
||||
String[] defnames = getListableBeanFactory().getBeanNamesForType(String.class);
|
||||
assertTrue("No string definitions", defnames.length == 0);
|
||||
}
|
||||
@@ -69,7 +75,8 @@ public abstract class AbstractListableBeanFactoryTests extends AbstractBeanFacto
|
||||
* Check that count refers to factory class, not bean class. (We don't know
|
||||
* what type factories may return, and it may even change over time.)
|
||||
*/
|
||||
public void testGetCountForFactoryClass() {
|
||||
@Test
|
||||
public void getCountForFactoryClass() {
|
||||
assertTrue("Should have 2 factories, not " +
|
||||
getListableBeanFactory().getBeanNamesForType(FactoryBean.class).length,
|
||||
getListableBeanFactory().getBeanNamesForType(FactoryBean.class).length == 2);
|
||||
@@ -79,7 +86,8 @@ public abstract class AbstractListableBeanFactoryTests extends AbstractBeanFacto
|
||||
getListableBeanFactory().getBeanNamesForType(FactoryBean.class).length == 2);
|
||||
}
|
||||
|
||||
public void testContainsBeanDefinition() {
|
||||
@Test
|
||||
public void containsBeanDefinition() {
|
||||
assertTrue(getListableBeanFactory().containsBeanDefinition("rod"));
|
||||
assertTrue(getListableBeanFactory().containsBeanDefinition("roderick"));
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 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.
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.springframework.beans.factory.xml;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.beans.factory.config.PropertiesFactoryBean;
|
||||
import org.springframework.beans.factory.config.RuntimeBeanReference;
|
||||
@@ -25,13 +25,16 @@ import org.springframework.beans.factory.support.RootBeanDefinition;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.tests.sample.beans.TestBean;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* @author Rob Harrop
|
||||
* @author Juergen Hoeller
|
||||
*/
|
||||
public class AutowireWithExclusionTests extends TestCase {
|
||||
public class AutowireWithExclusionTests {
|
||||
|
||||
public void testByTypeAutowireWithAutoSelfExclusion() throws Exception {
|
||||
@Test
|
||||
public void byTypeAutowireWithAutoSelfExclusion() throws Exception {
|
||||
CountingFactory.reset();
|
||||
DefaultListableBeanFactory beanFactory = getBeanFactory("autowire-with-exclusion.xml");
|
||||
beanFactory.preInstantiateSingletons();
|
||||
@@ -41,7 +44,8 @@ public class AutowireWithExclusionTests extends TestCase {
|
||||
assertEquals(1, CountingFactory.getFactoryBeanInstanceCount());
|
||||
}
|
||||
|
||||
public void testByTypeAutowireWithExclusion() throws Exception {
|
||||
@Test
|
||||
public void byTypeAutowireWithExclusion() throws Exception {
|
||||
CountingFactory.reset();
|
||||
DefaultListableBeanFactory beanFactory = getBeanFactory("autowire-with-exclusion.xml");
|
||||
beanFactory.preInstantiateSingletons();
|
||||
@@ -50,7 +54,8 @@ public class AutowireWithExclusionTests extends TestCase {
|
||||
assertEquals(1, CountingFactory.getFactoryBeanInstanceCount());
|
||||
}
|
||||
|
||||
public void testByTypeAutowireWithExclusionInParentFactory() throws Exception {
|
||||
@Test
|
||||
public void byTypeAutowireWithExclusionInParentFactory() throws Exception {
|
||||
CountingFactory.reset();
|
||||
DefaultListableBeanFactory parent = getBeanFactory("autowire-with-exclusion.xml");
|
||||
parent.preInstantiateSingletons();
|
||||
@@ -64,7 +69,8 @@ public class AutowireWithExclusionTests extends TestCase {
|
||||
assertEquals(1, CountingFactory.getFactoryBeanInstanceCount());
|
||||
}
|
||||
|
||||
public void testByTypeAutowireWithPrimaryInParentFactory() throws Exception {
|
||||
@Test
|
||||
public void byTypeAutowireWithPrimaryInParentFactory() throws Exception {
|
||||
CountingFactory.reset();
|
||||
DefaultListableBeanFactory parent = getBeanFactory("autowire-with-exclusion.xml");
|
||||
parent.getBeanDefinition("props1").setPrimary(true);
|
||||
@@ -82,7 +88,8 @@ public class AutowireWithExclusionTests extends TestCase {
|
||||
assertEquals(1, CountingFactory.getFactoryBeanInstanceCount());
|
||||
}
|
||||
|
||||
public void testByTypeAutowireWithPrimaryOverridingParentFactory() throws Exception {
|
||||
@Test
|
||||
public void byTypeAutowireWithPrimaryOverridingParentFactory() throws Exception {
|
||||
CountingFactory.reset();
|
||||
DefaultListableBeanFactory parent = getBeanFactory("autowire-with-exclusion.xml");
|
||||
parent.preInstantiateSingletons();
|
||||
@@ -100,7 +107,8 @@ public class AutowireWithExclusionTests extends TestCase {
|
||||
assertEquals(1, CountingFactory.getFactoryBeanInstanceCount());
|
||||
}
|
||||
|
||||
public void testByTypeAutowireWithPrimaryInParentAndChild() throws Exception {
|
||||
@Test
|
||||
public void byTypeAutowireWithPrimaryInParentAndChild() throws Exception {
|
||||
CountingFactory.reset();
|
||||
DefaultListableBeanFactory parent = getBeanFactory("autowire-with-exclusion.xml");
|
||||
parent.getBeanDefinition("props1").setPrimary(true);
|
||||
@@ -119,7 +127,8 @@ public class AutowireWithExclusionTests extends TestCase {
|
||||
assertEquals(1, CountingFactory.getFactoryBeanInstanceCount());
|
||||
}
|
||||
|
||||
public void testByTypeAutowireWithInclusion() throws Exception {
|
||||
@Test
|
||||
public void byTypeAutowireWithInclusion() throws Exception {
|
||||
CountingFactory.reset();
|
||||
DefaultListableBeanFactory beanFactory = getBeanFactory("autowire-with-inclusion.xml");
|
||||
beanFactory.preInstantiateSingletons();
|
||||
@@ -128,7 +137,8 @@ public class AutowireWithExclusionTests extends TestCase {
|
||||
assertEquals(1, CountingFactory.getFactoryBeanInstanceCount());
|
||||
}
|
||||
|
||||
public void testByTypeAutowireWithSelectiveInclusion() throws Exception {
|
||||
@Test
|
||||
public void byTypeAutowireWithSelectiveInclusion() throws Exception {
|
||||
CountingFactory.reset();
|
||||
DefaultListableBeanFactory beanFactory = getBeanFactory("autowire-with-selective-inclusion.xml");
|
||||
beanFactory.preInstantiateSingletons();
|
||||
@@ -137,7 +147,8 @@ public class AutowireWithExclusionTests extends TestCase {
|
||||
assertEquals(1, CountingFactory.getFactoryBeanInstanceCount());
|
||||
}
|
||||
|
||||
public void testConstructorAutowireWithAutoSelfExclusion() throws Exception {
|
||||
@Test
|
||||
public void constructorAutowireWithAutoSelfExclusion() throws Exception {
|
||||
DefaultListableBeanFactory beanFactory = getBeanFactory("autowire-constructor-with-exclusion.xml");
|
||||
TestBean rob = (TestBean) beanFactory.getBean("rob");
|
||||
TestBean sally = (TestBean) beanFactory.getBean("sally");
|
||||
@@ -149,7 +160,8 @@ public class AutowireWithExclusionTests extends TestCase {
|
||||
assertNotSame(rob.getSpouse(), rob2.getSpouse());
|
||||
}
|
||||
|
||||
public void testConstructorAutowireWithExclusion() throws Exception {
|
||||
@Test
|
||||
public void constructorAutowireWithExclusion() throws Exception {
|
||||
DefaultListableBeanFactory beanFactory = getBeanFactory("autowire-constructor-with-exclusion.xml");
|
||||
TestBean rob = (TestBean) beanFactory.getBean("rob");
|
||||
assertEquals("props1", rob.getSomeProperties().getProperty("name"));
|
||||
|
||||
@@ -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.
|
||||
@@ -16,21 +16,25 @@
|
||||
|
||||
package org.springframework.beans.factory.xml;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.beans.factory.support.BeanDefinitionReaderUtils;
|
||||
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* @author Rob Harrop
|
||||
* @author Juergen Hoeller
|
||||
*/
|
||||
public class BeanNameGenerationTests extends TestCase {
|
||||
public class BeanNameGenerationTests {
|
||||
|
||||
private DefaultListableBeanFactory beanFactory;
|
||||
|
||||
@Override
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
this.beanFactory = new DefaultListableBeanFactory();
|
||||
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(this.beanFactory);
|
||||
@@ -38,7 +42,8 @@ public class BeanNameGenerationTests extends TestCase {
|
||||
reader.loadBeanDefinitions(new ClassPathResource("beanNameGeneration.xml", getClass()));
|
||||
}
|
||||
|
||||
public void testNaming() {
|
||||
@Test
|
||||
public void naming() {
|
||||
String className = GeneratedNameBean.class.getName();
|
||||
|
||||
String targetName = className + BeanDefinitionReaderUtils.GENERATED_BEAN_NAME_SEPARATOR + "0";
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 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.
|
||||
@@ -22,31 +22,36 @@ import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.beans.factory.support.BeanDefinitionReader;
|
||||
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.tests.sample.beans.TestBean;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Unit and integration tests for the collection merging support.
|
||||
*
|
||||
* @author Rob Harrop
|
||||
* @author Rick Evans
|
||||
*/
|
||||
public class CollectionMergingTests extends TestCase {
|
||||
@SuppressWarnings("rawtypes")
|
||||
public class CollectionMergingTests {
|
||||
|
||||
private DefaultListableBeanFactory beanFactory;
|
||||
private final DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
this.beanFactory = new DefaultListableBeanFactory();
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
BeanDefinitionReader reader = new XmlBeanDefinitionReader(this.beanFactory);
|
||||
reader.loadBeanDefinitions(new ClassPathResource("collectionMerging.xml", getClass()));
|
||||
}
|
||||
|
||||
public void testMergeList() throws Exception {
|
||||
@Test
|
||||
public void mergeList() throws Exception {
|
||||
TestBean bean = (TestBean) this.beanFactory.getBean("childWithList");
|
||||
List list = bean.getSomeList();
|
||||
assertEquals("Incorrect size", 3, list.size());
|
||||
@@ -55,7 +60,8 @@ public class CollectionMergingTests extends TestCase {
|
||||
assertEquals(list.get(2), "Juergen Hoeller");
|
||||
}
|
||||
|
||||
public void testMergeListWithInnerBeanAsListElement() throws Exception {
|
||||
@Test
|
||||
public void mergeListWithInnerBeanAsListElement() throws Exception {
|
||||
TestBean bean = (TestBean) this.beanFactory.getBean("childWithListOfRefs");
|
||||
List list = bean.getSomeList();
|
||||
assertNotNull(list);
|
||||
@@ -64,7 +70,8 @@ public class CollectionMergingTests extends TestCase {
|
||||
assertTrue(list.get(2) instanceof TestBean);
|
||||
}
|
||||
|
||||
public void testMergeSet() {
|
||||
@Test
|
||||
public void mergeSet() {
|
||||
TestBean bean = (TestBean) this.beanFactory.getBean("childWithSet");
|
||||
Set set = bean.getSomeSet();
|
||||
assertEquals("Incorrect size", 2, set.size());
|
||||
@@ -72,7 +79,8 @@ public class CollectionMergingTests extends TestCase {
|
||||
assertTrue(set.contains("Sally Greenwood"));
|
||||
}
|
||||
|
||||
public void testMergeSetWithInnerBeanAsSetElement() throws Exception {
|
||||
@Test
|
||||
public void mergeSetWithInnerBeanAsSetElement() throws Exception {
|
||||
TestBean bean = (TestBean) this.beanFactory.getBean("childWithSetOfRefs");
|
||||
Set set = bean.getSomeSet();
|
||||
assertNotNull(set);
|
||||
@@ -85,7 +93,8 @@ public class CollectionMergingTests extends TestCase {
|
||||
assertEquals("Sally", ((TestBean) o).getName());
|
||||
}
|
||||
|
||||
public void testMergeMap() throws Exception {
|
||||
@Test
|
||||
public void mergeMap() throws Exception {
|
||||
TestBean bean = (TestBean) this.beanFactory.getBean("childWithMap");
|
||||
Map map = bean.getSomeMap();
|
||||
assertEquals("Incorrect size", 3, map.size());
|
||||
@@ -94,7 +103,8 @@ public class CollectionMergingTests extends TestCase {
|
||||
assertEquals(map.get("Juergen"), "Eva");
|
||||
}
|
||||
|
||||
public void testMergeMapWithInnerBeanAsMapEntryValue() throws Exception {
|
||||
@Test
|
||||
public void mergeMapWithInnerBeanAsMapEntryValue() throws Exception {
|
||||
TestBean bean = (TestBean) this.beanFactory.getBean("childWithMapOfRefs");
|
||||
Map map = bean.getSomeMap();
|
||||
assertNotNull(map);
|
||||
@@ -104,7 +114,8 @@ public class CollectionMergingTests extends TestCase {
|
||||
assertEquals("Sally", ((TestBean) map.get("Rob")).getName());
|
||||
}
|
||||
|
||||
public void testMergeProperties() throws Exception {
|
||||
@Test
|
||||
public void mergeProperties() throws Exception {
|
||||
TestBean bean = (TestBean) this.beanFactory.getBean("childWithProps");
|
||||
Properties props = bean.getSomeProperties();
|
||||
assertEquals("Incorrect size", 3, props.size());
|
||||
@@ -113,8 +124,8 @@ public class CollectionMergingTests extends TestCase {
|
||||
assertEquals(props.getProperty("Juergen"), "Eva");
|
||||
}
|
||||
|
||||
|
||||
public void testMergeListInConstructor() throws Exception {
|
||||
@Test
|
||||
public void mergeListInConstructor() throws Exception {
|
||||
TestBean bean = (TestBean) this.beanFactory.getBean("childWithListInConstructor");
|
||||
List list = bean.getSomeList();
|
||||
assertEquals("Incorrect size", 3, list.size());
|
||||
@@ -123,7 +134,8 @@ public class CollectionMergingTests extends TestCase {
|
||||
assertEquals(list.get(2), "Juergen Hoeller");
|
||||
}
|
||||
|
||||
public void testMergeListWithInnerBeanAsListElementInConstructor() throws Exception {
|
||||
@Test
|
||||
public void mergeListWithInnerBeanAsListElementInConstructor() throws Exception {
|
||||
TestBean bean = (TestBean) this.beanFactory.getBean("childWithListOfRefsInConstructor");
|
||||
List list = bean.getSomeList();
|
||||
assertNotNull(list);
|
||||
@@ -132,7 +144,8 @@ public class CollectionMergingTests extends TestCase {
|
||||
assertTrue(list.get(2) instanceof TestBean);
|
||||
}
|
||||
|
||||
public void testMergeSetInConstructor() {
|
||||
@Test
|
||||
public void mergeSetInConstructor() {
|
||||
TestBean bean = (TestBean) this.beanFactory.getBean("childWithSetInConstructor");
|
||||
Set set = bean.getSomeSet();
|
||||
assertEquals("Incorrect size", 2, set.size());
|
||||
@@ -140,7 +153,8 @@ public class CollectionMergingTests extends TestCase {
|
||||
assertTrue(set.contains("Sally Greenwood"));
|
||||
}
|
||||
|
||||
public void testMergeSetWithInnerBeanAsSetElementInConstructor() throws Exception {
|
||||
@Test
|
||||
public void mergeSetWithInnerBeanAsSetElementInConstructor() throws Exception {
|
||||
TestBean bean = (TestBean) this.beanFactory.getBean("childWithSetOfRefsInConstructor");
|
||||
Set set = bean.getSomeSet();
|
||||
assertNotNull(set);
|
||||
@@ -153,7 +167,8 @@ public class CollectionMergingTests extends TestCase {
|
||||
assertEquals("Sally", ((TestBean) o).getName());
|
||||
}
|
||||
|
||||
public void testMergeMapInConstructor() throws Exception {
|
||||
@Test
|
||||
public void mergeMapInConstructor() throws Exception {
|
||||
TestBean bean = (TestBean) this.beanFactory.getBean("childWithMapInConstructor");
|
||||
Map map = bean.getSomeMap();
|
||||
assertEquals("Incorrect size", 3, map.size());
|
||||
@@ -162,7 +177,8 @@ public class CollectionMergingTests extends TestCase {
|
||||
assertEquals(map.get("Juergen"), "Eva");
|
||||
}
|
||||
|
||||
public void testMergeMapWithInnerBeanAsMapEntryValueInConstructor() throws Exception {
|
||||
@Test
|
||||
public void mergeMapWithInnerBeanAsMapEntryValueInConstructor() throws Exception {
|
||||
TestBean bean = (TestBean) this.beanFactory.getBean("childWithMapOfRefsInConstructor");
|
||||
Map map = bean.getSomeMap();
|
||||
assertNotNull(map);
|
||||
@@ -172,7 +188,8 @@ public class CollectionMergingTests extends TestCase {
|
||||
assertEquals("Sally", ((TestBean) map.get("Rob")).getName());
|
||||
}
|
||||
|
||||
public void testMergePropertiesInConstructor() throws Exception {
|
||||
@Test
|
||||
public void mergePropertiesInConstructor() throws Exception {
|
||||
TestBean bean = (TestBean) this.beanFactory.getBean("childWithPropsInConstructor");
|
||||
Properties props = bean.getSomeProperties();
|
||||
assertEquals("Incorrect size", 3, props.size());
|
||||
|
||||
@@ -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.
|
||||
@@ -16,26 +16,30 @@
|
||||
|
||||
package org.springframework.beans.factory.xml;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* @author Rob Harrop
|
||||
*/
|
||||
public class DefaultLifecycleMethodsTests extends TestCase {
|
||||
public class DefaultLifecycleMethodsTests {
|
||||
|
||||
private DefaultListableBeanFactory beanFactory;
|
||||
private final DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
this.beanFactory = new DefaultListableBeanFactory();
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
new XmlBeanDefinitionReader(this.beanFactory).loadBeanDefinitions(new ClassPathResource(
|
||||
"defaultLifecycleMethods.xml", getClass()));
|
||||
}
|
||||
|
||||
public void testLifecycleMethodsInvoked() {
|
||||
@Test
|
||||
public void lifecycleMethodsInvoked() {
|
||||
LifecycleAwareBean bean = (LifecycleAwareBean) this.beanFactory.getBean("lifecycleAware");
|
||||
assertTrue("Bean not initialized", bean.isInitCalled());
|
||||
assertFalse("Bean destroyed too early", bean.isDestroyCalled());
|
||||
@@ -43,28 +47,25 @@ public class DefaultLifecycleMethodsTests extends TestCase {
|
||||
assertTrue("Bean not destroyed", bean.isDestroyCalled());
|
||||
}
|
||||
|
||||
public void testLifecycleMethodsDisabled() throws Exception {
|
||||
@Test
|
||||
public void lifecycleMethodsDisabled() throws Exception {
|
||||
LifecycleAwareBean bean = (LifecycleAwareBean) this.beanFactory.getBean("lifecycleMethodsDisabled");
|
||||
assertFalse("Bean init method called incorrectly", bean.isInitCalled());
|
||||
this.beanFactory.destroySingletons();
|
||||
assertFalse("Bean destroy method called incorrectly", bean.isDestroyCalled());
|
||||
}
|
||||
|
||||
public void testIgnoreDefaultLifecycleMethods() throws Exception {
|
||||
try {
|
||||
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
|
||||
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(
|
||||
new ClassPathResource("ignoreDefaultLifecycleMethods.xml", getClass()));
|
||||
bf.preInstantiateSingletons();
|
||||
bf.destroySingletons();
|
||||
}
|
||||
catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
fail("Should ignore non-existent default lifecycle methods");
|
||||
}
|
||||
@Test
|
||||
public void ignoreDefaultLifecycleMethods() throws Exception {
|
||||
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
|
||||
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(new ClassPathResource(
|
||||
"ignoreDefaultLifecycleMethods.xml", getClass()));
|
||||
bf.preInstantiateSingletons();
|
||||
bf.destroySingletons();
|
||||
}
|
||||
|
||||
public void testOverrideDefaultLifecycleMethods() throws Exception {
|
||||
@Test
|
||||
public void overrideDefaultLifecycleMethods() throws Exception {
|
||||
LifecycleAwareBean bean = (LifecycleAwareBean) this.beanFactory.getBean("overrideLifecycleMethods");
|
||||
assertFalse("Default init method called incorrectly.", bean.isInitCalled());
|
||||
assertTrue("Custom init method not called.", bean.isCustomInitCalled());
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 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.
|
||||
@@ -18,8 +18,8 @@ package org.springframework.beans.factory.xml;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import org.w3c.dom.Element;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
import org.springframework.beans.factory.config.TypedStringValue;
|
||||
@@ -32,26 +32,33 @@ import org.springframework.beans.factory.support.DefaultListableBeanFactory;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.tests.beans.CollectingReaderEventListener;
|
||||
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* @author Rob Harrop
|
||||
* @author Juergen Hoeller
|
||||
*/
|
||||
public class EventPublicationTests extends TestCase {
|
||||
@SuppressWarnings("rawtypes")
|
||||
public class EventPublicationTests {
|
||||
|
||||
private final DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();
|
||||
|
||||
private final CollectingReaderEventListener eventListener = new CollectingReaderEventListener();
|
||||
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(this.beanFactory);
|
||||
reader.setEventListener(this.eventListener);
|
||||
reader.setSourceExtractor(new PassThroughSourceExtractor());
|
||||
reader.loadBeanDefinitions(new ClassPathResource("beanEvents.xml", getClass()));
|
||||
}
|
||||
|
||||
public void testDefaultsEventReceived() throws Exception {
|
||||
@Test
|
||||
public void defaultsEventReceived() throws Exception {
|
||||
List defaultsList = this.eventListener.getDefaults();
|
||||
assertTrue(!defaultsList.isEmpty());
|
||||
assertTrue(defaultsList.get(0) instanceof DocumentDefaultsDefinition);
|
||||
@@ -65,7 +72,8 @@ public class EventPublicationTests extends TestCase {
|
||||
assertTrue(defaults.getSource() instanceof Element);
|
||||
}
|
||||
|
||||
public void testBeanEventReceived() throws Exception {
|
||||
@Test
|
||||
public void beanEventReceived() throws Exception {
|
||||
ComponentDefinition componentDefinition1 = this.eventListener.getComponentDefinition("testBean");
|
||||
assertTrue(componentDefinition1 instanceof BeanComponentDefinition);
|
||||
assertEquals(1, componentDefinition1.getBeanDefinitions().length);
|
||||
@@ -94,7 +102,8 @@ public class EventPublicationTests extends TestCase {
|
||||
assertTrue(componentDefinition2.getSource() instanceof Element);
|
||||
}
|
||||
|
||||
public void testAliasEventReceived() throws Exception {
|
||||
@Test
|
||||
public void aliasEventReceived() throws Exception {
|
||||
List aliases = this.eventListener.getAliases("testBean");
|
||||
assertEquals(2, aliases.size());
|
||||
AliasDefinition aliasDefinition1 = (AliasDefinition) aliases.get(0);
|
||||
@@ -105,7 +114,8 @@ public class EventPublicationTests extends TestCase {
|
||||
assertTrue(aliasDefinition2.getSource() instanceof Element);
|
||||
}
|
||||
|
||||
public void testImportEventReceived() throws Exception {
|
||||
@Test
|
||||
public void importEventReceived() throws Exception {
|
||||
List imports = this.eventListener.getImports();
|
||||
assertEquals(1, imports.size());
|
||||
ImportDefinition importDefinition = (ImportDefinition) imports.get(0);
|
||||
|
||||
@@ -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.
|
||||
@@ -16,39 +16,46 @@
|
||||
|
||||
package org.springframework.beans.factory.xml;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.beans.PropertyValue;
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* @author Rob Harrop
|
||||
*/
|
||||
public class MetadataAttachmentTests extends TestCase {
|
||||
public class MetadataAttachmentTests {
|
||||
|
||||
private DefaultListableBeanFactory beanFactory;
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
this.beanFactory = new DefaultListableBeanFactory();
|
||||
new XmlBeanDefinitionReader(this.beanFactory).loadBeanDefinitions(
|
||||
new ClassPathResource("withMeta.xml", getClass()));
|
||||
}
|
||||
|
||||
public void testMetadataAttachment() throws Exception {
|
||||
@Test
|
||||
public void metadataAttachment() throws Exception {
|
||||
BeanDefinition beanDefinition1 = this.beanFactory.getMergedBeanDefinition("testBean1");
|
||||
assertEquals("bar", beanDefinition1.getAttribute("foo"));
|
||||
}
|
||||
|
||||
public void testMetadataIsInherited() throws Exception {
|
||||
@Test
|
||||
public void metadataIsInherited() throws Exception {
|
||||
BeanDefinition beanDefinition = this.beanFactory.getMergedBeanDefinition("testBean2");
|
||||
assertEquals("Metadata not inherited", "bar", beanDefinition.getAttribute("foo"));
|
||||
assertEquals("Child metdata not attached", "123", beanDefinition.getAttribute("abc"));
|
||||
}
|
||||
|
||||
public void testPropertyMetadata() throws Exception {
|
||||
@Test
|
||||
public void propertyMetadata() throws Exception {
|
||||
BeanDefinition beanDefinition = this.beanFactory.getMergedBeanDefinition("testBean3");
|
||||
PropertyValue pv = beanDefinition.getPropertyValues().getPropertyValue("name");
|
||||
assertEquals("Harrop", pv.getAttribute("surname"));
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 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.
|
||||
@@ -16,20 +16,24 @@
|
||||
|
||||
package org.springframework.beans.factory.xml;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import org.xml.sax.SAXParseException;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.tests.sample.beans.TestBean;
|
||||
|
||||
import org.xml.sax.SAXParseException;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* @author Rob Harrop
|
||||
*/
|
||||
public class SchemaValidationTests extends TestCase {
|
||||
public class SchemaValidationTests {
|
||||
|
||||
public void testWithAutodetection() throws Exception {
|
||||
@Test
|
||||
public void withAutodetection() throws Exception {
|
||||
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
|
||||
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(bf);
|
||||
try {
|
||||
@@ -41,7 +45,8 @@ public class SchemaValidationTests extends TestCase {
|
||||
}
|
||||
}
|
||||
|
||||
public void testWithExplicitValidationMode() throws Exception {
|
||||
@Test
|
||||
public void withExplicitValidationMode() throws Exception {
|
||||
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
|
||||
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(bf);
|
||||
reader.setValidationMode(XmlBeanDefinitionReader.VALIDATION_XSD);
|
||||
@@ -54,7 +59,8 @@ public class SchemaValidationTests extends TestCase {
|
||||
}
|
||||
}
|
||||
|
||||
public void testLoadDefinitions() throws Exception {
|
||||
@Test
|
||||
public void loadDefinitions() throws Exception {
|
||||
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
|
||||
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(bf);
|
||||
reader.setValidationMode(XmlBeanDefinitionReader.VALIDATION_XSD);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 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.
|
||||
@@ -18,8 +18,7 @@ package org.springframework.beans.factory.xml;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import org.xml.sax.InputSource;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.beans.factory.BeanDefinitionStoreException;
|
||||
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
|
||||
@@ -31,49 +30,45 @@ import org.springframework.core.io.Resource;
|
||||
import org.springframework.tests.sample.beans.TestBean;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
import org.xml.sax.InputSource;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* @author Rick Evans
|
||||
* @author Juergen Hoeller
|
||||
* @author Sam Brannen
|
||||
*/
|
||||
public class XmlBeanDefinitionReaderTests extends TestCase {
|
||||
public class XmlBeanDefinitionReaderTests {
|
||||
|
||||
public void testSetParserClassSunnyDay() {
|
||||
@Test
|
||||
public void setParserClassSunnyDay() {
|
||||
SimpleBeanDefinitionRegistry registry = new SimpleBeanDefinitionRegistry();
|
||||
new XmlBeanDefinitionReader(registry).setDocumentReaderClass(DefaultBeanDefinitionDocumentReader.class);
|
||||
}
|
||||
|
||||
public void testSetParserClassToNull() {
|
||||
try {
|
||||
SimpleBeanDefinitionRegistry registry = new SimpleBeanDefinitionRegistry();
|
||||
new XmlBeanDefinitionReader(registry).setDocumentReaderClass(null);
|
||||
fail("Should have thrown IllegalArgumentException (null parserClass)");
|
||||
}
|
||||
catch (IllegalArgumentException expected) {
|
||||
}
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void setParserClassToNull() {
|
||||
SimpleBeanDefinitionRegistry registry = new SimpleBeanDefinitionRegistry();
|
||||
new XmlBeanDefinitionReader(registry).setDocumentReaderClass(null);
|
||||
}
|
||||
|
||||
public void testSetParserClassToUnsupportedParserType() throws Exception {
|
||||
try {
|
||||
SimpleBeanDefinitionRegistry registry = new SimpleBeanDefinitionRegistry();
|
||||
new XmlBeanDefinitionReader(registry).setDocumentReaderClass(String.class);
|
||||
fail("Should have thrown IllegalArgumentException (unsupported parserClass)");
|
||||
}
|
||||
catch (IllegalArgumentException expected) {
|
||||
}
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void setParserClassToUnsupportedParserType() throws Exception {
|
||||
SimpleBeanDefinitionRegistry registry = new SimpleBeanDefinitionRegistry();
|
||||
new XmlBeanDefinitionReader(registry).setDocumentReaderClass(String.class);
|
||||
}
|
||||
|
||||
public void testWithOpenInputStream() {
|
||||
try {
|
||||
SimpleBeanDefinitionRegistry registry = new SimpleBeanDefinitionRegistry();
|
||||
Resource resource = new InputStreamResource(getClass().getResourceAsStream("test.xml"));
|
||||
new XmlBeanDefinitionReader(registry).loadBeanDefinitions(resource);
|
||||
fail("Should have thrown BeanDefinitionStoreException (can't determine validation mode)");
|
||||
}
|
||||
catch (BeanDefinitionStoreException expected) {
|
||||
}
|
||||
@Test(expected = BeanDefinitionStoreException.class)
|
||||
public void withOpenInputStream() {
|
||||
SimpleBeanDefinitionRegistry registry = new SimpleBeanDefinitionRegistry();
|
||||
Resource resource = new InputStreamResource(getClass().getResourceAsStream(
|
||||
"test.xml"));
|
||||
new XmlBeanDefinitionReader(registry).loadBeanDefinitions(resource);
|
||||
}
|
||||
|
||||
public void testWithOpenInputStreamAndExplicitValidationMode() {
|
||||
@Test
|
||||
public void withOpenInputStreamAndExplicitValidationMode() {
|
||||
SimpleBeanDefinitionRegistry registry = new SimpleBeanDefinitionRegistry();
|
||||
Resource resource = new InputStreamResource(getClass().getResourceAsStream("test.xml"));
|
||||
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(registry);
|
||||
@@ -82,32 +77,31 @@ public class XmlBeanDefinitionReaderTests extends TestCase {
|
||||
testBeanDefinitions(registry);
|
||||
}
|
||||
|
||||
public void testWithImport() {
|
||||
@Test
|
||||
public void withImport() {
|
||||
SimpleBeanDefinitionRegistry registry = new SimpleBeanDefinitionRegistry();
|
||||
Resource resource = new ClassPathResource("import.xml", getClass());
|
||||
new XmlBeanDefinitionReader(registry).loadBeanDefinitions(resource);
|
||||
testBeanDefinitions(registry);
|
||||
}
|
||||
|
||||
public void testWithWildcardImport() {
|
||||
@Test
|
||||
public void withWildcardImport() {
|
||||
SimpleBeanDefinitionRegistry registry = new SimpleBeanDefinitionRegistry();
|
||||
Resource resource = new ClassPathResource("importPattern.xml", getClass());
|
||||
new XmlBeanDefinitionReader(registry).loadBeanDefinitions(resource);
|
||||
testBeanDefinitions(registry);
|
||||
}
|
||||
|
||||
public void testWithInputSource() {
|
||||
try {
|
||||
SimpleBeanDefinitionRegistry registry = new SimpleBeanDefinitionRegistry();
|
||||
InputSource resource = new InputSource(getClass().getResourceAsStream("test.xml"));
|
||||
new XmlBeanDefinitionReader(registry).loadBeanDefinitions(resource);
|
||||
fail("Should have thrown BeanDefinitionStoreException (can't determine validation mode)");
|
||||
}
|
||||
catch (BeanDefinitionStoreException expected) {
|
||||
}
|
||||
@Test(expected = BeanDefinitionStoreException.class)
|
||||
public void withInputSource() {
|
||||
SimpleBeanDefinitionRegistry registry = new SimpleBeanDefinitionRegistry();
|
||||
InputSource resource = new InputSource(getClass().getResourceAsStream("test.xml"));
|
||||
new XmlBeanDefinitionReader(registry).loadBeanDefinitions(resource);
|
||||
}
|
||||
|
||||
public void testWithInputSourceAndExplicitValidationMode() {
|
||||
@Test
|
||||
public void withInputSourceAndExplicitValidationMode() {
|
||||
SimpleBeanDefinitionRegistry registry = new SimpleBeanDefinitionRegistry();
|
||||
InputSource resource = new InputSource(getClass().getResourceAsStream("test.xml"));
|
||||
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(registry);
|
||||
@@ -116,7 +110,8 @@ public class XmlBeanDefinitionReaderTests extends TestCase {
|
||||
testBeanDefinitions(registry);
|
||||
}
|
||||
|
||||
public void testWithFreshInputStream() {
|
||||
@Test
|
||||
public void withFreshInputStream() {
|
||||
SimpleBeanDefinitionRegistry registry = new SimpleBeanDefinitionRegistry();
|
||||
Resource resource = new ClassPathResource("test.xml", getClass());
|
||||
new XmlBeanDefinitionReader(registry).loadBeanDefinitions(resource);
|
||||
@@ -139,11 +134,13 @@ public class XmlBeanDefinitionReaderTests extends TestCase {
|
||||
assertTrue(ObjectUtils.containsElement(aliases, "youralias"));
|
||||
}
|
||||
|
||||
public void testDtdValidationAutodetect() throws Exception {
|
||||
@Test
|
||||
public void dtdValidationAutodetect() throws Exception {
|
||||
doTestValidation("validateWithDtd.xml");
|
||||
}
|
||||
|
||||
public void testXsdValidationAutodetect() throws Exception {
|
||||
@Test
|
||||
public void xsdValidationAutodetect() throws Exception {
|
||||
doTestValidation("validateWithXsd.xml");
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 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.
|
||||
@@ -21,6 +21,9 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.MutablePropertyValues;
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
@@ -33,18 +36,21 @@ import org.springframework.tests.sample.beans.LifecycleBean;
|
||||
import org.springframework.tests.sample.beans.TestBean;
|
||||
import org.springframework.tests.sample.beans.factory.DummyFactory;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* @author Juergen Hoeller
|
||||
* @since 09.11.2003
|
||||
*/
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
public class XmlListableBeanFactoryTests extends AbstractListableBeanFactoryTests {
|
||||
|
||||
private DefaultListableBeanFactory parent;
|
||||
|
||||
private DefaultListableBeanFactory factory;
|
||||
|
||||
@Override
|
||||
protected void setUp() {
|
||||
@Before
|
||||
public void setUp() {
|
||||
parent = new DefaultListableBeanFactory();
|
||||
Map m = new HashMap();
|
||||
m.put("name", "Albert");
|
||||
@@ -86,26 +92,31 @@ public class XmlListableBeanFactoryTests extends AbstractListableBeanFactoryTest
|
||||
return factory;
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testCount() {
|
||||
public void count() {
|
||||
assertCount(24);
|
||||
}
|
||||
|
||||
public void testTestBeanCount() {
|
||||
@Test
|
||||
public void beanCount() {
|
||||
assertTestBeanCount(13);
|
||||
}
|
||||
|
||||
public void testLifecycleMethods() throws Exception {
|
||||
@Test
|
||||
public void lifecycleMethods() throws Exception {
|
||||
LifecycleBean bean = (LifecycleBean) getBeanFactory().getBean("lifecycle");
|
||||
bean.businessMethod();
|
||||
}
|
||||
|
||||
public void testProtectedLifecycleMethods() throws Exception {
|
||||
@Test
|
||||
public void protectedLifecycleMethods() throws Exception {
|
||||
ProtectedLifecycleBean bean = (ProtectedLifecycleBean) getBeanFactory().getBean("protectedLifecycle");
|
||||
bean.businessMethod();
|
||||
}
|
||||
|
||||
public void testDescriptionButNoProperties() throws Exception {
|
||||
@Test
|
||||
public void descriptionButNoProperties() throws Exception {
|
||||
TestBean validEmpty = (TestBean) getBeanFactory().getBean("validEmptyWithDescription");
|
||||
assertEquals(0, validEmpty.getAge());
|
||||
}
|
||||
@@ -113,7 +124,8 @@ public class XmlListableBeanFactoryTests extends AbstractListableBeanFactoryTest
|
||||
/**
|
||||
* Test that properties with name as well as id creating an alias up front.
|
||||
*/
|
||||
public void testAutoAliasing() throws Exception {
|
||||
@Test
|
||||
public void autoAliasing() throws Exception {
|
||||
List beanNames = Arrays.asList(getListableBeanFactory().getBeanDefinitionNames());
|
||||
|
||||
TestBean tb1 = (TestBean) getBeanFactory().getBean("aliased");
|
||||
@@ -172,7 +184,8 @@ public class XmlListableBeanFactoryTests extends AbstractListableBeanFactoryTest
|
||||
assertTrue(drs.containsKey(DummyReferencer.class.getName() + "#2"));
|
||||
}
|
||||
|
||||
public void testFactoryNesting() {
|
||||
@Test
|
||||
public void factoryNesting() {
|
||||
ITestBean father = (ITestBean) getBeanFactory().getBean("father");
|
||||
assertTrue("Bean from root context", father != null);
|
||||
|
||||
@@ -184,7 +197,8 @@ public class XmlListableBeanFactoryTests extends AbstractListableBeanFactoryTest
|
||||
assertTrue("Bean from root context", "Roderick".equals(rod.getName()));
|
||||
}
|
||||
|
||||
public void testFactoryReferences() {
|
||||
@Test
|
||||
public void factoryReferences() {
|
||||
DummyFactory factory = (DummyFactory) getBeanFactory().getBean("&singletonFactory");
|
||||
|
||||
DummyReferencer ref = (DummyReferencer) getBeanFactory().getBean("factoryReferencer");
|
||||
@@ -196,7 +210,8 @@ public class XmlListableBeanFactoryTests extends AbstractListableBeanFactoryTest
|
||||
assertTrue(ref2.getDummyFactory() == factory);
|
||||
}
|
||||
|
||||
public void testPrototypeReferences() {
|
||||
@Test
|
||||
public void prototypeReferences() {
|
||||
// check that not broken by circular reference resolution mechanism
|
||||
DummyReferencer ref1 = (DummyReferencer) getBeanFactory().getBean("prototypeReferencer");
|
||||
assertTrue("Not referencing same bean twice", ref1.getTestBean1() != ref1.getTestBean2());
|
||||
@@ -208,7 +223,8 @@ public class XmlListableBeanFactoryTests extends AbstractListableBeanFactoryTest
|
||||
assertTrue("Not referencing same bean twice", ref1.getTestBean1() != ref2.getTestBean2());
|
||||
}
|
||||
|
||||
public void testBeanPostProcessor() throws Exception {
|
||||
@Test
|
||||
public void beanPostProcessor() throws Exception {
|
||||
TestBean kerry = (TestBean) getBeanFactory().getBean("kerry");
|
||||
TestBean kathy = (TestBean) getBeanFactory().getBean("kathy");
|
||||
DummyFactory factory = (DummyFactory) getBeanFactory().getBean("&singletonFactory");
|
||||
@@ -219,14 +235,16 @@ public class XmlListableBeanFactoryTests extends AbstractListableBeanFactoryTest
|
||||
assertTrue(factoryCreated.isPostProcessed());
|
||||
}
|
||||
|
||||
public void testEmptyValues() {
|
||||
@Test
|
||||
public void emptyValues() {
|
||||
TestBean rod = (TestBean) getBeanFactory().getBean("rod");
|
||||
TestBean kerry = (TestBean) getBeanFactory().getBean("kerry");
|
||||
assertTrue("Touchy is empty", "".equals(rod.getTouchy()));
|
||||
assertTrue("Touchy is empty", "".equals(kerry.getTouchy()));
|
||||
}
|
||||
|
||||
public void testCommentsAndCdataInValue() {
|
||||
@Test
|
||||
public void commentsAndCdataInValue() {
|
||||
TestBean bean = (TestBean) getBeanFactory().getBean("commentsInValue");
|
||||
assertEquals("Failed to handle comments and CDATA properly", "this is a <!--comment-->", bean.getName());
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
@@ -18,19 +18,22 @@ package org.springframework.beans.propertyeditors;
|
||||
|
||||
import java.beans.PropertyEditor;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Unit tests for the {@link ByteArrayPropertyEditor} class.
|
||||
*
|
||||
* @author Rick Evans
|
||||
*/
|
||||
public final class ByteArrayPropertyEditorTests extends TestCase {
|
||||
public final class ByteArrayPropertyEditorTests {
|
||||
|
||||
public void testSunnyDaySetAsText() throws Exception {
|
||||
private final PropertyEditor byteEditor = new ByteArrayPropertyEditor();
|
||||
|
||||
@Test
|
||||
public void sunnyDaySetAsText() throws Exception {
|
||||
final String text = "Hideous towns make me throw... up";
|
||||
|
||||
PropertyEditor byteEditor = new ByteArrayPropertyEditor();
|
||||
byteEditor.setAsText(text);
|
||||
|
||||
Object value = byteEditor.getValue();
|
||||
@@ -43,8 +46,8 @@ public final class ByteArrayPropertyEditorTests extends TestCase {
|
||||
assertEquals(text, byteEditor.getAsText());
|
||||
}
|
||||
|
||||
public void testGetAsTextReturnsEmptyStringIfValueIsNull() throws Exception {
|
||||
PropertyEditor byteEditor = new ByteArrayPropertyEditor();
|
||||
@Test
|
||||
public void getAsTextReturnsEmptyStringIfValueIsNull() throws Exception {
|
||||
assertEquals("", byteEditor.getAsText());
|
||||
|
||||
byteEditor.setAsText(null);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2006 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.
|
||||
@@ -18,19 +18,22 @@ package org.springframework.beans.propertyeditors;
|
||||
|
||||
import java.beans.PropertyEditor;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Unit tests for the {@link CharArrayPropertyEditor} class.
|
||||
*
|
||||
* @author Rick Evans
|
||||
*/
|
||||
public final class CharArrayPropertyEditorTests extends TestCase {
|
||||
public final class CharArrayPropertyEditorTests {
|
||||
|
||||
public void testSunnyDaySetAsText() throws Exception {
|
||||
private final PropertyEditor charEditor = new CharArrayPropertyEditor();
|
||||
|
||||
@Test
|
||||
public void sunnyDaySetAsText() throws Exception {
|
||||
final String text = "Hideous towns make me throw... up";
|
||||
|
||||
PropertyEditor charEditor = new CharArrayPropertyEditor();
|
||||
charEditor.setAsText(text);
|
||||
|
||||
Object value = charEditor.getValue();
|
||||
@@ -43,8 +46,8 @@ public final class CharArrayPropertyEditorTests extends TestCase {
|
||||
assertEquals(text, charEditor.getAsText());
|
||||
}
|
||||
|
||||
public void testGetAsTextReturnsEmptyStringIfValueIsNull() throws Exception {
|
||||
PropertyEditor charEditor = new CharArrayPropertyEditor();
|
||||
@Test
|
||||
public void getAsTextReturnsEmptyStringIfValueIsNull() throws Exception {
|
||||
assertEquals("", charEditor.getAsText());
|
||||
|
||||
charEditor.setAsText(null);
|
||||
|
||||
@@ -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,7 +20,9 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Test the conversion of Strings to {@link java.util.Properties} objects,
|
||||
@@ -30,9 +32,10 @@ import junit.framework.TestCase;
|
||||
* @author Juergen Hoeller
|
||||
* @author Rick Evans
|
||||
*/
|
||||
public class PropertiesEditorTests extends TestCase {
|
||||
public class PropertiesEditorTests {
|
||||
|
||||
public void testOneProperty() {
|
||||
@Test
|
||||
public void oneProperty() {
|
||||
String s = "foo=bar";
|
||||
PropertiesEditor pe= new PropertiesEditor();
|
||||
pe.setAsText(s);
|
||||
@@ -41,7 +44,8 @@ public class PropertiesEditorTests extends TestCase {
|
||||
assertTrue("foo=bar", p.get("foo").equals("bar"));
|
||||
}
|
||||
|
||||
public void testTwoProperties() {
|
||||
@Test
|
||||
public void twoProperties() {
|
||||
String s = "foo=bar with whitespace\n" +
|
||||
"me=mi";
|
||||
PropertiesEditor pe= new PropertiesEditor();
|
||||
@@ -52,7 +56,8 @@ public class PropertiesEditorTests extends TestCase {
|
||||
assertTrue("me=mi", p.get("me").equals("mi"));
|
||||
}
|
||||
|
||||
public void testHandlesEqualsInValue() {
|
||||
@Test
|
||||
public void handlesEqualsInValue() {
|
||||
String s = "foo=bar\n" +
|
||||
"me=mi\n" +
|
||||
"x=y=z";
|
||||
@@ -65,7 +70,8 @@ public class PropertiesEditorTests extends TestCase {
|
||||
assertTrue("x='y=z'", p.get("x").equals("y=z"));
|
||||
}
|
||||
|
||||
public void testHandlesEmptyProperty() {
|
||||
@Test
|
||||
public void handlesEmptyProperty() {
|
||||
String s = "foo=bar\nme=mi\nx=";
|
||||
PropertiesEditor pe= new PropertiesEditor();
|
||||
pe.setAsText(s);
|
||||
@@ -76,7 +82,8 @@ public class PropertiesEditorTests extends TestCase {
|
||||
assertTrue("x='y=z'", p.get("x").equals(""));
|
||||
}
|
||||
|
||||
public void testHandlesEmptyPropertyWithoutEquals() {
|
||||
@Test
|
||||
public void handlesEmptyPropertyWithoutEquals() {
|
||||
String s = "foo\nme=mi\nx=x";
|
||||
PropertiesEditor pe= new PropertiesEditor();
|
||||
pe.setAsText(s);
|
||||
@@ -89,7 +96,8 @@ public class PropertiesEditorTests extends TestCase {
|
||||
/**
|
||||
* Comments begin with #
|
||||
*/
|
||||
public void testIgnoresCommentLinesAndEmptyLines() {
|
||||
@Test
|
||||
public void ignoresCommentLinesAndEmptyLines() {
|
||||
String s = "#Ignore this comment\n" +
|
||||
"foo=bar\n" +
|
||||
"#Another=comment more junk /\n" +
|
||||
@@ -110,7 +118,8 @@ public class PropertiesEditorTests extends TestCase {
|
||||
* We must ensure that comment lines beginning with whitespace are
|
||||
* still ignored: The standard syntax doesn't allow this on JDK 1.3.
|
||||
*/
|
||||
public void testIgnoresLeadingSpacesAndTabs() {
|
||||
@Test
|
||||
public void ignoresLeadingSpacesAndTabs() {
|
||||
String s = " #Ignore this comment\n" +
|
||||
"\t\tfoo=bar\n" +
|
||||
"\t#Another comment more junk \n" +
|
||||
@@ -125,22 +134,25 @@ public class PropertiesEditorTests extends TestCase {
|
||||
assertTrue("me=mi", p.get("me").equals("mi"));
|
||||
}
|
||||
|
||||
public void testNull() {
|
||||
@Test
|
||||
public void nullValue() {
|
||||
PropertiesEditor pe= new PropertiesEditor();
|
||||
pe.setAsText(null);
|
||||
Properties p = (Properties) pe.getValue();
|
||||
assertEquals(0, p.size());
|
||||
}
|
||||
|
||||
public void testEmptyString() {
|
||||
@Test
|
||||
public void emptyString() {
|
||||
PropertiesEditor pe = new PropertiesEditor();
|
||||
pe.setAsText("");
|
||||
Properties p = (Properties) pe.getValue();
|
||||
assertTrue("empty string means empty properties", p.isEmpty());
|
||||
}
|
||||
|
||||
public void testUsingMapAsValueSource() throws Exception {
|
||||
Map map = new HashMap();
|
||||
@Test
|
||||
public void usingMapAsValueSource() throws Exception {
|
||||
Map<String, String> map = new HashMap<>();
|
||||
map.put("one", "1");
|
||||
map.put("two", "2");
|
||||
map.put("three", "3");
|
||||
|
||||
@@ -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.
|
||||
@@ -16,15 +16,18 @@
|
||||
|
||||
package org.springframework.beans.propertyeditors;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* @author Rick Evans
|
||||
* @author Juergen Hoeller
|
||||
*/
|
||||
public class StringArrayPropertyEditorTests extends TestCase {
|
||||
public class StringArrayPropertyEditorTests {
|
||||
|
||||
public void testWithDefaultSeparator() throws Exception {
|
||||
@Test
|
||||
public void withDefaultSeparator() throws Exception {
|
||||
StringArrayPropertyEditor editor = new StringArrayPropertyEditor();
|
||||
editor.setAsText("0,1,2");
|
||||
Object value = editor.getValue();
|
||||
@@ -37,7 +40,8 @@ public class StringArrayPropertyEditorTests extends TestCase {
|
||||
assertEquals("0,1,2", editor.getAsText());
|
||||
}
|
||||
|
||||
public void testTrimByDefault() throws Exception {
|
||||
@Test
|
||||
public void trimByDefault() throws Exception {
|
||||
StringArrayPropertyEditor editor = new StringArrayPropertyEditor();
|
||||
editor.setAsText(" 0,1 , 2 ");
|
||||
Object value = editor.getValue();
|
||||
@@ -48,7 +52,8 @@ public class StringArrayPropertyEditorTests extends TestCase {
|
||||
assertEquals("0,1,2", editor.getAsText());
|
||||
}
|
||||
|
||||
public void testNoTrim() throws Exception {
|
||||
@Test
|
||||
public void noTrim() throws Exception {
|
||||
StringArrayPropertyEditor editor = new StringArrayPropertyEditor(",",false,false);
|
||||
editor.setAsText(" 0,1 , 2 ");
|
||||
Object value = editor.getValue();
|
||||
@@ -60,7 +65,8 @@ public class StringArrayPropertyEditorTests extends TestCase {
|
||||
assertEquals(" 0,1 , 2 ", editor.getAsText());
|
||||
}
|
||||
|
||||
public void testWithCustomSeparator() throws Exception {
|
||||
@Test
|
||||
public void withCustomSeparator() throws Exception {
|
||||
StringArrayPropertyEditor editor = new StringArrayPropertyEditor(":");
|
||||
editor.setAsText("0:1:2");
|
||||
Object value = editor.getValue();
|
||||
@@ -72,7 +78,8 @@ public class StringArrayPropertyEditorTests extends TestCase {
|
||||
assertEquals("0:1:2", editor.getAsText());
|
||||
}
|
||||
|
||||
public void testWithCharsToDelete() throws Exception {
|
||||
@Test
|
||||
public void withCharsToDelete() throws Exception {
|
||||
StringArrayPropertyEditor editor = new StringArrayPropertyEditor(",", "\r\n", false);
|
||||
editor.setAsText("0\r,1,\n2");
|
||||
Object value = editor.getValue();
|
||||
@@ -84,7 +91,8 @@ public class StringArrayPropertyEditorTests extends TestCase {
|
||||
assertEquals("0,1,2", editor.getAsText());
|
||||
}
|
||||
|
||||
public void testWithEmptyArray() throws Exception {
|
||||
@Test
|
||||
public void withEmptyArray() throws Exception {
|
||||
StringArrayPropertyEditor editor = new StringArrayPropertyEditor();
|
||||
editor.setAsText("");
|
||||
Object value = editor.getValue();
|
||||
@@ -92,7 +100,8 @@ public class StringArrayPropertyEditorTests extends TestCase {
|
||||
assertEquals(0, ((String[]) value).length);
|
||||
}
|
||||
|
||||
public void testWithEmptyArrayAsNull() throws Exception {
|
||||
@Test
|
||||
public void withEmptyArrayAsNull() throws Exception {
|
||||
StringArrayPropertyEditor editor = new StringArrayPropertyEditor(",", true);
|
||||
editor.setAsText("");
|
||||
assertNull(editor.getValue());
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 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.
|
||||
@@ -18,15 +18,19 @@ package org.springframework.beans.propertyeditors;
|
||||
|
||||
import java.time.ZoneId;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* @author Nicholas Williams
|
||||
*/
|
||||
public class ZoneIdEditorTests extends TestCase {
|
||||
public class ZoneIdEditorTests {
|
||||
|
||||
public void testAmericaChicago() {
|
||||
ZoneIdEditor editor = new ZoneIdEditor();
|
||||
private final ZoneIdEditor editor = new ZoneIdEditor();
|
||||
|
||||
@Test
|
||||
public void americaChicago() {
|
||||
editor.setAsText("America/Chicago");
|
||||
|
||||
ZoneId zoneId = (ZoneId) editor.getValue();
|
||||
@@ -36,8 +40,8 @@ public class ZoneIdEditorTests extends TestCase {
|
||||
assertEquals("The text version is not correct.", "America/Chicago", editor.getAsText());
|
||||
}
|
||||
|
||||
public void testAmericaLosAngeles() {
|
||||
ZoneIdEditor editor = new ZoneIdEditor();
|
||||
@Test
|
||||
public void americaLosAngeles() {
|
||||
editor.setAsText("America/Los_Angeles");
|
||||
|
||||
ZoneId zoneId = (ZoneId) editor.getValue();
|
||||
@@ -47,16 +51,14 @@ public class ZoneIdEditorTests extends TestCase {
|
||||
assertEquals("The text version is not correct.", "America/Los_Angeles", editor.getAsText());
|
||||
}
|
||||
|
||||
public void testGetNullAsText() {
|
||||
ZoneIdEditor editor = new ZoneIdEditor();
|
||||
|
||||
@Test
|
||||
public void getNullAsText() {
|
||||
assertEquals("The returned value is not correct.", "", editor.getAsText());
|
||||
}
|
||||
|
||||
public void testGetValueAsText() {
|
||||
ZoneIdEditor editor = new ZoneIdEditor();
|
||||
@Test
|
||||
public void getValueAsText() {
|
||||
editor.setValue(ZoneId.of("America/New_York"));
|
||||
|
||||
assertEquals("The text version is not correct.", "America/New_York", editor.getAsText());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user