1
2
3
4
5 package com.atlassian.spring.container;
6
7 import junit.framework.TestCase;
8
9
10
11
12
13
14 public abstract class AbstractContainerContextTest extends TestCase
15 {
16 public void testContainer() throws Exception
17 {
18 ContainerContext container = getContainer();
19
20 try
21 {
22 container.getComponent(null);
23 fail("Should get an exception with a null key");
24 }
25 catch (ComponentNotFoundException e)
26 {
27
28 }
29
30 try
31 {
32 container.getComponent(getInvalidKey());
33 fail("Should get an exception with a invalid key");
34 }
35 catch (ComponentNotFoundException e1)
36 {
37
38 }
39
40 assertNotNull(container.getComponent(getValidKey()));
41
42 Object dupKey = getDuplicateKey();
43
44 if(dupKey!=null)
45 {
46 try
47 {
48 container.getComponent(dupKey);
49 fail("Should get an exception with a duplicate key");
50 }
51 catch (ComponentNotFoundException e)
52 {
53
54 }
55 }
56
57
58 container.refresh();
59 }
60
61 public abstract ContainerContext getContainer() throws Exception;
62
63 public abstract Object getValidKey();
64
65 public Object getInvalidKey()
66 {
67 return "12345676890Invalid";
68 }
69
70 public abstract Object getDuplicateKey();
71
72 }