1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.springframework.ws.test.support;
18
19 import org.springframework.beans.factory.BeanInitializationException;
20 import org.springframework.context.support.StaticApplicationContext;
21
22 import org.junit.Test;
23
24 import static org.junit.Assert.assertNotNull;
25 import static org.junit.Assert.assertNull;
26
27 public class MockStrategiesHelperTest {
28
29 @Test
30 public void none() {
31 StaticApplicationContext applicationContext = new StaticApplicationContext();
32
33 MockStrategiesHelper helper = new MockStrategiesHelper(applicationContext);
34 assertNull(helper.getStrategy(IMyBean.class));
35 }
36
37 @Test
38 public void one() {
39 StaticApplicationContext applicationContext = new StaticApplicationContext();
40 applicationContext.registerSingleton("myBean", MyBean.class);
41
42 MockStrategiesHelper helper = new MockStrategiesHelper(applicationContext);
43 assertNotNull(helper.getStrategy(IMyBean.class));
44 }
45
46 @Test(expected = BeanInitializationException.class)
47 public void many() {
48 StaticApplicationContext applicationContext = new StaticApplicationContext();
49 applicationContext.registerSingleton("myBean1", MyBean.class);
50 applicationContext.registerSingleton("myBean2", MyBean.class);
51
52 MockStrategiesHelper helper = new MockStrategiesHelper(applicationContext);
53 helper.getStrategy(IMyBean.class);
54 }
55
56 @Test
57 public void noneWithDefault() {
58 StaticApplicationContext applicationContext = new StaticApplicationContext();
59
60
61 MockStrategiesHelper helper = new MockStrategiesHelper(applicationContext);
62 assertNotNull(helper.getStrategy(IMyBean.class, MyBean.class));
63 }
64
65
66 public interface IMyBean {
67
68 }
69
70 public static class MyBean implements IMyBean {
71
72 }
73
74 }