Lines 1-5
Link Here
|
1 |
/******************************************************************************* |
1 |
/******************************************************************************* |
2 |
* Copyright (c) 2000, 2005 IBM Corporation and others. |
2 |
* Copyright (c) 2000, 2008 IBM Corporation and others. |
3 |
* All rights reserved. This program and the accompanying materials |
3 |
* All rights reserved. This program and the accompanying materials |
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
5 |
* which accompanies this distribution, and is available at |
5 |
* which accompanies this distribution, and is available at |
Lines 13-19
Link Here
|
13 |
import junit.framework.Test; |
13 |
import junit.framework.Test; |
14 |
import junit.framework.TestSuite; |
14 |
import junit.framework.TestSuite; |
15 |
import org.eclipse.core.resources.*; |
15 |
import org.eclipse.core.resources.*; |
16 |
import org.eclipse.core.runtime.CoreException; |
16 |
import org.eclipse.core.runtime.*; |
|
|
17 |
import org.eclipse.core.runtime.jobs.IJobManager; |
18 |
import org.eclipse.core.runtime.jobs.Job; |
17 |
import org.eclipse.core.tests.internal.resources.SimpleNature; |
19 |
import org.eclipse.core.tests.internal.resources.SimpleNature; |
18 |
|
20 |
|
19 |
/** |
21 |
/** |
Lines 59-65
Link Here
|
59 |
try { |
61 |
try { |
60 |
IProjectDescription desc = project.getDescription(); |
62 |
IProjectDescription desc = project.getDescription(); |
61 |
desc.setNatureIds(natures); |
63 |
desc.setNatureIds(natures); |
62 |
int flags = IResource.KEEP_HISTORY; |
64 |
int flags = IResource.KEEP_HISTORY ; |
63 |
if (silent) |
65 |
if (silent) |
64 |
flags |= IResource.AVOID_NATURE_CONFIG; |
66 |
flags |= IResource.AVOID_NATURE_CONFIG; |
65 |
project.setDescription(desc, flags, getMonitor()); |
67 |
project.setDescription(desc, flags, getMonitor()); |
Lines 214-217
Link Here
|
214 |
} |
216 |
} |
215 |
} |
217 |
} |
216 |
} |
218 |
} |
|
|
219 |
|
220 |
/** |
221 |
* Test addition of nature that requires the workspace root. |
222 |
* See bugs 127562 and 128709. |
223 |
*/ |
224 |
public void testBug127562Nature() { |
225 |
IWorkspace ws = ResourcesPlugin.getWorkspace(); |
226 |
IProject project = ws.getRoot().getProject("Project"); |
227 |
ensureExistsInWorkspace(project, true); |
228 |
|
229 |
String[][] valid = getValidNatureSets(); |
230 |
for (int i = 0; i < valid.length; i++) { |
231 |
setNatures("valid: " + i, project, valid[i], false); |
232 |
} |
233 |
|
234 |
// add with AVOID_NATURE_CONFIG |
235 |
String[] currentSet = new String[] {NATURE_127562}; |
236 |
setNatures("1.0", project, currentSet, false, true); |
237 |
|
238 |
// configure the nature using a conflicting scheduling rule |
239 |
IJobManager manager = Job.getJobManager(); |
240 |
try { |
241 |
manager.beginRule(ws.getRuleFactory().modifyRule(project), null); |
242 |
project.getNature(NATURE_127562).configure(); |
243 |
fail("2.0"); |
244 |
} catch (CoreException ex) { |
245 |
fail("2.1"); |
246 |
} catch (IllegalArgumentException ex) { |
247 |
// should throw this kind of exception |
248 |
} finally { |
249 |
manager.endRule(ws.getRuleFactory().modifyRule(project)); |
250 |
} |
251 |
|
252 |
// configure the nature using a non-conflicting scheduling rule |
253 |
try { |
254 |
manager.beginRule(ws.getRoot(), null); |
255 |
project.getNature(NATURE_127562).configure(); |
256 |
} catch (CoreException ex) { |
257 |
fail("3.0"); |
258 |
} finally { |
259 |
manager.endRule(ws.getRoot()); |
260 |
} |
261 |
} |
217 |
} |
262 |
} |