JBoss Tools SVN: r5539 - in trunk/tests/tests/org.jboss.tools.test: src/org/jboss/tools/test/util and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: dgolovin
Date: 2008-01-09 03:02:43 -0500 (Wed, 09 Jan 2008)
New Revision: 5539
Modified:
trunk/tests/tests/org.jboss.tools.test/META-INF/MANIFEST.MF
trunk/tests/tests/org.jboss.tools.test/src/org/jboss/tools/test/util/ResourcesUtils.java
Log:
Test errors were fixed
Modified: trunk/tests/tests/org.jboss.tools.test/META-INF/MANIFEST.MF
===================================================================
--- trunk/tests/tests/org.jboss.tools.test/META-INF/MANIFEST.MF 2008-01-09 08:02:39 UTC (rev 5538)
+++ trunk/tests/tests/org.jboss.tools.test/META-INF/MANIFEST.MF 2008-01-09 08:02:43 UTC (rev 5539)
@@ -12,5 +12,6 @@
Provide-Package: org.jboss.ide.tests.util
Eclipse-LazyStart: true
Export-Package: org.jboss.tools.test.util,
+ org.jboss.tools.test.util.xpl,
org.jboss.tools.tests
Bundle-ClassPath: tools-tests.jar
Modified: trunk/tests/tests/org.jboss.tools.test/src/org/jboss/tools/test/util/ResourcesUtils.java
===================================================================
--- trunk/tests/tests/org.jboss.tools.test/src/org/jboss/tools/test/util/ResourcesUtils.java 2008-01-09 08:02:39 UTC (rev 5538)
+++ trunk/tests/tests/org.jboss.tools.test/src/org/jboss/tools/test/util/ResourcesUtils.java 2008-01-09 08:02:43 UTC (rev 5539)
@@ -31,6 +31,7 @@
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.swt.widgets.Display;
@@ -113,6 +114,13 @@
return project;
}
+ public static IProject createEclipseProject(String bundle,
+ String templateLocation, IProgressMonitor monitor)
+ throws CoreException, IOException {
+ return createEclipseProject(
+ Platform.getBundle(bundle), templateLocation, monitor);
+ }
+
public static boolean findLineInFile(IFile file, String pattern) throws CoreException, IOException {
InputStream content = file.getContents(true);
LineNumberReader contentReader = new LineNumberReader(new InputStreamReader(content));
@@ -126,4 +134,20 @@
} while (line != null && !patternIsFound);
return patternIsFound;
}
+
+ /**
+ * @param string
+ * @param string2
+ * @param nullProgressMonitor
+ * @return
+ * @throws InterruptedException
+ * @throws InvocationTargetException
+ * @throws CoreException
+ * @throws IOException
+ */
+ public static IProject importProject(String bundleName, String templatePath,
+ NullProgressMonitor monitor) throws IOException, CoreException, InvocationTargetException, InterruptedException {
+ // TODO Auto-generated method stub
+ return importProject(Platform.getBundle(bundleName), templatePath, monitor);
+ }
}
17 years
JBoss Tools SVN: r5538 - in trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test: wizard and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: dgolovin
Date: 2008-01-09 03:02:39 -0500 (Wed, 09 Jan 2008)
New Revision: 5538
Modified:
trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/hyperlink/SeamViewHyperlinkPartitionerTest.java
trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/wizard/SeamProjectNewWizardTest.java
Log:
Test errors were fixed
Modified: trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/hyperlink/SeamViewHyperlinkPartitionerTest.java
===================================================================
--- trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/hyperlink/SeamViewHyperlinkPartitionerTest.java 2008-01-09 08:00:04 UTC (rev 5537)
+++ trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/hyperlink/SeamViewHyperlinkPartitionerTest.java 2008-01-09 08:02:39 UTC (rev 5538)
@@ -11,6 +11,8 @@
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Platform;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IDocumentExtension3;
@@ -30,9 +32,10 @@
import org.jboss.tools.common.text.ext.hyperlink.IHyperlinkRegion;
import org.jboss.tools.common.text.ext.util.AxisUtil;
import org.jboss.tools.seam.text.ext.hyperlink.SeamViewHyperlinkPartitioner;
+import org.jboss.tools.test.util.ResourcesUtils;
public class SeamViewHyperlinkPartitionerTest extends TestCase {
- TestProjectProvider provider = null;
+
IProject project = null;
boolean makeCopy = false;
private static final String PROJECT_NAME = "TestSeamELContentAssist";
@@ -43,21 +46,15 @@
}
public void setUp() throws Exception {
- provider = new TestProjectProvider("org.jboss.tools.seam.ui.test", null, PROJECT_NAME, makeCopy);
- project = provider.getProject();
+ //provider = new TestProjectProvider("", null, PROJECT_NAME, makeCopy);
+ project = ResourcesUtils.importProject(Platform.getBundle("org.jboss.tools.seam.ui.test"), "/projects/TestSeamELContentAssist", new NullProgressMonitor());
Throwable exception = null;
- try {
- project.refreshLocal(IResource.DEPTH_INFINITE, null);
- } catch (Exception x) {
- exception = x;
- x.printStackTrace();
- }
- assertNull("An exception caught: " + (exception != null? exception.getMessage() : ""), exception);
+ project.refreshLocal(IResource.DEPTH_INFINITE, null);
}
protected void tearDown() throws Exception {
- if(provider != null) {
- provider.dispose();
+ if(project != null) {
+ project.delete(true, true, null);
}
}
Modified: trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/wizard/SeamProjectNewWizardTest.java
===================================================================
--- trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/wizard/SeamProjectNewWizardTest.java 2008-01-09 08:00:04 UTC (rev 5537)
+++ trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/wizard/SeamProjectNewWizardTest.java 2008-01-09 08:02:39 UTC (rev 5538)
@@ -26,6 +26,7 @@
import org.eclipse.ui.PlatformUI;
import org.eclipse.wst.common.componentcore.datamodel.properties.IFacetDataModelProperties;
import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
+import org.eclipse.wst.server.core.IServerWorkingCopy;
import org.eclipse.wst.web.ui.internal.wizards.NewProjectDataModelFacetWizard;
import org.jboss.tools.common.util.WorkbenchUtils;
import org.jboss.tools.jst.firstrun.JBossASAdapterInitializer;
@@ -40,9 +41,22 @@
*/
public class SeamProjectNewWizardTest extends TestCase{
+
+ /**
+ *
+ */
+ private static final String SEAM_2_0_0_RT_NAME = "Seam 2.0";
+ /**
+ *
+ */
+ private static final String SEAM_1_2_1_RT_NAME = "Seam 1.2.1";
+ public static final String JBOSS_AS_42_HOME
+ = System.getProperty("jbosstools.test.jboss.home.4.2", "C:\\java\\jboss-4.2.2.GA");
NewProjectDataModelFacetWizard wizard;
IWizardPage startSeamPrjWzPg;
-
+ SeamRuntimeManager manager = SeamRuntimeManager.getInstance();
+
+
@Override
protected void setUp() throws Exception {
super.setUp();
@@ -83,7 +97,9 @@
// Create JBoss AS Runtime, Server, HSQL DB Driver
try {
- JBossASAdapterInitializer.initJBossAS("", new NullProgressMonitor());
+ IServerWorkingCopy server = JBossASAdapterInitializer.initJBossAS(JBOSS_AS_42_HOME, new NullProgressMonitor());
+ System.out.println(server.getName());
+ System.out.println(server.getRuntime().getName());
} catch (CoreException e) {
fail("Cannot create JBoss AS Runtime, Server or HSQL Driver for unexisted AS location to test New Seam Project Wizard. " + e.getMessage());
} catch (ConnectionProfileException e) {
@@ -91,14 +107,12 @@
}
// Create Seam Runtime and set proper field
- SeamRuntimeManager manager = SeamRuntimeManager.getInstance();
-
Bundle seamTest = Platform.getBundle("org.jboss.tools.seam.ui.test");
try {
URL seamUrl = FileLocator.resolve(seamTest.getEntry("/seam"));
File folder = new File(seamUrl.getPath());
- manager.addRuntime("Seam 1.2.1", folder.getAbsolutePath(), SeamVersion.SEAM_1_2, true);
- manager.addRuntime("Seam 2.0", folder.getAbsolutePath(), SeamVersion.SEAM_2_0, true);
+ manager.addRuntime(SEAM_1_2_1_RT_NAME, folder.getAbsolutePath(), SeamVersion.SEAM_1_2, true);
+ manager.addRuntime(SEAM_2_0_0_RT_NAME, folder.getAbsolutePath(), SeamVersion.SEAM_2_0, true);
} catch (IOException e) {
fail("Cannot create Seam Runtime to test New Seam Project Wizard. " + e.getMessage());
}
@@ -122,5 +136,15 @@
assertTrue("Finish button is disabled at first wizard page in spite of created JBoss AS Runtime, Server, DB Connection and Seam Runtime and valid project name.", canFinish);
wizard.performCancel();
+
+ manager.removeRuntime(manager.findRuntimeByName(SEAM_1_2_1_RT_NAME));
+ manager.removeRuntime(manager.findRuntimeByName(SEAM_2_0_0_RT_NAME));
+
}
+
+ @Override
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
}
\ No newline at end of file
17 years
JBoss Tools SVN: r5537 - in trunk/seam/tests/org.jboss.tools.seam.core.test: src/org/jboss/tools/seam/core/test and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: dgolovin
Date: 2008-01-09 03:00:04 -0500 (Wed, 09 Jan 2008)
New Revision: 5537
Modified:
trunk/seam/tests/org.jboss.tools.seam.core.test/META-INF/MANIFEST.MF
trunk/seam/tests/org.jboss.tools.seam.core.test/src/org/jboss/tools/seam/core/test/ScannerTest.java
Log:
EditorTestHelper.joinBackgroundActivities(); used to test how it works.
SetUp method was switched from TestProjectProvider to importProject that creates copy of project in current workspace.
Modified: trunk/seam/tests/org.jboss.tools.seam.core.test/META-INF/MANIFEST.MF
===================================================================
--- trunk/seam/tests/org.jboss.tools.seam.core.test/META-INF/MANIFEST.MF 2008-01-09 07:55:02 UTC (rev 5536)
+++ trunk/seam/tests/org.jboss.tools.seam.core.test/META-INF/MANIFEST.MF 2008-01-09 08:00:04 UTC (rev 5537)
@@ -21,5 +21,8 @@
org.eclipse.ui.workbench,
org.eclipse.wst.common.modulecore,
org.eclipse.wst.common.frameworks,
- org.eclipse.jface
+ org.eclipse.jface,
+ org.jboss.tools.jst.firstrun,
+ org.eclipse.wst.server.core,
+ org.eclipse.datatools.connectivity
Provide-Package: org.jboss.tools.seam.core.test
Modified: trunk/seam/tests/org.jboss.tools.seam.core.test/src/org/jboss/tools/seam/core/test/ScannerTest.java
===================================================================
--- trunk/seam/tests/org.jboss.tools.seam.core.test/src/org/jboss/tools/seam/core/test/ScannerTest.java 2008-01-09 07:55:02 UTC (rev 5536)
+++ trunk/seam/tests/org.jboss.tools.seam.core.test/src/org/jboss/tools/seam/core/test/ScannerTest.java 2008-01-09 08:00:04 UTC (rev 5537)
@@ -50,46 +50,27 @@
import org.jboss.tools.seam.internal.core.scanner.lib.ClassPath;
import org.jboss.tools.seam.internal.core.scanner.lib.LibraryScanner;
import org.jboss.tools.test.util.JUnitUtils;
+import org.jboss.tools.test.util.ResourcesUtils;
+import org.jboss.tools.test.util.xpl.EditorTestHelper;
public class ScannerTest extends TestCase {
- TestProjectProvider provider = null;
IProject project = null;
boolean makeCopy = true;
- public ScannerTest() {}
+ public ScannerTest() {
+ super("Seam Scanner test");
+ }
protected void setUp() throws Exception {
- provider = new TestProjectProvider("org.jboss.tools.seam.core.test", null, "TestScanner", true);
- project = provider.getProject();
- try {
- project.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
- } catch (Exception e) {
- JUnitUtils.fail("Error in refreshing",e);
- }
- try {
- XJob.waitForJob();
- } catch (InterruptedException e) {
- JUnitUtils.fail("Interrupted",e);
- }
+ project = ResourcesUtils.importProject(
+ "org.jboss.tools.seam.core.test","/projects/TestScanner" , new NullProgressMonitor());
+ project.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
+ EditorTestHelper.joinBackgroundActivities();
+ project.build(IncrementalProjectBuilder.FULL_BUILD, new NullProgressMonitor());
+ EditorTestHelper.joinBackgroundActivities();
}
-
+
private ISeamProject getSeamProject() {
- try {
- XJob.waitForJob();
- } catch (Exception e) {
- JUnitUtils.fail("Interrupted",e);
- }
- try {
- project.build(IncrementalProjectBuilder.FULL_BUILD, new NullProgressMonitor());
- try {
- XJob.waitForJob();
- } catch (InterruptedException e) {
- JUnitUtils.fail("Interrupted",e);
- }
- } catch (Exception e) {
- e.printStackTrace();
- JUnitUtils.fail("Cannot build",e);
- }
ISeamProject seamProject = null;
try {
seamProject = (ISeamProject)project.getNature(SeamProject.NATURE_ID);
@@ -321,7 +302,7 @@
try {
project.build(IncrementalProjectBuilder.FULL_BUILD, new NullProgressMonitor());
- XJob.waitForJob();
+ EditorTestHelper.joinBackgroundActivities();
} catch (Exception e) {
JUnitUtils.fail("Cannot build",e);
}
@@ -501,4 +482,9 @@
assertTrue("Component inner_JBIDE_1374 declared in inner static class is not found.", c != null);
}
+ @Override
+ protected void tearDown() throws Exception {
+ EditorTestHelper.joinBackgroundActivities();
+ project.delete(true,true, null);
+ }
}
17 years
JBoss Tools SVN: r5536 - trunk/jst/tests/org.jboss.tools.jst.web.test/src/org/jboss/tools/jst/web/test.
by jbosstools-commits@lists.jboss.org
Author: dgolovin
Date: 2008-01-09 02:55:02 -0500 (Wed, 09 Jan 2008)
New Revision: 5536
Modified:
trunk/jst/tests/org.jboss.tools.jst.web.test/src/org/jboss/tools/jst/web/test/WebContentAssistProviderTest.java
Log:
Test error was fixed
Modified: trunk/jst/tests/org.jboss.tools.jst.web.test/src/org/jboss/tools/jst/web/test/WebContentAssistProviderTest.java
===================================================================
--- trunk/jst/tests/org.jboss.tools.jst.web.test/src/org/jboss/tools/jst/web/test/WebContentAssistProviderTest.java 2008-01-09 07:52:38 UTC (rev 5535)
+++ trunk/jst/tests/org.jboss.tools.jst.web.test/src/org/jboss/tools/jst/web/test/WebContentAssistProviderTest.java 2008-01-09 07:55:02 UTC (rev 5536)
@@ -19,6 +19,7 @@
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IncrementalProjectBuilder;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Platform;
@@ -46,6 +47,7 @@
}
public void testJsfBeanPropertyList() {
+ waitForJobs();
// seam beans list
List beanList = webPromptingProvider.getList(projectModel, WebPromptingProvider.JSF_BEAN_PROPERTIES, "facesManagedBean", new Properties());
assertTrue("Bean property list does not contain Managed bean property in XModel.", beanList.contains("property1"));
@@ -77,11 +79,9 @@
public void setUp() throws Exception {
provider = new TestProjectProvider("org.jboss.tools.jst.web.test", null, "TestsWebArtefacts", makeCopy);
project = provider.getProject();
- try {
- project.refreshLocal(IResource.DEPTH_INFINITE, null);
- } catch (Exception e) {
- ModelPlugin.getPluginLog().logError(e);
- }
+ project.refreshLocal(IResource.DEPTH_INFINITE, null);
+ project.build(IncrementalProjectBuilder.FULL_BUILD,null);
+ waitForJobs();
XModelObject xmo = EclipseResourceUtil.getObjectByResource(project);
assertNotNull("Can't get XModel Object for test project.", xmo);
projectModel = xmo.getModel();
17 years
JBoss Tools SVN: r5535 - trunk/common/tests/org.jboss.tools.common.test/src/org/jboss/tools/common/test/util.
by jbosstools-commits@lists.jboss.org
Author: dgolovin
Date: 2008-01-09 02:52:38 -0500 (Wed, 09 Jan 2008)
New Revision: 5535
Modified:
trunk/common/tests/org.jboss.tools.common.test/src/org/jboss/tools/common/test/util/TestProjectProvider.java
Log:
System.out.println removed
Modified: trunk/common/tests/org.jboss.tools.common.test/src/org/jboss/tools/common/test/util/TestProjectProvider.java
===================================================================
--- trunk/common/tests/org.jboss.tools.common.test/src/org/jboss/tools/common/test/util/TestProjectProvider.java 2008-01-09 07:51:54 UTC (rev 5534)
+++ trunk/common/tests/org.jboss.tools.common.test/src/org/jboss/tools/common/test/util/TestProjectProvider.java 2008-01-09 07:52:38 UTC (rev 5535)
@@ -69,7 +69,6 @@
}
private void init(String bundleName, String projectPath, String name) throws Exception {
- System.out.println("init");
IProject p = ResourcesPlugin.getWorkspace().getRoot().getProject(name);
if(p.exists()) {
project = p;
@@ -79,7 +78,6 @@
}
return;
}
- System.out.println("create");
Bundle bundle = Platform.getBundle(bundleName);
URL url = null;
17 years
JBoss Tools SVN: r5534 - trunk/jst/plugins/org.jboss.tools.jst.firstrun/src/org/jboss/tools/jst/firstrun.
by jbosstools-commits@lists.jboss.org
Author: dgolovin
Date: 2008-01-09 02:51:54 -0500 (Wed, 09 Jan 2008)
New Revision: 5534
Modified:
trunk/jst/plugins/org.jboss.tools.jst.firstrun/src/org/jboss/tools/jst/firstrun/JBossASAdapterInitializer.java
Log:
fix for initJBossAS that always return null
Modified: trunk/jst/plugins/org.jboss.tools.jst.firstrun/src/org/jboss/tools/jst/firstrun/JBossASAdapterInitializer.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.firstrun/src/org/jboss/tools/jst/firstrun/JBossASAdapterInitializer.java 2008-01-09 06:56:37 UTC (rev 5533)
+++ trunk/jst/plugins/org.jboss.tools.jst.firstrun/src/org/jboss/tools/jst/firstrun/JBossASAdapterInitializer.java 2008-01-09 07:51:54 UTC (rev 5534)
@@ -94,7 +94,7 @@
try {
JstFirstRunPlugin.getDefault().getPreferenceStore().setDefault(FIRST_START_PREFERENCE_NAME, true);
boolean firstStart = JstFirstRunPlugin.getDefault().getPreferenceStore().getBoolean(FIRST_START_PREFERENCE_NAME);
- if(!firstStart) {
+ if (!firstStart) {
return;
}
JstFirstRunPlugin.getDefault().getPreferenceStore().setValue(FIRST_START_PREFERENCE_NAME, false);
@@ -102,7 +102,7 @@
String jbossASLocation = null;
String pluginLocation = FileLocator.resolve(JstFirstRunPlugin.getDefault().getBundle().getEntry("/")).getPath();
File jbossASDir = new File(pluginLocation, JBOSS_AS_HOME);
- if(jbossASDir.isDirectory()) {
+ if (jbossASDir.isDirectory()) {
jbossASLocation = jbossASDir.getAbsolutePath();
} else {
return;
@@ -111,48 +111,48 @@
IPath jbossAsLocationPath = new Path(jbossASLocation);
IServer[] servers = ServerCore.getServers();
- for(int i=0; i<servers.length; i++) {
+ for (int i = 0; i < servers.length; i++) {
IRuntime runtime = servers[i].getRuntime();
- if(runtime!=null && runtime.getLocation().equals(jbossAsLocationPath)) {
+ if(runtime != null && runtime.getLocation().equals(jbossAsLocationPath)) {
return;
}
}
IRuntimeWorkingCopy runtime = null;
IRuntime[] runtimes = ServerCore.getRuntimes();
- for(int i=0; i<runtimes.length; i++) {
- if(runtimes[0].getLocation().equals(jbossASLocation)) {
+ for (int i = 0; i < runtimes.length; i++) {
+ if (runtimes[0].getLocation().equals(jbossASLocation)) {
runtime = runtimes[0].createWorkingCopy();
break;
}
}
IProgressMonitor progressMonitor = new NullProgressMonitor();
- if(runtime==null) {
+ if (runtime == null) {
runtime = createRuntime(jbossASLocation, progressMonitor);
}
- if(runtime!=null) {
+ if (runtime != null) {
createServer(progressMonitor, runtime);
}
createDriver(jbossASLocation);
} catch (CoreException e) {
JstFirstRunPlugin.getPluginLog().log(new Status(IStatus.ERROR,
- JstFirstRunPlugin.PLUGIN_ID,"Can't create new JBoss Server", e));
+ JstFirstRunPlugin.PLUGIN_ID, "Can't create new JBoss Server", e));
} catch (IOException e) {
JstFirstRunPlugin.getPluginLog().log(new Status(IStatus.ERROR,
- JstFirstRunPlugin.PLUGIN_ID,"Can't create new JBoss Server", e));
+ JstFirstRunPlugin.PLUGIN_ID, "Can't create new JBoss Server", e));
} catch (ConnectionProfileException e) {
JstFirstRunPlugin.getPluginLog().log(new Status(IStatus.ERROR,
- JstFirstRunPlugin.PLUGIN_ID,"Can't create new DTP " +
- "Connection Profile for JBoss AS Hypersonic embedded database", e));
+ JstFirstRunPlugin.PLUGIN_ID, "Can't create new DTP "
+ + "Connection Profile for JBoss AS Hypersonic embedded database", e));
}
}
/**
* Creates new JBoss AS Runtime, Server and hsqldb driver
* @param jbossASLocation location of JBoss Server
- * @param progressMonitor
+ * @param progressMonitor to report progress
* @return server working copy
* @throws CoreException
* @throws ConnectionProfileException
@@ -160,8 +160,8 @@
public static IServerWorkingCopy initJBossAS(String jbossASLocation, IProgressMonitor progressMonitor) throws CoreException, ConnectionProfileException {
IRuntimeWorkingCopy runtime = createRuntime(jbossASLocation, progressMonitor);
IServerWorkingCopy server = null;
- if(runtime!=null) {
- createServer(progressMonitor, runtime);
+ if (runtime != null) {
+ server = createServer(progressMonitor, runtime);
}
createDriver(jbossASLocation);
return server;
@@ -181,16 +181,16 @@
String runtimeId = null;
IPath jbossAsLocationPath = new Path(jbossASLocation);
IRuntimeType[] runtimeTypes = ServerUtil.getRuntimeTypes(type, version, JBOSS_AS_RUNTIME_TYPE_ID);
- if(runtimeTypes.length>0) {
+ if (runtimeTypes.length > 0) {
runtime = runtimeTypes[0].createRuntime(runtimeId, progressMonitor);
runtime.setLocation(jbossAsLocationPath);
IVMInstall defaultVM = JavaRuntime.getDefaultVMInstall();
// IJBossServerRuntime.PROPERTY_VM_ID
- ((RuntimeWorkingCopy)runtime).setAttribute("PROPERTY_VM_ID", defaultVM.getId());
+ ((RuntimeWorkingCopy) runtime).setAttribute("PROPERTY_VM_ID", defaultVM.getId());
// IJBossServerRuntime.PROPERTY_VM_TYPE_ID
- ((RuntimeWorkingCopy)runtime).setAttribute("PROPERTY_VM_TYPE_ID", defaultVM.getVMInstallType().getId());
+ ((RuntimeWorkingCopy) runtime).setAttribute("PROPERTY_VM_TYPE_ID", defaultVM.getVMInstallType().getId());
// IJBossServerRuntime.PROPERTY_CONFIGURATION_NAME
- ((RuntimeWorkingCopy)runtime).setAttribute("org.jboss.ide.eclipse.as.core.runtime.configurationName", JBOSS_AS_DEFAULT_CONFIGURATION_NAME);
+ ((RuntimeWorkingCopy) runtime).setAttribute("org.jboss.ide.eclipse.as.core.runtime.configurationName", JBOSS_AS_DEFAULT_CONFIGURATION_NAME);
runtime.save(false, progressMonitor);
}
@@ -212,11 +212,11 @@
server.setName(JBOSS_AS_NAME);
// JBossServer.DEPLOY_DIRECTORY
String deployVal = runtime.getLocation().append("server").append(JBOSS_AS_DEFAULT_CONFIGURATION_NAME).append("deploy").toOSString();
- ((ServerWorkingCopy)server).setAttribute("org.jboss.ide.eclipse.as.core.server.deployDirectory", deployVal);
+ ((ServerWorkingCopy) server).setAttribute("org.jboss.ide.eclipse.as.core.server.deployDirectory", deployVal);
// IDeployableServer.TEMP_DEPLOY_DIRECTORY
String deployTmpFolderVal = runtime.getLocation().append("server").append(JBOSS_AS_DEFAULT_CONFIGURATION_NAME).append("tmp").append("jbosstoolsTemp").toOSString();
- ((ServerWorkingCopy)server).setAttribute("org.jboss.ide.eclipse.as.core.server.tempDeployDirectory", deployTmpFolderVal);
+ ((ServerWorkingCopy) server).setAttribute("org.jboss.ide.eclipse.as.core.server.tempDeployDirectory", deployTmpFolderVal);
// If we'd need to set up a username / pw for JMX, do it here.
// ((ServerWorkingCopy)serverWC).setAttribute(JBossServer.SERVER_USERNAME, authUser);
@@ -260,7 +260,7 @@
}
driver = DriverManager.getInstance().getDriverInstanceByName(HSQL_DRIVER_NAME);
- if (driver != null) {
+ if (driver != null && ProfileManager.getInstance().getProfileByName("DefaultDS") == null) {
// create profile
Properties props = new Properties();
props.setProperty(ConnectionProfileConstants.PROP_DRIVER_DEFINITION_ID, HSQL_DRIVER_DEFINITION_ID);
17 years
JBoss Tools SVN: r5533 - in trunk/jsf/tests/org.jboss.tools.jsf.vpe.facelets.test: src/org/jboss/tools/jsf/vpe/facelets/test and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: dgolovin
Date: 2008-01-09 01:56:37 -0500 (Wed, 09 Jan 2008)
New Revision: 5533
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.facelets.test/resources/faceletstest.jar
trunk/jsf/tests/org.jboss.tools.jsf.vpe.facelets.test/src/org/jboss/tools/jsf/vpe/facelets/test/FaceletsComponentTest.java
Log:
http://jira.jboss.com/jira/browse/JBIDE-1504
comments TODO and proposed assets added
Modified: trunk/jsf/tests/org.jboss.tools.jsf.vpe.facelets.test/resources/faceletstest.jar
===================================================================
(Binary files differ)
Modified: trunk/jsf/tests/org.jboss.tools.jsf.vpe.facelets.test/src/org/jboss/tools/jsf/vpe/facelets/test/FaceletsComponentTest.java
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.vpe.facelets.test/src/org/jboss/tools/jsf/vpe/facelets/test/FaceletsComponentTest.java 2008-01-09 00:57:00 UTC (rev 5532)
+++ trunk/jsf/tests/org.jboss.tools.jsf.vpe.facelets.test/src/org/jboss/tools/jsf/vpe/facelets/test/FaceletsComponentTest.java 2008-01-09 06:56:37 UTC (rev 5533)
@@ -118,17 +118,62 @@
}
public void testInsert() throws PartInitException, Throwable {
- performTestForFaceletComponent("insert.xhtml"); // $NON-NLS-1$
+ performTestForFaceletComponent("insert.xhtml"); // $NON-NLS-1$
}
public void testDefine() throws PartInitException, Throwable {
- performTestForFaceletComponent("define.xhtml"); // $NON-NLS-1$
+ performTestForFaceletComponent("define.xhtml"); // $NON-NLS-1$
+ // TODO check that content from ui:defime element is shown
+ assertTrue("Defined content is not shown",false);
}
public void testComposite() throws PartInitException, Throwable {
- performTestForFaceletComponent("composition.xhtml"); // $NON-NLS-1$
+ performTestForFaceletComponent("composition.xhtml"); // $NON-NLS-1$
+ // TODO check that related and absolute path is processed
+ assertTrue("Template with absolute path is not included",false);
+ assertTrue("Template with related path is not included",false);
}
+ public void testComponent() throws PartInitException, Throwable {
+ performTestForFaceletComponent("component.xhtml"); // $NON-NLS-1$
+ // TODO check that content from ui:defime element is shown
+ //assertTrue("Component's content is not shown",false);
+ }
+
+ public void testRemove() throws PartInitException, Throwable {
+ performTestForFaceletComponent("remove.xhtml"); // $NON-NLS-1$
+ // TODO check that content in ui:remove isn't shown in VPE
+ assertTrue("Content inside ui:remove tag shouldn't be shown",false);
+ }
+
+ public void testDecorate() throws PartInitException, Throwable {
+ performTestForFaceletComponent("decorate.xhtml"); // $NON-NLS-1$
+ // TODO check that related and absolute path is processed
+ assertTrue("Template with absolute path is not included",false);
+ assertTrue("Template with related path is not included",false);
+ }
+
+ public void testRepeat() throws PartInitException, Throwable {
+ performTestForFaceletComponent("repeat.xhtml"); // $NON-NLS-1$
+ assertTrue("Component's content is not shown",false);
+ }
+
+ public void testDebug() throws PartInitException, Throwable {
+ performTestForFaceletComponent("debug.xhtml"); // $NON-NLS-1$
+ }
+
+ public void testInclude() throws PartInitException, Throwable {
+ performTestForFaceletComponent("include.xhtml"); // $NON-NLS-1$
+ // TODO check that absolute and related path is processed
+ assertTrue("Template with absolute path is not included",false);
+ assertTrue("Template with related path is not included",false);
+ }
+
+ public void testFragment() throws PartInitException, Throwable {
+ performTestForFaceletComponent("fragment.xhtml"); // $NON-NLS-1$
+ // TODO check that fragment's content is showed
+ assertTrue("Fragment's content is not sown",false);
+ }
private void performTestForFaceletComponent(String componentPage)
throws PartInitException, Throwable {
waitForJobs();
17 years
JBoss Tools SVN: r5532 - trunk/tests/tests/org.jboss.tools.test/src/org/jboss/tools/test/util/xpl.
by jbosstools-commits@lists.jboss.org
Author: dgolovin
Date: 2008-01-08 19:57:00 -0500 (Tue, 08 Jan 2008)
New Revision: 5532
Added:
trunk/tests/tests/org.jboss.tools.test/src/org/jboss/tools/test/util/xpl/DisplayHelper.java
trunk/tests/tests/org.jboss.tools.test/src/org/jboss/tools/test/util/xpl/DisplayWaiter.java
trunk/tests/tests/org.jboss.tools.test/src/org/jboss/tools/test/util/xpl/EditorTestHelper.java
Log:
Test Utils to be able Join to background tasks and delay in UI threads. Classes were taken from org.eclipse.ui.tests.navigator plugin on :pserver:anonymous@dev.eclipse.org:/cvsroot/eclipse/org.eclipse.ui.tests.navigator
Added: trunk/tests/tests/org.jboss.tools.test/src/org/jboss/tools/test/util/xpl/DisplayHelper.java
===================================================================
--- trunk/tests/tests/org.jboss.tools.test/src/org/jboss/tools/test/util/xpl/DisplayHelper.java (rev 0)
+++ trunk/tests/tests/org.jboss.tools.test/src/org/jboss/tools/test/util/xpl/DisplayHelper.java 2008-01-09 00:57:00 UTC (rev 5532)
@@ -0,0 +1,222 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2005 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.jboss.tools.test.util.xpl;
+
+import org.eclipse.swt.widgets.Display;
+
+/**
+ * Runs the event loop of the given display until {@link #condition()} becomes
+ * <code>true</code> or no events have occurred for the supplied timeout.
+ * Between running the event loop, {@link Display#sleep()} is called.
+ * <p>
+ * There is a caveat: the given timeouts must be long enough that the calling
+ * thread can enter <code>Display.sleep()</code> before the timeout elapses,
+ * otherwise, the waiter may time out before <code>sleep</code> is called and
+ * the sleeping thread may never be waken up.
+ * </p>
+ *
+ * @since 3.1
+ */
+public abstract class DisplayHelper {
+ /**
+ * Creates a new instance.
+ */
+ protected DisplayHelper() {
+ }
+
+ /**
+ * Until {@link #condition()} becomes <code>true</code> or the timeout
+ * elapses, call {@link Display#sleep()} and run the event loop.
+ * <p>
+ * If <code>timeout < 0</code>, the event loop is never driven and
+ * only the condition is checked. If <code>timeout == 0</code>, the event
+ * loop is driven at most once, but <code>Display.sleep()</code> is never
+ * invoked.
+ * </p>
+ *
+ * @param display the display to run the event loop of
+ * @param timeout the timeout in milliseconds
+ * @return <code>true</code> if the condition became <code>true</code>,
+ * <code>false</code> if the timeout elapsed
+ */
+ public final boolean waitForCondition(Display display, long timeout) {
+ // if the condition already holds, succeed
+ if (condition())
+ return true;
+
+ if (timeout < 0)
+ return false;
+
+ // if driving the event loop once makes the condition hold, succeed
+ // without spawning a thread.
+ driveEventQueue(display);
+ if (condition())
+ return true;
+
+ // if the timeout is negative or zero, fail
+ if (timeout == 0)
+ return false;
+
+ // repeatedly sleep until condition becomes true or timeout elapses
+ DisplayWaiter waiter= new DisplayWaiter(display);
+ DisplayWaiter.Timeout timeoutState= waiter.start(timeout);
+ boolean condition;
+ try {
+ do {
+ if (display.sleep())
+ driveEventQueue(display);
+ condition= condition();
+ } while (!condition && !timeoutState.hasTimedOut());
+ } finally {
+ waiter.stop();
+ }
+ return condition;
+ }
+
+ /**
+ * Call {@link Display#sleep()} and run the event loop until the given
+ * timeout has elapsed.
+ * <p>
+ * If <code>timeout < 0</code>, nothing happens. If
+ * <code>timeout == 0</code>, the event loop is driven exactly once, but
+ * <code>Display.sleep()</code> is never invoked.
+ * </p>
+ *
+ * @param display the display to run the event loop of
+ * @param millis the timeout in milliseconds
+ */
+ public static void sleep(Display display, long millis) {
+ new DisplayHelper() {
+ public boolean condition() {
+ return false;
+ }
+ }.waitForCondition(display, millis);
+ }
+
+ /**
+ * Call {@link Display#sleep()} and run the event loop once if
+ * <code>sleep</code> returns before the timeout elapses. Returns
+ * <code>true</code> if any events were processed, <code>false</code> if
+ * not.
+ * <p>
+ * If <code>timeout < 0</code>, nothing happens and false is returned.
+ * If <code>timeout == 0</code>, the event loop is driven exactly once,
+ * but <code>Display.sleep()</code> is never invoked.
+ * </p>
+ *
+ * @param display the display to run the event loop of
+ * @param timeout the timeout in milliseconds
+ * @return <code>true</code> if any event was taken off the event queue,
+ * <code>false</code> if not
+ */
+ public static boolean runEventLoop(Display display, long timeout) {
+ if (timeout < 0)
+ return false;
+
+ if (timeout == 0)
+ return driveEventQueue(display);
+
+ // repeatedly sleep until condition becomes true or timeout elapses
+ DisplayWaiter waiter= new DisplayWaiter(display);
+ DisplayWaiter.Timeout timeoutState= waiter.start(timeout);
+ boolean events= false;
+ if (display.sleep() && !timeoutState.hasTimedOut()) {
+ driveEventQueue(display);
+ events= true;
+ }
+ waiter.stop();
+ return events;
+ }
+
+ /**
+ * The condition which has to be met in order for
+ * {@link #waitForCondition(Display, int)} to return before the timeout
+ * elapses.
+ *
+ * @return <code>true</code> if the condition is met, <code>false</code>
+ * if the event loop should be driven some more
+ */
+ protected abstract boolean condition();
+
+ /**
+ * Runs the event loop on the given display.
+ *
+ * @param display the display
+ * @return if <code>display.readAndDispatch</code> returned
+ * <code>true</code> at least once
+ */
+ private static boolean driveEventQueue(Display display) {
+ boolean events= false;
+ while (display.readAndDispatch()) {
+ events= true;
+ }
+ return events;
+ }
+
+ /**
+ * Until {@link #condition()} becomes <code>true</code> or the timeout
+ * elapses, call {@link Display#sleep()} and run the event loop.
+ * <p>
+ * If <code>timeout < 0</code>, the event loop is never driven and
+ * only the condition is checked. If <code>timeout == 0</code>, the event
+ * loop is driven at most once, but <code>Display.sleep()</code> is never
+ * invoked.
+ * </p>
+ * <p>
+ * The condition gets rechecked every <code>interval</code> milliseconds, even
+ * if no events were read from the queue.
+ * </p>
+ *
+ * @param display the display to run the event loop of
+ * @param timeout the timeout in milliseconds
+ * @param interval the interval to re-check the condition in milliseconds
+ * @return <code>true</code> if the condition became <code>true</code>,
+ * <code>false</code> if the timeout elapsed
+ */
+ public final boolean waitForCondition(Display display, long timeout, long interval) {
+ // if the condition already holds, succeed
+ if (condition())
+ return true;
+
+ if (timeout < 0)
+ return false;
+
+ // if driving the event loop once makes the condition hold, succeed
+ // without spawning a thread.
+ driveEventQueue(display);
+ if (condition())
+ return true;
+
+ // if the timeout is negative or zero, fail
+ if (timeout == 0)
+ return false;
+
+ // repeatedly sleep until condition becomes true or timeout elapses
+ DisplayWaiter waiter= new DisplayWaiter(display, true);
+ long currentTimeMillis= System.currentTimeMillis();
+ long finalTimeout= timeout + currentTimeMillis;
+ if (finalTimeout < currentTimeMillis)
+ finalTimeout= Long.MAX_VALUE;
+ boolean condition;
+ try {
+ do {
+ waiter.restart(interval);
+ if (display.sleep())
+ driveEventQueue(display);
+ condition= condition();
+ } while (!condition && finalTimeout > System.currentTimeMillis());
+ } finally {
+ waiter.stop();
+ }
+ return condition;
+ }
+
+}
\ No newline at end of file
Property changes on: trunk/tests/tests/org.jboss.tools.test/src/org/jboss/tools/test/util/xpl/DisplayHelper.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/tests/tests/org.jboss.tools.test/src/org/jboss/tools/test/util/xpl/DisplayWaiter.java
===================================================================
--- trunk/tests/tests/org.jboss.tools.test/src/org/jboss/tools/test/util/xpl/DisplayWaiter.java (rev 0)
+++ trunk/tests/tests/org.jboss.tools.test/src/org/jboss/tools/test/util/xpl/DisplayWaiter.java 2008-01-09 00:57:00 UTC (rev 5532)
@@ -0,0 +1,410 @@
+/*******************************************************************************
+ * Copyright (c) 2005 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.jboss.tools.test.util.xpl;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import junit.framework.Assert;
+
+import org.eclipse.swt.widgets.Display;
+
+/**
+ * Implements the thread that will wait for the timeout and wake up the display
+ * so it does not wait forever. The thread may be restarted after it was stopped
+ * or timed out.
+ *
+ * @since 3.1
+ */
+final class DisplayWaiter {
+ /**
+ * Timeout state of a display waiter thread.
+ */
+ public final class Timeout {
+ boolean fTimeoutState= false;
+ /**
+ * Returns <code>true</code> if the timeout has been reached,
+ * <code>false</code> if not.
+ *
+ * @return <code>true</code> if the timeout has been reached,
+ * <code>false</code> if not
+ */
+ public boolean hasTimedOut() {
+ synchronized (fMutex) {
+ return fTimeoutState;
+ }
+ }
+ void setTimedOut(boolean timedOut) {
+ fTimeoutState= timedOut;
+ }
+ Timeout(boolean initialState) {
+ fTimeoutState= initialState;
+ }
+ }
+
+ // configuration
+ private final Display fDisplay;
+ private final Object fMutex= new Object();
+ private final boolean fKeepRunningOnTimeout;
+
+ /* State -- possible transitions:
+ *
+ * STOPPED -> RUNNING
+ * RUNNING -> STOPPED
+ * RUNNING -> IDLE
+ * IDLE -> RUNNING
+ * IDLE -> STOPPED
+ */
+ private static final int RUNNING= 1 << 1;
+ private static final int STOPPED= 1 << 2;
+ private static final int IDLE= 1 << 3;
+
+ /** The current state. */
+ private int fState;
+ /** The time in milliseconds (see Date) that the timeout will occur. */
+ private long fNextTimeout;
+ /** The thread. */
+ private Thread fCurrentThread;
+ /** The timeout state of the current thread. */
+ private Timeout fCurrentTimeoutState;
+
+ /**
+ * Creates a new instance on the given display and timeout.
+ *
+ * @param display the display to run the event loop of
+ */
+ public DisplayWaiter(Display display) {
+ this(display, false);
+ }
+
+ /**
+ * Creates a new instance on the given display and timeout.
+ *
+ * @param display the display to run the event loop of
+ * @param keepRunning <code>true</code> if the thread should be kept
+ * running after timing out
+ */
+ public DisplayWaiter(Display display, boolean keepRunning) {
+ Assert.assertNotNull(display);
+ fDisplay= display;
+ fState= STOPPED;
+ fKeepRunningOnTimeout= keepRunning;
+ }
+
+ /**
+ * Starts the timeout thread if it is not currently running. Nothing happens
+ * if a thread is already running.
+ *
+ * @param delay the delay from now in milliseconds
+ * @return the timeout state which can be queried for its timed out status
+ */
+ public Timeout start(long delay) {
+ Assert.assertTrue(delay > 0);
+ synchronized (fMutex) {
+ switch (fState) {
+ case STOPPED:
+ startThread();
+ setNextTimeout(delay);
+ break;
+ case IDLE:
+ unhold();
+ setNextTimeout(delay);
+ break;
+ }
+
+ return fCurrentTimeoutState;
+ }
+ }
+
+ /**
+ * Sets the next timeout to <em>current time</em> plus <code>delay</code>.
+ *
+ * @param delay the delay until the next timeout occurs in milliseconds from
+ * now
+ */
+ private void setNextTimeout(long delay) {
+ long currentTimeMillis= System.currentTimeMillis();
+ long next= currentTimeMillis + delay;
+ if (next > currentTimeMillis)
+ fNextTimeout= next;
+ else
+ fNextTimeout= Long.MAX_VALUE;
+ }
+
+ /**
+ * Starts the thread if it is not currently running; resets the timeout if
+ * it is.
+ *
+ * @param delay the delay from now in milliseconds
+ * @return the timeout state which can be queried for its timed out status
+ */
+ public Timeout restart(long delay) {
+ Assert.assertTrue(delay > 0);
+ synchronized (fMutex) {
+ switch (fState) {
+ case STOPPED:
+ startThread();
+ break;
+ case IDLE:
+ unhold();
+ break;
+ }
+ setNextTimeout(delay);
+
+ return fCurrentTimeoutState;
+ }
+ }
+
+ /**
+ * Stops the thread if it is running. If not, nothing happens. Another
+ * thread may be started by calling {@link #start(long)} or
+ * {@link #restart(long)}.
+ */
+ public void stop() {
+ synchronized (fMutex) {
+ if (tryTransition(RUNNING | IDLE, STOPPED))
+ fMutex.notifyAll();
+ }
+ }
+
+ /**
+ * Puts the reaper thread on hold but does not stop it. It may be restarted
+ * by calling {@link #start(long)} or {@link #restart(long)}.
+ */
+ public void hold() {
+ synchronized (fMutex) {
+ // nothing to do if there is no thread
+ if (tryTransition(RUNNING, IDLE))
+ fMutex.notifyAll();
+ }
+ }
+
+ /**
+ * Transition to <code>RUNNING</code> and clear the timed out flag. Assume
+ * current state is <code>IDLE</code>.
+ */
+ private void unhold() {
+ checkedTransition(IDLE, RUNNING);
+ fCurrentTimeoutState= new Timeout(false);
+ fMutex.notifyAll();
+ }
+
+ /**
+ * Start the thread. Assume the current state is <code>STOPPED</code>.
+ */
+ private void startThread() {
+ checkedTransition(STOPPED, RUNNING);
+ fCurrentTimeoutState= new Timeout(false);
+ fCurrentThread= new Thread() {
+ /**
+ * Exception thrown when a thread notices that it has been stopped
+ * and a new thread has been started.
+ */
+ final class ThreadChangedException extends Exception {
+ private static final long serialVersionUID= 1L;
+ }
+
+ /*
+ * @see java.lang.Runnable#run()
+ */
+ public void run() {
+ try {
+ run2();
+ } catch (InterruptedException e) {
+ // ignore and end the thread - we never interrupt ourselves,
+ // so it must be an external entity that interrupted us
+ Logger.global.log(Level.FINE, "", e); //$NON-NLS-1$
+ } catch (ThreadChangedException e) {
+ // the thread was stopped and restarted before we got out
+ // of a wait - we're no longer used
+ // we might have been notified instead of the current thread,
+ // so wake it up
+ Logger.global.log(Level.FINE, "", e); //$NON-NLS-1$
+ synchronized (fMutex) {
+ fMutex.notifyAll();
+ }
+ }
+ }
+
+ /**
+ * Runs the thread.
+ *
+ * @throws InterruptedException if the thread was interrupted
+ * @throws ThreadChangedException if the thread changed
+ */
+ private void run2() throws InterruptedException, ThreadChangedException {
+ synchronized (fMutex) {
+ checkThread();
+ tryHold(); // wait / potential state change
+ assertStates(STOPPED | RUNNING);
+
+ while (isState(RUNNING)) {
+ waitForTimeout(); // wait / potential state change
+
+ if (isState(RUNNING))
+ timedOut(); // state change
+ assertStates(STOPPED | IDLE);
+
+ tryHold(); // wait / potential state change
+ assertStates(STOPPED | RUNNING);
+ }
+ assertStates(STOPPED);
+ }
+ }
+
+ /**
+ * Check whether the current thread is this thread, throw an
+ * exception otherwise.
+ *
+ * @throws ThreadChangedException if the current thread changed
+ */
+ private void checkThread() throws ThreadChangedException {
+ if (fCurrentThread != this)
+ throw new ThreadChangedException();
+ }
+
+ /**
+ * Waits until the next timeout occurs.
+ *
+ * @throws InterruptedException if the thread was interrupted
+ * @throws ThreadChangedException if the thread changed
+ */
+ private void waitForTimeout() throws InterruptedException, ThreadChangedException {
+ long delta;
+ while (isState(RUNNING) && (delta = fNextTimeout - System.currentTimeMillis()) > 0) {
+ delta= Math.max(delta, 50); // wait at least 50ms in order to avoid timing out before the display is going to sleep
+ Logger.global.finest("sleeping for " + delta + "ms"); //$NON-NLS-1$ //$NON-NLS-2$
+ fMutex.wait(delta);
+ checkThread();
+ }
+ }
+
+ /**
+ * Sets the timed out flag and wakes up the display. Transitions to
+ * <code>IDLE</code> (if in keep-running mode) or
+ * <code>STOPPED</code>.
+ */
+ private void timedOut() {
+ Logger.global.finer("timed out"); //$NON-NLS-1$
+ fCurrentTimeoutState.setTimedOut(true);
+ fDisplay.wake(); // wake up call!
+ if (fKeepRunningOnTimeout)
+ checkedTransition(RUNNING, IDLE);
+ else
+ checkedTransition(RUNNING, STOPPED);
+ }
+
+ /**
+ * Waits while the state is <code>IDLE</code>, then returns. The
+ * state must not be <code>RUNNING</code> when calling this
+ * method. The state is either <code>STOPPED</code> or
+ * <code>RUNNING</code> when the method returns.
+ *
+ * @throws InterruptedException if the thread was interrupted
+ * @throws ThreadChangedException if the thread has changed while on
+ * hold
+ */
+ private void tryHold() throws InterruptedException, ThreadChangedException {
+ while (isState(IDLE)) {
+ fMutex.wait(0);
+ checkThread();
+ }
+ assertStates(STOPPED | RUNNING);
+ }
+ };
+
+ fCurrentThread.start();
+ }
+
+ /**
+ * Transitions to <code>nextState</code> if the current state is one of
+ * <code>possibleStates</code>. Returns <code>true</code> if the
+ * transition happened, <code>false</code> otherwise.
+ *
+ * @param possibleStates the states which trigger a transition
+ * @param nextState the state to transition to
+ * @return <code>true</code> if the transition happened,
+ * <code>false</code> otherwise
+ */
+ private boolean tryTransition(int possibleStates, int nextState) {
+ if (isState(possibleStates)) {
+ Logger.global.finer(name(fState) + " > " + name(nextState) + " (" + name(possibleStates) + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ fState= nextState;
+ return true;
+ }
+ Logger.global.finest("noTransition" + name(fState) + " !> " + name(nextState) + " (" + name(possibleStates) + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ return false;
+ }
+
+ /**
+ * Checks the <code>possibleStates</code> and throws an assertion if it is
+ * not met, then transitions to <code>nextState</code>.
+ *
+ * @param possibleStates the allowed states
+ * @param nextState the state to transition to
+ */
+ private void checkedTransition(int possibleStates, int nextState) {
+ assertStates(possibleStates);
+ Logger.global.finer(name(fState) + " > " + name(nextState)); //$NON-NLS-1$
+ fState= nextState;
+ }
+
+ /**
+ * Implements state consistency checking.
+ *
+ * @param states the allowed states
+ * @throws junit.framework.AssertionFailedError if the current state is not
+ * in <code>states</code>
+ */
+ private void assertStates(int states) {
+ Assert.assertTrue("illegal state", isState(states)); //$NON-NLS-1$
+ }
+
+ /**
+ * Answers <code>true</code> if the current state is in the given
+ * <code>states</code>.
+ *
+ * @param states the possible states
+ * @return <code>true</code> if the current state is in the given states,
+ * <code>false</code> otherwise
+ */
+ private boolean isState(int states) {
+ return (states & fState) == fState;
+ }
+
+ /**
+ * Pretty print the given states.
+ *
+ * @param states the states
+ * @return a string representation of the states
+ */
+ private String name(int states) {
+ StringBuffer buf= new StringBuffer();
+ boolean comma= false;
+ if ((states & RUNNING) == RUNNING) {
+ buf.append("RUNNING"); //$NON-NLS-1$
+ comma= true;
+ }
+ if ((states & STOPPED) == STOPPED) {
+ if (comma)
+ buf.append(","); //$NON-NLS-1$
+ buf.append("STOPPED"); //$NON-NLS-1$
+ comma= true;
+ }
+ if ((states & IDLE) == IDLE) {
+ if (comma)
+ buf.append(","); //$NON-NLS-1$
+ buf.append("IDLE"); //$NON-NLS-1$
+ }
+ return buf.toString();
+ }
+
+}
\ No newline at end of file
Property changes on: trunk/tests/tests/org.jboss.tools.test/src/org/jboss/tools/test/util/xpl/DisplayWaiter.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/tests/tests/org.jboss.tools.test/src/org/jboss/tools/test/util/xpl/EditorTestHelper.java
===================================================================
--- trunk/tests/tests/org.jboss.tools.test/src/org/jboss/tools/test/util/xpl/EditorTestHelper.java (rev 0)
+++ trunk/tests/tests/org.jboss.tools.test/src/org/jboss/tools/test/util/xpl/EditorTestHelper.java 2008-01-09 00:57:00 UTC (rev 5532)
@@ -0,0 +1,265 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 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.jboss.tools.test.util.xpl;
+
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.logging.Logger;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.jobs.IJobManager;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IEditorReference;
+import org.eclipse.ui.IViewReference;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IWorkbenchPartSite;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.WorkbenchException;
+
+
+/**
+ * @since 3.1
+ */
+public class EditorTestHelper {
+
+
+
+ public static final String TEXT_EDITOR_ID= "org.eclipse.ui.DefaultTextEditor"; //$NON-NLS-1$
+
+ public static final String COMPILATION_UNIT_EDITOR_ID= "org.eclipse.jdt.ui.CompilationUnitEditor"; //$NON-NLS-1$
+
+ public static final String RESOURCE_PERSPECTIVE_ID= "org.eclipse.ui.resourcePerspective"; //$NON-NLS-1$
+
+ public static final String JAVA_PERSPECTIVE_ID= "org.eclipse.jdt.ui.JavaPerspective"; //$NON-NLS-1$
+
+ public static final String OUTLINE_VIEW_ID= "org.eclipse.ui.views.ContentOutline"; //$NON-NLS-1$
+
+ public static final String PACKAGE_EXPLORER_VIEW_ID= "org.eclipse.jdt.ui.PackageExplorer"; //$NON-NLS-1$
+
+ public static final String NAVIGATOR_VIEW_ID= "org.eclipse.ui.views.ResourceNavigator"; //$NON-NLS-1$
+
+ public static final String INTRO_VIEW_ID= "org.eclipse.ui.internal.introview"; //$NON-NLS-1$
+
+ public static void closeEditor(IEditorPart editor) {
+ IWorkbenchPartSite site;
+ IWorkbenchPage page;
+ if (editor != null && (site= editor.getSite()) != null && (page= site.getPage()) != null)
+ page.closeEditor(editor, false);
+ }
+
+ public static void closeAllEditors() {
+ IWorkbenchWindow[] windows= PlatformUI.getWorkbench().getWorkbenchWindows();
+ for (int i= 0; i < windows.length; i++) {
+ IWorkbenchPage[] pages= windows[i].getPages();
+ for (int j= 0; j < pages.length; j++) {
+ IEditorReference[] editorReferences= pages[j].getEditorReferences();
+ for (int k= 0; k < editorReferences.length; k++)
+ closeEditor(editorReferences[k].getEditor(false));
+ }
+ }
+ }
+
+ /**
+ * Runs the event queue on the current display until it is empty.
+ */
+ public static void runEventQueue() {
+ IWorkbenchWindow window= getActiveWorkbenchWindow();
+ if (window != null)
+ runEventQueue(window.getShell());
+ }
+
+ public static void runEventQueue(IWorkbenchPart part) {
+ runEventQueue(part.getSite().getShell());
+ }
+
+ public static void runEventQueue(Shell shell) {
+ runEventQueue(shell.getDisplay());
+ }
+
+ public static void runEventQueue(Display display) {
+ while (display.readAndDispatch()) {
+ // do nothing
+ }
+ }
+
+ /**
+ * Runs the event queue on the current display and lets it sleep until the
+ * timeout elapses.
+ *
+ * @param millis the timeout in milliseconds
+ */
+ public static void runEventQueue(long millis) {
+ runEventQueue(getActiveDisplay(), millis);
+ }
+
+ public static void runEventQueue(IWorkbenchPart part, long millis) {
+ runEventQueue(part.getSite().getShell(), millis);
+ }
+
+ public static void runEventQueue(Shell shell, long millis) {
+ runEventQueue(shell.getDisplay(), millis);
+ }
+
+ public static void runEventQueue(Display display, long minTime) {
+ if (display != null) {
+ DisplayHelper.sleep(display, minTime);
+ } else {
+ sleep((int) minTime);
+ }
+ }
+
+ public static IWorkbenchWindow getActiveWorkbenchWindow() {
+ return PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+ }
+
+ public static void forceFocus() {
+ IWorkbenchWindow window= getActiveWorkbenchWindow();
+ if (window == null) {
+ IWorkbenchWindow[] wbWindows= PlatformUI.getWorkbench().getWorkbenchWindows();
+ if (wbWindows.length == 0)
+ return;
+ window= wbWindows[0];
+ }
+ Shell shell= window.getShell();
+ if (shell != null && !shell.isDisposed()) {
+ shell.forceActive();
+ shell.forceFocus();
+ }
+ }
+
+ public static IWorkbenchPage getActivePage() {
+ IWorkbenchWindow window= getActiveWorkbenchWindow();
+ return window != null ? window.getActivePage() : null;
+ }
+
+ public static Display getActiveDisplay() {
+ IWorkbenchWindow window= getActiveWorkbenchWindow();
+ return window != null ? window.getShell().getDisplay() : null;
+ }
+
+ public static void joinBackgroundActivities() throws CoreException {
+ // Join Building
+ Logger.global.entering("EditorTestHelper", "joinBackgroundActivities"); //$NON-NLS-1$ //$NON-NLS-2$
+ Logger.global.finer("join builder"); //$NON-NLS-1$
+ boolean interrupted= true;
+ while (interrupted) {
+ try {
+ Platform.getJobManager().join(ResourcesPlugin.FAMILY_AUTO_BUILD, null);
+ interrupted= false;
+ } catch (InterruptedException e) {
+ interrupted= true;
+ }
+ }
+ // Join jobs
+ joinJobs(0, 0, 500);
+ Logger.global.exiting("EditorTestHelper", "joinBackgroundActivities"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ public static boolean joinJobs(long minTime, long maxTime, long intervalTime) {
+ Logger.global.entering("EditorTestHelper", "joinJobs"); //$NON-NLS-1$ //$NON-NLS-2$
+ runEventQueue(minTime);
+
+ DisplayHelper helper= new DisplayHelper() {
+ public boolean condition() {
+ return allJobsQuiet();
+ }
+ };
+ boolean quiet= helper.waitForCondition(getActiveDisplay(), maxTime > 0 ? maxTime : Long.MAX_VALUE, intervalTime);
+ Logger.global.exiting("EditorTestHelper", "joinJobs", new Boolean(quiet)); //$NON-NLS-1$ //$NON-NLS-2$
+ return quiet;
+ }
+
+ public static void sleep(int intervalTime) {
+ try {
+ Thread.sleep(intervalTime);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+
+ public static boolean allJobsQuiet() {
+ IJobManager jobManager= Platform.getJobManager();
+ Job[] jobs= jobManager.find(null);
+ for (int i= 0; i < jobs.length; i++) {
+ Job job= jobs[i];
+ int state= job.getState();
+ if (state == Job.RUNNING || state == Job.WAITING) {
+ Logger.global.finest(job.getName());
+ return false;
+ }
+ }
+ return true;
+ }
+
+ public static boolean isViewShown(String viewId) {
+ return getActivePage().findViewReference(viewId) != null;
+ }
+
+ public static boolean showView(String viewId, boolean show) throws PartInitException {
+ IWorkbenchPage activePage= getActivePage();
+ IViewReference view= activePage.findViewReference(viewId);
+ boolean shown= view != null;
+ if (shown != show)
+ if (show)
+ activePage.showView(viewId);
+ else
+ activePage.hideView(view);
+ return shown;
+ }
+
+ public static void bringToTop() {
+ getActiveWorkbenchWindow().getShell().forceActive();
+ }
+
+ public static String showPerspective(String perspective) throws WorkbenchException {
+ String shownPerspective= getActivePage().getPerspective().getId();
+ if (!perspective.equals(shownPerspective)) {
+ IWorkbench workbench= PlatformUI.getWorkbench();
+ IWorkbenchWindow activeWindow= workbench.getActiveWorkbenchWindow();
+ workbench.showPerspective(perspective, activeWindow);
+ }
+ return shownPerspective;
+ }
+
+
+
+ public static IFile[] findFiles(IResource resource) throws CoreException {
+ List files= new ArrayList();
+ findFiles(resource, files);
+ return (IFile[]) files.toArray(new IFile[files.size()]);
+ }
+
+ private static void findFiles(IResource resource, List files) throws CoreException {
+ if (resource instanceof IFile) {
+ files.add(resource);
+ return;
+ }
+ if (resource instanceof IContainer) {
+ IResource[] resources= ((IContainer) resource).members();
+ for (int i= 0; i < resources.length; i++)
+ findFiles(resources[i], files);
+ }
+ }
+
+}
Property changes on: trunk/tests/tests/org.jboss.tools.test/src/org/jboss/tools/test/util/xpl/EditorTestHelper.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
17 years
JBoss Tools SVN: r5531 - trunk/tests/tests/org.jboss.tools.test/src/org/jboss/tools/test/util.
by jbosstools-commits@lists.jboss.org
Author: dgolovin
Date: 2008-01-08 19:56:43 -0500 (Tue, 08 Jan 2008)
New Revision: 5531
Added:
trunk/tests/tests/org.jboss.tools.test/src/org/jboss/tools/test/util/xpl/
Log:
Test Utils to be able Join to background tasks and delay in UI threads. Classes were taken from org.eclipse.ui.tests.navigator plugin on :pserver:anonymous@dev.eclipse.org:/cvsroot/eclipse/org.eclipse.ui.tests.navigator
17 years