Author: dsakovich
Date: 2007-12-13 12:14:17 -0500 (Thu, 13 Dec 2007)
New Revision: 5290
Added:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.seam.test/.classpath
trunk/jsf/tests/org.jboss.tools.jsf.vpe.seam.test/.project
trunk/jsf/tests/org.jboss.tools.jsf.vpe.seam.test/META-INF/
trunk/jsf/tests/org.jboss.tools.jsf.vpe.seam.test/META-INF/MANIFEST.MF
trunk/jsf/tests/org.jboss.tools.jsf.vpe.seam.test/build.properties
trunk/jsf/tests/org.jboss.tools.jsf.vpe.seam.test/resources/
trunk/jsf/tests/org.jboss.tools.jsf.vpe.seam.test/resources/seamtest.jar
trunk/jsf/tests/org.jboss.tools.jsf.vpe.seam.test/src/
trunk/jsf/tests/org.jboss.tools.jsf.vpe.seam.test/src/org/
trunk/jsf/tests/org.jboss.tools.jsf.vpe.seam.test/src/org/jboss/
trunk/jsf/tests/org.jboss.tools.jsf.vpe.seam.test/src/org/jboss/tools/
trunk/jsf/tests/org.jboss.tools.jsf.vpe.seam.test/src/org/jboss/tools/jsf/
trunk/jsf/tests/org.jboss.tools.jsf.vpe.seam.test/src/org/jboss/tools/jsf/vpe/
trunk/jsf/tests/org.jboss.tools.jsf.vpe.seam.test/src/org/jboss/tools/jsf/vpe/seam/
trunk/jsf/tests/org.jboss.tools.jsf.vpe.seam.test/src/org/jboss/tools/jsf/vpe/seam/test/
trunk/jsf/tests/org.jboss.tools.jsf.vpe.seam.test/src/org/jboss/tools/jsf/vpe/seam/test/ImportSeamComponents.java
trunk/jsf/tests/org.jboss.tools.jsf.vpe.seam.test/src/org/jboss/tools/jsf/vpe/seam/test/SeamAllTests.java
trunk/jsf/tests/org.jboss.tools.jsf.vpe.seam.test/src/org/jboss/tools/jsf/vpe/seam/test/SeamComponentTest.java
trunk/jsf/tests/org.jboss.tools.jsf.vpe.seam.test/src/org/jboss/tools/jsf/vpe/seam/test/SeamTestPlugin.java
Log:
http://jira.jboss.com/jira/browse/JBIDE-1491
Added: trunk/jsf/tests/org.jboss.tools.jsf.vpe.seam.test/.classpath
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.vpe.seam.test/.classpath
(rev 0)
+++ trunk/jsf/tests/org.jboss.tools.jsf.vpe.seam.test/.classpath 2007-12-13 17:14:17 UTC
(rev 5290)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="con"
path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="con"
path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
Added: trunk/jsf/tests/org.jboss.tools.jsf.vpe.seam.test/.project
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.vpe.seam.test/.project
(rev 0)
+++ trunk/jsf/tests/org.jboss.tools.jsf.vpe.seam.test/.project 2007-12-13 17:14:17 UTC
(rev 5290)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.jboss.tools.jsf.vpe.seam.test</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>
Added: trunk/jsf/tests/org.jboss.tools.jsf.vpe.seam.test/META-INF/MANIFEST.MF
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.vpe.seam.test/META-INF/MANIFEST.MF
(rev 0)
+++ trunk/jsf/tests/org.jboss.tools.jsf.vpe.seam.test/META-INF/MANIFEST.MF 2007-12-13
17:14:17 UTC (rev 5290)
@@ -0,0 +1,14 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Seam Test Plug-in
+Bundle-SymbolicName: org.jboss.tools.jsf.vpe.seam.test
+Bundle-Version: 1.0.0
+Bundle-Activator: org.jboss.tools.jsf.vpe.seam.test.SeamTestPlugin
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.eclipse.core.resources,
+ org.eclipse.ui.ide,
+ org.jboss.tools.common,
+ org.junit,
+ org.jboss.tools.vpe
+Eclipse-LazyStart: true
Added: trunk/jsf/tests/org.jboss.tools.jsf.vpe.seam.test/build.properties
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.vpe.seam.test/build.properties
(rev 0)
+++ trunk/jsf/tests/org.jboss.tools.jsf.vpe.seam.test/build.properties 2007-12-13 17:14:17
UTC (rev 5290)
@@ -0,0 +1,4 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .
Added: trunk/jsf/tests/org.jboss.tools.jsf.vpe.seam.test/resources/seamtest.jar
===================================================================
(Binary files differ)
Property changes on:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.seam.test/resources/seamtest.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.seam.test/src/org/jboss/tools/jsf/vpe/seam/test/ImportSeamComponents.java
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.vpe.seam.test/src/org/jboss/tools/jsf/vpe/seam/test/ImportSeamComponents.java
(rev 0)
+++
trunk/jsf/tests/org.jboss.tools.jsf.vpe.seam.test/src/org/jboss/tools/jsf/vpe/seam/test/ImportSeamComponents.java 2007-12-13
17:14:17 UTC (rev 5290)
@@ -0,0 +1,92 @@
+package org.jboss.tools.jsf.vpe.seam.test;
+
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+import java.util.zip.ZipFile;
+
+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.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 dsakovich(a)exadel.com
+ *
+ */
+public class ImportSeamComponents {
+ private static final String PROJECT_NAME = "SeamTest"; // $NON-NLS-1$
+ private static final String COMPONENTS_PATH = "WebContent/pages"; //
$NON-NLS-1$
+
+ @SuppressWarnings("restriction")
+ static void importSeamPages(String path) {
+ IProject project = ResourcesPlugin.getWorkspace().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());
+ } catch (InvocationTargetException ite) {
+ SeamTestPlugin.getPluginLog().logError(ite.getCause());
+ } catch (InterruptedException ie) {
+ SeamTestPlugin.getPluginLog().logError(ie);
+ } catch (IOException e) {
+ SeamTestPlugin.getPluginLog().logError(e);
+ }
+ }
+
+ /**
+ *
+ * @return
+ * @throws CoreException
+ */
+ static IPath getComponentPath(String componentPage) throws CoreException {
+ IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(
+ PROJECT_NAME);
+ if (project != null) {
+ IResource resource = project.getFolder(COMPONENTS_PATH).findMember(
+ componentPage);
+ if (resource != null) {
+ return resource.getFullPath();
+ }
+
+ }
+
+ return null;
+ }
+
+ /**
+ *
+ * @throws CoreException
+ */
+ static void removeProject() throws CoreException {
+ IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(
+ PROJECT_NAME);
+ if (project != null) {
+ project.delete(IResource.ALWAYS_DELETE_PROJECT_CONTENT,
+ new NullProgressMonitor());
+ }
+ }
+}
Added:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.seam.test/src/org/jboss/tools/jsf/vpe/seam/test/SeamAllTests.java
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.vpe.seam.test/src/org/jboss/tools/jsf/vpe/seam/test/SeamAllTests.java
(rev 0)
+++
trunk/jsf/tests/org.jboss.tools.jsf.vpe.seam.test/src/org/jboss/tools/jsf/vpe/seam/test/SeamAllTests.java 2007-12-13
17:14:17 UTC (rev 5290)
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * 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.seam.test;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ * Class for testing all Seam components
+ *
+ * @author dsakovich(a)exadel.com
+ *
+ */
+
+public class SeamAllTests {
+ public static Test suite() {
+ TestSuite suite = new TestSuite("Tests for Vpe Seam components"); //
$NON-NLS-1$
+ // $JUnit-BEGIN$
+ suite.addTestSuite(SeamComponentTest.class);
+ // $JUnit-END$
+ return suite;
+
+ }
+}
Added:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.seam.test/src/org/jboss/tools/jsf/vpe/seam/test/SeamComponentTest.java
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.vpe.seam.test/src/org/jboss/tools/jsf/vpe/seam/test/SeamComponentTest.java
(rev 0)
+++
trunk/jsf/tests/org.jboss.tools.jsf.vpe.seam.test/src/org/jboss/tools/jsf/vpe/seam/test/SeamComponentTest.java 2007-12-13
17:14:17 UTC (rev 5290)
@@ -0,0 +1,165 @@
+/*******************************************************************************
+ * 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.seam.test;
+
+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.core.runtime.jobs.Job;
+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 Seam components
+ *
+ * @author dsakovich(a)exadel.com
+ *
+ */
+public class SeamComponentTest extends TestCase implements ILogListener{
+
+ private final static String EDITOR_ID =
"org.jboss.tools.jst.jsp.jspeditor.JSPTextEditor"; // $NON-NLS-1$
+ private final static String TEST_PROJECT_JAR_PATH = "/seamtest.jar"; //
$NON-NLS-1$
+
+ // check warning log
+ private final static boolean checkWarning = false;
+ private Throwable exception;
+
+ public SeamComponentTest(String name) {
+ super(name);
+ }
+
+ /**
+ * Perform pre-test initialization.
+ *
+ * @throws Exception
+ *
+ * @see TestCase#setUp()
+ */
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ // TODO: Use TestSetup to create and remove project once for all tests
+ // not for every one
+ if(ResourcesPlugin.getWorkspace().getRoot().findMember("SeamTest")==null) {
+
+ ImportSeamComponents.importSeamPages(SeamTestPlugin
+ .getPluginResourcePath() + TEST_PROJECT_JAR_PATH);
+
+ waitForJobs();
+ waitForJobs();
+ delay(5000);
+ }
+ Platform.addLogListener(this);
+ }
+
+ /**
+ * Perform post-test cleanup.
+ *
+ * @throws Exception
+ *
+ * @see TestCase#tearDown()
+ */
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ 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 (Job.getJobManager().currentJob() != null)
+ delay(5000);
+ }
+
+ public void testAllComponentsOnSinglePage() throws PartInitException, Throwable {
+ performTestForSeamComponent("seamtest.xhtml"); // $NON-NLS-1$
+ }
+
+ public void testButton() throws PartInitException, Throwable {
+ performTestForSeamComponent("button.xhtml"); // $NON-NLS-1$
+ }
+
+ public void testSpan() throws PartInitException, Throwable {
+ performTestForSeamComponent("span.xhtml"); // $NON-NLS-1$
+ }
+
+
+ private void performTestForSeamComponent(String componentPage) throws PartInitException,
Throwable {
+ waitForJobs();
+
+ exception = null;
+ IPath componentPath = ImportSeamComponents.getComponentPath(componentPage);
+
+ 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);
+
+ if (exception != null) {
+ throw exception;
+ }
+ }
+
+ public void logging(IStatus status, String plugin) {
+ switch (status.getSeverity()) {
+ case IStatus.ERROR:
+ exception = status.getException();
+ break;
+ case IStatus.WARNING:
+ if (checkWarning)
+ exception = status.getException();
+ break;
+ default:
+ break;
+ }
+
+ }
+
+}
Added:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.seam.test/src/org/jboss/tools/jsf/vpe/seam/test/SeamTestPlugin.java
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.vpe.seam.test/src/org/jboss/tools/jsf/vpe/seam/test/SeamTestPlugin.java
(rev 0)
+++
trunk/jsf/tests/org.jboss.tools.jsf.vpe.seam.test/src/org/jboss/tools/jsf/vpe/seam/test/SeamTestPlugin.java 2007-12-13
17:14:17 UTC (rev 5290)
@@ -0,0 +1,84 @@
+/*******************************************************************************
+ * 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.seam.test;
+
+import java.net.URL;
+
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.Platform;
+import org.jboss.tools.common.log.BaseUIPlugin;
+import org.jboss.tools.common.log.IPluginLog;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class SeamTestPlugin extends BaseUIPlugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID =
"org.jboss.tools.jsf.vpe.seam.test";
+
+ // The shared instance
+ private static SeamTestPlugin plugin;
+
+ /**
+ * The constructor
+ */
+ public SeamTestPlugin() {
+ }
+
+ /*
+ * (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 SeamTestPlugin getDefault() {
+ return plugin;
+ }
+
+ public static IPluginLog getPluginLog() {
+ return getDefault();
+ }
+
+ public static String getPluginResourcePath() {
+ Bundle bundle = Platform.getBundle(PLUGIN_ID);
+ URL url = null;
+ try {
+ url = bundle == null ? null : FileLocator.resolve(bundle
+ .getEntry("/resources")); // $NON-NLS-1$
+ } catch (Exception e) {
+ url = bundle.getEntry("/resources"); // $NON-NLS-1$
+ }
+ return (url == null) ? null : url.getPath();
+ }
+
+}