JBoss Portal SVN: r8255 - modules/common/trunk/build/ide/intellij/idea60/modules/common.
by portal-commits@lists.jboss.org
Author: wesleyhales
Date: 2007-09-12 19:39:23 -0400 (Wed, 12 Sep 2007)
New Revision: 8255
Modified:
modules/common/trunk/build/ide/intellij/idea60/modules/common/common.iml
Log:
updated common iml
Modified: modules/common/trunk/build/ide/intellij/idea60/modules/common/common.iml
===================================================================
--- modules/common/trunk/build/ide/intellij/idea60/modules/common/common.iml 2007-09-12 21:38:19 UTC (rev 8254)
+++ modules/common/trunk/build/ide/intellij/idea60/modules/common/common.iml 2007-09-12 23:39:23 UTC (rev 8255)
@@ -1,339 +1,556 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<module version="4" relativePaths="true" type="JAVA_MODULE">
- <component name="ModuleRootManager" />
- <component name="NewModuleRootManager" inherit-compiler-output="false">
- <output url="file://$MODULE_DIR$/../../../../../../common/output/idea50/classes" />
- <exclude-output />
- <content url="file://$MODULE_DIR$/../../../../../../common">
- <sourceFolder url="file://$MODULE_DIR$/../../../../../../common/src/main" isTestSource="false" />
- <excludeFolder url="file://$MODULE_DIR$/../../../../../../common/output" />
- </content>
- <orderEntry type="inheritedJdk" />
- <orderEntry type="sourceFolder" forTests="false" />
- <orderEntry type="module-library" exported="">
- <library>
- <CLASSES>
- <root url="jar://$MODULE_DIR$/../../../../../../thirdparty/oswego-concurrent/lib/concurrent.jar!/" />
- </CLASSES>
- <JAVADOC>
- <root url="http://gee.cs.oswego.edu/dl/classes/" />
- </JAVADOC>
- <SOURCES />
- </library>
- </orderEntry>
- <orderEntry type="module-library" exported="">
- <library>
- <CLASSES>
- <root url="jar://$MODULE_DIR$/../../../../../../tools/lib/xalan.jar!/" />
- </CLASSES>
- <JAVADOC />
- <SOURCES />
- </library>
- </orderEntry>
- <orderEntry type="module-library">
- <library>
- <CLASSES>
- <root url="jar://$MODULE_DIR$/../../../../../../thirdparty/apache-ant/lib/ant.jar!/" />
- </CLASSES>
- <JAVADOC />
- <SOURCES />
- </library>
- </orderEntry>
- <orderEntry type="module-library">
- <library>
- <CLASSES>
- <root url="jar://$MODULE_DIR$/../../../../../../thirdparty/sun-jaf/lib/activation.jar!/" />
- </CLASSES>
- <JAVADOC />
- <SOURCES />
- </library>
- </orderEntry>
- <orderEntry type="module-library">
- <library>
- <CLASSES>
- <root url="jar://$MODULE_DIR$/../../../../../../thirdparty/apache-log4j/lib/log4j.jar!/" />
- </CLASSES>
- <JAVADOC />
- <SOURCES />
- </library>
- </orderEntry>
- <orderEntry type="module-library">
- <library>
- <CLASSES>
- <root url="jar://$MODULE_DIR$/../../../../../../thirdparty/junit/lib/junit.jar!/" />
- </CLASSES>
- <JAVADOC />
- <SOURCES />
- </library>
- </orderEntry>
- <orderEntry type="module-library">
- <library>
- <CLASSES>
- <root url="jar://$MODULE_DIR$/../../../../../../thirdparty/jbossas/core-libs/lib/jboss-j2ee.jar!/" />
- </CLASSES>
- <JAVADOC />
- <SOURCES />
- </library>
- </orderEntry>
- <orderEntry type="module-library">
- <library>
- <CLASSES>
- <root url="jar://$MODULE_DIR$/../../../../../../thirdparty/jbossas/core-libs/lib/jboss-common.jar!/" />
- </CLASSES>
- <JAVADOC />
- <SOURCES />
- </library>
- </orderEntry>
- <orderEntry type="module-library">
- <library>
- <CLASSES>
- <root url="jar://$MODULE_DIR$/../../../../../../thirdparty/jbossas/core-libs/lib/jboss-jmx.jar!/" />
- </CLASSES>
- <JAVADOC />
- <SOURCES />
- </library>
- </orderEntry>
- <orderEntry type="module-library">
- <library>
- <CLASSES>
- <root url="jar://$MODULE_DIR$/../../../../../../thirdparty/jbossas/core-libs/lib/jboss-system.jar!/" />
- </CLASSES>
- <JAVADOC />
- <SOURCES />
- </library>
- </orderEntry>
- <orderEntry type="module-library">
- <library>
- <CLASSES>
- <root url="jar://$MODULE_DIR$/../../../../../../tools/lib/cargo-core-uberjar-0.8.jar!/" />
- </CLASSES>
- <JAVADOC />
- <SOURCES />
- </library>
- </orderEntry>
- <orderEntry type="module-library">
- <library>
- <CLASSES>
- <root url="jar://$MODULE_DIR$/../../../../../../thirdparty/apache-ant/lib/ant-launcher.jar!/" />
- </CLASSES>
- <JAVADOC />
- <SOURCES />
- </library>
- </orderEntry>
- <orderEntry type="module-library">
- <library>
- <CLASSES>
- <root url="jar://$MODULE_DIR$/../../../../../../tools/lib/ant-junit.jar!/" />
- </CLASSES>
- <JAVADOC />
- <SOURCES />
- </library>
- </orderEntry>
- <orderEntry type="module-library">
- <library>
- <CLASSES>
- <root url="jar://$MODULE_DIR$/../../../../../../thirdparty/apache-httpclient/lib/commons-httpclient.jar!/" />
- </CLASSES>
- <JAVADOC />
- <SOURCES />
- </library>
- </orderEntry>
- <orderEntry type="module-library">
- <library>
- <CLASSES>
- <root url="jar://$MODULE_DIR$/../../../../../../thirdparty/jboss/backport-concurrent/lib/jboss-backport-concurrent.jar!/" />
- </CLASSES>
- <JAVADOC />
- <SOURCES />
- </library>
- </orderEntry>
- <orderEntry type="module-library">
- <library>
- <CLASSES>
- <root url="jar://$MODULE_DIR$/../../../../../../thirdparty/sun-servlet/lib/servlet-api.jar!/" />
- </CLASSES>
- <JAVADOC />
- <SOURCES />
- </library>
- </orderEntry>
- <orderEntryProperties />
- </component>
- <component name="VcsManagerConfiguration">
- <option name="ACTIVE_VCS_NAME" value="svn" />
- <option name="USE_PROJECT_VCS" value="false" />
- </component>
- <component name="copyright">
- <Base>
- <setting name="state" value="1" />
- </Base>
- <LanguageOptions name="$TEMPLATE$">
- <option name="templateOptions">
- <value>
- <option name="block" value="true" />
- <option name="separateBefore" value="true" />
- <option name="separateAfter" value="true" />
- <option name="prefixLines" value="true" />
- <option name="lenBefore" value="80" />
- <option name="lenAfter" value="80" />
- <option name="box" value="true" />
- <option name="filler" value=" " />
- </value>
- </option>
- <option name="notice" value="JBoss, a division of Red Hat Copyright &#36;today.year, Red Hat Middleware, LLC, and individual contributors as indicated by the @authors tag. See the copyright.txt in the distribution for a full listing of individual contributors. This is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this software; if not, write to the Free Software Foundation, Inc., 51 Fr!
anklin St, Fifth Floor, Boston, MA 02110-1301 USA, or see the FSF site: http://www.fsf.org." />
- <option name="keyword" value="Copyright" />
- <option name="fileTypeOverride" value="4" />
- <option name="relativeBefore" value="true" />
- <option name="addBlankAfter" value="true" />
- <option name="fileLocation" value="1" />
- <option name="useAlternate" value="false" />
- </LanguageOptions>
- <LanguageOptions name="CSS">
- <option name="templateOptions">
- <value>
- <option name="block" value="true" />
- <option name="separateBefore" value="false" />
- <option name="separateAfter" value="false" />
- <option name="prefixLines" value="true" />
- <option name="lenBefore" value="80" />
- <option name="lenAfter" value="80" />
- <option name="box" value="false" />
- <option name="filler" value=" " />
- </value>
- </option>
- <option name="notice" value="Copyright (c) &#36;today.year, Your Corporation. All Rights Reserved." />
- <option name="keyword" value="Copyright" />
- <option name="fileTypeOverride" value="2" />
- <option name="relativeBefore" value="true" />
- <option name="addBlankAfter" value="true" />
- <option name="fileLocation" value="1" />
- <option name="useAlternate" value="false" />
- </LanguageOptions>
- <LanguageOptions name="HTML">
- <option name="templateOptions">
- <value>
- <option name="block" value="true" />
- <option name="separateBefore" value="false" />
- <option name="separateAfter" value="false" />
- <option name="prefixLines" value="true" />
- <option name="lenBefore" value="80" />
- <option name="lenAfter" value="80" />
- <option name="box" value="false" />
- <option name="filler" value=" " />
- </value>
- </option>
- <option name="notice" value="Copyright (c) &#36;today.year, Your Corporation. All Rights Reserved." />
- <option name="keyword" value="Copyright" />
- <option name="fileTypeOverride" value="2" />
- <option name="relativeBefore" value="true" />
- <option name="addBlankAfter" value="true" />
- <option name="fileLocation" value="1" />
- <option name="useAlternate" value="false" />
- </LanguageOptions>
- <LanguageOptions name="JAVA">
- <option name="templateOptions">
- <value>
- <option name="block" value="true" />
- <option name="separateBefore" value="false" />
- <option name="separateAfter" value="false" />
- <option name="prefixLines" value="true" />
- <option name="lenBefore" value="80" />
- <option name="lenAfter" value="80" />
- <option name="box" value="false" />
- <option name="filler" value=" " />
- </value>
- </option>
- <option name="notice" value="Copyright (c) &#36;today.year, Your Corporation. All Rights Reserved." />
- <option name="keyword" value="Copyright" />
- <option name="fileTypeOverride" value="2" />
- <option name="relativeBefore" value="true" />
- <option name="addBlankAfter" value="true" />
- <option name="fileLocation" value="1" />
- <option name="useAlternate" value="false" />
- </LanguageOptions>
- <LanguageOptions name="JSP">
- <option name="templateOptions">
- <value>
- <option name="block" value="true" />
- <option name="separateBefore" value="false" />
- <option name="separateAfter" value="false" />
- <option name="prefixLines" value="true" />
- <option name="lenBefore" value="80" />
- <option name="lenAfter" value="80" />
- <option name="box" value="false" />
- <option name="filler" value=" " />
- </value>
- </option>
- <option name="notice" value="Copyright (c) &#36;today.year, Your Corporation. All Rights Reserved." />
- <option name="keyword" value="Copyright" />
- <option name="fileTypeOverride" value="2" />
- <option name="relativeBefore" value="true" />
- <option name="addBlankAfter" value="true" />
- <option name="fileLocation" value="1" />
- <option name="useAlternate" value="false" />
- </LanguageOptions>
- <LanguageOptions name="JavaScript">
- <option name="templateOptions">
- <value>
- <option name="block" value="true" />
- <option name="separateBefore" value="false" />
- <option name="separateAfter" value="false" />
- <option name="prefixLines" value="true" />
- <option name="lenBefore" value="80" />
- <option name="lenAfter" value="80" />
- <option name="box" value="false" />
- <option name="filler" value=" " />
- </value>
- </option>
- <option name="notice" value="Copyright (c) &#36;today.year, Your Corporation. All Rights Reserved." />
- <option name="keyword" value="Copyright" />
- <option name="fileTypeOverride" value="2" />
- <option name="relativeBefore" value="true" />
- <option name="addBlankAfter" value="true" />
- <option name="fileLocation" value="1" />
- <option name="useAlternate" value="false" />
- </LanguageOptions>
- <LanguageOptions name="Properties">
- <option name="templateOptions">
- <value>
- <option name="block" value="true" />
- <option name="separateBefore" value="false" />
- <option name="separateAfter" value="false" />
- <option name="prefixLines" value="true" />
- <option name="lenBefore" value="80" />
- <option name="lenAfter" value="80" />
- <option name="box" value="false" />
- <option name="filler" value=" " />
- </value>
- </option>
- <option name="notice" value="Copyright (c) &#36;today.year, Your Corporation. All Rights Reserved." />
- <option name="keyword" value="Copyright" />
- <option name="fileTypeOverride" value="2" />
- <option name="relativeBefore" value="true" />
- <option name="addBlankAfter" value="true" />
- <option name="fileLocation" value="1" />
- <option name="useAlternate" value="false" />
- </LanguageOptions>
- <LanguageOptions name="XML">
- <option name="templateOptions">
- <value>
- <option name="block" value="true" />
- <option name="separateBefore" value="false" />
- <option name="separateAfter" value="false" />
- <option name="prefixLines" value="true" />
- <option name="lenBefore" value="80" />
- <option name="lenAfter" value="80" />
- <option name="box" value="false" />
- <option name="filler" value=" " />
- </value>
- </option>
- <option name="notice" value="Copyright (c) &#36;today.year, Your Corporation. All Rights Reserved." />
- <option name="keyword" value="Copyright" />
- <option name="fileTypeOverride" value="2" />
- <option name="relativeBefore" value="true" />
- <option name="addBlankAfter" value="true" />
- <option name="fileLocation" value="1" />
- <option name="useAlternate" value="false" />
- </LanguageOptions>
- </component>
-</module>
-
+<?xml version="1.0" encoding="UTF-8"?>
+<module relativePaths="true" type="JAVA_MODULE" version="4">
+ <component name="FacetManager">
+ <facet type="web" name="Web">
+ <configuration>
+ <descriptors>
+ <deploymentDescriptor name="web.xml" url="file://$MODULE_DIR$/../../../../../../common/src/test/resources/implode/foo.sar/bar.war/WEB-INF/web.xml" optional="false" version="2.4" />
+ </descriptors>
+ <webroots>
+ <root url="file://$MODULE_DIR$/../../../../../../common/src/test/resources/implode/foo.sar/bar.war" relative="/" />
+ </webroots>
+ <building>
+ <setting name="EXPLODED_URL" value="file://" />
+ <setting name="EXPLODED_ENABLED" value="false" />
+ <setting name="JAR_URL" value="file://" />
+ <setting name="JAR_ENABLED" value="false" />
+ <setting name="BUILD_MODULE_ON_FRAME_DEACTIVATION" value="false" />
+ <setting name="BUILD_EXTERNAL_DEPENDENCIES" value="false" />
+ <setting name="EXCLUDE_EXPLODED_DIRECTORY" value="true" />
+ <setting name="RUN_JASPER_VALIDATION" value="true" />
+ <setting name="BUILD_ONLY_WEB_RESOURCES" value="false" />
+ </building>
+ <packaging>
+ <containerElement type="module" name="common">
+ <attribute name="method" value="0" />
+ <attribute name="URI" value="/WEB-INF/classes" />
+ </containerElement>
+ <containerElement type="library" level="module">
+ <attribute name="method" value="1" />
+ <attribute name="URI" value="/WEB-INF/lib/ant-junit.jar" />
+ <url>jar://$MODULE_DIR$/../../../../../../tools/lib/ant-junit.jar!/</url>
+ </containerElement>
+ <containerElement type="library" level="module">
+ <attribute name="method" value="1" />
+ <attribute name="URI" value="/WEB-INF/lib/ant-launcher.jar" />
+ <url>jar://$MODULE_DIR$/../../../../../../tools/lib/ant-launcher.jar!/</url>
+ </containerElement>
+ <containerElement type="library" level="module">
+ <attribute name="method" value="1" />
+ <attribute name="URI" value="/WEB-INF/lib/ant-nodeps.jar" />
+ <url>jar://$MODULE_DIR$/../../../../../../tools/lib/ant-nodeps.jar!/</url>
+ </containerElement>
+ <containerElement type="library" level="module">
+ <attribute name="method" value="1" />
+ <attribute name="URI" value="/WEB-INF/lib/ant.jar" />
+ <url>jar://$MODULE_DIR$/../../../../../../tools/lib/ant.jar!/</url>
+ </containerElement>
+ <containerElement type="library" level="module">
+ <attribute name="method" value="1" />
+ <attribute name="URI" value="/WEB-INF/lib/bsf.jar" />
+ <url>jar://$MODULE_DIR$/../../../../../../tools/lib/bsf.jar!/</url>
+ </containerElement>
+ <containerElement type="library" level="module">
+ <attribute name="method" value="1" />
+ <attribute name="URI" value="/WEB-INF/lib/buildmagic-tasks.jar" />
+ <url>jar://$MODULE_DIR$/../../../../../../tools/lib/buildmagic-tasks.jar!/</url>
+ </containerElement>
+ <containerElement type="library" level="module">
+ <attribute name="method" value="1" />
+ <attribute name="URI" value="/WEB-INF/lib/cargo-core-uberjar-0.8.jar" />
+ <url>jar://$MODULE_DIR$/../../../../../../tools/lib/cargo-core-uberjar-0.8.jar!/</url>
+ </containerElement>
+ <containerElement type="library" level="module">
+ <attribute name="method" value="1" />
+ <attribute name="URI" value="/WEB-INF/lib/crimson.jar" />
+ <url>jar://$MODULE_DIR$/../../../../../../tools/lib/crimson.jar!/</url>
+ </containerElement>
+ <containerElement type="library" level="module">
+ <attribute name="method" value="1" />
+ <attribute name="URI" value="/WEB-INF/lib/explode.jar" />
+ <url>jar://$MODULE_DIR$/../../../../../../tools/lib/explode.jar!/</url>
+ </containerElement>
+ <containerElement type="library" level="module">
+ <attribute name="method" value="1" />
+ <attribute name="URI" value="/WEB-INF/lib/jboss-test.jar" />
+ <url>jar://$MODULE_DIR$/../../../../../../tools/lib/jboss-test.jar!/</url>
+ </containerElement>
+ <containerElement type="library" level="module">
+ <attribute name="method" value="1" />
+ <attribute name="URI" value="/WEB-INF/lib/jbossbuild.jar" />
+ <url>jar://$MODULE_DIR$/../../../../../../tools/lib/jbossbuild.jar!/</url>
+ </containerElement>
+ <containerElement type="library" level="module">
+ <attribute name="method" value="1" />
+ <attribute name="URI" value="/WEB-INF/lib/junit.jar" />
+ <url>jar://$MODULE_DIR$/../../../../../../tools/lib/junit.jar!/</url>
+ </containerElement>
+ <containerElement type="library" level="module">
+ <attribute name="method" value="1" />
+ <attribute name="URI" value="/WEB-INF/lib/saxon.jar" />
+ <url>jar://$MODULE_DIR$/../../../../../../tools/lib/saxon.jar!/</url>
+ </containerElement>
+ <containerElement type="library" level="module">
+ <attribute name="method" value="1" />
+ <attribute name="URI" value="/WEB-INF/lib/xalan.jar" />
+ <url>jar://$MODULE_DIR$/../../../../../../tools/lib/xalan.jar!/</url>
+ </containerElement>
+ <containerElement type="library" level="module">
+ <attribute name="method" value="1" />
+ <attribute name="URI" value="/WEB-INF/lib/xercesImpl.jar" />
+ <url>jar://$MODULE_DIR$/../../../../../../tools/lib/xercesImpl.jar!/</url>
+ </containerElement>
+ <containerElement type="library" level="module">
+ <attribute name="method" value="1" />
+ <attribute name="URI" value="/WEB-INF/lib/xml-apis.jar" />
+ <url>jar://$MODULE_DIR$/../../../../../../tools/lib/xml-apis.jar!/</url>
+ </containerElement>
+ </packaging>
+ </configuration>
+ </facet>
+ <facet type="web" name="Web2">
+ <configuration>
+ <descriptors>
+ <deploymentDescriptor name="web.xml" url="file://$MODULE_DIR$/../../../../../../common/target/test-classes/implode/foo.sar/bar.war/WEB-INF/web.xml" optional="false" version="2.4" />
+ </descriptors>
+ <webroots>
+ <root url="file://$MODULE_DIR$/../../../../../../common/target/test-classes/implode/foo.sar/bar.war" relative="/" />
+ </webroots>
+ <building>
+ <setting name="EXPLODED_URL" value="file://" />
+ <setting name="EXPLODED_ENABLED" value="false" />
+ <setting name="JAR_URL" value="file://" />
+ <setting name="JAR_ENABLED" value="false" />
+ <setting name="BUILD_MODULE_ON_FRAME_DEACTIVATION" value="false" />
+ <setting name="BUILD_EXTERNAL_DEPENDENCIES" value="false" />
+ <setting name="EXCLUDE_EXPLODED_DIRECTORY" value="true" />
+ <setting name="RUN_JASPER_VALIDATION" value="true" />
+ <setting name="BUILD_ONLY_WEB_RESOURCES" value="false" />
+ </building>
+ <packaging>
+ <containerElement type="module" name="common">
+ <attribute name="method" value="0" />
+ <attribute name="URI" value="/WEB-INF/classes" />
+ </containerElement>
+ <containerElement type="library" level="module">
+ <attribute name="method" value="1" />
+ <attribute name="URI" value="/WEB-INF/lib/ant-junit.jar" />
+ <url>jar://$MODULE_DIR$/../../../../../../tools/lib/ant-junit.jar!/</url>
+ </containerElement>
+ <containerElement type="library" level="module">
+ <attribute name="method" value="1" />
+ <attribute name="URI" value="/WEB-INF/lib/ant-launcher.jar" />
+ <url>jar://$MODULE_DIR$/../../../../../../tools/lib/ant-launcher.jar!/</url>
+ </containerElement>
+ <containerElement type="library" level="module">
+ <attribute name="method" value="1" />
+ <attribute name="URI" value="/WEB-INF/lib/ant-nodeps.jar" />
+ <url>jar://$MODULE_DIR$/../../../../../../tools/lib/ant-nodeps.jar!/</url>
+ </containerElement>
+ <containerElement type="library" level="module">
+ <attribute name="method" value="1" />
+ <attribute name="URI" value="/WEB-INF/lib/ant.jar" />
+ <url>jar://$MODULE_DIR$/../../../../../../tools/lib/ant.jar!/</url>
+ </containerElement>
+ <containerElement type="library" level="module">
+ <attribute name="method" value="1" />
+ <attribute name="URI" value="/WEB-INF/lib/bsf.jar" />
+ <url>jar://$MODULE_DIR$/../../../../../../tools/lib/bsf.jar!/</url>
+ </containerElement>
+ <containerElement type="library" level="module">
+ <attribute name="method" value="1" />
+ <attribute name="URI" value="/WEB-INF/lib/buildmagic-tasks.jar" />
+ <url>jar://$MODULE_DIR$/../../../../../../tools/lib/buildmagic-tasks.jar!/</url>
+ </containerElement>
+ <containerElement type="library" level="module">
+ <attribute name="method" value="1" />
+ <attribute name="URI" value="/WEB-INF/lib/cargo-core-uberjar-0.8.jar" />
+ <url>jar://$MODULE_DIR$/../../../../../../tools/lib/cargo-core-uberjar-0.8.jar!/</url>
+ </containerElement>
+ <containerElement type="library" level="module">
+ <attribute name="method" value="1" />
+ <attribute name="URI" value="/WEB-INF/lib/crimson.jar" />
+ <url>jar://$MODULE_DIR$/../../../../../../tools/lib/crimson.jar!/</url>
+ </containerElement>
+ <containerElement type="library" level="module">
+ <attribute name="method" value="1" />
+ <attribute name="URI" value="/WEB-INF/lib/explode.jar" />
+ <url>jar://$MODULE_DIR$/../../../../../../tools/lib/explode.jar!/</url>
+ </containerElement>
+ <containerElement type="library" level="module">
+ <attribute name="method" value="1" />
+ <attribute name="URI" value="/WEB-INF/lib/jboss-test.jar" />
+ <url>jar://$MODULE_DIR$/../../../../../../tools/lib/jboss-test.jar!/</url>
+ </containerElement>
+ <containerElement type="library" level="module">
+ <attribute name="method" value="1" />
+ <attribute name="URI" value="/WEB-INF/lib/jbossbuild.jar" />
+ <url>jar://$MODULE_DIR$/../../../../../../tools/lib/jbossbuild.jar!/</url>
+ </containerElement>
+ <containerElement type="library" level="module">
+ <attribute name="method" value="1" />
+ <attribute name="URI" value="/WEB-INF/lib/junit.jar" />
+ <url>jar://$MODULE_DIR$/../../../../../../tools/lib/junit.jar!/</url>
+ </containerElement>
+ <containerElement type="library" level="module">
+ <attribute name="method" value="1" />
+ <attribute name="URI" value="/WEB-INF/lib/saxon.jar" />
+ <url>jar://$MODULE_DIR$/../../../../../../tools/lib/saxon.jar!/</url>
+ </containerElement>
+ <containerElement type="library" level="module">
+ <attribute name="method" value="1" />
+ <attribute name="URI" value="/WEB-INF/lib/xalan.jar" />
+ <url>jar://$MODULE_DIR$/../../../../../../tools/lib/xalan.jar!/</url>
+ </containerElement>
+ <containerElement type="library" level="module">
+ <attribute name="method" value="1" />
+ <attribute name="URI" value="/WEB-INF/lib/xercesImpl.jar" />
+ <url>jar://$MODULE_DIR$/../../../../../../tools/lib/xercesImpl.jar!/</url>
+ </containerElement>
+ <containerElement type="library" level="module">
+ <attribute name="method" value="1" />
+ <attribute name="URI" value="/WEB-INF/lib/xml-apis.jar" />
+ <url>jar://$MODULE_DIR$/../../../../../../tools/lib/xml-apis.jar!/</url>
+ </containerElement>
+ </packaging>
+ </configuration>
+ </facet>
+ </component>
+ <component name="NewModuleRootManager" inherit-compiler-output="false">
+ <output url="file://$MODULE_DIR$/../../../../../../common/output/idea50/classes" />
+ <exclude-output />
+ <content url="file://$MODULE_DIR$/../../../../../../common">
+ <sourceFolder url="file://$MODULE_DIR$/../../../../../../common/src/main/java" isTestSource="false" />
+ <sourceFolder url="file://$MODULE_DIR$/../../../../../../common/src/main/resources" isTestSource="false" />
+ <sourceFolder url="file://$MODULE_DIR$/../../../../../../common/src/test/java" isTestSource="false" />
+ <sourceFolder url="file://$MODULE_DIR$/../../../../../../common/src/test/resources" isTestSource="false" />
+ <excludeFolder url="file://$MODULE_DIR$/../../../../../../common/output" />
+ <excludeFolder url="file://$MODULE_DIR$/../../../../../../common/target" />
+ </content>
+ <orderEntry type="inheritedJdk" />
+ <orderEntry type="sourceFolder" forTests="false" />
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/../../../../../../tools/lib/junit.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/../../../../../../tools/lib/ant-launcher.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/../../../../../../tools/lib/jboss-test.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/../../../../../../tools/lib/jbossbuild.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/../../../../../../tools/lib/ant.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/../../../../../../tools/lib/explode.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/../../../../../../tools/lib/xml-apis.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/../../../../../../tools/lib/xercesImpl.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/../../../../../../tools/lib/ant-junit.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/../../../../../../tools/lib/xalan.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/../../../../../../tools/lib/cargo-core-uberjar-0.8.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/../../../../../../tools/lib/ant-nodeps.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/../../../../../../tools/lib/buildmagic-tasks.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/../../../../../../tools/lib/bsf.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/../../../../../../tools/lib/saxon.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/../../../../../../tools/lib/crimson.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntryProperties />
+ </component>
+ <component name="VcsManagerConfiguration">
+ <option name="ACTIVE_VCS_NAME" value="svn" />
+ <option name="USE_PROJECT_VCS" value="false" />
+ </component>
+ <component name="copyright">
+ <Base>
+ <setting name="state" value="1" />
+ </Base>
+ <LanguageOptions name="$TEMPLATE$">
+ <option name="templateOptions">
+ <value>
+ <option name="block" value="true" />
+ <option name="separateBefore" value="true" />
+ <option name="separateAfter" value="true" />
+ <option name="prefixLines" value="true" />
+ <option name="lenBefore" value="80" />
+ <option name="lenAfter" value="80" />
+ <option name="box" value="true" />
+ <option name="filler" value=" " />
+ </value>
+ </option>
+ <option name="notice" value="JBoss, a division of Red Hat Copyright &#36;today.year, Red Hat Middleware, LLC, and individual contributors as indicated by the @authors tag. See the copyright.txt in the distribution for a full listing of individual contributors. This is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this software; if not, write to the Free Software Foundation, Inc., 51 Fr!
anklin St, Fifth Floor, Boston, MA 02110-1301 USA, or see the FSF site: http://www.fsf.org." />
+ <option name="keyword" value="Copyright" />
+ <option name="fileTypeOverride" value="4" />
+ <option name="relativeBefore" value="true" />
+ <option name="addBlankAfter" value="true" />
+ <option name="fileLocation" value="1" />
+ <option name="useAlternate" value="false" />
+ </LanguageOptions>
+ <LanguageOptions name="CSS">
+ <option name="templateOptions">
+ <value>
+ <option name="block" value="true" />
+ <option name="separateBefore" value="false" />
+ <option name="separateAfter" value="false" />
+ <option name="prefixLines" value="true" />
+ <option name="lenBefore" value="80" />
+ <option name="lenAfter" value="80" />
+ <option name="box" value="false" />
+ <option name="filler" value=" " />
+ </value>
+ </option>
+ <option name="notice" value="Copyright (c) &#36;today.year, Your Corporation. All Rights Reserved." />
+ <option name="keyword" value="Copyright" />
+ <option name="fileTypeOverride" value="2" />
+ <option name="relativeBefore" value="true" />
+ <option name="addBlankAfter" value="true" />
+ <option name="fileLocation" value="1" />
+ <option name="useAlternate" value="false" />
+ </LanguageOptions>
+ <LanguageOptions name="HTML">
+ <option name="templateOptions">
+ <value>
+ <option name="block" value="true" />
+ <option name="separateBefore" value="false" />
+ <option name="separateAfter" value="false" />
+ <option name="prefixLines" value="true" />
+ <option name="lenBefore" value="80" />
+ <option name="lenAfter" value="80" />
+ <option name="box" value="false" />
+ <option name="filler" value=" " />
+ </value>
+ </option>
+ <option name="notice" value="Copyright (c) &#36;today.year, Your Corporation. All Rights Reserved." />
+ <option name="keyword" value="Copyright" />
+ <option name="fileTypeOverride" value="2" />
+ <option name="relativeBefore" value="true" />
+ <option name="addBlankAfter" value="true" />
+ <option name="fileLocation" value="1" />
+ <option name="useAlternate" value="false" />
+ </LanguageOptions>
+ <LanguageOptions name="JAVA">
+ <option name="templateOptions">
+ <value>
+ <option name="block" value="true" />
+ <option name="separateBefore" value="false" />
+ <option name="separateAfter" value="false" />
+ <option name="prefixLines" value="true" />
+ <option name="lenBefore" value="80" />
+ <option name="lenAfter" value="80" />
+ <option name="box" value="false" />
+ <option name="filler" value=" " />
+ </value>
+ </option>
+ <option name="notice" value="Copyright (c) &#36;today.year, Your Corporation. All Rights Reserved." />
+ <option name="keyword" value="Copyright" />
+ <option name="fileTypeOverride" value="2" />
+ <option name="relativeBefore" value="true" />
+ <option name="addBlankAfter" value="true" />
+ <option name="fileLocation" value="1" />
+ <option name="useAlternate" value="false" />
+ </LanguageOptions>
+ <LanguageOptions name="JSP">
+ <option name="templateOptions">
+ <value>
+ <option name="block" value="true" />
+ <option name="separateBefore" value="false" />
+ <option name="separateAfter" value="false" />
+ <option name="prefixLines" value="true" />
+ <option name="lenBefore" value="80" />
+ <option name="lenAfter" value="80" />
+ <option name="box" value="false" />
+ <option name="filler" value=" " />
+ </value>
+ </option>
+ <option name="notice" value="Copyright (c) &#36;today.year, Your Corporation. All Rights Reserved." />
+ <option name="keyword" value="Copyright" />
+ <option name="fileTypeOverride" value="2" />
+ <option name="relativeBefore" value="true" />
+ <option name="addBlankAfter" value="true" />
+ <option name="fileLocation" value="1" />
+ <option name="useAlternate" value="false" />
+ </LanguageOptions>
+ <LanguageOptions name="JavaScript">
+ <option name="templateOptions">
+ <value>
+ <option name="block" value="true" />
+ <option name="separateBefore" value="false" />
+ <option name="separateAfter" value="false" />
+ <option name="prefixLines" value="true" />
+ <option name="lenBefore" value="80" />
+ <option name="lenAfter" value="80" />
+ <option name="box" value="false" />
+ <option name="filler" value=" " />
+ </value>
+ </option>
+ <option name="notice" value="Copyright (c) &#36;today.year, Your Corporation. All Rights Reserved." />
+ <option name="keyword" value="Copyright" />
+ <option name="fileTypeOverride" value="2" />
+ <option name="relativeBefore" value="true" />
+ <option name="addBlankAfter" value="true" />
+ <option name="fileLocation" value="1" />
+ <option name="useAlternate" value="false" />
+ </LanguageOptions>
+ <LanguageOptions name="Properties">
+ <option name="templateOptions">
+ <value>
+ <option name="block" value="true" />
+ <option name="separateBefore" value="false" />
+ <option name="separateAfter" value="false" />
+ <option name="prefixLines" value="true" />
+ <option name="lenBefore" value="80" />
+ <option name="lenAfter" value="80" />
+ <option name="box" value="false" />
+ <option name="filler" value=" " />
+ </value>
+ </option>
+ <option name="notice" value="Copyright (c) &#36;today.year, Your Corporation. All Rights Reserved." />
+ <option name="keyword" value="Copyright" />
+ <option name="fileTypeOverride" value="2" />
+ <option name="relativeBefore" value="true" />
+ <option name="addBlankAfter" value="true" />
+ <option name="fileLocation" value="1" />
+ <option name="useAlternate" value="false" />
+ </LanguageOptions>
+ <LanguageOptions name="XML">
+ <option name="templateOptions">
+ <value>
+ <option name="block" value="true" />
+ <option name="separateBefore" value="false" />
+ <option name="separateAfter" value="false" />
+ <option name="prefixLines" value="true" />
+ <option name="lenBefore" value="80" />
+ <option name="lenAfter" value="80" />
+ <option name="box" value="false" />
+ <option name="filler" value=" " />
+ </value>
+ </option>
+ <option name="notice" value="Copyright (c) &#36;today.year, Your Corporation. All Rights Reserved." />
+ <option name="keyword" value="Copyright" />
+ <option name="fileTypeOverride" value="2" />
+ <option name="relativeBefore" value="true" />
+ <option name="addBlankAfter" value="true" />
+ <option name="fileLocation" value="1" />
+ <option name="useAlternate" value="false" />
+ </LanguageOptions>
+ </component>
+</module>
+
18 years, 7 months
JBoss Portal SVN: r8254 - trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jsf.
by portal-commits@lists.jboss.org
Author: chris.laprun(a)jboss.com
Date: 2007-09-12 17:38:19 -0400 (Wed, 12 Sep 2007)
New Revision: 8254
Modified:
trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/editContext.xhtml
trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/editPage.xhtml
trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/objectNavigation.xhtml
Log:
- JBPORTAL-1690: added action* styles that were missed the first time around.
Modified: trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/editContext.xhtml
===================================================================
--- trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/editContext.xhtml 2007-09-12 21:34:19 UTC (rev 8253)
+++ trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/editContext.xhtml 2007-09-12 21:38:19 UTC (rev 8254)
@@ -17,9 +17,10 @@
</c:choose>
</h3>
<h:form>
- <h:commandLink action="editProperties" actionListener="#{portalobjectmgr.selectObject}">
- <h:outputText value="Properties"/>
+ <h:commandLink action="editProperties" actionListener="#{portalobjectmgr.selectObject}"
+ styleClass="actionProperties">
<f:param name="id" value="#{portalobjectmgr.selectedObject.id}"/>
+ Properties
</h:commandLink>
</h:form>
Modified: trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/editPage.xhtml
===================================================================
--- trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/editPage.xhtml 2007-09-12 21:34:19 UTC (rev 8253)
+++ trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/editPage.xhtml 2007-09-12 21:38:19 UTC (rev 8254)
@@ -16,25 +16,27 @@
action="editPageLayout" actionListener="#{portalobjectmgr.selectObject}">
<h:outputText value="Page layout"/>
<f:param name="id" value="#{portalobjectmgr.selectedObject.id}"/>
- </h:commandLink> | </h:panelGroup><h:commandLink action="editPageSecurity"
+ </h:commandLink> | </h:panelGroup><h:commandLink action="editPageSecurity" styleClass="actionSecurity"
actionListener="#{portalobjectmgr.selectObject}">
- <h:outputText value="Security"/>
<f:param name="id" value="#{portalobjectmgr.selectedObject.id}"/>
- </h:commandLink> | <h:commandLink action="editProperties" actionListener="#{portalobjectmgr.selectObject}">
- <h:outputText value="Properties"/>
+ Security
+ </h:commandLink> | <h:commandLink action="editProperties" styleClass="actionProperties"
+ actionListener="#{portalobjectmgr.selectObject}">
<f:param name="id" value="#{portalobjectmgr.selectedObject.id}"/>
- </h:commandLink> | <h:commandLink action="editPageTheme" actionListener="#{portalobjectmgr.selectObject}">
- <h:outputText value="Theme"/>
+ Properties
+ </h:commandLink> | <h:commandLink action="editPageTheme" styleClass="actionTheme"
+ actionListener="#{portalobjectmgr.selectObject}">
<f:param name="id" value="#{portalobjectmgr.selectedObject.id}"/>
+ Theme
</h:commandLink> | <h:panelGroup
rendered="#{!((portalobjectmgr.selectedObject.type == PortalObject.TYPE_PORTAL) and ((portalobjectmgr.selectedObject.name == 'admin') or (portalobjectmgr.selectedObject.name == 'template') or (portalobjectmgr.selectedObject.name == 'default')))}"><h:commandLink
- action="renameObject" actionListener="#{portalobjectmgr.selectObject}">
- <h:outputText value="Rename"/>
+ action="renameObject" actionListener="#{portalobjectmgr.selectObject}" styleClass="actionRename">
<f:param name="id" value="#{portalobjectmgr.selectedObject.id}"/>
- </h:commandLink> | </h:panelGroup><h:commandLink action="confirm"
+ Rename
+ </h:commandLink> | </h:panelGroup><h:commandLink action="confirm" styleClass="actionDelete"
actionListener="#{portalobjectmgr.selectObject}">
- <h:outputText value="Delete"/>
<f:param name="id" value="#{portalobjectmgr.selectedObject.id}"/>
+ Delete
</h:commandLink>
</h:form>
Modified: trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/objectNavigation.xhtml
===================================================================
--- trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/objectNavigation.xhtml 2007-09-12 21:34:19 UTC (rev 8253)
+++ trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/objectNavigation.xhtml 2007-09-12 21:38:19 UTC (rev 8254)
@@ -23,15 +23,18 @@
<f:facet name="header">
<h:outputText value="Actions"/>
</f:facet>
- <h:commandLink action="editPortalSecurity" actionListener="#{portalobjectmgr.selectObject}">
- <h:outputText value="Security"/>
+ <h:commandLink action="editPortalSecurity" actionListener="#{portalobjectmgr.selectObject}"
+ styleClass="actionSecurity">
<f:param name="id" value="#{object.id}"/>
- </h:commandLink> | <h:commandLink action="editProperties" actionListener="#{portalobjectmgr.selectObject}">
- <h:outputText value="Properties"/>
+ Security
+ </h:commandLink> | <h:commandLink action="editProperties" styleClass="actionProperties"
+ actionListener="#{portalobjectmgr.selectObject}">
<f:param name="id" value="#{object.id}"/>
- </h:commandLink> | <h:commandLink action="editPortalTheme" actionListener="#{portalobjectmgr.selectObject}">
- <h:outputText value="Theme"/>
+ Properties
+ </h:commandLink> | <h:commandLink action="editPortalTheme" styleClass="actionTheme"
+ actionListener="#{portalobjectmgr.selectObject}">
<f:param name="id" value="#{object.id}"/>
+ Theme
</h:commandLink>
<h:panelGroup
rendered="#{(object.name != 'admin') and (object.name != 'template') and (object.name != 'default')}">
@@ -39,16 +42,19 @@
<h:outputText value="Rename"/>
<f:param name="id" value="#{object.id}"/>
</h:commandLink>
- </h:panelGroup> | <h:commandLink action="confirm" actionListener="#{portalobjectmgr.selectObject}">
- <h:outputText value="Delete"/>
+ </h:panelGroup> | <h:commandLink action="confirm" styleClass="actionDelete"
+ actionListener="#{portalobjectmgr.selectObject}">
<f:param name="id" value="#{object.id}"/>
+ Delete
</h:commandLink>
- <h:panelGroup rendered="#{not object.default}"> | <h:commandLink action="#{portalobjectmgr.makeObjectDefault}">
- <h:outputText value="Make Default"/>
+ <h:panelGroup rendered="#{not object.default}"> | <h:commandLink styleClass="actionMakeDefault"
+ action="#{portalobjectmgr.makeObjectDefault}">
<f:param name="id" value="#{object.id}"/>
+ Make Default
</h:commandLink>
</h:panelGroup>
- <h:panelGroup rendered="#{object.default}"> | <h:outputText value="Default"/></h:panelGroup>
+ <h:panelGroup rendered="#{object.default}"> | <h:outputText styleClass="actionDefault"
+ value="Default"/></h:panelGroup>
</h:column>
</h:dataTable>
</c:if>
@@ -68,32 +74,39 @@
<f:facet name="header">
<h:outputText value="Actions"/>
</f:facet>
- <h:commandLink action="editPageLayout" actionListener="#{portalobjectmgr.selectObject}">
- <h:outputText value="Page layout"/>
+ <h:commandLink action="editPageLayout" actionListener="#{portalobjectmgr.selectObject}"
+ styleClass="actionLayout">
<f:param name="id" value="#{object.id}"/>
- </h:commandLink> | <h:commandLink action="editPageSecurity"
+ Page layout
+ </h:commandLink> | <h:commandLink action="editPageSecurity" styleClass="actionSecurity"
actionListener="#{portalobjectmgr.selectObject}">
- <h:outputText value="Security"/>
<f:param name="id" value="#{object.id}"/>
- </h:commandLink> | <h:commandLink action="editProperties" actionListener="#{portalobjectmgr.selectObject}">
- <h:outputText value="Properties"/>
+ Security
+ </h:commandLink> | <h:commandLink action="editProperties" styleClass="actionProperties"
+ actionListener="#{portalobjectmgr.selectObject}">
<f:param name="id" value="#{object.id}"/>
- </h:commandLink> | <h:commandLink action="editPageTheme" actionListener="#{portalobjectmgr.selectObject}">
- <h:outputText value="Theme"/>
+ Properties
+ </h:commandLink> | <h:commandLink action="editPageTheme" styleClass="actionTheme"
+ actionListener="#{portalobjectmgr.selectObject}">
<f:param name="id" value="#{object.id}"/>
- </h:commandLink> | <h:commandLink action="renameObject" actionListener="#{portalobjectmgr.selectObject}">
- <h:outputText value="Rename"/>
+ Theme
+ </h:commandLink> | <h:commandLink action="renameObject" styleClass="actionRename"
+ actionListener="#{portalobjectmgr.selectObject}">
<f:param name="id" value="#{object.id}"/>
- </h:commandLink> | <h:commandLink action="confirm" actionListener="#{portalobjectmgr.selectObject}">
- <h:outputText value="Delete"/>
+ Rename
+ </h:commandLink> | <h:commandLink action="confirm" styleClass="actionDelete"
+ actionListener="#{portalobjectmgr.selectObject}">
<f:param name="id" value="#{object.id}"/>
+ Delete
</h:commandLink>
- <h:panelGroup rendered="#{not object.default}"> | <h:commandLink action="#{portalobjectmgr.makeObjectDefault}">
- <h:outputText value="Make Default"/>
+ <h:panelGroup rendered="#{not object.default}"> | <h:commandLink styleClass="actionMakeDefault"
+ action="#{portalobjectmgr.makeObjectDefault}">
<f:param name="id" value="#{object.id}"/>
+ Make Default
</h:commandLink>
</h:panelGroup>
- <h:panelGroup rendered="#{object.default}"> | <h:outputText value="Default"/></h:panelGroup>
+ <h:panelGroup rendered="#{object.default}"> | <h:outputText styleClass="actionDefault"
+ value="Default"/></h:panelGroup>
</h:column>
</h:dataTable>
</c:if>
@@ -115,19 +128,22 @@
<f:facet name="header">
<h:outputText value="Actions"/>
</f:facet>
- <h:commandLink action="editWindowTheme" actionListener="#{portalobjectmgr.selectObject}">
- <h:outputText value="Theme"/>
+ <h:commandLink action="editWindowTheme" actionListener="#{portalobjectmgr.selectObject}"
+ styleClass="actionTheme">
<f:param name="id" value="#{object.id}"/>
- </h:commandLink> | <h:commandLink action="editProperties"
+ Theme
+ </h:commandLink> | <h:commandLink action="editProperties" styleClass="actionProperties"
actionListener="#{portalobjectmgr.selectObject}">
- <h:outputText value="Properties"/>
<f:param name="id" value="#{object.id}"/>
- </h:commandLink> | <h:commandLink action="renameObject" actionListener="#{portalobjectmgr.selectObject}">
- <h:outputText value="Rename"/>
+ Properties
+ </h:commandLink> | <h:commandLink action="renameObject" styleClass="actionRename"
+ actionListener="#{portalobjectmgr.selectObject}">
<f:param name="id" value="#{object.id}"/>
- </h:commandLink> | <h:commandLink action="confirm" actionListener="#{portalobjectmgr.selectObject}">
- <h:outputText value="Delete"/>
+ Rename
+ </h:commandLink> | <h:commandLink action="confirm" actionListener="#{portalobjectmgr.selectObject}"
+ styleClass="actionDelete">
<f:param name="id" value="#{object.id}"/>
+ Delete
</h:commandLink>
</h:column>
</h:dataTable>
18 years, 7 months
JBoss Portal SVN: r8253 - branches/JBoss_Portal_Branch_2_6/core-admin/src/resources/portal-admin-war/WEB-INF/jsf.
by portal-commits@lists.jboss.org
Author: chris.laprun(a)jboss.com
Date: 2007-09-12 17:34:19 -0400 (Wed, 12 Sep 2007)
New Revision: 8253
Modified:
branches/JBoss_Portal_Branch_2_6/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/editContext.xhtml
branches/JBoss_Portal_Branch_2_6/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/editPage.xhtml
branches/JBoss_Portal_Branch_2_6/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/objectNavigation.xhtml
Log:
- JBPORTAL-1690: added action* styles that were missed the first time around.
Modified: branches/JBoss_Portal_Branch_2_6/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/editContext.xhtml
===================================================================
--- branches/JBoss_Portal_Branch_2_6/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/editContext.xhtml 2007-09-12 19:55:20 UTC (rev 8252)
+++ branches/JBoss_Portal_Branch_2_6/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/editContext.xhtml 2007-09-12 21:34:19 UTC (rev 8253)
@@ -17,9 +17,10 @@
</c:choose>
</h3>
<h:form>
- <h:commandLink action="editProperties" actionListener="#{portalobjectmgr.selectObject}">
- <h:outputText value="Properties"/>
+ <h:commandLink action="editProperties" actionListener="#{portalobjectmgr.selectObject}"
+ styleClass="actionProperties">
<f:param name="id" value="#{portalobjectmgr.selectedObject.id}"/>
+ Properties
</h:commandLink>
</h:form>
Modified: branches/JBoss_Portal_Branch_2_6/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/editPage.xhtml
===================================================================
--- branches/JBoss_Portal_Branch_2_6/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/editPage.xhtml 2007-09-12 19:55:20 UTC (rev 8252)
+++ branches/JBoss_Portal_Branch_2_6/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/editPage.xhtml 2007-09-12 21:34:19 UTC (rev 8253)
@@ -16,25 +16,27 @@
action="editPageLayout" actionListener="#{portalobjectmgr.selectObject}">
<h:outputText value="Page layout"/>
<f:param name="id" value="#{portalobjectmgr.selectedObject.id}"/>
- </h:commandLink> | </h:panelGroup><h:commandLink action="editPageSecurity"
+ </h:commandLink> | </h:panelGroup><h:commandLink action="editPageSecurity" styleClass="actionSecurity"
actionListener="#{portalobjectmgr.selectObject}">
- <h:outputText value="Security"/>
<f:param name="id" value="#{portalobjectmgr.selectedObject.id}"/>
- </h:commandLink> | <h:commandLink action="editProperties" actionListener="#{portalobjectmgr.selectObject}">
- <h:outputText value="Properties"/>
+ Security
+ </h:commandLink> | <h:commandLink action="editProperties" styleClass="actionProperties"
+ actionListener="#{portalobjectmgr.selectObject}">
<f:param name="id" value="#{portalobjectmgr.selectedObject.id}"/>
- </h:commandLink> | <h:commandLink action="editPageTheme" actionListener="#{portalobjectmgr.selectObject}">
- <h:outputText value="Theme"/>
+ Properties
+ </h:commandLink> | <h:commandLink action="editPageTheme" styleClass="actionTheme"
+ actionListener="#{portalobjectmgr.selectObject}">
<f:param name="id" value="#{portalobjectmgr.selectedObject.id}"/>
+ Theme
</h:commandLink> | <h:panelGroup
rendered="#{!((portalobjectmgr.selectedObject.type == PortalObject.TYPE_PORTAL) and ((portalobjectmgr.selectedObject.name == 'admin') or (portalobjectmgr.selectedObject.name == 'template') or (portalobjectmgr.selectedObject.name == 'default')))}"><h:commandLink
- action="renameObject" actionListener="#{portalobjectmgr.selectObject}">
- <h:outputText value="Rename"/>
+ action="renameObject" actionListener="#{portalobjectmgr.selectObject}" styleClass="actionRename">
<f:param name="id" value="#{portalobjectmgr.selectedObject.id}"/>
- </h:commandLink> | </h:panelGroup><h:commandLink action="confirm"
+ Rename
+ </h:commandLink> | </h:panelGroup><h:commandLink action="confirm" styleClass="actionDelete"
actionListener="#{portalobjectmgr.selectObject}">
- <h:outputText value="Delete"/>
<f:param name="id" value="#{portalobjectmgr.selectedObject.id}"/>
+ Delete
</h:commandLink>
</h:form>
Modified: branches/JBoss_Portal_Branch_2_6/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/objectNavigation.xhtml
===================================================================
--- branches/JBoss_Portal_Branch_2_6/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/objectNavigation.xhtml 2007-09-12 19:55:20 UTC (rev 8252)
+++ branches/JBoss_Portal_Branch_2_6/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/objectNavigation.xhtml 2007-09-12 21:34:19 UTC (rev 8253)
@@ -23,15 +23,18 @@
<f:facet name="header">
<h:outputText value="Actions"/>
</f:facet>
- <h:commandLink action="editPortalSecurity" actionListener="#{portalobjectmgr.selectObject}">
- <h:outputText value="Security"/>
+ <h:commandLink action="editPortalSecurity" actionListener="#{portalobjectmgr.selectObject}"
+ styleClass="actionSecurity">
<f:param name="id" value="#{object.id}"/>
- </h:commandLink> | <h:commandLink action="editProperties" actionListener="#{portalobjectmgr.selectObject}">
- <h:outputText value="Properties"/>
+ Security
+ </h:commandLink> | <h:commandLink action="editProperties" styleClass="actionProperties"
+ actionListener="#{portalobjectmgr.selectObject}">
<f:param name="id" value="#{object.id}"/>
- </h:commandLink> | <h:commandLink action="editPortalTheme" actionListener="#{portalobjectmgr.selectObject}">
- <h:outputText value="Theme"/>
+ Properties
+ </h:commandLink> | <h:commandLink action="editPortalTheme" styleClass="actionTheme"
+ actionListener="#{portalobjectmgr.selectObject}">
<f:param name="id" value="#{object.id}"/>
+ Theme
</h:commandLink>
<h:panelGroup
rendered="#{(object.name != 'admin') and (object.name != 'template') and (object.name != 'default')}">
@@ -39,16 +42,19 @@
<h:outputText value="Rename"/>
<f:param name="id" value="#{object.id}"/>
</h:commandLink>
- </h:panelGroup> | <h:commandLink action="confirm" actionListener="#{portalobjectmgr.selectObject}">
- <h:outputText value="Delete"/>
+ </h:panelGroup> | <h:commandLink action="confirm" styleClass="actionDelete"
+ actionListener="#{portalobjectmgr.selectObject}">
<f:param name="id" value="#{object.id}"/>
+ Delete
</h:commandLink>
- <h:panelGroup rendered="#{not object.default}"> | <h:commandLink action="#{portalobjectmgr.makeObjectDefault}">
- <h:outputText value="Make Default"/>
+ <h:panelGroup rendered="#{not object.default}"> | <h:commandLink styleClass="actionMakeDefault"
+ action="#{portalobjectmgr.makeObjectDefault}">
<f:param name="id" value="#{object.id}"/>
+ Make Default
</h:commandLink>
</h:panelGroup>
- <h:panelGroup rendered="#{object.default}"> | <h:outputText value="Default"/></h:panelGroup>
+ <h:panelGroup rendered="#{object.default}"> | <h:outputText styleClass="actionDefault"
+ value="Default"/></h:panelGroup>
</h:column>
</h:dataTable>
</c:if>
@@ -68,32 +74,39 @@
<f:facet name="header">
<h:outputText value="Actions"/>
</f:facet>
- <h:commandLink action="editPageLayout" actionListener="#{portalobjectmgr.selectObject}">
- <h:outputText value="Page layout"/>
+ <h:commandLink action="editPageLayout" actionListener="#{portalobjectmgr.selectObject}"
+ styleClass="actionLayout">
<f:param name="id" value="#{object.id}"/>
- </h:commandLink> | <h:commandLink action="editPageSecurity"
+ Page layout
+ </h:commandLink> | <h:commandLink action="editPageSecurity" styleClass="actionSecurity"
actionListener="#{portalobjectmgr.selectObject}">
- <h:outputText value="Security"/>
<f:param name="id" value="#{object.id}"/>
- </h:commandLink> | <h:commandLink action="editProperties" actionListener="#{portalobjectmgr.selectObject}">
- <h:outputText value="Properties"/>
+ Security
+ </h:commandLink> | <h:commandLink action="editProperties" styleClass="actionProperties"
+ actionListener="#{portalobjectmgr.selectObject}">
<f:param name="id" value="#{object.id}"/>
- </h:commandLink> | <h:commandLink action="editPageTheme" actionListener="#{portalobjectmgr.selectObject}">
- <h:outputText value="Theme"/>
+ Properties
+ </h:commandLink> | <h:commandLink action="editPageTheme" styleClass="actionTheme"
+ actionListener="#{portalobjectmgr.selectObject}">
<f:param name="id" value="#{object.id}"/>
- </h:commandLink> | <h:commandLink action="renameObject" actionListener="#{portalobjectmgr.selectObject}">
- <h:outputText value="Rename"/>
+ Theme
+ </h:commandLink> | <h:commandLink action="renameObject" styleClass="actionRename"
+ actionListener="#{portalobjectmgr.selectObject}">
<f:param name="id" value="#{object.id}"/>
- </h:commandLink> | <h:commandLink action="confirm" actionListener="#{portalobjectmgr.selectObject}">
- <h:outputText value="Delete"/>
+ Rename
+ </h:commandLink> | <h:commandLink action="confirm" styleClass="actionDelete"
+ actionListener="#{portalobjectmgr.selectObject}">
<f:param name="id" value="#{object.id}"/>
+ Delete
</h:commandLink>
- <h:panelGroup rendered="#{not object.default}"> | <h:commandLink action="#{portalobjectmgr.makeObjectDefault}">
- <h:outputText value="Make Default"/>
+ <h:panelGroup rendered="#{not object.default}"> | <h:commandLink styleClass="actionMakeDefault"
+ action="#{portalobjectmgr.makeObjectDefault}">
<f:param name="id" value="#{object.id}"/>
+ Make Default
</h:commandLink>
</h:panelGroup>
- <h:panelGroup rendered="#{object.default}"> | <h:outputText value="Default"/></h:panelGroup>
+ <h:panelGroup rendered="#{object.default}"> | <h:outputText styleClass="actionDefault"
+ value="Default"/></h:panelGroup>
</h:column>
</h:dataTable>
</c:if>
@@ -115,19 +128,22 @@
<f:facet name="header">
<h:outputText value="Actions"/>
</f:facet>
- <h:commandLink action="editWindowTheme" actionListener="#{portalobjectmgr.selectObject}">
- <h:outputText value="Theme"/>
+ <h:commandLink action="editWindowTheme" actionListener="#{portalobjectmgr.selectObject}"
+ styleClass="actionTheme">
<f:param name="id" value="#{object.id}"/>
- </h:commandLink> | <h:commandLink action="editProperties"
+ Theme
+ </h:commandLink> | <h:commandLink action="editProperties" styleClass="actionProperties"
actionListener="#{portalobjectmgr.selectObject}">
- <h:outputText value="Properties"/>
<f:param name="id" value="#{object.id}"/>
- </h:commandLink> | <h:commandLink action="renameObject" actionListener="#{portalobjectmgr.selectObject}">
- <h:outputText value="Rename"/>
+ Properties
+ </h:commandLink> | <h:commandLink action="renameObject" styleClass="actionRename"
+ actionListener="#{portalobjectmgr.selectObject}">
<f:param name="id" value="#{object.id}"/>
- </h:commandLink> | <h:commandLink action="confirm" actionListener="#{portalobjectmgr.selectObject}">
- <h:outputText value="Delete"/>
+ Rename
+ </h:commandLink> | <h:commandLink action="confirm" actionListener="#{portalobjectmgr.selectObject}"
+ styleClass="actionDelete">
<f:param name="id" value="#{object.id}"/>
+ Delete
</h:commandLink>
</h:column>
</h:dataTable>
18 years, 7 months
JBoss Portal SVN: r8252 - modules/common/trunk/common.
by portal-commits@lists.jboss.org
Author: wesleyhales
Date: 2007-09-12 15:55:20 -0400 (Wed, 12 Sep 2007)
New Revision: 8252
Modified:
modules/common/trunk/common/pom.xml
Log:
dependency changes
Modified: modules/common/trunk/common/pom.xml
===================================================================
--- modules/common/trunk/common/pom.xml 2007-09-12 19:49:12 UTC (rev 8251)
+++ modules/common/trunk/common/pom.xml 2007-09-12 19:55:20 UTC (rev 8252)
@@ -86,6 +86,12 @@
</dependency>
<dependency>
+ <groupId>ant</groupId>
+ <artifactId>ant-junit</artifactId>
+ <version>1.6.5</version>
+ </dependency>
+
+ <dependency>
<groupId>cargo</groupId>
<artifactId>cargo-core-uberjar</artifactId>
<version>0.8</version>
@@ -103,14 +109,6 @@
<dependency>
<groupId>ant</groupId>
- <artifactId>ant-junit</artifactId>
- <version>0.1</version>
- <scope>system</scope>
- <systemPath>${basedir}/../tools/lib/ant-junit.jar</systemPath>
- </dependency>
-
- <dependency>
- <groupId>ant</groupId>
<artifactId>ant-nodeps</artifactId>
<version>0.1</version>
<scope>system</scope>
18 years, 7 months
JBoss Portal SVN: r8251 - /.
by portal-commits@lists.jboss.org
Author: wesleyhales
Date: 2007-09-12 15:49:12 -0400 (Wed, 12 Sep 2007)
New Revision: 8251
Modified:
pom.xml
Log:
repository location
Modified: pom.xml
===================================================================
--- pom.xml 2007-09-12 19:01:56 UTC (rev 8250)
+++ pom.xml 2007-09-12 19:49:12 UTC (rev 8251)
@@ -11,13 +11,10 @@
<dependencies/>
<repositories>
- <repository>
- <id>my repository</id>
- <url>http://localhost:8081/artifactory/repo</url>
- <snapshots>
- <enabled>true</enabled>
- </snapshots>
- </repository>
+ <repository>
+ <id>repository.jboss.org</id>
+ <url>http://repository.jboss.com/maven2/</url>
+ </repository>
</repositories>
<build>
18 years, 7 months
JBoss Portal SVN: r8250 - in modules/common/trunk/common/src: resources and 8 other directories.
by portal-commits@lists.jboss.org
Author: wesleyhales
Date: 2007-09-12 15:01:56 -0400 (Wed, 12 Sep 2007)
New Revision: 8250
Added:
modules/common/trunk/common/src/resources/
modules/common/trunk/common/src/resources/format/
modules/common/trunk/common/src/resources/format/code/
modules/common/trunk/common/src/resources/test/
modules/common/trunk/common/src/resources/test/bundle/
modules/common/trunk/common/src/resources/test/implode/
modules/common/trunk/common/src/resources/test/implode/foo.sar/
modules/common/trunk/common/src/resources/test/implode/foo.sar/META-INF/
modules/common/trunk/common/src/resources/test/implode/foo.sar/bar.war/
modules/common/trunk/common/src/resources/test/implode/foo.sar/bar.war/WEB-INF/
modules/common/trunk/common/src/resources/test/implode/foo.sar/bar/
modules/common/trunk/common/src/resources/test/test-jar/
modules/common/trunk/common/src/resources/test/test-jar/a1/
modules/common/trunk/common/src/resources/test/test-jar/a1/b1-/
modules/common/trunk/common/src/resources/test/test-jar/a1/b1/
modules/common/trunk/common/src/resources/test/test-jar/a1/b1/c1/
Log:
needed for ant build
18 years, 7 months
JBoss Portal SVN: r8247 - modules/common/trunk/tools/lib.
by portal-commits@lists.jboss.org
Author: wesleyhales
Date: 2007-09-12 14:29:40 -0400 (Wed, 12 Sep 2007)
New Revision: 8247
Modified:
modules/common/trunk/tools/lib/junit.jar
Log:
update junit jar
Modified: modules/common/trunk/tools/lib/junit.jar
===================================================================
(Binary files differ)
18 years, 7 months
JBoss Portal SVN: r8246 - in modules/common/trunk/common: src and 22 other directories.
by portal-commits@lists.jboss.org
Author: wesleyhales
Date: 2007-09-12 14:29:07 -0400 (Wed, 12 Sep 2007)
New Revision: 8246
Added:
modules/common/trunk/common/pom.xml
modules/common/trunk/common/src/main/resources/
modules/common/trunk/common/src/main/resources/format/
modules/common/trunk/common/src/main/resources/format/code/
modules/common/trunk/common/src/test/
modules/common/trunk/common/src/test/filters/
modules/common/trunk/common/src/test/java/
modules/common/trunk/common/src/test/java/org/
modules/common/trunk/common/src/test/java/org/jboss/
modules/common/trunk/common/src/test/java/org/jboss/portal/
modules/common/trunk/common/src/test/java/org/jboss/portal/test/
modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/
modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/AbstractInvocationContextTestCase.java
modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/BufferedStreamTestCase.java
modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/BundleNameIteratorTestCase.java
modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/BundleNameParserTestCase.java
modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/ComplexResourceBundleFactoryTestCase.java
modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/CopyOnWriteRegistryTestCase.java
modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/DescriptionTestCase.java
modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/HexTestCase.java
modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/ImplodeTestCase.java
modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/IteratorStatusTestCase.java
modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/JarTestCase.java
modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/JavaBeanModelMBeanBuilderTestCase.java
modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/LocaleFormatTestCase.java
modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/LocalizedStringTestCase.java
modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/MarkupTestCase.java
modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/ParameterMapTestCase.java
modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/ParentChildResourceBundleTestCase.java
modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/PathMapperTestCase.java
modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/PathTestCase.java
modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/StringTestCase.java
modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/TemporaryHashTestCase.java
modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/ToolsTestCase.java
modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/TypedMapTestCase.java
modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/ValueTestCase.java
modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/ValveTestCase.java
modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/adapter/
modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/adapter/Adapted1.java
modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/adapter/Adapted2.java
modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/adapter/AdapterTestCase.java
modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/adapter/Business1.java
modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/adapter/Business2.java
modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/adapter/ObjectAdapted.java
modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/http/
modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/http/QueryStringParserTestCase.java
modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/io/
modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/io/IOToolsTestCase.java
modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/io/WriterCharWriterTestCase.java
modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/net/
modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/net/URLNavigatorTestCase.java
modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/net/URLToolsTestCase.java
modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/reflect/
modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/reflect/Class1.java
modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/reflect/Class2.java
modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/reflect/Class3.java
modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/reflect/ModifierTestCase.java
modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/reflect/ReflectionTestCase.java
modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/text/
modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/text/CharBufferTestCase.java
modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/text/CharToByteEncoderTestCase.java
modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/text/FastURLDecoderTestCase.java
modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/text/FastURLEncoderTestCase.java
modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/text/TextToolsTestCase.java
modules/common/trunk/common/src/test/resources/
modules/common/trunk/common/src/test/resources/bundle/
modules/common/trunk/common/src/test/resources/bundle/a_de_DE.properties
modules/common/trunk/common/src/test/resources/bundle/a_fr.properties
modules/common/trunk/common/src/test/resources/bundle/a_fr_FR.properties
modules/common/trunk/common/src/test/resources/bundle/a_it.properties
modules/common/trunk/common/src/test/resources/bundle/b.properties
modules/common/trunk/common/src/test/resources/bundle/c_fr.properties
modules/common/trunk/common/src/test/resources/bundle/d_fr_FR.properties
modules/common/trunk/common/src/test/resources/bundle/e.properties
modules/common/trunk/common/src/test/resources/bundle/e_fr.properties
modules/common/trunk/common/src/test/resources/bundle/f.properties
modules/common/trunk/common/src/test/resources/bundle/f_fr_FR.properties
modules/common/trunk/common/src/test/resources/bundle/g_fr.properties
modules/common/trunk/common/src/test/resources/bundle/g_fr_FR.properties
modules/common/trunk/common/src/test/resources/bundle/h.properties
modules/common/trunk/common/src/test/resources/bundle/h_fr.properties
modules/common/trunk/common/src/test/resources/bundle/h_fr_FR.properties
modules/common/trunk/common/src/test/resources/implode/
modules/common/trunk/common/src/test/resources/implode/foo.sar/
modules/common/trunk/common/src/test/resources/test-jar/
modules/common/trunk/common/src/test/resources/test-jar/a1/
modules/common/trunk/common/src/test/resources/test-jar/a3.txt
modules/common/trunk/common/src/test/resources/test01.code
Removed:
modules/common/trunk/common/src/main/resources/format/code/
modules/common/trunk/common/src/resources/format/
modules/common/trunk/common/src/resources/test/bundle/
modules/common/trunk/common/src/resources/test/implode/
modules/common/trunk/common/src/resources/test/test-jar/
modules/common/trunk/common/src/resources/test/test01.code
modules/common/trunk/common/src/test/resources/bundle/a_de_DE.properties
modules/common/trunk/common/src/test/resources/bundle/a_fr.properties
modules/common/trunk/common/src/test/resources/bundle/a_fr_FR.properties
modules/common/trunk/common/src/test/resources/bundle/a_it.properties
modules/common/trunk/common/src/test/resources/bundle/b.properties
modules/common/trunk/common/src/test/resources/bundle/c_fr.properties
modules/common/trunk/common/src/test/resources/bundle/d_fr_FR.properties
modules/common/trunk/common/src/test/resources/bundle/e.properties
modules/common/trunk/common/src/test/resources/bundle/e_fr.properties
modules/common/trunk/common/src/test/resources/bundle/f.properties
modules/common/trunk/common/src/test/resources/bundle/f_fr_FR.properties
modules/common/trunk/common/src/test/resources/bundle/g_fr.properties
modules/common/trunk/common/src/test/resources/bundle/g_fr_FR.properties
modules/common/trunk/common/src/test/resources/bundle/h.properties
modules/common/trunk/common/src/test/resources/bundle/h_fr.properties
modules/common/trunk/common/src/test/resources/bundle/h_fr_FR.properties
modules/common/trunk/common/src/test/resources/implode/foo.sar/
modules/common/trunk/common/src/test/resources/test-jar/a1/
modules/common/trunk/common/src/test/resources/test-jar/a3.txt
Log:
- Migrate common to maven and let ant build coexist
- Moved unit tests to maven test dir
- moved portal code under src/main
- setup initial pom
Added: modules/common/trunk/common/pom.xml
===================================================================
--- modules/common/trunk/common/pom.xml (rev 0)
+++ modules/common/trunk/common/pom.xml 2007-09-12 18:29:07 UTC (rev 8246)
@@ -0,0 +1,192 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <parent>
+ <artifactId>modules</artifactId>
+ <groupId>org.jboss.portal</groupId>
+ <version>1.0-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.jboss.portal</groupId>
+ <artifactId>common</artifactId>
+ <packaging>jar</packaging>
+ <name>Jboss Portal Common</name>
+ <version>1.0-SNAPSHOT</version>
+
+ <dependencies>
+ <dependency>
+ <groupId>apache-log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <version>1.2.14</version>
+ </dependency>
+
+ <dependency>
+ <groupId>oswego-concurrent</groupId>
+ <artifactId>concurrent</artifactId>
+ <version>1.3.4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.activation</groupId>
+ <artifactId>activation</artifactId>
+ <version>1.1</version>
+ </dependency>
+
+ <!--<dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.1</version>
+ </dependency>-->
+
+ <dependency>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-j2ee</artifactId>
+ <version>4.2.0.GA</version>
+ </dependency>
+
+ <dependency>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-common-core</artifactId>
+ <version>2.2.0.GA</version>
+ </dependency>
+
+ <dependency>
+ <groupId>ant</groupId>
+ <artifactId>ant</artifactId>
+ <version>1.6.5</version>
+ </dependency>
+
+ <dependency>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-jmx</artifactId>
+ <version>4.2.0.GA</version>
+ </dependency>
+
+ <dependency>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-system</artifactId>
+ <version>4.2.0.GA</version>
+ </dependency>
+
+ <dependency>
+ <groupId>apache-httpclient</groupId>
+ <artifactId>commons-httpclient</artifactId>
+ <version>2.0.2</version>
+ </dependency>
+
+ <dependency>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-backport-concurrent</artifactId>
+ <version>2.1.0.GA</version>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>2.4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>cargo</groupId>
+ <artifactId>cargo-core-uberjar</artifactId>
+ <version>0.8</version>
+ <scope>system</scope>
+ <systemPath>${basedir}/../tools/lib/cargo-core-uberjar-0.8.jar</systemPath>
+ </dependency>
+
+ <dependency>
+ <groupId>ant</groupId>
+ <artifactId>ant-launcher</artifactId>
+ <version>0.1</version>
+ <scope>system</scope>
+ <systemPath>${basedir}/../tools/lib/ant-launcher.jar</systemPath>
+ </dependency>
+
+ <dependency>
+ <groupId>ant</groupId>
+ <artifactId>ant-junit</artifactId>
+ <version>0.1</version>
+ <scope>system</scope>
+ <systemPath>${basedir}/../tools/lib/ant-junit.jar</systemPath>
+ </dependency>
+
+ <dependency>
+ <groupId>ant</groupId>
+ <artifactId>ant-nodeps</artifactId>
+ <version>0.1</version>
+ <scope>system</scope>
+ <systemPath>${basedir}/../tools/lib/ant-nodeps.jar</systemPath>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>0.1</version>
+ <scope>system</scope>
+ <systemPath>${basedir}/../tools/lib/junit.jar</systemPath>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <resources>
+ <resource>
+ <filtering>false</filtering>
+ <directory>src/main/resources/format/code</directory>
+ <includes>
+ <include>*.tpl</include>
+ </includes>
+ </resource>
+ </resources>
+ <plugins>
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <encoding>iso-8859-1</encoding>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <configuration>
+ <archive>
+ <manifest>
+ <addClasspath>true</addClasspath>
+ </manifest>
+ </archive>
+ </configuration>
+ </plugin>
+
+ <!--<plugin>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <executions>
+ <execution>
+ <phase>generate-sources</phase>
+ <configuration>
+ <tasks>
+ <echo message="Run Ant tasks"/>
+ <property name="build.resources" refid="maven.test.classpath"/>
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>-->
+ </plugins>
+
+ <testSourceDirectory>src/test/java</testSourceDirectory>
+
+ <testResources>
+ <testResource>
+ <directory>src/test/resources</directory>
+ <filtering>false</filtering>
+ </testResource>
+ </testResources>
+ </build>
+ <properties>
+ <!--<build.resources>src/test/resources</build.resources>-->
+ <!--<env.build_resources>src/test/resources</env.build_resources>-->
+ </properties>
+</project>
\ No newline at end of file
Copied: modules/common/trunk/common/src/main/resources/format (from rev 8225, modules/common/trunk/common/src/resources/format)
Copied: modules/common/trunk/common/src/main/resources/format/code (from rev 8242, modules/common/trunk/common/src/resources/format/code)
Deleted: modules/common/trunk/common/src/resources/test/test01.code
===================================================================
--- modules/common/trunk/common/src/resources/test/test01.code 2007-09-12 18:27:35 UTC (rev 8245)
+++ modules/common/trunk/common/src/resources/test/test01.code 2007-09-12 18:29:07 UTC (rev 8246)
@@ -1,82 +0,0 @@
-this is some plain text
-<table><tr><td>I love to write entities like < or > to see how the renderer interprets that
-check the line break around this line
-here we check the wellformdness of the HTML stuff because we enter a code section
-which must terminates any open HTML tag
-[b]bold[/b]
-[i]italic[/i]
-
-the next line is a quote of myself which contains code
-[quote=julien]
-[code]
-this is an XML sample, so the great than etc... should be displayed instead of
-being treated as entities
-<?xml version="1.0"?>
-[b]<root>[/b] the root element is bold
-</root>
-[/code]
-
-the code is closed, we are going to test the nested quotes
-[quote]
-this is a nested quote
-[/quote]
-the next line is code that contains no breaks
-[code]public static void[/code]
-[/quote]
-
-next one is a quote with no line break
-[quote]quote with no line break[/quote]
-
-
-we are going to test if the renderer closes the unclosed statements
-[b][i][u]bold, italic, underline[/b]
-
-[url]http://www.test.com[/url]
-
-[list]
-[*]first item
-[/list]
-
-[list]
-[*]first item
-[*]second item
-[/list]
-
-[list=1]
-[*]first item
-[*]second item
-[/list]
-
-[list=a]
-[*]first item
-[*]second item
-[/list]
-
-[size=25][color=#FF0000]big red[/color][/size]
-
-<code><pre>
-a
- a
- a
- a
-</pre></code>
-<code>
-a
- a
- a
- a
-</code>
-<pre>
-a
- a
- a
- a
-</pre>
-[code]
-a
- a
- a
- a
-[/code]
-
-this is the end of the message
Added: modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/AbstractInvocationContextTestCase.java
===================================================================
--- modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/AbstractInvocationContextTestCase.java (rev 0)
+++ modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/AbstractInvocationContextTestCase.java 2007-09-12 18:29:07 UTC (rev 8246)
@@ -0,0 +1,252 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.test.common;
+
+import junit.framework.TestCase;
+import org.jboss.portal.common.invocation.AbstractInvocationContext;
+import org.jboss.portal.common.invocation.Scope;
+import org.jboss.portal.common.invocation.AttributeResolver;
+
+import java.util.HashMap;
+import java.util.Set;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class AbstractInvocationContextTestCase extends TestCase
+{
+
+ /** . */
+ private static final Scope TEST_SCOPE = new Scope("test");
+
+ public void testNonExistingScope()
+ {
+ AbstractInvocationContext ctx = new AbstractInvocationContext();
+ try
+ {
+ ctx.getAttribute(TEST_SCOPE, "foo");
+ fail("was expecting an IllegalArgumentException");
+ }
+ catch (IllegalArgumentException expected)
+ {
+
+ }
+ try
+ {
+ ctx.setAttribute(TEST_SCOPE, "foo", "bar");
+ fail("was expecting an IllegalArgumentException");
+ }
+ catch (IllegalArgumentException expected)
+ {
+
+ }
+ try
+ {
+ ctx.removeAttribute(TEST_SCOPE, "foo");
+ fail("was expecting an IllegalArgumentException");
+ }
+ catch (IllegalArgumentException expected)
+ {
+
+ }
+ try
+ {
+ ctx.getAttributeResolver(TEST_SCOPE);
+ fail("was expecting an IllegalArgumentException");
+ }
+ catch (IllegalArgumentException expected)
+ {
+
+ }
+ }
+
+ public void testExistingScopeWithResolver()
+ {
+ final MapResolver resolver = new MapResolver();
+ AbstractInvocationContext ctx = new AbstractInvocationContext()
+ {
+ {
+ addResolver(TEST_SCOPE, resolver);
+ }
+ };
+ testExistingScope(ctx, resolver);
+ }
+
+ public void testExistingScopeDelegation()
+ {
+ final MapResolver resolver = new MapResolver();
+ final AbstractInvocationContext parent = new AbstractInvocationContext()
+ {
+ {
+ addResolver(TEST_SCOPE, resolver);
+ }
+ };
+ AbstractInvocationContext child = new AbstractInvocationContext()
+ {
+ {
+ addResolver(TEST_SCOPE, parent);
+ }
+ };
+ testExistingScope(child, resolver);
+ }
+
+
+ private void testExistingScope(AbstractInvocationContext ctx, MapResolver resolver)
+ {
+ // Assert empty does not exist
+ assertNull(ctx.getAttribute(TEST_SCOPE, "foo"));
+ assertEquals(0, resolver.size());
+
+ // Remove non existing
+ ctx.removeAttribute(TEST_SCOPE, "foo");
+ assertNull(ctx.getAttribute(TEST_SCOPE, "foo"));
+ assertEquals(0, resolver.size());
+
+ // Set non existing
+ ctx.setAttribute(TEST_SCOPE, "foo", "bar");
+ assertEquals("bar", resolver.getAttribute("foo"));
+ assertEquals(1, resolver.size());
+
+ // Overwrite existing
+ ctx.setAttribute(TEST_SCOPE, "foo", "bar2");
+ assertEquals("bar2", resolver.getAttribute("foo"));
+ assertEquals(1, resolver.size());
+
+ // Remove existing
+ ctx.removeAttribute(TEST_SCOPE, "foo");
+ assertNull(ctx.getAttribute(TEST_SCOPE, "foo"));
+ assertEquals(0, resolver.size());
+
+ // Get resolver
+ assertEquals(resolver, ctx.getAttributeResolver(TEST_SCOPE));
+ }
+
+ public void testAPI()
+ {
+ AbstractInvocationContext ctx = new AbstractInvocationContext();
+ try
+ {
+ ctx.getAttribute(null, "foo");
+ fail("was expecting an IllegalArgumentException");
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ try
+ {
+ ctx.getAttribute(TEST_SCOPE, null);
+ fail("was expecting an IllegalArgumentException");
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ try
+ {
+ ctx.setAttribute(null, "foo", "bar");
+ fail("was expecting an IllegalArgumentException");
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ try
+ {
+ ctx.setAttribute(TEST_SCOPE, null, "bar");
+ fail("was expecting an IllegalArgumentException");
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ try
+ {
+ ctx.setAttribute(null, "foo", null);
+ fail("was expecting an IllegalArgumentException");
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ try
+ {
+ ctx.setAttribute(TEST_SCOPE, null, null);
+ fail("was expecting an IllegalArgumentException");
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ try
+ {
+ ctx.removeAttribute(null, "foo");
+ fail("was expecting an IllegalArgumentException");
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ try
+ {
+ ctx.removeAttribute(TEST_SCOPE, null);
+ fail("was expecting an IllegalArgumentException");
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ try
+ {
+ ctx.getAttributeResolver(null);
+ fail("was expecting an IllegalArgumentException");
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ }
+
+ private static class MapResolver extends HashMap implements AttributeResolver
+ {
+ public Set getKeys()
+ {
+ return keySet();
+ }
+ public Object getAttribute(Object attrKey) throws IllegalArgumentException
+ {
+ if (attrKey == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ return get(attrKey);
+ }
+ public void setAttribute(Object attrKey, Object attrValue) throws IllegalArgumentException
+ {
+ if (attrKey == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (attrValue != null)
+ {
+ put(attrKey, attrValue);
+ }
+ else
+ {
+ remove(attrKey);
+ }
+ }
+ }
+}
Added: modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/BufferedStreamTestCase.java
===================================================================
--- modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/BufferedStreamTestCase.java (rev 0)
+++ modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/BufferedStreamTestCase.java 2007-09-12 18:29:07 UTC (rev 8246)
@@ -0,0 +1,72 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.test.common;
+
+import junit.framework.TestCase;
+import org.jboss.portal.common.io.IOTools;
+
+import java.io.InputStream;
+import java.io.ByteArrayInputStream;
+import java.io.BufferedInputStream;
+import java.io.OutputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.BufferedOutputStream;
+import java.util.Arrays;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class BufferedStreamTestCase extends TestCase
+{
+
+ public BufferedStreamTestCase(String name)
+ {
+ super(name);
+ }
+
+ public void testInputStream() throws Exception
+ {
+ assertNull(IOTools.safeBufferedWrapper((InputStream)null));
+ BufferedInputStream in = IOTools.safeBufferedWrapper(new ByteArrayInputStream("abc".getBytes("UTF8")));
+ assertEquals(System.identityHashCode(in), System.identityHashCode(IOTools.safeBufferedWrapper(in)));
+ assertNotNull(in);
+ byte[] bytes = "abc".getBytes("UTF8");
+ Arrays.fill(bytes, (byte)0);
+ assertEquals(bytes.length, in.read(bytes));
+ assertEquals(-1, in.read());
+ assertEquals("abc", new String(bytes, "UTF8"));
+ }
+
+ public void testOutputputStream() throws Exception
+ {
+ assertNull(IOTools.safeBufferedWrapper((OutputStream)null));
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ BufferedOutputStream buffered = IOTools.safeBufferedWrapper(out);
+ assertNotNull(buffered);
+ assertEquals(System.identityHashCode(buffered), System.identityHashCode(IOTools.safeBufferedWrapper(buffered)));
+ buffered.write("abc".getBytes("UTF8"));
+ buffered.close();
+ assertEquals("abc", out.toString("UTF8"));
+ }
+}
Added: modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/BundleNameIteratorTestCase.java
===================================================================
--- modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/BundleNameIteratorTestCase.java (rev 0)
+++ modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/BundleNameIteratorTestCase.java 2007-09-12 18:29:07 UTC (rev 8246)
@@ -0,0 +1,206 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.test.common;
+
+import junit.framework.TestCase;
+
+import java.util.Locale;
+import java.util.NoSuchElementException;
+
+import org.jboss.portal.common.i18n.BundleName;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class BundleNameIteratorTestCase extends TestCase
+{
+
+ private final String A = new Locale("a", "b", "c").getLanguage();
+ private final String B = new Locale("a", "b", "c").getCountry();
+ private final String C = new Locale("a", "b", "c").getVariant();
+
+ public void testNameLookup1()
+ {
+ Locale l = new Locale("a", "b", "c");
+ BundleName.Iterator iterator = new BundleName.Iterator("base", l);
+ assertTrue(iterator.hasNext());
+ assertEquals("base_" + A + "_" + B + "_" + C, iterator.next());
+ assertTrue(iterator.hasNext());
+ assertEquals("base_" + A + "_" + B, iterator.next());
+ assertTrue(iterator.hasNext());
+ assertEquals("base_" + A, iterator.next());
+ assertTrue(iterator.hasNext());
+ assertEquals("base", iterator.next());
+ assertFalse(iterator.hasNext());
+ try
+ {
+ iterator.next();
+ fail("Was expecting NoSuchElementException");
+ }
+ catch (NoSuchElementException expected)
+ {
+ }
+ }
+
+ public void testNameLookup2()
+ {
+ Locale l = new Locale("a", "b");
+ BundleName.Iterator iterator = new BundleName.Iterator("base", l);
+ assertTrue(iterator.hasNext());
+ assertEquals("base_" + A + "_" + B, iterator.next());
+ assertTrue(iterator.hasNext());
+ assertEquals("base_" + A, iterator.next());
+ assertTrue(iterator.hasNext());
+ assertEquals("base", iterator.next());
+ assertFalse(iterator.hasNext());
+ try
+ {
+ iterator.next();
+ fail("Was expecting NoSuchElementException");
+ }
+ catch (NoSuchElementException expected)
+ {
+ }
+ }
+
+ public void testNameLookup4()
+ {
+ Locale l = new Locale("a", "b", "");
+ BundleName.Iterator iterator = new BundleName.Iterator("base", l);
+ assertTrue(iterator.hasNext());
+ assertEquals("base_" + A + "_" + B, iterator.next());
+ assertTrue(iterator.hasNext());
+ assertEquals("base_" + A, iterator.next());
+ assertTrue(iterator.hasNext());
+ assertEquals("base", iterator.next());
+ assertFalse(iterator.hasNext());
+ try
+ {
+ iterator.next();
+ fail("Was expecting NoSuchElementException");
+ }
+ catch (NoSuchElementException expected)
+ {
+ }
+ }
+
+ public void testNameLookup3()
+ {
+ Locale l = new Locale("a");
+ BundleName.Iterator iterator = new BundleName.Iterator("base", l);
+ assertTrue(iterator.hasNext());
+ assertEquals("base_" + A, iterator.next());
+ assertTrue(iterator.hasNext());
+ assertEquals("base", iterator.next());
+ assertFalse(iterator.hasNext());
+ try
+ {
+ iterator.next();
+ fail("Was expecting NoSuchElementException");
+ }
+ catch (NoSuchElementException expected)
+ {
+ }
+ }
+
+ public void testNameLookup5()
+ {
+ Locale l = new Locale("a", "", "");
+ BundleName.Iterator iterator = new BundleName.Iterator("base", l);
+ assertTrue(iterator.hasNext());
+ assertEquals("base_" + A, iterator.next());
+ assertTrue(iterator.hasNext());
+ assertEquals("base", iterator.next());
+ assertFalse(iterator.hasNext());
+ try
+ {
+ iterator.next();
+ fail("Was expecting NoSuchElementException");
+ }
+ catch (NoSuchElementException expected)
+ {
+ }
+ }
+
+ public void testNameLookup6()
+ {
+ Locale l = new Locale("a", "", "c");
+ BundleName.Iterator iterator = new BundleName.Iterator("base", l);
+ assertTrue(iterator.hasNext());
+ assertEquals("base_" + A + "__" + C, iterator.next());
+ assertTrue(iterator.hasNext());
+ assertEquals("base_" + A, iterator.next());
+ assertTrue(iterator.hasNext());
+ assertEquals("base", iterator.next());
+ assertFalse(iterator.hasNext());
+ try
+ {
+ iterator.next();
+ fail("Was expecting NoSuchElementException");
+ }
+ catch (NoSuchElementException expected)
+ {
+ }
+ }
+
+ public void testNameLookup7()
+ {
+ Locale l = new Locale("", "b", "c");
+ BundleName.Iterator iterator = new BundleName.Iterator("base", l);
+ assertTrue(iterator.hasNext());
+ assertEquals("base__" + B + "_" + C, iterator.next());
+ assertTrue(iterator.hasNext());
+ assertEquals("base__" + B, iterator.next());
+ assertTrue(iterator.hasNext());
+ assertEquals("base", iterator.next());
+ assertFalse(iterator.hasNext());
+ try
+ {
+ iterator.next();
+ fail("Was expecting NoSuchElementException");
+ }
+ catch (NoSuchElementException expected)
+ {
+ }
+ }
+
+ public void testNameLookup8()
+ {
+ Locale l = new Locale("", "", "c");
+ BundleName.Iterator iterator = new BundleName.Iterator("base", l);
+ assertTrue(iterator.hasNext());
+ assertEquals("base___" + C, iterator.next());
+ assertTrue(iterator.hasNext());
+ assertEquals("base", iterator.next());
+ assertFalse(iterator.hasNext());
+ try
+ {
+ iterator.next();
+ fail("Was expecting NoSuchElementException");
+ }
+ catch (NoSuchElementException expected)
+ {
+ }
+ }
+}
Added: modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/BundleNameParserTestCase.java
===================================================================
--- modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/BundleNameParserTestCase.java (rev 0)
+++ modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/BundleNameParserTestCase.java 2007-09-12 18:29:07 UTC (rev 8246)
@@ -0,0 +1,102 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.test.common;
+
+import junit.framework.TestCase;
+import org.jboss.portal.common.i18n.BundleName;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class BundleNameParserTestCase extends TestCase
+{
+
+ /** . */
+ private final BundleName.Parser parser = new BundleName.Parser();
+
+
+ private static final Test[] tests = {
+ new Test("_", null),
+ new Test("__", null),
+ new Test("___", null),
+
+ //
+ new Test("a", new BundleName("a")),
+ new Test("a_b", new BundleName("a", "b")),
+ new Test("a_b_c", new BundleName("a", "b", "c")),
+ new Test("a__b", new BundleName("a", "", "b")),
+ new Test("a___b", new BundleName("a", "", "", "b")),
+ new Test("a__b_c", new BundleName("a", "", "b", "c")),
+ new Test("a_b__c", new BundleName("a", "b", "", "c")),
+ new Test("a_b_c_d", new BundleName("a", "b", "c", "d")),
+
+ //
+ new Test("", new BundleName("")),
+ new Test("_b", new BundleName("", "b")),
+ new Test("_b_c", new BundleName("", "b", "c")),
+ new Test("__b", new BundleName("", "", "b")),
+ new Test("___b", new BundleName("", "", "", "b")),
+ new Test("__b_c", new BundleName("", "", "b", "c")),
+ new Test("_b__c", new BundleName("", "b", "", "c")),
+ new Test("_b_c_d", new BundleName("", "b", "c", "d")),
+ };
+
+ public void testA()
+ {
+ for (int i = 0; i < tests.length; i++)
+ {
+ Test test = tests[i];
+ BundleName name = parser.parse(test.input, 0, test.input.length());
+ if (name == null)
+ {
+ assertNull(test.input, test.expectedName);
+ }
+ else
+ {
+ assertNotNull(test.input, test.expectedName);
+ assertEquals(test.input, test.expectedName.getBaseName(), name.getBaseName());
+ assertEquals(test.input, test.expectedName.getLanguage(), name.getLanguage());
+ assertEquals(test.input, test.expectedName.getCountry(), name.getCountry());
+ assertEquals(test.input, test.expectedName.getVariant(), name.getVariant());
+ }
+ }
+ }
+
+
+ private static class Test
+ {
+
+ /** . */
+ private String input;
+
+ /** . */
+ private BundleName expectedName;
+
+ public Test(String input, BundleName expectedName)
+ {
+ this.input = input;
+ this.expectedName = expectedName;
+ }
+ }
+}
Added: modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/ComplexResourceBundleFactoryTestCase.java
===================================================================
--- modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/ComplexResourceBundleFactoryTestCase.java (rev 0)
+++ modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/ComplexResourceBundleFactoryTestCase.java 2007-09-12 18:29:07 UTC (rev 8246)
@@ -0,0 +1,310 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.test.common;
+
+import junit.framework.TestCase;
+
+import java.io.File;
+import java.net.URLClassLoader;
+import java.net.URL;
+import java.util.Locale;
+import java.util.ResourceBundle;
+
+import org.jboss.portal.common.i18n.ComplexResourceBundleFactory;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class ComplexResourceBundleFactoryTestCase extends TestCase
+{
+
+ /** . */
+ private File resourcesDir;
+
+ /** . */
+ private ClassLoader cl;
+
+ protected void setUp() throws Exception
+ {
+ File f = new File("");
+ String path = f.getAbsolutePath();
+ resourcesDir = new File(path + "/target/test-classes");
+ assertTrue(resourcesDir.exists());
+ assertTrue(resourcesDir.isDirectory());
+
+ File bundle = new File(resourcesDir, "/bundle");
+ assertTrue(bundle.exists());
+ assertTrue(bundle.isDirectory());
+ cl = new URLClassLoader(new URL[]{bundle.toURL()}, ClassLoader.getSystemClassLoader());
+ }
+
+ public void testExactMatch() throws Exception
+ {
+ Locale.setDefault(new Locale("ja"));
+
+ //
+ ComplexResourceBundleFactory factory = new ComplexResourceBundleFactory(cl, "a");
+
+ //
+ ResourceBundle a_de_DE = factory.getBundle(new Locale("de", "DE"));
+ assertNotNull(a_de_DE);
+ assertEquals("a_de_DE", a_de_DE.getString("value"));
+
+ //
+ ResourceBundle a_fr = factory.getBundle(new Locale("fr"));
+ assertNotNull(a_fr);
+ assertEquals("a_fr", a_fr.getString("value"));
+
+ //
+ ResourceBundle a_fr_FR = factory.getBundle(new Locale("fr", "FR"));
+ assertNotNull(a_fr_FR);
+ assertEquals("a_fr_FR", a_fr_FR.getString("value"));
+
+ //
+ ResourceBundle a_it = factory.getBundle(new Locale("it"));
+ assertNotNull(a_it);
+ assertEquals("a_it", a_it.getString("value"));
+ }
+
+ public void testNoMatch() throws Exception
+ {
+ Locale.setDefault(new Locale("ja"));
+
+ //
+ ComplexResourceBundleFactory factory = new ComplexResourceBundleFactory(cl, "a");
+
+ //
+ ResourceBundle a_de = factory.getBundle(new Locale("de"));
+ assertNull(a_de);
+
+ //
+ ResourceBundle a_en = factory.getBundle(new Locale("en"));
+ assertNull(a_en);
+
+ //
+ ResourceBundle a_en_EN = factory.getBundle(new Locale("en", "EN"));
+ assertNull(a_en_EN);
+ }
+
+ public void testFallbackOnDefaultLocale1() throws Exception
+ {
+ ComplexResourceBundleFactory factory = new ComplexResourceBundleFactory(cl, "b");
+
+ //
+ Locale.setDefault(new Locale("fr"));
+ ResourceBundle de = factory.getBundle(new Locale("de"));
+ assertNotNull(de);
+ assertEquals("b", de.getString("value"));
+ ResourceBundle fr = factory.getBundle(new Locale("fr"));
+ assertNotNull(fr);
+ assertEquals("b", fr.getString("value"));
+ ResourceBundle fr_FR = factory.getBundle(new Locale("fr", "FR"));
+ assertNotNull(fr_FR);
+ assertEquals("b", fr_FR.getString("value"));
+
+ //
+ Locale.setDefault(new Locale("fr", "FR"));
+ de = factory.getBundle(new Locale("de"));
+ assertNotNull(de);
+ assertEquals("b", de.getString("value"));
+ fr = factory.getBundle(new Locale("fr"));
+ assertNotNull(fr);
+ assertEquals("b", fr.getString("value"));
+ fr_FR = factory.getBundle(new Locale("fr", "FR"));
+ assertNotNull(fr_FR);
+ assertEquals("b", fr_FR.getString("value"));
+ }
+
+ public void testFallbackOnDefaultLocale2() throws Exception
+ {
+ ComplexResourceBundleFactory factory = new ComplexResourceBundleFactory(cl, "c");
+
+ //
+ Locale.setDefault(new Locale("fr"));
+ ResourceBundle de = factory.getBundle(new Locale("de"));
+ assertNotNull(de);
+ assertEquals("c_fr", de.getString("value"));
+ ResourceBundle fr = factory.getBundle(new Locale("fr"));
+ assertNotNull(fr);
+ assertEquals("c_fr", fr.getString("value"));
+ ResourceBundle fr_FR = factory.getBundle(new Locale("fr", "FR"));
+ assertNotNull(fr_FR);
+ assertEquals("c_fr", fr_FR.getString("value"));
+
+ //
+ Locale.setDefault(new Locale("fr", "FR"));
+ de = factory.getBundle(new Locale("de"));
+ assertNotNull(de);
+ assertEquals("c_fr", de.getString("value"));
+ fr = factory.getBundle(new Locale("fr"));
+ assertNotNull(fr);
+ assertEquals("c_fr", fr.getString("value"));
+ fr_FR = factory.getBundle(new Locale("fr", "FR"));
+ assertNotNull(fr_FR);
+ assertEquals("c_fr", fr_FR.getString("value"));
+ }
+
+ public void testFallbackOnDefaultLocale3() throws Exception
+ {
+ ComplexResourceBundleFactory factory = new ComplexResourceBundleFactory(cl, "d");
+
+ //
+ Locale.setDefault(new Locale("fr"));
+ ResourceBundle de = factory.getBundle(new Locale("de"));
+ assertNull(de);
+ ResourceBundle fr = factory.getBundle(new Locale("fr"));
+ assertNull(fr);
+ ResourceBundle fr_FR = factory.getBundle(new Locale("fr", "FR"));
+ assertNotNull(fr_FR);
+ assertEquals("d_fr_FR", fr_FR.getString("value"));
+
+ //
+ Locale.setDefault(new Locale("fr", "FR"));
+ de = factory.getBundle(new Locale("de"));
+ assertNotNull(de);
+ assertEquals("d_fr_FR", de.getString("value"));
+ fr = factory.getBundle(new Locale("fr"));
+ assertNotNull(fr);
+ assertEquals("d_fr_FR", fr.getString("value"));
+ fr_FR = factory.getBundle(new Locale("fr", "FR"));
+ assertNotNull(fr_FR);
+ assertEquals("d_fr_FR", fr_FR.getString("value"));
+ }
+
+ public void testFallbackOnDefaultLocale4() throws Exception
+ {
+ ComplexResourceBundleFactory factory = new ComplexResourceBundleFactory(cl, "e");
+
+ //
+ Locale.setDefault(new Locale("fr"));
+ ResourceBundle de = factory.getBundle(new Locale("de"));
+ assertNotNull(de);
+ assertEquals("e_fr", de.getString("value"));
+ ResourceBundle fr = factory.getBundle(new Locale("fr"));
+ assertNotNull(fr);
+ assertEquals("e_fr", fr.getString("value"));
+ ResourceBundle fr_FR = factory.getBundle(new Locale("fr", "FR"));
+ assertNotNull(fr_FR);
+ assertEquals("e_fr", fr_FR.getString("value"));
+
+ //
+ Locale.setDefault(new Locale("fr", "FR"));
+ de = factory.getBundle(new Locale("de"));
+ assertNotNull(de);
+ assertEquals("e_fr", de.getString("value"));
+ fr = factory.getBundle(new Locale("fr"));
+ assertNotNull(fr);
+ assertEquals("e_fr", fr.getString("value"));
+ fr_FR = factory.getBundle(new Locale("fr", "FR"));
+ assertNotNull(fr_FR);
+ assertEquals("e_fr", fr_FR.getString("value"));
+ }
+
+ public void testFallbackOnDefaultLocale5() throws Exception
+ {
+ ComplexResourceBundleFactory factory = new ComplexResourceBundleFactory(cl, "f");
+
+ //
+ Locale.setDefault(new Locale("fr"));
+ ResourceBundle de = factory.getBundle(new Locale("de"));
+ assertNotNull(de);
+ assertEquals("f", de.getString("value"));
+ ResourceBundle fr = factory.getBundle(new Locale("fr"));
+ assertNotNull(fr);
+ assertEquals("f", fr.getString("value"));
+ ResourceBundle fr_FR = factory.getBundle(new Locale("fr", "FR"));
+ assertNotNull(fr_FR);
+ assertEquals("f_fr_FR", fr_FR.getString("value"));
+
+ //
+ Locale.setDefault(new Locale("fr", "FR"));
+ de = factory.getBundle(new Locale("de"));
+ assertNotNull(de);
+ assertEquals("f_fr_FR", de.getString("value"));
+ fr = factory.getBundle(new Locale("fr"));
+ assertNotNull(fr);
+ assertEquals("f_fr_FR", fr.getString("value"));
+ fr_FR = factory.getBundle(new Locale("fr", "FR"));
+ assertNotNull(fr_FR);
+ assertEquals("f_fr_FR", fr_FR.getString("value"));
+ }
+
+ public void testFallbackOnDefaultLocale6() throws Exception
+ {
+ ComplexResourceBundleFactory factory = new ComplexResourceBundleFactory(cl, "g");
+
+ //
+ Locale.setDefault(new Locale("fr"));
+ ResourceBundle de = factory.getBundle(new Locale("de"));
+ assertNotNull(de);
+ assertEquals("g_fr", de.getString("value"));
+ ResourceBundle fr = factory.getBundle(new Locale("fr"));
+ assertNotNull(fr);
+ assertEquals("g_fr", fr.getString("value"));
+ ResourceBundle fr_FR = factory.getBundle(new Locale("fr", "FR"));
+ assertNotNull(fr_FR);
+ assertEquals("g_fr_FR", fr_FR.getString("value"));
+
+ //
+ Locale.setDefault(new Locale("fr", "FR"));
+ de = factory.getBundle(new Locale("de"));
+ assertNotNull(de);
+ assertEquals("g_fr_FR", de.getString("value"));
+ fr = factory.getBundle(new Locale("fr"));
+ assertNotNull(fr);
+ assertEquals("g_fr", fr.getString("value"));
+ fr_FR = factory.getBundle(new Locale("fr", "FR"));
+ assertNotNull(fr_FR);
+ assertEquals("g_fr_FR", fr_FR.getString("value"));
+ }
+
+ public void testFallbackOnDefaultLocale7() throws Exception
+ {
+ ComplexResourceBundleFactory factory = new ComplexResourceBundleFactory(cl, "h");
+
+ //
+ Locale.setDefault(new Locale("fr"));
+ ResourceBundle de = factory.getBundle(new Locale("de"));
+ assertNotNull(de);
+ assertEquals("h_fr", de.getString("value"));
+ ResourceBundle fr = factory.getBundle(new Locale("fr"));
+ assertNotNull(fr);
+ assertEquals("h_fr", fr.getString("value"));
+ ResourceBundle fr_FR = factory.getBundle(new Locale("fr", "FR"));
+ assertNotNull(fr_FR);
+ assertEquals("h_fr_FR", fr_FR.getString("value"));
+
+ //
+ Locale.setDefault(new Locale("fr", "FR"));
+ de = factory.getBundle(new Locale("de"));
+ assertNotNull(de);
+ assertEquals("h_fr_FR", de.getString("value"));
+ fr = factory.getBundle(new Locale("fr"));
+ assertNotNull(fr);
+ assertEquals("h_fr", fr.getString("value"));
+ fr_FR = factory.getBundle(new Locale("fr", "FR"));
+ assertNotNull(fr_FR);
+ assertEquals("h_fr_FR", fr_FR.getString("value"));
+ }
+}
Added: modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/CopyOnWriteRegistryTestCase.java
===================================================================
--- modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/CopyOnWriteRegistryTestCase.java (rev 0)
+++ modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/CopyOnWriteRegistryTestCase.java 2007-09-12 18:29:07 UTC (rev 8246)
@@ -0,0 +1,187 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.test.common;
+
+import junit.framework.TestCase;
+import org.jboss.portal.common.util.CopyOnWriteRegistry;
+
+import java.util.Collections;
+import java.util.Set;
+import java.util.List;
+import java.util.ArrayList;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class CopyOnWriteRegistryTestCase extends TestCase
+{
+
+ private CopyOnWriteRegistry registry;
+ Object key;
+ Object registered1;
+ Object registered2;
+
+
+ protected void setUp() throws Exception
+ {
+ registry = new CopyOnWriteRegistry();
+ key = new Object();
+ registered1 = new Object();
+ registered2 = new Object();
+ }
+
+ protected void tearDown() throws Exception
+ {
+ registry = null;
+ key = null;
+ registered1 = null;
+ registered2 = null;
+ }
+
+ public void testRegisterThrowsIAE()
+ {
+ try
+ {
+ registry.register(null, registered1);
+ fail("Was expecting an IAE");
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ try
+ {
+ registry.register(registered1, null);
+ fail("Was expecting an IAE");
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ try
+ {
+ registry.register(null, null);
+ fail("Was expecting an IAE");
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ }
+
+ public void testUnregisterThrowsIAE()
+ {
+ try
+ {
+ registry.unregister(null);
+ fail("Was expecting an IAE");
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ }
+
+ public void testGetThrowsIAE()
+ {
+ try
+ {
+ registry.getRegistration(null);
+ fail("Was expecting an IAE");
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ }
+
+ public void testDualRegistration()
+ {
+ assertTrue(registry.register(key, registered1));
+ assertFalse(registry.register(key, registered2));
+ assertEquals(registered1, registry.getRegistration(key));
+ }
+
+ public void testUnregisterNonRegistered()
+ {
+ assertNull(registry.unregister(key));
+ }
+
+ public void testNormal()
+ {
+ assertEquals(Collections.EMPTY_SET, registry.getKeys());
+ assertEquals(Collections.EMPTY_LIST, new ArrayList(registry.getRegistrations()));
+ assertTrue(registry.register(key, registered1));
+ assertEquals(Collections.singleton(key), registry.getKeys());
+ assertEquals(Collections.singletonList(registered1), new ArrayList(registry.getRegistrations()));
+ assertEquals(registered1, registry.getRegistration(key));
+ assertEquals(registered1, registry.unregister(key));
+ assertEquals(null, registry.getRegistration(key));
+ assertEquals(Collections.EMPTY_SET, registry.getKeys());
+ assertEquals(Collections.EMPTY_LIST, new ArrayList(registry.getRegistrations()));
+ }
+
+ public void testCopyOnWrite()
+ {
+ Set keys = registry.getKeys();
+ List registrations = new ArrayList(registry.getRegistrations());
+ assertEquals(Collections.EMPTY_SET, keys);
+ assertEquals(Collections.EMPTY_LIST, registrations);
+ assertTrue(registry.register(key, registered1));
+ assertEquals(Collections.EMPTY_SET, keys);
+ assertEquals(Collections.EMPTY_LIST, registrations);
+ keys = registry.getKeys();
+ registrations = new ArrayList(registry.getRegistrations());
+ assertEquals(Collections.singleton(key), keys);
+ assertEquals(Collections.singletonList(registered1), registrations);
+ assertEquals(registered1, registry.unregister(key));
+ assertEquals(Collections.singleton(key), keys);
+ assertEquals(Collections.singletonList(registered1), registrations);
+ keys = registry.getKeys();
+ registrations = new ArrayList(registry.getRegistrations());
+ assertEquals(Collections.EMPTY_SET, keys);
+ assertEquals(Collections.EMPTY_LIST, registrations);
+ }
+
+ public void testKeysAreNotModifiable()
+ {
+ registry.register(key, registered1);
+ try
+ {
+ registry.getKeys().clear();
+ fail("Was expecting UnsupportedOperationException");
+ }
+ catch (UnsupportedOperationException expected)
+ {
+ }
+ }
+
+ public void testRegistrationsAreNotModifiable()
+ {
+ registry.register(key, registered1);
+ try
+ {
+ registry.getRegistrations().clear();
+ fail("Was expecting UnsupportedOperationException");
+ }
+ catch (UnsupportedOperationException expected)
+ {
+ }
+ }
+}
Added: modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/DescriptionTestCase.java
===================================================================
--- modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/DescriptionTestCase.java (rev 0)
+++ modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/DescriptionTestCase.java 2007-09-12 18:29:07 UTC (rev 8246)
@@ -0,0 +1,105 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.test.common;
+
+import junit.framework.TestCase;
+
+import java.util.Map;
+import java.util.HashMap;
+import java.util.Locale;
+
+import org.jboss.portal.common.i18n.LocalizedString;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 6818 $
+ */
+public class DescriptionTestCase extends TestCase
+{
+
+ public DescriptionTestCase(String name)
+ {
+ super(name);
+ }
+
+ private Locale deflt = Locale.ENGLISH;
+ private Locale abc = new Locale("a", "b", "c");
+ private Locale ab = new Locale("a", "b");
+ private Locale a = new Locale("a");
+
+ public void testA()
+ {
+ Map map = new HashMap();
+ map.put(abc, "abc");
+ map.put(ab, "ab");
+ map.put(a, "a");
+ map.put(deflt, "deflt");
+ LocalizedString desc = new LocalizedString(map, deflt);
+ assertEquals("abc", desc.getString(abc, true));
+ assertEquals("ab", desc.getString(ab, true));
+ assertEquals("a", desc.getString(a, true));
+ }
+
+ public void testB()
+ {
+ Map map = new HashMap();
+ map.put(abc, "abc");
+ map.put(deflt, "deflt");
+ LocalizedString desc = new LocalizedString(map, deflt);
+ assertEquals("abc", desc.getString(abc, true));
+ assertEquals("deflt", desc.getString(ab, true));
+ assertEquals("deflt", desc.getString(a, true));
+ }
+
+ public void testC()
+ {
+ Map map = new HashMap();
+ map.put(ab, "ab");
+ map.put(deflt, "deflt");
+ LocalizedString desc = new LocalizedString(map, deflt);
+ assertEquals("ab", desc.getString(abc, true));
+ assertEquals("ab", desc.getString(ab, true));
+ assertEquals("deflt", desc.getString(a, true));
+ }
+
+ public void testD()
+ {
+ Map map = new HashMap();
+ map.put(a, "a");
+ map.put(deflt, "deflt");
+ LocalizedString desc = new LocalizedString(map, deflt);
+ assertEquals("a", desc.getString(abc, true));
+ assertEquals("a", desc.getString(ab, true));
+ assertEquals("a", desc.getString(a, true));
+ }
+
+ public void testE()
+ {
+ Map map = new HashMap();
+ map.put(deflt, "deflt");
+ LocalizedString desc = new LocalizedString(map, deflt);
+ assertEquals("deflt", desc.getString(abc, true));
+ assertEquals("deflt", desc.getString(ab, true));
+ assertEquals("deflt", desc.getString(a, true));
+ }
+}
Added: modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/HexTestCase.java
===================================================================
--- modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/HexTestCase.java (rev 0)
+++ modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/HexTestCase.java 2007-09-12 18:29:07 UTC (rev 8246)
@@ -0,0 +1,53 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.test.common;
+
+import junit.framework.TestCase;
+import org.jboss.portal.common.util.Tools;
+
+import java.util.Arrays;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 5451 $
+ */
+public class HexTestCase extends TestCase
+{
+ public HexTestCase(String s)
+ {
+ super(s);
+ System.out.println("BUILD");
+ System.out.println("BUILD");
+ System.out.println("BUILD");
+ }
+
+ public void testBasic()
+ {
+ byte[] original = new byte[]{0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20};
+ String hex = Tools.toHexString(original);
+// assertEquals((String)"000102030405060708090a0b0c0d0e0f1011121314", (String)hex);
+ assertEquals("a", "a");
+ byte[] copy = Tools.fromHexString(hex);
+ assertTrue(Arrays.equals(original, copy));
+ }
+}
Added: modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/ImplodeTestCase.java
===================================================================
--- modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/ImplodeTestCase.java (rev 0)
+++ modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/ImplodeTestCase.java 2007-09-12 18:29:07 UTC (rev 8246)
@@ -0,0 +1,63 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.test.common;
+
+import junit.framework.TestCase;
+import org.jboss.portal.common.ant.Implode;
+
+import java.io.File;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 6289 $
+ */
+public class ImplodeTestCase extends TestCase
+{
+
+ public ImplodeTestCase(String name)
+ {
+ super(name);
+ }
+
+ public void testA() throws Exception
+ {
+ File f = new File("");
+ String path = f.getAbsolutePath();
+
+ File foo_sarDir = new File(path + "/target/test-classes/implode/foo.sar");
+
+ assertTrue(foo_sarDir.exists());
+ assertTrue(foo_sarDir.isDirectory());
+ File tmp = File.createTempFile("foo", ".sar");
+ tmp.deleteOnExit();
+ tmp.setLastModified(foo_sarDir.lastModified() - 1);
+ assertTrue(foo_sarDir.lastModified() > tmp.lastModified());
+ Implode implode = new Implode();
+ implode.setDir(foo_sarDir);
+ implode.setTofile(tmp);
+ implode.execute();
+
+ // Test that the structure is correct
+ }
+
+}
Added: modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/IteratorStatusTestCase.java
===================================================================
--- modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/IteratorStatusTestCase.java (rev 0)
+++ modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/IteratorStatusTestCase.java 2007-09-12 18:29:07 UTC (rev 8246)
@@ -0,0 +1,83 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.test.common;
+
+import junit.framework.TestCase;
+
+import java.util.ArrayList;
+import java.util.NoSuchElementException;
+
+import org.jboss.portal.common.util.IteratorStatus;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class IteratorStatusTestCase extends TestCase
+{
+
+ public void testA()
+ {
+ ArrayList list = new ArrayList();
+ list.add("a");
+ list.add("b");
+ list.add("c");
+
+ //
+ test(new IteratorStatus(list));
+ test(new IteratorStatus(list.iterator()));
+ }
+
+ private void test(IteratorStatus iterator)
+ {
+ assertTrue(iterator.hasNext());
+ assertEquals(-1, iterator.getIndex());
+
+ //
+ assertEquals("a", iterator.next());
+ assertTrue(iterator.hasNext());
+ assertEquals(0, iterator.getIndex());
+
+ //
+ assertEquals("b", iterator.next());
+ assertTrue(iterator.hasNext());
+ assertEquals(1, iterator.getIndex());
+
+ //
+ assertEquals("c", iterator.next());
+ assertFalse(iterator.hasNext());
+ assertEquals(2, iterator.getIndex());
+
+ //
+ try
+ {
+ iterator.next();
+ fail("Was expecting a NoSuchElementException");
+ }
+ catch (NoSuchElementException expected)
+ {
+ }
+ assertFalse(iterator.hasNext());
+ assertEquals(2, iterator.getIndex());
+ }
+}
Added: modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/JarTestCase.java
===================================================================
--- modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/JarTestCase.java (rev 0)
+++ modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/JarTestCase.java 2007-09-12 18:29:07 UTC (rev 8246)
@@ -0,0 +1,126 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.test.common;
+
+import junit.framework.TestCase;
+
+import java.util.Iterator;
+import java.util.Arrays;
+import java.util.jar.JarOutputStream;
+import java.util.jar.JarEntry;
+import java.util.jar.JarInputStream;
+import java.io.IOException;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.FileInputStream;
+import java.io.OutputStream;
+
+import org.jboss.portal.common.jar.JarEntryInfo;
+import org.jboss.portal.common.jar.JarInfo;
+import org.jboss.portal.common.io.IOTools;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7425 $
+ */
+public class JarTestCase extends TestCase
+{
+
+ public JarTestCase(String name)
+ {
+ super(name);
+ }
+
+ public void testJarEntryInfo()
+ {
+ JarEntryInfo info1 = new JarEntryInfo(new JarEntry("a"));
+ assertEquals(Arrays.asList(new String[]{"/", "a"}), info1.getNames());
+
+ JarEntryInfo info2 = new JarEntryInfo(new JarEntry("a/"));
+ assertEquals(Arrays.asList(new String[]{"/", "a"}), info2.getNames());
+
+ JarEntryInfo info3 = new JarEntryInfo(new JarEntry("/"));
+ assertEquals(Arrays.asList(new String[]{"/"}), info3.getNames());
+
+ JarEntryInfo info4 = new JarEntryInfo(new JarEntry("a/b"));
+ assertEquals(Arrays.asList(new String[]{"/", "a","b"}), info4.getNames());
+
+ JarEntryInfo info5 = new JarEntryInfo(new JarEntry("a/b/"));
+ assertEquals(Arrays.asList(new String[]{"/", "a","b"}), info5.getNames());
+
+ JarEntryInfo info6 = new JarEntryInfo(new JarEntry("/a"));
+ assertEquals(Arrays.asList(new String[]{"/", "a"}), info6.getNames());
+
+ JarEntryInfo info7 = new JarEntryInfo(new JarEntry("/a/"));
+ assertEquals(Arrays.asList(new String[]{"/", "a"}), info7.getNames());
+
+ JarEntryInfo info8 = new JarEntryInfo(new JarEntry("/a/b"));
+ assertEquals(Arrays.asList(new String[]{"/", "a","b"}), info8.getNames());
+
+ JarEntryInfo info9 = new JarEntryInfo(new JarEntry("/a/b/"));
+ assertEquals(Arrays.asList(new String[]{"/", "a","b"}), info9.getNames());
+ }
+
+ public void testEntryComparator() throws IOException
+ {
+ File jarFile = File.createTempFile("test", ".jar");
+
+ OutputStream out = IOTools.safeBufferedWrapper(new FileOutputStream(jarFile));
+ JarOutputStream jarOut = new JarOutputStream(out);
+ jarOut.putNextEntry(new JarEntry("a/c"));
+ jarOut.closeEntry();
+ jarOut.putNextEntry(new JarEntry("c/d"));
+ jarOut.closeEntry();
+ jarOut.putNextEntry(new JarEntry("a"));
+ jarOut.closeEntry();
+ jarOut.putNextEntry(new JarEntry("b"));
+ jarOut.closeEntry();
+ jarOut.putNextEntry(new JarEntry("a/b"));
+ jarOut.closeEntry();
+ jarOut.close();
+
+ jarFile.deleteOnExit();
+
+ JarInputStream jarIn = new JarInputStream(IOTools.safeBufferedWrapper(new FileInputStream(jarFile)));
+ Iterator i = new JarInfo(jarIn).entries();
+ while (i.hasNext())
+ {
+ Object o = i.next();
+ System.out.println("o = " + o);
+ }
+ jarIn.close();
+ }
+
+ public void testIsChildOf()
+ {
+ assertFalse(new JarEntryInfo(new JarEntry("a")).isChildOf(new JarEntryInfo(new JarEntry(""))));
+ assertFalse(new JarEntryInfo(new JarEntry("/a")).isChildOf(new JarEntryInfo(new JarEntry(""))));
+ assertTrue(new JarEntryInfo(new JarEntry("a")).isChildOf(new JarEntryInfo(new JarEntry("/"))));
+ assertTrue(new JarEntryInfo(new JarEntry("/a")).isChildOf(new JarEntryInfo(new JarEntry("/"))));
+ assertFalse(new JarEntryInfo(new JarEntry("a/b")).isChildOf(new JarEntryInfo(new JarEntry("a"))));
+ assertFalse(new JarEntryInfo(new JarEntry("/a/b")).isChildOf(new JarEntryInfo(new JarEntry("a"))));
+ assertTrue(new JarEntryInfo(new JarEntry("a/b")).isChildOf(new JarEntryInfo(new JarEntry("a/"))));
+ assertTrue(new JarEntryInfo(new JarEntry("/a/b")).isChildOf(new JarEntryInfo(new JarEntry("a/"))));
+ }
+
+}
Added: modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/JavaBeanModelMBeanBuilderTestCase.java
===================================================================
--- modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/JavaBeanModelMBeanBuilderTestCase.java (rev 0)
+++ modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/JavaBeanModelMBeanBuilderTestCase.java 2007-09-12 18:29:07 UTC (rev 8246)
@@ -0,0 +1,496 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.test.common;
+
+import junit.framework.TestCase;
+import org.jboss.portal.common.mx.JavaBeanModelMBeanBuilder;
+
+import javax.management.AttributeNotFoundException;
+import javax.management.MBeanAttributeInfo;
+import javax.management.MBeanOperationInfo;
+import javax.management.MBeanServer;
+import javax.management.MBeanServerFactory;
+import javax.management.ObjectName;
+import javax.management.Attribute;
+import javax.management.Descriptor;
+import javax.management.modelmbean.ModelMBeanInfo;
+import javax.management.modelmbean.RequiredModelMBean;
+import javax.management.modelmbean.ModelMBeanOperationInfo;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.Arrays;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a>
+ * @version $Revision: 7452 $
+ */
+public class JavaBeanModelMBeanBuilderTestCase extends TestCase
+{
+
+ public void testEmpty() throws Exception
+ {
+ JavaBeanModelMBeanBuilder builder = new JavaBeanModelMBeanBuilder(Empty.class, Object.class);
+ ModelMBeanInfo info = builder.getInfo();
+
+ //
+ MBeanAttributeInfo[] attrs = info.getAttributes();
+ assertNotNull(attrs);
+ assertEquals(0, attrs.length);
+
+ //
+ MBeanOperationInfo[] ops = info.getOperations();
+ assertNotNull(ops);
+ assertEquals(0, ops.length);
+ }
+
+ public void testSimpleClass() throws Exception
+ {
+ JavaBeanModelMBeanBuilder builder = new JavaBeanModelMBeanBuilder(TestClass.class, Object.class);
+ ModelMBeanInfo info = builder.getInfo();
+
+ //
+ assertNotNull(info.getAttributes());
+ Set attrs = getAttributes(info);
+
+ //
+ Set expectedAttrs = new HashSet();
+ expectedAttrs.add(new TestAttribute("java.lang.String", "String"));
+ expectedAttrs.add(new TestAttribute("boolean", "Boolean"));
+ assertEquals(expectedAttrs, attrs);
+
+ //
+ assertNotNull(info.getOperations());
+ Set ops = getOperations(info);
+
+ //
+ Set expectedOps = new HashSet();
+ expectedOps.add(TestOperation.newOperation("void", "operation", new String[]{}));
+ expectedOps.add(TestOperation.newOperation("void", "operation", new String[]{"java.lang.String"}));
+ expectedOps.add(TestOperation.newSetter("setString", "java.lang.String"));
+ expectedOps.add(TestOperation.newGetter("getString", "java.lang.String"));
+ expectedOps.add(TestOperation.newSetter("setBoolean", "boolean"));
+ expectedOps.add(TestOperation.newGetter("isBoolean", "boolean"));
+ assertEquals(expectedOps, ops);
+ }
+
+ public void testOperationOverride() throws Exception
+ {
+ JavaBeanModelMBeanBuilder builder = new JavaBeanModelMBeanBuilder(Child.class, Parent.class);
+ ModelMBeanInfo info = builder.getInfo();
+
+ //
+ assertNotNull(info.getOperations());
+ Set ops = getOperations(info);
+
+ //
+ Set expectedOps = new HashSet();
+ expectedOps.add(TestOperation.newOperation("void", "overridenOperation", new String[]{}));
+ assertEquals(expectedOps, ops);
+ }
+
+ public void testSetterOverload() throws Exception
+ {
+ try
+ {
+ JavaBeanModelMBeanBuilder builder = new JavaBeanModelMBeanBuilder(OverloadedSetter.class, Object.class);
+ fail();
+ }
+ catch (Exception expected)
+ {
+ // expected
+ }
+ }
+
+ public void testOverridenGetter() throws Exception
+ {
+ JavaBeanModelMBeanBuilder builder = new JavaBeanModelMBeanBuilder(TestOverridenExtend.class, Object.class);
+ ModelMBeanInfo info = builder.getInfo();
+
+ //
+ Set ops = getOperations(info);
+ Set expectedOps = new HashSet();
+ expectedOps.add(TestOperation.newGetter("getTest", "java.util.Set"));
+ assertEquals(expectedOps, ops);
+
+ }
+
+ public void testAttributesAreNotCached() throws Exception
+ {
+ AttributesAreNotCached aanc = new AttributesAreNotCached();
+ ModelMBeanInfo info = JavaBeanModelMBeanBuilder.build(aanc);
+
+ MBeanServer server = MBeanServerFactory.createMBeanServer();
+
+ ObjectName name = new ObjectName(":a=b");
+ RequiredModelMBean mbean = new RequiredModelMBean(info);
+ mbean.setManagedResource(aanc, "ObjectReference");
+ server.registerMBean(mbean, name);
+ assertEquals(new Integer(0), server.getAttribute(name, "Count"));
+ assertEquals(new Integer(1), server.getAttribute(name, "Count"));
+
+ MBeanServerFactory.releaseMBeanServer(server);
+ }
+
+ public void testStaticAttribute() throws Exception
+ {
+ StaticAttribute sa = new StaticAttribute();
+ ModelMBeanInfo info = JavaBeanModelMBeanBuilder.build(sa);
+
+ MBeanServer server = MBeanServerFactory.createMBeanServer();
+
+ ObjectName name = new ObjectName(":a=b");
+ RequiredModelMBean mbean = new RequiredModelMBean(info);
+ mbean.setManagedResource(sa, "ObjectReference");
+ server.registerMBean(mbean, name);
+ try
+ {
+ server.getAttribute(name, "Read");
+ fail();
+ }
+ catch (AttributeNotFoundException expected)
+ {
+ }
+ try
+ {
+ server.getAttribute(name, "ReadWrite");
+ fail();
+ }
+ catch (AttributeNotFoundException expected)
+ {
+ }
+ try
+ {
+ server.setAttribute(name, new Attribute("ReadWrite", new Integer(0)));
+ fail();
+ }
+ catch (AttributeNotFoundException expected)
+ {
+ }
+ try
+ {
+ server.setAttribute(name, new Attribute("Write", new Integer(0)));
+ fail();
+ }
+ catch (AttributeNotFoundException expected)
+ {
+ }
+ MBeanServerFactory.releaseMBeanServer(server);
+ }
+
+ public Set getAttributes(ModelMBeanInfo info)
+ {
+ Set set = new HashSet();
+ MBeanAttributeInfo[] attrs = info.getAttributes();
+ for (int i = 0; i < attrs.length; i++)
+ {
+ MBeanAttributeInfo attr = attrs[i];
+ set.add(new TestAttribute(attr));
+ }
+ return set;
+ }
+
+ public Set getOperations(ModelMBeanInfo info)
+ {
+ MBeanOperationInfo[] ops = info.getOperations();
+ Set set = new HashSet();
+ for (int i = 0; i < ops.length; i++)
+ {
+ MBeanOperationInfo op = ops[i];
+ set.add(new TestOperation((ModelMBeanOperationInfo)op));
+ }
+ return set;
+ }
+
+ public static class StaticAttribute
+ {
+ public static int getRead()
+ {
+ return 0;
+ }
+
+ public static void setWrite(int a)
+ {
+ }
+
+ public static int getReadWrite()
+ {
+ return 0;
+ }
+
+ public static void setReadWrite(int a)
+ {
+ }
+ }
+
+ public static class OverloadedSetter
+ {
+ public void setA(int a)
+ {
+ }
+
+ public void setA(String a)
+ {
+ }
+
+ public boolean getA()
+ {
+ return false;
+ }
+
+ public boolean isA()
+ {
+ return false;
+ }
+ }
+
+ public static class Parent
+ {
+ public void operation()
+ {
+ }
+
+ public void overridenOperation()
+ {
+ }
+ }
+
+ public static class Child extends Parent
+ {
+ public void overridenOperation()
+ {
+ }
+ }
+
+ public static class Empty
+ {
+ }
+
+ public static class TestClass
+ {
+
+ public void operation()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void operation(String s)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public String getString()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void setString(String s)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean isBoolean()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void setBoolean(boolean b)
+ {
+ throw new UnsupportedOperationException();
+ }
+ }
+
+ public class AttributesAreNotCached
+ {
+ private int count;
+
+ public int getCount()
+ {
+ return count++;
+ }
+ }
+
+ public class TestOverridenBase
+ {
+ public Set getTest()
+ {
+ //nothing
+ return new HashSet();
+ }
+ }
+
+ public class TestOverridenExtend extends TestOverridenBase
+ {
+ public Set getTest()
+ {
+ //nothing
+ return new HashSet();
+ }
+ }
+
+ public static class TestAttribute
+ {
+
+ /** . */
+ public final String type;
+
+ /** . */
+ public final String name;
+
+ public TestAttribute(MBeanAttributeInfo info)
+ {
+ this.type = info.getType();
+ this.name = info.getName();
+ }
+
+ public TestAttribute(String type, String name)
+ {
+ if (type == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (name == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ this.type = type;
+ this.name = name;
+ }
+
+ public int hashCode()
+ {
+ return type.hashCode() * 43 + name.hashCode();
+ }
+
+ public boolean equals(Object obj)
+ {
+ TestAttribute that = (TestAttribute)obj;
+ return type.equals(that.type) && name.equals(that.name);
+ }
+
+ public String toString()
+ {
+ return "Attribute[" + type + "," + name + "]";
+ }
+ }
+
+ public static class TestOperation
+ {
+
+ /** . */
+ public final String returnType;
+
+ /** . */
+ public final String name;
+
+ /** . */
+ public final String[] argTypes;
+
+ /** . */
+ public final String role;
+
+ public TestOperation(ModelMBeanOperationInfo info)
+ {
+ Descriptor desc = info.getDescriptor();
+
+ this.returnType = info.getReturnType();
+ this.name = info.getName();
+ this.argTypes = new String[info.getSignature().length];
+ this.role = (String)desc.getFieldValue("role");
+ for (int i = 0; i < argTypes.length; i++)
+ {
+ argTypes[i] = info.getSignature()[i].getType();
+ }
+ }
+
+ public static TestOperation newOperation(String returnType, String name, String[] argTypes)
+ {
+ return new TestOperation(returnType, name, argTypes, "operation");
+ }
+
+ public static TestOperation newGetter(String name, String type)
+ {
+ return new TestOperation(type, name, new String[0], "getter");
+ }
+
+ public static TestOperation newSetter(String name, String type)
+ {
+ return new TestOperation("void", name, new String[]{type}, "setter");
+ }
+
+ public TestOperation(String returnType, String name, String[] argTypes, String role)
+ {
+ if (returnType == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (name == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (argTypes == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ for (int i = 0; i < argTypes.length; i++)
+ {
+ if (argTypes[i] == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ }
+ this.returnType = returnType;
+ this.name = name;
+ this.argTypes = argTypes;
+ this.role = role;
+ }
+
+ public int hashCode()
+ {
+ int code = (returnType.hashCode() * 43 + name.hashCode()) * 43 + role.hashCode();
+ for (int i = 0; i < argTypes.length; i++)
+ {
+ String argType = argTypes[i];
+ code = code * 43 + argType.hashCode();
+ }
+ return code;
+ }
+
+ public boolean equals(Object obj)
+ {
+ TestOperation that = (TestOperation)obj;
+ return returnType.equals(that.returnType) && name.equals(that.name) && role.equals(that.role) && Arrays.equals(argTypes, that.argTypes);
+ }
+
+ public String toString()
+ {
+ StringBuffer tmp = new StringBuffer("Operation[").append(returnType).append(",").append(name).append(",").append(role);
+ for (int i = 0; i < argTypes.length; i++)
+ {
+ tmp.append(",").append(argTypes[i]);
+ }
+ tmp.append(")");
+ return tmp.toString();
+ }
+ }
+}
Added: modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/LocaleFormatTestCase.java
===================================================================
--- modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/LocaleFormatTestCase.java (rev 0)
+++ modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/LocaleFormatTestCase.java 2007-09-12 18:29:07 UTC (rev 8246)
@@ -0,0 +1,217 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.test.common;
+
+import junit.framework.TestCase;
+
+import java.util.Locale;
+import java.util.Map;
+import java.util.HashMap;
+import java.io.Writer;
+import java.io.IOException;
+
+import org.jboss.portal.common.i18n.LocaleFormat;
+import org.jboss.portal.common.i18n.CachingLocaleFormat;
+import org.jboss.portal.common.i18n.AbstractLocaleFormat;
+import org.jboss.portal.common.util.FormatConversionException;
+import org.jboss.portal.common.util.ConversionException;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class LocaleFormatTestCase extends TestCase
+{
+
+ public void testgetLocaleFromDefaultFormat() throws ConversionException
+ {
+ assertEquals(new Locale("a"), LocaleFormat.DEFAULT_NO_CACHE.getLocale("a"));
+ assertEquals(new Locale("a", "b"), LocaleFormat.DEFAULT_NO_CACHE.getLocale("a_b"));
+ assertEquals(new Locale("", "b"), LocaleFormat.DEFAULT_NO_CACHE.getLocale("_b"));
+ assertEquals(new Locale("a", "b", "c"), LocaleFormat.DEFAULT_NO_CACHE.getLocale("a_b_c"));
+ assertEquals(new Locale("a", "", "b"), LocaleFormat.DEFAULT_NO_CACHE.getLocale("a__b"));
+ assertEquals(new Locale("", "a", "b"), LocaleFormat.DEFAULT_NO_CACHE.getLocale("_a_b"));
+ assertEquals(new Locale(""), LocaleFormat.DEFAULT_NO_CACHE.getLocale(""));
+
+ //
+ try
+ {
+ assertEquals(new Locale("", "", "a"), LocaleFormat.DEFAULT.getLocale("__a"));
+ fail();
+ }
+ catch (ConversionException expected)
+ {
+ }
+ try
+ {
+ assertEquals(new Locale("", "", ""), LocaleFormat.DEFAULT_NO_CACHE.getLocale("__"));
+ fail();
+ }
+ catch (ConversionException expected)
+ {
+ }
+ try
+ {
+ LocaleFormat.DEFAULT.getLocale("_");
+ fail();
+ }
+ catch (ConversionException expected)
+ {
+ }
+ }
+
+ public void testToStringFromDefaultFormat() throws ConversionException
+ {
+ assertEquals("a", LocaleFormat.DEFAULT_NO_CACHE.toString(new Locale("a")));
+ assertEquals("", LocaleFormat.DEFAULT_NO_CACHE.toString(new Locale("")));
+
+ //
+ assertEquals("", LocaleFormat.DEFAULT_NO_CACHE.toString(new Locale("", "")));
+ assertEquals("a_B", LocaleFormat.DEFAULT_NO_CACHE.toString(new Locale("a", "b")));
+ assertEquals("a", LocaleFormat.DEFAULT_NO_CACHE.toString(new Locale("a", "")));
+ assertEquals("_A", LocaleFormat.DEFAULT_NO_CACHE.toString(new Locale("", "a")));
+
+ //
+ assertEquals("a_B_c", LocaleFormat.DEFAULT_NO_CACHE.toString(new Locale("a", "b", "c")));
+ assertEquals("_A_b", LocaleFormat.DEFAULT_NO_CACHE.toString(new Locale("", "a", "b")));
+ assertEquals("a__b", LocaleFormat.DEFAULT_NO_CACHE.toString(new Locale("a", "", "b")));
+ assertEquals("a_B", LocaleFormat.DEFAULT_NO_CACHE.toString(new Locale("a", "b", "")));
+ assertEquals("", LocaleFormat.DEFAULT_NO_CACHE.toString(new Locale("", "", "a")));
+ assertEquals("a", LocaleFormat.DEFAULT_NO_CACHE.toString(new Locale("a", "", "")));
+ assertEquals("_A", LocaleFormat.DEFAULT_NO_CACHE.toString(new Locale("", "a", "")));
+ assertEquals("", LocaleFormat.DEFAULT_NO_CACHE.toString(new Locale("", "", "")));
+ }
+
+ public void testGetLocaleFromRFC3066LanguageTag() throws ConversionException
+ {
+ assertEquals(new Locale("en"), LocaleFormat.RFC3066_LANGUAGE_TAG_NO_CACHE.getLocale("en"));
+ assertEquals(new Locale("en", "US"), LocaleFormat.RFC3066_LANGUAGE_TAG_NO_CACHE.getLocale("en-US"));
+
+ try
+ {
+ LocaleFormat.RFC3066_LANGUAGE_TAG_NO_CACHE.getLocale("wrong");
+ fail("Should have failed since an invalid String was passed.");
+ }
+ catch (FormatConversionException e)
+ {
+ //expected
+ }
+
+ try
+ {
+ LocaleFormat.RFC3066_LANGUAGE_TAG_NO_CACHE.getLocale("zz");
+ fail("Should have failed since an invalid language code was passed.");
+ }
+ catch (FormatConversionException e)
+ {
+ //expected
+ }
+
+ try
+ {
+ LocaleFormat.RFC3066_LANGUAGE_TAG_NO_CACHE.getLocale("fr-ZZ");
+ fail("Should have failed since an invalid country code was passed.");
+ }
+ catch (FormatConversionException e)
+ {
+ //expected
+ }
+
+ // weird combination should work as well
+ LocaleFormat.RFC3066_LANGUAGE_TAG_NO_CACHE.getLocale("fr-US");
+ }
+
+ public void testGetRFC3066LanguageTagFromLocale() throws ConversionException
+ {
+ assertEquals("en", LocaleFormat.RFC3066_LANGUAGE_TAG_NO_CACHE.toString(new Locale("en")));
+ assertEquals("en-US", LocaleFormat.RFC3066_LANGUAGE_TAG_NO_CACHE.toString(new Locale("en", "US")));
+ }
+
+ public void testCachingLocaleFormat() throws ConversionException
+ {
+ TestLocaleFormat delegate = new TestLocaleFormat();
+ delegate.put(new Locale("abc"), "abc");
+ CachingLocaleFormat format = new CachingLocaleFormat(delegate);
+
+ //
+ assertEquals(new Locale("abc"), format.getLocale("abc"));
+ assertEquals("abc", format.toString(new Locale("abc")));
+
+ //
+ try
+ {
+ format.getLocale("def");
+ fail();
+ }
+ catch (ConversionException e)
+ {
+ }
+
+ //
+ try
+ {
+ format.toString(new Locale("def"));
+ fail();
+ }
+ catch (ConversionException e)
+ {
+ }
+ }
+
+ private static class TestLocaleFormat extends AbstractLocaleFormat
+ {
+
+ /** . */
+ private final Map localeToString = new HashMap();
+
+ /** . */
+ private final Map stringToLocale = new HashMap();
+
+ private void put(Locale locale, String string)
+ {
+ localeToString.put(locale, string);
+ stringToLocale.put(string, locale);
+ }
+
+ protected Locale internalGetLocale(String value) throws ConversionException
+ {
+ Locale locale = (Locale)stringToLocale.get(value);
+ if (locale == null)
+ {
+ throw new ConversionException();
+ }
+ return locale;
+ }
+
+ protected void internalWrite(Locale locale, Writer writer) throws IOException, ConversionException
+ {
+ String string = (String)localeToString.get(locale);
+ if (string == null)
+ {
+ throw new ConversionException();
+ }
+ writer.write(string);
+ }
+ }
+
+}
Added: modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/LocalizedStringTestCase.java
===================================================================
--- modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/LocalizedStringTestCase.java (rev 0)
+++ modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/LocalizedStringTestCase.java 2007-09-12 18:29:07 UTC (rev 8246)
@@ -0,0 +1,77 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.test.common;
+
+import junit.framework.TestCase;
+import org.jboss.portal.common.i18n.LocalizedString;
+
+import java.util.HashMap;
+import java.util.Locale;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a>
+ * @version $Revision: 6818 $
+ */
+public class LocalizedStringTestCase extends TestCase
+{
+ private Map values = new HashMap();
+ private LocalizedString localizedString;
+
+ protected void setUp() throws Exception
+ {
+ values.put(Locale.ENGLISH, "labour");
+ values.put(Locale.FRENCH, "travail");
+ values.put(Locale.US, "labor");
+ localizedString = new LocalizedString(values, Locale.US);
+ }
+
+ public void testPreferredOrBestLocalizedMappingFor()
+ {
+ try
+ {
+ localizedString.getPreferredOrBestLocalizedMappingFor(null);
+ fail("LocalizedString get most appropriate value for should have thrown an IllegalArgumentException with a null argument");
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+
+ // no desired locales: should return default
+ checkValueAndLocale(Locale.US, new String[]{});
+
+ checkValueAndLocale(Locale.ENGLISH, new String[]{"en", "en-US", "aa"});
+ checkValueAndLocale(Locale.US, new String[]{"en-US", "en", "aa"});
+ checkValueAndLocale(Locale.FRENCH, new String[]{"fr-CA"});
+ }
+
+ private void checkValueAndLocale(Locale locale, String[] desiredLocales)
+ {
+ LocalizedString.Value mapping = localizedString.getPreferredOrBestLocalizedMappingFor(desiredLocales);
+
+ Locale foundLocale = mapping.getLocale();
+ assertEquals(locale, foundLocale);
+ assertEquals(values.get(foundLocale), mapping.getString());
+ assertEquals(mapping.getString(), localizedString.getMostAppropriateValueFor(desiredLocales));
+ }
+}
Added: modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/MarkupTestCase.java
===================================================================
--- modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/MarkupTestCase.java (rev 0)
+++ modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/MarkupTestCase.java 2007-09-12 18:29:07 UTC (rev 8246)
@@ -0,0 +1,115 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.test.common;
+
+import junit.framework.TestCase;
+import org.jboss.portal.common.markup.MarkupAttribute;
+import org.jboss.portal.common.markup.MarkupElement;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class MarkupTestCase extends TestCase
+{
+
+ public void testAttributeConstructor()
+ {
+ try
+ {
+ new MarkupAttribute(null, "value", MarkupAttribute.Type.CDATA);
+ fail("Was expecting an IAE");
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ try
+ {
+ new MarkupAttribute("name", null, MarkupAttribute.Type.CDATA);
+ fail("Was expecting an IAE");
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ try
+ {
+ new MarkupAttribute("name", "value", null);
+ fail("Was expecting an IAE");
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ MarkupAttribute attribute = new MarkupAttribute("name", "value", MarkupAttribute.Type.CDATA);
+ assertEquals("name", attribute.getName());
+ assertEquals("value", attribute.getValue());
+ assertEquals(MarkupAttribute.Type.CDATA, attribute.getType());
+ }
+
+ public void testElementContructor()
+ {
+ try
+ {
+ new MarkupElement(null, "body", false, new MarkupAttribute[0]);
+ fail("Was expecting an IAE");
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ try
+ {
+ new MarkupElement("name", "body", false, null);
+ fail("Was expecting an IAE");
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ try
+ {
+ new MarkupElement("name", "body", false, new MarkupAttribute[]{null});
+ fail("Was expecting an IAE");
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ MarkupElement element = new MarkupElement("elementname", "body", false, new MarkupAttribute[]{new MarkupAttribute("attributename", "attributevalue", MarkupAttribute.Type.CDATA)});
+ assertEquals("elementname", element.getName());
+ assertEquals("body", element.getBodyContent());
+ assertEquals(false, element.isNeverEmpty());
+ assertEquals(1, element.getAttributeSize());
+ MarkupAttribute attribute = element.getAttribute(0);
+ assertEquals("attributename", attribute.getName());
+ assertEquals("attributevalue", attribute.getValue());
+ assertEquals(MarkupAttribute.Type.CDATA, attribute.getType());
+ attribute = element.getAttribute("attributename");
+ assertEquals("attributename", attribute.getName());
+ assertEquals("attributevalue", attribute.getValue());
+ assertEquals(MarkupAttribute.Type.CDATA, attribute.getType());
+ assertEquals(null, element.getAttribute("someotherattributename"));
+ }
+
+ public void testAttributeURIEncoding()
+ {
+ MarkupAttribute attribute = new MarkupAttribute("name", "/-_.*ABCabc012# ", MarkupAttribute.Type.URI);
+ assertEquals("/-_.*ABCabc012%23+", attribute.getEncodedValue());
+ }
+}
Added: modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/ParameterMapTestCase.java
===================================================================
--- modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/ParameterMapTestCase.java (rev 0)
+++ modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/ParameterMapTestCase.java 2007-09-12 18:29:07 UTC (rev 8246)
@@ -0,0 +1,143 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.test.common;
+
+import junit.framework.TestCase;
+import org.jboss.portal.common.util.ParameterMap;
+
+import java.util.HashMap;
+import java.util.Set;
+import java.util.Iterator;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 6643 $
+ */
+public class ParameterMapTestCase extends TestCase
+{
+
+ public void testPut()
+ {
+ ParameterMap pm = new ParameterMap(new HashMap());
+ pm.put("foo", new String[]{"bar"});
+ // ExtendedAssert.assertEquals(new String[]{"bar"}, (Object[])pm.get("foo"));
+ }
+
+ public void testEntry()
+ {
+ ParameterMap pm = new ParameterMap(new HashMap());
+ pm.put("foo", new String[]{"bar"});
+ Set entries = pm.entrySet();
+ assertNotNull(entries);
+ Iterator iterator = entries.iterator();
+ assertTrue(iterator.hasNext());
+ Object tmp = iterator.next();
+ assertTrue(tmp instanceof Map.Entry);
+ Map.Entry entry = (Map.Entry)tmp;
+ assertEquals("foo", entry.getKey());
+ // ExtendedAssert.assertEquals(new String[]{"bar"}, (Object[])entry.getValue());
+ }
+
+ public void testPutThrowsException()
+ {
+ ParameterMap pm = new ParameterMap(new HashMap());
+ try
+ {
+ pm.put(new Object(), new String[]{"bar"});
+ fail();
+ }
+ catch (ClassCastException expected)
+ {
+ }
+ try
+ {
+ pm.put("foo", new Object[]{});
+ fail();
+ }
+ catch (ClassCastException expected)
+ {
+ }
+ try
+ {
+ pm.put("foo", new String[]{});
+ fail();
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ try
+ {
+ pm.put("foo", new String[]{null});
+ fail();
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ }
+
+ public void testEntrySetValueThrowsException()
+ {
+ ParameterMap pm = new ParameterMap(new HashMap());
+ pm.put("foo", new String[]{"bar"});
+ Set entries = pm.entrySet();
+ assertNotNull(entries);
+ Iterator iterator = entries.iterator();
+ assertTrue(iterator.hasNext());
+ Object tmp = iterator.next();
+ assertTrue(tmp instanceof Map.Entry);
+ Map.Entry entry = (Map.Entry)tmp;
+ try
+ {
+ entry.setValue(null);
+ fail();
+ }
+ catch (NullPointerException expected)
+ {
+ }
+ try
+ {
+ entry.setValue(new Object[]{});
+ fail();
+ }
+ catch (ClassCastException expected)
+ {
+ }
+ try
+ {
+ entry.setValue(new String[]{});
+ fail();
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ try
+ {
+ entry.setValue(new String[]{null});
+ fail();
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ }
+}
Added: modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/ParentChildResourceBundleTestCase.java
===================================================================
--- modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/ParentChildResourceBundleTestCase.java (rev 0)
+++ modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/ParentChildResourceBundleTestCase.java 2007-09-12 18:29:07 UTC (rev 8246)
@@ -0,0 +1,115 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.test.common;
+
+import java.util.Arrays;
+import java.util.Enumeration;
+import java.util.HashSet;
+import java.util.Locale;
+import java.util.ResourceBundle;
+import java.util.Set;
+import java.util.Vector;
+
+import junit.framework.TestCase;
+
+import org.jboss.portal.common.i18n.ParentChildResourceBundle;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 6818 $
+ */
+public class ParentChildResourceBundleTestCase extends TestCase
+{
+ public ParentChildResourceBundleTestCase(String name)
+ {
+ super(name);
+ }
+
+ public void testBasic()
+ {
+ ResourceBundle parent = new ResourceBundle()
+ {
+ protected Object handleGetObject(String key)
+ {
+ if ("key-a".equals(key))
+ {
+ return "parent-a";
+ }
+ if ("key-b".equals(key))
+ {
+ return "parent-b";
+ }
+ return null;
+ }
+ public Enumeration getKeys()
+ {
+ Vector keys = new Vector();
+ keys.add("key-a");
+ keys.add("key-b");
+ return keys.elements();
+ }
+ public Locale getLocale()
+ {
+ return Locale.CHINA;
+ }
+ };
+ ResourceBundle child = new ResourceBundle()
+ {
+ protected Object handleGetObject(String key)
+ {
+ if ("key-a".equals(key))
+ {
+ return "child-a";
+ }
+ if ("key-c".equals(key))
+ {
+ return "child-c";
+ }
+ return null;
+ }
+ public Enumeration getKeys()
+ {
+ Vector keys = new Vector();
+ keys.add("key-a");
+ keys.add("key-c");
+ return keys.elements();
+ }
+ public Locale getLocale()
+ {
+ return Locale.GERMAN;
+ }
+ };
+ ResourceBundle bundle = new ParentChildResourceBundle(parent, child);
+ assertEquals(Locale.GERMAN, bundle.getLocale());
+ assertEquals("child-a", bundle.getString("key-a"));
+ assertEquals("parent-b", bundle.getString("key-b"));
+ assertEquals("child-c", bundle.getString("key-c"));
+ Set keys = new HashSet(Arrays.asList(new Object[]{"key-a","key-b","key-c"}));
+ for (Enumeration e = bundle.getKeys();e.hasMoreElements();)
+ {
+ assertTrue(keys.remove(e.nextElement()));
+ }
+ assertTrue(keys.isEmpty());
+ }
+
+}
Added: modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/PathMapperTestCase.java
===================================================================
--- modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/PathMapperTestCase.java (rev 0)
+++ modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/PathMapperTestCase.java 2007-09-12 18:29:07 UTC (rev 8246)
@@ -0,0 +1,156 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.test.common;
+
+import junit.framework.TestCase;
+import org.jboss.portal.common.path.PathMapper;
+import org.jboss.portal.common.path.PathMapperContext;
+import org.jboss.portal.common.path.PathMapperResult;
+import org.jboss.portal.common.path.SimplePathMapper;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 5448 $
+ */
+public class PathMapperTestCase extends TestCase
+{
+
+ public PathMapperTestCase(String s)
+ {
+ super(s);
+ }
+
+ private PathMapper mapper;
+
+ protected void setUp() throws Exception
+ {
+ mapper = new SimplePathMapper();
+ }
+
+ protected void tearDown() throws Exception
+ {
+ mapper = null;
+ }
+
+ public void testEmptyContext()
+ {
+ PathMapperContextImpl root = new PathMapperContextImpl(null);
+
+ assertEquals(new PathMapperResult(null, null, null), mapper.map(root, null));
+ assertEquals(new PathMapperResult(null, null, null), mapper.map(root, ""));
+ assertEquals(new PathMapperResult(null, null, "/"), mapper.map(root, "/"));
+ assertEquals(new PathMapperResult(null, null, "/"), mapper.map(root, "//"));
+
+ assertEquals(new PathMapperResult(null, null, "/a"), mapper.map(root, "/a"));
+ assertEquals(new PathMapperResult(null, null, "/a/"), mapper.map(root, "/a/"));
+ assertEquals(new PathMapperResult(null, null, "/a/b"), mapper.map(root, "/a/b"));
+ assertEquals(new PathMapperResult(null, null, "/a/b/"), mapper.map(root, "/a/b/"));
+ assertEquals(new PathMapperResult(null, null, "/a/b/c"), mapper.map(root, "/a/b/c"));
+ }
+
+ public void testOneChild()
+ {
+ PathMapperContextImpl root = new PathMapperContextImpl(null);
+ PathMapperContextImpl child = new PathMapperContextImpl(null);
+ root.addChild("a", child);
+
+ assertEquals(new PathMapperResult(null, null, null), mapper.map(root, null));
+ assertEquals(new PathMapperResult(null, null, null), mapper.map(root, ""));
+ assertEquals(new PathMapperResult(null, null, "/"), mapper.map(root, "/"));
+ assertEquals(new PathMapperResult(null, null, "/"), mapper.map(root, "//"));
+
+ assertEquals(new PathMapperResult(child, "/a", null), mapper.map(root, "/a"));
+ assertEquals(new PathMapperResult(child, "/a", "/"), mapper.map(root, "/a/"));
+ assertEquals(new PathMapperResult(child, "/a", "/b"), mapper.map(root, "/a/b"));
+ assertEquals(new PathMapperResult(child, "/a", "/b/"), mapper.map(root, "/a/b/"));
+ assertEquals(new PathMapperResult(child, "/a", "/b/c"), mapper.map(root, "/a/b/c"));
+
+ assertEquals(new PathMapperResult(null, null, "/b"), mapper.map(root, "/b"));
+ assertEquals(new PathMapperResult(null, null, "/b/"), mapper.map(root, "/b/"));
+ assertEquals(new PathMapperResult(null, null, "/b/c"), mapper.map(root, "/b/c"));
+ assertEquals(new PathMapperResult(null, null, "/b/c/"), mapper.map(root, "/b/c/"));
+ assertEquals(new PathMapperResult(null, null, "/b/c/d"), mapper.map(root, "/b/c/d"));
+ }
+
+ public void testOneChildHavingOneChild()
+ {
+ PathMapperContextImpl root = new PathMapperContextImpl(null);
+ PathMapperContextImpl child = new PathMapperContextImpl(null);
+ PathMapperContextImpl childOfChild = new PathMapperContextImpl(null);
+ root.addChild("a", child);
+ child.addChild("b", childOfChild);
+
+ assertEquals(new PathMapperResult(null, null, null), mapper.map(root, null));
+ assertEquals(new PathMapperResult(null, null, null), mapper.map(root, ""));
+ assertEquals(new PathMapperResult(null, null, "/"), mapper.map(root, "/"));
+ assertEquals(new PathMapperResult(null, null, "/"), mapper.map(root, "//"));
+
+ assertEquals(new PathMapperResult(child, "/a", null), mapper.map(root, "/a"));
+ assertEquals(new PathMapperResult(child, "/a", "/"), mapper.map(root, "/a/"));
+ assertEquals(new PathMapperResult(childOfChild, "/a/b", null), mapper.map(root, "/a/b"));
+ assertEquals(new PathMapperResult(child, "/a", "/b/"), mapper.map(root, "/a/b/"));
+ assertEquals(new PathMapperResult(child, "/a", "/b/c"), mapper.map(root, "/a/b/c"));
+
+ assertEquals(new PathMapperResult(null, null, "/b"), mapper.map(root, "/b"));
+ assertEquals(new PathMapperResult(null, null, "/b/"), mapper.map(root, "/b/"));
+ assertEquals(new PathMapperResult(null, null, "/b/c"), mapper.map(root, "/b/c"));
+ assertEquals(new PathMapperResult(null, null, "/b/c/"), mapper.map(root, "/b/c/"));
+ assertEquals(new PathMapperResult(null, null, "/b/c/d"), mapper.map(root, "/b/c/d"));
+ }
+
+ private static class Context
+ {
+ private final Map children;
+
+ public Context(Object dflt)
+ {
+ children = new HashMap();
+ }
+
+ public void addChild(String name, Object child)
+ {
+ children.put(name, child);
+ }
+ }
+
+ private static class PathMapperContextImpl extends Context implements PathMapperContext
+ {
+ public PathMapperContextImpl(Object dflt)
+ {
+ super(dflt);
+ }
+
+ public Object getRoot()
+ {
+ return this;
+ }
+
+ public Object getChild(Object parent, String name)
+ {
+ return ((Context)parent).children.get(name);
+ }
+ }
+}
Added: modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/PathTestCase.java
===================================================================
--- modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/PathTestCase.java (rev 0)
+++ modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/PathTestCase.java 2007-09-12 18:29:07 UTC (rev 8246)
@@ -0,0 +1,80 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.test.common;
+
+import junit.framework.TestCase;
+import org.jboss.portal.common.path.RelativePathParser;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 5451 $
+ */
+public class PathTestCase extends TestCase
+{
+
+ public void testSimpleDown()
+ {
+ String[] paths = {"abc","abc/","abc/."};
+ for (int i = 0; i < paths.length; i++)
+ {
+ String path = paths[i];
+ RelativePathParser cursor = new RelativePathParser(path);
+ assertEquals(RelativePathParser.DOWN, cursor.next());
+ assertEquals(0, cursor.getOffset());
+ assertEquals(3, cursor.getLength());
+ assertEquals("abc", path.substring(cursor.getOffset(), cursor.getLength()));
+ assertEquals(RelativePathParser.NONE, cursor.next());
+ assertEquals(-1, cursor.getOffset());
+ assertEquals(-1, cursor.getLength());
+ }
+ }
+
+ public void testSimpleNone()
+ {
+ String[] paths = {"",".","./","./."};
+ for (int i = 0; i < paths.length; i++)
+ {
+ String path = paths[i];
+ RelativePathParser cursor = new RelativePathParser(path);
+ assertEquals(RelativePathParser.NONE, cursor.next());
+ assertEquals(-1, cursor.getOffset());
+ assertEquals(-1, cursor.getLength());
+ }
+ }
+
+ public void testSimpleUp()
+ {
+ String[] paths = {"..","../","../."};
+ for (int i = 0; i < paths.length; i++)
+ {
+ String path = paths[i];
+ RelativePathParser cursor = new RelativePathParser(path);
+ assertEquals(RelativePathParser.UP, cursor.next());
+ assertEquals(-1, cursor.getOffset());
+ assertEquals(-1, cursor.getLength());
+ assertEquals(RelativePathParser.NONE, cursor.next());
+ assertEquals(-1, cursor.getOffset());
+ assertEquals(-1, cursor.getLength());
+ }
+ }
+}
Added: modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/StringTestCase.java
===================================================================
--- modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/StringTestCase.java (rev 0)
+++ modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/StringTestCase.java 2007-09-12 18:29:07 UTC (rev 8246)
@@ -0,0 +1,60 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.test.common;
+
+import junit.framework.TestCase;
+import org.jboss.portal.common.util.Tools;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 6305 $
+ */
+public class StringTestCase extends TestCase
+{
+
+ public StringTestCase(String name)
+ {
+ super(name);
+ }
+
+ public void testReplace()
+ {
+ assertEquals("", Tools.replace("", "abc", "def"));
+ assertEquals("defg", Tools.replace("abc", "abc", "defg"));
+ assertEquals("_defg_", Tools.replace("_abc_", "abc", "defg"));
+ assertEquals("_defgdefg_", Tools.replace("_abcabc_", "abc", "defg"));
+ assertEquals("_defg_defg_", Tools.replace("_abc_abc_", "abc", "defg"));
+ }
+
+ public void testReplaceBoundedString()
+ {
+ assertEquals("", Tools.replaceAllInstancesOfBoundedString("", "PREFIX", "SUFFIX", "REPLACEMENT"));
+ assertEquals("REPLACEMENT", Tools.replaceAllInstancesOfBoundedString("PREFIXSUFFIX", "PREFIX", "SUFFIX", "REPLACEMENT"));
+ assertEquals("PREFIXSUFFIX", Tools.replaceBoundedString("PREFIXSUFFIX", "PREFIX", "SUFFIX", "REPLACEMENT", false, true));
+ assertEquals("PREFIXSUFFIX", Tools.replaceBoundedString("PREFIXSUFFIX", "PREFIX", "SUFFIX", "REPLACEMENT", false, false));
+ assertEquals("aaaaREPLACEMENTccccc", Tools.replaceAllInstancesOfBoundedString("aaaaPREFIXbbbbbSUFFIXccccc", "PREFIX", "SUFFIX", "REPLACEMENT"));
+ assertEquals("aaaPREFIXbbbbSUFF", Tools.replaceAllInstancesOfBoundedString("aaaPREFIXbbbbSUFF", "PREFIX", "SUFFIX", "REPLACEMENT"));
+ assertEquals("aRcccReeeR", Tools.replaceAllInstancesOfBoundedString("aPbbScccPdSeeePS", "P", "S", "R"));
+ assertEquals("PSaPScccReeePS", Tools.replaceBoundedString("PSaPScccPdSeeePS", "P", "S", "R", false, false));
+ }
+}
Added: modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/TemporaryHashTestCase.java
===================================================================
--- modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/TemporaryHashTestCase.java (rev 0)
+++ modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/TemporaryHashTestCase.java 2007-09-12 18:29:07 UTC (rev 8246)
@@ -0,0 +1,64 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.test.common;
+
+import junit.framework.TestCase;
+
+import java.util.Calendar;
+
+import org.jboss.portal.common.util.Tools;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 5451 $
+ */
+public class TemporaryHashTestCase extends TestCase
+{
+
+ public TemporaryHashTestCase(String key)
+ {
+ super(key);
+ }
+
+ public void testBasic()
+ {
+ Calendar calendar = Calendar.getInstance();
+ calendar.set(2004, 1, 1, 1, 30, 0);
+ String hash = Tools.generateTemporaryHash("blah", calendar.getTimeInMillis());
+
+ calendar.set(2004, 1, 1, 1, 0, 0);
+ assertTrue(Tools.confirmTemporaryHash(hash, "blah", calendar.getTimeInMillis()));
+
+ calendar.set(2004, 1, 1, 0, 59, 59);
+ assertFalse(Tools.confirmTemporaryHash(hash, "blah", calendar.getTimeInMillis()));
+
+ calendar.set(2004, 1, 1, 2, 0, 0);
+ assertTrue(Tools.confirmTemporaryHash(hash, "blah", calendar.getTimeInMillis()));
+
+ calendar.set(2004, 1, 1, 2, 59, 59);
+ assertTrue(Tools.confirmTemporaryHash(hash, "blah", calendar.getTimeInMillis()));
+
+ calendar.set(2004, 1, 1, 3, 0, 0);
+ assertFalse(Tools.confirmTemporaryHash(hash, "blah", calendar.getTimeInMillis()));
+ }
+}
Added: modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/ToolsTestCase.java
===================================================================
--- modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/ToolsTestCase.java (rev 0)
+++ modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/ToolsTestCase.java 2007-09-12 18:29:07 UTC (rev 8246)
@@ -0,0 +1,47 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2007, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+
+package org.jboss.portal.test.common;
+
+import junit.framework.TestCase;
+import org.jboss.portal.common.util.Tools;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a>
+ * @version $Revision: 6384 $
+ * @since 2.6
+ */
+public class ToolsTestCase extends TestCase
+{
+ public void testIsContainedIn()
+ {
+ String value = "value";
+ String[] array = new String[]{"foo", "bar", value, "baz"};
+
+ assertTrue(Tools.isContainedIn(value, array));
+ assertFalse(Tools.isContainedIn(null, array));
+ assertFalse(Tools.isContainedIn(value, null));
+ assertFalse(Tools.isContainedIn(null, null));
+ assertFalse(Tools.isContainedIn("bat", array));
+ }
+}
Added: modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/TypedMapTestCase.java
===================================================================
--- modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/TypedMapTestCase.java (rev 0)
+++ modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/TypedMapTestCase.java 2007-09-12 18:29:07 UTC (rev 8246)
@@ -0,0 +1,454 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.test.common;
+
+import junit.framework.TestCase;
+import org.jboss.portal.common.util.CollectionBuilder;
+import org.jboss.portal.common.util.TypedMap;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class TypedMapTestCase extends TestCase
+{
+
+ public TypedMapTestCase(String name)
+ {
+ super(name);
+ }
+
+ public void testGetWithBrokenGetInternalValue()
+ {
+ StringToIntegerMap map = new StringToIntegerMap();
+ map.internalValueReturnsNull = true;
+ map.get("abc");
+ map.delegate.put("abc", new Integer(0));
+ map.get("abc");
+ }
+
+ public void testPutWithBrokenGetInternalValue()
+ {
+ StringToIntegerMap map = new StringToIntegerMap();
+ map.internalValueReturnsNull = true;
+ try
+ {
+ map.put("abc", "0");
+ fail();
+ }
+ catch (IllegalArgumentException e)
+ {
+ }
+ }
+
+ public void testRemoveWithBrokenGetInternalValue()
+ {
+ StringToIntegerMap map = new StringToIntegerMap();
+ map.internalValueReturnsNull = true;
+ map.remove("abc");
+ }
+
+ public void testRemoveWithBrokenGetExternalValue()
+ {
+ StringToIntegerMap map = new StringToIntegerMap();
+ map.externalValueReturnsNull = true;
+ map.remove("abc");
+ map.delegate.put("abc", new Integer(0));
+ try
+ {
+ map.remove("abc");
+ fail();
+ }
+ catch (IllegalStateException e)
+ {
+ }
+ }
+
+ public void testGetWithBrokenGetExternalValue()
+ {
+ StringToIntegerMap map = new StringToIntegerMap();
+ map.externalValueReturnsNull = true;
+ map.get("abc");
+ map.delegate.put("abc", new Integer(0));
+ try
+ {
+ map.get("abc");
+ fail();
+ }
+ catch (IllegalStateException e)
+ {
+ }
+ }
+
+ public void testPutWithBrokenGetExternalValue()
+ {
+ StringToIntegerMap map = new StringToIntegerMap();
+ map.externalValueReturnsNull = true;
+ map.put("abc", "0");
+ try
+ {
+ map.put("abc", "0");
+ fail();
+ }
+ catch (IllegalStateException e)
+ {
+ }
+ }
+
+ public void testGetWithInvalidInternalValue()
+ {
+ StringToIntegerMap map = new StringToIntegerMap();
+ map.delegate.put("abc", "0");
+ try
+ {
+ map.get("abc");
+ fail();
+ }
+ catch (ClassCastException expected)
+ {
+ }
+ }
+
+ public void testPutWithInvalidInternalValue()
+ {
+ StringToIntegerMap map = new StringToIntegerMap();
+ map.delegate.put("abc", "0");
+ try
+ {
+ map.put("abc", "0");
+ fail();
+ }
+ catch (ClassCastException expected)
+ {
+ }
+ }
+
+ public void testRemoveWithInvalidInternalValue()
+ {
+ StringToIntegerMap map = new StringToIntegerMap();
+ map.delegate.put("abc", "0");
+ try
+ {
+ map.remove("abc");
+ fail();
+ }
+ catch (ClassCastException expected)
+ {
+ }
+ }
+
+ public void testRemove()
+ {
+ StringToIntegerMap map = new StringToIntegerMap();
+ assertNull(map.remove("abc"));
+ map.delegate.put("abc", new Integer(0));
+ assertEquals("0", map.remove("abc"));
+ assertTrue(map.delegate.isEmpty());
+ }
+
+ public void testPut()
+ {
+ StringToIntegerMap map = new StringToIntegerMap();
+ map.put("abc", "0");
+ assertEquals(Collections.singletonMap("abc", new Integer(0)), map.delegate);
+ }
+
+ public void testGet()
+ {
+ StringToIntegerMap map = new StringToIntegerMap();
+ assertNull(map.get("abc"));
+ map.delegate.put("abc", new Integer(0));
+ assertEquals(Collections.singletonMap("abc", "0"), map);
+ }
+
+ public void testContainsKeyWithInvalidKey()
+ {
+ try
+ {
+ new StringToIntegerMap().containsKey(null);
+ fail();
+ }
+ catch (NullPointerException expected)
+ {
+ }
+ try
+ {
+ new StringToIntegerMap().containsKey(new Object());
+ fail();
+ }
+ catch (ClassCastException expected)
+ {
+ }
+ }
+
+ public void testContainsValueWithInvalidValue()
+ {
+ try
+ {
+ new StringToIntegerMap().containsValue(null);
+ fail();
+ }
+ catch (NullPointerException expected)
+ {
+ }
+ try
+ {
+ new StringToIntegerMap().containsValue(new Object());
+ fail();
+ }
+ catch (ClassCastException expected)
+ {
+ }
+ }
+
+ public void testRemoveWithInvalidKey()
+ {
+ try
+ {
+ new StringToIntegerMap().remove(null);
+ fail();
+ }
+ catch (NullPointerException expected)
+ {
+ }
+ try
+ {
+ new StringToIntegerMap().remove(new Object());
+ fail();
+ }
+ catch (ClassCastException expected)
+ {
+ }
+ }
+
+ public void testGetWithInvalidKey()
+ {
+ try
+ {
+ new StringToIntegerMap().get(null);
+ fail();
+ }
+ catch (NullPointerException expected)
+ {
+ }
+ try
+ {
+ new StringToIntegerMap().get(new Object());
+ fail();
+ }
+ catch (ClassCastException expected)
+ {
+ }
+ }
+
+ public void testPutWithInvalidKey()
+ {
+ try
+ {
+ new StringToIntegerMap().put(null, "0");
+ fail();
+ }
+ catch (NullPointerException expected)
+ {
+ }
+ try
+ {
+ new StringToIntegerMap().put(new Object(), "0");
+ fail();
+ }
+ catch (ClassCastException expected)
+ {
+ }
+ }
+
+ public void testWithPutInvalidValue()
+ {
+ try
+ {
+ new StringToIntegerMap().put("", null);
+ fail();
+ }
+ catch (NullPointerException expected)
+ {
+ }
+ try
+ {
+ new StringToIntegerMap().put("", new Object());
+ fail();
+ }
+ catch (ClassCastException expected)
+ {
+ }
+ }
+
+ public void testEquals()
+ {
+ StringToIntegerMap left = new StringToIntegerMap();
+ left.delegate.put("abc", new Integer(0));
+ Map right = new HashMap();
+
+ //
+ assertFalse(left.equals(right));
+ assertFalse(right.equals(left));
+
+ //
+ right.put("abc", new Object());
+ assertFalse(left.equals(right));
+ assertFalse(right.equals(left));
+
+ //
+ right.put("abc", "abc");
+ assertFalse(left.equals(right));
+ assertFalse(right.equals(left));
+
+ //
+ right.put("abc", "0");
+ assertTrue(left.equals(right));
+ assertTrue(right.equals(left));
+
+ //
+ right.put("def", "1");
+ assertFalse(left.equals(right));
+ assertFalse(right.equals(left));
+
+ //
+ right.remove("def");
+ right.put(null, "0");
+ assertFalse(left.equals(right));
+ assertFalse(right.equals(left));
+
+ //
+ right.remove(null);
+ right.put("def", null);
+ assertFalse(left.equals(right));
+ assertFalse(right.equals(left));
+ }
+
+ public void testEntrySetRetainAll()
+ {
+ Map right = new HashMap();
+ right.put("abc", new Integer(0));
+ right.put("def", new Integer(1));
+ right.put("ghi", new Integer(2));
+
+ //
+ StringToIntegerMap left = new StringToIntegerMap();
+ left.delegate.putAll(right);
+
+ try
+ {
+ left.keySet().retainAll(null);
+ fail("Was expecting NPE");
+ }
+ catch (NullPointerException expected)
+ {
+ }
+
+ //
+ boolean changed = left.keySet().retainAll(new CollectionBuilder().add("abc").add("def").add("ghi").toHashSet());
+ assertFalse(changed);
+ assertEquals(right, left.delegate);
+
+ //
+ changed = left.keySet().retainAll(new CollectionBuilder().add("def").toHashSet());
+ assertTrue(changed);
+ right.remove("abc");
+ right.remove("ghi");
+ assertEquals(right, left.delegate);
+ }
+
+ public static class StringToIntegerMap extends TypedMap
+ {
+
+ /** . */
+ final Map delegate;
+
+ /** . */
+ boolean internalValueReturnsNull = false;
+
+ /** . */
+ boolean externalValueReturnsNull = false;
+
+ public StringToIntegerMap()
+ {
+ super(new HashMap());
+
+ //
+ delegate = getDelegate(false);
+ }
+
+ protected void assertKeyValidity(Object key) throws ClassCastException
+ {
+ assertNotNull(key);
+ if (key instanceof String == false)
+ {
+ throw new ClassCastException();
+ }
+ }
+
+ protected Object getInternalValue(Object value) throws IllegalArgumentException, ClassCastException
+ {
+ assertNotNull(value);
+ if (internalValueReturnsNull)
+ {
+ return null;
+ }
+ String s = (String)value;
+ try
+ {
+ return new Integer(s);
+ }
+ catch (NumberFormatException e)
+ {
+ IllegalArgumentException iae = new IllegalArgumentException();
+ iae.initCause(e);
+ throw iae;
+ }
+ }
+
+ protected Object getExternalValue(Object value)
+ {
+ assertNotNull(value);
+ if (externalValueReturnsNull)
+ {
+ return null;
+ }
+ Integer i = (Integer)value;
+ return i.toString();
+ }
+
+ protected boolean internalValueEquals(Object left, Object right)
+ {
+ assertNotNull(left);
+ assertNotNull(right);
+ Integer li = (Integer)left;
+ Integer ri = (Integer)right;
+ return li.intValue() == ri.intValue();
+ }
+ }
+
+}
Added: modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/ValueTestCase.java
===================================================================
--- modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/ValueTestCase.java (rev 0)
+++ modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/ValueTestCase.java 2007-09-12 18:29:07 UTC (rev 8246)
@@ -0,0 +1,222 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.test.common;
+
+import junit.framework.TestCase;
+
+import org.jboss.portal.common.value.Value;
+import org.jboss.portal.common.value.IntegerValue;
+import org.jboss.portal.common.value.StringValue;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 5451 $
+ */
+public class ValueTestCase extends TestCase
+{
+ public ValueTestCase(String s)
+ {
+ super(s);
+ }
+
+
+ public void testIntegerValueWithNull() throws Exception
+ {
+ _testNullInteger(new IntegerValue());
+ _testNullInteger(new IntegerValue((Integer)null));
+ _testNullInteger(new IntegerValue((String)null));
+ _testNullInteger(new IntegerValue(new Integer[1]));
+ _testNullInteger(new IntegerValue(new String[1]));
+ }
+
+ private void _testNullInteger(Value value) throws Exception
+ {
+ assertFalse(value.isInstanceOf(String.class));
+ assertTrue(value.isInstanceOf(Number.class));
+ assertTrue(value.isInstanceOf(Integer.class));
+ assertTrue(value.isNull());
+ assertEquals(1, value.size());
+ assertFalse(value.isMultiValued());
+ assertFalse(value.isEmpty());
+ assertNull(value.asString());
+ assertEquals(null, value.asObject());
+ assertNotNull(value.asStringArray());
+ assertEquals(1, value.asStringArray().length);
+ assertNull(value.asStringArray()[0]);
+ assertTrue(value.asObjectArray() instanceof Integer[]);
+ assertEquals(1, value.asObjectArray().length);
+ assertNull(value.asObjectArray()[0]);
+ }
+
+ public void testIntegerValueEmptyArray() throws Exception
+ {
+ _testIntegerValueEmptyArray(new IntegerValue(new Integer[0]));
+ _testIntegerValueEmptyArray(new IntegerValue(new int[0]));
+ _testIntegerValueEmptyArray(new IntegerValue(new String[0]));
+ }
+
+ public void _testIntegerValueEmptyArray(Value value) throws Exception
+ {
+ assertFalse(value.isInstanceOf(String.class));
+ assertTrue(value.isInstanceOf(Number.class));
+ assertTrue(value.isInstanceOf(Integer.class));
+ assertTrue(value.isNull());
+ assertEquals(0, value.size());
+ assertFalse(value.isMultiValued());
+ assertTrue(value.isEmpty());
+ assertNull(value.asString());
+ assertNull(value.asObject());
+ assertTrue(value.asObjectArray() instanceof Integer[]);
+ assertEquals(0, value.asObjectArray().length);
+ assertNotNull(value.asStringArray());
+ assertEquals(0, value.asStringArray().length);
+ }
+
+ public void testIntegerValueNonNullInteger() throws Exception
+ {
+ _testIntegerValueNonNullInteger(new IntegerValue(1));
+ _testIntegerValueNonNullInteger(new IntegerValue(new Integer(1)));
+ _testIntegerValueNonNullInteger(new IntegerValue(new int[]{1}));
+ _testIntegerValueNonNullInteger(new IntegerValue(new Integer[]{new Integer(1)}));
+ _testIntegerValueNonNullInteger(new IntegerValue("1"));
+ _testIntegerValueNonNullInteger(new IntegerValue(new String[]{"1"}));
+ }
+
+ private void _testIntegerValueNonNullInteger(Value value) throws Exception
+ {
+ assertFalse(value.isInstanceOf(String.class));
+ assertTrue(value.isInstanceOf(Number.class));
+ assertTrue(value.isInstanceOf(Integer.class));
+ assertFalse(value.isNull());
+ assertEquals(1, value.size());
+ assertFalse(value.isMultiValued());
+ assertFalse(value.isEmpty());
+ assertEquals("1", value.asString());
+ assertEquals(new Integer(1), value.asObject());
+ assertNotNull(value.asStringArray());
+ assertEquals(1, value.asStringArray().length);
+ assertEquals("1", value.asStringArray()[0]);
+ assertTrue(value.asObjectArray() instanceof Integer[]);
+ assertEquals(1, value.asObjectArray().length);
+ assertEquals(new Integer(1), value.asObjectArray()[0]);
+ }
+
+ public void testIntegerValueIntegerArray() throws Exception
+ {
+ _testIntegerValueIntegerArray(new IntegerValue(new int[]{1,2}));
+ _testIntegerValueIntegerArray(new IntegerValue(new Integer[]{new Integer(1), new Integer(2)}));
+ _testIntegerValueIntegerArray(new IntegerValue(new String[]{"1","2"}));
+ }
+
+ private void _testIntegerValueIntegerArray(Value value) throws Exception
+ {
+ assertFalse(value.isInstanceOf(String.class));
+ assertTrue(value.isInstanceOf(Number.class));
+ assertTrue(value.isInstanceOf(Integer.class));
+ assertFalse(value.isNull());
+ assertEquals(2, value.size());
+ assertTrue(value.isMultiValued());
+ assertFalse(value.isEmpty());
+ assertEquals("1", value.asString());
+ assertEquals(new Integer(1), value.asObject());
+ assertNotNull(value.asStringArray());
+ assertEquals(2, value.asStringArray().length);
+ assertEquals("1", value.asStringArray()[0]);
+ assertEquals("2", value.asStringArray()[1]);
+ assertTrue(value.asObjectArray() instanceof Integer[]);
+ assertEquals(2, value.asObjectArray().length);
+ assertEquals(new Integer(1), value.asObjectArray()[0]);
+ assertEquals(new Integer(2), value.asObjectArray()[1]);
+ }
+
+ public void testIntegerValueIntegerArrayWithNull() throws Exception
+ {
+ _testIntegerValueIntegerArrayWithNull(new IntegerValue(new Integer[]{null, new Integer(1)}));
+ _testIntegerValueIntegerArrayWithNull(new IntegerValue(new String[]{null, "1"}));
+ }
+
+ private void _testIntegerValueIntegerArrayWithNull(Value value) throws Exception
+ {
+ assertFalse(value.isInstanceOf(String.class));
+ assertTrue(value.isInstanceOf(Number.class));
+ assertTrue(value.isInstanceOf(Integer.class));
+ assertTrue(value.isNull());
+ assertEquals(2, value.size());
+ assertTrue(value.isMultiValued());
+ assertFalse(value.isEmpty());
+ assertEquals(null, value.asString());
+ assertEquals(null, value.asObject());
+ assertNotNull(value.asStringArray());
+ assertEquals(2, value.asStringArray().length);
+ assertEquals(null, value.asStringArray()[0]);
+ assertEquals("1", value.asStringArray()[1]);
+ assertTrue(value.asObjectArray() instanceof Integer[]);
+ assertEquals(2, value.asObjectArray().length);
+ assertEquals(null, value.asObjectArray()[0]);
+ assertEquals(new Integer(1), value.asObjectArray()[1]);
+ }
+
+ public void testClone() throws Exception
+ {
+ StringValue a = new StringValue("abc");
+ Object b = a.clone();
+ assertTrue(b instanceof StringValue);
+ StringValue c = (StringValue)b;
+ assertEquals(a, c);
+
+ //
+ StringValue d = new StringValue(new String[]{"abc","def"});
+ Object e = d.clone();
+ assertTrue(e instanceof StringValue);
+ StringValue f = (StringValue)e;
+ assertEquals(d, f);
+ }
+
+ public void testEqualsOnStringValues()
+ {
+ assertEquals(new StringValue(), new StringValue());
+ assertEquals(new StringValue(), new StringValue((String)null));
+ assertEquals(new StringValue(), new StringValue(new String[0]));
+ assertEquals(new StringValue(), new StringValue(new String[]{null}));
+ assertEquals(new StringValue((String)null), new StringValue());
+ assertEquals(new StringValue((String)null), new StringValue((String)null));
+ assertEquals(new StringValue((String)null), new StringValue(new String[0]));
+ assertEquals(new StringValue((String)null), new StringValue(new String[]{null}));
+ assertEquals(new StringValue(new String[0]), new StringValue());
+ assertEquals(new StringValue(new String[0]), new StringValue((String)null));
+ assertEquals(new StringValue(new String[0]), new StringValue(new String[0]));
+ assertEquals(new StringValue(new String[0]), new StringValue(new String[]{null}));
+ assertEquals(new StringValue(new String[]{null}), new StringValue());
+ assertEquals(new StringValue(new String[]{null}), new StringValue((String)null));
+ assertEquals(new StringValue(new String[]{null}), new StringValue(new String[0]));
+ assertEquals(new StringValue(new String[]{null}), new StringValue(new String[]{null}));
+ }
+
+ public void testUnmodifiable()
+ {
+ StringValue a = new StringValue("abc");
+ String[] b = (String[])a.asObjectArray();
+ b[0] = "def";
+ assertEquals("abc", a.asString());
+ }
+}
Added: modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/ValveTestCase.java
===================================================================
--- modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/ValveTestCase.java (rev 0)
+++ modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/ValveTestCase.java 2007-09-12 18:29:07 UTC (rev 8246)
@@ -0,0 +1,189 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.test.common;
+
+import java.io.PrintStream;
+
+import junit.framework.TestCase;
+
+import org.jboss.portal.common.concurrent.Valve;
+
+import EDU.oswego.cs.dl.util.concurrent.CyclicBarrier;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 5451 $
+ */
+public class ValveTestCase extends TestCase
+{
+
+ public ValveTestCase(String key)
+ {
+ super(key);
+ }
+
+ public static final PrintStream out = System.out;
+
+ public void testTransitions()
+ {
+ Valve valve = new Valve();
+ assertEquals(Valve.CLOSED, valve.getState());
+ assertFalse(valve.beforeInvocation());
+ try
+ {
+ valve.closing(10);
+ fail("IllegalStateException expected");
+ }
+ catch (IllegalStateException expected)
+ {
+ }
+ try
+ {
+ valve.closing();
+ fail("IllegalStateException expected");
+ }
+ catch (IllegalStateException expected)
+ {
+ }
+ try
+ {
+ valve.closed();
+ fail("IllegalStateException expected");
+ }
+ catch (IllegalStateException expected)
+ {
+ }
+
+ // Open the valve
+ valve.open();
+ try
+ {
+ assertTrue(valve.beforeInvocation());
+ }
+ finally
+ {
+ valve.afterInvocation();
+ }
+ try
+ {
+ valve.open();
+ fail("IllegalStateException expected");
+ }
+ catch (IllegalStateException e)
+ {
+ }
+ try
+ {
+ valve.closed();
+ fail("IllegalStateException expected");
+ }
+ catch (IllegalStateException e)
+ {
+ }
+
+
+ // Closing the valve
+ valve.closing();
+ assertEquals(Valve.CLOSING, valve.getState());
+ assertFalse(valve.beforeInvocation());
+ try
+ {
+ valve.open();
+ fail("IllegalStateException expected");
+ }
+ catch (IllegalStateException e)
+ {
+ }
+ valve.closing();
+
+ // Close the valve
+ valve.closed();
+ assertEquals(Valve.CLOSED, valve.getState());
+ }
+
+ public void testTimeOut() throws Exception
+ {
+ final Valve valve = new Valve();
+ final CyclicBarrier barrier = new CyclicBarrier(2);
+
+ Thread thread = new Thread()
+ {
+ public void run()
+ {
+ try
+ {
+ assertTrue(valve.beforeInvocation());
+
+ // The valve is enterred
+ barrier.barrier();
+
+ // Wait
+ barrier.barrier();
+ }
+ catch (InterruptedException ignore)
+ {
+ }
+ finally
+ {
+ valve.afterInvocation();
+ try
+ {
+ // Tell the other thread we have finished
+ barrier.barrier();
+ }
+ catch (InterruptedException ignore)
+ {
+ }
+ }
+ }
+ };
+
+ // Open valve and start thread
+ valve.open();
+ thread.start();
+
+ // Wait until the thread called beforeInvocation
+ barrier.barrier();
+
+ // Attemtp to close
+ assertFalse(valve.closing(100));
+
+ // Check it is in closing state
+ assertEquals(Valve.CLOSING, valve.getState());
+
+ // Ask the invoker thread to finish
+ barrier.barrier();
+
+ // Wait until invocation is finished
+ barrier.barrier();
+
+ // Close, no thread are inside
+ valve.closing();
+ assertEquals(Valve.CLOSING, valve.getState());
+
+ //
+ valve.closed();
+ assertEquals(Valve.CLOSED, valve.getState());
+ }
+
+}
Added: modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/adapter/Adapted1.java
===================================================================
--- modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/adapter/Adapted1.java (rev 0)
+++ modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/adapter/Adapted1.java 2007-09-12 18:29:07 UTC (rev 8246)
@@ -0,0 +1,47 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.test.common.adapter;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class Adapted1 implements Business1
+{
+
+ /** . */
+ int business1MethodCount;
+
+ /** . */
+ int commonMethodCount;
+
+ public void business1Method()
+ {
+ business1MethodCount++;
+ }
+
+ public void commonMethod()
+ {
+ commonMethodCount++;
+ }
+}
Added: modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/adapter/Adapted2.java
===================================================================
--- modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/adapter/Adapted2.java (rev 0)
+++ modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/adapter/Adapted2.java 2007-09-12 18:29:07 UTC (rev 8246)
@@ -0,0 +1,47 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.test.common.adapter;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class Adapted2 implements Business2
+{
+
+ /** . */
+ int business2MethodCount;
+
+ /** . */
+ int commonMethodCount;
+
+ public void business2Method()
+ {
+ business2MethodCount++;
+ }
+
+ public void commonMethod()
+ {
+ commonMethodCount++;
+ }
+}
Added: modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/adapter/AdapterTestCase.java
===================================================================
--- modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/adapter/AdapterTestCase.java (rev 0)
+++ modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/adapter/AdapterTestCase.java 2007-09-12 18:29:07 UTC (rev 8246)
@@ -0,0 +1,162 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.test.common.adapter;
+
+import junit.framework.TestCase;
+import org.jboss.portal.common.adapter.ClassAdapter;
+import org.jboss.portal.common.adapter.ClassAdapted;
+import org.jboss.portal.common.adapter.ClassAdaptable;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class AdapterTestCase extends TestCase
+{
+
+ Adapted1 adapted1;
+ Adapted2 adapted2;
+ ObjectAdapted objectAdapted;
+ ClassAdaptable adaptable;
+
+ protected void setUp() throws Exception
+ {
+ adapted1 = new Adapted1();
+ adapted2 = new Adapted2();
+ objectAdapted = new ObjectAdapted();
+ ClassAdapted[] adapteds = new ClassAdapted[]{new ClassAdapted(Business1.class, adapted1),new ClassAdapted(Business2.class, adapted2)};
+ ClassAdapter adapter = new ClassAdapter(Thread.currentThread().getContextClassLoader(), adapteds, objectAdapted);
+ adaptable = adapter.getAdaptable();
+ }
+
+
+ protected void tearDown() throws Exception
+ {
+ adapted1 = null;
+ adapted2 = null;
+ objectAdapted = null;
+ adaptable = null;
+ }
+
+ public void testImplementedInterfaces()
+ {
+ assertTrue(adaptable instanceof Business1);
+ assertTrue(adaptable instanceof Business2);
+ }
+
+ public void testObjectMethodCall() throws Exception
+ {
+ assertEquals(0, adapted1.business1MethodCount);
+ assertEquals(0, adapted1.commonMethodCount);
+ assertEquals(0, adapted2.business2MethodCount);
+ assertEquals(0, adapted2.commonMethodCount);
+ assertEquals(0, objectAdapted.toStringCount);
+ assertEquals(0, objectAdapted.hashCodeCount);
+ assertEquals(0, objectAdapted.equalsCount);
+
+ //
+ assertEquals("Foo", adaptable.toString());
+ assertEquals(0, adapted1.business1MethodCount);
+ assertEquals(0, adapted1.commonMethodCount);
+ assertEquals(0, adapted2.business2MethodCount);
+ assertEquals(0, adapted2.commonMethodCount);
+ assertEquals(1, objectAdapted.toStringCount);
+ assertEquals(0, objectAdapted.hashCodeCount);
+ assertEquals(0, objectAdapted.equalsCount);
+
+ //
+ assertEquals(1234, adaptable.hashCode());
+ assertEquals(0, adapted1.business1MethodCount);
+ assertEquals(0, adapted1.commonMethodCount);
+ assertEquals(0, adapted2.business2MethodCount);
+ assertEquals(0, adapted2.commonMethodCount);
+ assertEquals(1, objectAdapted.toStringCount);
+ assertEquals(1, objectAdapted.hashCodeCount);
+ assertEquals(0, objectAdapted.equalsCount);
+
+ //
+ assertEquals(true, adaptable.equals(Boolean.TRUE));
+ assertEquals(0, adapted1.business1MethodCount);
+ assertEquals(0, adapted1.commonMethodCount);
+ assertEquals(0, adapted2.business2MethodCount);
+ assertEquals(0, adapted2.commonMethodCount);
+ assertEquals(1, objectAdapted.toStringCount);
+ assertEquals(1, objectAdapted.hashCodeCount);
+ assertEquals(1, objectAdapted.equalsCount);
+
+ //
+ assertEquals(false, adaptable.equals(Boolean.FALSE));
+ assertEquals(0, adapted1.business1MethodCount);
+ assertEquals(0, adapted1.commonMethodCount);
+ assertEquals(0, adapted2.business2MethodCount);
+ assertEquals(0, adapted2.commonMethodCount);
+ assertEquals(1, objectAdapted.toStringCount);
+ assertEquals(1, objectAdapted.hashCodeCount);
+ assertEquals(2, objectAdapted.equalsCount);
+ }
+
+ public void testBusinessMethodCall() throws Exception
+ {
+ assertEquals(0, adapted1.business1MethodCount);
+ assertEquals(0, adapted1.commonMethodCount);
+ assertEquals(0, adapted2.business2MethodCount);
+ assertEquals(0, adapted2.commonMethodCount);
+ assertEquals(0, objectAdapted.toStringCount);
+ assertEquals(0, objectAdapted.hashCodeCount);
+ assertEquals(0, objectAdapted.equalsCount);
+
+ //
+ Business1 business1Adapter = (Business1)adaptable;
+ Business2 business2Adapter = (Business2)adaptable;
+
+ //
+ business1Adapter.business1Method();
+ assertEquals(1, adapted1.business1MethodCount);
+ assertEquals(0, adapted1.commonMethodCount);
+ assertEquals(0, adapted2.business2MethodCount);
+ assertEquals(0, adapted2.commonMethodCount);
+ assertEquals(0, objectAdapted.toStringCount);
+ assertEquals(0, objectAdapted.hashCodeCount);
+ assertEquals(0, objectAdapted.equalsCount);
+
+ //
+ business2Adapter.business2Method();
+ assertEquals(1, adapted1.business1MethodCount);
+ assertEquals(0, adapted1.commonMethodCount);
+ assertEquals(1, adapted2.business2MethodCount);
+ assertEquals(0, adapted2.commonMethodCount);
+ assertEquals(0, objectAdapted.toStringCount);
+ assertEquals(0, objectAdapted.hashCodeCount);
+ assertEquals(0, objectAdapted.equalsCount);
+
+ //
+ business1Adapter.commonMethod();
+ assertEquals(1, adapted1.business1MethodCount);
+ assertEquals(1, adapted1.commonMethodCount);
+ assertEquals(1, adapted2.business2MethodCount);
+ assertEquals(0, adapted2.commonMethodCount);
+ assertEquals(0, objectAdapted.toStringCount);
+ assertEquals(0, objectAdapted.hashCodeCount);
+ assertEquals(0, objectAdapted.equalsCount);
+ }
+}
Added: modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/adapter/Business1.java
===================================================================
--- modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/adapter/Business1.java (rev 0)
+++ modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/adapter/Business1.java 2007-09-12 18:29:07 UTC (rev 8246)
@@ -0,0 +1,33 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.test.common.adapter;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public interface Business1
+{
+ void business1Method();
+ void commonMethod();
+}
Added: modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/adapter/Business2.java
===================================================================
--- modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/adapter/Business2.java (rev 0)
+++ modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/adapter/Business2.java 2007-09-12 18:29:07 UTC (rev 8246)
@@ -0,0 +1,33 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.test.common.adapter;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public interface Business2
+{
+ void business2Method();
+ void commonMethod();
+}
Added: modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/adapter/ObjectAdapted.java
===================================================================
--- modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/adapter/ObjectAdapted.java (rev 0)
+++ modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/adapter/ObjectAdapted.java 2007-09-12 18:29:07 UTC (rev 8246)
@@ -0,0 +1,56 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.test.common.adapter;
+
+import org.jboss.portal.common.adapter.JavaLangObjectAdapted;
+import org.jboss.portal.common.adapter.ClassAdaptable;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class ObjectAdapted implements JavaLangObjectAdapted
+{
+
+ int toStringCount;
+ int hashCodeCount;
+ int equalsCount;
+
+ public String toString(ClassAdaptable adaptable)
+ {
+ toStringCount++;
+ return "Foo";
+ }
+
+ public int hashCode(ClassAdaptable adaptable)
+ {
+ hashCodeCount++;
+ return 1234;
+ }
+
+ public boolean equals(ClassAdaptable adaptable, Object obj)
+ {
+ equalsCount++;
+ return ((Boolean)obj).booleanValue();
+ }
+}
Added: modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/http/QueryStringParserTestCase.java
===================================================================
--- modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/http/QueryStringParserTestCase.java (rev 0)
+++ modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/http/QueryStringParserTestCase.java 2007-09-12 18:29:07 UTC (rev 8246)
@@ -0,0 +1,203 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.test.common.http;
+
+import junit.framework.TestCase;
+import org.jboss.portal.common.http.QueryStringParser;
+import org.jboss.portal.common.util.MapBuilder;
+import org.jboss.portal.common.util.ParameterMap;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class QueryStringParserTestCase extends TestCase
+{
+
+ /** . */
+ private final QueryStringParser parser = new QueryStringParser();
+
+ public void testConstructorThrowsIAE()
+ {
+ try
+ {
+ new QueryStringParser(null);
+ fail("Was expecting an IAE");
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ }
+
+ public void testParseThrowsIAE()
+ {
+ try
+ {
+ QueryStringParser.getInstance().parseQueryString(null);
+ fail("Was expecting an IAE");
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ }
+
+ public void testEmpty()
+ {
+ assertEquals(MapBuilder.create(new ParameterMap()).get(), parser.parseQueryString(""));
+ }
+
+ public void testOneParam()
+ {
+ assertEquals(MapBuilder.create(new ParameterMap()).put("f", new String[]{""}).get(), parser.parseQueryString("f"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("f", new String[]{""}).get(), parser.parseQueryString("f="));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("f", new String[]{"b"}).get(), parser.parseQueryString("f=b"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("f", new String[]{"bar"}).get(), parser.parseQueryString("f=bar"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("foo", new String[]{""}).get(), parser.parseQueryString("foo"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("foo", new String[]{""}).get(), parser.parseQueryString("foo="));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("foo", new String[]{"b"}).get(), parser.parseQueryString("foo=b"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("foo", new String[]{"bar"}).get(), parser.parseQueryString("foo=bar"));
+ }
+
+ public void testTwoValues()
+ {
+ assertEquals(MapBuilder.create(new ParameterMap()).put("f", new String[]{"","bar2"}).get(), parser.parseQueryString("f&f=bar2"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("f", new String[]{"","bar2"}).get(), parser.parseQueryString("f=&f=bar2"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("f", new String[]{"b","bar2"}).get(), parser.parseQueryString("f=b&f=bar2"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("f", new String[]{"bar","bar2"}).get(), parser.parseQueryString("f=bar&f=bar2"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("foo", new String[]{"","bar2"}).get(), parser.parseQueryString("foo&foo=bar2"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("foo", new String[]{"","bar2"}).get(), parser.parseQueryString("foo=&foo=bar2"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("foo", new String[]{"b","bar2"}).get(), parser.parseQueryString("foo=b&foo=bar2"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("foo", new String[]{"bar","bar2"}).get(), parser.parseQueryString("foo=bar&foo=bar2"));
+
+ assertEquals(MapBuilder.create(new ParameterMap()).put("f", new String[]{"bar2",""}).get(), parser.parseQueryString("f=bar2&f"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("f", new String[]{"bar2",""}).get(), parser.parseQueryString("f=bar2&f="));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("f", new String[]{"bar2","b"}).get(), parser.parseQueryString("f=bar2&f=b"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("f", new String[]{"bar2","bar"}).get(), parser.parseQueryString("f=bar2&f=bar"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("foo", new String[]{"bar2",""}).get(), parser.parseQueryString("foo=bar2&foo"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("foo", new String[]{"bar2",""}).get(), parser.parseQueryString("foo=bar2&foo="));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("foo", new String[]{"bar2","b"}).get(), parser.parseQueryString("foo=bar2&foo=b"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("foo", new String[]{"bar2","bar"}).get(), parser.parseQueryString("foo=bar2&foo=bar"));
+ }
+
+ public void testEncodedValue()
+ {
+ assertEquals(MapBuilder.create(new ParameterMap()).put("foo", new String[]{" "}).get(), parser.parseQueryString("foo=+"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("foo", new String[]{"."}).get(), parser.parseQueryString("foo=."));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("foo", new String[]{"-"}).get(), parser.parseQueryString("foo=-"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("foo", new String[]{"*"}).get(), parser.parseQueryString("foo=*"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("foo", new String[]{"_"}).get(), parser.parseQueryString("foo=_"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("foo", new String[]{"/"}).get(), parser.parseQueryString("foo=%2F"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("foo", new String[]{"/"}).get(), parser.parseQueryString("foo=/"));
+ }
+
+ public void testMalformedValue()
+ {
+ assertEquals(MapBuilder.create(new ParameterMap()).get(), parser.parseQueryString("foo=%2"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("foo", new String[]{""}).get(), parser.parseQueryString("foo&foo=%2"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("foo", new String[]{"bar"}).get(), parser.parseQueryString("foo=bar&foo=%2"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("foo", new String[]{""}).get(), parser.parseQueryString("foo=%2&foo"));
+ }
+
+ public void testTwoParams()
+ {
+ assertEquals(MapBuilder.create(new ParameterMap()).put("x", new String[]{"y"}).put("f", new String[]{""}).get(), parser.parseQueryString("x=y&f"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("x", new String[]{"y"}).put("f", new String[]{""}).get(), parser.parseQueryString("x=y&f="));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("x", new String[]{"y"}).put("f", new String[]{"b"}).get(), parser.parseQueryString("x=y&f=b"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("x", new String[]{"y"}).put("f", new String[]{"bar"}).get(), parser.parseQueryString("x=y&f=bar"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("x", new String[]{"y"}).put("foo", new String[]{""}).get(), parser.parseQueryString("x=y&foo"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("x", new String[]{"y"}).put("foo", new String[]{""}).get(), parser.parseQueryString("x=y&foo="));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("x", new String[]{"y"}).put("foo", new String[]{"b"}).get(), parser.parseQueryString("x=y&foo=b"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("x", new String[]{"y"}).put("foo", new String[]{"bar"}).get(), parser.parseQueryString("x=y&foo=bar"));
+ }
+
+ public void testValueContainingEqual()
+ {
+ assertEquals(MapBuilder.create(new ParameterMap()).put("f", new String[]{"b=j"}).get(), parser.parseQueryString("f=b=j"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("f", new String[]{"bar=j"}).get(), parser.parseQueryString("f=bar=j"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("f", new String[]{"b=juu"}).get(), parser.parseQueryString("f=b=juu"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("f", new String[]{"bar=juu"}).get(), parser.parseQueryString("f=bar=juu"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("foo", new String[]{"b=j"}).get(), parser.parseQueryString("foo=b=j"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("foo", new String[]{"bar=j"}).get(), parser.parseQueryString("foo=bar=j"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("foo", new String[]{"b=juu"}).get(), parser.parseQueryString("foo=b=juu"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("foo", new String[]{"bar=juu"}).get(), parser.parseQueryString("foo=bar=juu"));
+ }
+
+ public void testInvalidChunck()
+ {
+ assertEquals(MapBuilder.create(new ParameterMap()).get(), parser.parseQueryString("="));
+ assertEquals(MapBuilder.create(new ParameterMap()).get(), parser.parseQueryString("=x"));
+ assertEquals(MapBuilder.create(new ParameterMap()).get(), parser.parseQueryString("=x="));
+ assertEquals(MapBuilder.create(new ParameterMap()).get(), parser.parseQueryString("=x=y"));
+ }
+
+ public void testInvalidChunckWithAmpersand()
+ {
+ //
+ assertEquals(MapBuilder.create(new ParameterMap()).get(), parser.parseQueryString("=&"));
+ assertEquals(MapBuilder.create(new ParameterMap()).get(), parser.parseQueryString("=x&"));
+ assertEquals(MapBuilder.create(new ParameterMap()).get(), parser.parseQueryString("=x=&"));
+ assertEquals(MapBuilder.create(new ParameterMap()).get(), parser.parseQueryString("=x=y&"));
+
+ //
+ assertEquals(MapBuilder.create(new ParameterMap()).put("f", new String[]{""}).get(), parser.parseQueryString("=&f"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("f", new String[]{""}).get(), parser.parseQueryString("=x&f"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("f", new String[]{""}).get(), parser.parseQueryString("=x=&f"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("f", new String[]{""}).get(), parser.parseQueryString("=x=y&f"));
+
+ //
+ assertEquals(MapBuilder.create(new ParameterMap()).put("f", new String[]{""}).get(), parser.parseQueryString("=&f="));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("f", new String[]{""}).get(), parser.parseQueryString("=x&f="));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("f", new String[]{""}).get(), parser.parseQueryString("=x=&f="));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("f", new String[]{""}).get(), parser.parseQueryString("=x=y&f="));
+
+ //
+ assertEquals(MapBuilder.create(new ParameterMap()).put("f", new String[]{"b"}).get(), parser.parseQueryString("=&f=b"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("f", new String[]{"b"}).get(), parser.parseQueryString("=x&f=b"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("f", new String[]{"b"}).get(), parser.parseQueryString("=x=&f=b"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("f", new String[]{"b"}).get(), parser.parseQueryString("=x=y&f=b"));
+
+ //
+ assertEquals(MapBuilder.create(new ParameterMap()).put("foo", new String[]{""}).get(), parser.parseQueryString("=&foo"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("foo", new String[]{""}).get(), parser.parseQueryString("=x&foo"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("foo", new String[]{""}).get(), parser.parseQueryString("=x=&foo"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("foo", new String[]{""}).get(), parser.parseQueryString("=x=y&foo"));
+
+ //
+ assertEquals(MapBuilder.create(new ParameterMap()).put("foo", new String[]{""}).get(), parser.parseQueryString("=&foo="));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("foo", new String[]{""}).get(), parser.parseQueryString("=x&foo="));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("foo", new String[]{""}).get(), parser.parseQueryString("=x=&foo="));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("foo", new String[]{""}).get(), parser.parseQueryString("=x=y&foo="));
+
+ //
+ assertEquals(MapBuilder.create(new ParameterMap()).put("foo", new String[]{"b"}).get(), parser.parseQueryString("=&foo=b"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("foo", new String[]{"b"}).get(), parser.parseQueryString("=x&foo=b"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("foo", new String[]{"b"}).get(), parser.parseQueryString("=x=&foo=b"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("foo", new String[]{"b"}).get(), parser.parseQueryString("=x=y&foo=b"));
+
+ //
+ assertEquals(MapBuilder.create(new ParameterMap()).put("foo", new String[]{"bar"}).get(), parser.parseQueryString("=&foo=bar"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("foo", new String[]{"bar"}).get(), parser.parseQueryString("=x&foo=bar"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("foo", new String[]{"bar"}).get(), parser.parseQueryString("=x=&foo=bar"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("foo", new String[]{"bar"}).get(), parser.parseQueryString("=x=y&foo=bar"));
+ }
+}
Added: modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/io/IOToolsTestCase.java
===================================================================
--- modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/io/IOToolsTestCase.java (rev 0)
+++ modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/io/IOToolsTestCase.java 2007-09-12 18:29:07 UTC (rev 8246)
@@ -0,0 +1,667 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.test.common.io;
+
+import org.jboss.portal.common.io.IOTools;
+import org.jboss.portal.common.junit.ExtendedAssert;
+import junit.framework.TestCase;
+
+import java.io.OutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Reader;
+import java.io.Writer;
+import java.io.ByteArrayOutputStream;
+import java.io.ByteArrayInputStream;
+import java.io.CharArrayWriter;
+import java.io.CharArrayReader;
+import java.util.Random;
+
+import EDU.oswego.cs.dl.util.concurrent.SynchronizedBoolean;
+
+/**
+ * todo:
+ * <ul>
+ * <li>test safeBufferedWrapper</li>
+ * <li>test serialize</li>
+ * <li>test unserialize</li>
+ * <li>test clone</li>
+ * </ul>
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class IOToolsTestCase extends TestCase
+{
+
+ public void testGenericSafeClose()
+ {
+ IOTools.safeClose((Object)null);
+ IOTools.safeClose(new Object());
+
+ //
+ assertTrue(new GenericPublicSafeClose().apply().called);
+ assertFalse(new GenericProtectedSafeClose().apply().called);
+ assertFalse(new GenericPackageProtectedSafeClose().apply().called);
+ assertFalse(new GenericPrivateSafeClose().apply().called);
+
+ //
+ IOTools.safeClose(new GenericPublicStaticSafeClose());
+ assertFalse(GenericPublicStaticSafeClose.called);
+ IOTools.safeClose(new GenericProtectedStaticSafeClose());
+ assertFalse(GenericProtectedStaticSafeClose.called);
+ IOTools.safeClose(new GenericPackageProtectedStaticSafeClose());
+ assertFalse(GenericPackageProtectedStaticSafeClose.called);
+ IOTools.safeClose(new GenericPrivateStaticSafeClose());
+ assertFalse(GenericPrivateStaticSafeClose.called);
+ }
+
+ public static class GenericSafeClose
+ {
+ boolean called = false;
+ public GenericSafeClose apply()
+ {
+ IOTools.safeClose(this);
+ return this;
+ }
+ }
+
+ public static class GenericPublicSafeClose extends GenericSafeClose
+ {
+ public void close()
+ {
+ called = true;
+ }
+ }
+
+ public static class GenericProtectedSafeClose extends GenericSafeClose
+ {
+ protected void close()
+ {
+ called = true;
+ }
+ }
+
+ public static class GenericPackageProtectedSafeClose extends GenericSafeClose
+ {
+ protected void close()
+ {
+ called = true;
+ }
+ }
+
+ public static class GenericPrivateSafeClose extends GenericSafeClose
+ {
+ private void close()
+ {
+ called = true;
+ }
+ }
+
+ public static class GenericPublicStaticSafeClose
+ {
+ static boolean called = false;
+ public static void close()
+ {
+ called = true;
+ }
+ }
+
+ public static class GenericProtectedStaticSafeClose
+ {
+ static boolean called = false;
+ protected static void close()
+ {
+ called = true;
+ }
+ }
+
+ public static class GenericPackageProtectedStaticSafeClose
+ {
+ static boolean called = false;
+ static void close()
+ {
+ called = true;
+ }
+ }
+
+ public static class GenericPrivateStaticSafeClose
+ {
+ static boolean called = false;
+ private static void close()
+ {
+ called = true;
+ }
+ }
+
+
+ public void testGenericSafeCloseWithThrowable()
+ {
+ new FailingGenericSafeClose()
+ {
+ protected void internalClose() throws Throwable
+ {
+ throw new Exception();
+ }
+ }.apply(null);
+ new FailingGenericSafeClose()
+ {
+ protected void internalClose() throws Throwable
+ {
+ throw new Throwable();
+ }
+ }.apply(null);
+ final RuntimeException runtimeException = new RuntimeException();
+ new FailingGenericSafeClose()
+ {
+ protected void internalClose() throws Throwable
+ {
+ throw runtimeException;
+ }
+ }.apply(runtimeException);
+ final Error error = new Error();
+ new FailingGenericSafeClose()
+ {
+ protected void internalClose() throws Throwable
+ {
+ throw error;
+ }
+ }.apply(error);
+ }
+
+ public abstract static class FailingGenericSafeClose
+ {
+ public void apply(Throwable expectedThrowable)
+ {
+ try
+ {
+ IOTools.safeClose(this);
+ assertNull(expectedThrowable);
+ }
+ catch (Throwable t)
+ {
+ assertEquals(expectedThrowable, t);
+ }
+ }
+
+ public void close() throws Throwable
+ {
+ internalClose();
+ }
+
+ protected abstract void internalClose() throws Throwable;
+ }
+
+ public void testOutputStreamSafeClose()
+ {
+ IOTools.safeClose((OutputStream)null);
+ final SynchronizedBoolean called = new SynchronizedBoolean(false);
+ IOTools.safeClose(new AbstractOutputStream()
+ {
+ public void close() throws IOException
+ {
+ called.set(true);
+ }
+ });
+ assertTrue(called.get());
+ IOTools.safeClose(new AbstractOutputStream()
+ {
+ public void close() throws IOException
+ {
+ throw new IOException();
+ }
+ });
+ final Error error = new Error();
+ try
+ {
+ IOTools.safeClose(new AbstractOutputStream()
+ {
+ public void close() throws IOException
+ {
+ throw error;
+ }
+ });
+ fail("Was expecting an error exception");
+ }
+ catch (Error expected)
+ {
+ assertEquals(error, expected);
+ }
+ final RuntimeException runtimeException = new RuntimeException();
+ try
+ {
+ IOTools.safeClose(new AbstractOutputStream()
+ {
+ public void close() throws IOException
+ {
+ throw runtimeException;
+ }
+ });
+ fail("Was expecting a runtime exception");
+ }
+ catch (RuntimeException expected)
+ {
+ assertEquals(runtimeException, expected);
+ }
+ }
+
+ public abstract static class AbstractOutputStream extends OutputStream
+ {
+ public void write(int b) throws IOException
+ {
+ }
+ }
+
+ public void testInputStreamSafeClose()
+ {
+ IOTools.safeClose((InputStream)null);
+ final SynchronizedBoolean called = new SynchronizedBoolean(false);
+ IOTools.safeClose(new AbstractInputStream()
+ {
+ public void close() throws IOException
+ {
+ called.set(true);
+ }
+ });
+ assertTrue(called.get());
+ IOTools.safeClose(new AbstractInputStream()
+ {
+ public void close() throws IOException
+ {
+ throw new IOException();
+ }
+ });
+ final Error error = new Error();
+ try
+ {
+ IOTools.safeClose(new AbstractInputStream()
+ {
+ public void close() throws IOException
+ {
+ throw error;
+ }
+ });
+ fail("Was expecting an error exception");
+ }
+ catch (Error expected)
+ {
+ assertEquals(error, expected);
+ }
+ final RuntimeException runtimeException = new RuntimeException();
+ try
+ {
+ IOTools.safeClose(new AbstractInputStream()
+ {
+ public void close() throws IOException
+ {
+ throw runtimeException;
+ }
+ });
+ fail("Was expecting a runtime exception");
+ }
+ catch (RuntimeException expected)
+ {
+ assertEquals(runtimeException, expected);
+ }
+ }
+
+ public abstract static class AbstractInputStream extends InputStream
+ {
+ public int read() throws IOException
+ {
+ return 0;
+ }
+ }
+
+ public void testReaderSafeClose()
+ {
+ IOTools.safeClose((Reader)null);
+ final SynchronizedBoolean called = new SynchronizedBoolean(false);
+ IOTools.safeClose(new AbstractReader()
+ {
+ public void close() throws IOException
+ {
+ called.set(true);
+ }
+ });
+ assertTrue(called.get());
+ IOTools.safeClose(new AbstractReader()
+ {
+ public void close() throws IOException
+ {
+ throw new IOException();
+ }
+ });
+ final Error error = new Error();
+ try
+ {
+ IOTools.safeClose(new AbstractReader()
+ {
+ public void close() throws IOException
+ {
+ throw error;
+ }
+ });
+ fail("Was expecting an error exception");
+ }
+ catch (Error expected)
+ {
+ assertEquals(error, expected);
+ }
+ final RuntimeException runtimeException = new RuntimeException();
+ try
+ {
+ IOTools.safeClose(new AbstractReader()
+ {
+ public void close() throws IOException
+ {
+ throw runtimeException;
+ }
+ });
+ fail("Was expecting a runtime exception");
+ }
+ catch (RuntimeException expected)
+ {
+ assertEquals(runtimeException, expected);
+ }
+ }
+
+ public abstract static class AbstractReader extends Reader
+ {
+ public int read(char cbuf[], int off, int len) throws IOException
+ {
+ return 0;
+ }
+ }
+
+ public void testWriterSafeClose()
+ {
+ IOTools.safeClose((Writer)null);
+ final SynchronizedBoolean called = new SynchronizedBoolean(false);
+ IOTools.safeClose(new AbstractWriter()
+ {
+ public void close() throws IOException
+ {
+ called.set(true);
+ }
+ });
+ assertTrue(called.get());
+ IOTools.safeClose(new AbstractWriter()
+ {
+ public void close() throws IOException
+ {
+ throw new IOException();
+ }
+ });
+ final Error error = new Error();
+ try
+ {
+ IOTools.safeClose(new AbstractWriter()
+ {
+ public void close() throws IOException
+ {
+ throw error;
+ }
+ });
+ fail("Was expecting an error exception");
+ }
+ catch (Error expected)
+ {
+ assertEquals(error, expected);
+ }
+ final RuntimeException runtimeException = new RuntimeException();
+ try
+ {
+ IOTools.safeClose(new AbstractWriter()
+ {
+ public void close() throws IOException
+ {
+ throw runtimeException;
+ }
+ });
+ fail("Was expecting a runtime exception");
+ }
+ catch (RuntimeException expected)
+ {
+ assertEquals(runtimeException, expected);
+ }
+ }
+
+ public abstract static class AbstractWriter extends Writer
+ {
+ public void write(char cbuf[], int off, int len) throws IOException
+ {
+ }
+ public void flush() throws IOException
+ {
+ }
+ }
+
+ public void testCopyInputStreamToOutputStream() throws IOException
+ {
+ try
+ {
+ IOTools.copy(null, new ByteArrayOutputStream());
+ fail("Was expecting an IAE");
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+
+ //
+ try
+ {
+ IOTools.copy(new ByteArrayInputStream(new byte[0]), null);
+ fail("Was expecting an IOException");
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+
+ //
+ final SynchronizedBoolean closeCalled1 = new SynchronizedBoolean(false);
+ final IOException ioException1 = new IOException();
+ try
+ {
+ IOTools.copy(new AbstractInputStream()
+ {
+ public int read() throws IOException
+ {
+ throw ioException1;
+ }
+ public void close() throws IOException
+ {
+ closeCalled1.set(true);
+ }
+ }, new ByteArrayOutputStream());
+ fail("Was expecting an IOException");
+ }
+ catch (IOException expected)
+ {
+ assertEquals(ioException1, expected);
+ assertFalse(closeCalled1.get());
+ }
+
+ //
+ final SynchronizedBoolean closeCalled2 = new SynchronizedBoolean(false);
+ IOTools.copy(new AbstractInputStream()
+ {
+ public int read() throws IOException
+ {
+ return -1;
+ }
+ public void close() throws IOException
+ {
+ closeCalled2.set(true);
+ }
+ }, new ByteArrayOutputStream());
+ assertFalse(closeCalled2.get());
+
+ //
+ final IOException ioException2 = new IOException();
+ final SynchronizedBoolean closeCalled3 = new SynchronizedBoolean(false);
+ try
+ {
+ IOTools.copy(new ByteArrayInputStream(new byte[1]), new AbstractOutputStream()
+ {
+ public void write(int b) throws IOException
+ {
+ throw ioException2;
+ }
+ public void close() throws IOException
+ {
+ closeCalled3.set(true);
+ }
+ });
+ fail("Was expecting an IOException");
+ }
+ catch (IOException expected)
+ {
+ assertEquals(ioException2, expected);
+ }
+
+ //
+ final SynchronizedBoolean closeCalled4 = new SynchronizedBoolean(false);
+ IOTools.copy(new ByteArrayInputStream(new byte[1]), new AbstractOutputStream()
+ {
+ public void close() throws IOException
+ {
+ closeCalled4.set(true);
+ }
+ });
+
+ //
+ Random random = new Random();
+ byte[] bytes = new byte[2000];
+ random.nextBytes(bytes);
+ ByteArrayOutputStream baos = new ByteArrayOutputStream(bytes.length);
+ IOTools.copy(new ByteArrayInputStream((byte[])bytes.clone()), baos);
+ ExtendedAssert.assertEquals(bytes, baos.toByteArray());
+ }
+
+ public void testCopyReaderToWriter() throws IOException
+ {
+ try
+ {
+ IOTools.copy(null, new CharArrayWriter());
+ fail("Was expecting an IAE");
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+
+ //
+ try
+ {
+ IOTools.copy(new CharArrayReader(new char[0]), null);
+ fail("Was expecting an IOException");
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+
+ //
+ final SynchronizedBoolean closeCalled1 = new SynchronizedBoolean(false);
+ final IOException ioException1 = new IOException();
+ try
+ {
+ IOTools.copy(new AbstractReader()
+ {
+ public int read(char cbuf[], int off, int len) throws IOException
+ {
+ throw ioException1;
+ }
+ public void close() throws IOException
+ {
+ closeCalled1.set(true);
+ }
+ }, new CharArrayWriter());
+ fail("Was expecting an IOException");
+ }
+ catch (IOException expected)
+ {
+ assertEquals(ioException1, expected);
+ assertFalse(closeCalled1.get());
+ }
+
+ //
+ final SynchronizedBoolean closeCalled2 = new SynchronizedBoolean(false);
+ IOTools.copy(new AbstractReader()
+ {
+ public int read(char cbuf[], int off, int len) throws IOException
+ {
+ return -1;
+ }
+ public void close() throws IOException
+ {
+ closeCalled2.set(true);
+ }
+ }, new CharArrayWriter());
+ assertFalse(closeCalled2.get());
+
+ //
+ final IOException ioException2 = new IOException();
+ final SynchronizedBoolean closeCalled3 = new SynchronizedBoolean(false);
+ try
+ {
+ IOTools.copy(new CharArrayReader(new char[1]), new AbstractWriter()
+ {
+ public void write(char cbuf[], int off, int len) throws IOException
+ {
+ throw ioException2;
+ }
+ public void close() throws IOException
+ {
+ closeCalled3.set(true);
+ }
+ });
+ fail("Was expecting an IOException");
+ }
+ catch (IOException expected)
+ {
+ assertEquals(ioException2, expected);
+ }
+
+ //
+ final SynchronizedBoolean closeCalled4 = new SynchronizedBoolean(false);
+ IOTools.copy(new CharArrayReader(new char[1]), new AbstractWriter()
+ {
+ public void close() throws IOException
+ {
+ closeCalled4.set(true);
+ }
+ });
+
+ //
+ Random random = new Random();
+ char[] chars = new char[2000];
+ for (int i = 0; i < chars.length; i++)
+ {
+ chars[i] = (char)random.nextInt();
+
+ }
+ CharArrayWriter caw = new CharArrayWriter(chars.length);
+ IOTools.copy(new CharArrayReader((char[])chars.clone()), caw);
+ ExtendedAssert.assertEquals(chars, caw.toCharArray());
+ }
+}
Added: modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/io/WriterCharWriterTestCase.java
===================================================================
--- modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/io/WriterCharWriterTestCase.java (rev 0)
+++ modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/io/WriterCharWriterTestCase.java 2007-09-12 18:29:07 UTC (rev 8246)
@@ -0,0 +1,203 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.test.common.io;
+
+import org.jboss.portal.common.io.WriterCharWriter;
+import org.jboss.portal.common.io.UndeclaredIOException;
+
+import java.io.StringWriter;
+import java.io.IOException;
+import java.io.Writer;
+
+import junit.framework.TestCase;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class WriterCharWriterTestCase extends TestCase
+{
+
+ public void testAppend1() throws IOException
+ {
+ StringWriter s = new StringWriter();
+ WriterCharWriter writer = new WriterCharWriter(s);
+ writer.append('a');
+ s.close();
+ assertEquals("a", s.toString());
+ }
+
+ public void testAppend2() throws IOException
+ {
+ StringWriter s = new StringWriter();
+ WriterCharWriter writer = new WriterCharWriter(s);
+ writer.append("abc".toCharArray());
+ s.close();
+ assertEquals("abc", s.toString());
+ }
+
+ public void testAppend3() throws IOException
+ {
+ StringWriter s = new StringWriter();
+ WriterCharWriter writer = new WriterCharWriter(s);
+ writer.append("abcdef".toCharArray(), 1, 3);
+ s.close();
+ assertEquals("bcd", s.toString());
+ }
+
+ public void testAppend4() throws IOException
+ {
+ StringWriter s = new StringWriter();
+ WriterCharWriter writer = new WriterCharWriter(s);
+ writer.append("abc");
+ s.close();
+ assertEquals("abc", s.toString());
+ }
+
+ private Writer failingWriter = new Writer()
+ {
+ public void write(char[] chars, int i, int i1) throws IOException
+ {
+ throw new IOException();
+ }
+
+ public void flush() throws IOException
+ {
+ throw new IOException();
+ }
+
+ public void close() throws IOException
+ {
+ throw new IOException();
+ }
+ };
+
+ public void testWrappedIOException()
+ {
+ WriterCharWriter writer = new WriterCharWriter(failingWriter);
+ try
+ {
+ writer.append('c');
+ fail("Was expecting an UndeclaredIOException");
+ }
+ catch (UndeclaredIOException expected)
+ {
+ }
+ try
+ {
+ writer.append("abc".toCharArray());
+ fail("Was expecting an UndeclaredIOException");
+ }
+ catch (UndeclaredIOException expected)
+ {
+ }
+ try
+ {
+ writer.append("abcdef".toCharArray(), 1, 3);
+ fail("Was expecting an UndeclaredIOException");
+ }
+ catch (UndeclaredIOException expected)
+ {
+ }
+ try
+ {
+ writer.append("abc");
+ fail("Was expecting an UndeclaredIOException");
+ }
+ catch (UndeclaredIOException expected)
+ {
+ }
+ }
+
+ public void testAppendThrowsIAE()
+ {
+ try
+ {
+ new WriterCharWriter(null);
+ fail();
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+
+ //
+ WriterCharWriter writer = new WriterCharWriter(new StringWriter());
+ try
+ {
+ writer.append(new char[10], -1, 0);
+ fail();
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ try
+ {
+ writer.append(new char[10], 5, -1);
+ fail();
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ try
+ {
+ writer.append(new char[10], 15, 0);
+ fail();
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ try
+ {
+ writer.append(new char[10], 5, 6);
+ fail();
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ try
+ {
+ writer.append(null, 0, 5);
+ fail();
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ try
+ {
+ writer.append((char[])null);
+ fail();
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ try
+ {
+ writer.append((CharSequence)null);
+ fail();
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ }
+
+}
Added: modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/net/URLNavigatorTestCase.java
===================================================================
--- modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/net/URLNavigatorTestCase.java (rev 0)
+++ modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/net/URLNavigatorTestCase.java 2007-09-12 18:29:07 UTC (rev 8246)
@@ -0,0 +1,639 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.test.common.net;
+
+import junit.framework.TestCase;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Iterator;
+
+import org.jboss.portal.common.net.URLFilter;
+import org.jboss.portal.common.net.URLNavigator;
+import org.jboss.portal.common.net.URLVisitor;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7448 $
+ */
+public class URLNavigatorTestCase extends TestCase
+{
+
+ public URLNavigatorTestCase(String name)
+ {
+ super(name);
+ }
+
+ // the name of the jar that contains the tests
+ private final String TEST_JAR_NAME="test.jar";
+
+
+ ArrayList expectedAtomsC1 = new ArrayList();
+ ArrayList expectedAtomsB1 = new ArrayList();
+ ArrayList expectedAtomsA1 = new ArrayList();
+ ArrayList expectedAtomsB1Dash = new ArrayList();
+ ArrayList expectedAtomsD1txt = new ArrayList();
+ ArrayList expectedAtomsC1txt = new ArrayList();
+ ArrayList expectedAtomsB1txt = new ArrayList();
+ ArrayList expectedAtomsB2txt = new ArrayList();
+ ArrayList expectedAtomsA3txt = new ArrayList();
+
+ ArrayList expectedURLsC1 = new ArrayList();
+ ArrayList expectedURLsB1 = new ArrayList();
+ ArrayList expectedURLsA1 = new ArrayList();
+ ArrayList expectedURLsB1Dash = new ArrayList();
+ ArrayList expectedURLsD1txt = new ArrayList();
+ ArrayList expectedURLsC1txt = new ArrayList();
+ ArrayList expectedURLsB1txt = new ArrayList();
+ ArrayList expectedURLsB2txt = new ArrayList();
+ ArrayList expectedURLsA3txt = new ArrayList();
+
+ Filter noFilter;
+ Filter fullFilter;
+ Filter noDirFilter;
+ Filter noFileFilter;
+
+ protected void setUp() throws Exception
+ {
+
+ expectedURLsD1txt = new ArrayList();
+ expectedURLsD1txt.add("/a1/b1/c1/d1.txt");
+
+ expectedURLsC1 = new ArrayList();
+ expectedURLsC1.add("/a1/b1/c1/");
+ expectedURLsC1.addAll(expectedURLsD1txt);
+ expectedURLsC1.add("/a1/b1/c1/");
+
+ expectedURLsC1txt = new ArrayList();
+ expectedURLsC1txt.add("/a1/b1/c1.txt");
+
+ expectedURLsB1 = new ArrayList();
+ expectedURLsB1.add("/a1/b1/");
+ expectedURLsB1.addAll(expectedURLsC1);
+ expectedURLsB1.addAll(expectedURLsC1txt);
+ expectedURLsB1.add("/a1/b1/");
+
+ expectedURLsB1Dash = new ArrayList();
+ expectedURLsB1Dash.add("/a1/b1-/");
+ expectedURLsB1Dash.add("/a1/b1-/");
+
+ expectedURLsB1txt = new ArrayList();
+ expectedURLsB1txt.add("/a1/b1.txt");
+
+ expectedURLsB2txt = new ArrayList();
+ expectedURLsB2txt.add("/a1/b2.txt");
+
+ expectedURLsA1 = new ArrayList();
+ expectedURLsA1.add("/a1/");
+ expectedURLsA1.addAll(expectedURLsB1);
+ expectedURLsA1.addAll(expectedURLsB1Dash);
+ expectedURLsA1.addAll(expectedURLsB1txt);
+ expectedURLsA1.addAll(expectedURLsB2txt);
+ expectedURLsA1.add("/a1/");
+
+ expectedURLsA3txt = new ArrayList();
+ expectedURLsA3txt.add("a3.txt");
+
+ expectedAtomsD1txt = new ArrayList();
+ expectedAtomsD1txt.add("d1.txt");
+
+ expectedAtomsC1 = new ArrayList();
+ expectedAtomsC1.add("<c1>");
+ expectedAtomsC1.addAll(expectedAtomsD1txt);
+ expectedAtomsC1.add("</c1>");
+
+ expectedAtomsC1txt = new ArrayList();
+ expectedAtomsC1txt.add("c1.txt");
+
+ expectedAtomsB1 = new ArrayList();
+ expectedAtomsB1.add("<b1>");
+ expectedAtomsB1.addAll(expectedAtomsC1);
+ expectedAtomsB1.addAll(expectedAtomsC1txt);
+ expectedAtomsB1.add("</b1>");
+
+ expectedAtomsB1Dash = new ArrayList();
+ expectedAtomsB1Dash.add("<b1->");
+ expectedAtomsB1Dash.add("</b1->");
+
+ expectedAtomsB1txt = new ArrayList();
+ expectedAtomsB1txt.add("b1.txt");
+
+ expectedAtomsB2txt = new ArrayList();
+ expectedAtomsB2txt.add("b2.txt");
+
+ expectedAtomsA1 = new ArrayList();
+ expectedAtomsA1.add("<a1>");
+ expectedAtomsA1.addAll(expectedAtomsB1);
+ expectedAtomsA1.addAll(expectedAtomsB1Dash);
+ expectedAtomsA1.addAll(expectedAtomsB1txt);
+ expectedAtomsA1.addAll(expectedAtomsB2txt);
+ expectedAtomsA1.add("</a1>");
+
+ expectedAtomsA3txt = new ArrayList();
+ expectedAtomsA3txt.add("a3.txt");
+
+ noFilter = new Filter(true, true);
+ fullFilter = new Filter(false, false);
+ noDirFilter = new Filter(true, false);
+ noFileFilter = new Filter(false, true);
+ }
+
+ protected void tearDown() throws Exception
+ {
+ }
+
+
+//// Root tests
+
+ public void testRootWithFile() throws Exception
+ {
+ URL fileURL = getFileURL ("/test-jar");
+
+ ArrayList expectedAtoms = new ArrayList();
+ expectedAtoms.add("<test-jar>");
+ expectedAtoms.addAll(expectedAtomsA1);
+ expectedAtoms.addAll(expectedAtomsA3txt);
+ expectedAtoms.add("</test-jar>");
+
+ ArrayList expectedURLs = new ArrayList();
+ expectedURLs.add("test-jar/");
+ expectedURLs.addAll(expectedURLsA1);
+ expectedURLs.addAll(expectedURLsA3txt);
+ expectedURLs.add("test-jar/");
+
+ doTest (fileURL, expectedAtoms, expectedURLs, noFilter);
+ doTest (fileURL, expectedAtoms, expectedURLs, null);
+ doTest (fileURL, new ArrayList(), new ArrayList(), fullFilter);
+ doTest (fileURL, removeFiles(expectedAtoms), removeFiles(expectedURLs), noFileFilter);
+ //since we pass it a directory, we can't enter the directory
+ doTest (fileURL, new ArrayList(), new ArrayList(),noDirFilter);
+
+ }
+
+ public void testRootWithJar() throws Exception
+ {
+ URL jarURL = getJarURL ("/");
+
+ ArrayList expectedAtoms = new ArrayList();
+ expectedAtoms.add("</>");
+ expectedAtoms.add("<META-INF>");
+ expectedAtoms.add("MANIFEST.MF");
+ expectedAtoms.add("</META-INF>");
+ expectedAtoms.addAll(expectedAtomsA1);
+ expectedAtoms.addAll(expectedAtomsA3txt);
+ //TODO: should this really be //?
+ expectedAtoms.add("<//>");
+
+ ArrayList expectedURLs = new ArrayList();
+ expectedURLs.add("/");
+ expectedURLs.add("/META-INF/");
+ expectedURLs.add("/META-INF/MANIFEST.MF");
+ expectedURLs.add("/META-INF/");
+ expectedURLs.addAll(expectedURLsA1);
+ expectedURLs.addAll(expectedURLsA3txt);
+ expectedURLs.add("/");
+
+ doTest (jarURL, expectedAtoms, expectedURLs, noFilter);
+ doTest (jarURL, new ArrayList(), new ArrayList(), fullFilter);
+ doTest (jarURL, removeFiles(expectedAtoms), removeFiles(expectedURLs), noFileFilter);
+ doTest (jarURL, new ArrayList(), new ArrayList(), noDirFilter);
+
+ }
+
+//// Directory Test
+
+ public void testDirectoryWithFile() throws Exception
+ {
+ URL fileURL = getFileURL ("test-jar/a1/");
+ doDirectoryTest(fileURL);
+ }
+
+ public void testDirectoryWithJar() throws Exception
+ {
+ URL jarURL = getJarURL("/a1/");
+ doDirectoryTest(jarURL);
+ }
+
+ private void doDirectoryTest(URL url) throws Exception
+ {
+ doTest (url, expectedAtomsA1, expectedURLsA1, noFilter);
+ doTest (url, expectedAtomsA1, expectedURLsA1, new Filter());
+ doTest (url, new ArrayList(), new ArrayList(), fullFilter);
+ doTest (url, removeFiles(expectedAtomsA1), removeFiles(expectedURLsA1), noFileFilter);
+ // since we pass it a directory, we can't enter the directory
+ doTest (url, new ArrayList(), new ArrayList(),noDirFilter);
+
+ Filter mixFilter = new Filter();
+ List dirSeq = new ArrayList();
+ dirSeq.add(Boolean.TRUE); //a1
+ dirSeq.add(Boolean.TRUE); //b1
+ dirSeq.add(Boolean.TRUE); //c1
+ dirSeq.add(Boolean.FALSE); //b1-
+
+ List fileSeq = new ArrayList();
+ fileSeq.add(Boolean.TRUE); //d1.txt
+ fileSeq.add(Boolean.FALSE); //c1.txt
+ fileSeq.add(Boolean.FALSE); //b1.txt
+ fileSeq.add(Boolean.FALSE); //b2.txt
+
+ mixFilter.setAcceptDir(dirSeq);
+ mixFilter.setAcceptFile(fileSeq);
+
+ ArrayList expectedMixAtoms = new ArrayList();
+ expectedMixAtoms.add("<a1>");
+ expectedMixAtoms.add("<b1>");
+ expectedMixAtoms.add("<c1>");
+ expectedMixAtoms.add("d1.txt");
+ expectedMixAtoms.add("</c1>");
+ expectedMixAtoms.add("</b1>");
+ expectedMixAtoms.add("</a1>");
+
+ ArrayList expectedMixURLs = new ArrayList();
+ expectedMixURLs.add("/a1/");
+ expectedMixURLs.add("/a1/b1/");
+ expectedMixURLs.add("/a1/b1/c1/");
+ expectedMixURLs.add("/a1/b1/c1/d1.txt");
+ expectedMixURLs.add("/a1/b1/c1/");
+ expectedMixURLs.add("/a1/b1/");
+ expectedMixURLs.add("/a1/");
+
+ doTest (url, expectedMixAtoms, expectedMixURLs, mixFilter);
+ }
+
+//// SubDirectory Test
+
+ public void testSubDirectoryWithFile() throws Exception
+ {
+ URL fileURL = getFileURL ("test-jar/a1/b1");
+ doSubDirectoryTest(fileURL);
+ }
+
+ public void testSubDirectoryWithJar() throws Exception
+ {
+ URL jarURL = getJarURL("/a1/b1/");
+ doSubDirectoryTest(jarURL);
+ }
+
+ private void doSubDirectoryTest(URL url) throws Exception
+ {
+ doTest (url, expectedAtomsB1, expectedURLsB1, noFilter);
+ doTest (url, new ArrayList(), new ArrayList(), fullFilter);
+ doTest (url, new ArrayList(), new ArrayList(), fullFilter);
+ doTest (url, removeFiles(expectedAtomsB1), removeFiles(expectedURLsB1), noFileFilter);
+ // since we pass it a directory, we can't enter the directory
+ doTest (url, new ArrayList(), new ArrayList(),noDirFilter);
+
+ Filter mixFilter = new Filter();
+ List dirSeq = new ArrayList();
+ dirSeq.add(Boolean.TRUE); //b1
+ dirSeq.add(Boolean.FALSE); //c1
+
+ List fileSeq = new ArrayList();
+ fileSeq.add (Boolean.TRUE); //c1.txt
+
+ mixFilter.setAcceptDir(dirSeq);
+ mixFilter.setAcceptFile(fileSeq);
+
+ ArrayList expectedMixAtoms = new ArrayList();
+ expectedMixAtoms.add("<b1>");
+ expectedMixAtoms.addAll(expectedAtomsC1txt);
+ expectedMixAtoms.add("</b1>");
+
+ ArrayList expectedMixURLs = new ArrayList();
+ expectedMixURLs.add("/a1/b1/");
+ expectedMixURLs.add("/a1/b1/c1.txt");
+ expectedMixURLs.add("/a1/b1/");
+
+ doTest (url, expectedMixAtoms, expectedMixURLs, mixFilter);
+ }
+
+/// SingleFileTest
+
+ public void testSingleFileWithFile() throws Exception
+ {
+ URL fileURL = getFileURL("test-jar/a1/b1/c1/d1.txt");
+ doSingleFileTest(fileURL);
+ }
+
+ public void testSingleFileWithJar() throws Exception
+ {
+ URL jarURL = getJarURL("/a1/b1/c1/d1.txt");
+ doSingleFileTest(jarURL);
+ }
+
+ private void doSingleFileTest(URL url) throws Exception
+ {
+ doTest (url, expectedAtomsD1txt, expectedURLsD1txt, noFilter);
+ doTest (url, new ArrayList(), new ArrayList(), fullFilter);
+ doTest (url, removeFiles(expectedAtomsD1txt), removeFiles(expectedAtomsD1txt), noFileFilter);
+ doTest (url, expectedAtomsD1txt, expectedURLsD1txt, noDirFilter);
+ }
+
+//// Empty Directory Test
+
+ public void testEmptyDirectoryWithFile() throws Exception
+ {
+ URL fileURL = getFileURL("test-jar/a1/b1-");
+ doEmptyDirectoryTest(fileURL);
+ }
+
+ public void testEmptyDirectoryWithJar() throws Exception
+ {
+ URL jarURL = getJarURL("/a1/b1-/");
+ doEmptyDirectoryTest(jarURL);
+ }
+
+ private void doEmptyDirectoryTest(URL url) throws Exception
+ {
+ doTest (url, expectedAtomsB1Dash, expectedURLsB1Dash, noFilter);
+ doTest (url, new ArrayList(), new ArrayList(), fullFilter);
+ doTest (url, expectedAtomsB1Dash, expectedURLsB1Dash, noFileFilter);
+ doTest (url, new ArrayList(), new ArrayList(), noDirFilter);
+ }
+
+////
+
+ public void testJarURLs() throws Exception
+ {
+ //Note no / at the end
+ URL jarURL = getJarURL("/a1");
+ doTest (jarURL, expectedAtomsA1, expectedURLsA1, noFilter);
+ doTest (jarURL, new ArrayList(), new ArrayList(), fullFilter);
+ doTest (jarURL, removeFiles(expectedAtomsA1), removeFiles(expectedURLsA1), noFileFilter);
+ // since we pass it a directory, we can't enter the directory
+ doTest (jarURL, new ArrayList(), new ArrayList(),noDirFilter);
+
+ try
+ {
+ //Note extra / at front
+ jarURL = getJarURL("//a1");
+ doTest (jarURL, expectedAtomsA1, expectedURLsA1, noFilter);
+ doTest (jarURL, new ArrayList(), new ArrayList(), fullFilter);
+ doTest (jarURL, removeFiles(expectedAtomsA1), removeFiles(expectedURLsA1), noFileFilter);
+ // since we pass it a directory, we can't enter the directory
+ doTest (jarURL, new ArrayList(), new ArrayList(),noDirFilter);
+ }
+ catch (FileNotFoundException fnfe)
+ {
+ //expected result
+ }
+
+ try
+ {
+ jarURL = getJarURL("/foobar/");
+ doTest (jarURL, expectedAtomsA1, expectedURLsA1, noFilter);
+ fail ("An invalid jar url did not cause a FileNotFoundException");
+ }
+ catch (FileNotFoundException fnfe)
+ {
+ //expected result
+ }
+ }
+
+ public void testFileURLs() throws Exception
+ {
+ //Note no / at the end
+ URL fileURL = getFileURL("/test-jar/a1");
+
+ doTest (fileURL, expectedAtomsA1, expectedURLsA1, noFilter);
+ doTest (fileURL, new ArrayList(), new ArrayList(), fullFilter);
+ doTest (fileURL, removeFiles(expectedAtomsA1), removeFiles(expectedURLsA1), noFileFilter);
+ // since we pass it a directory, we can't enter the directory
+ doTest (fileURL, new ArrayList(), new ArrayList(),noDirFilter);
+
+ try
+ {
+ fileURL = new URL("file:foobar");
+ doTest (fileURL, expectedAtomsA1, expectedURLsA1, noFilter);
+ fail ("An invalid file url did not cause a FileNotFoundException");
+ }
+ catch (FileNotFoundException fnfe)
+ {
+ //expected result
+ }
+ }
+
+
+/*----------Utility Metods and Classes ---------------*/
+
+ private URL getFileURL (String name) throws MalformedURLException
+ {
+ File f = new File("");
+ String resourcePath = f.getAbsolutePath() + "/target/test-classes";
+ File resourcesDir = new File(resourcePath);
+ assertTrue(resourcesDir.exists());
+ assertTrue(resourcesDir.isDirectory());
+
+ File file = new File (resourcesDir, name);
+ assertTrue (file.exists());
+ return file.toURL();
+ }
+
+ private URL getJarURL (String name) throws MalformedURLException
+ {
+ File f = new File("");
+ String libPath = f.getAbsolutePath() + "/target";
+ assertNotNull(libPath);
+ File libDir = new File(libPath);
+ assertTrue(libDir.exists());
+ assertTrue(libDir.isDirectory());
+ File jarFile = new File(libDir, TEST_JAR_NAME);
+ assertTrue(jarFile.exists());
+ jarFile.deleteOnExit();
+ assertFalse(jarFile.isDirectory());
+ URL jarURL = new URL("jar", "", jarFile.toURL() + "!" + name);
+ return jarURL;
+ }
+
+ public List removeFiles(ArrayList list){
+ ArrayList newList = (ArrayList)list.clone();
+ ArrayList fileList = new ArrayList();
+
+ Iterator iterator = newList.iterator();
+ while (iterator.hasNext())
+ {
+ String element = (String)(iterator.next());
+ if (element.endsWith(".txt") || element.endsWith(".MF"))
+ {
+ fileList.add(element);
+ }
+ }
+
+ newList.removeAll(fileList);
+
+ return newList;
+ }
+
+ private void doTest(URL url, List expectedAtoms, List expectedURLs, Filter filter) throws Exception
+ {
+ final List atoms = new ArrayList();
+ final List urls = new ArrayList();
+ URLNavigator.visit(url, new URLVisitor()
+ {
+ public void startDir(URL url, String name)
+ {
+ atoms.add("<" + name + ">");
+ urls.add(url);
+ }
+ public void endDir(URL url, String name)
+ {
+ atoms.add("</" + name + ">");
+ urls.add(url);
+ }
+ public void file(URL url, String name)
+ {
+ atoms.add(name);
+ urls.add(url);
+ }
+ }, filter);
+
+ //
+ if (urls.size() != expectedURLs.size())
+ {
+ assertEquals(expectedURLs, urls);
+ fail("URLs size does not match " + urls.size() + "!=" + expectedURLs.size());
+ }
+
+ //
+ assertEquals(expectedAtoms, atoms);
+
+ //
+ for (int i = 0;i < urls.size();i++)
+ {
+ URL entryURL = (URL)urls.get(i);
+ String suffix = (String)expectedURLs.get(i);
+ if (!entryURL.getPath().endsWith(suffix))
+ {
+ fail("URL " + entryURL + " does not end with the suffix " + suffix + " at index " + i);
+ }
+ if (entryURL.getPath().endsWith ("//" + suffix.substring(1)))
+ {
+ fail("URL " + entryURL + " ends with /" + suffix + " at index " + i);
+ }
+ }
+
+ if (filter != null)
+ {
+ assertTrue("The Sequence never completed", filter.SequenceComplete());
+ }
+ }
+
+ /**
+ * Class used to setup URLFilter behavior for tests
+ * @author Matt Wringe
+ */
+ private static class Filter implements URLFilter
+ {
+ private boolean acceptFile;
+ private boolean acceptDir;
+
+ private List acceptFileSequence = null;
+ private Iterator fileIterator = null;
+
+ private List acceptDirSequence = null;
+ private Iterator dirIterator = null;
+
+ /**
+ * Method used to setup URLFilter behavior
+ * @param acceptFile Always accept files
+ * @param acceptDir Always accept files
+ */
+ public Filter (boolean acceptFile, boolean acceptDir)
+ {
+ this.acceptFile = acceptFile;
+ this.acceptDir = acceptDir;
+ }
+
+ /**
+ * Method to setup URLFilter behavior which by default always accepts
+ * files and directories
+ */
+ public Filter()
+ {
+ this.acceptDir = true;
+ this.acceptFile = true;
+ }
+
+ /**
+ * Set the sequence to accept or reject files
+ * @param acceptFileSequence Sequence for accepting files
+ */
+ public void setAcceptFile (List acceptFileSequence)
+ {
+ this.acceptFileSequence = acceptFileSequence;
+ this.fileIterator = acceptFileSequence.iterator();
+ }
+
+ /**
+ * Set the sequence to accept or reject directories
+ * @param acceptDirSequence Sequence for accepting directories
+ */
+ public void setAcceptDir (List acceptDirSequence)
+ {
+ this.acceptDirSequence = acceptDirSequence;
+ this.dirIterator = acceptDirSequence.iterator();
+ }
+
+ /**
+ * Returns true if the sequence is complete or if no sequence has been setup
+ * @return True if the sequence is complete
+ */
+ public boolean SequenceComplete()
+ {
+ if ((dirIterator == null || !dirIterator.hasNext()) && (fileIterator == null || !fileIterator.hasNext()))
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ public boolean acceptFile(URL url)
+ {
+ if (fileIterator != null)
+ {
+ return ((Boolean)fileIterator.next()).booleanValue();
+ }
+ else
+ {
+ return acceptFile;
+ }
+ }
+
+ public boolean acceptDir(URL url)
+ {
+ if (dirIterator != null)
+ {
+ return ((Boolean)dirIterator.next()).booleanValue();
+ }
+ return acceptDir;
+ }
+ }
+}
+
Added: modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/net/URLToolsTestCase.java
===================================================================
--- modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/net/URLToolsTestCase.java (rev 0)
+++ modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/net/URLToolsTestCase.java 2007-09-12 18:29:07 UTC (rev 8246)
@@ -0,0 +1,169 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.test.common.net;
+
+import junit.framework.TestCase;
+import org.jboss.portal.common.net.URLTools;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a>
+ * @version $Revision: 7379 $
+ * @since 2.4 (May 29, 2006)
+ */
+public class URLToolsTestCase extends TestCase
+{
+ private static final String MARKUP = "Hello, Anonymous!\n" +
+ "Counter: 0<a href='wsrp_rewrite?wsrp-urlType=render&wsrp-navigationalState=rO0ABXNyACdvcmc" +
+ "uamJvc3MucG9ydGFsLnNlcnZlci51dGlsLlBhcmFtZXRlcnOJoAlMQZGhngIAAUwAA21hcHQAD0xqYXZhL3V0aWwvTWFwO3hwc3IAEWphd" +
+ "mEudXRpbC5IYXNoTWFwBQfawcMWYNEDAAJGAApsb2FkRmFjdG9ySQAJdGhyZXNob2xkeHA_QAAAAAAADHcIAAAAEAAAAAF0AARuYW1ldXI" +
+ "AE1tMamF2YS5sYW5nLlN0cmluZzut0lbn6R17RwIAAHhwAAAAAXQABkp1bGllbng*/wsrp_rewrite'>My name is Julien</a><a hr" +
+ "ef='wsrp_rewrite?wsrp-urlType=render&wsrp-navigationalState=rO0ABXNyACdvcmcuamJvc3MucG9ydGFsLnNlcnZlci" +
+ "51dGlsLlBhcmFtZXRlcnOJoAlMQZGhngIAAUwAA21hcHQAD0xqYXZhL3V0aWwvTWFwO3hwc3IAEWphdmEudXRpbC5IYXNoTWFwBQfawcMW" +
+ "YNEDAAJGAApsb2FkRmFjdG9ySQAJdGhyZXNob2xkeHA_QAAAAAAADHcIAAAAEAAAAAF0AARuYW1ldXIAE1tMamF2YS5sYW5nLlN0cmluZz" +
+ "ut0lbn6R17RwIAAHhwAAAAAXQAA1JveXg*/wsrp_rewrite'>My name is Roy</a><action='wsrp_rewrite?wsrp-urlType=bloc" +
+ "kingAction&wsrp-interactionState=rO0ABXNyACdvcmcuamJvc3MucG9ydGFsLnNlcnZlci51dGlsLlBhcmFtZXRlcnOJoAlMQ" +
+ "ZGhngIAAUwAA21hcHQAD0xqYXZhL3V0aWwvTWFwO3hwc3IAEWphdmEudXRpbC5IYXNoTWFwBQfawcMWYNEDAAJGAApsb2FkRmFjdG9ySQA" +
+ "JdGhyZXNob2xkeHA_QAAAAAAADHcIAAAAEAAAAAF0AAJvcHVyABNbTGphdmEubGFuZy5TdHJpbmc7rdJW5-kde0cCAAB4cAAAAAF0AAIrK" +
+ "3g*/wsrp_rewrite'>counter++</a><a href='wsrp_rewrite?wsrp-urlType=blockingAction&wsrp-interactionState" +
+ "=rO0ABXNyACdvcmcuamJvc3MucG9ydGFsLnNlcnZlci51dGlsLlBhcmFtZXRlcnOJoAlMQZGhngIAAUwAA21hcHQAD0xqYXZhL3V0aWwvT" +
+ "WFwO3hwc3IAEWphdmEudXRpbC5IYXNoTWFwBQfawcMWYNEDAAJGAApsb2FkRmFjdG9ySQAJdGhyZXNob2xkeHA_QAAAAAAADHcIAAAAEAA" +
+ "AAAF0AAJvcHVyABNbTGphdmEubGFuZy5TdHJpbmc7rdJW5-kde0cCAAB4cAAAAAF0AAItLXg*/wsrp_rewrite'>counter--</a>";
+
+ public void testExtractURLs()
+ {
+ String markup = MARKUP;
+
+ URLTools.URLMatch[] links = URLTools.extractURLsFrom(markup);
+ assertEquals(4, links.length);
+ URLTools.URLMatch link = links[0];
+ assertEquals("wsrp_rewrite?wsrp-urlType=render&wsrp-navigationalState=rO0ABXNyACdvcmcuamJvc3MucG9ydGFsLnNl" +
+ "cnZlci51dGlsLlBhcmFtZXRlcnOJoAlMQZGhngIAAUwAA21hcHQAD0xqYXZhL3V0aWwvTWFwO3hwc3IAEWphdmEudXRpbC5IYXNoTWFwBQ" +
+ "fawcMWYNEDAAJGAApsb2FkRmFjdG9ySQAJdGhyZXNob2xkeHA_QAAAAAAADHcIAAAAEAAAAAF0AARuYW1ldXIAE1tMamF2YS5sYW5nLlN0" +
+ "cmluZzut0lbn6R17RwIAAHhwAAAAAXQABkp1bGllbng*/wsrp_rewrite", link.getURLAsString());
+ assertEquals("wsrp_rewrite?wsrp-urlType=blockingAction&wsrp-interactionState=rO0ABXNyACdvcmcuamJvc3MucG9yd" +
+ "GFsLnNlcnZlci51dGlsLlBhcmFtZXRlcnOJoAlMQZGhngIAAUwAA21hcHQAD0xqYXZhL3V0aWwvTWFwO3hwc3IAEWphdmEudXRpbC5IYXN" +
+ "oTWFwBQfawcMWYNEDAAJGAApsb2FkRmFjdG9ySQAJdGhyZXNob2xkeHA_QAAAAAAADHcIAAAAEAAAAAF0AAJvcHVyABNbTGphdmEubGFuZ" +
+ "y5TdHJpbmc7rdJW5-kde0cCAAB4cAAAAAF0AAIrK3g*/wsrp_rewrite", links[2].getURLAsString());
+
+ String url = "wsrp_rewrite?wsrp-urlType=render&wsrp-mode=help/wsrp_rewrite";
+ markup = "12345href='" + url + "'76";
+ links = URLTools.extractURLsFrom(markup);
+ link = links[0];
+ int startIndex = 11;
+ assertEquals(startIndex, link.getStart());
+ assertEquals(url.length() + startIndex, link.getEnd());
+ assertEquals(url, markup.substring(link.getStart(), link.getEnd()));
+ assertEquals(url, link.getURLAsString());
+ }
+
+ public void testReplaceURLs()
+ {
+ String markup = URLTools.replaceURLsBy(MARKUP, new String[]{"foo", "bar", "baz", "buz"});
+ String replaced = "Hello, Anonymous!\nCounter: 0<a href='foo'>My name is Julien</a><a href='bar'>My name is Roy</a>" +
+ "<action='baz'>counter++</a><a href='buz'>counter--</a>";
+ assertEquals(replaced, markup);
+ assertEquals(replaced, URLTools.replaceURLsBy(replaced, (String[])null));
+
+ String mixed = "<a href='wsrp_rewrite?wsrp-urlType=render&wsrp-mode=help/wsrp_rewrite'>My name is Julien</a>" +
+ "<a href='bar'>My name is Roy</a>";
+ assertEquals("<a href='foo'>My name is Julien</a><a href='bar'>My name is Roy</a>",
+ URLTools.replaceURLsBy(mixed, new URLTools.URLReplacementGenerator()
+ {
+ public String getReplacementFor(int currentIndex, URLTools.URLMatch currentMatch)
+ {
+ String urlAsString = currentMatch.getURLAsString();
+ if (urlAsString.startsWith("wsrp_rewrite"))
+ {
+ return "foo";
+ }
+ return urlAsString;
+ }
+ }));
+ }
+
+ public void testReplaceAllPorts()
+ {
+ String original = "<wsdl:definitions targetNamespace='urn:oasis:names:tc:wsrp:v1:wsdl'\n" +
+ " xmlns:bind='urn:oasis:names:tc:wsrp:v1:bind'\n" +
+ " xmlns='http://schemas.xmlsoap.org/wsdl/'\n" +
+ " xmlns:wsdl='http://schemas.xmlsoap.org/wsdl/'\n" +
+ " xmlns:soap='http://schemas.xmlsoap.org/wsdl/soap/'\n" +
+ " xmlns:intf='urn:oasis:names:tc:wsrp:v1:intf'\n" +
+ " xmlns:tns='urn:oasis:names:tc:wsrp:v1:wsdl'>\n" +
+ " <import namespace='urn:oasis:names:tc:wsrp:v1:bind' location='wsrp_v1_bindings.wsdl'/>\n" +
+ " <wsdl:service name='WSRPService'>\n" +
+ " <wsdl:port binding='bind:WSRP_v1_Markup_Binding_SOAP' name='WSRPBaseService'>\n" +
+ " <soap:address location='http://localhost/portal-wsrp/ServiceDescriptionService'/>\n" +
+ " </wsdl:port>\n" +
+ " <wsdl:port binding='bind:WSRP_v1_ServiceDescription_Binding_SOAP' name='WSRPServiceDescriptionService'>\n" +
+ " <soap:address location='http://localhost/portal-wsrp/MarkupService'/>\n" +
+ " </wsdl:port>\n" +
+ " <wsdl:port binding='bind:WSRP_v1_Registration_Binding_SOAP' name='WSRPRegistrationService'>\n" +
+ " <soap:address location='http://localhost/portal-wsrp/RegistrationService'/>\n" +
+ " </wsdl:port>\n" +
+ " <wsdl:port binding='bind:WSRP_v1_PortletManagement_Binding_SOAP' name='WSRPPortletManagementService'>\n" +
+ " <soap:address location='http://localhost/portal-wsrp/PortletManagementService'/>\n" +
+ " </wsdl:port>\n" +
+ " </wsdl:service>\n" +
+ "</wsdl:definitions>";
+ String result = "<wsdl:definitions targetNamespace='urn:oasis:names:tc:wsrp:v1:wsdl'\n" +
+ " xmlns:bind='urn:oasis:names:tc:wsrp:v1:bind'\n" +
+ " xmlns='http://schemas.xmlsoap.org/wsdl/'\n" +
+ " xmlns:wsdl='http://schemas.xmlsoap.org/wsdl/'\n" +
+ " xmlns:soap='http://schemas.xmlsoap.org/wsdl/soap/'\n" +
+ " xmlns:intf='urn:oasis:names:tc:wsrp:v1:intf'\n" +
+ " xmlns:tns='urn:oasis:names:tc:wsrp:v1:wsdl'>\n" +
+ " <import namespace='urn:oasis:names:tc:wsrp:v1:bind' location='wsrp_v1_bindings.wsdl'/>\n" +
+ " <wsdl:service name='WSRPService'>\n" +
+ " <wsdl:port binding='bind:WSRP_v1_Markup_Binding_SOAP' name='WSRPBaseService'>\n" +
+ " <soap:address location='http://localhost:8888/portal-wsrp/ServiceDescriptionService'/>\n" +
+ " </wsdl:port>\n" +
+ " <wsdl:port binding='bind:WSRP_v1_ServiceDescription_Binding_SOAP' name='WSRPServiceDescriptionService'>\n" +
+ " <soap:address location='http://localhost:8888/portal-wsrp/MarkupService'/>\n" +
+ " </wsdl:port>\n" +
+ " <wsdl:port binding='bind:WSRP_v1_Registration_Binding_SOAP' name='WSRPRegistrationService'>\n" +
+ " <soap:address location='http://localhost:8888/portal-wsrp/RegistrationService'/>\n" +
+ " </wsdl:port>\n" +
+ " <wsdl:port binding='bind:WSRP_v1_PortletManagement_Binding_SOAP' name='WSRPPortletManagementService'>\n" +
+ " <soap:address location='http://localhost:8888/portal-wsrp/PortletManagementService'/>\n" +
+ " </wsdl:port>\n" +
+ " </wsdl:service>\n" +
+ "</wsdl:definitions>";
+
+ assertEquals(result, URLTools.replaceURLsBy(original, new URLTools.PortReplacementGenerator(8888)));
+ }
+
+ public void testReplaceServerPort()
+ {
+ assertEquals("http://hostname:8088/some/path", URLTools.replaceServerPortInURL("http://hostname:8080/some/path", 8088));
+ assertEquals("https://hostname:8088/some/path", URLTools.replaceServerPortInURL("https://hostname:8080/some/path", 8088));
+ assertEquals("http://hostname:8088/some/path", URLTools.replaceServerPortInURL("http://hostname/some/path", 8088));
+ assertEquals("https://hostname:8088/some/path", URLTools.replaceServerPortInURL("https://hostname/some/path", 8088));
+ }
+
+ public void testExistsURL()
+ {
+ // todo: add more tests
+ assertFalse(URLTools.exists(null, true));
+ }
+}
Added: modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/reflect/Class1.java
===================================================================
--- modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/reflect/Class1.java (rev 0)
+++ modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/reflect/Class1.java 2007-09-12 18:29:07 UTC (rev 8246)
@@ -0,0 +1,43 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.test.common.reflect;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class Class1
+{
+
+ private void privateMethod()
+ {
+ }
+
+ public abstract void publicAbstractMethodOfClass1();
+
+ protected abstract void protectedAbstractMethodOfClass1();
+
+ private void privateMethodOfClass1()
+ {
+ }
+}
Added: modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/reflect/Class2.java
===================================================================
--- modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/reflect/Class2.java (rev 0)
+++ modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/reflect/Class2.java 2007-09-12 18:29:07 UTC (rev 8246)
@@ -0,0 +1,55 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.test.common.reflect;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class Class2 extends Class1
+{
+
+ private void privateMethod()
+ {
+ }
+
+ public void publicAbstractMethodOfClass1()
+ {
+ }
+
+ protected void protectedAbstractMethodOfClass1()
+ {
+ }
+
+ public void publicMethodOfClass2()
+ {
+ }
+
+ protected void protectedMethodOfClass2()
+ {
+ }
+
+ private void privateMethodOfClass2()
+ {
+ }
+}
Added: modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/reflect/Class3.java
===================================================================
--- modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/reflect/Class3.java (rev 0)
+++ modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/reflect/Class3.java 2007-09-12 18:29:07 UTC (rev 8246)
@@ -0,0 +1,38 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.test.common.reflect;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class Class3 extends Class2
+{
+ private void privateMethod()
+ {
+ }
+
+ private void privateMethodOfClass3()
+ {
+ }
+}
Added: modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/reflect/ModifierTestCase.java
===================================================================
--- modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/reflect/ModifierTestCase.java (rev 0)
+++ modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/reflect/ModifierTestCase.java 2007-09-12 18:29:07 UTC (rev 8246)
@@ -0,0 +1,121 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.test.common.reflect;
+
+import junit.framework.TestCase;
+import org.jboss.portal.common.reflect.Modifier;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class ModifierTestCase extends TestCase
+{
+
+ public void testIsReadableProperty() throws Exception
+ {
+ try
+ {
+ Modifier.isReadableProperty(null);
+ fail("Was expecting an IAE");
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+
+ assertTrue(Modifier.isReadableProperty(Bean.class.getDeclaredField("publicField")));
+ assertFalse(Modifier.isReadableProperty(Bean.class.getDeclaredField("privateField")));
+ assertFalse(Modifier.isReadableProperty(Bean.class.getDeclaredField("protectedField")));
+ assertFalse(Modifier.isReadableProperty(Bean.class.getDeclaredField("packageProtectedField")));
+
+ assertTrue(Modifier.isReadableProperty(Bean.class.getDeclaredField("finalPublicField")));
+ assertFalse(Modifier.isReadableProperty(Bean.class.getDeclaredField("finalPrivateField")));
+ assertFalse(Modifier.isReadableProperty(Bean.class.getDeclaredField("finalProtectedField")));
+ assertFalse(Modifier.isReadableProperty(Bean.class.getDeclaredField("finalPackageProtectedField")));
+
+ assertFalse(Modifier.isReadableProperty(Bean.class.getDeclaredField("staticPublicField")));
+ assertFalse(Modifier.isReadableProperty(Bean.class.getDeclaredField("staticPrivateField")));
+ assertFalse(Modifier.isReadableProperty(Bean.class.getDeclaredField("staticProtectedField")));
+ assertFalse(Modifier.isReadableProperty(Bean.class.getDeclaredField("staticPackageProtectedField")));
+
+ assertFalse(Modifier.isReadableProperty(Bean.class.getDeclaredField("finalStaticPublicField")));
+ assertFalse(Modifier.isReadableProperty(Bean.class.getDeclaredField("finalStaticPrivateField")));
+ assertFalse(Modifier.isReadableProperty(Bean.class.getDeclaredField("finalStaticProtectedField")));
+ assertFalse(Modifier.isReadableProperty(Bean.class.getDeclaredField("finalStaticPackageProtectedField")));
+ }
+
+ public void testIsWritableProperty() throws Exception
+ {
+ try
+ {
+ Modifier.isWritableProperty(null);
+ fail("Was expecting an IAE");
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+
+ assertTrue(Modifier.isWritableProperty(Bean.class.getDeclaredField("publicField")));
+ assertFalse(Modifier.isWritableProperty(Bean.class.getDeclaredField("privateField")));
+ assertFalse(Modifier.isWritableProperty(Bean.class.getDeclaredField("protectedField")));
+ assertFalse(Modifier.isWritableProperty(Bean.class.getDeclaredField("packageProtectedField")));
+
+ assertFalse(Modifier.isWritableProperty(Bean.class.getDeclaredField("finalPublicField")));
+ assertFalse(Modifier.isWritableProperty(Bean.class.getDeclaredField("finalPrivateField")));
+ assertFalse(Modifier.isWritableProperty(Bean.class.getDeclaredField("finalProtectedField")));
+ assertFalse(Modifier.isWritableProperty(Bean.class.getDeclaredField("finalPackageProtectedField")));
+
+ assertFalse(Modifier.isWritableProperty(Bean.class.getDeclaredField("staticPublicField")));
+ assertFalse(Modifier.isWritableProperty(Bean.class.getDeclaredField("staticPrivateField")));
+ assertFalse(Modifier.isWritableProperty(Bean.class.getDeclaredField("staticProtectedField")));
+ assertFalse(Modifier.isWritableProperty(Bean.class.getDeclaredField("staticPackageProtectedField")));
+
+ assertFalse(Modifier.isWritableProperty(Bean.class.getDeclaredField("finalStaticPublicField")));
+ assertFalse(Modifier.isWritableProperty(Bean.class.getDeclaredField("finalStaticPrivateField")));
+ assertFalse(Modifier.isWritableProperty(Bean.class.getDeclaredField("finalStaticProtectedField")));
+ assertFalse(Modifier.isWritableProperty(Bean.class.getDeclaredField("finalStaticPackageProtectedField")));
+ }
+
+ private static class Bean
+ {
+ public Object publicField;
+ private Object privateField;
+ protected Object protectedField;
+ Object packageProtectedField;
+
+ final public Object finalPublicField = new Object();
+ final private Object finalPrivateField = new Object();
+ final protected Object finalProtectedField = new Object();
+ final Object finalPackageProtectedField = new Object();
+
+ static public Object staticPublicField;
+ static private Object staticPrivateField;
+ static protected Object staticProtectedField;
+ static Object staticPackageProtectedField;
+
+ final static public Object finalStaticPublicField = new Object();
+ final static private Object finalStaticPrivateField = new Object();
+ final static protected Object finalStaticProtectedField = new Object();
+ final static Object finalStaticPackageProtectedField = new Object();
+ }
+}
Added: modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/reflect/ReflectionTestCase.java
===================================================================
--- modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/reflect/ReflectionTestCase.java (rev 0)
+++ modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/reflect/ReflectionTestCase.java 2007-09-12 18:29:07 UTC (rev 8246)
@@ -0,0 +1,90 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.test.common.reflect;
+
+import junit.framework.TestCase;
+
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+
+import org.jboss.portal.common.reflect.Reflection;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class ReflectionTestCase extends TestCase
+{
+
+ public void testClass1()
+ {
+ assertEquals(Class1.class, "privateMethod", Modifier.PRIVATE, Reflection.findMethod(Class1.class, "privateMethod", new Class[0]));
+
+ //
+ assertEquals(Class1.class, "privateMethodOfClass1", Modifier.PRIVATE, Reflection.findMethod(Class1.class, "privateMethodOfClass1", new Class[0]));
+ assertEquals(Class1.class, "publicAbstractMethodOfClass1", Modifier.PUBLIC | Modifier.ABSTRACT, Reflection.findMethod(Class1.class, "publicAbstractMethodOfClass1", new Class[0]));
+ assertEquals(Class1.class, "protectedAbstractMethodOfClass1", Modifier.PROTECTED | Modifier.ABSTRACT, Reflection.findMethod(Class1.class, "protectedAbstractMethodOfClass1", new Class[0]));
+ }
+
+ public void testClass2()
+ {
+ assertEquals(Class2.class, "privateMethod", Modifier.PRIVATE, Reflection.findMethod(Class2.class, "privateMethod", new Class[0]));
+
+ //
+ assertEquals(Class1.class, "privateMethodOfClass1", Modifier.PRIVATE, Reflection.findMethod(Class2.class, "privateMethodOfClass1", new Class[0]));
+ assertEquals(Class2.class, "publicAbstractMethodOfClass1", Modifier.PUBLIC, Reflection.findMethod(Class2.class, "publicAbstractMethodOfClass1", new Class[0]));
+ assertEquals(Class2.class, "protectedAbstractMethodOfClass1", Modifier.PROTECTED, Reflection.findMethod(Class2.class, "protectedAbstractMethodOfClass1", new Class[0]));
+
+ //
+ assertEquals(Class2.class, "privateMethodOfClass2", Modifier.PRIVATE, Reflection.findMethod(Class2.class, "privateMethodOfClass2", new Class[0]));
+ assertEquals(Class2.class, "publicMethodOfClass2", Modifier.PUBLIC, Reflection.findMethod(Class2.class, "publicMethodOfClass2", new Class[0]));
+ assertEquals(Class2.class, "protectedMethodOfClass2", Modifier.PROTECTED, Reflection.findMethod(Class2.class, "protectedMethodOfClass2", new Class[0]));
+ }
+
+ public void testClass3()
+ {
+ assertEquals(Class3.class, "privateMethod", Modifier.PRIVATE, Reflection.findMethod(Class3.class, "privateMethod", new Class[0]));
+
+ //
+ assertEquals(Class1.class, "privateMethodOfClass1", Modifier.PRIVATE, Reflection.findMethod(Class3.class, "privateMethodOfClass1", new Class[0]));
+ assertEquals(Class2.class, "publicAbstractMethodOfClass1", Modifier.PUBLIC, Reflection.findMethod(Class3.class, "publicAbstractMethodOfClass1", new Class[0]));
+ assertEquals(Class2.class, "protectedAbstractMethodOfClass1", Modifier.PROTECTED, Reflection.findMethod(Class3.class, "protectedAbstractMethodOfClass1", new Class[0]));
+
+ //
+ assertEquals(Class2.class, "privateMethodOfClass2", Modifier.PRIVATE, Reflection.findMethod(Class3.class, "privateMethodOfClass2", new Class[0]));
+ assertEquals(Class2.class, "publicMethodOfClass2", Modifier.PUBLIC, Reflection.findMethod(Class3.class, "publicMethodOfClass2", new Class[0]));
+ assertEquals(Class2.class, "protectedMethodOfClass2", Modifier.PROTECTED, Reflection.findMethod(Class3.class, "protectedMethodOfClass2", new Class[0]));
+
+ //
+ assertEquals(Class3.class, "privateMethodOfClass3", Modifier.PRIVATE, Reflection.findMethod(Class3.class, "privateMethodOfClass3", new Class[0]));
+ }
+
+ private void assertEquals(Class declaringClass, String methodName, int modifiers, Method effectiveMethod)
+ {
+ assertNotNull(effectiveMethod);
+ assertEquals(declaringClass, effectiveMethod.getDeclaringClass());
+ assertEquals(modifiers, effectiveMethod.getModifiers());
+ assertEquals(methodName, effectiveMethod.getName());
+ }
+
+}
Added: modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/text/CharBufferTestCase.java
===================================================================
--- modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/text/CharBufferTestCase.java (rev 0)
+++ modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/text/CharBufferTestCase.java 2007-09-12 18:29:07 UTC (rev 8246)
@@ -0,0 +1,118 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.test.common.text;
+
+import junit.framework.TestCase;
+import org.jboss.portal.common.text.CharBuffer;
+import org.jboss.portal.common.text.FastURLEncoder;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class CharBufferTestCase extends TestCase
+{
+
+ private FastURLEncoder encoder = FastURLEncoder.getInstance();
+
+ public void testUTF8EncodedStringAppend()
+ {
+ CharBuffer buffer = new CharBuffer(0);
+ buffer.append("/ a$\u0400", encoder);
+ assertEquals("%2F+a%24%D0%80", buffer.asString());
+ }
+
+ public void testStringAppend()
+ {
+ CharBuffer buffer = new CharBuffer(0);
+ buffer.append("abc");
+ assertEquals("abc", buffer.asString());
+ }
+
+ public void testCharArrayAppend()
+ {
+ CharBuffer buffer = new CharBuffer(0);
+ buffer.append("abc".toCharArray());
+ assertEquals("abc", buffer.asString());
+ }
+
+ public void testCharsAppend()
+ {
+ CharBuffer buffer = new CharBuffer(0);
+ buffer.append('a').append('b').append('c');
+ assertEquals("abc", buffer.asString());
+ }
+
+ public void testReset()
+ {
+ CharBuffer buffer = new CharBuffer(0);
+ buffer.append("abc".toCharArray());
+ assertEquals("abc", buffer.asString());
+ buffer.reset();
+ buffer.append("def".toCharArray());
+ assertEquals("def", buffer.asString());
+ }
+
+ public void testCharArrayAppendThrowsIAE()
+ {
+ CharBuffer buffer = new CharBuffer(0);
+ try
+ {
+ buffer.append((char[])null);
+ }
+ catch (IllegalArgumentException e)
+ {
+ }
+ }
+
+ public void testStringAppendThrowsIAE()
+ {
+ CharBuffer buffer = new CharBuffer(0);
+ try
+ {
+ buffer.append((String)null);
+ }
+ catch (IllegalArgumentException e)
+ {
+ }
+ }
+
+ public void testUTF8EncodedAppendThrowsIAE()
+ {
+ CharBuffer buffer = new CharBuffer(0);
+ try
+ {
+ buffer.append(null, encoder);
+ }
+ catch (IllegalArgumentException e)
+ {
+ }
+ try
+ {
+ buffer.append("abc", null);
+ }
+ catch (IllegalArgumentException e)
+ {
+ }
+ }
+}
Added: modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/text/CharToByteEncoderTestCase.java
===================================================================
--- modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/text/CharToByteEncoderTestCase.java (rev 0)
+++ modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/text/CharToByteEncoderTestCase.java 2007-09-12 18:29:07 UTC (rev 8246)
@@ -0,0 +1,61 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.test.common.text;
+
+import junit.framework.TestCase;
+import org.jboss.portal.common.text.CharToByteEncoder;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class CharToByteEncoderTestCase extends TestCase
+{
+
+ public void testCorrectness()
+ {
+ CharToByteEncoder encoder = new CharToByteEncoder.Generic("UTF8");
+
+ //
+ for (int i = 0;i <= 0x10FFFD;i++)
+ {
+ char c = (char)i;
+ int type = Character.getType(c);
+ byte[] r = encoder.encode(c);
+ if (type == Character.SURROGATE || type == Character.PRIVATE_USE)
+ {
+ if (r.length != 0)
+ {
+ fail("Char " + i + " has length " + r.length);
+ }
+ }
+ else
+ {
+ if (r.length < 1)
+ {
+ fail("Char " + i + " has length " + r.length);
+ }
+ }
+ }
+ }
+}
Added: modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/text/FastURLDecoderTestCase.java
===================================================================
--- modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/text/FastURLDecoderTestCase.java (rev 0)
+++ modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/text/FastURLDecoderTestCase.java 2007-09-12 18:29:07 UTC (rev 8246)
@@ -0,0 +1,241 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.test.common.text;
+
+import junit.framework.TestCase;
+import org.jboss.portal.common.text.FastURLDecoder;
+import org.jboss.portal.common.text.CharEncoder;
+import org.jboss.portal.common.text.CharBuffer;
+import org.jboss.portal.common.text.MalformedInputException;
+
+import java.net.URLEncoder;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class FastURLDecoderTestCase extends TestCase
+{
+
+ public void testEncodeThrowsIAE() throws Exception
+ {
+ CharEncoder encoder = FastURLDecoder.getUTF8Instance();
+ try
+ {
+ encoder.encode(new char[10], -1, 0, new CharBuffer());
+ fail();
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ try
+ {
+ encoder.encode(new char[10], 5, -1, new CharBuffer());
+ fail();
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ try
+ {
+ encoder.encode(new char[10], 15, 0, new CharBuffer());
+ fail();
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ try
+ {
+ encoder.encode(new char[10], 5, 6, new CharBuffer());
+ fail();
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ try
+ {
+ encoder.encode(null, 0, 5, new CharBuffer());
+ fail();
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ try
+ {
+ encoder.encode((char[])null, new CharBuffer());
+ fail();
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ try
+ {
+ encoder.encode((CharSequence)null, new CharBuffer());
+ fail();
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+
+ //
+ try
+ {
+ encoder.encode(new char[10], 0, 10, null);
+ fail();
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ try
+ {
+ encoder.encode(new char[10], null);
+ fail();
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ try
+ {
+ encoder.encode('A', null);
+ fail();
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ try
+ {
+ encoder.encode("abc", null);
+ fail();
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ }
+
+ public void testEncode() throws Exception
+ {
+ FastURLDecoder encoder = FastURLDecoder.getUTF8Instance();
+ StringBuffer tmp = new StringBuffer();
+ for (int i = 0;i < 512;i++)
+ {
+ tmp.append((char)i);
+ }
+ CharBuffer out = new CharBuffer();
+ String s = tmp.toString();
+ String t = URLEncoder.encode(s, "UTF8");
+ encoder.encode(t, out);
+ assertEquals(s, out.asString());
+ }
+
+ public void testEncodeMalformedInput()
+ {
+ testEncodeMalformedInput(FastURLDecoder.getUTF8StrictInstance(), true);
+ testEncodeMalformedInput(FastURLDecoder.getUTF8Instance(), false);
+ }
+
+ private void testEncodeMalformedInput(FastURLDecoder encoder, boolean strict)
+ {
+ try
+ {
+ encoder.encode("%0T", new CharBuffer());
+ fail("Was expecting a malformed input exception");
+ }
+ catch (MalformedInputException expected)
+ {
+ }
+ try
+ {
+ encoder.encode("%T0", new CharBuffer());
+ fail("Was expecting a malformed input exception");
+ }
+ catch (MalformedInputException expected)
+ {
+ }
+ try
+ {
+ encoder.encode("%0\u0100", new CharBuffer());
+ fail("Was expecting a malformed input exception");
+ }
+ catch (MalformedInputException expected)
+ {
+ }
+ try
+ {
+ encoder.encode("%\u01000", new CharBuffer());
+ fail("Was expecting a malformed input exception");
+ }
+ catch (MalformedInputException expected)
+ {
+ }
+ try
+ {
+ encoder.encode("%0", new CharBuffer());
+ fail("Was expecting a malformed input exception");
+ }
+ catch (MalformedInputException expected)
+ {
+ }
+ try
+ {
+ encoder.encode("%", new CharBuffer());
+ fail("Was expecting a malformed input exception");
+ }
+ catch (MalformedInputException expected)
+ {
+ }
+
+ //
+ if (strict)
+ {
+ try
+ {
+ encoder.encode(";", new CharBuffer());
+ fail("Was expecting a malformed input exception");
+ }
+ catch (MalformedInputException expected)
+ {
+ }
+ try
+ {
+ encoder.encode("\u0100", new CharBuffer());
+ fail("Was expecting a malformed input exception");
+ }
+ catch (MalformedInputException expected)
+ {
+ }
+ }
+ else
+ {
+ CharBuffer tmp = new CharBuffer();
+
+ //
+ encoder.encode(";", tmp);
+ assertEquals(";", tmp.asString());
+
+ //
+ tmp.reset();
+ encoder.encode("\u0100", tmp);
+ assertEquals("\u0100", tmp.asString());
+ }
+ }
+}
Added: modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/text/FastURLEncoderTestCase.java
===================================================================
--- modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/text/FastURLEncoderTestCase.java (rev 0)
+++ modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/text/FastURLEncoderTestCase.java 2007-09-12 18:29:07 UTC (rev 8246)
@@ -0,0 +1,149 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.test.common.text;
+
+import org.jboss.portal.common.text.FastURLEncoder;
+import org.jboss.portal.common.text.CharBuffer;
+import org.jboss.portal.common.text.CharEncoder;
+
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
+
+import junit.framework.TestCase;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class FastURLEncoderTestCase extends TestCase
+{
+
+ public void testEncodeThrowsIAE() throws Exception
+ {
+ CharEncoder encoder = FastURLEncoder.getInstance();
+ try
+ {
+ encoder.encode(new char[10], -1, 0, new CharBuffer());
+ fail();
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ try
+ {
+ encoder.encode(new char[10], 5, -1, new CharBuffer());
+ fail();
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ try
+ {
+ encoder.encode(new char[10], 15, 0, new CharBuffer());
+ fail();
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ try
+ {
+ encoder.encode(new char[10], 5, 6, new CharBuffer());
+ fail();
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ try
+ {
+ encoder.encode(null, 0, 5, new CharBuffer());
+ fail();
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ try
+ {
+ encoder.encode((char[])null, new CharBuffer());
+ fail();
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ try
+ {
+ encoder.encode((CharSequence)null, new CharBuffer());
+ fail();
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+
+ //
+ try
+ {
+ encoder.encode(new char[10], 0, 10, null);
+ fail();
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ try
+ {
+ encoder.encode(new char[10], null);
+ fail();
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ try
+ {
+ encoder.encode('A', null);
+ fail();
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ try
+ {
+ encoder.encode("abc", null);
+ fail();
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ }
+
+ public void testEncode() throws Exception
+ {
+ FastURLEncoder encoder = FastURLEncoder.getInstance();
+ StringBuffer tmp = new StringBuffer();
+ for (int i = 0;i < 512;i++)
+ {
+ tmp.append((char)i);
+ }
+ String s = tmp.toString();
+ String u1 = encoder.encode(s);
+ String u2 = URLEncoder.encode(s, "UTF8");
+ assertEquals(u2, u1);
+ }
+}
Added: modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/text/TextToolsTestCase.java
===================================================================
--- modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/text/TextToolsTestCase.java (rev 0)
+++ modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/text/TextToolsTestCase.java 2007-09-12 18:29:07 UTC (rev 8246)
@@ -0,0 +1,96 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.test.common.text;
+
+import junit.framework.TestCase;
+import org.jboss.portal.common.text.TextTools;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class TextToolsTestCase extends TestCase
+{
+
+ public void testIsAlphaNumeric()
+ {
+ assertForChar(false, 0, '0');
+ assertForChar(true, '0', '9' + 1);
+ assertForChar(false, '9' + 1, 'A');
+ assertForChar(true, 'A', 'Z' + 1);
+ assertForChar(false, 'Z' + 1, 'a');
+ assertForChar(true, 'a', 'z' + 1);
+ assertForChar(false, 'z' + 1, 512);
+ }
+
+ private void assertForChar(boolean result, int from, int to)
+ {
+ while (from < to)
+ {
+ assertEquals(result, TextTools.isAlphaNumeric((char)(from++)));
+ }
+ }
+
+ public void testToHex()
+ {
+ assertEquals('0', TextTools.toHex(0));
+ assertEquals('1', TextTools.toHex(1));
+ assertEquals('2', TextTools.toHex(2));
+ assertEquals('3', TextTools.toHex(3));
+ assertEquals('4', TextTools.toHex(4));
+ assertEquals('5', TextTools.toHex(5));
+ assertEquals('6', TextTools.toHex(6));
+ assertEquals('7', TextTools.toHex(7));
+ assertEquals('8', TextTools.toHex(8));
+ assertEquals('9', TextTools.toHex(9));
+ assertEquals('A', TextTools.toHex(10));
+ assertEquals('B', TextTools.toHex(11));
+ assertEquals('C', TextTools.toHex(12));
+ assertEquals('D', TextTools.toHex(13));
+ assertEquals('E', TextTools.toHex(14));
+ assertEquals('F', TextTools.toHex(15));
+ for (int i = 16;i < 512;i++)
+ {
+ try
+ {
+ TextTools.toHex(i);
+ fail("Was expecting an IAE at index=" + i);
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ }
+ for (int i = -512;i < 0;i++)
+ {
+ try
+ {
+ TextTools.toHex(i);
+ fail("Was expecting an IAE at index=" + i);
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ }
+ }
+
+}
Copied: modules/common/trunk/common/src/test/resources/bundle (from rev 8225, modules/common/trunk/common/src/resources/test/bundle)
Deleted: modules/common/trunk/common/src/test/resources/bundle/a_de_DE.properties
===================================================================
--- modules/common/trunk/common/src/resources/test/bundle/a_de_DE.properties 2007-09-11 12:36:29 UTC (rev 8225)
+++ modules/common/trunk/common/src/test/resources/bundle/a_de_DE.properties 2007-09-12 18:29:07 UTC (rev 8246)
@@ -1 +0,0 @@
-value=a_de_DE
\ No newline at end of file
Copied: modules/common/trunk/common/src/test/resources/bundle/a_de_DE.properties (from rev 8242, modules/common/trunk/common/src/resources/test/bundle/a_de_DE.properties)
===================================================================
--- modules/common/trunk/common/src/test/resources/bundle/a_de_DE.properties (rev 0)
+++ modules/common/trunk/common/src/test/resources/bundle/a_de_DE.properties 2007-09-12 18:29:07 UTC (rev 8246)
@@ -0,0 +1 @@
+value=a_de_DE
\ No newline at end of file
Deleted: modules/common/trunk/common/src/test/resources/bundle/a_fr.properties
===================================================================
--- modules/common/trunk/common/src/resources/test/bundle/a_fr.properties 2007-09-11 12:36:29 UTC (rev 8225)
+++ modules/common/trunk/common/src/test/resources/bundle/a_fr.properties 2007-09-12 18:29:07 UTC (rev 8246)
@@ -1 +0,0 @@
-value=a_fr
\ No newline at end of file
Copied: modules/common/trunk/common/src/test/resources/bundle/a_fr.properties (from rev 8242, modules/common/trunk/common/src/resources/test/bundle/a_fr.properties)
===================================================================
--- modules/common/trunk/common/src/test/resources/bundle/a_fr.properties (rev 0)
+++ modules/common/trunk/common/src/test/resources/bundle/a_fr.properties 2007-09-12 18:29:07 UTC (rev 8246)
@@ -0,0 +1 @@
+value=a_fr
\ No newline at end of file
Deleted: modules/common/trunk/common/src/test/resources/bundle/a_fr_FR.properties
===================================================================
--- modules/common/trunk/common/src/resources/test/bundle/a_fr_FR.properties 2007-09-11 12:36:29 UTC (rev 8225)
+++ modules/common/trunk/common/src/test/resources/bundle/a_fr_FR.properties 2007-09-12 18:29:07 UTC (rev 8246)
@@ -1 +0,0 @@
-value=a_fr_FR
\ No newline at end of file
Copied: modules/common/trunk/common/src/test/resources/bundle/a_fr_FR.properties (from rev 8242, modules/common/trunk/common/src/resources/test/bundle/a_fr_FR.properties)
===================================================================
--- modules/common/trunk/common/src/test/resources/bundle/a_fr_FR.properties (rev 0)
+++ modules/common/trunk/common/src/test/resources/bundle/a_fr_FR.properties 2007-09-12 18:29:07 UTC (rev 8246)
@@ -0,0 +1 @@
+value=a_fr_FR
\ No newline at end of file
Deleted: modules/common/trunk/common/src/test/resources/bundle/a_it.properties
===================================================================
--- modules/common/trunk/common/src/resources/test/bundle/a_it.properties 2007-09-11 12:36:29 UTC (rev 8225)
+++ modules/common/trunk/common/src/test/resources/bundle/a_it.properties 2007-09-12 18:29:07 UTC (rev 8246)
@@ -1 +0,0 @@
-value=a_it
\ No newline at end of file
Copied: modules/common/trunk/common/src/test/resources/bundle/a_it.properties (from rev 8242, modules/common/trunk/common/src/resources/test/bundle/a_it.properties)
===================================================================
--- modules/common/trunk/common/src/test/resources/bundle/a_it.properties (rev 0)
+++ modules/common/trunk/common/src/test/resources/bundle/a_it.properties 2007-09-12 18:29:07 UTC (rev 8246)
@@ -0,0 +1 @@
+value=a_it
\ No newline at end of file
Deleted: modules/common/trunk/common/src/test/resources/bundle/b.properties
===================================================================
--- modules/common/trunk/common/src/resources/test/bundle/b.properties 2007-09-11 12:36:29 UTC (rev 8225)
+++ modules/common/trunk/common/src/test/resources/bundle/b.properties 2007-09-12 18:29:07 UTC (rev 8246)
@@ -1 +0,0 @@
-value=b
\ No newline at end of file
Copied: modules/common/trunk/common/src/test/resources/bundle/b.properties (from rev 8242, modules/common/trunk/common/src/resources/test/bundle/b.properties)
===================================================================
--- modules/common/trunk/common/src/test/resources/bundle/b.properties (rev 0)
+++ modules/common/trunk/common/src/test/resources/bundle/b.properties 2007-09-12 18:29:07 UTC (rev 8246)
@@ -0,0 +1 @@
+value=b
\ No newline at end of file
Deleted: modules/common/trunk/common/src/test/resources/bundle/c_fr.properties
===================================================================
--- modules/common/trunk/common/src/resources/test/bundle/c_fr.properties 2007-09-11 12:36:29 UTC (rev 8225)
+++ modules/common/trunk/common/src/test/resources/bundle/c_fr.properties 2007-09-12 18:29:07 UTC (rev 8246)
@@ -1 +0,0 @@
-value=c_fr
\ No newline at end of file
Copied: modules/common/trunk/common/src/test/resources/bundle/c_fr.properties (from rev 8242, modules/common/trunk/common/src/resources/test/bundle/c_fr.properties)
===================================================================
--- modules/common/trunk/common/src/test/resources/bundle/c_fr.properties (rev 0)
+++ modules/common/trunk/common/src/test/resources/bundle/c_fr.properties 2007-09-12 18:29:07 UTC (rev 8246)
@@ -0,0 +1 @@
+value=c_fr
\ No newline at end of file
Deleted: modules/common/trunk/common/src/test/resources/bundle/d_fr_FR.properties
===================================================================
--- modules/common/trunk/common/src/resources/test/bundle/d_fr_FR.properties 2007-09-11 12:36:29 UTC (rev 8225)
+++ modules/common/trunk/common/src/test/resources/bundle/d_fr_FR.properties 2007-09-12 18:29:07 UTC (rev 8246)
@@ -1 +0,0 @@
-value=d_fr_FR
\ No newline at end of file
Copied: modules/common/trunk/common/src/test/resources/bundle/d_fr_FR.properties (from rev 8242, modules/common/trunk/common/src/resources/test/bundle/d_fr_FR.properties)
===================================================================
--- modules/common/trunk/common/src/test/resources/bundle/d_fr_FR.properties (rev 0)
+++ modules/common/trunk/common/src/test/resources/bundle/d_fr_FR.properties 2007-09-12 18:29:07 UTC (rev 8246)
@@ -0,0 +1 @@
+value=d_fr_FR
\ No newline at end of file
Deleted: modules/common/trunk/common/src/test/resources/bundle/e.properties
===================================================================
--- modules/common/trunk/common/src/resources/test/bundle/e.properties 2007-09-11 12:36:29 UTC (rev 8225)
+++ modules/common/trunk/common/src/test/resources/bundle/e.properties 2007-09-12 18:29:07 UTC (rev 8246)
@@ -1 +0,0 @@
-value=e
\ No newline at end of file
Copied: modules/common/trunk/common/src/test/resources/bundle/e.properties (from rev 8242, modules/common/trunk/common/src/resources/test/bundle/e.properties)
===================================================================
--- modules/common/trunk/common/src/test/resources/bundle/e.properties (rev 0)
+++ modules/common/trunk/common/src/test/resources/bundle/e.properties 2007-09-12 18:29:07 UTC (rev 8246)
@@ -0,0 +1 @@
+value=e
\ No newline at end of file
Deleted: modules/common/trunk/common/src/test/resources/bundle/e_fr.properties
===================================================================
--- modules/common/trunk/common/src/resources/test/bundle/e_fr.properties 2007-09-11 12:36:29 UTC (rev 8225)
+++ modules/common/trunk/common/src/test/resources/bundle/e_fr.properties 2007-09-12 18:29:07 UTC (rev 8246)
@@ -1 +0,0 @@
-value=e_fr
\ No newline at end of file
Copied: modules/common/trunk/common/src/test/resources/bundle/e_fr.properties (from rev 8242, modules/common/trunk/common/src/resources/test/bundle/e_fr.properties)
===================================================================
--- modules/common/trunk/common/src/test/resources/bundle/e_fr.properties (rev 0)
+++ modules/common/trunk/common/src/test/resources/bundle/e_fr.properties 2007-09-12 18:29:07 UTC (rev 8246)
@@ -0,0 +1 @@
+value=e_fr
\ No newline at end of file
Deleted: modules/common/trunk/common/src/test/resources/bundle/f.properties
===================================================================
--- modules/common/trunk/common/src/resources/test/bundle/f.properties 2007-09-11 12:36:29 UTC (rev 8225)
+++ modules/common/trunk/common/src/test/resources/bundle/f.properties 2007-09-12 18:29:07 UTC (rev 8246)
@@ -1 +0,0 @@
-value=f
Copied: modules/common/trunk/common/src/test/resources/bundle/f.properties (from rev 8242, modules/common/trunk/common/src/resources/test/bundle/f.properties)
===================================================================
--- modules/common/trunk/common/src/test/resources/bundle/f.properties (rev 0)
+++ modules/common/trunk/common/src/test/resources/bundle/f.properties 2007-09-12 18:29:07 UTC (rev 8246)
@@ -0,0 +1 @@
+value=f
Deleted: modules/common/trunk/common/src/test/resources/bundle/f_fr_FR.properties
===================================================================
--- modules/common/trunk/common/src/resources/test/bundle/f_fr_FR.properties 2007-09-11 12:36:29 UTC (rev 8225)
+++ modules/common/trunk/common/src/test/resources/bundle/f_fr_FR.properties 2007-09-12 18:29:07 UTC (rev 8246)
@@ -1 +0,0 @@
-value=f_fr_FR
\ No newline at end of file
Copied: modules/common/trunk/common/src/test/resources/bundle/f_fr_FR.properties (from rev 8242, modules/common/trunk/common/src/resources/test/bundle/f_fr_FR.properties)
===================================================================
--- modules/common/trunk/common/src/test/resources/bundle/f_fr_FR.properties (rev 0)
+++ modules/common/trunk/common/src/test/resources/bundle/f_fr_FR.properties 2007-09-12 18:29:07 UTC (rev 8246)
@@ -0,0 +1 @@
+value=f_fr_FR
\ No newline at end of file
Deleted: modules/common/trunk/common/src/test/resources/bundle/g_fr.properties
===================================================================
--- modules/common/trunk/common/src/resources/test/bundle/g_fr.properties 2007-09-11 12:36:29 UTC (rev 8225)
+++ modules/common/trunk/common/src/test/resources/bundle/g_fr.properties 2007-09-12 18:29:07 UTC (rev 8246)
@@ -1 +0,0 @@
-value=g_fr
Copied: modules/common/trunk/common/src/test/resources/bundle/g_fr.properties (from rev 8242, modules/common/trunk/common/src/resources/test/bundle/g_fr.properties)
===================================================================
--- modules/common/trunk/common/src/test/resources/bundle/g_fr.properties (rev 0)
+++ modules/common/trunk/common/src/test/resources/bundle/g_fr.properties 2007-09-12 18:29:07 UTC (rev 8246)
@@ -0,0 +1 @@
+value=g_fr
Deleted: modules/common/trunk/common/src/test/resources/bundle/g_fr_FR.properties
===================================================================
--- modules/common/trunk/common/src/resources/test/bundle/g_fr_FR.properties 2007-09-11 12:36:29 UTC (rev 8225)
+++ modules/common/trunk/common/src/test/resources/bundle/g_fr_FR.properties 2007-09-12 18:29:07 UTC (rev 8246)
@@ -1 +0,0 @@
-value=g_fr_FR
Copied: modules/common/trunk/common/src/test/resources/bundle/g_fr_FR.properties (from rev 8242, modules/common/trunk/common/src/resources/test/bundle/g_fr_FR.properties)
===================================================================
--- modules/common/trunk/common/src/test/resources/bundle/g_fr_FR.properties (rev 0)
+++ modules/common/trunk/common/src/test/resources/bundle/g_fr_FR.properties 2007-09-12 18:29:07 UTC (rev 8246)
@@ -0,0 +1 @@
+value=g_fr_FR
Deleted: modules/common/trunk/common/src/test/resources/bundle/h.properties
===================================================================
--- modules/common/trunk/common/src/resources/test/bundle/h.properties 2007-09-11 12:36:29 UTC (rev 8225)
+++ modules/common/trunk/common/src/test/resources/bundle/h.properties 2007-09-12 18:29:07 UTC (rev 8246)
@@ -1 +0,0 @@
-value=h
Copied: modules/common/trunk/common/src/test/resources/bundle/h.properties (from rev 8242, modules/common/trunk/common/src/resources/test/bundle/h.properties)
===================================================================
--- modules/common/trunk/common/src/test/resources/bundle/h.properties (rev 0)
+++ modules/common/trunk/common/src/test/resources/bundle/h.properties 2007-09-12 18:29:07 UTC (rev 8246)
@@ -0,0 +1 @@
+value=h
Deleted: modules/common/trunk/common/src/test/resources/bundle/h_fr.properties
===================================================================
--- modules/common/trunk/common/src/resources/test/bundle/h_fr.properties 2007-09-11 12:36:29 UTC (rev 8225)
+++ modules/common/trunk/common/src/test/resources/bundle/h_fr.properties 2007-09-12 18:29:07 UTC (rev 8246)
@@ -1 +0,0 @@
-value=h_fr
Copied: modules/common/trunk/common/src/test/resources/bundle/h_fr.properties (from rev 8242, modules/common/trunk/common/src/resources/test/bundle/h_fr.properties)
===================================================================
--- modules/common/trunk/common/src/test/resources/bundle/h_fr.properties (rev 0)
+++ modules/common/trunk/common/src/test/resources/bundle/h_fr.properties 2007-09-12 18:29:07 UTC (rev 8246)
@@ -0,0 +1 @@
+value=h_fr
Deleted: modules/common/trunk/common/src/test/resources/bundle/h_fr_FR.properties
===================================================================
--- modules/common/trunk/common/src/resources/test/bundle/h_fr_FR.properties 2007-09-11 12:36:29 UTC (rev 8225)
+++ modules/common/trunk/common/src/test/resources/bundle/h_fr_FR.properties 2007-09-12 18:29:07 UTC (rev 8246)
@@ -1 +0,0 @@
-value=h_fr_FR
Copied: modules/common/trunk/common/src/test/resources/bundle/h_fr_FR.properties (from rev 8242, modules/common/trunk/common/src/resources/test/bundle/h_fr_FR.properties)
===================================================================
--- modules/common/trunk/common/src/test/resources/bundle/h_fr_FR.properties (rev 0)
+++ modules/common/trunk/common/src/test/resources/bundle/h_fr_FR.properties 2007-09-12 18:29:07 UTC (rev 8246)
@@ -0,0 +1 @@
+value=h_fr_FR
Copied: modules/common/trunk/common/src/test/resources/implode (from rev 8225, modules/common/trunk/common/src/resources/test/implode)
Copied: modules/common/trunk/common/src/test/resources/implode/foo.sar (from rev 8242, modules/common/trunk/common/src/resources/test/implode/foo.sar)
Copied: modules/common/trunk/common/src/test/resources/test-jar (from rev 8225, modules/common/trunk/common/src/resources/test/test-jar)
Copied: modules/common/trunk/common/src/test/resources/test-jar/a1 (from rev 8242, modules/common/trunk/common/src/resources/test/test-jar/a1)
Deleted: modules/common/trunk/common/src/test/resources/test-jar/a3.txt
===================================================================
Copied: modules/common/trunk/common/src/test/resources/test-jar/a3.txt (from rev 8242, modules/common/trunk/common/src/resources/test/test-jar/a3.txt)
===================================================================
Copied: modules/common/trunk/common/src/test/resources/test01.code (from rev 8225, modules/common/trunk/common/src/resources/test/test01.code)
===================================================================
--- modules/common/trunk/common/src/test/resources/test01.code (rev 0)
+++ modules/common/trunk/common/src/test/resources/test01.code 2007-09-12 18:29:07 UTC (rev 8246)
@@ -0,0 +1,82 @@
+this is some plain text
+<table><tr><td>I love to write entities like < or > to see how the renderer interprets that
+check the line break around this line
+here we check the wellformdness of the HTML stuff because we enter a code section
+which must terminates any open HTML tag
+[b]bold[/b]
+[i]italic[/i]
+
+the next line is a quote of myself which contains code
+[quote=julien]
+[code]
+this is an XML sample, so the great than etc... should be displayed instead of
+being treated as entities
+<?xml version="1.0"?>
+[b]<root>[/b] the root element is bold
+</root>
+[/code]
+
+the code is closed, we are going to test the nested quotes
+[quote]
+this is a nested quote
+[/quote]
+the next line is code that contains no breaks
+[code]public static void[/code]
+[/quote]
+
+next one is a quote with no line break
+[quote]quote with no line break[/quote]
+
+
+we are going to test if the renderer closes the unclosed statements
+[b][i][u]bold, italic, underline[/b]
+
+[url]http://www.test.com[/url]
+
+[list]
+[*]first item
+[/list]
+
+[list]
+[*]first item
+[*]second item
+[/list]
+
+[list=1]
+[*]first item
+[*]second item
+[/list]
+
+[list=a]
+[*]first item
+[*]second item
+[/list]
+
+[size=25][color=#FF0000]big red[/color][/size]
+
+<code><pre>
+a
+ a
+ a
+ a
+</pre></code>
+<code>
+a
+ a
+ a
+ a
+</code>
+<pre>
+a
+ a
+ a
+ a
+</pre>
+[code]
+a
+ a
+ a
+ a
+[/code]
+
+this is the end of the message
Property changes on: modules/common/trunk/common/src/test/resources/test01.code
___________________________________________________________________
Name: svn:executable
+
18 years, 7 months