Author: svasilyev
Date: 2007-10-19 06:14:24 -0400 (Fri, 19 Oct 2007)
New Revision: 4371
Added:
trunk/vpe/tests/org.jboss.tools.vpe.test/src/org/jboss/tools/vpe/test/
trunk/vpe/tests/org.jboss.tools.vpe.test/src/org/jboss/tools/vpe/test/AllTests.java
trunk/vpe/tests/org.jboss.tools.vpe.test/src/org/jboss/tools/vpe/test/TemplateLoadingTest.java
trunk/vpe/tests/org.jboss.tools.vpe.test/src/org/jboss/tools/vpe/test/TemplatesExpressionParsingTest.java
trunk/vpe/tests/org.jboss.tools.vpe.test/src/org/jboss/tools/vpe/test/VpeTestPlugin.java
Removed:
trunk/vpe/tests/org.jboss.tools.vpe.test/src/org/jboss/tools/vpe/test/TemplateLoadingTest.java
trunk/vpe/tests/org.jboss.tools.vpe.test/src/org/jboss/tools/vpe/test/TemplatesExpressionParsingTest.java
trunk/vpe/tests/org.jboss.tools.vpe.test/src/org/jboss/tools/vpe/test/VpeAllTests.java
trunk/vpe/tests/org.jboss.tools.vpe.test/src/org/jboss/tools/vpe/test/VpeTestPlugin.java
trunk/vpe/tests/org.jboss.tools.vpe.test/src/org/jboss/tools/vpe/tests/
Modified:
trunk/vpe/tests/org.jboss.tools.vpe.test/
trunk/vpe/tests/org.jboss.tools.vpe.test/META-INF/MANIFEST.MF
Log:
Tests were fixed to be run on XULRunner
Property changes on: trunk/vpe/tests/org.jboss.tools.vpe.test
___________________________________________________________________
Name: svn:ignore
- bin
+ bin
AllTests.txt
Modified: trunk/vpe/tests/org.jboss.tools.vpe.test/META-INF/MANIFEST.MF
===================================================================
--- trunk/vpe/tests/org.jboss.tools.vpe.test/META-INF/MANIFEST.MF 2007-10-19 10:12:54 UTC
(rev 4370)
+++ trunk/vpe/tests/org.jboss.tools.vpe.test/META-INF/MANIFEST.MF 2007-10-19 10:14:24 UTC
(rev 4371)
@@ -3,7 +3,7 @@
Bundle-Name: Tests Plug-in
Bundle-SymbolicName: org.jboss.tools.vpe.test;singleton:=true
Bundle-Version: 2.0.0
-Bundle-Activator: org.jboss.tools.vpe.tests.VpeTestPlugin
+Bundle-Activator: org.jboss.tools.vpe.test.VpeTestPlugin
Bundle-Vendor: RedHat
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
@@ -11,5 +11,5 @@
org.jboss.tools.common,
org.jboss.tools.vpe
Eclipse-LazyStart: true
-Export-Package: org.jboss.tools.vpe.tests
+Export-Package: org.jboss.tools.vpe.test
Bundle-ClassPath: vpe-tests.jar
Copied: trunk/vpe/tests/org.jboss.tools.vpe.test/src/org/jboss/tools/vpe/test (from rev
4348, trunk/vpe/tests/org.jboss.tools.vpe.test/src/org/jboss/tools/vpe/tests)
Copied:
trunk/vpe/tests/org.jboss.tools.vpe.test/src/org/jboss/tools/vpe/test/AllTests.java (from
rev 4348,
trunk/vpe/tests/org.jboss.tools.vpe.test/src/org/jboss/tools/vpe/tests/VpeAllTests.java)
===================================================================
--- trunk/vpe/tests/org.jboss.tools.vpe.test/src/org/jboss/tools/vpe/test/AllTests.java
(rev 0)
+++
trunk/vpe/tests/org.jboss.tools.vpe.test/src/org/jboss/tools/vpe/test/AllTests.java 2007-10-19
10:14:24 UTC (rev 4371)
@@ -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;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+/**
+ * Class created for run tests for org.jboss.tools.vpe plugin.
+ *
+ * @author Max Areshkau
+ *
+ */
+
+public class AllTests extends TestCase{
+
+ public static Test suite(){
+ TestSuite suite = new TestSuite("Tests for vpe");
+ // $JUnit-BEGIN$
+ suite.addTestSuite(TemplateLoadingTest.class);
+ suite.addTestSuite(TemplatesExpressionParsingTest.class);
+ // $JUnit-END$
+ return suite;
+ }
+}
Deleted:
trunk/vpe/tests/org.jboss.tools.vpe.test/src/org/jboss/tools/vpe/test/TemplateLoadingTest.java
===================================================================
---
trunk/vpe/tests/org.jboss.tools.vpe.test/src/org/jboss/tools/vpe/tests/TemplateLoadingTest.java 2007-10-18
18:27:14 UTC (rev 4348)
+++
trunk/vpe/tests/org.jboss.tools.vpe.test/src/org/jboss/tools/vpe/test/TemplateLoadingTest.java 2007-10-19
10:14:24 UTC (rev 4371)
@@ -1,114 +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.vpe.tests;
-
-import java.io.File;
-import java.io.IOException;
-import java.net.URL;
-import org.eclipse.core.runtime.FileLocator;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IExtension;
-import org.eclipse.core.runtime.IExtensionPoint;
-import org.eclipse.core.runtime.IExtensionRegistry;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Platform;
-import org.osgi.framework.Bundle;
-import org.w3c.dom.Element;
-import org.jboss.tools.common.xml.XMLUtilities;
-import org.jboss.tools.vpe.VpePlugin;
-import org.jboss.tools.vpe.editor.template.VpeHtmlTemplate;
-import org.jboss.tools.vpe.editor.template.VpeTemplate;
-import junit.framework.TestCase;
-
-/**
- * JUnit Test for Loading templates
- *
- * @author Alexey Yukhovich
- */
-public class TemplateLoadingTest extends TestCase {
- /**
- * Extension point ID
- */
- private static final String COM_REDHAT_VPE_TEMPLATES =
"org.jboss.tools.vpe.templates";
-
- /**
- * Test for load all templates
- */
- public void testParseTemplates() {
- //
- IExtensionRegistry extensionRepository = Platform
- .getExtensionRegistry();
-
- IExtensionPoint extensionPoint = extensionRepository
- .getExtensionPoint(COM_REDHAT_VPE_TEMPLATES);
- IExtension[] extensions = extensionPoint.getExtensions();
-
- // iterate for all extensions
- for (int i = 0; i < extensions.length; i++) {
- IExtension extension = extensions[i];
- IConfigurationElement[] elements = extension
- .getConfigurationElements();
- for (int j = 0; j < elements.length; j++) {
- String pathAttrValue = elements[j].getAttribute("path");
-
- try {
- IPath templateFile = getFullpathForConfigurationElement(
- pathAttrValue, elements[j]);
-
- File file = templateFile.toFile();
- if (file.exists() && file.isFile()) {
- Element rootElement =
XMLUtilities.getElement(templateFile.toFile(), null);
- assertNotNull("Cannot parse template " +
templateFile.toFile(), rootElement);
- VpeTemplate vpeTemplate = new VpeHtmlTemplate();
- vpeTemplate.init(rootElement, false);
- }
- } catch (IOException ioException) {
- fail(ioException.getMessage());
- }
- }
- }
- }
-
-
- /**
- * Get a full path for IConfigurationElement
- *
- * @param fileName
- * a String contain relevant fileName
- * @param confElement
- * a IConfigurationElement
- * @return full path for IConfigurationElement
- * @throws IOException
- * if an error occurs during the conversion
- */
- private static IPath getFullpathForConfigurationElement(String name,
- IConfigurationElement confElement) throws IOException {
- // 1. get a shared instance
- VpePlugin plugin = VpePlugin.getDefault();
-
- Bundle bundle = null;
-
- if (confElement == null) {
- bundle = plugin.getBundle();
- } else {
- bundle = Platform.getBundle(confElement.getNamespaceIdentifier());
- }
-
- URL url = bundle.getEntry("/");
-
- IPath path = new Path(FileLocator.toFileURL(url).getFile());
- path = path.append(name);
- return path;
- }
-
-
-}
Copied:
trunk/vpe/tests/org.jboss.tools.vpe.test/src/org/jboss/tools/vpe/test/TemplateLoadingTest.java
(from rev 4369,
trunk/vpe/tests/org.jboss.tools.vpe.test/src/org/jboss/tools/vpe/tests/TemplateLoadingTest.java)
===================================================================
---
trunk/vpe/tests/org.jboss.tools.vpe.test/src/org/jboss/tools/vpe/test/TemplateLoadingTest.java
(rev 0)
+++
trunk/vpe/tests/org.jboss.tools.vpe.test/src/org/jboss/tools/vpe/test/TemplateLoadingTest.java 2007-10-19
10:14:24 UTC (rev 4371)
@@ -0,0 +1,114 @@
+/*******************************************************************************
+ * 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;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URL;
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtension;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.IExtensionRegistry;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Platform;
+import org.osgi.framework.Bundle;
+import org.w3c.dom.Element;
+import org.jboss.tools.common.xml.XMLUtilities;
+import org.jboss.tools.vpe.VpePlugin;
+import org.jboss.tools.vpe.editor.template.VpeHtmlTemplate;
+import org.jboss.tools.vpe.editor.template.VpeTemplate;
+import junit.framework.TestCase;
+
+/**
+ * JUnit Test for Loading templates
+ *
+ * @author Alexey Yukhovich
+ */
+public class TemplateLoadingTest extends TestCase {
+ /**
+ * Extension point ID
+ */
+ private static final String COM_REDHAT_VPE_TEMPLATES =
"org.jboss.tools.vpe.templates";
+
+ /**
+ * Test for load all templates
+ */
+ public void testParseTemplates() {
+ //
+ IExtensionRegistry extensionRepository = Platform
+ .getExtensionRegistry();
+
+ IExtensionPoint extensionPoint = extensionRepository
+ .getExtensionPoint(COM_REDHAT_VPE_TEMPLATES);
+ IExtension[] extensions = extensionPoint.getExtensions();
+
+ // iterate for all extensions
+ for (int i = 0; i < extensions.length; i++) {
+ IExtension extension = extensions[i];
+ IConfigurationElement[] elements = extension
+ .getConfigurationElements();
+ for (int j = 0; j < elements.length; j++) {
+ String pathAttrValue = elements[j].getAttribute("path");
+
+ try {
+ IPath templateFile = getFullpathForConfigurationElement(
+ pathAttrValue, elements[j]);
+
+ File file = templateFile.toFile();
+ if (file.exists() && file.isFile()) {
+ Element rootElement =
XMLUtilities.getElement(templateFile.toFile(), null);
+ assertNotNull("Cannot parse template " +
templateFile.toFile(), rootElement);
+ VpeTemplate vpeTemplate = new VpeHtmlTemplate();
+ vpeTemplate.init(rootElement, false);
+ }
+ } catch (IOException ioException) {
+ fail(ioException.getMessage());
+ }
+ }
+ }
+ }
+
+
+ /**
+ * Get a full path for IConfigurationElement
+ *
+ * @param fileName
+ * a String contain relevant fileName
+ * @param confElement
+ * a IConfigurationElement
+ * @return full path for IConfigurationElement
+ * @throws IOException
+ * if an error occurs during the conversion
+ */
+ private static IPath getFullpathForConfigurationElement(String name,
+ IConfigurationElement confElement) throws IOException {
+ // 1. get a shared instance
+ VpePlugin plugin = VpePlugin.getDefault();
+
+ Bundle bundle = null;
+
+ if (confElement == null) {
+ bundle = plugin.getBundle();
+ } else {
+ bundle = Platform.getBundle(confElement.getNamespaceIdentifier());
+ }
+
+ URL url = bundle.getEntry("/");
+
+ IPath path = new Path(FileLocator.toFileURL(url).getFile());
+ path = path.append(name);
+ return path;
+ }
+
+
+}
Deleted:
trunk/vpe/tests/org.jboss.tools.vpe.test/src/org/jboss/tools/vpe/test/TemplatesExpressionParsingTest.java
===================================================================
---
trunk/vpe/tests/org.jboss.tools.vpe.test/src/org/jboss/tools/vpe/tests/TemplatesExpressionParsingTest.java 2007-10-18
18:27:14 UTC (rev 4348)
+++
trunk/vpe/tests/org.jboss.tools.vpe.test/src/org/jboss/tools/vpe/test/TemplatesExpressionParsingTest.java 2007-10-19
10:14:24 UTC (rev 4371)
@@ -1,188 +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.vpe.tests;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.net.URL;
-import org.eclipse.core.internal.registry.ExtensionRegistry;
-import org.eclipse.core.runtime.ContributorFactoryOSGi;
-import org.eclipse.core.runtime.FileLocator;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IContributor;
-import org.eclipse.core.runtime.IExtension;
-import org.eclipse.core.runtime.IExtensionPoint;
-import org.eclipse.core.runtime.IExtensionRegistry;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.RegistryFactory;
-import org.osgi.framework.Bundle;
-import org.jboss.tools.vpe.editor.template.VpeTemplateManager;
-import org.jboss.tools.common.reporting.IProblemReporter;
-import org.jboss.tools.common.reporting.ProblemReporterFactory;
-import junit.framework.TestCase;
-
-/**
- * This class created for testing templates expression.
- *
- * @author Max Areshkau
- */
-public class TemplatesExpressionParsingTest extends TestCase {
-
- private static final String PLUGIN_FAILURE_NAME = "testFailure-plugin.xml";
-
- private static final String PLUGIN_OK_NAME = "testOk-plugin.xml";
-
- private static final String EXTENSION_POINT_ID =
"org.jboss.tools.vpe.templates";
-
- private static final String EXTENSION_ERROR_EXTENSION_ID_1 =
"org.jboss.tools.vpe.tests.failureExtensions";
-
- private static final String EXTENSION_ERROR_EXTENSION_ID_2 =
"org.jboss.tools.vpe.tests.okExtensions";
-
- private IStatus iStatus = null;
-
- private int errorNumber = 0;
-
- private VpeTemplateManager vpeTemplateManager;
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- // sets problem reporter
- ProblemReporterFactory reporter = ProblemReporterFactory.getInstance();
- reporter.setReporter(new IProblemReporter() {
- public void reportProblem(IStatus status) {
- errorNumber++;
- iStatus = status;
- }
- });
- }
-
- @Override
- protected void tearDown() throws Exception {
- removeExtension(EXTENSION_POINT_ID, EXTENSION_ERROR_EXTENSION_ID_1);
- removeExtension(EXTENSION_POINT_ID, EXTENSION_ERROR_EXTENSION_ID_2);
- iStatus=null;
- errorNumber = 0;
- super.tearDown();
- }
-
- /**
- * Tests existing templates
- *
- * @throws Exception
- */
- public void testExistingTemplates() throws Exception {
-
- vpeTemplateManager = VpeTemplateManager.getInstance();
- vpeTemplateManager.reload();
- assertNull("Can not parse template from ReDHat DevStudio" + iStatus,
iStatus);
- assertEquals("There exist some errors", 0, errorNumber);
- assertNotNull(vpeTemplateManager);
- }
-
- /**
- * Creates test template and testing that extensions with errors have errors
- * variants
- *
- * @throws Exception
- */
- public void testIncorrectTemplates() throws Exception {
- createTemplatesForTesting(PLUGIN_FAILURE_NAME);
- vpeTemplateManager = VpeTemplateManager.getInstance();
- errorNumber = 0;
- vpeTemplateManager.reload();
- assertEquals("Number founds error is Incorrect ", 5, errorNumber);
- assertNotNull("Can not parse template from ReDHat DevStudio" + iStatus,
- iStatus);
- return;
- }
-
- /**
- * Creates test template and testing possible(without errors) variants
- *
- * @throws Exception
- */
- public void testCorrectTemplates() throws Exception {
- createTemplatesForTesting(PLUGIN_OK_NAME);
- vpeTemplateManager = VpeTemplateManager.getInstance();
- vpeTemplateManager.reload();
- assertNull("Can not parse template from ReDHat DevStudio" + iStatus,
iStatus);
- assertEquals("There exist some errors", 0, errorNumber);
- return;
- }
-
- /**
- * Tests passible template
- *
- * @throws Exception
- */
- private void createTemplatesForTesting(String pluginXmlFileName)
- throws Exception {
- IPath iPath = getFullpathForConfigurationElement(pluginXmlFileName, null);
- File file = iPath.toFile();
- FileInputStream is = new FileInputStream(file);
- IExtensionRegistry registry = RegistryFactory.getRegistry();
- Object key = ((ExtensionRegistry) registry).getTemporaryUserToken();
- Bundle bundle = VpeTestPlugin.getDefault().getBundle();
- IContributor contributor = ContributorFactoryOSGi
- .createContributor(bundle);
- registry.addContribution(is, contributor, false, null, null, key);
- }
-
- /**
- * Get a full path for IConfigurationElement
- *
- * @param fileName
- * a String contain relevant fileName
- * @param confElement
- * a IConfigurationElement
- * @return full path for IConfigurationElement
- * @throws IOException
- * if an error occurs during the conversion
- */
- private static IPath getFullpathForConfigurationElement(String name,
- IConfigurationElement confElement) throws IOException {
- // 1. get a shared instance
- VpeTestPlugin plugin = VpeTestPlugin.getDefault();
-
- Bundle bundle = null;
-
- if (confElement == null) {
- bundle = plugin.getBundle();
- } else {
- bundle = Platform.getBundle(confElement.getNamespaceIdentifier());
- }
-
- URL url = bundle.getEntry("/");
-
- IPath path = new Path(FileLocator.toFileURL(url).getFile());
- path = path.append(name);
- return path;
- }
-
- /**
- * Removing extensions from eclipse
- *
- * @param extensionPointId
- * @param extensionId
- */
- private void removeExtension(String extensionPointId, String extensionId) {
- // use Eclipse Dynamic Extension API
- IExtensionRegistry reg = RegistryFactory.getRegistry();
- Object token = ((ExtensionRegistry) reg).getTemporaryUserToken();
- IExtension extension = reg.getExtension(extensionPointId, extensionId);
- reg.removeExtension(extension, token);
- }
-}
Copied:
trunk/vpe/tests/org.jboss.tools.vpe.test/src/org/jboss/tools/vpe/test/TemplatesExpressionParsingTest.java
(from rev 4369,
trunk/vpe/tests/org.jboss.tools.vpe.test/src/org/jboss/tools/vpe/tests/TemplatesExpressionParsingTest.java)
===================================================================
---
trunk/vpe/tests/org.jboss.tools.vpe.test/src/org/jboss/tools/vpe/test/TemplatesExpressionParsingTest.java
(rev 0)
+++
trunk/vpe/tests/org.jboss.tools.vpe.test/src/org/jboss/tools/vpe/test/TemplatesExpressionParsingTest.java 2007-10-19
10:14:24 UTC (rev 4371)
@@ -0,0 +1,188 @@
+/*******************************************************************************
+ * 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;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.net.URL;
+import org.eclipse.core.internal.registry.ExtensionRegistry;
+import org.eclipse.core.runtime.ContributorFactoryOSGi;
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IContributor;
+import org.eclipse.core.runtime.IExtension;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.IExtensionRegistry;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.RegistryFactory;
+import org.osgi.framework.Bundle;
+import org.jboss.tools.vpe.editor.template.VpeTemplateManager;
+import org.jboss.tools.common.reporting.IProblemReporter;
+import org.jboss.tools.common.reporting.ProblemReporterFactory;
+import junit.framework.TestCase;
+
+/**
+ * This class created for testing templates expression.
+ *
+ * @author Max Areshkau
+ */
+public class TemplatesExpressionParsingTest extends TestCase {
+
+ private static final String PLUGIN_FAILURE_NAME = "testFailure-plugin.xml";
+
+ private static final String PLUGIN_OK_NAME = "testOk-plugin.xml";
+
+ private static final String EXTENSION_POINT_ID =
"org.jboss.tools.vpe.templates";
+
+ private static final String EXTENSION_ERROR_EXTENSION_ID_1 =
"org.jboss.tools.vpe.tests.failureExtensions";
+
+ private static final String EXTENSION_ERROR_EXTENSION_ID_2 =
"org.jboss.tools.vpe.tests.okExtensions";
+
+ private IStatus iStatus = null;
+
+ private int errorNumber = 0;
+
+ private VpeTemplateManager vpeTemplateManager;
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ // sets problem reporter
+ ProblemReporterFactory reporter = ProblemReporterFactory.getInstance();
+ reporter.setReporter(new IProblemReporter() {
+ public void reportProblem(IStatus status) {
+ errorNumber++;
+ iStatus = status;
+ }
+ });
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ removeExtension(EXTENSION_POINT_ID, EXTENSION_ERROR_EXTENSION_ID_1);
+ removeExtension(EXTENSION_POINT_ID, EXTENSION_ERROR_EXTENSION_ID_2);
+ iStatus=null;
+ errorNumber = 0;
+ super.tearDown();
+ }
+
+ /**
+ * Tests existing templates
+ *
+ * @throws Exception
+ */
+ public void testExistingTemplates() throws Exception {
+
+ vpeTemplateManager = VpeTemplateManager.getInstance();
+ vpeTemplateManager.reload();
+ assertNull("Can not parse template from ReDHat DevStudio" + iStatus,
iStatus);
+ assertEquals("There exist some errors", 0, errorNumber);
+ assertNotNull(vpeTemplateManager);
+ }
+
+ /**
+ * Creates test template and testing that extensions with errors have errors
+ * variants
+ *
+ * @throws Exception
+ */
+ public void testIncorrectTemplates() throws Exception {
+ createTemplatesForTesting(PLUGIN_FAILURE_NAME);
+ vpeTemplateManager = VpeTemplateManager.getInstance();
+ errorNumber = 0;
+ vpeTemplateManager.reload();
+ assertEquals("Number founds error is Incorrect ", 5, errorNumber);
+ assertNotNull("Can not parse template from ReDHat DevStudio" + iStatus,
+ iStatus);
+ return;
+ }
+
+ /**
+ * Creates test template and testing possible(without errors) variants
+ *
+ * @throws Exception
+ */
+ public void testCorrectTemplates() throws Exception {
+ createTemplatesForTesting(PLUGIN_OK_NAME);
+ vpeTemplateManager = VpeTemplateManager.getInstance();
+ vpeTemplateManager.reload();
+ assertNull("Can not parse template from ReDHat DevStudio" + iStatus,
iStatus);
+ assertEquals("There exist some errors", 0, errorNumber);
+ return;
+ }
+
+ /**
+ * Tests passible template
+ *
+ * @throws Exception
+ */
+ private void createTemplatesForTesting(String pluginXmlFileName)
+ throws Exception {
+ IPath iPath = getFullpathForConfigurationElement(pluginXmlFileName, null);
+ File file = iPath.toFile();
+ FileInputStream is = new FileInputStream(file);
+ IExtensionRegistry registry = RegistryFactory.getRegistry();
+ Object key = ((ExtensionRegistry) registry).getTemporaryUserToken();
+ Bundle bundle = VpeTestPlugin.getDefault().getBundle();
+ IContributor contributor = ContributorFactoryOSGi
+ .createContributor(bundle);
+ registry.addContribution(is, contributor, false, null, null, key);
+ }
+
+ /**
+ * Get a full path for IConfigurationElement
+ *
+ * @param fileName
+ * a String contain relevant fileName
+ * @param confElement
+ * a IConfigurationElement
+ * @return full path for IConfigurationElement
+ * @throws IOException
+ * if an error occurs during the conversion
+ */
+ private static IPath getFullpathForConfigurationElement(String name,
+ IConfigurationElement confElement) throws IOException {
+ // 1. get a shared instance
+ VpeTestPlugin plugin = VpeTestPlugin.getDefault();
+
+ Bundle bundle = null;
+
+ if (confElement == null) {
+ bundle = plugin.getBundle();
+ } else {
+ bundle = Platform.getBundle(confElement.getNamespaceIdentifier());
+ }
+
+ URL url = bundle.getEntry("/");
+
+ IPath path = new Path(FileLocator.toFileURL(url).getFile());
+ path = path.append(name);
+ return path;
+ }
+
+ /**
+ * Removing extensions from eclipse
+ *
+ * @param extensionPointId
+ * @param extensionId
+ */
+ private void removeExtension(String extensionPointId, String extensionId) {
+ // use Eclipse Dynamic Extension API
+ IExtensionRegistry reg = RegistryFactory.getRegistry();
+ Object token = ((ExtensionRegistry) reg).getTemporaryUserToken();
+ IExtension extension = reg.getExtension(extensionPointId, extensionId);
+ reg.removeExtension(extension, token);
+ }
+}
Deleted:
trunk/vpe/tests/org.jboss.tools.vpe.test/src/org/jboss/tools/vpe/test/VpeAllTests.java
===================================================================
---
trunk/vpe/tests/org.jboss.tools.vpe.test/src/org/jboss/tools/vpe/tests/VpeAllTests.java 2007-10-18
18:27:14 UTC (rev 4348)
+++
trunk/vpe/tests/org.jboss.tools.vpe.test/src/org/jboss/tools/vpe/test/VpeAllTests.java 2007-10-19
10:14:24 UTC (rev 4371)
@@ -1,34 +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.vpe.tests;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-/**
- * Class created for run tests for org.jboss.tools.vpe plugin.
- *
- * @author Max Areshkau
- *
- */
-
-public class VpeAllTests extends TestCase{
-
- public static Test suite(){
- TestSuite suite = new TestSuite("Tests for vpe");
- // $JUnit-BEGIN$
- suite.addTestSuite(TemplateLoadingTest.class);
- suite.addTestSuite(TemplatesExpressionParsingTest.class);
- // $JUnit-END$
- return suite;
- }
-}
Deleted:
trunk/vpe/tests/org.jboss.tools.vpe.test/src/org/jboss/tools/vpe/test/VpeTestPlugin.java
===================================================================
---
trunk/vpe/tests/org.jboss.tools.vpe.test/src/org/jboss/tools/vpe/tests/VpeTestPlugin.java 2007-10-18
18:27:14 UTC (rev 4348)
+++
trunk/vpe/tests/org.jboss.tools.vpe.test/src/org/jboss/tools/vpe/test/VpeTestPlugin.java 2007-10-19
10:14:24 UTC (rev 4371)
@@ -1,60 +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.vpe.tests;
-
-import org.eclipse.core.runtime.Plugin;
-import org.osgi.framework.BundleContext;
-
-/**
- * The activator class controls the plug-in life cycle
- */
-public class VpeTestPlugin extends Plugin {
-
- // The plug-in ID
- public static final String PLUGIN_ID = "org.jboss.ide.vpe.tests";
-
- // The shared instance
- private static VpeTestPlugin plugin;
-
- /**
- * The constructor
- */
- public VpeTestPlugin() {
- plugin = this;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
- */
- public void start(BundleContext context) throws Exception {
- super.start(context);
- }
-
- /*
- * (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 VpeTestPlugin getDefault() {
- return plugin;
- }
-
-}
Copied:
trunk/vpe/tests/org.jboss.tools.vpe.test/src/org/jboss/tools/vpe/test/VpeTestPlugin.java
(from rev 4369,
trunk/vpe/tests/org.jboss.tools.vpe.test/src/org/jboss/tools/vpe/tests/VpeTestPlugin.java)
===================================================================
---
trunk/vpe/tests/org.jboss.tools.vpe.test/src/org/jboss/tools/vpe/test/VpeTestPlugin.java
(rev 0)
+++
trunk/vpe/tests/org.jboss.tools.vpe.test/src/org/jboss/tools/vpe/test/VpeTestPlugin.java 2007-10-19
10:14:24 UTC (rev 4371)
@@ -0,0 +1,60 @@
+/*******************************************************************************
+ * 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;
+
+import org.eclipse.core.runtime.Plugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class VpeTestPlugin extends Plugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "org.jboss.ide.vpe.tests";
+
+ // The shared instance
+ private static VpeTestPlugin plugin;
+
+ /**
+ * The constructor
+ */
+ public VpeTestPlugin() {
+ plugin = this;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ }
+
+ /*
+ * (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 VpeTestPlugin getDefault() {
+ return plugin;
+ }
+
+}