Author: dsakovich
Date: 2007-10-12 09:25:12 -0400 (Fri, 12 Oct 2007)
New Revision: 4158
Added:
branches/jbosstools_xulrunner/vpe/tests/org.jboss.tools.vpe.test.richfaces/.classpath
branches/jbosstools_xulrunner/vpe/tests/org.jboss.tools.vpe.test.richfaces/.project
branches/jbosstools_xulrunner/vpe/tests/org.jboss.tools.vpe.test.richfaces/META-INF/
branches/jbosstools_xulrunner/vpe/tests/org.jboss.tools.vpe.test.richfaces/META-INF/MANIFEST.MF
branches/jbosstools_xulrunner/vpe/tests/org.jboss.tools.vpe.test.richfaces/build.properties
branches/jbosstools_xulrunner/vpe/tests/org.jboss.tools.vpe.test.richfaces/resources/
branches/jbosstools_xulrunner/vpe/tests/org.jboss.tools.vpe.test.richfaces/resources/richFacesTest.jar
branches/jbosstools_xulrunner/vpe/tests/org.jboss.tools.vpe.test.richfaces/src/
branches/jbosstools_xulrunner/vpe/tests/org.jboss.tools.vpe.test.richfaces/src/org/
branches/jbosstools_xulrunner/vpe/tests/org.jboss.tools.vpe.test.richfaces/src/org/jboss/
branches/jbosstools_xulrunner/vpe/tests/org.jboss.tools.vpe.test.richfaces/src/org/jboss/tools/
branches/jbosstools_xulrunner/vpe/tests/org.jboss.tools.vpe.test.richfaces/src/org/jboss/tools/vpe/
branches/jbosstools_xulrunner/vpe/tests/org.jboss.tools.vpe.test.richfaces/src/org/jboss/tools/vpe/test/
branches/jbosstools_xulrunner/vpe/tests/org.jboss.tools.vpe.test.richfaces/src/org/jboss/tools/vpe/test/richfaces/
branches/jbosstools_xulrunner/vpe/tests/org.jboss.tools.vpe.test.richfaces/src/org/jboss/tools/vpe/test/richfaces/Activator.java
branches/jbosstools_xulrunner/vpe/tests/org.jboss.tools.vpe.test.richfaces/src/org/jboss/tools/vpe/test/richfaces/ImportRichFacesComponents.java
branches/jbosstools_xulrunner/vpe/tests/org.jboss.tools.vpe.test.richfaces/src/org/jboss/tools/vpe/test/richfaces/RichFacesAllTest.java
branches/jbosstools_xulrunner/vpe/tests/org.jboss.tools.vpe.test.richfaces/src/org/jboss/tools/vpe/test/richfaces/RichFacesComponentTest.java
Log:
Add JUnit tests for RichFaces components
Added:
branches/jbosstools_xulrunner/vpe/tests/org.jboss.tools.vpe.test.richfaces/.classpath
===================================================================
--- branches/jbosstools_xulrunner/vpe/tests/org.jboss.tools.vpe.test.richfaces/.classpath
(rev 0)
+++
branches/jbosstools_xulrunner/vpe/tests/org.jboss.tools.vpe.test.richfaces/.classpath 2007-10-12
13:25:12 UTC (rev 4158)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="con"
path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="con"
path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
Property changes on:
branches/jbosstools_xulrunner/vpe/tests/org.jboss.tools.vpe.test.richfaces/.classpath
___________________________________________________________________
Name: svn:executable
+ *
Added:
branches/jbosstools_xulrunner/vpe/tests/org.jboss.tools.vpe.test.richfaces/.project
===================================================================
--- branches/jbosstools_xulrunner/vpe/tests/org.jboss.tools.vpe.test.richfaces/.project
(rev 0)
+++
branches/jbosstools_xulrunner/vpe/tests/org.jboss.tools.vpe.test.richfaces/.project 2007-10-12
13:25:12 UTC (rev 4158)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.jboss.tools.vpe.test.richfaces</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
Property changes on:
branches/jbosstools_xulrunner/vpe/tests/org.jboss.tools.vpe.test.richfaces/.project
___________________________________________________________________
Name: svn:executable
+ *
Added:
branches/jbosstools_xulrunner/vpe/tests/org.jboss.tools.vpe.test.richfaces/META-INF/MANIFEST.MF
===================================================================
---
branches/jbosstools_xulrunner/vpe/tests/org.jboss.tools.vpe.test.richfaces/META-INF/MANIFEST.MF
(rev 0)
+++
branches/jbosstools_xulrunner/vpe/tests/org.jboss.tools.vpe.test.richfaces/META-INF/MANIFEST.MF 2007-10-12
13:25:12 UTC (rev 4158)
@@ -0,0 +1,13 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Richfaces Plug-in
+Bundle-SymbolicName: org.jboss.tools.vpe.test.richfaces
+Bundle-Version: 1.0.0
+Bundle-Activator: org.jboss.tools.vpe.test.richfaces.Activator
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.jboss.tools.vpe,
+ org.junit,
+ org.eclipse.core.resources,
+ org.eclipse.ui.ide
+Eclipse-LazyStart: true
Property changes on:
branches/jbosstools_xulrunner/vpe/tests/org.jboss.tools.vpe.test.richfaces/META-INF/MANIFEST.MF
___________________________________________________________________
Name: svn:executable
+ *
Added:
branches/jbosstools_xulrunner/vpe/tests/org.jboss.tools.vpe.test.richfaces/build.properties
===================================================================
---
branches/jbosstools_xulrunner/vpe/tests/org.jboss.tools.vpe.test.richfaces/build.properties
(rev 0)
+++
branches/jbosstools_xulrunner/vpe/tests/org.jboss.tools.vpe.test.richfaces/build.properties 2007-10-12
13:25:12 UTC (rev 4158)
@@ -0,0 +1,4 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .
Property changes on:
branches/jbosstools_xulrunner/vpe/tests/org.jboss.tools.vpe.test.richfaces/build.properties
___________________________________________________________________
Name: svn:executable
+ *
Added:
branches/jbosstools_xulrunner/vpe/tests/org.jboss.tools.vpe.test.richfaces/resources/richFacesTest.jar
===================================================================
(Binary files differ)
Property changes on:
branches/jbosstools_xulrunner/vpe/tests/org.jboss.tools.vpe.test.richfaces/resources/richFacesTest.jar
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:mime-type
+ application/octet-stream
Added:
branches/jbosstools_xulrunner/vpe/tests/org.jboss.tools.vpe.test.richfaces/src/org/jboss/tools/vpe/test/richfaces/Activator.java
===================================================================
---
branches/jbosstools_xulrunner/vpe/tests/org.jboss.tools.vpe.test.richfaces/src/org/jboss/tools/vpe/test/richfaces/Activator.java
(rev 0)
+++
branches/jbosstools_xulrunner/vpe/tests/org.jboss.tools.vpe.test.richfaces/src/org/jboss/tools/vpe/test/richfaces/Activator.java 2007-10-12
13:25:12 UTC (rev 4158)
@@ -0,0 +1,78 @@
+/*******************************************************************************
+ * 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.vpe.test.richfaces;
+
+import java.net.URL;
+
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class Activator extends AbstractUIPlugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID =
"org.jboss.tools.vpe.test.richfaces";
+
+ // The shared instance
+ private static Activator plugin;
+
+ /**
+ * The constructor
+ */
+ public Activator() {
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static Activator getDefault() {
+ return plugin;
+ }
+
+ public static String getPluginResourcePath() {
+ Bundle bundle = Platform.getBundle(PLUGIN_ID);
+ URL url = null;
+ try {
+ url = bundle == null ? null : FileLocator.resolve(bundle
+ .getEntry("/resources"));
+ } catch (Exception e) {
+ url = bundle.getEntry("/resources");
+ }
+ return (url == null) ? null : url.getPath();
+ }
+}
Property changes on:
branches/jbosstools_xulrunner/vpe/tests/org.jboss.tools.vpe.test.richfaces/src/org/jboss/tools/vpe/test/richfaces/Activator.java
___________________________________________________________________
Name: svn:executable
+ *
Added:
branches/jbosstools_xulrunner/vpe/tests/org.jboss.tools.vpe.test.richfaces/src/org/jboss/tools/vpe/test/richfaces/ImportRichFacesComponents.java
===================================================================
---
branches/jbosstools_xulrunner/vpe/tests/org.jboss.tools.vpe.test.richfaces/src/org/jboss/tools/vpe/test/richfaces/ImportRichFacesComponents.java
(rev 0)
+++
branches/jbosstools_xulrunner/vpe/tests/org.jboss.tools.vpe.test.richfaces/src/org/jboss/tools/vpe/test/richfaces/ImportRichFacesComponents.java 2007-10-12
13:25:12 UTC (rev 4158)
@@ -0,0 +1,110 @@
+/*******************************************************************************
+ * 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.vpe.test.richfaces;
+
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.zip.ZipFile;
+
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.dialogs.IOverwriteQuery;
+import org.eclipse.ui.internal.wizards.datatransfer.ZipLeveledStructureProvider;
+import org.eclipse.ui.wizards.datatransfer.ImportOperation;
+
+/**
+ * Class for importing project from jar file
+ *
+ * @author dsakharov@exadel.com,amakhtadui(a)exadel.com
+ *
+ */
+public class ImportRichFacesComponents {
+ private static final String PROJECT_NAME = "richFacesTest";
+ private static final String COMPONENTS_PATH = "WebContent/pages";
+
+ @SuppressWarnings("restriction")
+ public static boolean importRichFacesPages(String path) {
+ boolean result = false;
+ IWorkspace workspace = ResourcesPlugin.getWorkspace();
+ IProject project = workspace.getRoot().getProject(PROJECT_NAME);
+ ZipLeveledStructureProvider zipStructureProvider;
+ try {
+ zipStructureProvider = new ZipLeveledStructureProvider(new ZipFile(
+ path));
+
+ IOverwriteQuery overwrite = new IOverwriteQuery() {
+ public String queryOverwrite(String pathString) {
+ return ALL;
+ }
+ };
+
+ ImportOperation importOp = new ImportOperation(project
+ .getFullPath(), zipStructureProvider.getRoot(),
+ zipStructureProvider, overwrite);
+
+ importOp.setContext(PlatformUI.getWorkbench()
+ .getActiveWorkbenchWindow().getShell());
+
+ importOp.run(new NullProgressMonitor());
+ result = true;
+
+ } catch (InvocationTargetException e) {
+ e.printStackTrace();
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ return result;
+ }
+
+ /**
+ *
+ * @return
+ * @throws CoreException
+ */
+ public static Collection<IPath> getComponentsPaths() throws CoreException {
+ Collection<IPath> result = null;
+ IWorkspace workspace = ResourcesPlugin.getWorkspace();
+ IProject project = workspace.getRoot().getProject(PROJECT_NAME);
+ if (project != null) {
+ IFolder folder = project.getFolder(COMPONENTS_PATH);
+ IResource[] resources = folder.members();
+ if (resources != null && resources.length > 0) {
+ result = new ArrayList<IPath>(resources.length);
+ for (IResource res : resources) {
+ result.add(res.getFullPath());
+ }
+ }
+ }
+ return result;
+ }
+
+ /**
+ *
+ * @throws CoreException
+ */
+ public static void removeProject() throws CoreException {
+ IWorkspace workspace = ResourcesPlugin.getWorkspace();
+ IProject project = workspace.getRoot().getProject(PROJECT_NAME);
+ project.delete(IResource.ALWAYS_DELETE_PROJECT_CONTENT,
+ new NullProgressMonitor());
+ }
+}
Property changes on:
branches/jbosstools_xulrunner/vpe/tests/org.jboss.tools.vpe.test.richfaces/src/org/jboss/tools/vpe/test/richfaces/ImportRichFacesComponents.java
___________________________________________________________________
Name: svn:executable
+ *
Added:
branches/jbosstools_xulrunner/vpe/tests/org.jboss.tools.vpe.test.richfaces/src/org/jboss/tools/vpe/test/richfaces/RichFacesAllTest.java
===================================================================
---
branches/jbosstools_xulrunner/vpe/tests/org.jboss.tools.vpe.test.richfaces/src/org/jboss/tools/vpe/test/richfaces/RichFacesAllTest.java
(rev 0)
+++
branches/jbosstools_xulrunner/vpe/tests/org.jboss.tools.vpe.test.richfaces/src/org/jboss/tools/vpe/test/richfaces/RichFacesAllTest.java 2007-10-12
13:25:12 UTC (rev 4158)
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * 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.vpe.test.richfaces;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ * Class for testing all RichFaces components
+ *
+ * @author dsakovich(a)exadel.com
+ *
+ */
+
+public class RichFacesAllTest {
+
+ public static Test suite() {
+ TestSuite suite = new TestSuite("Tests for Vpe RichFaces components");
+ // $JUnit-BEGIN$
+ suite.addTestSuite(RichFacesComponentTest.class);
+ // $JUnit-END$
+ return suite;
+
+ }
+
+}
Property changes on:
branches/jbosstools_xulrunner/vpe/tests/org.jboss.tools.vpe.test.richfaces/src/org/jboss/tools/vpe/test/richfaces/RichFacesAllTest.java
___________________________________________________________________
Name: svn:executable
+ *
Added:
branches/jbosstools_xulrunner/vpe/tests/org.jboss.tools.vpe.test.richfaces/src/org/jboss/tools/vpe/test/richfaces/RichFacesComponentTest.java
===================================================================
---
branches/jbosstools_xulrunner/vpe/tests/org.jboss.tools.vpe.test.richfaces/src/org/jboss/tools/vpe/test/richfaces/RichFacesComponentTest.java
(rev 0)
+++
branches/jbosstools_xulrunner/vpe/tests/org.jboss.tools.vpe.test.richfaces/src/org/jboss/tools/vpe/test/richfaces/RichFacesComponentTest.java 2007-10-12
13:25:12 UTC (rev 4158)
@@ -0,0 +1,151 @@
+/*******************************************************************************
+ * 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.vpe.test.richfaces;
+
+import java.util.Collection;
+
+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.IPath;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.part.FileEditorInput;
+
+/**
+ * Class for testing all RichFaces components
+ *
+ * @author dsakovich(a)exadel.com
+ *
+ */
+public class RichFacesComponentTest extends TestCase implements ILogListener {
+
+ private final static String EDITOR_ID =
"org.jboss.tools.jst.jsp.jspeditor.JSPTextEditor";
+ private final static String TEST_PROJECT_JAR_PATH = "/richFacesTest.jar";
+
+ // check warning log
+ private final static boolean checkWarning = false;
+ private boolean failureLog;
+ private Collection<IPath> components = null;
+
+ public RichFacesComponentTest(String name) {
+ super(name);
+ }
+
+ /**
+ * Perform pre-test initialization.
+ *
+ * @throws Exception
+ *
+ * @see TestCase#setUp()
+ */
+ protected void setUp() throws Exception {
+ super.setUp();
+ if (ImportRichFacesComponents.importRichFacesPages(Activator
+ .getPluginResourcePath()
+ + TEST_PROJECT_JAR_PATH)) {
+ components = ImportRichFacesComponents.getComponentsPaths();
+ }
+ failureLog = false;
+ waitForJobs();
+ Platform.addLogListener(this);
+ waitForJobs();
+ delay(5000);
+ }
+
+ /**
+ * Perform post-test cleanup.
+ *
+ * @throws Exception
+ *
+ * @see TestCase#tearDown()
+ */
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ ImportRichFacesComponents.removeProject();
+ waitForJobs();
+ Platform.removeLogListener(this);
+ }
+
+ /**
+ * Process UI input but do not return for the specified time interval.
+ *
+ * @param waitTimeMillis
+ * the number of milliseconds
+ */
+ private void delay(long waitTimeMillis) {
+ Display display = Display.getCurrent();
+ if (display != null) {
+ long endTimeMillis = 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 void waitForJobs() {
+ while (Platform.getJobManager().currentJob() != null)
+ delay(5000);
+ }
+
+ public void testRichFacesComponent() throws PartInitException {
+ waitForJobs();
+
+ for (IPath componentPath : components) {
+ IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(
+ componentPath);
+ IEditorInput input = new FileEditorInput(file);
+ PlatformUI.getWorkbench().getActiveWorkbenchWindow()
+ .getActivePage().openEditor(input, EDITOR_ID, true);
+
+ waitForJobs();
+ delay(3000);
+ PlatformUI.getWorkbench().getActiveWorkbenchWindow()
+ .getActivePage().closeAllEditors(true);
+ }
+ assertEquals(failureLog, false);
+ }
+
+ public void logging(IStatus status, String plugin) {
+ switch (status.getSeverity()) {
+ case IStatus.ERROR:
+ failureLog = true;
+ break;
+ case IStatus.WARNING:
+ if (checkWarning)
+ failureLog = true;
+ break;
+ default:
+ break;
+ }
+
+ }
+
+}
Property changes on:
branches/jbosstools_xulrunner/vpe/tests/org.jboss.tools.vpe.test.richfaces/src/org/jboss/tools/vpe/test/richfaces/RichFacesComponentTest.java
___________________________________________________________________
Name: svn:executable
+ *