@@ -80,104 +80,59 @@ public static Test suite() {
8080 return suite ;
8181 }
8282
83- public void testAddSaveParticipant () {
83+ public void testAddSaveParticipant () throws Exception {
8484 // get plugin
8585 Bundle bundle = Platform .getBundle (PI_SAVE_PARTICIPANT_1 );
8686 assertTrue ("0.1" , bundle != null );
87- try {
88- bundle .start ();
89- } catch (BundleException e ) {
90- fail ("0.0" , e );
91- }
87+ bundle .start ();
9288 SaveParticipant1Plugin plugin1 = SaveParticipant1Plugin .getInstance ();
9389
9490 // prepare plugin to the save operation
9591 plugin1 .resetDeltaVerifier ();
9692 IStatus status ;
97- try {
98- status = plugin1 .registerAsSaveParticipant ();
99- if (!status .isOK ()) {
100- System .out .println (status .getMessage ());
101- fail ("1.0" );
102- }
103- } catch (CoreException e ) {
104- fail ("1.1" , e );
105- }
93+ status = plugin1 .registerAsSaveParticipant ();
94+ assertTrue ("Registering save participant failed with message: " + status .getMessage (), status .isOK ());
10695 plugin1 .setExpectedSaveKind (ISaveContext .FULL_SAVE );
10796
10897 // SaveParticipant2Plugin
10998 bundle = Platform .getBundle (PI_SAVE_PARTICIPANT_2 );
11099 assertTrue ("5.1" , bundle != null );
111- try {
112- bundle .start ();
113- } catch (BundleException e ) {
114- fail ("5.0" , e );
115- }
100+ bundle .start ();
116101 SaveParticipant2Plugin plugin2 = SaveParticipant2Plugin .getInstance ();
117102
118103 // prepare plugin to the save operation
119104 plugin2 .getDeltaVerifier ().reset ();
120- try {
121- status = plugin2 .registerAsSaveParticipant ();
122- if (!status .isOK ()) {
123- System .out .println (status .getMessage ());
124- fail ("6.0" );
125- }
126- } catch (CoreException e ) {
127- fail ("6.1" , e );
128- }
105+ status = plugin2 .registerAsSaveParticipant ();
106+ assertTrue ("Registering save participant failed with message: " + status .getMessage (), status .isOK ());
129107 plugin1 .setExpectedSaveKind (ISaveContext .FULL_SAVE );
130108
131109 // SaveParticipant3Plugin
132110 bundle = Platform .getBundle (PI_SAVE_PARTICIPANT_3 );
133111 assertTrue ("7.1" , bundle != null );
134- try {
135- bundle .start ();
136- } catch (BundleException e ) {
137- fail ("7.0" , e );
138- }
112+ bundle .start ();
139113 SaveParticipant3Plugin plugin3 = SaveParticipant3Plugin .getInstance ();
140114
141- try {
142- status = plugin3 .registerAsSaveParticipant ();
143- if (!status .isOK ()) {
144- System .out .println (status .getMessage ());
145- fail ("7.2" );
146- }
147- } catch (CoreException e ) {
148- fail ("7.3" , e );
149- }
115+ status = plugin3 .registerAsSaveParticipant ();
116+ assertTrue ("Registering save participant failed with message: " + status .getMessage (), status .isOK ());
150117 }
151118
152119 /**
153120 * Create another project and leave it closed for next session.
154121 */
155- public void testAnotherProject () {
122+ public void testAnotherProject () throws CoreException {
156123 IProject project = getWorkspace ().getRoot ().getProject (PROJECT_1 );
157- try {
158- project .create (null );
159- project .open (null );
160- } catch (CoreException e ) {
161- fail ("0.0" , e );
162- }
124+ project .create (null );
125+ project .open (null );
163126 assertTrue ("0.1" , project .exists ());
164127 assertTrue ("0.2" , project .isOpen ());
165128
166- try {
167- project .close (null );
168- } catch (CoreException e ) {
169- fail ("1.0" , e );
170- }
129+ project .close (null );
171130 assertTrue ("1.1" , project .exists ());
172131 assertTrue ("1.2" , !project .isOpen ());
173132
174133 // when closing and opening the project again, it should still exist
175134 project = getWorkspace ().getRoot ().getProject (PROJECT_1 );
176- try {
177- project .open (null );
178- } catch (CoreException e ) {
179- fail ("2.0" , e );
180- }
135+ project .open (null );
181136 assertTrue ("2.1" , project .exists ());
182137 assertTrue ("2.2" , project .isOpen ());
183138
@@ -187,101 +142,60 @@ public void testAnotherProject() {
187142 assertExistsInFileSystem ("3.1" , resources );
188143 assertExistsInWorkspace ("3.2" , resources );
189144
190- try {
191- project .close (null );
192- project .open (null );
193- } catch (CoreException e ) {
194- fail ("4.0" , e );
195- }
145+ project .close (null );
146+ project .open (null );
196147 assertExistsInFileSystem ("4.1" , resources );
197148 assertExistsInWorkspace ("4.2" , resources );
198149
199- try {
200- getWorkspace ().save (true , null );
201- } catch (CoreException e ) {
202- fail ("5.0" , e );
203- }
150+ getWorkspace ().save (true , null );
204151 }
205152
206- public void testBuilder () {
153+ public void testBuilder () throws CoreException {
207154 IProject project = getWorkspace ().getRoot ().getProject (PROJECT_1 );
208155 assertTrue ("0.0" , project .isAccessible ());
209156
210- try {
211- // Make sure autobuild is on
212- if (!getWorkspace ().isAutoBuilding ()) {
213- IWorkspaceDescription wsDesc = getWorkspace ().getDescription ();
214- wsDesc .setAutoBuilding (true );
215- getWorkspace ().setDescription (wsDesc );
216- }
217- // Create and set a build spec for the project
218- IProjectDescription description = project .getDescription ();
219- ICommand command = description .newCommand ();
220- command .setBuilderName (DeltaVerifierBuilder .BUILDER_NAME );
221- description .setBuildSpec (new ICommand [] {command });
222- project .setDescription (description , null );
223- project .build (IncrementalProjectBuilder .FULL_BUILD , getMonitor ());
224- } catch (CoreException e ) {
225- fail ("2.0" , e );
226- }
157+ setAutoBuilding (true );
158+ // Create and set a build spec for the project
159+ IProjectDescription description = project .getDescription ();
160+ ICommand command = description .newCommand ();
161+ command .setBuilderName (DeltaVerifierBuilder .BUILDER_NAME );
162+ description .setBuildSpec (new ICommand [] {command });
163+ project .setDescription (description , null );
164+ project .build (IncrementalProjectBuilder .FULL_BUILD , getMonitor ());
227165
228166 // close and open the project and see if the builder gets a good delta
229- try {
230- project .close (null );
231- project .open (null );
232- } catch (CoreException e ) {
233- fail ("3.0" , e );
234- }
167+ project .close (null );
168+ project .open (null );
235169 IFile added = project .getFile ("added file" );
236170 waitForBuild ();
237171 DeltaVerifierBuilder verifier = DeltaVerifierBuilder .getInstance ();
238172 verifier .reset ();
239173 verifier .addExpectedChange (added , project , IResourceDelta .ADDED , 0 );
240- try {
241- added .create (getRandomContents (), true , null );
242- } catch (CoreException e ) {
243- fail ("3.1" , e );
244- }
174+ added .create (getRandomContents (), true , null );
245175 waitForBuild ();
246176 assertTrue ("3.2" , verifier .wasAutoBuild ());
247177 assertTrue ("3.3" , verifier .isDeltaValid ());
248178 // remove the file because we don't want it to affect any other delta in the test
249- try {
250- added .delete (true , false , null );
251- } catch (CoreException e ) {
252- fail ("3.4" , e );
253- }
179+ added .delete (true , false , null );
254180 }
255181
256182 /**
257183 * Create some resources and save the workspace.
258184 */
259- public void testCreateMyProject () {
185+ public void testCreateMyProject () throws CoreException {
260186 IProject project = getWorkspace ().getRoot ().getProject (PROJECT_1 );
261- try {
262- project .create (null );
263- project .open (null );
264- } catch (CoreException e ) {
265- fail ("0.0" , e );
266- }
187+ project .create (null );
188+ project .open (null );
267189 assertTrue ("0.1" , project .exists ());
268190 assertTrue ("0.2" , project .isOpen ());
269191
270- try {
271- project .close (null );
272- } catch (CoreException e ) {
273- fail ("1.0" , e );
274- }
192+ project .close (null );
275193 assertTrue ("1.1" , project .exists ());
276194 assertTrue ("1.2" , !project .isOpen ());
277195
278196 // when closing and opening the project again, it should still exist
279197 project = getWorkspace ().getRoot ().getProject (PROJECT_1 );
280- try {
281- project .open (null );
282- } catch (CoreException e ) {
283- fail ("2.0" , e );
284- }
198+ project .open (null );
285199 assertTrue ("2.1" , project .exists ());
286200 assertTrue ("2.2" , project .isOpen ());
287201
@@ -291,27 +205,19 @@ public void testCreateMyProject() {
291205 assertExistsInFileSystem ("3.1" , resources );
292206 assertExistsInWorkspace ("3.2" , resources );
293207
294- try {
295- project .close (null );
296- project .open (null );
297- } catch (CoreException e ) {
298- fail ("4.0" , e );
299- }
208+ project .close (null );
209+ project .open (null );
300210 assertExistsInFileSystem ("4.1" , resources );
301211 assertExistsInWorkspace ("4.2" , resources );
302212 }
303213
304214 /**
305215 * Create another project and leave it closed for next session.
306216 */
307- public void testCreateProject2 () {
217+ public void testCreateProject2 () throws CoreException {
308218 IProject project = getWorkspace ().getRoot ().getProject (PROJECT_2 );
309- try {
310- project .create (null );
311- project .open (null );
312- } catch (CoreException e ) {
313- fail ("0.0" , e );
314- }
219+ project .create (null );
220+ project .open (null );
315221 assertTrue ("0.1" , project .exists ());
316222 assertTrue ("0.2" , project .isOpen ());
317223
@@ -322,42 +228,27 @@ public void testCreateProject2() {
322228 assertExistsInWorkspace ("3.2" , resources );
323229
324230 // add a builder to this project
325- try {
326- IProjectDescription description = project .getDescription ();
327- ICommand command = description .newCommand ();
328- command .setBuilderName (SimpleBuilder .BUILDER_ID );
329- description .setBuildSpec (new ICommand [] {command });
330- project .setDescription (description , null );
331- project .build (IncrementalProjectBuilder .FULL_BUILD , null );
332- } catch (CoreException e ) {
333- fail ("4.0" , e );
334- }
335-
336- try {
337- project .close (null );
338- } catch (CoreException e ) {
339- fail ("5.0" , e );
340- }
231+ IProjectDescription description = project .getDescription ();
232+ ICommand command = description .newCommand ();
233+ command .setBuilderName (SimpleBuilder .BUILDER_ID );
234+ description .setBuildSpec (new ICommand [] {command });
235+ project .setDescription (description , null );
236+ project .build (IncrementalProjectBuilder .FULL_BUILD , null );
237+
238+ project .close (null );
341239 assertTrue ("5.1" , project .exists ());
342240 assertTrue ("5.2" , !project .isOpen ());
343241 }
344242
345- public void testPostSave () {
243+ public void testPostSave () throws BundleException {
346244 // get plugin
347245 Bundle bundle = Platform .getBundle (PI_SAVE_PARTICIPANT_1 );
348246 assertTrue ("0.1" , bundle != null );
349- try {
350- bundle .start ();
351- } catch (BundleException e ) {
352- fail ("0.0" , e );
353- }
247+ bundle .start ();
354248 SaveParticipant1Plugin plugin = SaveParticipant1Plugin .getInstance ();
355249
356250 // look at the plugin save lifecycle
357251 IStatus status = plugin .getSaveLifecycleLog ();
358- if (!status .isOK ()) {
359- System .out .println (status .getMessage ());
360- assertTrue ("1.0" , false );
361- }
252+ assertTrue ("Getting lifecycle log failed with message: " + status .getMessage (), status .isOK ());
362253 }
363254}
0 commit comments