JBoss Tools SVN: r40210 - in trunk: jmx/plugins/org.jboss.tools.jmx.ui/src/org/jboss/tools/jmx/ui/internal/views/navigator and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2012-04-16 10:20:27 -0400 (Mon, 16 Apr 2012)
New Revision: 40210
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.jmx.integration/build.properties
trunk/jmx/plugins/org.jboss.tools.jmx.ui/src/org/jboss/tools/jmx/ui/internal/views/navigator/MBeanExplorerLabelProvider.java
Log:
JBIDE-11452 - MBean Explorer displays NPE
JBIDE-11396 - JBoss jmx sever connections should have jboss server icon
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.jmx.integration/build.properties
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.jmx.integration/build.properties 2012-04-16 14:06:22 UTC (rev 40209)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.jmx.integration/build.properties 2012-04-16 14:20:27 UTC (rev 40210)
@@ -2,4 +2,5 @@
output.. = bin/
bin.includes = META-INF/,\
.,\
- plugin.xml
+ plugin.xml,\
+ icons/
Modified: trunk/jmx/plugins/org.jboss.tools.jmx.ui/src/org/jboss/tools/jmx/ui/internal/views/navigator/MBeanExplorerLabelProvider.java
===================================================================
--- trunk/jmx/plugins/org.jboss.tools.jmx.ui/src/org/jboss/tools/jmx/ui/internal/views/navigator/MBeanExplorerLabelProvider.java 2012-04-16 14:06:22 UTC (rev 40209)
+++ trunk/jmx/plugins/org.jboss.tools.jmx.ui/src/org/jboss/tools/jmx/ui/internal/views/navigator/MBeanExplorerLabelProvider.java 2012-04-16 14:20:27 UTC (rev 40210)
@@ -52,8 +52,12 @@
public void dispose() {
instances.remove(this);
if( instances.isEmpty()) {
- for( Iterator<Image> i = images.values().iterator(); i.hasNext(); )
- i.next().dispose();
+ Iterator<Image> i = images.values().iterator();
+ while(i.hasNext()) {
+ Image o = i.next();
+ if( o != null )
+ o.dispose();
+ }
}
super.dispose();
}
@@ -104,8 +108,8 @@
if( obj instanceof IConnectionWrapper ) {
IConnectionProvider provider = ((IConnectionWrapper)obj).getProvider();
ConnectionProviderUI ui = UIExtensionManager.getConnectionProviderUI(provider.getId());
- if( ui != null ) {
- if(!images.containsKey(ui.getId()) || images.get(ui.getId()).isDisposed()) {
+ if( ui != null && ui.getId() != null ) {
+ if(images.get(ui.getId()) == null || images.get(ui.getId()).isDisposed()) {
Image i = null;
if( ui.getImageDescriptor() != null ) {
i = ui.getImageDescriptor().createImage();
13 years, 12 months
JBoss Tools SVN: r40209 - trunk/runtime/tests.
by jbosstools-commits@lists.jboss.org
Author: ljelinko
Date: 2012-04-16 10:06:22 -0400 (Mon, 16 Apr 2012)
New Revision: 40209
Added:
trunk/runtime/tests/org.jboss.tools.runtime.as.detector.ui.bot.test/
trunk/runtime/tests/org.jboss.tools.runtime.as.ui.bot.test/
Log:
Committed empty folders prepared for bot tests.
13 years, 12 months
JBoss Tools SVN: r40207 - trunk/download.jboss.org/jbosstools/updates/requirements/m2eclipse.
by jbosstools-commits@lists.jboss.org
Author: nickboldt
Date: 2012-04-16 09:47:48 -0400 (Mon, 16 Apr 2012)
New Revision: 40207
Added:
trunk/download.jboss.org/jbosstools/updates/requirements/m2eclipse/README...
trunk/download.jboss.org/jbosstools/updates/requirements/m2eclipse/build-...
trunk/download.jboss.org/jbosstools/updates/requirements/m2eclipse/build-...
Removed:
trunk/download.jboss.org/jbosstools/updates/requirements/m2eclipse/build-...
trunk/download.jboss.org/jbosstools/updates/requirements/m2eclipse/build-...
trunk/download.jboss.org/jbosstools/updates/requirements/m2eclipse/build-...
trunk/download.jboss.org/jbosstools/updates/requirements/m2eclipse/build-...
trunk/download.jboss.org/jbosstools/updates/requirements/m2eclipse/build-...
Modified:
trunk/download.jboss.org/jbosstools/updates/requirements/m2eclipse/build.xml
Log:
new builder for m2e 1.1; clean up old builders and add README so we don't accidentally purge old required releases.
Added: trunk/download.jboss.org/jbosstools/updates/requirements/m2eclipse/README...
===================================================================
--- trunk/download.jboss.org/jbosstools/updates/requirements/m2eclipse/README... (rev 0)
+++ trunk/download.jboss.org/jbosstools/updates/requirements/m2eclipse/README... 2012-04-16 13:47:48 UTC (rev 40207)
@@ -0,0 +1,16 @@
+<pre>
+The following folders should never be removed as they are part of composite
+requirement sites used for current/previous JBoss Tools releases:
+
+Helios SR2
+ * m2eclipse/20110728-1500
+ * m2eclipse/m2eclipse-wtp-0.13.1
+
+Indigo SR2
+ * m2eclipse/20120306-1800
+
+Juno M6 (milestone, not release)
+ * m2eclipse/20120416-0900
+
+</pre>
+
Deleted: trunk/download.jboss.org/jbosstools/updates/requirements/m2eclipse/build-...
===================================================================
--- trunk/download.jboss.org/jbosstools/updates/requirements/m2eclipse/build-... 2012-04-16 13:12:46 UTC (rev 40206)
+++ trunk/download.jboss.org/jbosstools/updates/requirements/m2eclipse/build-... 2012-04-16 13:47:48 UTC (rev 40207)
@@ -1,42 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project default="mirror">
- <!-- run locally in Eclipse (to resolve p2 tasks) using these commandline options:
-
- -os ${target.os} -ws ${target.ws} -arch ${target.arch} -nl ${target.nl}
- -consoleLog -nosplash -data /tmp
- -application org.eclipse.ant.core.antRunner
- -f "/home/nboldt/tru/download.jboss.org/jbosstools/updates/requirements/m2eclipse/build.xml"
-
- or, run headless on qa01 server, where Eclipse is installed into ~/eclipse:
-
- export JAVA_HOME=/opt/jdk1.6.0; \
- ${JAVA_HOME}/bin/java -cp ~/eclipse/plugins/org.eclipse.equinox.launcher_*.jar \
- org.eclipse.equinox.launcher.Main -vm ${JAVA_HOME} -consoleLog -nosplash -data /tmp \
- -application org.eclipse.ant.core.antRunner \
- -f ~/RHDS/updates/requirements/m2eclipse/build.xml -Ddestination=/tmp/m2eclipse-repo
- -->
- <target name="mirror">
- <property name="URL1" value="https://repository.sonatype.org/content/sites/forge-sites/m2e/0.12.2/S/0...." />
- <property name="URL2" value="https://repository.sonatype.org/content/sites/forge-sites/m2eclipse-wtp/0..." />
-
- <!--
- <property name="URL1" value="http://m2eclipse.sonatype.org/sites/m2e/" />
- <property name="URL2" value="http://m2eclipse.sonatype.org/sites/m2e-extras/" />
- -->
-
- <property name="destination" value="/home/nboldt/tru/download.jboss.org/jbosstools/updates/requirements/m2eclipse/" />
- <property name="compress" value="true" />
-
- <p2.mirror>
- <repository location="file:${destination}/0.12.2/" name="m2eclipse 0.12 plugins for Eclipse 3.6" />
- <source>
- <repository location="${URL1}" />
- <repository location="${URL2}" />
- </source>
-
- <slicingOptions includeFeatures="true" followStrict="true" />
- </p2.mirror>
-
- <p2.publish.featuresAndBundles metadataRepository="file:${destination}/0.12.2/" artifactRepository="file:${destination}/0.12.2/" publishartifacts="true" source="${destination}/0.12.2/" compress="${compress}" />
- </target>
-</project>
Deleted: trunk/download.jboss.org/jbosstools/updates/requirements/m2eclipse/build-...
===================================================================
--- trunk/download.jboss.org/jbosstools/updates/requirements/m2eclipse/build-... 2012-04-16 13:12:46 UTC (rev 40206)
+++ trunk/download.jboss.org/jbosstools/updates/requirements/m2eclipse/build-... 2012-04-16 13:47:48 UTC (rev 40207)
@@ -1,41 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project default="mirror">
- <!-- run locally in Eclipse (to resolve p2 tasks) using these commandline options:
-
- -os ${target.os} -ws ${target.ws} -arch ${target.arch} -nl ${target.nl}
- -consoleLog -nosplash -data /tmp
- -application org.eclipse.ant.core.antRunner
- -f "/home/nboldt/tru/download.jboss.org/jbosstools/updates/requirements/m2eclipse/build.xml"
-
- or, run headless on qa01 server, where Eclipse is installed into ~/eclipse:
-
- export JAVA_HOME=/opt/jdk1.6.0; \
- ${JAVA_HOME}/bin/java -cp ~/eclipse/plugins/org.eclipse.equinox.launcher_*.jar \
- org.eclipse.equinox.launcher.Main -vm ${JAVA_HOME} -consoleLog -nosplash -data /tmp \
- -application org.eclipse.ant.core.antRunner \
- -f ~/RHDS/updates/requirements/m2eclipse/build.xml -Ddestination=/tmp/m2eclipse-repo
- -->
- <target name="mirror">
-
- <property name="URL1" value="https://repository.sonatype.org/content/sites/forge-sites/m2e/0.13.0/N/0...."/>
- <property name="URL2" value="https://repository.sonatype.org/content/sites/forge-sites/m2e-extras/0.13..."/>
- <property name="URL3" value="https://repository.sonatype.org/content/sites/forge-sites/m2eclipse-wtp/0..."/>
-
- <property name="destination" value="/home/nboldt/tru/download.jboss.org/jbosstools/updates/requirements/m2eclipse/" />
- <property name="compress" value="true" />
-
- <p2.mirror>
- <repository location="file:${destination}/0.13.0.201103291237/" name="m2eclipse 0.13.0.201103291237 plugins for Eclipse 3.6 - 3.7" />
- <source>
- <repository location="${URL1}" />
- <repository location="${URL2}" />
- <repository location="${URL3}" />
- </source>
-
- <slicingOptions includeFeatures="true" followStrict="true" />
- </p2.mirror>
-
- <p2.publish.featuresAndBundles metadataRepository="file:${destination}/0.13.0.201103291237/" artifactRepository="file:${destination}/0.13.0.201103291237/"
- publishartifacts="true" source="${destination}/0.13.0.201103291237/" compress="${compress}" />
- </target>
-</project>
Deleted: trunk/download.jboss.org/jbosstools/updates/requirements/m2eclipse/build-...
===================================================================
--- trunk/download.jboss.org/jbosstools/updates/requirements/m2eclipse/build-... 2012-04-16 13:12:46 UTC (rev 40206)
+++ trunk/download.jboss.org/jbosstools/updates/requirements/m2eclipse/build-... 2012-04-16 13:47:48 UTC (rev 40207)
@@ -1,61 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project default="mirror">
- <!-- run locally in Eclipse (to resolve p2 tasks) using these commandline options:
-
- -os ${target.os} -ws ${target.ws} -arch ${target.arch} -nl ${target.nl}
- -consoleLog -nosplash -data /tmp
- -application org.eclipse.ant.core.antRunner
- -f "/home/nboldt/tru/download.jboss.org/jbosstools/updates/requirements/m2eclipse/build.xml"
-
- or, run headless on qa01 server, where Eclipse is installed into ~/eclipse:
-
- export JAVA_HOME=/opt/jdk1.6.0; \
- ${JAVA_HOME}/bin/java -cp ~/eclipse/plugins/org.eclipse.equinox.launcher_*.jar \
- org.eclipse.equinox.launcher.Main -vm ${JAVA_HOME} -consoleLog -nosplash -data /tmp \
- -application org.eclipse.ant.core.antRunner \
- -f ~/RHDS/updates/requirements/m2eclipse/build.xml -Ddestination=/tmp/m2eclipse-repo
- -->
- <target name="mirror">
- <property name="URL1" value="http://download.eclipse.org/technology/m2e/milestones/1.0/"/>
- <property name="URL2" value="http://m2eclipse.sonatype.org/sites/m2e"/>
- <property name="URL3" value="http://m2eclipse.sonatype.org/sites/m2e-extras/"/>
-
- <property name="URL4" value="http://download.jboss.org/jbosstools/updates/requirements/m2eclipse-wtp-e37/"/>
-
- <!--
- <property name="URL1" value="https://repository.sonatype.org/content/sites/forge-sites/m2e/0.13.0/N/0...."/>
- <property name="URL2" value="https://repository.sonatype.org/content/sites/forge-sites/m2e-extras/0.13..."/>
- <property name="URL3" value="https://repository.sonatype.org/content/sites/forge-sites/m2eclipse-wtp/0..."/>
-
- <property name="URL1" value="https://repository.sonatype.org/content/sites/forge-sites/m2e/0.13.0/N/0...."/>
- <property name="URL2" value="https://repository.sonatype.org/content/sites/forge-sites/m2e-extras/0.13..."/>
- <property name="URL3" value="https://repository.sonatype.org/content/sites/forge-sites/m2eclipse-wtp/0..."/>
-
- <property name="URL1" value="https://repository.sonatype.org/content/sites/forge-sites/m2e/0.13.0/N/0...."/>
- <property name="URL2" value="https://repository.sonatype.org/content/sites/forge-sites/m2e-extras/0.13..."/>
- <property name="URL3" value="https://repository.sonatype.org/content/sites/forge-sites/m2eclipse-wtp/0..."/>
-
- <property name="URL1" value="http://m2eclipse.sonatype.org/sites/m2e/" />
- <property name="URL2" value="http://m2eclipse.sonatype.org/sites/m2e-extras/" />
- <property name="URL3" value="http://download.eclipse.org/technology/m2e/updates/M/" />
- -->
-
- <property name="destination" value="/home/nboldt/tru/download.jboss.org/jbosstools/updates/requirements/m2eclipse/" />
- <property name="compress" value="true" />
-
- <p2.mirror>
- <repository location="file:${destination}/20110607-1445" name="m2eclipse 0.13 (1.0) for Eclipse 3.6 - 3.7 (mirrored 20110607-1445" />
- <source>
- <repository location="${URL1}" />
- <repository location="${URL2}" />
- <repository location="${URL3}" />
- <repository location="${URL4}" />
- </source>
-
- <slicingOptions includeFeatures="true" followStrict="true" />
- </p2.mirror>
-
- <p2.publish.featuresAndBundles metadataRepository="file:${destination}/20110607-1445/" artifactRepository="file:${destination}/20110607-1445/"
- publishartifacts="true" source="${destination}/20110607-1445/" compress="${compress}" />
- </target>
-</project>
Deleted: trunk/download.jboss.org/jbosstools/updates/requirements/m2eclipse/build-...
===================================================================
--- trunk/download.jboss.org/jbosstools/updates/requirements/m2eclipse/build-... 2012-04-16 13:12:46 UTC (rev 40206)
+++ trunk/download.jboss.org/jbosstools/updates/requirements/m2eclipse/build-... 2012-04-16 13:47:48 UTC (rev 40207)
@@ -1,69 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project default="mirror">
- <!-- run locally in Eclipse (to resolve p2 tasks) using these commandline options:
-
- -os ${target.os} -ws ${target.ws} -arch ${target.arch} -nl ${target.nl}
- -consoleLog -nosplash -data /tmp
- -application org.eclipse.ant.core.antRunner
- -f "/home/nboldt/tru/download.jboss.org/jbosstools/updates/requirements/m2eclipse/build.xml"
-
- or, run headless on qa01 server, where Eclipse is installed into ~/eclipse:
-
- export JAVA_HOME=/opt/jdk1.6.0; \
- ${JAVA_HOME}/bin/java -cp ~/eclipse/plugins/org.eclipse.equinox.launcher_*.jar \
- org.eclipse.equinox.launcher.Main -vm ${JAVA_HOME} -consoleLog -nosplash -data /tmp \
- -application org.eclipse.ant.core.antRunner \
- -f ~/RHDS/updates/requirements/m2eclipse/build.xml -Ddestination=/tmp/m2eclipse-repo
- -->
- <target name="mirror">
- <property name="URL1" value="https://repository.sonatype.org/content/sites/forge-sites/m2e/1.0.0/N/1.0..."/>
- <property name="URL2" value="https://repository.sonatype.org/content/repositories/forge-sites/m2e-extr..."/>
- <property name="URL3" value="https://repository.sonatype.org/content/sites/forge-sites/m2eclipse-wtp/0..."/>
- <property name="URL4" value="http://download.jboss.org/jbosstools/updates/m2eclipse-wtp/"/>
-
- <!--
- <property name="URL1" value="https://repository.sonatype.org/content/sites/forge-sites/m2e/1.0.0/N/1.0..."/>
- <property name="URL2" value="https://repository.sonatype.org/content/repositories/forge-sites/m2e-extr..."/>
- <property name="URL3" value="https://repository.sonatype.org/content/sites/forge-sites/m2eclipse-wtp/0..."/>
-
- <property name="URL1" value="http://download.eclipse.org/technology/m2e/milestones/1.0/"/>
- <property name="URL2" value="http://m2eclipse.sonatype.org/sites/m2e"/>
- <property name="URL3" value="http://m2eclipse.sonatype.org/sites/m2e-extras/"/>
- <property name="URL4" value="http://download.jboss.org/jbosstools/updates/requirements/m2eclipse-wtp-e37/"/>
-
- <property name="URL1" value="https://repository.sonatype.org/content/sites/forge-sites/m2e/0.13.0/N/0...."/>
- <property name="URL2" value="https://repository.sonatype.org/content/sites/forge-sites/m2e-extras/0.13..."/>
- <property name="URL3" value="https://repository.sonatype.org/content/sites/forge-sites/m2eclipse-wtp/0..."/>
-
- <property name="URL1" value="https://repository.sonatype.org/content/sites/forge-sites/m2e/0.13.0/N/0...."/>
- <property name="URL2" value="https://repository.sonatype.org/content/sites/forge-sites/m2e-extras/0.13..."/>
- <property name="URL3" value="https://repository.sonatype.org/content/sites/forge-sites/m2eclipse-wtp/0..."/>
-
- <property name="URL1" value="https://repository.sonatype.org/content/sites/forge-sites/m2e/0.13.0/N/0...."/>
- <property name="URL2" value="https://repository.sonatype.org/content/sites/forge-sites/m2e-extras/0.13..."/>
- <property name="URL3" value="https://repository.sonatype.org/content/sites/forge-sites/m2eclipse-wtp/0..."/>
-
- <property name="URL1" value="http://m2eclipse.sonatype.org/sites/m2e/" />
- <property name="URL2" value="http://m2eclipse.sonatype.org/sites/m2e-extras/" />
- <property name="URL3" value="http://download.eclipse.org/technology/m2e/updates/M/" />
- -->
-
- <property name="destination" value="/home/nboldt/tru/download.jboss.org/jbosstools/updates/requirements/m2eclipse/" />
- <property name="compress" value="true" />
-
- <p2.mirror>
- <repository location="file:${destination}/20110728-1500" name="m2eclipse 0.13 (1.0) for Eclipse 3.6 - 3.7 (mirrored 20110728-1500)" />
- <source>
- <repository location="${URL1}" />
- <repository location="${URL2}" />
- <repository location="${URL3}" />
- <repository location="${URL4}" />
- </source>
-
- <slicingOptions includeFeatures="true" followStrict="true" />
- </p2.mirror>
-
- <p2.publish.featuresAndBundles metadataRepository="file:${destination}/20110728-1500/" artifactRepository="file:${destination}/20110728-1500/"
- publishartifacts="true" source="${destination}/20110728-1500/" compress="${compress}" />
- </target>
-</project>
Deleted: trunk/download.jboss.org/jbosstools/updates/requirements/m2eclipse/build-...
===================================================================
--- trunk/download.jboss.org/jbosstools/updates/requirements/m2eclipse/build-... 2012-04-16 13:12:46 UTC (rev 40206)
+++ trunk/download.jboss.org/jbosstools/updates/requirements/m2eclipse/build-... 2012-04-16 13:47:48 UTC (rev 40207)
@@ -1,72 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project default="mirror">
- <!-- run locally in Eclipse (to resolve p2 tasks) using these commandline options:
-
- -os ${target.os} -ws ${target.ws} -arch ${target.arch} -nl ${target.nl}
- -consoleLog -nosplash -data /tmp
- -application org.eclipse.ant.core.antRunner
- -f "/home/nboldt/tru/download.jboss.org/jbosstools/updates/requirements/m2eclipse/build.xml"
-
- or, run headless on qa01 server, where Eclipse is installed into ~/eclipse:
-
- export JAVA_HOME=/opt/jdk1.6.0; \
- ${JAVA_HOME}/bin/java -cp ~/eclipse/plugins/org.eclipse.equinox.launcher_*.jar \
- org.eclipse.equinox.launcher.Main -vm ${JAVA_HOME} -consoleLog -nosplash -data /tmp \
- -application org.eclipse.ant.core.antRunner \
- -f ~/RHDS/updates/requirements/m2eclipse/build.xml -Ddestination=/tmp/m2eclipse-repo
- -->
- <target name="mirror">
- <property name="URL1" value="http://download.eclipse.org/technology/m2e/releases/"/>
- <property name="URL2" value="http://repository.sonatype.org/content/repositories/forge-sites/m2e-extra..."/>
- <property name="URL3" value="http://download.jboss.org/jbosstools/updates/m2eclipse-wtp/"/>
-
- <!--
- <property name="URL1" value="https://repository.sonatype.org/content/sites/forge-sites/m2e/1.0.0/N/1.0..."/>
- <property name="URL2" value="https://repository.sonatype.org/content/repositories/forge-sites/m2e-extr..."/>
- <property name="URL3" value="https://repository.sonatype.org/content/sites/forge-sites/m2eclipse-wtp/0..."/>
- <property name="URL4" value="http://download.jboss.org/jbosstools/updates/m2eclipse-wtp/"/>
-
- <property name="URL1" value="https://repository.sonatype.org/content/sites/forge-sites/m2e/1.0.0/N/1.0..."/>
- <property name="URL2" value="https://repository.sonatype.org/content/repositories/forge-sites/m2e-extr..."/>
- <property name="URL3" value="https://repository.sonatype.org/content/sites/forge-sites/m2eclipse-wtp/0..."/>
-
- <property name="URL1" value="http://download.eclipse.org/technology/m2e/milestones/1.0/"/>
- <property name="URL2" value="http://m2eclipse.sonatype.org/sites/m2e"/>
- <property name="URL3" value="http://m2eclipse.sonatype.org/sites/m2e-extras/"/>
- <property name="URL4" value="http://download.jboss.org/jbosstools/updates/requirements/m2eclipse-wtp-e37/"/>
-
- <property name="URL1" value="https://repository.sonatype.org/content/sites/forge-sites/m2e/0.13.0/N/0...."/>
- <property name="URL2" value="https://repository.sonatype.org/content/sites/forge-sites/m2e-extras/0.13..."/>
- <property name="URL3" value="https://repository.sonatype.org/content/sites/forge-sites/m2eclipse-wtp/0..."/>
-
- <property name="URL1" value="https://repository.sonatype.org/content/sites/forge-sites/m2e/0.13.0/N/0...."/>
- <property name="URL2" value="https://repository.sonatype.org/content/sites/forge-sites/m2e-extras/0.13..."/>
- <property name="URL3" value="https://repository.sonatype.org/content/sites/forge-sites/m2eclipse-wtp/0..."/>
-
- <property name="URL1" value="https://repository.sonatype.org/content/sites/forge-sites/m2e/0.13.0/N/0...."/>
- <property name="URL2" value="https://repository.sonatype.org/content/sites/forge-sites/m2e-extras/0.13..."/>
- <property name="URL3" value="https://repository.sonatype.org/content/sites/forge-sites/m2eclipse-wtp/0..."/>
-
- <property name="URL1" value="http://m2eclipse.sonatype.org/sites/m2e/" />
- <property name="URL2" value="http://m2eclipse.sonatype.org/sites/m2e-extras/" />
- <property name="URL3" value="http://download.eclipse.org/technology/m2e/updates/M/" />
- -->
-
- <property name="destination" value="/home/nboldt/tru/download.jboss.org/jbosstools/updates/requirements/m2eclipse/" />
- <property name="compress" value="true" />
-
- <p2.mirror>
- <repository location="file:${destination}/20111005-1500" name="m2eclipse 1.0.100 for Eclipse 3.6 - 3.7 (mirrored 20111005-1500)" />
- <source>
- <repository location="${URL1}" />
- <repository location="${URL2}" />
- <repository location="${URL3}" />
- </source>
-
- <slicingOptions includeFeatures="true" followStrict="true" />
- </p2.mirror>
-
- <p2.publish.featuresAndBundles metadataRepository="file:${destination}/20111005-1500/" artifactRepository="file:${destination}/20111005-1500/"
- publishartifacts="true" source="${destination}/20111005-1500/" compress="${compress}" />
- </target>
-</project>
Copied: trunk/download.jboss.org/jbosstools/updates/requirements/m2eclipse/build-... (from rev 40206, trunk/download.jboss.org/jbosstools/updates/requirements/m2eclipse/build-...)
===================================================================
--- trunk/download.jboss.org/jbosstools/updates/requirements/m2eclipse/build-... (rev 0)
+++ trunk/download.jboss.org/jbosstools/updates/requirements/m2eclipse/build-... 2012-04-16 13:47:48 UTC (rev 40207)
@@ -0,0 +1,69 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project default="mirror">
+ <!-- run locally in Eclipse (to resolve p2 tasks) using these commandline options:
+
+ -os ${target.os} -ws ${target.ws} -arch ${target.arch} -nl ${target.nl}
+ -consoleLog -nosplash -data /tmp
+ -application org.eclipse.ant.core.antRunner
+ -f "/home/nboldt/tru/download.jboss.org/jbosstools/updates/requirements/m2eclipse/build.xml"
+
+ or, run headless on qa01 server, where Eclipse is installed into ~/eclipse:
+
+ export JAVA_HOME=/opt/jdk1.6.0; \
+ ${JAVA_HOME}/bin/java -cp ~/eclipse/plugins/org.eclipse.equinox.launcher_*.jar \
+ org.eclipse.equinox.launcher.Main -vm ${JAVA_HOME} -consoleLog -nosplash -data /tmp \
+ -application org.eclipse.ant.core.antRunner \
+ -f ~/RHDS/updates/requirements/m2eclipse/build.xml -Ddestination=/tmp/m2eclipse-repo
+ -->
+ <target name="mirror">
+ <property name="URL1" value="https://repository.sonatype.org/content/sites/forge-sites/m2e/1.0.0/N/1.0..."/>
+ <property name="URL2" value="https://repository.sonatype.org/content/repositories/forge-sites/m2e-extr..."/>
+ <property name="URL3" value="https://repository.sonatype.org/content/sites/forge-sites/m2eclipse-wtp/0..."/>
+ <property name="URL4" value="http://download.jboss.org/jbosstools/updates/m2eclipse-wtp/"/>
+
+ <!--
+ <property name="URL1" value="https://repository.sonatype.org/content/sites/forge-sites/m2e/1.0.0/N/1.0..."/>
+ <property name="URL2" value="https://repository.sonatype.org/content/repositories/forge-sites/m2e-extr..."/>
+ <property name="URL3" value="https://repository.sonatype.org/content/sites/forge-sites/m2eclipse-wtp/0..."/>
+
+ <property name="URL1" value="http://download.eclipse.org/technology/m2e/milestones/1.0/"/>
+ <property name="URL2" value="http://m2eclipse.sonatype.org/sites/m2e"/>
+ <property name="URL3" value="http://m2eclipse.sonatype.org/sites/m2e-extras/"/>
+ <property name="URL4" value="http://download.jboss.org/jbosstools/updates/requirements/m2eclipse-wtp-e37/"/>
+
+ <property name="URL1" value="https://repository.sonatype.org/content/sites/forge-sites/m2e/0.13.0/N/0...."/>
+ <property name="URL2" value="https://repository.sonatype.org/content/sites/forge-sites/m2e-extras/0.13..."/>
+ <property name="URL3" value="https://repository.sonatype.org/content/sites/forge-sites/m2eclipse-wtp/0..."/>
+
+ <property name="URL1" value="https://repository.sonatype.org/content/sites/forge-sites/m2e/0.13.0/N/0...."/>
+ <property name="URL2" value="https://repository.sonatype.org/content/sites/forge-sites/m2e-extras/0.13..."/>
+ <property name="URL3" value="https://repository.sonatype.org/content/sites/forge-sites/m2eclipse-wtp/0..."/>
+
+ <property name="URL1" value="https://repository.sonatype.org/content/sites/forge-sites/m2e/0.13.0/N/0...."/>
+ <property name="URL2" value="https://repository.sonatype.org/content/sites/forge-sites/m2e-extras/0.13..."/>
+ <property name="URL3" value="https://repository.sonatype.org/content/sites/forge-sites/m2eclipse-wtp/0..."/>
+
+ <property name="URL1" value="http://m2eclipse.sonatype.org/sites/m2e/" />
+ <property name="URL2" value="http://m2eclipse.sonatype.org/sites/m2e-extras/" />
+ <property name="URL3" value="http://download.eclipse.org/technology/m2e/updates/M/" />
+ -->
+
+ <property name="destination" value="/home/nboldt/tru/download.jboss.org/jbosstools/updates/requirements/m2eclipse/" />
+ <property name="compress" value="true" />
+
+ <p2.mirror>
+ <repository location="file:${destination}/20110728-1500" name="m2eclipse 0.13 (1.0) for Eclipse 3.6 - 3.7 (mirrored 20110728-1500)" />
+ <source>
+ <repository location="${URL1}" />
+ <repository location="${URL2}" />
+ <repository location="${URL3}" />
+ <repository location="${URL4}" />
+ </source>
+
+ <slicingOptions includeFeatures="true" followStrict="true" />
+ </p2.mirror>
+
+ <p2.publish.featuresAndBundles metadataRepository="file:${destination}/20110728-1500/" artifactRepository="file:${destination}/20110728-1500/"
+ publishartifacts="true" source="${destination}/20110728-1500/" compress="${compress}" />
+ </target>
+</project>
Copied: trunk/download.jboss.org/jbosstools/updates/requirements/m2eclipse/build-... (from rev 40206, trunk/download.jboss.org/jbosstools/updates/requirements/m2eclipse/build.xml)
===================================================================
--- trunk/download.jboss.org/jbosstools/updates/requirements/m2eclipse/build-... (rev 0)
+++ trunk/download.jboss.org/jbosstools/updates/requirements/m2eclipse/build-... 2012-04-16 13:47:48 UTC (rev 40207)
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project default="mirror">
+ <!-- run locally in Eclipse (to resolve p2 tasks) using these commandline options:
+
+ -os ${target.os} -ws ${target.ws} -arch ${target.arch} -nl ${target.nl}
+ -consoleLog -nosplash -data /tmp
+ -application org.eclipse.ant.core.antRunner
+ -f "/home/nboldt/tru/download.jboss.org/jbosstools/updates/requirements/m2eclipse/build.xml"
+
+ or, run headless on qa01 server, where Eclipse is installed into ~/eclipse:
+
+ export JAVA_HOME=/opt/jdk1.6.0; \
+ ${JAVA_HOME}/bin/java -cp ~/eclipse/plugins/org.eclipse.equinox.launcher_*.jar \
+ org.eclipse.equinox.launcher.Main -vm ${JAVA_HOME} -consoleLog -nosplash -data /tmp \
+ -application org.eclipse.ant.core.antRunner \
+ -f ~/RHDS/updates/requirements/m2eclipse/build.xml -Ddestination=/tmp/m2eclipse-repo
+ -->
+ <target name="mirror">
+ <property name="URL1" value="http://download.jboss.org/jbosstools/updates/m2eclipse-wtp/"/>
+ <property name="URL2" value="http://download.jboss.org/jbosstools/updates/m2e-jdt-compiler/"/>
+ <property name="URL3" value="http://download.jboss.org/jbosstools/updates/requirements/m2eclipse/m2ecl..."/>
+
+ <!--
+ <property name="URL1" value="http://download.eclipse.org/technology/m2e/releases/"/>
+ <property name="URL2" value="http://repository.sonatype.org/content/repositories/forge-sites/m2e-extra..."/>
+ -->
+
+ <property name="destination" value="/home/nboldt/tru/download.jboss.org/jbosstools/updates/requirements/m2eclipse/" />
+ <property name="compress" value="true" />
+
+ <p2.mirror>
+ <repository location="file:${destination}/20120306-1800" name="m2e 1.0, m2e-wtp 0.15.2, m2e-extras 0.15, m2e-jdt-compiler 1.0 (mirrored 20120306-1800)" />
+ <source>
+ <repository location="${URL1}" />
+ <repository location="${URL2}" />
+ <repository location="${URL3}" />
+ </source>
+
+ <slicingOptions includeFeatures="true" followStrict="true" />
+ </p2.mirror>
+
+ <p2.publish.featuresAndBundles metadataRepository="file:${destination}/20120306-1800/" artifactRepository="file:${destination}/20120306-1800/"
+ publishartifacts="true" source="${destination}/20120306-1800/" compress="${compress}" />
+ </target>
+</project>
Modified: trunk/download.jboss.org/jbosstools/updates/requirements/m2eclipse/build.xml
===================================================================
--- trunk/download.jboss.org/jbosstools/updates/requirements/m2eclipse/build.xml 2012-04-16 13:12:46 UTC (rev 40206)
+++ trunk/download.jboss.org/jbosstools/updates/requirements/m2eclipse/build.xml 2012-04-16 13:47:48 UTC (rev 40207)
@@ -16,30 +16,28 @@
-f ~/RHDS/updates/requirements/m2eclipse/build.xml -Ddestination=/tmp/m2eclipse-repo
-->
<target name="mirror">
- <property name="URL1" value="http://download.jboss.org/jbosstools/updates/m2eclipse-wtp/"/>
- <property name="URL2" value="http://download.jboss.org/jbosstools/updates/m2e-jdt-compiler/"/>
+ <!-- <property name="URL1" value="http://download.jboss.org/jbosstools/updates/m2eclipse-wtp/"/> -->
+ <property name="URL1" value="http://download.eclipse.org/technology/m2e/milestones/1.1/1.1.0.20120320-..."/>
+ <property name="URL2" value="https://repository.sonatype.org/content/sites/forge-sites/m2e-extras/0.15..."/>
<property name="URL3" value="http://download.jboss.org/jbosstools/updates/requirements/m2eclipse/m2ecl..."/>
+ <property name="URL4" value="http://download.jboss.org/jbosstools/updates/m2e-jdt-compiler/"/>
- <!--
- <property name="URL1" value="http://download.eclipse.org/technology/m2e/releases/"/>
- <property name="URL2" value="http://repository.sonatype.org/content/repositories/forge-sites/m2e-extra..."/>
- -->
-
<property name="destination" value="/home/nboldt/tru/download.jboss.org/jbosstools/updates/requirements/m2eclipse/" />
<property name="compress" value="true" />
<p2.mirror>
- <repository location="file:${destination}/20120306-1800" name="m2e 1.0, m2e-wtp 0.15.2, m2e-extras 0.15, m2e-jdt-compiler 1.0 (mirrored 20120306-1800)" />
+ <repository location="file:${destination}/20120416-0900" name="m2e 1.1, m2e-extras 0.15.0.N, m2e-wtp 0.15.2, m2e-jdt-compiler 1.0 (for use with Juno; mirrored 20120416-0900)" />
<source>
<repository location="${URL1}" />
<repository location="${URL2}" />
<repository location="${URL3}" />
+ <repository location="${URL4}" />
</source>
<slicingOptions includeFeatures="true" followStrict="true" />
</p2.mirror>
- <p2.publish.featuresAndBundles metadataRepository="file:${destination}/20120306-1800/" artifactRepository="file:${destination}/20120306-1800/"
- publishartifacts="true" source="${destination}/20120306-1800/" compress="${compress}" />
+ <p2.publish.featuresAndBundles metadataRepository="file:${destination}/20120416-0900/" artifactRepository="file:${destination}/20120416-0900/"
+ publishartifacts="true" source="${destination}/20120416-0900/" compress="${compress}" />
</target>
</project>
13 years, 12 months
JBoss Tools SVN: r40206 - trunk/vpe/plugins/org.jboss.tools.vpe.browsersim/src/org/jboss/tools/vpe/browsersim/ui/skin/ios.
by jbosstools-commits@lists.jboss.org
Author: yradtsevich
Date: 2012-04-16 09:12:46 -0400 (Mon, 16 Apr 2012)
New Revision: 40206
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe.browsersim/src/org/jboss/tools/vpe/browsersim/ui/skin/ios/AppleIPhone3ResizableSkin.java
Log:
https://issues.jboss.org/browse/JBIDE-10945 : BrowserSim: create more skins
- home button support added
Modified: trunk/vpe/plugins/org.jboss.tools.vpe.browsersim/src/org/jboss/tools/vpe/browsersim/ui/skin/ios/AppleIPhone3ResizableSkin.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe.browsersim/src/org/jboss/tools/vpe/browsersim/ui/skin/ios/AppleIPhone3ResizableSkin.java 2012-04-16 13:04:19 UTC (rev 40205)
+++ trunk/vpe/plugins/org.jboss.tools.vpe.browsersim/src/org/jboss/tools/vpe/browsersim/ui/skin/ios/AppleIPhone3ResizableSkin.java 2012-04-16 13:12:46 UTC (rev 40206)
@@ -215,6 +215,15 @@
}
}
});
+ if (deviceComposite.getHomeButtonComposite() != null) {
+ deviceComposite.getHomeButtonComposite().addMouseListener(new MouseAdapter() {
+ public void mouseDown(MouseEvent e) {
+ if (e.button == 1) {
+ controlHandler.goHome();
+ }
+ }
+ });
+ }
deviceComposite.getUrlText().addListener(SWT.DefaultSelection, new Listener() {
public void handleEvent(Event e) {
controlHandler.goToAddress(((Text)e.widget).getText());
13 years, 12 months
JBoss Tools SVN: r40205 - trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n.
by jbosstools-commits@lists.jboss.org
Author: dmaliarevich
Date: 2012-04-16 09:04:19 -0400 (Mon, 16 Apr 2012)
New Revision: 40205
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/ExternalizeStringsWizardPage.java
Log:
https://issues.jboss.org/browse/JBIDE-11551 - Externalize selected string not support dot
Modified: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/ExternalizeStringsWizardPage.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/ExternalizeStringsWizardPage.java 2012-04-16 11:16:38 UTC (rev 40204)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/ExternalizeStringsWizardPage.java 2012-04-16 13:04:19 UTC (rev 40205)
@@ -537,8 +537,11 @@
for (int i = 0; i < ExternalizeStringsUtils.REPLACED_CHARACTERS.length; i++) {
/*
* Entering of the forbidden characters will be prevented.
+ * https://issues.jboss.org/browse/JBIDE-11551
+ * Dot(.) should be supported.
*/
- if (e.character == ExternalizeStringsUtils.REPLACED_CHARACTERS[i]) {
+ if ((e.character == ExternalizeStringsUtils.REPLACED_CHARACTERS[i])
+ && (e.character != '.')) {
e.doit = false;
break;
}
13 years, 12 months
JBoss Tools SVN: r40204 - in trunk/modeshape: features/org.jboss.tools.modeshape.jcr.test.feature and 6 other directories.
by jbosstools-commits@lists.jboss.org
Author: elvisisking
Date: 2012-04-16 07:16:38 -0400 (Mon, 16 Apr 2012)
New Revision: 40204
Added:
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/MultiValidationStatusTest.java
Modified:
trunk/modeshape/features/org.jboss.tools.modeshape.jcr.feature/
trunk/modeshape/features/org.jboss.tools.modeshape.jcr.test.feature/
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/PropertyDialog.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/MultiValidationStatus.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/ValidationStatus.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/CndValidator.java
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/CndValidatorTest.java
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/test/AllTests.java
Log:
JBIDE-11530 Add Code Field To ValidationStatus Object To Facilitate Successful Test Verification. Added a code field to ValidationStatus and changed tests to verify the status code.
Property changes on: trunk/modeshape/features/org.jboss.tools.modeshape.jcr.feature
___________________________________________________________________
Added: svn:ignore
+ *.class
bin
target
.classpath
Property changes on: trunk/modeshape/features/org.jboss.tools.modeshape.jcr.test.feature
___________________________________________________________________
Added: svn:ignore
+ *.class
bin
target
.classpath
Modified: trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/MultiValidationStatus.java
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/MultiValidationStatus.java 2012-04-16 11:12:14 UTC (rev 40203)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/MultiValidationStatus.java 2012-04-16 11:16:38 UTC (rev 40204)
@@ -20,6 +20,9 @@
*/
public static MultiValidationStatus OK_STATUS = new MultiValidationStatus();
+ /**
+ * A collection of statuses (never <code>null</code>)
+ */
private final List<ValidationStatus> errors = new ArrayList<ValidationStatus>();
private ValidationStatus primary = null;
@@ -28,14 +31,18 @@
* Constructs an OK status.
*/
public MultiValidationStatus() {
- super(Severity.OK, Messages.okValidationMsg);
+ super(Severity.OK, ValidationStatus.OK_CODE, ValidationStatus.OK_STATUS.getMessage());
}
/**
* @param status the status used to construct (cannot be <code>null</code>)
*/
public MultiValidationStatus( final ValidationStatus status ) {
- super(status.getSeverity(), status.getMessage());
+ super(status.getSeverity(), status.getCode(), status.getMessage());
+
+ if (!status.isOk()) {
+ add(status);
+ }
}
/**
@@ -48,14 +55,48 @@
this.primary = statusBeingAdded;
this.severity = this.primary.getSeverity();
this.message = this.primary.getMessage();
+ this.code = this.primary.getCode();
}
}
/**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.tools.modeshape.jcr.ValidationStatus#containsCode(int)
+ */
+ @Override
+ public boolean containsCode( int code ) {
+ if (code == getCode()) {
+ return true;
+ }
+
+ for (ValidationStatus status : getAll()) {
+ if (status instanceof MultiValidationStatus) {
+ if (((MultiValidationStatus)status).containsCode(code)) {
+ return true;
+ }
+ } else if (code == status.getCode()) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ /**
* @return a collection of all contained statuses (never <code>null</code>)
*/
public List<ValidationStatus> getAll() {
- return this.errors;
+ List<ValidationStatus> all = new ArrayList<ValidationStatus>();
+
+ for (ValidationStatus status : this.errors) {
+ if (status instanceof MultiValidationStatus) {
+ all.addAll(((MultiValidationStatus)status).getAll());
+ } else {
+ all.add(status);
+ }
+ }
+
+ return all;
}
-
}
Modified: trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/ValidationStatus.java
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/ValidationStatus.java 2012-04-16 11:12:14 UTC (rev 40203)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/ValidationStatus.java 2012-04-16 11:16:38 UTC (rev 40204)
@@ -13,43 +13,61 @@
public class ValidationStatus implements Comparable<ValidationStatus> {
/**
+ * The default code for an OK message. Value is {@value} .
+ */
+ public static final int OK_CODE = 0;
+
+ /**
* An OK validation status with a standard, localized message.
*/
- public static final ValidationStatus OK_STATUS = createOkMessage(Messages.okValidationMsg);
+ public static final ValidationStatus OK_STATUS = createOkMessage(OK_CODE, Messages.okValidationMsg);
/**
+ * @param code a code uniquely identifying the status
* @param message the validation message (cannot be <code>null</code> or empty)
* @return the error validation message (never <code>null</code>)
*/
- public static ValidationStatus createErrorMessage( final String message ) {
- return new ValidationStatus(Severity.ERROR, message);
+ public static ValidationStatus createErrorMessage( int code,
+ final String message ) {
+ return new ValidationStatus(Severity.ERROR, code, message);
}
/**
+ * @param code a code uniquely identifying the status
* @param message the validation message (cannot be <code>null</code> or empty)
* @return the information validation message (never <code>null</code>)
*/
- public static ValidationStatus createInfoMessage( final String message ) {
- return new ValidationStatus(Severity.INFO, message);
+ public static ValidationStatus createInfoMessage( int code,
+ final String message ) {
+ return new ValidationStatus(Severity.INFO, code, message);
}
/**
+ * @param code a code uniquely identifying the status
* @param message the validation message (cannot be <code>null</code> or empty)
* @return the OK validation message (never <code>null</code>)
*/
- public static ValidationStatus createOkMessage( final String message ) {
- return new ValidationStatus(Severity.OK, message);
+ public static ValidationStatus createOkMessage( int code,
+ final String message ) {
+ return new ValidationStatus(Severity.OK, code, message);
}
/**
+ * @param code a code uniquely identifying the status
* @param message the validation message (cannot be <code>null</code> or empty)
* @return the warning validation message (never <code>null</code>)
*/
- public static ValidationStatus createWarningMessage( final String message ) {
- return new ValidationStatus(Severity.WARNING, message);
+ public static ValidationStatus createWarningMessage( int code,
+ final String message ) {
+ return new ValidationStatus(Severity.WARNING, code, message);
}
/**
+ * A code uniquely identifying the status.
+ */
+ protected int code;
+
+ /**
* The localized message which can be displayed to the user (never <code>null</code>).
*/
protected String message;
@@ -61,13 +79,16 @@
/**
* @param severity the status severity (cannot be <code>null</code>)
+ * @param code a code uniquely identifying the status
* @param message the status localized user message (cannot be <code>null</code>)
*/
protected ValidationStatus( final Severity severity,
+ int code,
final String message ) {
assert (severity != null) : "severity is null"; //$NON-NLS-1$
Utils.verifyIsNotEmpty(message, "message"); //$NON-NLS-1$
+ this.code = code;
this.severity = severity;
this.message = message;
}
@@ -132,8 +153,16 @@
}
/**
+ * @param code the code being checked for
+ * @return <code>true</code> if the code is found
+ */
+ public boolean containsCode(int code) {
+ return (getCode() == code);
+ }
+
+ /**
* {@inheritDoc}
- *
+ *
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
@@ -149,8 +178,15 @@
ValidationStatus that = (ValidationStatus)obj;
return (this.severity.equals(that.severity) && this.message.equals(that.message));
}
-
+
/**
+ * @return the unique code for this status
+ */
+ public int getCode() {
+ return this.code;
+ }
+
+ /**
* @return the message pertaining to the worse validation severity (never <code>null</code>)
*/
public String getMessage() {
@@ -166,14 +202,14 @@
/**
* {@inheritDoc}
- *
+ *
* @see java.lang.Object#hashCode()
*/
@Override
public int hashCode() {
return Utils.hashCode(this.severity, this.message);
}
-
+
/**
* @return <code>true</code> if the validation status has an error severity
*/
Modified: trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/CndValidator.java
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/CndValidator.java 2012-04-16 11:12:14 UTC (rev 40203)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/CndValidator.java 2012-04-16 11:16:38 UTC (rev 40204)
@@ -11,7 +11,9 @@
import java.net.URI;
import java.sql.Date;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collection;
+import java.util.Collections;
import java.util.StringTokenizer;
import org.eclipse.core.runtime.IStatus;
@@ -39,6 +41,7 @@
public final class CndValidator {
private static final String PARENT_PATH_SEGMENT = ".."; //$NON-NLS-1$
+
private static final String SELF_PATH_SEGMENT = "."; //$NON-NLS-1$
/**
@@ -57,7 +60,7 @@
}
if (Utils.isEmpty(value)) {
- return ValidationStatus.createErrorMessage(NLS.bind(Messages.emptyValue, propertyName));
+ return ValidationStatus.createErrorMessage(StatusCodes.EMPTY_VALUE, NLS.bind(Messages.emptyValue, propertyName));
}
try {
@@ -69,35 +72,40 @@
return ValidationStatus.OK_STATUS; // always valid
} else if (PropertyType.BOOLEAN == propertyType) {
if (!value.equalsIgnoreCase(Boolean.TRUE.toString()) && !value.equalsIgnoreCase(Boolean.FALSE.toString())) {
- return ValidationStatus.createErrorMessage(NLS.bind(Messages.invalidPropertyValueForType, new Object[] { value,
- PropertyType.BOOLEAN, propertyName }));
+ return ValidationStatus.createErrorMessage(StatusCodes.INVALID_PROPERTY_VALUE_FOR_TYPE,
+ NLS.bind(Messages.invalidPropertyValueForType, new Object[] { value,
+ PropertyType.BOOLEAN, propertyName }));
}
} else if (PropertyType.DATE == propertyType) {
try {
Date.valueOf(value);
} catch (final Exception e) {
- return ValidationStatus.createErrorMessage(NLS.bind(Messages.invalidPropertyValueForType, new Object[] { value,
- PropertyType.DATE, propertyName }));
+ return ValidationStatus.createErrorMessage(StatusCodes.INVALID_PROPERTY_VALUE_FOR_TYPE,
+ NLS.bind(Messages.invalidPropertyValueForType, new Object[] { value,
+ PropertyType.DATE, propertyName }));
}
} else if (PropertyType.DECIMAL == propertyType) {
try {
new BigDecimal(value);
} catch (final Exception e) {
- return ValidationStatus.createErrorMessage(NLS.bind(Messages.invalidPropertyValueForType, value,
+ return ValidationStatus.createErrorMessage(StatusCodes.INVALID_PROPERTY_VALUE_FOR_TYPE,
+ NLS.bind(Messages.invalidPropertyValueForType, value,
PropertyType.DECIMAL));
}
} else if (PropertyType.DOUBLE == propertyType) {
try {
Double.parseDouble(value);
} catch (final Exception e) {
- return ValidationStatus.createErrorMessage(NLS.bind(Messages.invalidPropertyValueForType, value,
+ return ValidationStatus.createErrorMessage(StatusCodes.INVALID_PROPERTY_VALUE_FOR_TYPE,
+ NLS.bind(Messages.invalidPropertyValueForType, value,
PropertyType.DOUBLE));
}
} else if (PropertyType.LONG == propertyType) {
try {
Long.parseLong(value);
} catch (final Exception e) {
- return ValidationStatus.createErrorMessage(NLS.bind(Messages.invalidPropertyValueForType, value,
+ return ValidationStatus.createErrorMessage(StatusCodes.INVALID_PROPERTY_VALUE_FOR_TYPE,
+ NLS.bind(Messages.invalidPropertyValueForType, value,
PropertyType.LONG));
}
} else if (PropertyType.NAME == propertyType) {
@@ -116,8 +124,9 @@
return ValidationStatus.OK_STATUS;
} catch (final Exception e) {
- return ValidationStatus.createErrorMessage(NLS.bind(Messages.errorValidatingPropertyValueForType, new Object[] { value,
- propertyType, propertyName }));
+ return ValidationStatus.createErrorMessage(StatusCodes.ERROR_VALIDATING_PROPERTY_VALUE_FOR_TYPE,
+ NLS.bind(Messages.errorValidatingPropertyValueForType, new Object[] { value,
+ propertyType, propertyName }));
}
}
@@ -231,7 +240,8 @@
if (!Utils.isEmpty(childNodeName) && !ItemDefinition.RESIDUAL_NAME.equals(childNodeName)) {
if (childNodeNames.contains(childNodeName)) {
- status.add(ValidationStatus.createErrorMessage(NLS.bind(Messages.duplicateChildNodeDefinitionName,
+ status.add(ValidationStatus.createErrorMessage(StatusCodes.DUPLICATE_CHILD_NODE_DEFINITION_NAME,
+ NLS.bind(Messages.duplicateChildNodeDefinitionName,
nodeTypeName, childNodeName)));
} else {
childNodeNames.add(childNodeName);
@@ -301,7 +311,8 @@
// WARNING - No namespace declarations or node type definitions exist
if (noNamespaceMappings && noNodeTypeDefinitions) {
- status.add(ValidationStatus.createWarningMessage(Messages.cndHasNoNamespacesOrNodeTypeDefinitions));
+ status.add(ValidationStatus.createWarningMessage(StatusCodes.CND_HAS_NO_NAMESPACES_OR_NODE_TYPE_DEFINITIONS,
+ Messages.cndHasNoNamespacesOrNodeTypeDefinitions));
}
return status;
@@ -370,14 +381,16 @@
}
if (!foundMatch) {
- status.add(ValidationStatus.createErrorMessage(NLS.bind(Messages.defaultTypeDoesNotMatchRequiredType,
+ status.add(ValidationStatus.createErrorMessage(StatusCodes.DEFAULT_TYPE_DOES_NOT_MATCH_REQUIRED_TYPE,
+ NLS.bind(Messages.defaultTypeDoesNotMatchRequiredType,
childNodeName, defaultTypeName)));
}
}
}
} else if (!Utils.isEmpty(defaultTypeName)) {
// ERROR - Cannot have explicit default type when default type is marked as a variant
- status.add(ValidationStatus.createErrorMessage(NLS.bind(Messages.defaultTypeExistsButMarkedAsVariant, childNodeName)));
+ status.add(ValidationStatus.createErrorMessage(StatusCodes.DEFAULT_TYPE_EXISTS_BUT_MARKED_AS_VARIANT,
+ NLS.bind(Messages.defaultTypeExistsButMarkedAsVariant, childNodeName)));
}
}
@@ -414,30 +427,85 @@
if (Utils.isEmpty(defaultValues)) {
if (propertyDefinition.getState(PropertyDefinition.PropertyName.DEFAULT_VALUES) == Value.IS) {
- status.add(ValidationStatus.createErrorMessage(NLS.bind(Messages.emptyDefaultValues, propertyName)));
+ status.add(ValidationStatus.createErrorMessage(StatusCodes.EMPTY_DEFAULT_VALUES,
+ NLS.bind(Messages.emptyDefaultValues, propertyName)));
}
} else {
// ERROR - Cannot have multiple default values when the property definition is single-valued
if ((defaultValues.size() > 1)
&& (propertyDefinition.getState(PropertyDefinition.PropertyName.MULTIPLE) == Value.IS_NOT)) {
- status.add(ValidationStatus.createErrorMessage(NLS.bind(Messages.multipleDefaultValuesForSingleValuedProperty,
+ status.add(ValidationStatus.createErrorMessage(StatusCodes.MULTIPLE_DEFAULT_VALUES_FOR_SINGLE_VALUED_PROPERTY,
+ NLS.bind(Messages.multipleDefaultValuesForSingleValuedProperty,
propertyName)));
}
+ validateDefaultValues(propertyName, propertyDefinition.getType(), defaultValues, validNamespacePrefixes, status);
+
+ // ERROR - Cannot have explicit default values when default values is marked as a variant
+ if (propertyDefinition.getState(PropertyDefinition.PropertyName.DEFAULT_VALUES) != Value.IS) {
+ status.add(ValidationStatus.createErrorMessage(StatusCodes.DEFAULT_VALUES_EXIST_BUT_MARKED_AS_VARIANT,
+ NLS.bind(Messages.defaultValuesExistButMarkedAsVariant,
+ propertyDefinition)));
+ }
+ }
+ }
+
+ /**
+ * Checks for duplicates and correct value for type.
+ *
+ * @param propertyName the name of the property definition (can be <code>null</code> or empty)
+ * @param propertyType the property definition's property type (cannot be <code>null</code>)
+ * @param defaultValues the default values (can be <code>null</code>)
+ * @param validNamespacePrefixes the valid namespace prefixes (can be <code>null</code> or empty)
+ * @return the status (never <code>null</code>)
+ */
+ public static MultiValidationStatus validateDefaultValues( final String propertyName,
+ final PropertyType propertyType,
+ final Collection<String> defaultValues,
+ final Collection<String> validNamespacePrefixes ) {
+ final MultiValidationStatus status = new MultiValidationStatus();
+ validateDefaultValues(propertyName, propertyType, defaultValues, validNamespacePrefixes, status);
+ return status;
+ }
+
+ /**
+ * Checks for duplicates and correct value for type.
+ *
+ * @param propertyName the name of the property definition (cannot be <code>null</code> or empty)
+ * @param propertyType the property definition's property type (cannot be <code>null</code>)
+ * @param defaultValues the default values (can be <code>null</code>)
+ * @param validNamespacePrefixes the valid namespace prefixes (can be <code>null</code> or empty)
+ * @param status the status to add the new status to (cannot be <code>null</code>)
+ */
+ public static void validateDefaultValues( String propertyName,
+ final PropertyType propertyType,
+ final Collection<String> defaultValues,
+ final Collection<String> validNamespacePrefixes,
+ final MultiValidationStatus status ) {
+ Utils.verifyIsNotNull(propertyType, "propertyType"); //$NON-NLS-1$
+
+ if (propertyName == null) {
+ propertyName = Messages.missingName;
+ }
+
+ if (!Utils.isEmpty(defaultValues)) {
final Collection<String> values = new ArrayList<String>(defaultValues.size());
for (final String defaultValue : defaultValues) {
// ERROR - Default value is not valid for the property definition type
- isValid(defaultValue, propertyDefinition.getType(), Messages.defaultValue, status);
+ isValid(defaultValue, propertyType, Messages.defaultValue, status);
// make sure if NAME type the qualifier is valid
- if (!Utils.isEmpty(validNamespacePrefixes) && (propertyDefinition.getType() == PropertyType.NAME)) {
+ final Collection<String> qualifiers = (Utils.isEmpty(validNamespacePrefixes) ? Collections.<String> emptyList()
+ : validNamespacePrefixes);
+
+ if (propertyType == PropertyType.NAME) {
final QualifiedName qname = QualifiedName.parse(defaultValue);
final String qualifier = qname.getQualifier();
boolean valid = false;
if (!Utils.isEmpty(qualifier)) {
- for (final String validQualifier : validNamespacePrefixes) {
+ for (final String validQualifier : qualifiers) {
if (validQualifier.equals(qualifier)) {
valid = true;
break;
@@ -446,7 +514,8 @@
}
if (!valid) {
- status.add(ValidationStatus.createErrorMessage(NLS.bind(Messages.invalidQualifierForDefaultValue,
+ status.add(ValidationStatus.createErrorMessage(StatusCodes.INVALID_QUALIFIER_FOR_DEFAULT_VALUE,
+ NLS.bind(Messages.invalidQualifierForDefaultValue,
propertyName, defaultValue)));
}
}
@@ -454,19 +523,14 @@
if (!Utils.isEmpty(defaultValue)) {
// ERROR - Duplicate default value
if (values.contains(defaultValue)) {
- status.add(ValidationStatus.createErrorMessage(NLS.bind(Messages.duplicateDefaultValue, propertyName,
+ status.add(ValidationStatus.createErrorMessage(StatusCodes.DUPLICATE_DEFAULT_VALUE,
+ NLS.bind(Messages.duplicateDefaultValue, propertyName,
defaultValue)));
} else {
values.add(defaultValue);
}
}
}
-
- // ERROR - Cannot have explicit default values when default values is marked as a variant
- if (propertyDefinition.getState(PropertyDefinition.PropertyName.DEFAULT_VALUES) != Value.IS) {
- status.add(ValidationStatus.createErrorMessage(NLS.bind(Messages.defaultValuesExistButMarkedAsVariant,
- propertyDefinition)));
- }
}
}
@@ -481,12 +545,14 @@
Utils.verifyIsNotEmpty(messagePrefix, messagePrefix);
if (Utils.isEmpty(localName)) {
- return ValidationStatus.createErrorMessage(NLS.bind(Messages.emptyLocalName, messagePrefix));
+ return ValidationStatus.createErrorMessage(StatusCodes.EMPTY_LOCAL_NAME,
+ NLS.bind(Messages.emptyLocalName, messagePrefix));
}
// ERROR Local name cannot be self or parent
if (localName.equals(SELF_PATH_SEGMENT) || localName.equals(PARENT_PATH_SEGMENT)) {
- return ValidationStatus.createErrorMessage(NLS.bind(Messages.localNameEqualToSelfOrParent, messagePrefix));
+ return ValidationStatus.createErrorMessage(StatusCodes.LOCAL_NAME_EQUAL_TO_SELF_OR_PARENT,
+ NLS.bind(Messages.localNameEqualToSelfOrParent, messagePrefix));
}
for (final char c : localName.toCharArray()) {
@@ -498,7 +564,8 @@
case '|':
case '*':
// ERROR invalid character
- return ValidationStatus.createErrorMessage(NLS.bind(Messages.localNameHasInvalidCharacters, messagePrefix,
+ return ValidationStatus.createErrorMessage(StatusCodes.LOCAL_NAME_HAS_INVALID_CHARACTERS,
+ NLS.bind(Messages.localNameHasInvalidCharacters, messagePrefix,
localName));
default:
continue;
@@ -652,7 +719,8 @@
try {
if (!Utils.isEmpty(prefix) && WorkspaceRegistry.get().isBuiltInNamespacePrefix(prefix)) {
if (!Utils.equals(uri, WorkspaceRegistry.get().getUri(prefix))) {
- status.add(ValidationStatus.createErrorMessage(NLS.bind(Messages.invalidUriForBuiltInNamespacePrefix,
+ status.add(ValidationStatus.createErrorMessage(StatusCodes.INVALID_URI_FOR_BUILT_IN_NAMESPACE_PREFIX,
+ NLS.bind(Messages.invalidUriForBuiltInNamespacePrefix,
new Object[] { uri, prefix,
WorkspaceRegistry.get().getUri(prefix) })));
}
@@ -661,7 +729,8 @@
// ERROR - URI matches a built-in but prefix does not match
if (!Utils.isEmpty(uri) && WorkspaceRegistry.get().isBuiltInNamespaceUri(uri)) {
if (!Utils.equals(prefix, WorkspaceRegistry.get().getPrefix(uri))) {
- status.add(ValidationStatus.createErrorMessage(NLS.bind(Messages.invalidPrefixForBuiltInNamespaceUri,
+ status.add(ValidationStatus.createErrorMessage(StatusCodes.INVALID_PREFIX_FOR_BUILT_IN_NAMESPACE_URI,
+ NLS.bind(Messages.invalidPrefixForBuiltInNamespaceUri,
new Object[] { prefix, uri,
WorkspaceRegistry.get().getPrefix(uri) })));
}
@@ -697,7 +766,8 @@
prefix = Utils.EMPTY_STRING;
}
- status.add(ValidationStatus.createErrorMessage(NLS.bind(Messages.duplicateNamespacePrefix, prefix)));
+ status.add(ValidationStatus.createErrorMessage(StatusCodes.DUPLICATE_NAMESPACE_PREFIX,
+ NLS.bind(Messages.duplicateNamespacePrefix, prefix)));
}
if (checkUri && Utils.equivalent(namespaceMapping.getUri(), namespace.getUri())) {
@@ -708,7 +778,8 @@
uri = Utils.EMPTY_STRING;
}
- status.add(ValidationStatus.createErrorMessage(NLS.bind(Messages.duplicateNamespaceUri, uri)));
+ status.add(ValidationStatus.createErrorMessage(StatusCodes.DUPLICATE_NAMESPACE_URI,
+ NLS.bind(Messages.duplicateNamespaceUri, uri)));
}
}
}
@@ -774,7 +845,8 @@
if (!Utils.isEmpty(prefix)) {
if (prefixes.contains(prefix)) {
- status.add(ValidationStatus.createErrorMessage(NLS.bind(Messages.duplicateNamespacePrefix, prefix)));
+ status.add(ValidationStatus.createErrorMessage(StatusCodes.DUPLICATE_NAMESPACE_PREFIX,
+ NLS.bind(Messages.duplicateNamespacePrefix, prefix)));
} else {
prefixes.add(prefix);
}
@@ -786,7 +858,8 @@
if (!Utils.isEmpty(uri)) {
if (uris.contains(uri)) {
- status.add(ValidationStatus.createErrorMessage(NLS.bind(Messages.duplicateNamespaceUri, uri)));
+ status.add(ValidationStatus.createErrorMessage(StatusCodes.DUPLICATE_NAMESPACE_URI,
+ NLS.bind(Messages.duplicateNamespaceUri, uri)));
} else {
uris.add(uri);
}
@@ -855,7 +928,8 @@
if (Utils.isEmpty(superTypeNames)) {
if (nodeTypeDefinition.getState(NodeTypeDefinition.PropertyName.SUPERTYPES) == Value.IS) {
- status.add(ValidationStatus.createErrorMessage(NLS.bind(Messages.emptySuperTypes, nodeTypeDefinitionName)));
+ status.add(ValidationStatus.createErrorMessage(StatusCodes.EMPTY_SUPER_TYPES,
+ NLS.bind(Messages.emptySuperTypes, nodeTypeDefinitionName)));
}
} else {
validateSuperTypes(nodeTypeDefinitionName, validNamespacePrefixes,
@@ -871,7 +945,8 @@
validateQualifiedName(primaryItemName, Messages.primaryItemName, validNamespacePrefixes, null, status);
} else if (!Utils.isEmpty(primaryItemName.get())) {
// ERROR Cannot have a primary item name when the primary item node type attribute is marked as a variant
- status.add(ValidationStatus.createErrorMessage(NLS.bind(Messages.primaryItemExistsButMarkedAsVariant,
+ status.add(ValidationStatus.createErrorMessage(StatusCodes.PRIMARY_ITEM_EXISTS_BUT_MARKED_AS_VARIANT,
+ NLS.bind(Messages.primaryItemExistsButMarkedAsVariant,
nodeTypeDefinitionName)));
}
}
@@ -950,7 +1025,8 @@
if (!Utils.isEmpty(name)) {
if (names.contains(name)) {
- status.add(ValidationStatus.createErrorMessage(NLS.bind(Messages.duplicateNodeTypeDefinitionName, name)));
+ status.add(ValidationStatus.createErrorMessage(StatusCodes.DUPLICATE_NODE_TYPE_DEFINITION_NAME,
+ NLS.bind(Messages.duplicateNodeTypeDefinitionName, name)));
} else {
names.add(name);
}
@@ -994,7 +1070,7 @@
}
if (Utils.isEmpty(path)) {
- return ValidationStatus.createErrorMessage(NLS.bind(Messages.emptyValue, propertyName));
+ return ValidationStatus.createErrorMessage(StatusCodes.EMPTY_VALUE, NLS.bind(Messages.emptyValue, propertyName));
}
final StringTokenizer pathTokenizer = new StringTokenizer(path, "/"); //$NON-NLS-1$
@@ -1006,7 +1082,8 @@
if (Utils.isEmpty(segment)) {
if (pathTokenizer.hasMoreTokens()) {
// found empty segment
- return ValidationStatus.createErrorMessage(NLS.bind(Messages.invalidPropertyValueForType, path,
+ return ValidationStatus.createErrorMessage(StatusCodes.INVALID_PROPERTY_VALUE_FOR_TYPE,
+ NLS.bind(Messages.invalidPropertyValueForType, path,
PropertyType.PATH));
}
} else {
@@ -1018,7 +1095,8 @@
if (Utils.isEmpty(qualifiedName)) {
// found SNS but now qualified name
- return ValidationStatus.createErrorMessage(NLS.bind(Messages.invalidPropertyValueForType, path,
+ return ValidationStatus.createErrorMessage(StatusCodes.INVALID_PROPERTY_VALUE_FOR_TYPE,
+ NLS.bind(Messages.invalidPropertyValueForType, path,
PropertyType.PATH));
}
@@ -1044,13 +1122,15 @@
for (final char c : snsIndex.toCharArray()) {
if (!Character.isDigit(c)) {
// found invalid character
- return ValidationStatus.createErrorMessage(NLS.bind(Messages.invalidPropertyValueForType, path,
+ return ValidationStatus.createErrorMessage(StatusCodes.INVALID_PROPERTY_VALUE_FOR_TYPE,
+ NLS.bind(Messages.invalidPropertyValueForType, path,
PropertyType.PATH));
}
}
} else {
// no ending SNS bracket
- return ValidationStatus.createErrorMessage(NLS.bind(Messages.invalidPropertyValueForType, path,
+ return ValidationStatus.createErrorMessage(StatusCodes.INVALID_PROPERTY_VALUE_FOR_TYPE,
+ NLS.bind(Messages.invalidPropertyValueForType, path,
PropertyType.PATH));
}
} else {
@@ -1137,7 +1217,8 @@
if (Utils.isEmpty(queryOperators)) {
if (propertyDefinition.getState(PropertyDefinition.PropertyName.QUERY_OPS) == Value.IS) {
- status.add(ValidationStatus.createErrorMessage(NLS.bind(Messages.emptyQueryOperators, propertyDefinitionName)));
+ status.add(ValidationStatus.createErrorMessage(StatusCodes.EMPTY_QUERY_OPERATORS,
+ NLS.bind(Messages.emptyQueryOperators, propertyDefinitionName)));
}
} else {
final Collection<String> operators = new ArrayList<String>(queryOperators.length);
@@ -1149,7 +1230,8 @@
if (!Utils.isEmpty(operator)) {
// ERROR - Duplicate query operator
if (operators.contains(operator)) {
- status.add(ValidationStatus.createErrorMessage(NLS.bind(Messages.duplicateQueryOperator,
+ status.add(ValidationStatus.createErrorMessage(StatusCodes.DUPLICATE_QUERY_OPERATOR,
+ NLS.bind(Messages.duplicateQueryOperator,
propertyDefinitionName, operator)));
} else {
operators.add(operator);
@@ -1159,7 +1241,8 @@
// ERROR - Cannot have explicit query operators when query operators is marked as a variant
if (propertyDefinition.getState(PropertyDefinition.PropertyName.QUERY_OPS) != Value.IS) {
- status.add(ValidationStatus.createErrorMessage(NLS.bind(Messages.queryOperatorsExistButMarkedAsVariant,
+ status.add(ValidationStatus.createErrorMessage(StatusCodes.QUERY_OPERATORS_EXIST_BUT_MARKED_AS_VARIANT,
+ NLS.bind(Messages.queryOperatorsExistButMarkedAsVariant,
propertyDefinition)));
}
}
@@ -1220,7 +1303,8 @@
if (!Utils.isEmpty(propName) && !ItemDefinition.RESIDUAL_NAME.equals(propName)) {
if (propNames.contains(propName)) {
- status.add(ValidationStatus.createErrorMessage(NLS.bind(Messages.duplicatePropertyDefinitionName,
+ status.add(ValidationStatus.createErrorMessage(StatusCodes.DUPLICATE_PROPERTY_DEFINITION_NAME,
+ NLS.bind(Messages.duplicatePropertyDefinitionName,
nodeTypeName, propName)));
} else {
propNames.add(propName);
@@ -1299,7 +1383,8 @@
final String unqualifiedName = qname.getUnqualifiedName();
if (Utils.isEmpty(unqualifiedName)) {
- status.add(ValidationStatus.createErrorMessage(NLS.bind(Messages.emptyUnqualifiedName, propertyName)));
+ status.add(ValidationStatus.createErrorMessage(StatusCodes.EMPTY_UNQUALIFIED_NAME,
+ NLS.bind(Messages.emptyUnqualifiedName, propertyName)));
} else {
final ValidationStatus nameStatus = validateLocalName(unqualifiedName, propertyName);
@@ -1314,7 +1399,8 @@
final String qualifier = qname.getQualifier();
if (!Utils.isEmpty(qualifier) && !validNamespacePrefixes.contains(qualifier)) {
- final ValidationStatus newStatus = ValidationStatus.createErrorMessage(NLS.bind(Messages.nameQualifierNotFound,
+ final ValidationStatus newStatus = ValidationStatus.createErrorMessage(StatusCodes.NAME_QUALIFIER_NOT_FOUND,
+ NLS.bind(Messages.nameQualifierNotFound,
propertyName, qualifier));
status.add(newStatus);
}
@@ -1322,7 +1408,8 @@
// make sure qname is not a duplicate
if (!Utils.isEmpty(existingQNames) && existingQNames.contains(qname)) {
- final ValidationStatus newStatus = ValidationStatus.createErrorMessage(NLS.bind(Messages.duplicateQualifiedName,
+ final ValidationStatus newStatus = ValidationStatus.createErrorMessage(StatusCodes.DUPLICATE_QUALIFIED_NAME,
+ NLS.bind(Messages.duplicateQualifiedName,
propertyName, qname));
status.add(newStatus);
}
@@ -1337,13 +1424,14 @@
public static ValidationStatus validateQueryOperator( final String operator,
final String propertyDefinitionName ) {
if (Utils.isEmpty(operator)) {
- return ValidationStatus.createErrorMessage(Messages.emptyQueryOperator);
+ return ValidationStatus.createErrorMessage(StatusCodes.EMPTY_QUERY_OPERATOR, Messages.emptyQueryOperator);
}
try {
QueryOperator.find(operator);
} catch (final Exception e) {
- return ValidationStatus.createErrorMessage(NLS.bind(Messages.invalidQueryOperator, operator, propertyDefinitionName));
+ return ValidationStatus.createErrorMessage(StatusCodes.INVALID_QUERY_OPERATOR,
+ NLS.bind(Messages.invalidQueryOperator, operator, propertyDefinitionName));
}
return ValidationStatus.OK_STATUS;
@@ -1397,7 +1485,8 @@
if (Utils.isEmpty(requiredTypeNames)) {
if (childNodeDefinition.getState(ChildNodeDefinition.PropertyName.REQUIRED_TYPES) == Value.IS) {
- status.add(ValidationStatus.createErrorMessage(NLS.bind(Messages.emptyRequiredTypes, childNodeName)));
+ status.add(ValidationStatus.createErrorMessage(StatusCodes.EMPTY_REQUIRED_TYPES,
+ NLS.bind(Messages.emptyRequiredTypes, childNodeName)));
}
} else {
final Collection<QualifiedName> requiredTypes = new ArrayList<QualifiedName>(requiredTypeNames.length);
@@ -1408,7 +1497,8 @@
// ERROR - Duplicate required type name
if (requiredTypes.contains(requiredType)) {
- status.add(ValidationStatus.createErrorMessage(NLS.bind(Messages.duplicateRequiredType, childNodeName,
+ status.add(ValidationStatus.createErrorMessage(StatusCodes.DUPLICATE_REQUIRED_TYPE,
+ NLS.bind(Messages.duplicateRequiredType, childNodeName,
requiredType)));
} else {
requiredTypes.add(requiredType);
@@ -1417,7 +1507,8 @@
// ERROR - Cannot have explicit required types when required types is marked as a variant
if (childNodeDefinition.getState(ChildNodeDefinition.PropertyName.REQUIRED_TYPES) != Value.IS) {
- status.add(ValidationStatus.createErrorMessage(NLS.bind(Messages.requiredTypesExistButMarkedAsVariant,
+ status.add(ValidationStatus.createErrorMessage(StatusCodes.REQUIRED_TYPES_EXIST_BUT_MARKED_AS_VARIANT,
+ NLS.bind(Messages.requiredTypesExistButMarkedAsVariant,
childNodeName)));
}
}
@@ -1461,7 +1552,8 @@
if (!Utils.isEmpty(superTypeName.get())) {
// ERROR - Duplicate super type name
if (names.contains(superTypeName)) {
- status.add(ValidationStatus.createErrorMessage(NLS.bind(Messages.duplicateSuperType, nodeTypeDefinitionName,
+ status.add(ValidationStatus.createErrorMessage(StatusCodes.DUPLICATE_SUPER_TYPE,
+ NLS.bind(Messages.duplicateSuperType, nodeTypeDefinitionName,
superTypeName)));
} else {
names.add(superTypeName);
@@ -1471,7 +1563,8 @@
// ERROR - Cannot have explicit super types when super types is marked as a variant
if (superTypesState != Value.IS) {
- status.add(ValidationStatus.createErrorMessage(NLS.bind(Messages.superTypesExistButMarkedAsVariant,
+ status.add(ValidationStatus.createErrorMessage(StatusCodes.SUPER_TYPES_EXIST_BUT_MARKED_AS_VARIANT,
+ NLS.bind(Messages.superTypesExistButMarkedAsVariant,
nodeTypeDefinitionName)));
}
@@ -1509,13 +1602,13 @@
Utils.verifyIsNotEmpty(propertyName, "propertyName"); //$NON-NLS-1$
if (Utils.isEmpty(uri) || uri.contains(" ")) { //$NON-NLS-1$
- return ValidationStatus.createErrorMessage(NLS.bind(Messages.emptyValue, propertyName));
+ return ValidationStatus.createErrorMessage(StatusCodes.EMPTY_VALUE, NLS.bind(Messages.emptyValue, propertyName));
}
try {
URI.create(uri);
} catch (final Exception e) {
- return ValidationStatus.createErrorMessage(NLS.bind(Messages.invalidUri, propertyName));
+ return ValidationStatus.createErrorMessage(StatusCodes.INVALID_URI, NLS.bind(Messages.invalidUri, propertyName));
}
return ValidationStatus.OK_STATUS;
@@ -1574,11 +1667,52 @@
if (Utils.isEmpty(valueConstraints)) {
if (propertyDefinition.getState(PropertyDefinition.PropertyName.VALUE_CONSTRAINTS) == Value.IS) {
- status.add(ValidationStatus.createErrorMessage(NLS.bind(Messages.emptyValueConstraints, propertyName)));
+ status.add(ValidationStatus.createErrorMessage(StatusCodes.EMPTY_VALUE_CONSTRAINTS,
+ NLS.bind(Messages.emptyValueConstraints, propertyName)));
}
} else {
- final Collection<String> constraints = new ArrayList<String>(valueConstraints.length);
+ validateValueConstraints(propertyName, Arrays.asList(valueConstraints), status);
+ // ERROR - Cannot have explicit value constraints when value constraints is marked as a variant
+ if (propertyDefinition.getState(PropertyDefinition.PropertyName.VALUE_CONSTRAINTS) != Value.IS) {
+ status.add(ValidationStatus.createErrorMessage(StatusCodes.VALUE_CONSTRAINTS_EXIST_BUT_MARKED_AS_VARIANT,
+ NLS.bind(Messages.valueConstraintsExistButMarkedAsVariant,
+ propertyDefinition)));
+ }
+ }
+ }
+
+ /**
+ * Checks for valid constraint and duplicates.
+ *
+ * @param propertyName the property definition name (can be <code>null</code> or empty)
+ * @param valueConstraints the value constraints (can be <code>null</code> or empty)
+ * @return the status (never <code>null</code>)
+ */
+ public static MultiValidationStatus validateValueConstraints( final String propertyName,
+ final Collection<String> valueConstraints ) {
+ final MultiValidationStatus status = new MultiValidationStatus();
+ validateValueConstraints(propertyName, valueConstraints, status);
+ return status;
+ }
+
+ /**
+ * Checks for valid constraint and duplicates.
+ *
+ * @param propertyName the property definition name (can be <code>null</code> or empty)
+ * @param valueConstraints the value constraints (can be <code>null</code> or empty)
+ * @param status the status to add the new status to (cannot be <code>null</code>)
+ */
+ public static void validateValueConstraints( String propertyName,
+ final Collection<String> valueConstraints,
+ final MultiValidationStatus status ) {
+ if (propertyName == null) {
+ propertyName = Messages.missingName;
+ }
+
+ if (!Utils.isEmpty(valueConstraints)) {
+ final Collection<String> constraints = new ArrayList<String>(valueConstraints.size());
+
for (final String constraint : valueConstraints) {
// ERROR - Invalid value constraint
validateValueConstraint(constraint, status);
@@ -1586,19 +1720,14 @@
if (!Utils.isEmpty(constraint)) {
// ERROR - Duplicate value constraint
if (constraints.contains(constraint)) {
- status.add(ValidationStatus.createErrorMessage(NLS.bind(Messages.duplicateValueConstraint, propertyName,
+ status.add(ValidationStatus.createErrorMessage(StatusCodes.DUPLICATE_VALUE_CONSTRAINT,
+ NLS.bind(Messages.duplicateValueConstraint, propertyName,
constraint)));
} else {
constraints.add(constraint);
}
}
}
-
- // ERROR - Cannot have explicit value constraints when value constraints is marked as a variant
- if (propertyDefinition.getState(PropertyDefinition.PropertyName.VALUE_CONSTRAINTS) != Value.IS) {
- status.add(ValidationStatus.createErrorMessage(NLS.bind(Messages.valueConstraintsExistButMarkedAsVariant,
- propertyDefinition)));
- }
}
}
@@ -1609,4 +1738,47 @@
// nothing to do
}
+ interface StatusCodes {
+ int EMPTY_VALUE = 100;
+ int INVALID_PROPERTY_VALUE_FOR_TYPE = 105;
+ int ERROR_VALIDATING_PROPERTY_VALUE_FOR_TYPE = 110;
+ int DUPLICATE_CHILD_NODE_DEFINITION_NAME = 115;
+ int CND_HAS_NO_NAMESPACES_OR_NODE_TYPE_DEFINITIONS = 120;
+ int DEFAULT_TYPE_DOES_NOT_MATCH_REQUIRED_TYPE = 125;
+ int DEFAULT_TYPE_EXISTS_BUT_MARKED_AS_VARIANT = 130;
+ int EMPTY_DEFAULT_VALUES = 135;
+ int MULTIPLE_DEFAULT_VALUES_FOR_SINGLE_VALUED_PROPERTY = 140;
+ int INVALID_QUALIFIER_FOR_DEFAULT_VALUE = 145;
+ int DUPLICATE_DEFAULT_VALUE = 150;
+ int DEFAULT_VALUES_EXIST_BUT_MARKED_AS_VARIANT = 155;
+ int EMPTY_LOCAL_NAME = 160;
+ int LOCAL_NAME_EQUAL_TO_SELF_OR_PARENT = 165;
+ int LOCAL_NAME_HAS_INVALID_CHARACTERS = 170;
+ int INVALID_URI_FOR_BUILT_IN_NAMESPACE_PREFIX = 175;
+ int INVALID_PREFIX_FOR_BUILT_IN_NAMESPACE_URI = 180;
+ int DUPLICATE_NAMESPACE_PREFIX = 185;
+ int DUPLICATE_NAMESPACE_URI = 190;
+ int EMPTY_SUPER_TYPES = 195;
+ int PRIMARY_ITEM_EXISTS_BUT_MARKED_AS_VARIANT = 200;
+ int DUPLICATE_NODE_TYPE_DEFINITION_NAME = 205;
+ int EMPTY_QUERY_OPERATORS = 210;
+ int DUPLICATE_QUERY_OPERATOR = 215;
+ int QUERY_OPERATORS_EXIST_BUT_MARKED_AS_VARIANT = 220;
+ int DUPLICATE_PROPERTY_DEFINITION_NAME = 225;
+ int EMPTY_UNQUALIFIED_NAME = 230;
+ int NAME_QUALIFIER_NOT_FOUND = 235;
+ int DUPLICATE_QUALIFIED_NAME = 240;
+ int EMPTY_QUERY_OPERATOR = 245;
+ int INVALID_QUERY_OPERATOR = 250;
+ int EMPTY_REQUIRED_TYPES = 255;
+ int DUPLICATE_REQUIRED_TYPE = 260;
+ int REQUIRED_TYPES_EXIST_BUT_MARKED_AS_VARIANT = 265;
+ int DUPLICATE_SUPER_TYPE = 270;
+ int SUPER_TYPES_EXIST_BUT_MARKED_AS_VARIANT = 275;
+ int INVALID_URI = 280;
+ int EMPTY_VALUE_CONSTRAINTS = 285;
+ int DUPLICATE_VALUE_CONSTRAINT = 290;
+ int VALUE_CONSTRAINTS_EXIST_BUT_MARKED_AS_VARIANT = 295;
+ }
+
}
Modified: trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/PropertyDialog.java
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/PropertyDialog.java 2012-04-16 11:12:14 UTC (rev 40203)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/PropertyDialog.java 2012-04-16 11:16:38 UTC (rev 40204)
@@ -164,6 +164,10 @@
return this.propertyBeingEdited;
}
+ Collection<String> accessExistingNamespacePrefixes() {
+ return this.existingNamespacePrefixes;
+ }
+
/**
* {@inheritDoc}
*
@@ -1051,7 +1055,7 @@
void handleAddDefaultValue() {
final PropertyDefinition propDefn = getPropertyDefinition();
- final Collection<String> currentDefaultValues = propDefn.getDefaultValuesAsStrings();
+ final Collection<String> currentDefaultValues = new ArrayList<String>(propDefn.getDefaultValuesAsStrings());
final StringValueEditorDialog dialog = new StringValueEditorDialog(getShell()) {
/**
* {@inheritDoc}
@@ -1082,12 +1086,9 @@
}
// check for duplicate
- if (currentDefaultValues.contains(newValue)) {
- return ValidationStatus.createErrorMessage(NLS.bind(Messages.duplicateDefaultValue, propDefn.getName(),
- newValue));
- }
-
- return ValidationStatus.OK_STATUS;
+ currentDefaultValues.add(newValue);
+ return CndValidator.validateDefaultValues(propDefn.getName(), propDefn.getType(), currentDefaultValues,
+ accessExistingNamespacePrefixes());
}
};
@@ -1142,12 +1143,8 @@
}
// check for duplicate
- if (currentConstraints.contains(newValue)) {
- return ValidationStatus.createErrorMessage(NLS.bind(Messages.duplicateValueConstraint,
- propDefn.getName(), newValue));
- }
-
- return ValidationStatus.OK_STATUS;
+ currentConstraints.add(newValue);
+ return CndValidator.validateValueConstraints(propDefn.getName(), currentConstraints);
}
};
@@ -1252,12 +1249,9 @@
}
// check for duplicate
- if (currentDefaultValues.contains(newValue)) {
- return ValidationStatus.createErrorMessage(NLS.bind(Messages.duplicateDefaultValue, propDefn.getName(),
- newValue));
- }
-
- return ValidationStatus.OK_STATUS;
+ currentDefaultValues.add(newValue);
+ return CndValidator.validateDefaultValues(propDefn.getName(), propDefn.getType(), currentDefaultValues,
+ accessExistingNamespacePrefixes());
}
};
@@ -1332,12 +1326,8 @@
}
// check for duplicate
- if (currentConstraints.contains(newValue)) {
- return ValidationStatus.createErrorMessage(NLS.bind(Messages.duplicateValueConstraint,
- propDefn.getName(), newValue));
- }
-
- return ValidationStatus.OK_STATUS;
+ currentConstraints.add(newValue);
+ return CndValidator.validateValueConstraints(propDefn.getName(), currentConstraints);
}
};
Added: trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/MultiValidationStatusTest.java
===================================================================
--- trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/MultiValidationStatusTest.java (rev 0)
+++ trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/MultiValidationStatusTest.java 2012-04-16 11:16:38 UTC (rev 40204)
@@ -0,0 +1,171 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ *
+ * See the LEGAL.txt file distributed with this work for information regarding copyright ownership and licensing.
+ *
+ * See the AUTHORS.txt file distributed with this work for a full listing of individual contributors.
+ */
+package org.jboss.tools.modeshape.jcr;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ *
+ */
+public class MultiValidationStatusTest {
+
+ private static final int ERROR_CODE = 100;
+ private static final String ERROR_MSG = "error messgae"; //$NON-NLS-1$
+ private static final ValidationStatus ERROR_STATUS = ValidationStatus.createErrorMessage(ERROR_CODE, ERROR_MSG);
+
+ private static final int WARNING_CODE = 200;
+ private static final String WARNING_MSG = "warning messgae"; //$NON-NLS-1$
+ private static final ValidationStatus WARNING_STATUS = ValidationStatus.createWarningMessage(WARNING_CODE, WARNING_MSG);
+
+ private static final int INFO_CODE = 300;
+ private static final String INFO_MSG = "warning messgae"; //$NON-NLS-1$
+ private static final ValidationStatus INFO_STATUS = ValidationStatus.createInfoMessage(INFO_CODE, INFO_MSG);
+
+ private MultiValidationStatus status;
+
+ @Before
+ public void beforeEach() {
+ this.status = new MultiValidationStatus();
+ }
+
+ @Test
+ public void shouldHaveOkStatusAfterConstruction() {
+ assertTrue(this.status.isOk());
+ }
+
+ @Test
+ public void shouldNotHaveErrorsAfterConstruction() {
+ assertEquals(0, this.status.getAll().size());
+ }
+
+ @Test
+ public void shouldHaveOkStatusCodeAfterConstruction() {
+ assertEquals(ValidationStatus.OK_CODE, this.status.getCode());
+ }
+
+ @Test
+ public void shouldHaveErrorStatusAfterAddingAnError() {
+ this.status.add(ERROR_STATUS);
+ assertTrue(this.status.isError());
+ assertEquals(ERROR_CODE, this.status.getCode());
+ assertTrue(this.status.containsCode(ERROR_CODE));
+ assertEquals(ERROR_MSG, this.status.getMessage());
+ assertEquals(1, this.status.getAll().size());
+ }
+
+ @Test
+ public void shouldHaveWarningStatusAfterAddingAWarning() {
+ this.status.add(WARNING_STATUS);
+ assertTrue(this.status.isWarning());
+ assertEquals(WARNING_CODE, this.status.getCode());
+ assertTrue(this.status.containsCode(WARNING_CODE));
+ assertEquals(WARNING_MSG, this.status.getMessage());
+ assertEquals(1, this.status.getAll().size());
+ }
+
+ @Test
+ public void shouldHaveInfoStatusAfterAddingAnInfo() {
+ this.status.add(INFO_STATUS);
+ assertTrue(this.status.isInfo());
+ assertEquals(INFO_CODE, this.status.getCode());
+ assertTrue(this.status.containsCode(INFO_CODE));
+ assertEquals(INFO_MSG, this.status.getMessage());
+ assertEquals(1, this.status.getAll().size());
+ }
+
+ @Test
+ public void shouldChangeStatusToErrorFromInfoAfterAddingAnError() {
+ this.status.add(INFO_STATUS);
+ this.status.add(ERROR_STATUS);
+ assertTrue(this.status.isError());
+ assertEquals(2, this.status.getAll().size());
+ assertTrue(this.status.containsCode(ERROR_CODE));
+ assertTrue(this.status.containsCode(INFO_CODE));
+ }
+
+ @Test
+ public void shouldChangeStatusToErrorFromWarningAfterAddingAnError() {
+ this.status.add(WARNING_STATUS);
+ this.status.add(ERROR_STATUS);
+ assertTrue(this.status.isError());
+ assertEquals(2, this.status.getAll().size());
+ assertTrue(this.status.containsCode(ERROR_CODE));
+ assertTrue(this.status.containsCode(WARNING_CODE));
+ }
+
+ @Test
+ public void shouldNotChangeStatusFromErrorWhenAddingAnInfo() {
+ this.status.add(ERROR_STATUS);
+ this.status.add(INFO_STATUS);
+ assertTrue(this.status.isError());
+ assertEquals(2, this.status.getAll().size());
+ assertTrue(this.status.containsCode(ERROR_CODE));
+ assertTrue(this.status.containsCode(INFO_CODE));
+ }
+
+ @Test
+ public void shouldNotChangeStatusFromErrorWhenAddingAWarning() {
+ this.status.add(ERROR_STATUS);
+ this.status.add(WARNING_STATUS);
+ assertTrue(this.status.isError());
+ assertEquals(2, this.status.getAll().size());
+ assertTrue(this.status.containsCode(ERROR_CODE));
+ assertTrue(this.status.containsCode(WARNING_CODE));
+ }
+
+ @Test
+ public void shouldNotChangeStatusFromWarningWhenAddingAnInfo() {
+ this.status.add(WARNING_STATUS);
+ this.status.add(INFO_STATUS);
+ assertTrue(this.status.isWarning());
+ assertEquals(2, this.status.getAll().size());
+ assertTrue(this.status.containsCode(WARNING_CODE));
+ assertTrue(this.status.containsCode(INFO_CODE));
+ }
+
+ @Test
+ public void shouldAddMultiStatusesCorrectly() {
+ MultiValidationStatus mvs1 = new MultiValidationStatus(ERROR_STATUS);
+ this.status.add(mvs1);
+
+ MultiValidationStatus mvs2 = new MultiValidationStatus(WARNING_STATUS);
+ this.status.add(mvs2);
+
+ MultiValidationStatus mvs3 = new MultiValidationStatus(INFO_STATUS);
+ this.status.add(mvs3);
+
+ assertTrue(this.status.isError());
+ assertEquals(ERROR_CODE, this.status.getCode());
+ assertEquals(3, this.status.getAll().size());
+ assertTrue(this.status.containsCode(ERROR_CODE));
+ assertTrue(this.status.containsCode(WARNING_CODE));
+ assertTrue(this.status.containsCode(INFO_CODE));
+ }
+
+ @Test
+ public void shouldAddNestedMultiStatusesCorrectly() {
+ MultiValidationStatus mvs1 = new MultiValidationStatus(ERROR_STATUS);
+ MultiValidationStatus mvs2 = new MultiValidationStatus(WARNING_STATUS);
+ MultiValidationStatus mvs3 = new MultiValidationStatus(INFO_STATUS);
+
+ mvs2.add(mvs1);
+ mvs3.add(mvs2);
+ this.status.add(mvs3);
+
+ assertTrue(this.status.isError());
+ assertEquals(ERROR_CODE, this.status.getCode());
+ assertEquals(3, this.status.getAll().size());
+ assertTrue(this.status.containsCode(ERROR_CODE));
+ assertTrue(this.status.containsCode(WARNING_CODE));
+ assertTrue(this.status.containsCode(INFO_CODE));
+ }
+}
Property changes on: trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/MultiValidationStatusTest.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/CndValidatorTest.java
===================================================================
--- trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/CndValidatorTest.java 2012-04-16 11:12:14 UTC (rev 40203)
+++ trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/CndValidatorTest.java 2012-04-16 11:16:38 UTC (rev 40204)
@@ -17,8 +17,10 @@
import org.jboss.tools.modeshape.jcr.PropertyDefinition;
import org.jboss.tools.modeshape.jcr.QualifiedName;
import org.jboss.tools.modeshape.jcr.Utils;
+import org.jboss.tools.modeshape.jcr.ValidationStatus;
import org.jboss.tools.modeshape.jcr.attributes.PropertyType;
import org.jboss.tools.modeshape.jcr.attributes.QueryOperators.QueryOperator;
+import org.jboss.tools.modeshape.jcr.cnd.CndValidator.StatusCodes;
import org.junit.Before;
import org.junit.Test;
@@ -35,94 +37,155 @@
@Before
public void beforeEach() {
- this.cnd = new CompactNodeTypeDefinition();
- this.namespaceMapping = new NamespaceMapping();
+ cnd = new CompactNodeTypeDefinition();
+ namespaceMapping = new NamespaceMapping();
- this.nodeTypeDefinition = new NodeTypeDefinition();
- this.nodeTypeDefinition.setName(Constants.QUALIFIED_NAME1.get());
+ nodeTypeDefinition = new NodeTypeDefinition();
+ nodeTypeDefinition.setName(Constants.QUALIFIED_NAME1.get());
- this.childNodeDefinition = new ChildNodeDefinition(this.nodeTypeDefinition);
- this.childNodeDefinition.setName(Constants.QUALIFIED_NAME1.get());
+ childNodeDefinition = new ChildNodeDefinition(nodeTypeDefinition);
+ childNodeDefinition.setName(Constants.QUALIFIED_NAME1.get());
- this.propertyDefinition = new PropertyDefinition(this.nodeTypeDefinition);
- this.propertyDefinition.setName(Constants.QUALIFIED_NAME1.get());
+ propertyDefinition = new PropertyDefinition(nodeTypeDefinition);
+ propertyDefinition.setName(Constants.QUALIFIED_NAME1.get());
}
@Test
public void childNodeDefinitionWithEmptyNameShouldBeAnError() {
- this.childNodeDefinition.setName(null);
- assertTrue(CndValidator.validateChildNodeDefinition(this.childNodeDefinition, null, null).isError());
+ // setup
+ childNodeDefinition.setName(null);
+ ValidationStatus status = CndValidator.validateChildNodeDefinition(childNodeDefinition, null, null);
- this.childNodeDefinition.setName(Utils.EMPTY_STRING);
- assertTrue(CndValidator.validateChildNodeDefinition(this.childNodeDefinition, null, null).isError());
+ // tests
+ assertTrue(status.isError());
+ assertTrue(status.containsCode(StatusCodes.EMPTY_UNQUALIFIED_NAME));
+
+ // setup
+ childNodeDefinition.setName(Utils.EMPTY_STRING);
+ status = CndValidator.validateChildNodeDefinition(childNodeDefinition, null, null);
+
+ // tests
+ assertTrue(status.isError());
+ assertTrue("Code is " + status.getCode(), status.containsCode(StatusCodes.EMPTY_UNQUALIFIED_NAME)); //$NON-NLS-1$
}
@Test
public void childNodeDefinitionWithInvalidDefaultTypeNameShouldBeAnError() {
- this.childNodeDefinition.setName("name"); //$NON-NLS-1$
- this.childNodeDefinition.setDefaultPrimaryTypeName("missingName:"); //$NON-NLS-1$
- assertTrue(CndValidator.validateChildNodeDefinition(this.childNodeDefinition, null, null).isError());
+ // setup
+ childNodeDefinition.setName("name"); //$NON-NLS-1$
+ childNodeDefinition.setDefaultPrimaryTypeName("missingName:"); //$NON-NLS-1$
+ final ValidationStatus status = CndValidator.validateChildNodeDefinition(childNodeDefinition, null, null);
+
+ // tests
+ assertTrue(status.isError());
+ assertTrue("Code is " + status.getCode(), status.containsCode(StatusCodes.EMPTY_UNQUALIFIED_NAME)); //$NON-NLS-1$
}
@Test
public void childNodeDefinitionWithInvalidNameShouldBeAnError() {
- this.childNodeDefinition.setName("invalid/name"); //$NON-NLS-1$
- assertTrue(CndValidator.validateChildNodeDefinition(this.childNodeDefinition, null, null).isError());
+ // setup
+ childNodeDefinition.setName("invalid/name"); //$NON-NLS-1$
+ final ValidationStatus status = CndValidator.validateChildNodeDefinition(childNodeDefinition, null, null);
+
+ // tests
+ assertTrue(status.isError());
+ assertTrue("Code is " + status.getCode(), status.containsCode(StatusCodes.LOCAL_NAME_HAS_INVALID_CHARACTERS)); //$NON-NLS-1$
}
@Test
public void childNodeDefinitionWithInvalidRequiredTypeNameShouldBeAnError() {
- this.childNodeDefinition.setName("name"); //$NON-NLS-1$
- this.childNodeDefinition.addRequiredType("missingName:"); //$NON-NLS-1$
- assertTrue(CndValidator.validateChildNodeDefinition(this.childNodeDefinition, null, null).isError());
+ // setup
+ childNodeDefinition.setName("name"); //$NON-NLS-1$
+ childNodeDefinition.addRequiredType("missingName:"); //$NON-NLS-1$
+ final ValidationStatus status = CndValidator.validateChildNodeDefinition(childNodeDefinition, null, null);
+
+ // tests
+ assertTrue(status.isError());
+ assertTrue("Code is " + status.getCode(), status.containsCode(StatusCodes.EMPTY_UNQUALIFIED_NAME)); //$NON-NLS-1$
}
@Test
public void childNodeNameWithNonMatchingQualifierShouldBeAnError() {
- this.childNodeDefinition.setName(Constants.NAME_WITH_NON_DEFAULT_QUALIFIER.get());
- assertTrue(CndValidator.validateName(this.childNodeDefinition, Constants.Helper.getDefaultNamespacePrefixes(), null)
- .isError());
+ // setup
+ childNodeDefinition.setName(Constants.NAME_WITH_NON_DEFAULT_QUALIFIER.get());
+ final ValidationStatus status = CndValidator.validateName(childNodeDefinition,
+ Constants.Helper.getDefaultNamespacePrefixes(), null);
+
+ // tests
+ assertTrue(status.isError());
+ assertTrue("Code is " + status.getCode(), status.containsCode(StatusCodes.NAME_QUALIFIER_NOT_FOUND)); //$NON-NLS-1$
}
@Test
public void cndWithoutNamespaceMappingsAndNodeTypeDefintionsShouldBeAWarning() {
- assertTrue(CndValidator.validateCnd(this.cnd).isWarning());
+ // setup
+ final ValidationStatus status = CndValidator.validateCnd(cnd);
+
+ // tests
+ assertTrue(status.isWarning());
+ assertTrue("Code is " + status.getCode(), status.containsCode(StatusCodes.CND_HAS_NO_NAMESPACES_OR_NODE_TYPE_DEFINITIONS)); //$NON-NLS-1$
}
@Test
public void defaultTypeNameShoudMatchRequiredType() {
- this.childNodeDefinition.setName(Constants.QUALIFIED_NAME1.get());
- this.childNodeDefinition.addRequiredType(Constants.QUALIFIED_NAME1.get());
- this.childNodeDefinition.setDefaultPrimaryTypeName(Constants.QUALIFIED_NAME2.get());
- assertTrue(CndValidator.validateDefaultType(this.childNodeDefinition, Constants.Helper.getDefaultNamespacePrefixes())
- .isError());
+ // setup
+ childNodeDefinition.setName(Constants.QUALIFIED_NAME1.get());
+ childNodeDefinition.addRequiredType(Constants.QUALIFIED_NAME1.get());
+ childNodeDefinition.setDefaultPrimaryTypeName(Constants.QUALIFIED_NAME2.get());
+ final ValidationStatus status = CndValidator.validateDefaultType(childNodeDefinition,
+ Constants.Helper.getDefaultNamespacePrefixes());
+
+ // tests
+ assertTrue(status.isError());
+ assertTrue("Code is " + status.getCode(), status.containsCode(StatusCodes.DEFAULT_TYPE_DOES_NOT_MATCH_REQUIRED_TYPE)); //$NON-NLS-1$
}
@Test
public void defaultTypeNameWithNonMatchingQualifierShouldBeAnError() {
- this.childNodeDefinition.setName(Constants.QUALIFIED_NAME1.get());
- this.childNodeDefinition.setDefaultPrimaryTypeName(Constants.NAME_WITH_NON_DEFAULT_QUALIFIER.get());
- assertTrue(CndValidator.validateDefaultType(this.childNodeDefinition, Constants.Helper.getDefaultNamespacePrefixes())
- .isError());
+ // setup
+ childNodeDefinition.setName(Constants.QUALIFIED_NAME1.get());
+ childNodeDefinition.setDefaultPrimaryTypeName(Constants.NAME_WITH_NON_DEFAULT_QUALIFIER.get());
+ final ValidationStatus status = CndValidator.validateDefaultType(childNodeDefinition,
+ Constants.Helper.getDefaultNamespacePrefixes());
+
+ // tests
+ assertTrue(status.isError());
+ assertTrue("Code is " + status.getCode(), status.containsCode(StatusCodes.NAME_QUALIFIER_NOT_FOUND)); //$NON-NLS-1$
}
@Test
public void defaultValueWithInvalidQualifierShouldBeAnError() {
- assertTrue(this.propertyDefinition.setType(PropertyType.NAME));
- assertTrue(this.propertyDefinition.addDefaultValue("bogus:value")); //$NON-NLS-1$
- assertTrue(CndValidator.validateDefaultValues(this.propertyDefinition, Constants.Helper.getDefaultNamespacePrefixes())
- .isError());
+ // setup
+ propertyDefinition.setType(PropertyType.NAME);
+ propertyDefinition.addDefaultValue("bogus:value"); //$NON-NLS-1$
+ final ValidationStatus status = CndValidator.validateDefaultValues(propertyDefinition,
+ Constants.Helper.getDefaultNamespacePrefixes());
+
+ // tests
+ assertTrue(status.isError());
+ assertTrue("Code is " + status.getCode(), status.containsCode(StatusCodes.INVALID_QUALIFIER_FOR_DEFAULT_VALUE)); //$NON-NLS-1$
}
@Test
public void emptyNamespaceMappingPrefixShouldBeAnError() {
- assertTrue(CndValidator.validateNamespaceMapping(this.namespaceMapping).isError());
+ // setup
+ namespaceMapping.setUri("uri"); //$NON-NLS-1$
+ final ValidationStatus status = CndValidator.validateNamespaceMapping(namespaceMapping);
+
+ // tests
+ assertTrue(status.isError());
+ assertTrue("Code is " + status.getCode(), status.containsCode(StatusCodes.EMPTY_LOCAL_NAME)); //$NON-NLS-1$
}
@Test
public void emptyNamespaceMappingUriShouldBeAnError() {
- this.namespaceMapping.setUri("uri"); //$NON-NLS-1$
- assertTrue(CndValidator.validateNamespaceMapping(this.namespaceMapping).isError());
+ // setup
+ namespaceMapping.setPrefix("prefix"); //$NON-NLS-1$
+ final ValidationStatus status = CndValidator.validateNamespaceMapping(namespaceMapping);
+
+ // tests
+ assertTrue(status.isError());
+ assertTrue("Code is " + status.getCode(), status.containsCode(StatusCodes.EMPTY_VALUE)); //$NON-NLS-1$
}
@Test
@@ -133,282 +196,473 @@
@Test
public void emptyQueryOperatorShouldBeAnError() {
- assertTrue(CndValidator.validateQueryOperator(Utils.EMPTY_STRING, "propName").isError()); //$NON-NLS-1$
+ // setup
+ final ValidationStatus status = CndValidator.validateQueryOperator(Utils.EMPTY_STRING, "propName"); //$NON-NLS-1$
+
+ // tests
+ assertTrue(status.isError());
+ assertTrue("Code is " + status.getCode(), status.containsCode(StatusCodes.EMPTY_QUERY_OPERATOR)); //$NON-NLS-1$
}
@Test
public void invalidQualifiedNameQualifierShouldBeAnError() {
+ // setup
final QualifiedName qname = new QualifiedName(Constants.QUALIFIER1 + "Changed", Constants.UNQUALIFIED_NAME1); //$NON-NLS-1$
- assertTrue(CndValidator.validateQualifiedName(qname, "propertyName", Constants.Helper.getDefaultQualifiers(), null).isError()); //$NON-NLS-1$
+ final ValidationStatus status = CndValidator.validateQualifiedName(qname, "propertyName", //$NON-NLS-1$
+ Constants.Helper.getDefaultQualifiers(), null);
+
+ // tests
+ assertTrue(status.isError());
+ assertTrue("Code is " + status.getCode(), status.containsCode(StatusCodes.NAME_QUALIFIER_NOT_FOUND)); //$NON-NLS-1$
}
@Test
public void invalidQueryOperatorShouldBeAnError() {
- assertTrue(CndValidator.validateQueryOperator("a", "propName").isError()); //$NON-NLS-1$ //$NON-NLS-2$
+ // setup
+ final ValidationStatus status = CndValidator.validateQueryOperator("a", "propName"); //$NON-NLS-1$ //$NON-NLS-2$
+
+ // tests
+ assertTrue(status.isError());
+ assertTrue("Code is " + status.getCode(), status.containsCode(StatusCodes.INVALID_QUERY_OPERATOR)); //$NON-NLS-1$
}
@Test
public void localNameEqualToParentShouldBeAnError() {
- this.childNodeDefinition.setName(".."); //$NON-NLS-1$
- assertTrue(CndValidator.validateLocalName(this.childNodeDefinition.getName(), "name").isError()); //$NON-NLS-1$
+ // setup
+ childNodeDefinition.setName(".."); //$NON-NLS-1$
+ final ValidationStatus status = CndValidator.validateLocalName(childNodeDefinition.getName(), "name"); //$NON-NLS-1$
+
+ // tests
+ assertTrue(status.isError());
+ assertTrue("Code is " + status.getCode(), status.containsCode(StatusCodes.LOCAL_NAME_EQUAL_TO_SELF_OR_PARENT)); //$NON-NLS-1$
}
@Test
public void localNameEqualToSelfShouldBeAnError() {
- this.childNodeDefinition.setName("."); //$NON-NLS-1$
- assertTrue(CndValidator.validateLocalName(this.childNodeDefinition.getName(), "name").isError()); //$NON-NLS-1$
+ // setup
+ childNodeDefinition.setName("."); //$NON-NLS-1$
+ final ValidationStatus status = CndValidator.validateLocalName(childNodeDefinition.getName(), "name"); //$NON-NLS-1$
+
+ // tests
+ assertTrue(status.isError());
+ assertTrue("Code is " + status.getCode(), status.containsCode(StatusCodes.LOCAL_NAME_EQUAL_TO_SELF_OR_PARENT)); //$NON-NLS-1$
}
@Test
public void localNameWithInvalidCharactersShouldBeAnError() {
- this.childNodeDefinition.setName("name/"); //$NON-NLS-1$
- assertTrue(CndValidator.validateLocalName(this.childNodeDefinition.getName(), "name").isError()); //$NON-NLS-1$
+ // setup
+ childNodeDefinition.setName("name/"); //$NON-NLS-1$
+ ValidationStatus status = CndValidator.validateLocalName(childNodeDefinition.getName(), "name"); //$NON-NLS-1$
- this.childNodeDefinition.setName("name:"); //$NON-NLS-1$
- assertTrue(CndValidator.validateLocalName(this.childNodeDefinition.getName(), "name").isError()); //$NON-NLS-1$
+ // tests
+ assertTrue(status.isError());
+ assertTrue("Code is " + status.getCode(), status.containsCode(StatusCodes.LOCAL_NAME_HAS_INVALID_CHARACTERS)); //$NON-NLS-1$
- this.childNodeDefinition.setName("name["); //$NON-NLS-1$
- assertTrue(CndValidator.validateLocalName(this.childNodeDefinition.getName(), "name").isError()); //$NON-NLS-1$
+ // setup
+ childNodeDefinition.setName("name:"); //$NON-NLS-1$
+ status = CndValidator.validateLocalName(childNodeDefinition.getName(), "name"); //$NON-NLS-1$
- this.childNodeDefinition.setName("name]"); //$NON-NLS-1$
- assertTrue(CndValidator.validateLocalName(this.childNodeDefinition.getName(), "name").isError()); //$NON-NLS-1$
+ // tests
+ assertTrue(status.isError());
+ assertTrue("Code is " + status.getCode(), status.containsCode(StatusCodes.LOCAL_NAME_HAS_INVALID_CHARACTERS)); //$NON-NLS-1$
- this.childNodeDefinition.setName("name|"); //$NON-NLS-1$
- assertTrue(CndValidator.validateLocalName(this.childNodeDefinition.getName(), "name").isError()); //$NON-NLS-1$
+ // setup
+ childNodeDefinition.setName("name["); //$NON-NLS-1$
+ status = CndValidator.validateLocalName(childNodeDefinition.getName(), "name"); //$NON-NLS-1$
- this.childNodeDefinition.setName("name*"); //$NON-NLS-1$
- assertTrue(CndValidator.validateLocalName(this.childNodeDefinition.getName(), "name").isError()); //$NON-NLS-1$
+ // tests
+ assertTrue(status.isError());
+ assertTrue("Code is " + status.getCode(), status.containsCode(StatusCodes.LOCAL_NAME_HAS_INVALID_CHARACTERS)); //$NON-NLS-1$
+
+ // setup
+ childNodeDefinition.setName("name]"); //$NON-NLS-1$
+ status = CndValidator.validateLocalName(childNodeDefinition.getName(), "name"); //$NON-NLS-1$
+
+ // tests
+ assertTrue(status.isError());
+ assertTrue("Code is " + status.getCode(), status.containsCode(StatusCodes.LOCAL_NAME_HAS_INVALID_CHARACTERS)); //$NON-NLS-1$
+
+ // setup
+ childNodeDefinition.setName("name|"); //$NON-NLS-1$
+ status = CndValidator.validateLocalName(childNodeDefinition.getName(), "name"); //$NON-NLS-1$
+
+ // tests
+ assertTrue(status.isError());
+ assertTrue("Code is " + status.getCode(), status.containsCode(StatusCodes.LOCAL_NAME_HAS_INVALID_CHARACTERS)); //$NON-NLS-1$
+
+ // setup
+ childNodeDefinition.setName("name*"); //$NON-NLS-1$
+ status = CndValidator.validateLocalName(childNodeDefinition.getName(), "name"); //$NON-NLS-1$
+
+ // tests
+ assertTrue(status.isError());
+ assertTrue("Code is " + status.getCode(), status.containsCode(StatusCodes.LOCAL_NAME_HAS_INVALID_CHARACTERS)); //$NON-NLS-1$
}
@Test
public void nodeTypeDefinitionWithDuplicateChildNodeNamesShouldBeAnError() {
- this.nodeTypeDefinition.setName("nodeTypeName"); //$NON-NLS-1$
+ // setup
+ nodeTypeDefinition.setName("nodeTypeName"); //$NON-NLS-1$
+ childNodeDefinition.setName("name"); //$NON-NLS-1$);
+ final ChildNodeDefinition child2 = new ChildNodeDefinition(nodeTypeDefinition);
+ child2.setName(childNodeDefinition.getName());
- final String NAME = "name"; //$NON-NLS-1$
- this.childNodeDefinition.setName(NAME);
- final ChildNodeDefinition child2 = new ChildNodeDefinition(this.nodeTypeDefinition);
- child2.setName(NAME);
+ nodeTypeDefinition.addChildNodeDefinition(childNodeDefinition);
+ nodeTypeDefinition.addChildNodeDefinition(child2);
- this.nodeTypeDefinition.addChildNodeDefinition(this.childNodeDefinition);
- this.nodeTypeDefinition.addChildNodeDefinition(child2);
-
- assertTrue(CndValidator.validateNodeTypeDefinition(this.nodeTypeDefinition, null, null, true).isError());
+ // tests
+ final ValidationStatus status = CndValidator.validateNodeTypeDefinition(nodeTypeDefinition, null, null, true);
+ assertTrue(status.isError());
+ assertTrue("Code is " + status.getCode(), status.containsCode(StatusCodes.DUPLICATE_CHILD_NODE_DEFINITION_NAME)); //$NON-NLS-1$
}
@Test
public void nodeTypeDefinitionWithDuplicatePropertyNamesShouldBeAnError() {
- this.nodeTypeDefinition.setName("nodeTypeName"); //$NON-NLS-1$
+ // setup
+ nodeTypeDefinition.setName("nodeTypeName"); //$NON-NLS-1$
+ propertyDefinition.setName("name"); //$NON-NLS-1$
+ final PropertyDefinition prop2 = new PropertyDefinition(nodeTypeDefinition);
+ prop2.setName(propertyDefinition.getName());
- final String NAME = "name"; //$NON-NLS-1$
- this.propertyDefinition.setName(NAME);
- final PropertyDefinition prop2 = new PropertyDefinition(this.nodeTypeDefinition);
- prop2.setName(NAME);
+ nodeTypeDefinition.addPropertyDefinition(propertyDefinition);
+ nodeTypeDefinition.addPropertyDefinition(prop2);
- this.nodeTypeDefinition.addPropertyDefinition(this.propertyDefinition);
- this.nodeTypeDefinition.addPropertyDefinition(prop2);
-
- assertTrue(CndValidator.validateNodeTypeDefinition(this.nodeTypeDefinition, null, null, true).isError());
+ // tests
+ final ValidationStatus status = CndValidator.validateNodeTypeDefinition(nodeTypeDefinition, null, null, true);
+ assertTrue(status.isError());
+ assertTrue("Code is " + status.getCode(), status.containsCode(StatusCodes.DUPLICATE_PROPERTY_DEFINITION_NAME)); //$NON-NLS-1$
}
@Test
public void nodeTypeDefinitionWithEmptyNameShouldAnError() {
- this.nodeTypeDefinition.setName(null);
- assertTrue(CndValidator.validateNodeTypeDefinition(this.nodeTypeDefinition, null, null, false).isError());
+ // setup
+ nodeTypeDefinition.setName(null);
+ ValidationStatus status = CndValidator.validateNodeTypeDefinition(nodeTypeDefinition, null, null, false);
- this.nodeTypeDefinition.setName(Utils.EMPTY_STRING);
- assertTrue(CndValidator.validateNodeTypeDefinition(this.nodeTypeDefinition, null, null, false).isError());
+ // tests
+ assertTrue(status.isError());
+ assertTrue("Code is " + status.getCode(), status.containsCode(StatusCodes.EMPTY_UNQUALIFIED_NAME)); //$NON-NLS-1$
+
+ // setup
+ nodeTypeDefinition.setName(Utils.EMPTY_STRING);
+ status = CndValidator.validateNodeTypeDefinition(nodeTypeDefinition, null, null, false);
+
+ // tests
+ assertTrue(status.isError());
+ assertTrue("Code is " + status.getCode(), status.containsCode(StatusCodes.EMPTY_UNQUALIFIED_NAME)); //$NON-NLS-1$
}
@Test
public void nodeTypeDefinitionWithInvalidNameShouldBeAnError() {
- this.nodeTypeDefinition.setName("invalid/name"); //$NON-NLS-1$
- assertTrue(CndValidator.validateNodeTypeDefinition(this.nodeTypeDefinition, null, null, false).isError());
+ // setup
+ nodeTypeDefinition.setName("invalid/name"); //$NON-NLS-1$
+ final ValidationStatus status = CndValidator.validateNodeTypeDefinition(nodeTypeDefinition, null, null, false);
+
+ // tests
+ assertTrue(status.isError());
+ assertTrue("Code is " + status.getCode(), status.containsCode(StatusCodes.LOCAL_NAME_HAS_INVALID_CHARACTERS)); //$NON-NLS-1$
}
@Test
public void nodeTypeDefinitionWithInvalidPrimaryItemNameShouldBeAnError() {
- this.nodeTypeDefinition.setName("nodeTypeName"); //$NON-NLS-1$
- this.nodeTypeDefinition.setPrimaryItemName("invalid/name"); //$NON-NLS-1$
+ // setup
+ nodeTypeDefinition.setName("nodeTypeName"); //$NON-NLS-1$
+ nodeTypeDefinition.setPrimaryItemName("invalid/name"); //$NON-NLS-1$
+ final ValidationStatus status = CndValidator.validateNodeTypeDefinition(nodeTypeDefinition, null, null, false);
- assertTrue(CndValidator.validateNodeTypeDefinition(this.nodeTypeDefinition, null, null, false).isError());
+ // tests
+ assertTrue(status.isError());
+ assertTrue("Code is " + status.getCode(), status.containsCode(StatusCodes.LOCAL_NAME_HAS_INVALID_CHARACTERS)); //$NON-NLS-1$
}
@Test
public void nodeTypeDefinitionWithInvalidSuperTypeNameShouldBeAnError() {
- this.nodeTypeDefinition.setName("nodeTypeName"); //$NON-NLS-1$
- this.nodeTypeDefinition.addSuperType("invalid/name"); //$NON-NLS-1$
+ // setup
+ nodeTypeDefinition.setName("nodeTypeName"); //$NON-NLS-1$
+ nodeTypeDefinition.addSuperType("invalid/name"); //$NON-NLS-1$
+ final ValidationStatus status = CndValidator.validateNodeTypeDefinition(nodeTypeDefinition, null, null, false);
- assertTrue(CndValidator.validateNodeTypeDefinition(this.nodeTypeDefinition, null, null, false).isError());
+ // tests
+ assertTrue(status.isError());
+ assertTrue("Code is " + status.getCode(), status.containsCode(StatusCodes.LOCAL_NAME_HAS_INVALID_CHARACTERS)); //$NON-NLS-1$
}
@Test
public void nodeTypeNameWithNonMatchingQualifierShouldBeAnError() {
- this.nodeTypeDefinition.setName(Constants.NAME_WITH_NON_DEFAULT_QUALIFIER.get());
- assertTrue(CndValidator.validateName(this.nodeTypeDefinition, Constants.Helper.getDefaultNamespacePrefixes(), null)
- .isError());
+ // setup
+ nodeTypeDefinition.setName(Constants.NAME_WITH_NON_DEFAULT_QUALIFIER.get());
+ final ValidationStatus status = CndValidator.validateName(nodeTypeDefinition,
+ Constants.Helper.getDefaultNamespacePrefixes(), null);
+
+ // tests
+ assertTrue(status.isError());
+ assertTrue("Code is " + status.getCode(), status.containsCode(StatusCodes.NAME_QUALIFIER_NOT_FOUND)); //$NON-NLS-1$
}
@Test
public void nullQueryOperatorShouldBeAnError() {
- assertTrue(CndValidator.validateQueryOperator(null, "propName").isError()); //$NON-NLS-1$
+ // setup
+ final ValidationStatus status = CndValidator.validateQueryOperator(null, "propName"); //$NON-NLS-1$
+
+ // tests
+ assertTrue(status.isError());
+ assertTrue("Code is " + status.getCode(), status.containsCode(StatusCodes.EMPTY_QUERY_OPERATOR)); //$NON-NLS-1$
}
@Test
public void primaryItemNameWithNonMatchingQualifierShouldBeAnError() {
- this.nodeTypeDefinition.setName(Constants.QUALIFIED_NAME1.get());
- this.nodeTypeDefinition.setPrimaryItemName(Constants.NAME_WITH_NON_DEFAULT_QUALIFIER.get());
- assertTrue(CndValidator.validateNodeTypeDefinition(this.nodeTypeDefinition, Constants.Helper.getDefaultNamespacePrefixes(),
- null, false).isError());
+ // setup
+ nodeTypeDefinition.setName(Constants.QUALIFIED_NAME1.get());
+ nodeTypeDefinition.setPrimaryItemName(Constants.NAME_WITH_NON_DEFAULT_QUALIFIER.get());
+ final ValidationStatus status = CndValidator.validateNodeTypeDefinition(nodeTypeDefinition,
+ Constants.Helper.getDefaultNamespacePrefixes(),
+ null, false);
+
+ // tests
+ assertTrue(status.isError());
+ assertTrue("Code is " + status.getCode(), status.containsCode(StatusCodes.NAME_QUALIFIER_NOT_FOUND)); //$NON-NLS-1$
}
@Test
public void propertyDefinitionWithEmptyNameShouldNotBeValid() {
- this.propertyDefinition.setName(null);
- assertTrue(CndValidator.validatePropertyDefinition(this.propertyDefinition, null, null).isError());
+ // setup
+ propertyDefinition.setName(null);
+ ValidationStatus status = CndValidator.validatePropertyDefinition(propertyDefinition, null, null);
- this.propertyDefinition.setName(Utils.EMPTY_STRING);
- assertTrue(CndValidator.validatePropertyDefinition(this.propertyDefinition, null, null).isError());
+ // tests
+ assertTrue(status.isError());
+ assertTrue("Code is " + status.getCode(), status.containsCode(StatusCodes.EMPTY_UNQUALIFIED_NAME)); //$NON-NLS-1$
+
+ // setup
+ propertyDefinition.setName(Utils.EMPTY_STRING);
+ status = CndValidator.validatePropertyDefinition(propertyDefinition, null, null);
+
+ // tests
+ assertTrue(status.isError());
+ assertTrue("Code is " + status.getCode(), status.containsCode(StatusCodes.EMPTY_UNQUALIFIED_NAME)); //$NON-NLS-1$
}
@Test
public void propertyDefinitionWithInvalidDefaultValueShouldBeAnError() {
- this.propertyDefinition.setName("name"); //$NON-NLS-1$
- this.propertyDefinition.setType(PropertyType.LONG);
- this.propertyDefinition.addDefaultValue("notALongValue"); //$NON-NLS-1$
+ // setup
+ propertyDefinition.setName("name"); //$NON-NLS-1$
+ propertyDefinition.setType(PropertyType.LONG);
+ propertyDefinition.addDefaultValue("notALongValue"); //$NON-NLS-1$
+ final ValidationStatus status = CndValidator.validatePropertyDefinition(propertyDefinition, null, null);
- assertTrue(CndValidator.validatePropertyDefinition(this.propertyDefinition, null, null).isError());
+ // tests
+ assertTrue(status.isError());
+ assertTrue("Code is " + status.getCode(), status.containsCode(StatusCodes.INVALID_PROPERTY_VALUE_FOR_TYPE)); //$NON-NLS-1$
}
@Test
public void propertyDefinitionWithInvalidNameShouldBeAnError() {
- this.propertyDefinition.setName("invalid/name"); //$NON-NLS-1$
- assertTrue(CndValidator.validatePropertyDefinition(this.propertyDefinition, null, null).isError());
+ // setup
+ propertyDefinition.setName("invalid/name"); //$NON-NLS-1$
+ final ValidationStatus status = CndValidator.validatePropertyDefinition(propertyDefinition, null, null);
+
+ // tests
+ assertTrue(status.isError());
+ assertTrue("Code is " + status.getCode(), status.containsCode(StatusCodes.LOCAL_NAME_HAS_INVALID_CHARACTERS)); //$NON-NLS-1$
}
@Test
public void propertyDefinitionWithMultipleDefaultValuesButSingleValuedShouldBeAnError() {
- this.propertyDefinition.setName("name"); //$NON-NLS-1$
- this.propertyDefinition.addDefaultValue("defaultValue1"); //$NON-NLS-1$
- this.propertyDefinition.addDefaultValue("defaultValue2"); //$NON-NLS-1$
+ // setup
+ propertyDefinition.setName("name"); //$NON-NLS-1$
+ propertyDefinition.addDefaultValue("defaultValue1"); //$NON-NLS-1$
+ propertyDefinition.addDefaultValue("defaultValue2"); //$NON-NLS-1$
+ final ValidationStatus status = CndValidator.validatePropertyDefinition(propertyDefinition, null, null);
- assertTrue(CndValidator.validatePropertyDefinition(this.propertyDefinition, null, null).isError());
+ // tests
+ assertTrue(status.isError());
+ assertTrue("Code is " + status.getCode(), status.containsCode(StatusCodes.MULTIPLE_DEFAULT_VALUES_FOR_SINGLE_VALUED_PROPERTY)); //$NON-NLS-1$
}
@Test
public void propertyNameWithNonMatchingQualifierShouldBeAnError() {
- this.propertyDefinition.setName(Constants.NAME_WITH_NON_DEFAULT_QUALIFIER.get());
- assertTrue(CndValidator.validateName(this.propertyDefinition, Constants.Helper.getDefaultNamespacePrefixes(), null)
- .isError());
+ // setup
+ propertyDefinition.setName(Constants.NAME_WITH_NON_DEFAULT_QUALIFIER.get());
+ final ValidationStatus status = CndValidator.validateName(propertyDefinition,
+ Constants.Helper.getDefaultNamespacePrefixes(), null);
+
+ // tests
+ assertTrue(status.isError());
+ assertTrue("Code is " + status.getCode(), status.containsCode(StatusCodes.NAME_QUALIFIER_NOT_FOUND)); //$NON-NLS-1$
}
@Test
public void requiredTypeNameWithNonMatchingQualifierShouldBeAnError() {
- this.childNodeDefinition.setName(Constants.QUALIFIED_NAME1.get());
- this.childNodeDefinition.addRequiredType(Constants.NAME_WITH_NON_DEFAULT_QUALIFIER.get());
- assertTrue(CndValidator.validateRequiredTypes(this.childNodeDefinition, Constants.Helper.getDefaultNamespacePrefixes())
- .isError());
+ // setup
+ childNodeDefinition.setName(Constants.QUALIFIED_NAME1.get());
+ childNodeDefinition.addRequiredType(Constants.NAME_WITH_NON_DEFAULT_QUALIFIER.get());
+ final ValidationStatus status = CndValidator.validateRequiredTypes(childNodeDefinition,
+ Constants.Helper.getDefaultNamespacePrefixes());
+
+ // tests
+ assertTrue(status.isError());
+ assertTrue("Code is " + status.getCode(), status.containsCode(StatusCodes.NAME_QUALIFIER_NOT_FOUND)); //$NON-NLS-1$
}
@Test
public void residualChildNodeDoesNotNeedDefaultType() {
- this.childNodeDefinition.setName(ItemDefinition.RESIDUAL_NAME);
- this.childNodeDefinition.addRequiredType(Constants.QUALIFIED_NAME1.get());
- assertFalse(CndValidator.validateDefaultType(this.childNodeDefinition, Constants.Helper.getDefaultNamespacePrefixes())
- .isError());
+ // setup
+ childNodeDefinition.setName(ItemDefinition.RESIDUAL_NAME);
+ childNodeDefinition.addRequiredType(Constants.QUALIFIED_NAME1.get());
+ final ValidationStatus status = CndValidator.validateDefaultType(childNodeDefinition,
+ Constants.Helper.getDefaultNamespacePrefixes());
+
+ // tests
+ assertFalse(status.isError());
}
@Test
public void shouldAllowChildNodeDefinitionsWithResidualNames() {
- this.childNodeDefinition.setName(ItemDefinition.RESIDUAL_NAME);
- assertTrue(CndValidator.validateName(this.childNodeDefinition, null, null).isOk());
+ // setup
+ childNodeDefinition.setName(ItemDefinition.RESIDUAL_NAME);
+ final ValidationStatus status = CndValidator.validateName(childNodeDefinition, null, null);
+
+ // tests
+ assertTrue(status.isOk());
}
@Test
public void shouldAllowMultipleChildNodeDefinitionsWithResidualNames() {
- this.nodeTypeDefinition.setName("nodeName"); //$NON-NLS-1$
- this.childNodeDefinition.setName(ItemDefinition.RESIDUAL_NAME);
- final ChildNodeDefinition childNode2 = new ChildNodeDefinition(this.nodeTypeDefinition);
+ // setup
+ nodeTypeDefinition.setName("nodeName"); //$NON-NLS-1$
+ childNodeDefinition.setName(ItemDefinition.RESIDUAL_NAME);
+ final ChildNodeDefinition childNode2 = new ChildNodeDefinition(nodeTypeDefinition);
childNode2.setName(ItemDefinition.RESIDUAL_NAME);
- this.nodeTypeDefinition.addChildNodeDefinition(this.childNodeDefinition);
- this.nodeTypeDefinition.addChildNodeDefinition(childNode2);
- assertTrue(CndValidator.validateChildNodeDefinitions(this.nodeTypeDefinition.getName(), null,
- this.nodeTypeDefinition.getChildNodeDefinitions()).isOk());
+ nodeTypeDefinition.addChildNodeDefinition(childNodeDefinition);
+ nodeTypeDefinition.addChildNodeDefinition(childNode2);
+ final ValidationStatus status = CndValidator.validateChildNodeDefinitions(nodeTypeDefinition.getName(), null,
+ nodeTypeDefinition.getChildNodeDefinitions());
+
+ // tests
+ assertTrue(status.isOk());
}
@Test
public void shouldAllowMultiplePropertyDefinitionsWithResidualNames() {
- this.nodeTypeDefinition.setName("nodeName"); //$NON-NLS-1$
- this.propertyDefinition.setName(ItemDefinition.RESIDUAL_NAME);
- final PropertyDefinition propDefn2 = new PropertyDefinition(this.nodeTypeDefinition);
+ // setup
+ nodeTypeDefinition.setName("nodeName"); //$NON-NLS-1$
+ propertyDefinition.setName(ItemDefinition.RESIDUAL_NAME);
+ final PropertyDefinition propDefn2 = new PropertyDefinition(nodeTypeDefinition);
propDefn2.setName(ItemDefinition.RESIDUAL_NAME);
- this.nodeTypeDefinition.addPropertyDefinition(this.propertyDefinition);
- this.nodeTypeDefinition.addPropertyDefinition(propDefn2);
- assertTrue(CndValidator.validatePropertyDefinitions(this.nodeTypeDefinition.getName(), null,
- this.nodeTypeDefinition.getPropertyDefinitions()).isOk());
+ nodeTypeDefinition.addPropertyDefinition(propertyDefinition);
+ nodeTypeDefinition.addPropertyDefinition(propDefn2);
+ final ValidationStatus status = CndValidator.validatePropertyDefinitions(nodeTypeDefinition.getName(), null,
+ nodeTypeDefinition.getPropertyDefinitions());
+
+ // tests
+ assertTrue(status.isOk());
}
@Test
public void shouldAllowPropertyDefinitionsWithResidualNames() {
- this.propertyDefinition.setName(ItemDefinition.RESIDUAL_NAME);
- assertTrue(CndValidator.validateName(this.propertyDefinition, null, null).isOk());
+ // setup
+ propertyDefinition.setName(ItemDefinition.RESIDUAL_NAME);
+ final ValidationStatus status = CndValidator.validateName(propertyDefinition, null, null);
+
+ // tests
+ assertTrue(status.isOk());
}
@Test
public void shouldNotAllowBuiltInPrefixWithIncorrectUri() {
- this.namespaceMapping.setPrefix(Constants.BuiltInNamespaces.JCR.getPrefix());
- this.namespaceMapping.setUri("foo"); //$NON-NLS-1$
- assertTrue(CndValidator.validateNamespaceMapping(this.namespaceMapping).isError());
+ // setup
+ namespaceMapping.setPrefix(Constants.BuiltInNamespaces.JCR.getPrefix());
+ namespaceMapping.setUri("foo"); //$NON-NLS-1$
+ final ValidationStatus status = CndValidator.validateNamespaceMapping(namespaceMapping);
+
+ // tests
+ assertTrue(status.isError());
+ assertTrue("Code is " + status.getCode(), status.containsCode(StatusCodes.INVALID_URI_FOR_BUILT_IN_NAMESPACE_PREFIX)); //$NON-NLS-1$
}
@Test
public void shouldNotAllowBuiltInUriWithIncorrectPrefix() {
- this.namespaceMapping.setPrefix("foo"); //$NON-NLS-1$
- this.namespaceMapping.setUri(Constants.BuiltInNamespaces.JCR.getUri());
- assertTrue(CndValidator.validateNamespaceMapping(this.namespaceMapping).isError());
+ // setup
+ namespaceMapping.setPrefix("foo"); //$NON-NLS-1$
+ namespaceMapping.setUri(Constants.BuiltInNamespaces.JCR.getUri());
+ final ValidationStatus status = CndValidator.validateNamespaceMapping(namespaceMapping);
+
+ // tests
+ assertTrue(status.isError());
+ assertTrue("Code is " + status.getCode(), status.containsCode(StatusCodes.INVALID_PREFIX_FOR_BUILT_IN_NAMESPACE_URI)); //$NON-NLS-1$
}
@Test
public void shouldNotAllowChildNodeDefinitionsWithSameName() {
- this.nodeTypeDefinition.setName("nodeName"); //$NON-NLS-1$
- this.childNodeDefinition.setName("name"); //$NON-NLS-1$
- final ChildNodeDefinition childNode2 = new ChildNodeDefinition(this.nodeTypeDefinition);
- childNode2.setName(this.childNodeDefinition.getName());
- this.nodeTypeDefinition.addChildNodeDefinition(this.childNodeDefinition);
- this.nodeTypeDefinition.addChildNodeDefinition(childNode2);
- assertTrue(CndValidator.validateChildNodeDefinitions(this.nodeTypeDefinition.getName(), null,
- this.nodeTypeDefinition.getChildNodeDefinitions()).isError());
+ // setup
+ nodeTypeDefinition.setName("nodeName"); //$NON-NLS-1$
+ childNodeDefinition.setName("name"); //$NON-NLS-1$
+ final ChildNodeDefinition childNode2 = new ChildNodeDefinition(nodeTypeDefinition);
+ childNode2.setName(childNodeDefinition.getName());
+ nodeTypeDefinition.addChildNodeDefinition(childNodeDefinition);
+ nodeTypeDefinition.addChildNodeDefinition(childNode2);
+ final ValidationStatus status = CndValidator.validateChildNodeDefinitions(nodeTypeDefinition.getName(), null,
+ nodeTypeDefinition.getChildNodeDefinitions());
+
+ // tests
+ assertTrue(status.isError());
+ assertTrue("Code is " + status.getCode(), status.containsCode(StatusCodes.DUPLICATE_CHILD_NODE_DEFINITION_NAME)); //$NON-NLS-1$
}
@Test
public void shouldNotAllowDuplicateNamespacePrefixes() {
+ // setup
// create a namespace mapping with a prefix that already exists and a URI that doesn't exist in the default namespaces
final NamespaceMapping namespaceMapping = new NamespaceMapping(Constants.NAMESPACE_PREFIX1, "xyz"); //$NON-NLS-1$
- assertTrue(CndValidator.validateNamespaceMapping(namespaceMapping, Constants.Helper.getDefaultNamespaces()).isError());
+ final ValidationStatus status = CndValidator.validateNamespaceMapping(namespaceMapping,
+ Constants.Helper.getDefaultNamespaces());
+
+ // tests
+ assertTrue(status.isError());
+ assertTrue("Code is " + status.getCode(), status.containsCode(StatusCodes.DUPLICATE_NAMESPACE_PREFIX)); //$NON-NLS-1$
}
@Test
public void shouldNotAllowDuplicateNamespaceUris() {
+ // setup
// create a namespace mapping with a URI that already exists and a prefix that doesn't exist in the default namespaces
final NamespaceMapping namespaceMapping = new NamespaceMapping("xyz", Constants.NAMESPACE_URI1); //$NON-NLS-1$
- assertTrue(CndValidator.validateNamespaceMapping(namespaceMapping, Constants.Helper.getDefaultNamespaces()).isError());
+ final ValidationStatus status = CndValidator.validateNamespaceMapping(namespaceMapping,
+ Constants.Helper.getDefaultNamespaces());
+
+ // tests
+ assertTrue(status.isError());
+ assertTrue("Code is " + status.getCode(), status.containsCode(StatusCodes.DUPLICATE_NAMESPACE_URI)); //$NON-NLS-1$
}
@Test
public void shouldNotAllowDuplicateQualifiedNames() {
- assertTrue(CndValidator.validateQualifiedName(Constants.QUALIFIED_NAME1,
- "propertyName", Constants.Helper.getDefaultQualifiers(), Constants.Helper.getDefaultQualifiedNames()).isError()); //$NON-NLS-1$
+ // setup
+ final ValidationStatus status = CndValidator.validateQualifiedName(Constants.QUALIFIED_NAME1,
+ "propertyName", //$NON-NLS-1$
+ Constants.Helper.getDefaultQualifiers(),
+ Constants.Helper.getDefaultQualifiedNames());
+
+ // tests
+ assertTrue(status.isError());
+ assertTrue("Code is " + status.getCode(), status.containsCode(StatusCodes.DUPLICATE_QUALIFIED_NAME)); //$NON-NLS-1$
}
@Test
public void shouldNotAllowPropertyDefinitionsWithSameName() {
- this.nodeTypeDefinition.setName("nodeName"); //$NON-NLS-1$
- this.propertyDefinition.setName("name"); //$NON-NLS-1$
- final PropertyDefinition propDefn2 = new PropertyDefinition(this.nodeTypeDefinition);
- propDefn2.setName(this.propertyDefinition.getName());
- this.nodeTypeDefinition.addPropertyDefinition(this.propertyDefinition);
- this.nodeTypeDefinition.addPropertyDefinition(propDefn2);
- assertTrue(CndValidator.validatePropertyDefinitions(this.nodeTypeDefinition.getName(), null,
- this.nodeTypeDefinition.getPropertyDefinitions()).isError());
+ // setup
+ nodeTypeDefinition.setName("nodeName"); //$NON-NLS-1$
+ propertyDefinition.setName("name"); //$NON-NLS-1$
+ final PropertyDefinition propDefn2 = new PropertyDefinition(nodeTypeDefinition);
+ propDefn2.setName(propertyDefinition.getName());
+ nodeTypeDefinition.addPropertyDefinition(propertyDefinition);
+ nodeTypeDefinition.addPropertyDefinition(propDefn2);
+ final ValidationStatus status = CndValidator.validatePropertyDefinitions(nodeTypeDefinition.getName(), null,
+ nodeTypeDefinition.getPropertyDefinitions());
+
+ // tests
+ assertTrue(status.isError());
+ assertTrue("Code is " + status.getCode(), status.containsCode(StatusCodes.DUPLICATE_PROPERTY_DEFINITION_NAME)); //$NON-NLS-1$
}
@Test
@@ -440,11 +694,16 @@
@Test
public void superTypeNameWithNonMatchingQualifierShouldBeAnError() {
- this.nodeTypeDefinition.setName(Constants.QUALIFIED_NAME1.get());
- this.nodeTypeDefinition.addSuperType(Constants.NAME_WITH_NON_DEFAULT_QUALIFIER.get());
- assertTrue(CndValidator.validateSuperTypes(this.nodeTypeDefinition.getName(),
- Constants.Helper.getDefaultNamespacePrefixes(),
- this.nodeTypeDefinition.getState(NodeTypeDefinition.PropertyName.SUPERTYPES),
- this.nodeTypeDefinition.getSupertypes()).isError());
+ // setup
+ nodeTypeDefinition.setName(Constants.QUALIFIED_NAME1.get());
+ nodeTypeDefinition.addSuperType(Constants.NAME_WITH_NON_DEFAULT_QUALIFIER.get());
+ final ValidationStatus status = CndValidator.validateSuperTypes(nodeTypeDefinition.getName(),
+ Constants.Helper.getDefaultNamespacePrefixes(),
+ nodeTypeDefinition.getState(NodeTypeDefinition.PropertyName.SUPERTYPES),
+ nodeTypeDefinition.getSupertypes());
+
+ // tests
+ assertTrue(status.isError());
+ assertTrue("Code is " + status.getCode(), status.containsCode(StatusCodes.NAME_QUALIFIER_NOT_FOUND)); //$NON-NLS-1$
}
}
Modified: trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/test/AllTests.java
===================================================================
--- trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/test/AllTests.java 2012-04-16 11:12:14 UTC (rev 40203)
+++ trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/test/AllTests.java 2012-04-16 11:16:38 UTC (rev 40204)
@@ -7,6 +7,7 @@
*/
package org.jboss.tools.modeshape.jcr.test;
+import org.jboss.tools.modeshape.jcr.MultiValidationStatusTest;
import org.jboss.tools.modeshape.jcr.cnd.ChildNodeDefinitionTest;
import org.jboss.tools.modeshape.jcr.cnd.CndImporterTest;
import org.jboss.tools.modeshape.jcr.cnd.CndTokenizerTest;
@@ -54,6 +55,7 @@
CndValidatorTest.class,
CompactNodeTypeDefinitionTest.class,
LocalNameTest.class,
+ MultiValidationStatusTest.class,
NamespaceMappingTest.class,
NodeTypeDefinitionTest.class,
PropertyDefinitionTest.class,
13 years, 12 months