From jbosstools-commits at lists.jboss.org Tue Jan 8 13:59:01 2008 Content-Type: multipart/mixed; boundary="===============4490662055092796414==" MIME-Version: 1.0 From: jbosstools-commits at lists.jboss.org To: jbosstools-commits at lists.jboss.org Subject: [jbosstools-commits] JBoss Tools SVN: r5529 - in trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test: resources/jsfTest/WebContent/pages/JBIDE and 1 other directories. Date: Tue, 08 Jan 2008 13:59:01 -0500 Message-ID: --===============4490662055092796414== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: mareshkau Date: 2008-01-08 13:59:01 -0500 (Tue, 08 Jan 2008) New Revision: 5529 Added: trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebCo= ntent/pages/JBIDE/JBIDE-1484.jsp Removed: trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf= /vpe/jsf/test/ImportProvider.java trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf= /vpe/jsf/test/TestJsfUtil.java Modified: trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/META-INF/MANIFEST.MF trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf= /vpe/jsf/test/JsfAllTests.java trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf= /vpe/jsf/test/JsfComponentTest.java trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf= /vpe/jsf/test/JsfJbideTest.java Log: junit code adjustment Modified: trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/META-INF/MANIFES= T.MF =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/META-INF/MANIFEST.MF 2= 008-01-08 18:55:16 UTC (rev 5528) +++ trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/META-INF/MANIFEST.MF 2= 008-01-08 18:59:01 UTC (rev 5529) @@ -15,6 +15,7 @@ org.jboss.tools.common.text.ext, org.jboss.tools.common.model, org.jboss.tools.vpe.xulrunner, - org.mozilla.xpcom + org.mozilla.xpcom, + org.jboss.tools.jsf.vpe.ui.test;visibility:=3Dreexport Eclipse-LazyStart: true Bundle-ClassPath: jsf-test.jar Added: trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/W= ebContent/pages/JBIDE/JBIDE-1484.jsp =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebC= ontent/pages/JBIDE/JBIDE-1484.jsp (rev 0) +++ trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebC= ontent/pages/JBIDE/JBIDE-1484.jsp 2008-01-08 18:59:01 UTC (rev 5529) @@ -0,0 +1,14 @@ +<%@ taglib uri=3D"http://java.sun.com/jsf/core" prefix=3D"f"%> +<%@ taglib uri=3D"http://java.sun.com/jsf/html" prefix=3D"h"%> + + + + + + + + = + + + + \ No newline at end of file Deleted: trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/too= ls/jsf/vpe/jsf/test/ImportProvider.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/js= f/vpe/jsf/test/ImportProvider.java 2008-01-08 18:55:16 UTC (rev 5528) +++ trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/js= f/vpe/jsf/test/ImportProvider.java 2008-01-08 18:59:01 UTC (rev 5529) @@ -1,107 +0,0 @@ -/*************************************************************************= ****** - * Copyright (c) 2007 Exadel, Inc. and 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: - * Exadel, Inc. and Red Hat, Inc. - initial API and implementation - *************************************************************************= *****/ -package org.jboss.tools.jsf.vpe.jsf.test; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.InputStream; -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.ui.internal.ide.IDEWorkbenchPlugin; -import org.eclipse.ui.wizards.datatransfer.IImportStructureProvider; - -/** - * @author sdzmitrovich - * = - */ -public class ImportProvider implements IImportStructureProvider { - - /** - * list of files which will not be imported - */ - List unimportedFiles =3D new ArrayList(); - - /** - * Creates an instance of ImportProvider. - */ - public ImportProvider() { - super(); - } - - /* - * (non-Javadoc) Method declared on IImportStructureProvider - */ - public List getChildren(Object element) { - File folder =3D (File) element; - String[] children =3D folder.list(); - int childrenLength =3D children =3D=3D null ? 0 : children.length; - List result =3D new ArrayList(childrenLength); - - for (int i =3D 0; i < childrenLength; i++) { - if (!unimportedFiles.contains(children[i])) - result.add(new File(folder, children[i])); - } - - return result; - } - - /* - * (non-Javadoc) Method declared on IImportStructureProvider - */ - public InputStream getContents(Object element) { - try { - return new FileInputStream((File) element); - } catch (FileNotFoundException e) { - IDEWorkbenchPlugin.log(e.getLocalizedMessage(), e); - return null; - } - } - - /* - * (non-Javadoc) Method declared on IImportStructureProvider - */ - public String getFullPath(Object element) { - return ((File) element).getPath(); - } - - /* - * (non-Javadoc) Method declared on IImportStructureProvider - */ - public String getLabel(Object element) { - - // Get the name - if it is empty then return the path as it is a file - // root - File file =3D (File) element; - String name =3D file.getName(); - if (name.length() =3D=3D 0) { - return file.getPath(); - } - return name; - } - - /* - * (non-Javadoc) Method declared on IImportStructureProvider - */ - public boolean isFolder(Object element) { - return ((File) element).isDirectory(); - } - - public List getUnimportedFiles() { - return unimportedFiles; - } - - public void setUnimportedFiles(List unimportedFiles) { - this.unimportedFiles =3D unimportedFiles; - } - -} Modified: trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/to= ols/jsf/vpe/jsf/test/JsfAllTests.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/js= f/vpe/jsf/test/JsfAllTests.java 2008-01-08 18:55:16 UTC (rev 5528) +++ trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/js= f/vpe/jsf/test/JsfAllTests.java 2008-01-08 18:59:01 UTC (rev 5529) @@ -10,6 +10,8 @@ *************************************************************************= *****/ package org.jboss.tools.jsf.vpe.jsf.test; = +import org.eclipse.core.runtime.CoreException; + import junit.framework.Test; import junit.framework.TestSuite; = @@ -22,25 +24,13 @@ = public class JsfAllTests { = - private final static String TEST_PROJECT_PATH =3D "/jsfTest"; - - private static void prepareTests() { - - TestJsfUtil.importJsfPages(JsfTestPlugin.getPluginResourcePath() - + TEST_PROJECT_PATH); - - } - public static Test suite() { - // prepare tests - prepareTests(); = TestSuite suite =3D new TestSuite("Tests for Vpe Jsf components"); // $N= ON-NLS-1$ // $JUnit-BEGIN$ - suite.addTestSuite(JsfComponentTest.class); suite.addTestSuite(JsfJbideTest.class); - + //cleanUpTests(); // $JUnit-END$ return suite; = Modified: trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/to= ols/jsf/vpe/jsf/test/JsfComponentTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/js= f/vpe/jsf/test/JsfComponentTest.java 2008-01-08 18:55:16 UTC (rev 5528) +++ trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/js= f/vpe/jsf/test/JsfComponentTest.java 2008-01-08 18:59:01 UTC (rev 5529) @@ -10,16 +10,8 @@ *************************************************************************= *****/ package org.jboss.tools.jsf.vpe.jsf.test; = -import junit.framework.TestCase; - -import org.eclipse.core.resources.IFile; -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.PartInitException; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.part.FileEditorInput; +import org.jboss.tools.vpe.ui.test.VpeTest; = /** * Class for testing all jsf components @@ -27,45 +19,15 @@ * @author sdzmitrovich * = */ -public class JsfComponentTest extends TestCase implements ILogListener { +public class JsfComponentTest extends VpeTest { = - private final static String EDITOR_ID =3D "org.jboss.tools.jst.jsp.jspedi= tor.JSPTextEditor"; // $NON-NLS-1$ - // $NON-NLS-1$ - - // check warning log - private final static boolean checkWarning =3D false; - private Throwable exception; - + //import project name = + private static final String IMPORT_PROJECT_NAME =3D "jsfTest"; = + = public JsfComponentTest(String name) { - super(name); + super(name,IMPORT_PROJECT_NAME,JsfTestPlugin.getPluginResourcePath()); } = - /** - * Perform pre-test initialization. - * = - * @throws Exception - * = - * @see TestCase#setUp() - */ - - protected void setUp() throws Exception { - super.setUp(); - - Platform.addLogListener(this); - } - - /** - * Perform post-test cleanup. - * = - * @throws Exception - * = - * @see TestCase#tearDown() - */ - protected void tearDown() throws Exception { - super.tearDown(); - Platform.removeLogListener(this); - } - /* * JSF HTML test cases */ @@ -250,44 +212,4 @@ public void testView() throws PartInitException, Throwable { performTestForJsfComponent("components/view.jsp"); // $NON-NLS-1$ } - - private void performTestForJsfComponent(String componentPage) - throws PartInitException, Throwable { - TestJsfUtil.waitForJobs(); - - exception =3D null; - - IFile file =3D (IFile) TestJsfUtil.getComponentPath(componentPage); - - IEditorInput input =3D new FileEditorInput(file); - - PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage() - .openEditor(input, EDITOR_ID, true); - - TestJsfUtil.waitForJobs(); - TestJsfUtil.delay(3000); - - PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage() - .closeAllEditors(true); - - if (exception !=3D null) { - throw exception; - } - } - - public void logging(IStatus status, String plugin) { - switch (status.getSeverity()) { - case IStatus.ERROR: - exception =3D status.getException(); - break; - case IStatus.WARNING: - if (checkWarning) - exception =3D status.getException(); - break; - default: - break; - } - - } - } Modified: trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/to= ols/jsf/vpe/jsf/test/JsfJbideTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/js= f/vpe/jsf/test/JsfJbideTest.java 2008-01-08 18:55:16 UTC (rev 5528) +++ trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/js= f/vpe/jsf/test/JsfJbideTest.java 2008-01-08 18:59:01 UTC (rev 5529) @@ -14,81 +14,39 @@ import java.util.ArrayList; import java.util.List; = -import junit.framework.TestCase; - import org.eclipse.core.resources.IFile; -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.PartInitException; -import org.eclipse.ui.PlatformUI; import org.eclipse.ui.part.FileEditorInput; import org.jboss.tools.jst.jsp.jspeditor.JSPMultiPageEditor; -import org.jboss.tools.vpe.editor.VpeController; -import org.jboss.tools.vpe.editor.VpeEditorPart; import org.jboss.tools.vpe.editor.util.HTML; -import org.jboss.tools.vpe.xulrunner.editor.XulRunnerEditor; +import org.jboss.tools.vpe.ui.test.TestUtil; +import org.jboss.tools.vpe.ui.test.VpeTest; import org.mozilla.interfaces.nsIDOMDocument; import org.mozilla.interfaces.nsIDOMElement; import org.mozilla.interfaces.nsIDOMNamedNodeMap; import org.mozilla.interfaces.nsIDOMNode; import org.mozilla.interfaces.nsIDOMNodeList; - /** * Class for testing all jsf bugs * = * @author sdzmitrovich * = */ -public class JsfJbideTest extends TestCase implements ILogListener { +public class JsfJbideTest extends VpeTest { = - private final static String EDITOR_ID =3D "org.jboss.tools.jst.jsp.jspedi= tor.JSPTextEditor"; // $NON-NLS-1$ // type of input tag private static final String ATTR_TYPE_VALUE =3D "radio"; + = + //import project name + = + private static final String IMPORT_PROJECT_NAME =3D "jsfTest"; = = - // check warning log - private final static boolean checkWarning =3D false; - - private Throwable exception; - public JsfJbideTest(String name) { - super(name); + super(name,IMPORT_PROJECT_NAME,JsfTestPlugin.getPluginResourcePath()); } = - /** - * Perform pre-test initialization. - * = - * @throws Exception - * = - * @see TestCase#setUp() - */ = - protected void setUp() throws Exception { - - super.setUp(); - - Platform.addLogListener(this); - - closeEditors(); - } - - /** - * Perform post-test cleanup. - * = - * @throws Exception - * = - * @see TestCase#tearDown() - */ - protected void tearDown() throws Exception { - - super.tearDown(); - - Platform.removeLogListener(this); - - closeEditors(); - } - /* * JBIDE's test cases */ @@ -108,13 +66,13 @@ public void testJBIDE_1467() throws PartInitException, Throwable { = // wait - TestJsfUtil.waitForJobs(); + TestUtil.waitForJobs(); // set exception - exception =3D null; + setException(null); = // get test page path - IFile file =3D (IFile) TestJsfUtil - .getComponentPath("JBIDE/1467/JBIDE-1467.jsp"); + IFile file =3D (IFile) TestUtil + .getComponentPath("JBIDE/1467/JBIDE-1467.jsp",getImportProjectName()); = IEditorInput input =3D new FileEditorInput(file); = @@ -122,7 +80,7 @@ JSPMultiPageEditor part =3D openEditor(input); = // get dom document - nsIDOMDocument document =3D getVpePageSource(part); + nsIDOMDocument document =3D getVpeVisualDocument(part); nsIDOMElement element =3D document.getDocumentElement(); = if (element !=3D null) { @@ -143,8 +101,8 @@ } = // check exception - if (exception !=3D null) { - throw exception; + if (getException() !=3D null) { + throw getException(); } = } @@ -175,15 +133,15 @@ public void testJBIDE_1501() throws PartInitException, Throwable { = // wait - TestJsfUtil.waitForJobs(); + TestUtil.waitForJobs(); // set exception - exception =3D null; + setException(null); = // _____1st Part____// = // get test page path - IFile file =3D (IFile) TestJsfUtil - .getComponentPath("JBIDE/1501/JBIDE-1501_multiple.jsp"); + IFile file =3D (IFile) TestUtil + .getComponentPath("JBIDE/1501/JBIDE-1501_multiple.jsp",getImportProjec= tName()); = IEditorInput input =3D new FileEditorInput(file); = @@ -191,7 +149,7 @@ JSPMultiPageEditor part =3D openEditor(input); = // get dom document - nsIDOMDocument document =3D getVpePageSource(part); + nsIDOMDocument document =3D getVpeVisualDocument(part); assertNotNull(document); = // get dom element @@ -223,8 +181,8 @@ // _____2nd Part____// = // get test page path - file =3D (IFile) TestJsfUtil - .getComponentPath("JBIDE/1501/JBIDE-1501_size.jsp"); + file =3D (IFile) TestUtil + .getComponentPath("JBIDE/1501/JBIDE-1501_size.jsp",getImportProjectNam= e()); = input =3D new FileEditorInput(file); = @@ -232,7 +190,7 @@ part =3D openEditor(input); = // get dom document - document =3D getVpePageSource(part); + document =3D getVpeVisualDocument(part); assertNotNull(document); = // get dom element @@ -265,8 +223,8 @@ } = // check exception - if (exception !=3D null) { - throw exception; + if (getException() !=3D null) { + throw getException(); } = } @@ -345,78 +303,4 @@ = } = - /** - * close all opened editors - */ - private void closeEditors() { - - // wait - TestJsfUtil.waitForJobs(); - - // close - PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage() - .closeAllEditors(true); - - } - - /** - * Open JSPMultiPageEditor editor - * = - * @param input - * @return - * @throws PartInitException - */ - private JSPMultiPageEditor openEditor(IEditorInput input) - throws PartInitException { - - // get editor - JSPMultiPageEditor part =3D (JSPMultiPageEditor) PlatformUI - .getWorkbench().getActiveWorkbenchWindow().getActivePage() - .openEditor(input, EDITOR_ID, true); - - // wait for jobs - TestJsfUtil.waitForJobs(); - // wait full initialization of vpe - TestJsfUtil.delay(3000); - - return part; - - } - - /** - * get xulrunner source page - * = - * @param part - - * JSPMultiPageEditor - * @return nsIDOMDocument - */ - private nsIDOMDocument getVpePageSource(JSPMultiPageEditor part) { - - VpeEditorPart visualEditor =3D (VpeEditorPart) part.getVisualEditor(); - VpeController vpeController =3D visualEditor.getController(); - - // get xulRunner editor - XulRunnerEditor xulRunnerEditor =3D vpeController.getXulRunnerEditor(); - - // get dom document - nsIDOMDocument document =3D xulRunnerEditor.getDOMDocument(); - - return document; - } - - public void logging(IStatus status, String plugin) { - switch (status.getSeverity()) { - case IStatus.ERROR: - exception =3D status.getException(); - break; - case IStatus.WARNING: - if (checkWarning) - exception =3D status.getException(); - break; - default: - break; - } - - } - } Deleted: trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/too= ls/jsf/vpe/jsf/test/TestJsfUtil.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/js= f/vpe/jsf/test/TestJsfUtil.java 2008-01-08 18:55:16 UTC (rev 5528) +++ trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/js= f/vpe/jsf/test/TestJsfUtil.java 2008-01-08 18:59:01 UTC (rev 5529) @@ -1,157 +0,0 @@ -/*************************************************************************= ****** = - * 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.jsf.vpe.jsf.test; - -import java.io.File; -import java.lang.reflect.InvocationTargetException; -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.core.runtime.jobs.Job; -import org.eclipse.swt.widgets.Display; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.dialogs.IOverwriteQuery; -import org.eclipse.ui.wizards.datatransfer.ImportOperation; - -/** - * Class for importing project from jar file - * = - * @author sdzmitrovich - * = - */ -public class TestJsfUtil { - private static final String PROJECT_NAME =3D "JsfTest"; // $NON-NLS-1$ - private static final String COMPONENTS_PATH =3D "WebContent/pages"; // $N= ON-NLS-1$ - - @SuppressWarnings("restriction") - static void importJsfPages(String path) { - - if (ResourcesPlugin.getWorkspace().getRoot().findMember( - TestJsfUtil.PROJECT_NAME) !=3D null) { - waitForJobs(); - - try { - removeProject(); - } catch (CoreException e) { - e.printStackTrace(); - } - } - - IProject project =3D ResourcesPlugin.getWorkspace().getRoot().getProject( - PROJECT_NAME); - - try { - - IOverwriteQuery overwrite =3D new IOverwriteQuery() { - public String queryOverwrite(String pathString) { - return ALL; - } - }; - - ImportProvider importProvider =3D new ImportProvider(); - - // need to remove from imported project "svn" files - List unimportedFiles =3D new ArrayList(); - unimportedFiles.add(".svn"); - - importProvider.setUnimportedFiles(unimportedFiles); - - // create import operation - ImportOperation importOp =3D new ImportOperation(project - .getFullPath(), new File(path), importProvider, overwrite); - - // import files just to project folder ( without old structure ) - importOp.setCreateContainerStructure(false); - - importOp.setContext(PlatformUI.getWorkbench() - .getActiveWorkbenchWindow().getShell()); - - // run import - importOp.run(new NullProgressMonitor()); - - } catch (InvocationTargetException ite) { - JsfTestPlugin.getPluginLog().logError(ite.getCause()); - } catch (InterruptedException ie) { - JsfTestPlugin.getPluginLog().logError(ie); - } - } - - /** - * = - * @return - * @throws CoreException - */ - static IResource getComponentPath(String componentPage) - throws CoreException { - IProject project =3D ResourcesPlugin.getWorkspace().getRoot().getProject( - PROJECT_NAME); - if (project !=3D null) { - return project.getFolder(COMPONENTS_PATH).findMember(componentPage); - - } - - return null; - } - - /** - * = - * @throws CoreException - */ - static void removeProject() throws CoreException { - IProject project =3D ResourcesPlugin.getWorkspace().getRoot().getProject( - PROJECT_NAME); - if (project !=3D null) { - project.delete(IResource.ALWAYS_DELETE_PROJECT_CONTENT, - new NullProgressMonitor()); - } - } - - /** - * Process UI input but do not return for the specified time interval. - * = - * @param waitTimeMillis - * the number of milliseconds - */ - public static void delay(long waitTimeMillis) { - Display display =3D Display.getCurrent(); - if (display !=3D null) { - long endTimeMillis =3D System.currentTimeMillis() + waitTimeMillis; - while (System.currentTimeMillis() < endTimeMillis) { - if (!display.readAndDispatch()) - display.sleep(); - } - display.update(); - } - // Otherwise, perform a simple sleep. - else { - try { - Thread.sleep(waitTimeMillis); - } catch (InterruptedException e) { - // Ignored. - } - } - } - - /** - * Wait until all background tasks are complete. - */ - public static void waitForJobs() { - while (Job.getJobManager().currentJob() !=3D null) - delay(5000); - } - -} --===============4490662055092796414==--