revised bean scopes examples

This commit is contained in:
Loredana Crusoveanu
2016-05-05 20:19:48 +03:00
parent c3abba5f2a
commit e792db4d6d
3 changed files with 7 additions and 20 deletions

View File

@@ -9,10 +9,7 @@ import org.springframework.context.support.ClassPathXmlApplicationContext;
public class ScopesTest {
private static final String NAME = "John Smith";
private static final int AGE = 30;
private static final String NAME_OTHER = "Anna Jones";
private static final int AGE_OTHER = 40;
@Test
public void testScopeSingleton() {
@@ -22,10 +19,7 @@ public class ScopesTest {
final Person personSingletonB = (Person) applicationContext.getBean("personSingleton");
personSingletonA.setName(NAME);
personSingletonB.setAge(AGE);
Assert.assertEquals(NAME, personSingletonB.getName());
Assert.assertEquals(AGE, personSingletonB.getAge());
((AbstractApplicationContext) applicationContext).close();
}
@@ -38,10 +32,7 @@ public class ScopesTest {
final Person personPrototypeB = (Person) applicationContext.getBean("personPrototype");
personPrototypeA.setName(NAME);
personPrototypeA.setAge(AGE);
personPrototypeB.setName(NAME_OTHER);
personPrototypeB.setAge(AGE_OTHER);
Assert.assertEquals(NAME, personPrototypeA.getName());
Assert.assertEquals(NAME_OTHER, personPrototypeB.getName());