Author: dvinnichek
Date: 2010-08-26 02:29:45 -0400 (Thu, 26 Aug 2010)
New Revision: 24457
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe.spring/templates/vpe-templates-spring.xml
trunk/vpe/tests/org.jboss.tools.vpe.test/scheme/scheme.xsd
trunk/vpe/tests/org.jboss.tools.vpe.test/src/org/jboss/tools/vpe/test/TemplateSchemeValidateTest.java
Log:
fix org.jboss.tools.vpe.test.TemplateSchemeValidateTest
Modified: trunk/vpe/plugins/org.jboss.tools.vpe.spring/templates/vpe-templates-spring.xml
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe.spring/templates/vpe-templates-spring.xml 2010-08-25
22:05:33 UTC (rev 24456)
+++
trunk/vpe/plugins/org.jboss.tools.vpe.spring/templates/vpe-templates-spring.xml 2010-08-26
06:29:45 UTC (rev 24457)
@@ -242,7 +242,7 @@
</vpe:template>
</vpe:tag>
- <vpe:tag name="form:select" case-sensetive="yes">
+ <vpe:tag name="form:select" case-sensitive="yes">
<vpe:template children="yes" modify="yes"
class="org.jboss.tools.vpe.spring.template.SpringFormSelectTemplate">
<vpe:resize>
Modified: trunk/vpe/tests/org.jboss.tools.vpe.test/scheme/scheme.xsd
===================================================================
--- trunk/vpe/tests/org.jboss.tools.vpe.test/scheme/scheme.xsd 2010-08-25 22:05:33 UTC
(rev 24456)
+++ trunk/vpe/tests/org.jboss.tools.vpe.test/scheme/scheme.xsd 2010-08-26 06:29:45 UTC
(rev 24457)
@@ -327,7 +327,9 @@
<xsd:element name="value" type="vpe:VALUE"
minOccurs="0"/>
<xsd:element name="copy" type="vpe:COPY"
minOccurs="0"/>
<xsd:element name="input" type="vpe:HTML_INPUT"
minOccurs="0" form="unqualified" />
+ <xsd:element name="label" type="vpe:HTML_LABEL"
minOccurs="0" form="unqualified" />
</xsd:sequence>
+ <xsd:attribute name="id" type="xsd:string"
use="optional"/>
<xsd:attribute name="style" type="xsd:string"
use="optional"/>
<xsd:attribute name="class" type="xsd:string"
use="optional"/>
<xsd:attribute name="title" type="xsd:string"
use="optional"/>
@@ -347,6 +349,7 @@
<xsd:attribute name="border" type="xsd:string"
use="optional"/>
<xsd:attribute name="disabled" type="xsd:string"
use="optional"/>
<xsd:attribute name="id" type="xsd:string"
use="optional"/>
+ <xsd:attribute name="name" type="xsd:string"
use="optional"/>
</xsd:complexType>
<!-- -->
<xsd:complexType name="HTML_DIV" mixed="true">
@@ -416,7 +419,12 @@
<xsd:sequence>
<xsd:element name="value" minOccurs="0"
type="vpe:VALUE" />
</xsd:sequence>
+ <xsd:attribute name="id" type="xsd:string"
use="optional"/>
+ <xsd:attribute name="style" type="xsd:string"
use="optional"/>
+ <xsd:attribute name="class" type="xsd:string"
use="optional"/>
+ <xsd:attribute name="dir" type="xsd:string"
use="optional"/>
<xsd:attribute name="value" type="xsd:string"
use="optional"/>
+ <xsd:attribute name="disabled" type="xsd:string"
use="optional"/>
<xsd:attribute name="title" type="xsd:string"
use="optional"/>
</xsd:complexType>
<!-- -->
@@ -573,7 +581,11 @@
<!-- -->
<xsd:complexType name="HTML_P"/>
<!-- -->
- <xsd:complexType name="HTML_FORM"/>
+ <xsd:complexType name="HTML_FORM">
+ <xsd:attribute name="id" type="xsd:string"
use="optional"/>
+ <xsd:attribute name="style" type="xsd:string"
use="optional"/>
+ <xsd:attribute name="class" type="xsd:string"
use="optional"/>
+ </xsd:complexType>
<!-- -->
<xsd:complexType name="DEFAULT_TEMPLATE">
<xsd:sequence>
Modified:
trunk/vpe/tests/org.jboss.tools.vpe.test/src/org/jboss/tools/vpe/test/TemplateSchemeValidateTest.java
===================================================================
---
trunk/vpe/tests/org.jboss.tools.vpe.test/src/org/jboss/tools/vpe/test/TemplateSchemeValidateTest.java 2010-08-25
22:05:33 UTC (rev 24456)
+++
trunk/vpe/tests/org.jboss.tools.vpe.test/src/org/jboss/tools/vpe/test/TemplateSchemeValidateTest.java 2010-08-26
06:29:45 UTC (rev 24457)
@@ -15,11 +15,7 @@
import java.io.IOException;
import java.net.URL;
-import javax.xml.XMLConstants;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.transform.Source;
-import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamSource;
import javax.xml.validation.Schema;
import javax.xml.validation.SchemaFactory;
@@ -36,16 +32,10 @@
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.jboss.tools.common.reporting.IProblemReporter;
-import org.jboss.tools.common.reporting.ProblemReporterFactory;
-import org.jboss.tools.vpe.VpePlugin;
-import org.jboss.tools.vpe.editor.template.VpeTemplateManager;
import org.osgi.framework.Bundle;
-import org.w3c.dom.Document;
import org.xml.sax.SAXException;
/**
@@ -54,233 +44,234 @@
* @author Dzmitry Sakovich
*/
public class TemplateSchemeValidateTest extends TestCase {
- /**
- * Extension point ID
- */
- private static final String COM_REDHAT_VPE_TEMPLATES =
"org.jboss.tools.vpe.templates";
+ /**
+ * Extension point ID
+ */
+ private static final String COM_REDHAT_VPE_TEMPLATES =
"org.jboss.tools.vpe.templates"; //$NON-NLS-1$
- private static final String VPE_TEST_EXTENSION =
"org.jboss.tools.vpe.test";
+ private static final String VPE_TEST_EXTENSION = "org.jboss.tools.vpe.test";
//$NON-NLS-1$
- private static final String SCHEME_PATH = "/scheme/scheme.xsd";
+ private static final String SCHEME_PATH = "/scheme/scheme.xsd"; //$NON-NLS-1$
- private static final String PLUGIN_FAILURE_NAME =
"testFailure-plugin.xml";
+ private static final String PLUGIN_FAILURE_NAME = "testFailure-plugin.xml";
//$NON-NLS-1$
- private static Schema schema = null;
+ private static Schema schema = null;
- private static final String PLUGIN_OK_NAME = "testOk-plugin.xml";
+ private static final String PLUGIN_OK_NAME = "testOk-plugin.xml";
//$NON-NLS-1$
- private static final String SCHEME_LANGUAGE =
"http://www.w3.org/2001/XMLSchema";
+ private static final String SCHEME_LANGUAGE =
"http://www.w3.org/2001/XMLSchema"; //$NON-NLS-1$
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- Bundle bundle = VpeTestPlugin.getDefault().getBundle();
- URL url = null;
- url = bundle == null ? null : FileLocator.resolve(bundle
- .getEntry(SCHEME_PATH));
- File schemeFile = new File(url.getPath());
- if (!schemeFile.exists() || !schemeFile.isFile()) {
- fail("scheme is not exist");
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ Bundle bundle = VpeTestPlugin.getDefault().getBundle();
+ URL url = null;
+ url = bundle == null ? null : FileLocator.resolve(bundle
+ .getEntry(SCHEME_PATH));
+ File schemeFile = new File(url.getPath());
+ if (!schemeFile.exists() || !schemeFile.isFile()) {
+ fail("scheme is not exist"); //$NON-NLS-1$
+ }
+ SchemaFactory factory = SchemaFactory.newInstance(SCHEME_LANGUAGE);
+ schema = factory.newSchema(schemeFile);
}
- SchemaFactory factory = SchemaFactory.newInstance(SCHEME_LANGUAGE);
- schema = factory.newSchema(schemeFile);
- }
- /**
- * Test for load all templates
- */
- public void testValidationGlobalTemplates() {
- //
- assertNotNull("Schema is not exist", schema);
- IExtensionRegistry extensionRepository = Platform
- .getExtensionRegistry();
+ /**
+ * Test for load all templates
+ */
+ public void testValidationGlobalTemplates() {
+ //
+ assertNotNull("Schema is not exist", schema); //$NON-NLS-1$
+ IExtensionRegistry extensionRepository = Platform
+ .getExtensionRegistry();
- IExtensionPoint extensionPoint = extensionRepository
- .getExtensionPoint(COM_REDHAT_VPE_TEMPLATES);
- IExtension[] extensions = extensionPoint.getExtensions();
+ 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]);
+ // 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"); //$NON-NLS-1$
+ try {
+ IPath templateFile = getFullpathForConfigurationElement(
+ pathAttrValue, elements[j]);
- try {
- Validator validator = schema.newValidator();
- Source source = new StreamSource(templateFile
- .toOSString());
- validator.validate(source);
- } catch (SAXException ex) {
- fail("Sheme " + templateFile.toFile().getName()
- + " is not valid : " + ex.getMessage());
- }
- } catch (IOException e) {
- fail(e.getMessage());
+ try {
+ Validator validator = schema.newValidator();
+ Source source = new StreamSource(
+ templateFile.toOSString());
+ validator.validate(source);
+ } catch (SAXException ex) {
+ fail("Sheme " + templateFile.toFile().getName() //$NON-NLS-1$
+ + " is not valid : " + ex.getMessage()); //$NON-NLS-1$
+ }
+ } catch (IOException e) {
+ fail(e.getMessage());
+ }
+ }
}
- }
+
}
- }
+ public void testValidationIncorrectTemplplates() throws Exception {
- public void testValidationIncorrectTemplplates() throws Exception {
+ assertNotNull("Schema is not exist", schema); //$NON-NLS-1$
+ createTemplatesForTesting(PLUGIN_FAILURE_NAME);
- assertNotNull("Schema is not exist", schema);
- createTemplatesForTesting(PLUGIN_FAILURE_NAME);
+ IExtensionRegistry extensionRepository = Platform
+ .getExtensionRegistry();
- IExtensionRegistry extensionRepository = Platform
- .getExtensionRegistry();
+ IExtensionPoint extensionPoint = extensionRepository
+ .getExtensionPoint(COM_REDHAT_VPE_TEMPLATES);
+ IExtension[] extensions = extensionPoint.getExtensions();
+ for (int i = 0; i < extensions.length; i++) {
+ if (extensions[i].getNamespaceIdentifier().equals(
+ VPE_TEST_EXTENSION)) {
+ IConfigurationElement[] elements = extensions[i]
+ .getConfigurationElements();
+ for (int j = 0; j < elements.length; j++) {
+ String pathAttrValue = elements[j].getAttribute("path"); //$NON-NLS-1$
+ try {
+ IPath templateFile = getFullpathForConfigurationElement(
+ pathAttrValue, elements[j]);
- IExtensionPoint extensionPoint = extensionRepository
- .getExtensionPoint(COM_REDHAT_VPE_TEMPLATES);
- IExtension[] extensions = extensionPoint.getExtensions();
- for (int i = 0; i < extensions.length; i++) {
- if (extensions[i].getNamespaceIdentifier().equals(
- VPE_TEST_EXTENSION)) {
- IConfigurationElement[] elements = extensions[i]
- .getConfigurationElements();
- for (int j = 0; j < elements.length; j++) {
- String pathAttrValue = elements[j].getAttribute("path");
- try {
- IPath templateFile = getFullpathForConfigurationElement(
- pathAttrValue, elements[j]);
-
- try {
- Validator validator = schema.newValidator();
- Source source = new StreamSource(templateFile
- .toOSString());
- validator.validate(source);
- } catch (SAXException ex) {
- assertTrue("Scheme "
- + templateFile.toFile().getName()
- + " is not valid", true);
+ try {
+ Validator validator = schema.newValidator();
+ Source source = new StreamSource(
+ templateFile.toOSString());
+ validator.validate(source);
+ } catch (SAXException ex) {
+ assertTrue("Scheme " //$NON-NLS-1$
+ + templateFile.toFile().getName()
+ + " is not valid", true); //$NON-NLS-1$
+ }
+ } catch (IOException e) {
+ fail(e.getMessage());
+ }
+ }
}
- } catch (IOException e) {
- fail(e.getMessage());
- }
}
- }
+ return;
}
- return;
- }
- public void testValidationCorrectTemplplates() throws Exception {
+ public void testValidationCorrectTemplplates() throws Exception {
- assertNotNull("Schema is not exist", schema);
- createTemplatesForTesting(PLUGIN_OK_NAME);
+ assertNotNull("Schema is not exist", schema); //$NON-NLS-1$
+ createTemplatesForTesting(PLUGIN_OK_NAME);
- IExtensionRegistry extensionRepository = Platform
- .getExtensionRegistry();
+ IExtensionRegistry extensionRepository = Platform
+ .getExtensionRegistry();
- IExtensionPoint extensionPoint = extensionRepository
- .getExtensionPoint(COM_REDHAT_VPE_TEMPLATES);
- IExtension[] extensions = extensionPoint.getExtensions();
- for (int i = 0; i < extensions.length; i++) {
- if (extensions[i].getNamespaceIdentifier().equals(
- VPE_TEST_EXTENSION)) {
- IConfigurationElement[] elements = extensions[i]
- .getConfigurationElements();
- for (int j = 0; j < elements.length; j++) {
- String pathAttrValue = elements[j].getAttribute("path");
- try {
- IPath templateFile = getFullpathForConfigurationElement(
- pathAttrValue, elements[j]);
+ IExtensionPoint extensionPoint = extensionRepository
+ .getExtensionPoint(COM_REDHAT_VPE_TEMPLATES);
+ IExtension[] extensions = extensionPoint.getExtensions();
+ for (int i = 0; i < extensions.length; i++) {
+ if (extensions[i].getNamespaceIdentifier().equals(
+ VPE_TEST_EXTENSION)) {
+ IConfigurationElement[] elements = extensions[i]
+ .getConfigurationElements();
+ for (int j = 0; j < elements.length; j++) {
+ String pathAttrValue = elements[j].getAttribute("path"); //$NON-NLS-1$
+ try {
+ IPath templateFile = getFullpathForConfigurationElement(
+ pathAttrValue, elements[j]);
- try {
- Validator validator = schema.newValidator();
- Source source = new StreamSource(templateFile
- .toOSString());
- validator.validate(source);
- } catch (SAXException ex) {
- fail("Sheme " + templateFile.toFile().getName()
- + " is not valid : " + ex.getMessage());
+ try {
+ Validator validator = schema.newValidator();
+ Source source = new StreamSource(
+ templateFile.toOSString());
+ validator.validate(source);
+ } catch (SAXException ex) {
+ fail("Sheme " + templateFile.toFile().getName() //$NON-NLS-1$
+ + " is not valid : " + ex.getMessage()); //$NON-NLS-1$
+ }
+ } catch (IOException e) {
+ fail(e.getMessage());
+ }
+ }
}
- } catch (IOException e) {
- fail(e.getMessage());
- }
}
- }
+
+ return;
}
- return;
- }
+ /**
+ * Tests possible 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);
+ }
- /**
- * Tests possible 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 {
+ VpeTestPlugin plugin = VpeTestPlugin.getDefault();
- /**
- * 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 {
- VpeTestPlugin plugin = VpeTestPlugin.getDefault();
+ Bundle bundle = null;
- Bundle bundle = null;
+ if (confElement == null) {
+ bundle = plugin.getBundle();
+ } else {
+ bundle = Platform.getBundle(confElement.getNamespaceIdentifier());
+ }
- if (confElement == null) {
- bundle = plugin.getBundle();
- } else {
- bundle = Platform.getBundle(confElement.getNamespaceIdentifier());
+ URL url = bundle.getEntry("/"); //$NON-NLS-1$
+
+ IPath path = new Path(FileLocator.toFileURL(url).getFile());
+ path = path.append(name);
+ return path;
}
- URL url = bundle.getEntry("/");
+ /**
+ * Removing extensions from eclipse
+ *
+ * @param extensionPointId
+ * @param extensionId
+ */
+ private void removeExtension(String extensionPointId, String extensionId) {
+ IExtensionRegistry extensionRepository = Platform
+ .getExtensionRegistry();
- 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) {
- IExtensionRegistry extensionRepository = Platform
- .getExtensionRegistry();
-
- Object token = ((ExtensionRegistry) extensionRepository).getTemporaryUserToken();
- IExtensionPoint extensionPoint = extensionRepository
- .getExtensionPoint(extensionPointId);
- IExtension[] extensions = extensionPoint.getExtensions();
- for (int i = 0; i < extensions.length; i++) {
- if (extensions[i].getNamespaceIdentifier().equals(extensionId))
- extensionRepository.removeExtension(extensions[i], token);
+ Object token = ((ExtensionRegistry) extensionRepository)
+ .getTemporaryUserToken();
+ IExtensionPoint extensionPoint = extensionRepository
+ .getExtensionPoint(extensionPointId);
+ IExtension[] extensions = extensionPoint.getExtensions();
+ for (int i = 0; i < extensions.length; i++) {
+ if (extensions[i].getNamespaceIdentifier().equals(extensionId))
+ extensionRepository.removeExtension(extensions[i], token);
+ }
}
- }
- @Override
- protected void tearDown() throws Exception {
- removeExtension(COM_REDHAT_VPE_TEMPLATES, VPE_TEST_EXTENSION);
- super.tearDown();
- }
+ @Override
+ protected void tearDown() throws Exception {
+ removeExtension(COM_REDHAT_VPE_TEMPLATES, VPE_TEST_EXTENSION);
+ super.tearDown();
+ }
}