1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.maven.plugin.eclipse.it;
20
21 import java.io.File;
22 import java.io.FileInputStream;
23 import java.io.InputStream;
24 import java.util.ArrayList;
25 import java.util.List;
26 import java.util.Properties;
27
28 import org.codehaus.plexus.util.IOUtil;
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67 public class EclipsePluginMasterProjectIT
68 extends AbstractEclipsePluginIT
69 {
70
71 protected File basedir;
72
73
74
75
76 protected void setUp()
77 throws Exception
78 {
79 basedir = getTestFile( "target/test-classes/projects/master-test" );
80 super.setUp();
81 }
82
83 protected void executeMaven2()
84 throws Exception
85 {
86 File pom = new File( basedir, "pom.xml" );
87
88 Properties properties = new Properties();
89 properties.setProperty( "wtpversion", "R7" );
90
91 String pluginSpec = getPluginCLISpecification();
92
93 List goals = new ArrayList();
94
95 goals.add( pluginSpec + "clean" );
96 goals.add( pluginSpec + "eclipse" );
97
98 executeMaven( pom, properties, goals );
99
100 }
101
102 public void testModule1Project()
103 throws Exception
104 {
105 executeMaven2();
106 assertFileEquals( new File( basedir, "module-1/expected/.project" ), new File( basedir, "module-1/.project" ) );
107 }
108
109 public void testModule1Classpath()
110 throws Exception
111 {
112 executeMaven2();
113 InputStream fis = new FileInputStream( new File( basedir, "module-1/.classpath" ) );
114 String classpath = IOUtil.toString( fis );
115 IOUtil.close( fis );
116
117
118 assertContains( "Invalid classpath", classpath, "/refproject-compile" );
119 assertContains( "Invalid classpath", classpath, "refproject-sysdep" );
120 assertContains( "Invalid classpath", classpath, "/refproject-test" );
121 assertContains( "Invalid classpath", classpath, "/refproject-optional" );
122 assertContains( "Invalid classpath", classpath, "/refproject-provided" );
123
124
125 assertContains( "Invalid classpath", classpath, "/deps-refproject-compile" );
126 assertDoesNotContain( "Invalid classpath", classpath, "/deps-refproject-test" );
127 assertDoesNotContain( "Invalid classpath", classpath, "/deps-refproject-optional" );
128 assertDoesNotContain( "Invalid classpath", classpath, "/deps-refproject-provided" );
129
130 }
131
132 public void testModule1Wtpmodules()
133 throws Exception
134 {
135 executeMaven2();
136 assertFileEquals( new File( basedir, "module-1/expected/.wtpmodules" ), new File( basedir,
137 "module-1/.wtpmodules" ) );
138 }
139
140 public void testModule2Project()
141 throws Exception
142 {
143 executeMaven2();
144 assertFileEquals( new File( basedir, "module-2/expected/.project" ), new File( basedir, "module-2/.project" ) );
145 }
146
147 public void testModule2Classpath()
148 throws Exception
149 {
150 executeMaven2();
151 InputStream fis = new FileInputStream( new File( basedir, "module-2/.classpath" ) );
152 String classpath = IOUtil.toString( fis );
153 IOUtil.close( fis );
154
155
156 assertContains( "Invalid classpath", classpath, "/direct-compile" );
157 assertContains( "Invalid classpath", classpath, "/direct-test" );
158 assertContains( "Invalid classpath", classpath, "direct-sysdep" );
159 assertContains( "Invalid classpath", classpath, "/direct-optional" );
160 assertContains( "Invalid classpath", classpath, "/direct-provided" );
161
162
163 assertContains( "Invalid classpath", classpath, "/module-1" );
164
165
166 assertDoesNotContain( "Invalid classpath", classpath, "/refproject-test" );
167 assertDoesNotContain( "Invalid classpath", classpath, "/refproject-optional" );
168 assertDoesNotContain( "Invalid classpath", classpath, "/refproject-provided" );
169
170
171 assertContains( "Invalid classpath", classpath, "/deps-direct-compile" );
172 assertDoesNotContain( "Invalid classpath", classpath, "/deps-direct-test" );
173 assertDoesNotContain( "Invalid classpath", classpath, "/deps-direct-optional" );
174
175 assertDoesNotContain( "Invalid classpath", classpath, "/deps-direct-provided" );
176
177
178 assertContains( "Invalid classpath", classpath, "/deps-refproject-compile" );
179 assertDoesNotContain( "Invalid classpath", classpath, "/deps-refproject-test" );
180 assertDoesNotContain( "Invalid classpath", classpath, "/deps-refproject-optional" );
181 assertDoesNotContain( "Invalid classpath", classpath, "/deps-refproject-provided" );
182 }
183
184 public void testModule2Wtpmodules()
185 throws Exception
186 {
187 executeMaven2();
188 InputStream fis = new FileInputStream( new File( basedir, "module-2/.wtpmodules" ) );
189 String wtpmodules = IOUtil.toString( fis );
190 IOUtil.close( fis );
191
192
193 assertContains( "Invalid wtpmodules", wtpmodules, "/direct-compile" );
194 assertDoesNotContain( "Invalid wtpmodules", wtpmodules, "/direct-test" );
195 assertContains( "Invalid wtpmodules", wtpmodules, "/direct-sysdep" );
196 assertContains( "Invalid wtpmodules", wtpmodules, "/direct-optional" );
197 assertDoesNotContain( "Invalid wtpmodules", wtpmodules, "/direct-provided" );
198
199
200 assertContains( "Invalid wtpmodules", wtpmodules, "/module-1" );
201 assertContains( "Invalid wtpmodules", wtpmodules, "/refproject-compile" );
202 assertContains( "Invalid wtpmodules", wtpmodules, "refproject-sysdep" );
203 assertDoesNotContain( "Invalid wtpmodules", wtpmodules, "/refproject-test" );
204 assertDoesNotContain( "Invalid wtpmodules", wtpmodules, "/refproject-optional" );
205 assertDoesNotContain( "Invalid wtpmodules", wtpmodules, "/refproject-provided" );
206
207
208 assertContains( "Invalid wtpmodules", wtpmodules, "/deps-direct-compile" );
209 assertDoesNotContain( "Invalid wtpmodules", wtpmodules, "/deps-direct-test" );
210 assertDoesNotContain( "Invalid wtpmodules", wtpmodules, "/deps-direct-optional" );
211 assertDoesNotContain( "Invalid wtpmodules", wtpmodules, "/deps-direct-provided" );
212
213
214 assertContains( "Invalid wtpmodules", wtpmodules, "/deps-refproject-compile" );
215 assertDoesNotContain( "Invalid wtpmodules", wtpmodules, "/deps-refproject-test" );
216 assertDoesNotContain( "Invalid wtpmodules", wtpmodules, "/deps-refproject-optional" );
217 assertDoesNotContain( "Invalid wtpmodules", wtpmodules, "/deps-refproject-provided" );
218 }
219
220 }