Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 185303 Details for
Bug 307587
NatureManager is NOT threadsafe causing incorrect responses to isNatureEnabled() (and others)
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
Test of parallel importing project and checking isNatureEnabled.
ConcurrentNatureTest.java (text/plain), 3.41 KB, created by
Malgorzata Janczarska
on 2010-12-16 06:05:08 EST
(
hide
)
Description:
Test of parallel importing project and checking isNatureEnabled.
Filename:
MIME Type:
Creator:
Malgorzata Janczarska
Created:
2010-12-16 06:05:08 EST
Size:
3.41 KB
patch
obsolete
>/******************************************************************************* > * Copyright (c) 2010 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at > * http://www.eclipse.org/legal/epl-v10.html > * > * Contributors: > * IBM Corporation - initial API and implementation > *******************************************************************************/ >package org.eclipse.core.tests.resources; > >import java.util.Random; >import junit.framework.TestCase; >import org.eclipse.core.resources.*; >import org.eclipse.core.runtime.CoreException; >import org.eclipse.core.runtime.Path; >import org.eclipse.core.tests.harness.FileSystemHelper; >import org.eclipse.wst.common.project.facet.core.internal.FacetedProjectNature; > >/** > * > */ >public class ConcurrentNatureTest extends TestCase { > private static final String projectName = "Project"; > private static final String projectPath = "/Path/to/your/project"; > private static final String nature = FacetedProjectNature.NATURE_ID; > > protected void setUp() throws Exception { > } > > protected void tearDown() throws Exception { > super.tearDown(); > ResourcesPlugin.getWorkspace().getRoot().refreshLocal(IResource.DEPTH_INFINITE, null); > FileSystemHelper.clear(ResourcesPlugin.getWorkspace().getRoot().getLocation().toFile()); > } > > private class CheckingThread extends Thread { > private Random random; > private int threadNo; > > public CheckingThread(Random random, int threadNo) { > super(); > this.random = random; > this.threadNo = threadNo; > } > > public void run() { > try { > sleep(Math.abs(random.nextLong() % 10)); > IProject project = importProject(projectName+threadNo, projectPath); > System.out.println("Imported " + project.getName() + " Thread" + threadNo); > assertTrue("Thread " + threadNo + " invalid nature " + nature, project.isNatureEnabled(nature)); > project.delete(true, null); > } catch (CoreException e) { > e.printStackTrace(); > fail(); > } catch (InterruptedException e) { > e.printStackTrace(); > fail(); > } > } > } > > protected IProject importProject(String projectName, String locationURI) throws CoreException { > IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName); > IProjectDescription recordDescr = ResourcesPlugin.getWorkspace().loadProjectDescription(new Path(locationURI + "/" + IProjectDescription.DESCRIPTION_FILE_NAME)); > IProjectDescription desc = ResourcesPlugin.getWorkspace().newProjectDescription(projectName); > desc.setBuildSpec(recordDescr.getBuildSpec()); > desc.setComment(recordDescr.getComment()); > desc.setDynamicReferences(recordDescr.getDynamicReferences()); > desc.setNatureIds(recordDescr.getNatureIds()); > desc.setReferencedProjects(recordDescr.getReferencedProjects()); > project.create(desc, IResource.NONE, null); > project.open(null); > return project; > } > > public void testConcurrentNatures() { > > Random random = new Random(); > > int size = 500; > CheckingThread[] threads = new CheckingThread[size]; > for (int i = 0; i < size; i++) { > threads[i] = new CheckingThread(random, i); > threads[i].start(); > } > for (int i = 0; i < size; i++) { > try { > threads[i].join(); > } catch (InterruptedException e) { > fail(); > } > } > > } > >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 307587
:
177513
|
177601
|
177612
|
177643
|
185251
| 185303 |
188503
|
188516
|
189502
|
189520