Author: mareshkau
Date: 2008-01-10 08:00:56 -0500 (Thu, 10 Jan 2008)
New Revision: 5576
Added:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.ui.test/src/org/jboss/tools/vpe/ui/test/VpeTestSetup.java
trunk/jsf/tests/org.jboss.tools.jsf.vpe.ui.test/src/org/jboss/tools/vpe/ui/test/beans/
trunk/jsf/tests/org.jboss.tools.jsf.vpe.ui.test/src/org/jboss/tools/vpe/ui/test/beans/ImportBean.java
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.ui.test/META-INF/MANIFEST.MF
trunk/jsf/tests/org.jboss.tools.jsf.vpe.ui.test/src/org/jboss/tools/vpe/ui/test/VpeTest.java
Log:
http://jira.jboss.com/jira/browse/JBIDE-1562, junit tests was adjusted, was added VpeTest
setup class which allows correctly import-remove test project from workspace(only once for
each test suite, not for every test case).Some code was refactored.
Modified: trunk/jsf/tests/org.jboss.tools.jsf.vpe.ui.test/META-INF/MANIFEST.MF
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.vpe.ui.test/META-INF/MANIFEST.MF 2008-01-10
10:29:54 UTC (rev 5575)
+++ trunk/jsf/tests/org.jboss.tools.jsf.vpe.ui.test/META-INF/MANIFEST.MF 2008-01-10
13:00:56 UTC (rev 5576)
@@ -18,4 +18,5 @@
org.mozilla.xpcom
Eclipse-LazyStart: true
Bundle-ClassPath: .
-Export-Package: org.jboss.tools.vpe.ui.test
+Export-Package: org.jboss.tools.vpe.ui.test,
+ org.jboss.tools.vpe.ui.test.beans
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.ui.test/src/org/jboss/tools/vpe/ui/test/VpeTest.java
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.vpe.ui.test/src/org/jboss/tools/vpe/ui/test/VpeTest.java 2008-01-10
10:29:54 UTC (rev 5575)
+++
trunk/jsf/tests/org.jboss.tools.jsf.vpe.ui.test/src/org/jboss/tools/vpe/ui/test/VpeTest.java 2008-01-10
13:00:56 UTC (rev 5576)
@@ -11,15 +11,13 @@
package org.jboss.tools.vpe.ui.test;
-import java.io.File;
-
import junit.framework.TestCase;
import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.ILogListener;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Platform;
import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.part.FileEditorInput;
@@ -50,24 +48,14 @@
private Boolean checkWarning;
/**
- * Contains project name with information for testing
- */
- private String importProjectName;
-
- /**
- * Contains plugin resource path
- */
- private String pluginResourcePath;
- /**
*
* @param name
* @param importProjectName
*/
- public VpeTest(String name, String importProjectName,String pluginResourcePath) {
+ public VpeTest(String name) {
super(name);
- setImportProjectName(importProjectName);
- setPluginResourcePath(pluginResourcePath);
+
}
/**
* Perform pre-test initialization.
@@ -79,13 +67,9 @@
protected void setUp() throws Exception {
super.setUp();
- closeEditors();
- if (ResourcesPlugin.getWorkspace().getRoot().findMember(getImportProjectName()) ==
null) {
- closeEditors();
- TestUtil.importProjectIntoWorkspace((getPluginResourcePath()
- + File.separator+getImportProjectName()),getImportProjectName());
- }
+
Platform.addLogListener(this);
+
closeEditors();
}
/**
@@ -101,7 +85,6 @@
closeEditors();
- TestUtil.removeProject(getImportProjectName());
Platform.removeLogListener(this);
}
@@ -165,22 +148,24 @@
* @throws PartInitException
* @throws Throwable
*/
- protected void performTestForJsfComponent(String componentPage)
+ protected void performTestForVpeComponent(IFile componentPage)
throws PartInitException, Throwable {
TestUtil.waitForJobs();
setException(null);
- IFile file = (IFile) TestUtil.getComponentPath(componentPage,getImportProjectName());
- IEditorInput input = new FileEditorInput(file);
+// IFile file = (IFile)
TestUtil.getComponentPath(componentPage,getImportProjectName());
+ IEditorInput input = new FileEditorInput(componentPage);
TestUtil.waitForJobs();
- PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()
+ IEditorPart editor =
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()
.openEditor(input, EDITOR_ID, true);
-
+
+ assertNotNull(editor);
+
TestUtil.waitForJobs();
- TestUtil.delay(3000);
+ TestUtil.delay(1000);
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()
.closeAllEditors(true);
@@ -207,7 +192,7 @@
// wait for jobs
TestUtil.waitForJobs();
// // wait full initialization of vpe
- TestUtil.delay(3000);
+ TestUtil.delay(100);
return part;
@@ -236,29 +221,5 @@
protected void setCheckWarning(Boolean checkWarning) {
this.checkWarning = checkWarning;
}
- /**
- * @return the importProjectName
- */
- protected String getImportProjectName() {
- return importProjectName;
- }
- /**
- * @param importProjectName the importProjectName to set
- */
- protected void setImportProjectName(String importProjectName) {
- this.importProjectName = importProjectName;
- }
- /**
- * @return the pluginResourcePath
- */
- protected String getPluginResourcePath() {
- return pluginResourcePath;
- }
- /**
- * @param pluginResourcePath the pluginResourcePath to set
- */
- protected void setPluginResourcePath(String pluginResourcePath) {
- this.pluginResourcePath = pluginResourcePath;
- }
}
Added:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.ui.test/src/org/jboss/tools/vpe/ui/test/VpeTestSetup.java
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.vpe.ui.test/src/org/jboss/tools/vpe/ui/test/VpeTestSetup.java
(rev 0)
+++
trunk/jsf/tests/org.jboss.tools.jsf.vpe.ui.test/src/org/jboss/tools/vpe/ui/test/VpeTestSetup.java 2008-01-10
13:00:56 UTC (rev 5576)
@@ -0,0 +1,81 @@
+/*******************************************************************************
+* Copyright (c) 2007 Red Hat, Inc.
+* Distributed under license by Red Hat, Inc. All rights reserved.
+* This program is 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:
+* Red Hat, Inc. - initial API and implementation
+******************************************************************************/
+package org.jboss.tools.vpe.ui.test;
+
+import java.io.File;
+import java.util.List;
+
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.jboss.tools.vpe.ui.test.beans.ImportBean;
+
+import junit.extensions.TestSetup;
+import junit.framework.TestSuite;
+
+/**
+ * @author Max Areshkau
+ *
+ * Class for setup-tear down junit tests(import project
+ * into workspace and remove project from workspace)
+ */
+public class VpeTestSetup extends TestSetup {
+
+ /**
+ * Contains test project names, which will be imported
+ * in setUp method and removed in tear down method
+ */
+ private List<ImportBean> testProjectNames;
+
+ public VpeTestSetup(TestSuite test, List<ImportBean> testProjectNames) {
+ super(test);
+ setTestProjects(testProjectNames);
+ }
+
+ /* (non-Javadoc)
+ * @see junit.extensions.TestSetup#setUp()
+ */
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ for (ImportBean importBean : getTestProjects()) {
+ if
(ResourcesPlugin.getWorkspace().getRoot().findMember(importBean.getImportProjectName()) ==
null) {
+ TestUtil.importProjectIntoWorkspace((importBean.getImportProjectPath()
+ +
File.separator+importBean.getImportProjectName()),importBean.getImportProjectName());
+ }
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see junit.extensions.TestSetup#tearDown()
+ */
+ @Override
+ protected void tearDown() throws Exception {
+
+ for(ImportBean importBean:getTestProjects()) {
+ TestUtil.removeProject(importBean.getImportProjectName());
+ }
+ super.tearDown();
+ }
+
+ /**
+ * @return the testProjectNames
+ */
+ private List<ImportBean> getTestProjects() {
+ return testProjectNames;
+ }
+
+ /**
+ * @param testProjectNames the testProjectNames to set
+ */
+ private void setTestProjects(List<ImportBean> testProjectNames) {
+ this.testProjectNames = testProjectNames;
+ }
+
+}
Added:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.ui.test/src/org/jboss/tools/vpe/ui/test/beans/ImportBean.java
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.vpe.ui.test/src/org/jboss/tools/vpe/ui/test/beans/ImportBean.java
(rev 0)
+++
trunk/jsf/tests/org.jboss.tools.jsf.vpe.ui.test/src/org/jboss/tools/vpe/ui/test/beans/ImportBean.java 2008-01-10
13:00:56 UTC (rev 5576)
@@ -0,0 +1,52 @@
+/*******************************************************************************
+* Copyright (c) 2007 Red Hat, Inc.
+* Distributed under license by Red Hat, Inc. All rights reserved.
+* This program is 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:
+* Red Hat, Inc. - initial API and implementation
+******************************************************************************/
+package org.jboss.tools.vpe.ui.test.beans;
+
+/**
+ * @author Max Areshkau
+ *
+ * Contains information about projects which should be imported
+ */
+public class ImportBean {
+ /**
+ * Contains import project Name
+ */
+ private String importProjectName;
+ /**
+ * Contains import project path
+ */
+ private String importProjectPath;
+ /**
+ * @return the importProjectName
+ */
+ public String getImportProjectName() {
+ return importProjectName;
+ }
+ /**
+ * @param importProjectName the importProjectName to set
+ */
+ public void setImportProjectName(String importProjectName) {
+ this.importProjectName = importProjectName;
+ }
+ /**
+ * @return the importProjectPath
+ */
+ public String getImportProjectPath() {
+ return importProjectPath;
+ }
+ /**
+ * @param importProjectPath the importProjectPath to set
+ */
+ public void setImportProjectPath(String importProjectPath) {
+ this.importProjectPath = importProjectPath;
+ }
+
+}