1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package test.de.smartics.ci.config.load;
17
18 import static org.hamcrest.MatcherAssert.assertThat;
19 import static org.hamcrest.Matchers.equalTo;
20 import static org.hamcrest.Matchers.is;
21
22 import java.io.File;
23 import java.io.FileNotFoundException;
24 import java.util.ArrayList;
25 import java.util.List;
26
27 import org.junit.Before;
28 import org.junit.Test;
29 import org.xml.sax.InputSource;
30
31 import de.smartics.ci.config.load.LoaderPlan;
32 import de.smartics.ci.config.load.LoaderPlanLoader;
33 import de.smartics.ci.config.load.LocationManager;
34 import de.smartics.ci.config.maven.MavenConfig;
35 import de.smartics.ci.config.projects.Project;
36 import de.smartics.ci.config.test.MavenConfigBuilder;
37 import de.smartics.testdoc.annotations.Uut;
38 import de.smartics.util.test.io.FileTestUtils;
39
40
41
42
43 public class LoaderPlanLoaderTest
44 {
45
46
47
48
49
50
51 @Uut
52 private LoaderPlanLoader uut;
53
54 private LocationManager locationManager;
55
56 private MavenConfig mavenConfig;
57
58
59
60
61
62
63
64 @Before
65 public void setUp()
66 {
67 locationManager = new LocationManager();
68 final File projectDir =
69 FileTestUtils.getFileFromRelativeResource(Project.class,
70 Project.SINGLE_PROJECT_USING_POM_DEFAULTS);
71 locationManager.addLocation(projectDir);
72
73 mavenConfig = MavenConfigBuilder.a().build();
74 uut = new LoaderPlanLoader(mavenConfig);
75 }
76
77
78
79
80
81 @Test
82 public void loadsMultipleLoaderInformationFromOneConfigurationFile()
83 throws FileNotFoundException
84 {
85 final InputSource inputSource = locationManager.open("ci-config.xml");
86 final List<LoaderPlan> plans = uut.load(inputSource);
87
88 final List<LoaderPlan> expectedPlans = new ArrayList<LoaderPlan>(2);
89 final LoaderPlan plan1 = new LoaderPlan("deploy", mavenConfig);
90 plan1.addConfigurationName("hudson-config-root");
91 plan1.addConfigurationName("hudson-config-deploy");
92 plan1.addConfigurationName("hudson-config");
93 expectedPlans.add(plan1);
94 final LoaderPlan plan2 = new LoaderPlan("site", mavenConfig);
95 plan2.addConfigurationName("hudson-config-root");
96 plan2.addConfigurationName("hudson-config-site");
97 plan2.addConfigurationName("hudson-config");
98 expectedPlans.add(plan2);
99
100 assertThat(plans, is(equalTo(expectedPlans)));
101 }
102 }