Author: bdaw
Date: 2008-02-22 18:26:34 -0500 (Fri, 22 Feb 2008)
New Revision: 10091
Added:
modules/test/trunk/test/src/main/java/org/jboss/portal/test/framework/common/
modules/test/trunk/test/src/main/java/org/jboss/portal/test/framework/common/Log4JWriter.java
modules/test/trunk/test/src/main/java/org/jboss/portal/test/framework/common/MultiValuedPropertyMap.java
modules/test/trunk/test/src/main/java/org/jboss/portal/test/framework/common/ParameterValidation.java
modules/test/trunk/test/src/main/java/org/jboss/portal/test/framework/common/Tools.java
modules/test/trunk/test/src/main/java/org/jboss/portal/test/framework/common/io/
modules/test/trunk/test/src/main/java/org/jboss/portal/test/framework/common/io/IOTools.java
modules/test/trunk/test/src/main/java/org/jboss/portal/test/framework/common/io/Serialization.java
modules/test/trunk/test/src/main/java/org/jboss/portal/test/framework/common/io/SerializationFilter.java
modules/test/trunk/test/src/main/java/org/jboss/portal/test/framework/common/io/UndeclaredIOException.java
modules/test/trunk/test/src/main/java/org/jboss/portal/test/framework/common/xml/
modules/test/trunk/test/src/main/java/org/jboss/portal/test/framework/common/xml/TooManyElementException.java
modules/test/trunk/test/src/main/java/org/jboss/portal/test/framework/common/xml/XMLTools.java
Modified:
modules/test/trunk/build/pom.xml
modules/test/trunk/docs/pom.xml
modules/test/trunk/docs/user-guide/pom.xml
modules/test/trunk/mc/pom.xml
modules/test/trunk/pom.xml
modules/test/trunk/remote/pom.xml
modules/test/trunk/test/agent/pom.xml
modules/test/trunk/test/core/pom.xml
modules/test/trunk/test/generic/pom.xml
modules/test/trunk/test/jboss/pom.xml
modules/test/trunk/test/opends/pom.xml
modules/test/trunk/test/src/main/java/org/jboss/portal/test/framework/embedded/DSConfig.java
modules/test/trunk/test/src/main/java/org/jboss/portal/test/framework/embedded/DataSourceSupport.java
modules/test/trunk/test/src/main/java/org/jboss/portal/test/framework/embedded/HibernateSupport.java
modules/test/trunk/test/src/main/java/org/jboss/portal/test/framework/impl/generic/config/ServerConfig.java
modules/test/trunk/tooling/ant/pom.xml
modules/test/trunk/tooling/core/pom.xml
modules/test/trunk/tooling/examples/maven2/pom.xml
modules/test/trunk/tooling/maven2/pom.xml
modules/test/trunk/tooling/pom.xml
modules/test/trunk/unit/pom.xml
Log:
remove dependency to portal common and change version to 1.2.0.Beta2
Modified: modules/test/trunk/build/pom.xml
===================================================================
--- modules/test/trunk/build/pom.xml 2008-02-22 16:28:22 UTC (rev 10090)
+++ modules/test/trunk/build/pom.xml 2008-02-22 23:26:34 UTC (rev 10091)
@@ -18,14 +18,13 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.jboss.unit</groupId>
<artifactId>module-parent</artifactId>
- <version>1.2.0-SNAPSHOT</version>
+ <version>1.2.0.Beta2</version>
<packaging>pom</packaging>
<name>JBoss Portal Test Module</name>
<
url>http://www.jboss.com/products/jbossmc</url>
<description>JBoss Portal Test Module</description>
<properties>
- <version.portal.common>1.2.0-SNAPSHOT</version.portal.common>
<version.jboss.microcontainer>2.0.0.Beta9</version.jboss.microcontainer>
<version.apache.httpclient>3.0.1</version.apache.httpclient>
<version.cargo>0.9-portal</version.cargo>
@@ -39,6 +38,10 @@
<version.junit>3.8.1</version.junit>
<version.log4j>1.2.14</version.log4j>
<version.sleepycat>3.0.12</version.sleepycat>
+ <version.jboss-j2ee>4.2.0.GA</version.jboss-j2ee>
+ <version.jboss-common-core>2.2.0.GA</version.jboss-common-core>
+ <version.jboss-jmx>4.2.0.GA</version.jboss-jmx>
+ <version.jboss-system>4.2.0.GA</version.jboss-system>
</properties>
@@ -128,11 +131,6 @@
</dependency>
- <dependency>
- <groupId>org.jboss.portal.common</groupId>
- <artifactId>common-common</artifactId>
- <version>${version.portal.common}</version>
- </dependency>
<dependency>
<groupId>org.jboss.microcontainer</groupId>
@@ -244,6 +242,27 @@
<version>${version.sleepycat}</version>
</dependency>
+ <dependency>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-j2ee</artifactId>
+ <version>${version.jboss-j2ee}</version>
+ </dependency>
+ <dependency>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-common-core</artifactId>
+ <version>${version.jboss-common-core}</version>
+ </dependency>
+ <dependency>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-jmx</artifactId>
+ <version>${version.jboss-jmx}</version>
+ </dependency>
+ <dependency>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-system</artifactId>
+ <version>${version.jboss-system}</version>
+ </dependency>
+
</dependencies>
</dependencyManagement>
Modified: modules/test/trunk/docs/pom.xml
===================================================================
--- modules/test/trunk/docs/pom.xml 2008-02-22 16:28:22 UTC (rev 10090)
+++ modules/test/trunk/docs/pom.xml 2008-02-22 23:26:34 UTC (rev 10091)
@@ -4,13 +4,13 @@
<parent>
<groupId>org.jboss.unit</groupId>
<artifactId>module-parent</artifactId>
- <version>1.2.0-SNAPSHOT</version>
+ <version>1.2.0.Beta2</version>
<relativePath>../build/pom.xml</relativePath>
</parent>
<artifactId>docs-aggregator</artifactId>
<packaging>pom</packaging>
<name>JBoss Portal Portlet Docs Aggregator</name>
- <version>1.2.0-SNAPSHOT</version>
+ <version>1.2.0.Beta2</version>
<
url>http://labs.jboss.com/jbossportal</url>
<modules>
Modified: modules/test/trunk/docs/user-guide/pom.xml
===================================================================
--- modules/test/trunk/docs/user-guide/pom.xml 2008-02-22 16:28:22 UTC (rev 10090)
+++ modules/test/trunk/docs/user-guide/pom.xml 2008-02-22 23:26:34 UTC (rev 10091)
@@ -60,7 +60,7 @@
<groupId>org.jboss.unit</groupId>
<artifactId>user-guide-${translation}</artifactId>
- <version>1.2.0-SNAPSHOT</version>
+ <version>1.2.0.Beta2</version>
<packaging>jdocbook</packaging>
<name>User_Guide_(${translation})</name>
Modified: modules/test/trunk/mc/pom.xml
===================================================================
--- modules/test/trunk/mc/pom.xml 2008-02-22 16:28:22 UTC (rev 10090)
+++ modules/test/trunk/mc/pom.xml 2008-02-22 23:26:34 UTC (rev 10091)
@@ -3,7 +3,7 @@
<parent>
<groupId>org.jboss.unit</groupId>
<artifactId>module-parent</artifactId>
- <version>1.2.0-SNAPSHOT</version>
+ <version>1.2.0.Beta2</version>
<relativePath>../build/pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Modified: modules/test/trunk/pom.xml
===================================================================
--- modules/test/trunk/pom.xml 2008-02-22 16:28:22 UTC (rev 10090)
+++ modules/test/trunk/pom.xml 2008-02-22 23:26:34 UTC (rev 10091)
@@ -5,7 +5,7 @@
<artifactId>module-aggregator</artifactId>
<packaging>pom</packaging>
<name>JBoss Portal Modules Test</name>
- <version>1.2.0-SNAPSHOT</version>
+ <version>1.2.0.Beta2</version>
<
url>http://labs.jboss.com/jbossportal</url>
<dependencies/>
Modified: modules/test/trunk/remote/pom.xml
===================================================================
--- modules/test/trunk/remote/pom.xml 2008-02-22 16:28:22 UTC (rev 10090)
+++ modules/test/trunk/remote/pom.xml 2008-02-22 23:26:34 UTC (rev 10091)
@@ -3,7 +3,7 @@
<parent>
<groupId>org.jboss.unit</groupId>
<artifactId>module-parent</artifactId>
- <version>1.2.0-SNAPSHOT</version>
+ <version>1.2.0.Beta2</version>
<relativePath>../build/pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Modified: modules/test/trunk/test/agent/pom.xml
===================================================================
--- modules/test/trunk/test/agent/pom.xml 2008-02-22 16:28:22 UTC (rev 10090)
+++ modules/test/trunk/test/agent/pom.xml 2008-02-22 23:26:34 UTC (rev 10091)
@@ -3,7 +3,7 @@
<parent>
<groupId>org.jboss.unit</groupId>
<artifactId>module-parent</artifactId>
- <version>1.2.0-SNAPSHOT</version>
+ <version>1.2.0.Beta2</version>
<relativePath>../../build/pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
@@ -13,10 +13,6 @@
<dependencies>
<dependency>
- <groupId>org.jboss.portal.common</groupId>
- <artifactId>common-common</artifactId>
- </dependency>
- <dependency>
<groupId>cargo</groupId>
<artifactId>core</artifactId>
</dependency>
Modified: modules/test/trunk/test/core/pom.xml
===================================================================
--- modules/test/trunk/test/core/pom.xml 2008-02-22 16:28:22 UTC (rev 10090)
+++ modules/test/trunk/test/core/pom.xml 2008-02-22 23:26:34 UTC (rev 10091)
@@ -3,7 +3,7 @@
<parent>
<groupId>org.jboss.unit</groupId>
<artifactId>module-parent</artifactId>
- <version>1.2.0-SNAPSHOT</version>
+ <version>1.2.0.Beta2</version>
<relativePath>../../build/pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
@@ -13,10 +13,6 @@
<dependencies>
<dependency>
- <groupId>org.jboss.portal.common</groupId>
- <artifactId>common-common</artifactId>
- </dependency>
- <dependency>
<groupId>cargo</groupId>
<artifactId>core</artifactId>
</dependency>
@@ -52,6 +48,26 @@
<groupId>jboss.jbossas.core-libs</groupId>
<artifactId>jboss</artifactId>
</dependency>
+ <dependency>
+ <groupId>apache-log4j</groupId>
+ <artifactId>log4j</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-j2ee</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-common-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-jmx</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-system</artifactId>
+ </dependency>
</dependencies>
<build>
Modified: modules/test/trunk/test/generic/pom.xml
===================================================================
--- modules/test/trunk/test/generic/pom.xml 2008-02-22 16:28:22 UTC (rev 10090)
+++ modules/test/trunk/test/generic/pom.xml 2008-02-22 23:26:34 UTC (rev 10091)
@@ -3,7 +3,7 @@
<parent>
<groupId>org.jboss.unit</groupId>
<artifactId>module-parent</artifactId>
- <version>1.2.0-SNAPSHOT</version>
+ <version>1.2.0.Beta2</version>
<relativePath>../../build/pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
@@ -13,10 +13,6 @@
<dependencies>
<dependency>
- <groupId>org.jboss.portal.common</groupId>
- <artifactId>common-common</artifactId>
- </dependency>
- <dependency>
<groupId>cargo</groupId>
<artifactId>core</artifactId>
</dependency>
@@ -56,6 +52,14 @@
<groupId>jboss</groupId>
<artifactId>jboss-remoting</artifactId>
</dependency>
+ <dependency>
+ <groupId>apache-log4j</groupId>
+ <artifactId>log4j</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-common-core</artifactId>
+ </dependency>
</dependencies>
<build>
@@ -76,6 +80,7 @@
<include>org/jboss/portal/test/framework/agent/**</include>
<include>org/jboss/portal/test/framework/server/**</include>
+
<include>org/jboss/portal/test/framework/common/**</include>
</includes>
</configuration>
</plugin>
Modified: modules/test/trunk/test/jboss/pom.xml
===================================================================
--- modules/test/trunk/test/jboss/pom.xml 2008-02-22 16:28:22 UTC (rev 10090)
+++ modules/test/trunk/test/jboss/pom.xml 2008-02-22 23:26:34 UTC (rev 10091)
@@ -3,7 +3,7 @@
<parent>
<groupId>org.jboss.unit</groupId>
<artifactId>module-parent</artifactId>
- <version>1.2.0-SNAPSHOT</version>
+ <version>1.2.0.Beta2</version>
<relativePath>../../build/pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
@@ -13,10 +13,6 @@
<dependencies>
<dependency>
- <groupId>org.jboss.portal.common</groupId>
- <artifactId>common-common</artifactId>
- </dependency>
- <dependency>
<groupId>cargo</groupId>
<artifactId>core</artifactId>
</dependency>
@@ -56,6 +52,10 @@
<groupId>jboss</groupId>
<artifactId>jboss-remoting</artifactId>
</dependency>
+ <dependency>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-common-core</artifactId>
+ </dependency>
</dependencies>
<build>
Modified: modules/test/trunk/test/opends/pom.xml
===================================================================
--- modules/test/trunk/test/opends/pom.xml 2008-02-22 16:28:22 UTC (rev 10090)
+++ modules/test/trunk/test/opends/pom.xml 2008-02-22 23:26:34 UTC (rev 10091)
@@ -3,7 +3,7 @@
<parent>
<groupId>org.jboss.unit</groupId>
<artifactId>module-parent</artifactId>
- <version>1.2.0-SNAPSHOT</version>
+ <version>1.2.0.Beta2</version>
<relativePath>../../build/pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Added:
modules/test/trunk/test/src/main/java/org/jboss/portal/test/framework/common/Log4JWriter.java
===================================================================
---
modules/test/trunk/test/src/main/java/org/jboss/portal/test/framework/common/Log4JWriter.java
(rev 0)
+++
modules/test/trunk/test/src/main/java/org/jboss/portal/test/framework/common/Log4JWriter.java 2008-02-22
23:26:34 UTC (rev 10091)
@@ -0,0 +1,86 @@
+/*
+* 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.framework.common;
+
+import org.apache.log4j.Logger;
+import org.apache.log4j.Level;
+
+import java.io.Writer;
+import java.io.IOException;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 5451 $
+ */
+public class Log4JWriter extends Writer
+{
+
+ /** The open/closed status. */
+ private boolean open;
+
+ /** The logger. */
+ private Logger log;
+
+ /** The logging level. */
+ private Level level;
+
+ /**
+ * @throws IllegalArgumentException if log or level is null
+ */
+ public Log4JWriter(Logger log, Level level) throws IllegalArgumentException
+ {
+ if (log == null)
+ {
+ throw new IllegalArgumentException("No logger provided");
+ }
+ if (level == null)
+ {
+ throw new IllegalArgumentException("No level provided");
+ }
+ this.open = false;
+ this.log = log;
+ this.level = level;
+ }
+
+ public void write(char cbuf[], int off, int len) throws IOException
+ {
+ if (open)
+ {
+ log.log(level, new String(cbuf, off, len));
+ }
+ else
+ {
+ throw new IOException("Stream closed");
+ }
+ }
+
+ public void flush() throws IOException
+ {
+ }
+
+ public void close() throws IOException
+ {
+ open = false;
+ }
+}
+
Added:
modules/test/trunk/test/src/main/java/org/jboss/portal/test/framework/common/MultiValuedPropertyMap.java
===================================================================
---
modules/test/trunk/test/src/main/java/org/jboss/portal/test/framework/common/MultiValuedPropertyMap.java
(rev 0)
+++
modules/test/trunk/test/src/main/java/org/jboss/portal/test/framework/common/MultiValuedPropertyMap.java 2008-02-22
23:26:34 UTC (rev 10091)
@@ -0,0 +1,44 @@
+/*
+* 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.framework.common;
+
+import java.util.List;
+import java.util.Set;
+
+/**
+ * A property map with multi valued properties.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public interface MultiValuedPropertyMap<T>
+{
+ T getValue(String key) throws IllegalArgumentException;
+ List<T> getValues(String key) throws IllegalArgumentException;
+ void addValue(String key, T value) throws IllegalArgumentException;
+ void setValue(String key, T value) throws IllegalArgumentException;
+ Set<String> keySet();
+ void clear();
+ int size();
+ void append(MultiValuedPropertyMap<T> appended) throws
IllegalArgumentException;
+}
Added:
modules/test/trunk/test/src/main/java/org/jboss/portal/test/framework/common/ParameterValidation.java
===================================================================
---
modules/test/trunk/test/src/main/java/org/jboss/portal/test/framework/common/ParameterValidation.java
(rev 0)
+++
modules/test/trunk/test/src/main/java/org/jboss/portal/test/framework/common/ParameterValidation.java 2008-02-22
23:26:34 UTC (rev 10091)
@@ -0,0 +1,67 @@
+/*
+* 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.framework.common;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
+ * @version $Revision: 5757 $
+ * @since 2.4 (May 31, 2006)
+ */
+public class ParameterValidation
+{
+ public static void throwIllegalArgExceptionIfNullOrEmpty(String valueToCheck, String
valueName, String contextName)
+ {
+ if (isNullOrEmpty(valueToCheck))
+ {
+ throw new IllegalArgumentException((contextName != null ? contextName + "
r" : "R") + "equires a non-null, non-empty " + valueName);
+ }
+ }
+
+ /** @since 2.6 */
+ public static boolean isNullOrEmpty(String valueToCheck)
+ {
+ return valueToCheck == null || valueToCheck.length() == 0;
+ }
+
+ public static void throwIllegalArgExceptionIfNull(Object objectToTest, String name)
+ {
+ if (objectToTest == null)
+ {
+ throw new IllegalArgumentException("Must pass a non null " + name);
+ }
+ }
+
+ /** @since 2.4.1 */
+ public static void throwIllegalArgExceptionIfNullOrEmpty(Object[] array, String name)
+ {
+ if (array == null)
+ {
+ throw new IllegalArgumentException("Must pass a non-null " + name);
+ }
+ if (array.length == 0)
+ {
+ throw new IllegalArgumentException("Must pass a non-empty " + name);
+ }
+ }
+}
+
Added:
modules/test/trunk/test/src/main/java/org/jboss/portal/test/framework/common/Tools.java
===================================================================
---
modules/test/trunk/test/src/main/java/org/jboss/portal/test/framework/common/Tools.java
(rev 0)
+++
modules/test/trunk/test/src/main/java/org/jboss/portal/test/framework/common/Tools.java 2008-02-22
23:26:34 UTC (rev 10091)
@@ -0,0 +1,1023 @@
+/*
+* 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.framework.common;
+
+import org.apache.log4j.Level;
+import org.apache.log4j.Logger;
+
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.io.Writer;
+import java.lang.reflect.Array;
+import java.math.BigInteger;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.net.UnknownHostException;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Enumeration;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.NoSuchElementException;
+import java.util.ResourceBundle;
+import java.util.Set;
+import java.util.Collections;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @author <a href="mailto:boleslaw dot dawidowicz at jboss.com">Boleslaw
Dawidowicz</a>
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
+ * @version $Revision: 7377 $
+ */
+public class Tools
+{
+
+ public static final int DEFAULT_BUFFER_SIZE = 512;
+
+ public static final Logger log = Logger.getLogger(Tools.class);
+
+ /** 16 chars long VMID. */
+ public static final String VMID = VMID();
+
+ private static String VMID()
+ {
+ try
+ {
+ BigInteger bi = BigInteger.valueOf(0);
+ byte[] address = java.net.InetAddress.getLocalHost().getAddress();
+ for (int i = 0; i < 4; i++)
+ {
+ bi = bi.shiftLeft(8);
+ bi = bi.add(BigInteger.valueOf(address[i]));
+ }
+ bi = bi.shiftLeft(32);
+ int code = System.identityHashCode(new Object());
+ bi = bi.add(BigInteger.valueOf(code));
+ byte[] bytes = bi.toByteArray();
+ StringBuffer buffer = new StringBuffer();
+ char[] chars = "0123456789ABCDEF".toCharArray();
+ for (int i = 0; i < bytes.length; i++)
+ {
+ buffer.append(chars[(bytes[i] & 0xF0) >> 4]).append(chars[bytes[i]
& 0xF]);
+ }
+ return buffer.toString();
+ }
+ catch (UnknownHostException e)
+ {
+ e.printStackTrace(System.err);
+ throw new Error("Cannot create VMID");
+ }
+ }
+
+ public static final Enumeration EMPTY_ENUMERATION = new Enumeration()
+ {
+ public boolean hasMoreElements()
+ {
+ return false;
+ }
+
+ public Object nextElement()
+ {
+ throw new NoSuchElementException();
+ }
+ };
+
+ public static final Iterator EMPTY_ITERATOR = new Iterator()
+ {
+ public boolean hasNext()
+ {
+ return false;
+ }
+
+ public Object next()
+ {
+ throw new NoSuchElementException();
+ }
+
+ public void remove()
+ {
+ throw new UnsupportedOperationException();
+ }
+ };
+
+ public static final ResourceBundle EMPTY_BUNDLE = new ResourceBundle()
+ {
+ protected Object handleGetObject(String key)
+ {
+ return null;
+ }
+
+ public Enumeration getKeys()
+ {
+ return EMPTY_ENUMERATION;
+ }
+ };
+
+ public static <E> Enumeration<E> emptyEnumeration()
+ {
+ return (Enumeration<E>)EMPTY_ENUMERATION;
+ }
+
+ public static <E> Iterator<E> emptyIterator()
+ {
+ return (Iterator<E>)EMPTY_ITERATOR;
+ }
+
+ public static <E> Enumeration<E> toEnumeration(final Iterator<E>
iterator)
+ {
+ if (iterator == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ return new Enumeration<E>()
+ {
+ public boolean hasMoreElements()
+ {
+ return iterator.hasNext();
+ }
+
+ public E nextElement()
+ {
+ return iterator.next();
+ }
+ };
+ }
+
+ public static <E> Enumeration<E> toEnumeration(final E[] objects)
+ {
+ if (objects == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ return new Enumeration<E>()
+ {
+ int index = 0;
+
+ public boolean hasMoreElements()
+ {
+ return index < objects.length;
+ }
+
+ public E nextElement()
+ {
+ if (index < objects.length)
+ {
+ return objects[index++];
+ }
+ else
+ {
+ throw new NoSuchElementException();
+ }
+ }
+ };
+ }
+
+ public static <E> Enumeration<E> toEnumeration(final E o)
+ {
+ return new Enumeration<E>()
+ {
+ boolean hasMore = true;
+
+ public boolean hasMoreElements()
+ {
+ return hasMore;
+ }
+
+ public E nextElement()
+ {
+ if (hasMore)
+ {
+ hasMore = false;
+ }
+ else
+ {
+ throw new NoSuchElementException();
+ }
+ return o;
+ }
+ };
+ }
+
+ public static <E> Set<E> toSet(Enumeration<E> e)
+ {
+ if (e == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ HashSet<E> set = new HashSet<E>();
+ while (e.hasMoreElements())
+ {
+ set.add(e.nextElement());
+ }
+ return set;
+ }
+
+ public static <E> Set<E> toSet(E... objects)
+ {
+ if (objects == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ HashSet<E> set = new HashSet<E>();
+ for (E object : objects)
+ {
+ set.add(object);
+ }
+ return set;
+ }
+
+ /**
+ * Transforms an iterator into an unordered Set
+ *
+ * @param iterator The iterator to transform
+ * @return A HashSet
+ */
+ public static <E> Set<E> toSet(Iterator<E> iterator)
+ {
+ if (iterator == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ return toSet(iterator, false);
+ }
+
+ /**
+ * Transforms an iterator into a Set
+ *
+ * @param iterator The iterator to transform
+ * @param preserveOrder true if the set must respect the ordering of the iterator
+ * @return a LinkedHashSet if ordered is true, a HashSet otherwise
+ */
+ public static <E> Set<E> toSet(Iterator<E> iterator, boolean
preserveOrder)
+ {
+ if (iterator == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ Set<E> set;
+ if (preserveOrder)
+ {
+ set = new LinkedHashSet<E>();
+ }
+ else
+ {
+ set = new HashSet<E>();
+ }
+ while (iterator.hasNext())
+ {
+ set.add(iterator.next());
+ }
+ return set;
+ }
+
+ public static <E> List<E> toList(Enumeration<E> e)
+ {
+ if (e == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ List<E> list = new ArrayList<E>();
+ while (e.hasMoreElements())
+ {
+ list.add(e.nextElement());
+ }
+ return list;
+ }
+
+ public static <E> List<E> toList(Iterator<E> iterator)
+ {
+ if (iterator == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ List<E> list = new ArrayList<E>();
+ while (iterator.hasNext())
+ {
+ list.add(iterator.next());
+ }
+ return list;
+ }
+
+ public static <E> List<E> toList(E... objects)
+ {
+ if (objects == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ List<E> list = new ArrayList<E>(objects.length);
+ for (E object : objects)
+ {
+ list.add(object);
+ }
+ return list;
+ }
+
+ /**
+ * Consider remove this method as it cannot be generified.
+ *
+ * @param i
+ * @return
+ */
+ @Deprecated
+ public static Object[] toArray(Iterator i)
+ {
+ // This method cannot be generified.
+ return toList(i).toArray();
+ }
+
+ /**
+ * Returns a singleton iterator.
+ *
+ * @param o the singleton object
+ * @return the iterator
+ */
+ public static <E> Iterator<E> iterator(final E o)
+ {
+ return new Iterator<E>()
+ {
+ /** The status of the iterator. */
+ boolean done = false;
+
+ public boolean hasNext()
+ {
+ return !done;
+ }
+
+ public E next()
+ {
+ if (done)
+ {
+ throw new NoSuchElementException("Already iterated");
+ }
+ done = true;
+ return o;
+ }
+
+ public void remove()
+ {
+ throw new UnsupportedOperationException("read only");
+ }
+ };
+ }
+
+ /**
+ * Returns an iterator over the array elements.
+ *
+ * @param objects the array containing the objects to iterate on
+ * @return the iterator
+ * @throws IllegalArgumentException if the object array is null or the specified range
is not valid
+ */
+ public static <E> Iterator<E> iterator(final E... objects) throws
IllegalArgumentException
+ {
+ if (objects == null)
+ {
+ throw new IllegalArgumentException("No null object array");
+ }
+ return iterator(objects, 0, objects.length);
+ }
+
+ /**
+ * Returns an iterator over the array elements within the specified range. The range
is considered as valid
+ * if the from argument is greater or equals than zero, the to argument is lesser or
equals than array size
+ * and the from argument is lesser or equals to the to argument.
+ *
+ * @param objects the array containing the objects to iterate on
+ * @param from the inclusive start index
+ * @param to the exclusive stop index
+ * @return the iterator
+ * @throws IllegalArgumentException if the object array is null or the specified range
is not valid or if the range is not valid
+ */
+ public static <E> Iterator<E> iterator(final E[] objects, final int from,
final int to) throws IllegalArgumentException
+ {
+ if (objects == null)
+ {
+ throw new IllegalArgumentException("No null object array");
+ }
+ if (from > to || from < 0 || to > objects.length)
+ {
+ throw new IllegalArgumentException("Invalid range [" + from +
"," + to + "] for array of length " + objects.length);
+ }
+ return new Iterator<E>()
+ {
+ /** . */
+ int index = from;
+
+ public boolean hasNext()
+ {
+ return index < to;
+ }
+
+ public E next()
+ {
+ if (index >= to)
+ {
+ throw new NoSuchElementException("Index is greater than the array
length");
+ }
+ return objects[index++];
+ }
+
+ public void remove()
+ {
+ throw new UnsupportedOperationException("read only");
+ }
+ };
+ }
+
+ public static int computeStringHash(int hash, String s)
+ {
+ char[] chars = s.toCharArray();
+ int length = chars.length;
+ for (int i = 0; i < length; i++)
+ {
+ char c = chars[i];
+ hash = 31 * hash + c;
+ }
+ return hash;
+ }
+
+ /**
+ * Computes an md5 hash of a string.
+ *
+ * @param text the hashed string
+ * @return the string hash
+ * @throws NullPointerException if text is null
+ */
+ public static byte[] md5(String text)
+ {
+ // arguments check
+ if (text == null)
+ {
+ throw new NullPointerException("null text");
+ }
+
+ try
+ {
+ MessageDigest md = MessageDigest.getInstance("MD5");
+ md.update(text.getBytes());
+ return md.digest();
+ }
+ catch (NoSuchAlgorithmException e)
+ {
+ log.error("Cannot find MD5 algorithm", e);
+ throw new RuntimeException("Cannot find MD5 algorithm");
+ }
+ }
+
+ /**
+ * Computes an md5 hash and returns the result as a string in hexadecimal format.
+ *
+ * @param text the hashed string
+ * @return the string hash
+ * @throws NullPointerException if text is null
+ */
+ public static String md5AsHexString(String text)
+ {
+ return toHexString(md5(text));
+ }
+
+ /**
+ * Computes a hash with specified algorighm and returns the result as a string in
hexadecimal format
+ *
+ * @param text
+ * @param algorithm
+ * @param encoding
+ * @return
+ * @throws NoSuchAlgorithmException
+ */
+ public static String hashAndEncodeString(String text, String algorithm, String
encoding) throws NoSuchAlgorithmException
+ {
+ // arguments check
+ if (text == null)
+ {
+ throw new NullPointerException("null text");
+ }
+ if (algorithm == null)
+ {
+ throw new NullPointerException("null algorithm");
+ }
+ if (encoding == null)
+ {
+ throw new NullPointerException("null encoding");
+ }
+
+ MessageDigest md = MessageDigest.getInstance(algorithm);
+ md.update(text.getBytes());
+ byte[] encoded = md.digest();
+
+ if ("HEX".equalsIgnoreCase(encoding))
+ {
+ return toHexString(encoded);
+ }
+ //TODO: add base64 support here
+ else
+ {
+ throw new IllegalArgumentException("Not supported encoding: " +
encoding);
+ }
+
+ }
+
+
+ /**
+ * Returns a string in the hexadecimal format.
+ *
+ * @param bytes the converted bytes
+ * @return the hexadecimal string representing the bytes data
+ * @throws IllegalArgumentException if the byte array is null
+ */
+ public static String toHexString(byte[] bytes)
+ {
+ if (bytes == null)
+ {
+ throw new IllegalArgumentException("byte array must not be null");
+ }
+ StringBuffer hex = new StringBuffer(bytes.length * 2);
+ for (int i = 0; i < bytes.length; i++)
+ {
+ hex.append(Character.forDigit((bytes[i] & 0XF0) >> 4, 16));
+ hex.append(Character.forDigit((bytes[i] & 0X0F), 16));
+ }
+ return hex.toString();
+ }
+
+ /**
+ * Returns a byte array converted from the hexadecimal format.
+ *
+ * @param hex the string to convert
+ * @return the byte array corresponding
+ * @throws IllegalArgumentException if the string is null or does not have the good
format
+ */
+ public static byte[] fromHexString(String hex)
+ {
+ if (hex == null)
+ {
+ throw new IllegalArgumentException("Hex string must not be null");
+ }
+ if (hex.length() % 2 == 1)
+ {
+ throw new IllegalArgumentException("Hex string length is not even : "
+ hex.length());
+ }
+ int index = 0;
+ byte[] bytes = new byte[hex.length() / 2];
+ for (int i = 0; i < bytes.length; i++)
+ {
+ char chigh = hex.charAt(index++);
+ int high = Character.digit(chigh, 16);
+ if (high == -1)
+ {
+ throw new IllegalArgumentException("Hex string contains a bad char :
" + chigh);
+ }
+ char clow = hex.charAt(index++);
+ int low = Character.digit(clow, 16);
+ if (low == -1)
+ {
+ throw new IllegalArgumentException("Hex string contains a bad char :
" + clow);
+ }
+ byte value = (byte)((high << 4) + low);
+ bytes[i] = value;
+ }
+ return bytes;
+ }
+
+ /**
+ *
+ */
+ public static String generateTemporaryHash(String value, long time)
+ {
+ if (value == null)
+ {
+ throw new IllegalArgumentException("id must not be null");
+ }
+
+ Calendar calendar = Calendar.getInstance();
+ calendar.setTimeInMillis(time);
+ calendar.set(Calendar.MINUTE, 0);
+ calendar.set(Calendar.SECOND, 0);
+ calendar.set(Calendar.MILLISECOND, 0);
+ return md5AsHexString(value + calendar.getTimeInMillis());
+ }
+
+ /**
+ *
+ */
+ public static boolean confirmTemporaryHash(String hash, String value, long time)
+ {
+ if (hash == null)
+ {
+ return false;
+ }
+ if (value == null)
+ {
+ throw new IllegalArgumentException("value must not be null");
+ }
+
+ Calendar calendar = Calendar.getInstance();
+ calendar.setTimeInMillis(time);
+ calendar.set(Calendar.MINUTE, 0);
+ calendar.set(Calendar.SECOND, 0);
+ calendar.set(Calendar.MILLISECOND, 0);
+ String expected = md5AsHexString(value + calendar.getTimeInMillis());
+ if (expected.equals(hash))
+ {
+ return true;
+ }
+ calendar.add(Calendar.HOUR_OF_DAY, -1);
+ expected = md5AsHexString(value + calendar.getTimeInMillis());
+ return expected.equals(hash);
+ }
+
+ public static String getShortNameOf(Class clazz)
+ {
+ return clazz.getSimpleName();
+ }
+
+ public static String getPackageOf(Class clazz)
+ {
+ String name = clazz.getName();
+ int index = name.lastIndexOf('.');
+ if (index != -1)
+ {
+ name = name.substring(0, index);
+ }
+ else
+ {
+ name = "";
+ }
+ return name;
+ }
+
+ public static String buildClassLoaderInfo(ClassLoader loader)
+ {
+ if (loader == null)
+ {
+ throw new IllegalArgumentException("no loader");
+ }
+ StringBuffer buffer = new StringBuffer();
+ buffer.append("ClassLoader[Name=").append(loader.getClass().getName());
+ buffer.append(",HashCode=").append(loader.hashCode());
+
buffer.append(",IdentityHashCode=").append(System.identityHashCode(loader));
+ if (loader instanceof URLClassLoader)
+ {
+ URLClassLoader urlLoader = (URLClassLoader)loader;
+ URL[] urls = urlLoader.getURLs();
+ for (int i = 0; i < urls.length; i++)
+ {
+ URL url = urls[i];
+
buffer.append(",URL(").append(i).append(")=").append(url);
+ }
+ }
+ try
+ {
+ Class uclClass =
Thread.currentThread().getContextClassLoader().loadClass("org.jboss.mx.loading.UnifiedClassLoader");
+ Class loaderClass = loader.getClass();
+ if (uclClass.isAssignableFrom(loaderClass))
+ {
+ URL url = (URL)loaderClass.getMethod("getURL", new
Class[0]).invoke(loader, new Object[0]);
+ buffer.append(",GetURL=").append(url);
+ }
+ }
+ catch (Exception e)
+ {
+ log.error("Cannot get UCL infos", e);
+ }
+ buffer.append("]");
+ return buffer.toString();
+ }
+
+ public static String dumpClassLoaderHierarchyInfo(ClassLoader loader)
+ {
+ StringWriter writer = new StringWriter();
+ dumpClassLoaderHierarchyInfo(writer, loader);
+ return writer.toString();
+ }
+
+ public static void dumpClassLoaderHierarchyInfo(Writer writer, ClassLoader loader)
+ {
+ if (writer == null)
+ {
+ throw new IllegalArgumentException("no writer");
+ }
+ if (loader == null)
+ {
+ throw new IllegalArgumentException("no loader");
+ }
+
+ //
+ PrintWriter pw = null;
+ if (writer instanceof PrintWriter)
+ {
+ pw = (PrintWriter)writer;
+ }
+ else
+ {
+ pw = new PrintWriter(writer);
+ }
+
+ pw.println("<classloader-dump>");
+ while (loader != null)
+ {
+ pw.println(buildClassLoaderInfo(loader));
+ loader = loader.getParent();
+ }
+ pw.print("</classloader-dump>");
+ pw.flush();
+ }
+
+ public static void dumpClassLoaderHierarchyInfo(Logger log, ClassLoader loader)
+ {
+ Writer writer = new Log4JWriter(log, Level.DEBUG);
+ dumpClassLoaderHierarchyInfo(writer, loader);
+ }
+
+ public static void dumpClassLoaderHierarchyInfo(Logger log, Level level, ClassLoader
loader)
+ {
+ Writer writer = new Log4JWriter(log, level);
+ dumpClassLoaderHierarchyInfo(writer, loader);
+ }
+
+ /**
+ * Replace occurence in a string.
+ *
+ * @param string the source string
+ * @param pattern the replaced pattern
+ * @param replacement the replacement text
+ * @return the new string
+ */
+ public static String replace(String string, String pattern, String replacement)
+ {
+ StringBuffer buffer = new StringBuffer(string.length());
+ int previous = 0;
+ int current = string.indexOf(pattern);
+ while (current != -1)
+ {
+ buffer.append(string.substring(previous, current));
+ buffer.append(replacement);
+ previous = current + pattern.length();
+ current = string.indexOf(pattern, previous);
+ }
+ buffer.append(string.substring(previous));
+ return buffer.toString();
+ }
+
+ /**
+ * Append an object to an array of objects. The original array is not modified. The
returned array
+ * will be of the same component type of the provided array and its first n elements
where n is the size
+ * of the provided array will be the elements of the provided array. The last element
of the array will be
+ * the provided object to append.
+ *
+ * @param array the array to augment
+ * @param o the object to append
+ * @return a new array
+ * @throws IllegalArgumentException if the array is null
+ * @throws ClassCastException if the appended object class prevents it from being
added to the array
+ */
+ public static <E> E[] appendTo(E[] array, E o) throws IllegalArgumentException,
ClassCastException
+ {
+ if (array == null)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ //
+ Class componentType = array.getClass().getComponentType();
+ if (o != null && !componentType.isAssignableFrom(o.getClass()))
+ {
+ throw new ClassCastException("Object with class " +
o.getClass().getName() + " cannot be casted to class " +
componentType.getName());
+ }
+
+ //
+ E[] copy = (E[])Array.newInstance(componentType, array.length + 1);
+ System.arraycopy(array, 0, copy, 0, array.length);
+ copy[array.length] = o;
+
+ //
+ return copy;
+ }
+
+ /**
+ * Return true if
+ * <ul>
+ * <li>o1 is null and o2 is null</li<
+ * <li>o1 is not null and the invocation of <code>equals(Object
o)</code> on o1 wit o2 as argument returns true</li>
+ * </ul>
+ *
+ * @param o1 the first argument
+ * @param o2 the second argument
+ * @return if arguments are equals according to the semantic defined by the method
contract
+ */
+ public static boolean safeEquals(Object o1, Object o2)
+ {
+ if (o1 == null)
+ {
+ return o2 == null;
+ }
+ else
+ {
+ return o1.equals(o2);
+ }
+ }
+
+ public static String replaceAllInstancesOfBoundedString(String initial, String prefix,
String suffix, String replacement)
+ {
+ return replaceBoundedString(initial, prefix, suffix, replacement, true, false);
+ }
+
+ /**
+ * Todo : define what "bounded" means.
+ *
+ * @param initial
+ * @param prefix
+ * @param suffix
+ * @param replacement
+ * @param replaceIfBoundedStringEmpty
+ * @param keepBoundaries
+ * @return
+ */
+ public static String replaceBoundedString(String initial, String prefix, String
suffix, String replacement,
+ boolean replaceIfBoundedStringEmpty, boolean
keepBoundaries)
+ {
+ if (initial == null || initial.length() == 0)
+ {
+ return initial;
+ }
+
+ ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(prefix,
"prefix", "Tools.replaceBoundedString");
+ ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(suffix,
"suffix", "Tools.replaceBoundedString");
+ ParameterValidation.throwIllegalArgExceptionIfNull(replacement,
"replacement");
+
+ StringBuffer tmp = new StringBuffer(initial);
+ int prefixIndex = tmp.indexOf(prefix);
+ int suffixLength = suffix.length();
+ int prefixLength = prefix.length();
+
+ while (prefixIndex != -1)
+ {
+ int suffixIndex = tmp.indexOf(suffix, prefixIndex);
+
+ if (suffixIndex != -1)
+ {
+ // we don't care about empty bounded strings or prefix and suffix
don't delimit an empty String => replace!
+ if (replaceIfBoundedStringEmpty || suffixIndex != prefixIndex +
prefixLength)
+ {
+ if (keepBoundaries)
+ {
+ tmp.delete(prefixIndex + prefixLength, suffixIndex);
+ tmp.insert(prefixIndex + prefixLength, replacement);
+ }
+ else
+ {
+ tmp.delete(prefixIndex, suffixIndex + suffixLength);
+ tmp.insert(prefixIndex, replacement);
+ }
+ }
+ }
+
+ prefixIndex = tmp.indexOf(prefix, prefixIndex + prefixLength);
+ }
+
+ return tmp.toString();
+ }
+
+ /**
+ * Determines if value is contained in array.
+ *
+ * todo: correct this method contract in order to make it more reusable, it looks like
for now like a method
+ * which has a contract convenient only for some kind of callers.
+ *
+ * 1/ null value should be accepted (or the method should be called
isContainedInButNotForNullValue ?)
+ * 2/ null array should not be accepted (or the method should be called
isContainedInExceptIfThePassedArrayIsNull ?)
+ *
+ * @param value
+ * @param array
+ * @return
+ * @since 2.4.2
+ */
+ public static boolean isContainedIn(Object value, Object[] array)
+ {
+ if (value == null)
+ {
+ return false;
+ }
+
+ //
+ if (array != null)
+ {
+ for (Object anArray : array)
+ {
+ if (value.equals(anArray))
+ {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Attempt to cast the value argument to the provided type argument. If the value
argument type is assignable
+ * to the provided type, the value is returned, otherwise if it is not or the value is
null, null is returned.
+ *
+ * todo: Move that to common package.
+ *
+ * @param value the value to cast
+ * @param type the type to downcast
+ * @return the casted value or null
+ */
+ public static <T> T safeCast(Object value, Class<T> type)
+ {
+ if (value == null)
+ {
+ return null;
+ }
+ else
+ {
+ if (type.isAssignableFrom(value.getClass()))
+ {
+ return type.cast(value);
+ }
+ else
+ {
+ return null;
+ }
+ }
+ }
+
+ public static <T> MultiValuedPropertyMap<T> emptyMultiValuedPropertyMap()
+ {
+ return new MultiValuedPropertyMap<T>()
+ {
+ public T getValue(String key) throws IllegalArgumentException
+ {
+ if (key == null)
+ {
+ throw new IllegalArgumentException("Key cannot be null");
+ }
+ return null;
+ }
+
+ public List<T> getValues(String key) throws IllegalArgumentException
+ {
+ if (key == null)
+ {
+ throw new IllegalArgumentException("Key cannot be null");
+ }
+ return null;
+ }
+
+ public void addValue(String key, T value) throws IllegalArgumentException
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void setValue(String key, T value) throws IllegalArgumentException
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public Set<String> keySet()
+ {
+ return Collections.emptySet();
+ }
+
+ public int size()
+ {
+ return 0;
+ }
+
+ public void clear()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void append(MultiValuedPropertyMap<T> appended) throws
IllegalArgumentException
+ {
+ throw new UnsupportedOperationException();
+ }
+ };
+ }
+
+}
\ No newline at end of file
Added:
modules/test/trunk/test/src/main/java/org/jboss/portal/test/framework/common/io/IOTools.java
===================================================================
---
modules/test/trunk/test/src/main/java/org/jboss/portal/test/framework/common/io/IOTools.java
(rev 0)
+++
modules/test/trunk/test/src/main/java/org/jboss/portal/test/framework/common/io/IOTools.java 2008-02-22
23:26:34 UTC (rev 10091)
@@ -0,0 +1,497 @@
+/*
+* 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.framework.common.io;
+
+import org.jboss.portal.test.framework.common.Tools;
+import org.apache.log4j.Logger;
+
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.lang.reflect.InvocationTargetException;
+import java.io.OutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Reader;
+import java.io.ByteArrayOutputStream;
+import java.io.Writer;
+import java.io.Serializable;
+import java.io.ObjectOutputStream;
+import java.io.ByteArrayInputStream;
+import java.io.ObjectInputStream;
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.DataOutputStream;
+import java.util.Map;
+
+/**
+ * IO tools.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class IOTools
+{
+
+ /** The logger. */
+ public static final Logger log = Logger.getLogger(IOTools.class);
+
+ /** . */
+ private static final Object[] EMPTY_ARGS = new Object[0];
+
+ /** . */
+ private static final Class[] EMPTY_PARAMETER_TYPES = new Class[0];
+
+ /**
+ * <p>Attempt to close an object. Null argument value is authorized and no
operation will be performed in that
+ * use case.</p>
+ *
+ * <p>It will try to obtain a <code>close()</code> method by
reflection and it
+ * will be invoked only if the method is public and not static. If the method is
called, any <code>Error</code>
+ * or <code>RuntimeException</code> will be rethrown, any other kind of
throwable will not be rethrown in any form.</p>
+ *
+ * @param closable the object to close
+ */
+ public static void safeClose(Object closable)
+ {
+ if (closable != null)
+ {
+ try
+ {
+ Method m = closable.getClass().getMethod("close",
EMPTY_PARAMETER_TYPES);
+ if (Modifier.isStatic(m.getModifiers()))
+ {
+ log.warn("close() method on closable object is static");
+ return;
+ }
+ m.invoke(closable, EMPTY_ARGS);
+ }
+ catch (NoSuchMethodException e)
+ {
+ log.warn("The closable object does not have a close() method", e);
+ }
+ catch (IllegalAccessException e)
+ {
+ log.warn("Cannot access close() method on closable object", e);
+ }
+ catch (InvocationTargetException e)
+ {
+ Throwable t = e.getCause();
+
+ //
+ if (t instanceof RuntimeException)
+ {
+ log.error("The close() method threw a runtime exception", t);
+ throw (RuntimeException)t;
+ }
+ else if (t instanceof Error)
+ {
+ log.error("The close() method threw an error", t);
+ throw (Error)t;
+ }
+ else if (t instanceof Exception)
+ {
+ log.error("The close() method threw an exception", t);
+ }
+ else
+ {
+ log.error("The close() method threw an unexpected throwable",
t);
+ }
+ }
+ }
+ }
+
+ /**
+ * <p>Attempt to close an <code>OutputStream</code>. Null argument
value is authorized and no operation will be performed in that
+ * use case.</p>
+ *
+ * @param out the stream to close
+ */
+ public static void safeClose(OutputStream out)
+ {
+ if (out != null)
+ {
+ try
+ {
+ out.close();
+ }
+ catch (IOException e)
+ {
+ log.error("Error while closing outstream", e);
+ }
+ }
+ }
+
+ /**
+ * <p>Attempt to close an <code>InputStream</code>. Null argument
value is authorized and no operation will be performed in that
+ * use case.</p>
+ *
+ * @param in the stream to close
+ */
+ public static void safeClose(InputStream in)
+ {
+ if (in != null)
+ {
+ try
+ {
+ in.close();
+ }
+ catch (IOException e)
+ {
+ log.error("Error while closing inputstream", e);
+ }
+ }
+ }
+
+ /**
+ * <p>Attempt to close an <code>Reader</code>. Null argument value
is authorized and no operation will be performed in that
+ * use case.</p>
+ *
+ * @param reader the stream to close
+ */
+ public static void safeClose(Reader reader)
+ {
+ if (reader != null)
+ {
+ try
+ {
+ reader.close();
+ }
+ catch (IOException e)
+ {
+ log.error("Error while closing reader", e);
+ }
+ }
+ }
+
+ /**
+ * <p>Attempt to close an <code>Writer</code>. Null argument value
is authorized and no operation will be performed in that
+ * use case.</p>
+ *
+ * @param writer the stream to close
+ */
+ public static void safeClose(Writer writer)
+ {
+ if (writer != null)
+ {
+ try
+ {
+ writer.close();
+ }
+ catch (IOException e)
+ {
+ log.error("Error while closing writer", e);
+ }
+ }
+ }
+
+ /**
+ * @see #getBytes(java.io.InputStream, int)
+ * @param in the input stream
+ * @return the bytes read from the stream
+ * @throws java.io.IOException
+ * @throws IllegalArgumentException if the input stream is null
+ */
+ public static byte[] getBytes(InputStream in) throws IOException,
IllegalArgumentException
+ {
+ return getBytes(in, Tools.DEFAULT_BUFFER_SIZE);
+ }
+
+ /**
+ * Get the bytes from the provided input stream. No attempt will be made to close the
stream.
+ *
+ * @param in the input stream
+ * @param bufferSize the buffer size used to copy the bytes
+ * @return the bytes read from the stream
+ * @throws java.io.IOException
+ * @throws IllegalArgumentException if the input stream is null or the buffer size
< 1
+ */
+ public static byte[] getBytes(InputStream in, int bufferSize) throws IOException,
IllegalArgumentException
+ {
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ copy(in, out, bufferSize);
+ return out.toByteArray();
+ }
+
+ /**
+ * @see #copy(java.io.InputStream, java.io.OutputStream, int)
+ * @param in the incoming stream
+ * @param out the outcoming stream
+ * @throws IllegalArgumentException if an argument is null
+ */
+ public static void copy(InputStream in, OutputStream out) throws IOException
+ {
+ copy(in, out, Tools.DEFAULT_BUFFER_SIZE);
+ }
+
+ /**
+ * Pipe an incoming stream in an outcoming stream until no bytes is available from the
input stream.
+ * No attempts will be made to close the streams.
+ *
+ * @param in the incoming stream
+ * @param out the outcoming stream
+ * @param bufferSize the buffer size
+ * @throws IllegalArgumentException if bufferSize < 1 or an argument is null
+ */
+ public static void copy(InputStream in, OutputStream out, int bufferSize) throws
IOException
+ {
+ // arguments check
+ if (in == null)
+ {
+ throw new IllegalArgumentException("null in");
+ }
+ if (out == null)
+ {
+ throw new IllegalArgumentException("null out");
+ }
+ if (bufferSize < 1)
+ {
+ throw new IllegalArgumentException("Buffer size is too small");
+ }
+
+ // do the job
+ byte[] buffer = new byte[bufferSize];
+ while (true)
+ {
+ int i = in.read(buffer);
+ if (i == 0)
+ {
+ continue;
+ }
+ if (i == -1)
+ {
+ break;
+ }
+ out.write(buffer, 0, i);
+ }
+ }
+
+ /**
+ * Pipe an input stream in an output stream.
+ *
+ * @param reader the incoming reader
+ * @param writer the outcoming writer
+ * @throws IllegalArgumentException if an argument is null
+ */
+ public static void copy(Reader reader, Writer writer) throws IOException
+ {
+ copy(reader, writer, Tools.DEFAULT_BUFFER_SIZE);
+ }
+
+ /**
+ * Pipe an incoming stream in an outcoming stream.
+ *
+ * @param reader the incoming reader
+ * @param writer the outcoming writer
+ * @param bufferSize the buffer size
+ * @throws IllegalArgumentException if bufferSize < 1 or an argument is null
+ */
+ public static void copy(Reader reader, Writer writer, int bufferSize) throws
IOException
+ {
+ // arguments check
+ if (reader == null)
+ {
+ throw new IllegalArgumentException("null in");
+ }
+ if (writer == null)
+ {
+ throw new IllegalArgumentException("null out");
+ }
+ if (bufferSize < 1)
+ {
+ throw new IllegalArgumentException("Buffer size is too small");
+ }
+
+ // do the job
+ char[] buffer = new char[bufferSize];
+ while (true)
+ {
+ int i = reader.read(buffer);
+ if (i == 0)
+ {
+ continue;
+ }
+ if (i == -1)
+ {
+ break;
+ }
+ writer.write(buffer, 0, i);
+ }
+ }
+
+ /**
+ * Clone an object implementing the <code>Serializable</code> interface.
+ *
+ * @param serializable
+ * @return
+ * @throws IllegalArgumentException if the serializable object is null
+ * @throws IOException
+ */
+ public static <S extends Serializable> S clone(S serializable) throws
IllegalArgumentException, IOException
+ {
+ if (serializable == null)
+ {
+ throw new IllegalArgumentException("Cannot clone null");
+ }
+ try
+ {
+ return (S)unserialize(serialize(serializable));
+ }
+ catch (ClassNotFoundException e)
+ {
+ throw new Error("Got a class not found exception for a class that was
used", e);
+ }
+ }
+
+ public static byte[] serialize(Serializable serializable) throws
IllegalArgumentException, IOException
+ {
+ if (serializable == null)
+ {
+ throw new IllegalArgumentException("No null serializable accepted");
+ }
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ ObjectOutputStream oos = new ObjectOutputStream(baos);
+ oos.writeObject(serializable);
+ oos.close();
+ return baos.toByteArray();
+ }
+
+ public static Serializable unserialize(byte[] bytes) throws IllegalArgumentException,
IOException, ClassNotFoundException
+ {
+ if (bytes == null)
+ {
+ throw new IllegalArgumentException("No null serializable accepted");
+ }
+ ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
+ ObjectInputStream ois = new ObjectInputStream(bais);
+ return (Serializable)ois.readObject();
+ }
+
+ public static <T> byte[] serialize(Serialization<T> serialization, T t)
+ {
+ return serialize(serialization, SerializationFilter.TRIVIAL, t);
+ }
+
+ public static <T> byte[] serialize(Serialization<T> serialization,
SerializationFilter filter, T t)
+ {
+ if (serialization == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (t == null)
+ {
+ throw new IllegalArgumentException("No null object to serialize");
+ }
+ try
+ {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ filter.serialize(serialization, t, baos);
+ return baos.toByteArray();
+ }
+ catch (IOException e)
+ {
+ throw new UndeclaredIOException(e);
+ }
+ }
+
+ public static <T> T unserialize(Serialization<T> serialization, byte[]
bytes)
+ {
+ return unserialize(serialization, SerializationFilter.TRIVIAL, bytes);
+ }
+
+ public static <T> T unserialize(Serialization<T> serialization,
SerializationFilter filter, byte[] bytes)
+ {
+ if (serialization == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (bytes == null)
+ {
+ throw new IllegalArgumentException("No null bytes to unserialize");
+ }
+ try
+ {
+ ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
+ return filter.unserialize(serialization, bais);
+ }
+ catch (IOException e)
+ {
+ throw new UndeclaredIOException(e);
+ }
+ }
+
+ /**
+ * Check that the provided input stream is buffered. If the argument is already an
instance of <code>BufferedInputStream</code>
+ * no operation will be performed, otherwise a instance of
<code>BufferedInputStream</code> will be created and returned.
+ *
+ * If the provided argument is null, the null value is returned.
+ *
+ * @param in the stream
+ * @return a buffered wrapper
+ */
+ public static BufferedInputStream safeBufferedWrapper(InputStream in)
+ {
+ if (in != null)
+ {
+ if (in instanceof BufferedInputStream)
+ {
+ return (BufferedInputStream)in;
+ }
+ else
+ {
+ return new BufferedInputStream(in);
+ }
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ /**
+ * Check that the provided output stream is buffered. If the argument is already an
instance of <code>BufferedOutputStream</code>
+ * no operation will be performed, otherwise a instance of
<code>BufferedOutputStream</code> will be created and returned.
+ *
+ * If the provided argument is null, the null value is returned.
+ *
+ * @param out the stream
+ * @return a buffered wrapper
+ */
+ public static BufferedOutputStream safeBufferedWrapper(OutputStream out)
+ {
+ if (out != null)
+ {
+ if (out instanceof BufferedOutputStream)
+ {
+ return (BufferedOutputStream)out;
+ }
+ else
+ {
+ return new BufferedOutputStream(out);
+ }
+ }
+ else
+ {
+ return null;
+ }
+ }
+}
Added:
modules/test/trunk/test/src/main/java/org/jboss/portal/test/framework/common/io/Serialization.java
===================================================================
---
modules/test/trunk/test/src/main/java/org/jboss/portal/test/framework/common/io/Serialization.java
(rev 0)
+++
modules/test/trunk/test/src/main/java/org/jboss/portal/test/framework/common/io/Serialization.java 2008-02-22
23:26:34 UTC (rev 10091)
@@ -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.framework.common.io;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.io.DataInputStream;
+import java.io.OutputStream;
+import java.io.InputStream;
+import java.util.Map;
+import java.util.HashMap;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public interface Serialization<T>
+{
+
+ Serialization<Map<String, String[]>> PARAMETER_MAP = new
Serialization<Map<String, String[]>>()
+ {
+ public void serialize(Map<String, String[]> map, OutputStream out) throws
IOException, IllegalArgumentException
+ {
+ if (map == null)
+ {
+ throw new IllegalArgumentException("No null map allowed");
+ }
+
+ //
+ DataOutputStream data = out instanceof DataOutputStream ? (DataOutputStream)out
: new DataOutputStream(out);
+
+ //
+ data.writeInt(map.size());
+
+ //
+ for (Map.Entry entry : map.entrySet())
+ {
+ String name = (String)entry.getKey();
+ data.writeUTF(name);
+
+ //
+ String[] values = (String[])entry.getValue();
+ if (values == null)
+ {
+ throw new IllegalArgumentException("No null values are allowed in the
map");
+ }
+
+ //
+ int length = values.length;
+ data.writeInt(length);
+
+ //
+ for (String value : values)
+ {
+ if (value == null)
+ {
+ throw new IllegalArgumentException("No null value in the String[]
are allowed in the map");
+ }
+ data.writeUTF(value);
+ }
+ }
+
+ //
+ data.flush();
+ }
+
+ public Map<String, String[]> unserialize(InputStream in) throws IOException
+ {
+ if (in == null)
+ {
+ throw new IllegalArgumentException("No null input stream");
+ }
+
+ //
+ DataInputStream data = in instanceof DataInputStream ? (DataInputStream)in : new
DataInputStream(in);
+
+ //
+ int size = data.readInt();
+ Map<String, String[]> tmp = new HashMap<String, String[]>(size);
+ while (size-- > 0)
+ {
+ String name = data.readUTF();
+ int length = data.readInt();
+ String[] values = new String[length];
+ for (int i = 0;i < length;i++)
+ {
+ values[i] = data.readUTF();
+ }
+ tmp.put(name, values);
+ }
+
+ //
+ return tmp;
+ }
+ };
+
+ public abstract void serialize(T t, OutputStream out) throws IOException,
IllegalArgumentException;
+
+ public abstract T unserialize(InputStream in) throws IOException,
IllegalArgumentException;
+
+}
Added:
modules/test/trunk/test/src/main/java/org/jboss/portal/test/framework/common/io/SerializationFilter.java
===================================================================
---
modules/test/trunk/test/src/main/java/org/jboss/portal/test/framework/common/io/SerializationFilter.java
(rev 0)
+++
modules/test/trunk/test/src/main/java/org/jboss/portal/test/framework/common/io/SerializationFilter.java 2008-02-22
23:26:34 UTC (rev 10091)
@@ -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.framework.common.io;
+
+import java.io.OutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.zip.GZIPOutputStream;
+import java.util.zip.GZIPInputStream;
+
+/**
+ * Filters a stream for serialize/unserialize operations.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public interface SerializationFilter
+{
+
+ SerializationFilter TRIVIAL = new SerializationFilter()
+ {
+ public <T> void serialize(Serialization<T> serialization, T t,
OutputStream out) throws IllegalArgumentException, IOException
+ {
+ serialization.serialize(t, out);
+ }
+
+ public <T> T unserialize(Serialization<T> serialization, InputStream
in) throws IllegalArgumentException, IOException
+ {
+ return serialization.unserialize(in);
+ }
+ };
+
+ /**
+ * Use GZIP streams.
+ */
+ SerializationFilter COMPRESSOR = new SerializationFilter()
+ {
+ public <T> void serialize(Serialization<T> serialization, T t,
OutputStream out) throws IllegalArgumentException, IOException
+ {
+ GZIPOutputStream zos = new GZIPOutputStream(out);
+ serialization.serialize(t, zos);
+ zos.finish();
+ }
+
+ public <T> T unserialize(Serialization<T> serialization, InputStream
in) throws IllegalArgumentException, IOException
+ {
+ GZIPInputStream zis = new GZIPInputStream(in);
+ return serialization.unserialize(zis);
+ }
+ };
+
+ <T> void serialize(Serialization<T> serialization, T t, OutputStream out)
throws IllegalArgumentException, IOException;
+
+ <T> T unserialize(Serialization<T> serialization, InputStream in) throws
IllegalArgumentException, IOException;
+
+}
+
Added:
modules/test/trunk/test/src/main/java/org/jboss/portal/test/framework/common/io/UndeclaredIOException.java
===================================================================
---
modules/test/trunk/test/src/main/java/org/jboss/portal/test/framework/common/io/UndeclaredIOException.java
(rev 0)
+++
modules/test/trunk/test/src/main/java/org/jboss/portal/test/framework/common/io/UndeclaredIOException.java 2008-02-22
23:26:34 UTC (rev 10091)
@@ -0,0 +1,45 @@
+/*
+* 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.framework.common.io;
+
+import java.io.IOException;
+import java.lang.reflect.UndeclaredThrowableException;
+
+/**
+ * Avoid a method to declare an IOException in its signature when it is not necessary.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7228 $
+ */
+public class UndeclaredIOException extends UndeclaredThrowableException
+{
+ public UndeclaredIOException(IOException undeclaredIOException)
+ {
+ super(undeclaredIOException);
+ }
+
+ public UndeclaredIOException(IOException undeclaredIOException, String s)
+ {
+ super(undeclaredIOException, s);
+ }
+}
\ No newline at end of file
Added:
modules/test/trunk/test/src/main/java/org/jboss/portal/test/framework/common/xml/TooManyElementException.java
===================================================================
---
modules/test/trunk/test/src/main/java/org/jboss/portal/test/framework/common/xml/TooManyElementException.java
(rev 0)
+++
modules/test/trunk/test/src/main/java/org/jboss/portal/test/framework/common/xml/TooManyElementException.java 2008-02-22
23:26:34 UTC (rev 10091)
@@ -0,0 +1,52 @@
+/*
+* 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.framework.common.xml;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7380 $
+ */
+public class TooManyElementException extends RuntimeException
+{
+ /** The serialVersionUID */
+ private static final long serialVersionUID = -2381186243988987102L;
+
+ public TooManyElementException()
+ {
+ }
+
+ public TooManyElementException(String message)
+ {
+ super(message);
+ }
+
+ public TooManyElementException(String message, Throwable cause)
+ {
+ super(message, cause);
+ }
+
+ public TooManyElementException(Throwable cause)
+ {
+ super(cause);
+ }
+}
\ No newline at end of file
Added:
modules/test/trunk/test/src/main/java/org/jboss/portal/test/framework/common/xml/XMLTools.java
===================================================================
---
modules/test/trunk/test/src/main/java/org/jboss/portal/test/framework/common/xml/XMLTools.java
(rev 0)
+++
modules/test/trunk/test/src/main/java/org/jboss/portal/test/framework/common/xml/XMLTools.java 2008-02-22
23:26:34 UTC (rev 10091)
@@ -0,0 +1,469 @@
+/*
+* 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.framework.common.xml;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.Text;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.OutputKeys;
+import javax.xml.transform.Result;
+import javax.xml.transform.Source;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+import java.io.IOException;
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Properties;
+import java.util.NoSuchElementException;
+
+/**
+ * Utilities for dealing with XML.
+ *
+ * @author <a href="mailto:mholzner@novell.com">Martin Holzner</a>
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7686 $
+ */
+public class XMLTools
+{
+
+ /** Namespace URI for XML lang. */
+ public static final String XML_LANG_NAMESPACE_URI =
"http://www.w3.org/XML/1998/namespace";
+
+ /** Document builder factory. */
+ private static final DocumentBuilderFactory buildFactory =
DocumentBuilderFactory.newInstance();
+
+ /** Transformer factory. */
+ private static final TransformerFactory transformerFactory =
TransformerFactory.newInstance();
+
+ /** Default output format which is : no xml declaration, no document type, indent. */
+ private static Properties DEFAULT_FORMAT = createFormat(true, false, true,
"utf-8");
+
+ /** . */
+ public static final String PARAM_YES = "yes";
+
+ /** . */
+ public static final String PARAM_NO = "no";
+
+ /** . */
+ public static final String ATTRIB_OMIT_XML_DECLARATION =
"omit-xml-declaration";
+
+ /** . */
+ public static final String ATTRIB_CDATA_SECTION_ELEMENTS =
"cdata-section-elements";
+
+ /** . */
+ public static final String ATTRIB_METHOD = "method";
+
+ /** . */
+ public static final String ATTRIB_INDENT = "indent";
+
+ /** . */
+ public static final String ATTRIB_HREF = "href";
+
+ /** . */
+ public static final String DIRECTIVE_IMPORT = "xsl:import";
+
+ /** . */
+ public static final String DIRECTIVE_INCLUDE = "xsl:include";
+
+ /** . */
+ public static final boolean DEFAULT_NAMESPACE_AWARE = true;
+
+ /** . */
+ public static final boolean DEFAULT_VALIDATION = false;
+
+ /** prevent instantiation */
+ private XMLTools()
+ {
+ }
+
+ /** Return the builder factory. */
+ public static DocumentBuilderFactory getDocumentBuilderFactory()
+ {
+ return buildFactory;
+ }
+
+ /**
+ *
+ */
+ private static Properties createFormat(boolean omitXMLDeclaration, boolean standalone,
boolean indented, String encoding)
+ {
+ Properties format = new Properties();
+ format.setProperty(OutputKeys.OMIT_XML_DECLARATION, omitXMLDeclaration ?
"yes" : "no");
+ format.setProperty(OutputKeys.STANDALONE, standalone ? "yes" :
"no");
+ format.setProperty(OutputKeys.INDENT, indented ? "yes" :
"no");
+ format.setProperty(OutputKeys.ENCODING, encoding);
+ return format;
+ }
+
+ /**
+ *
+ */
+ public static String toString(Document doc, boolean omitXMLDeclaration, boolean
standalone, boolean indented, String encoding) throws TransformerException
+ {
+ Properties format = createFormat(omitXMLDeclaration, standalone, indented,
encoding);
+ return toString(doc, format);
+ }
+
+ /**
+ * Serialize the document with the default format : - No XML declaration - Indented -
Encoding is UTF-8
+ *
+ * @see #toString(Document,Properties)
+ */
+ public static String toString(Document doc) throws TransformerException
+ {
+ return toString(doc, DEFAULT_FORMAT);
+ }
+
+ /** @see #toString(Document) */
+ public static String toString(Element element) throws ParserConfigurationException,
TransformerException
+ {
+ return toString(element, DEFAULT_FORMAT);
+ }
+
+ /** Converts an element to a String representation. */
+ private static String toString(Element element, Properties properties) throws
ParserConfigurationException, TransformerException
+ {
+ Document doc = buildFactory.newDocumentBuilder().newDocument();
+ element = (Element)doc.importNode(element, true);
+ doc.appendChild(element);
+ return toString(doc, properties);
+ }
+
+ /** Converts an document to a String representation. */
+ private static String toString(Document doc, Properties format) throws
TransformerException
+ {
+ Transformer transformer = transformerFactory.newTransformer();
+ transformer.setOutputProperties(format);
+ StringWriter writer = new StringWriter();
+ Source source = new DOMSource(doc);
+ Result result = new StreamResult(writer);
+ transformer.transform(source, result);
+ return writer.toString();
+ }
+
+ /** Parse a string into a document. */
+ public static Document toDocument(String text) throws ParserConfigurationException,
SAXException, IOException
+ {
+ DocumentBuilder builder = buildFactory.newDocumentBuilder();
+ StringReader reader = new StringReader(text);
+ InputSource source = new InputSource();
+ source.setCharacterStream(reader);
+ return builder.parse(source);
+ }
+
+ /** Parse a string into an element. */
+ public static Element toElement(String text) throws ParserConfigurationException,
SAXException, IOException
+ {
+ Document doc = toDocument(text);
+ return doc.getDocumentElement();
+ }
+
+ public static Document toDocument(Element element) throws
ParserConfigurationException, SAXException, IOException
+ {
+ if (element == null)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ //
+ Document doc = buildFactory.newDocumentBuilder().newDocument();
+ element = (Element)doc.importNode(element, true);
+ doc.appendChild(element);
+ return doc;
+ }
+
+ /**
+ * Perform trimming by default
+ *
+ * @param element
+ * @return
+ * @throws IllegalArgumentException
+ * @see #asString(org.w3c.dom.Element,boolean)
+ */
+ public static String asString(Element element) throws IllegalArgumentException
+ {
+ return asString(element, true);
+ }
+
+ /**
+ * Get the element's content as a string.
+ *
+ * @param element the container
+ * @param trim true if text should be trimmed before returning result
+ * @throws IllegalArgumentException if the element content is mixed or null
+ */
+ public static String asString(Element element, boolean trim) throws
IllegalArgumentException
+ {
+ if (element == null)
+ {
+ throw new IllegalArgumentException("No null element allowed");
+ }
+
+ //
+ StringBuffer buffer = new StringBuffer();
+ NodeList children = element.getChildNodes();
+ for (int i = 0; i < children.getLength(); i++)
+ {
+ Node child = children.item(i);
+ switch (child.getNodeType())
+ {
+ case Node.CDATA_SECTION_NODE:
+ case Node.TEXT_NODE:
+ buffer.append(((Text)child).getData());
+ break;
+ case Node.ELEMENT_NODE:
+ throw new IllegalArgumentException("Mixed content not
allowed");
+ default:
+ break;
+ }
+ }
+ String result = buffer.toString();
+ if (trim)
+ {
+ result = result.trim();
+ }
+ return result;
+ }
+
+ /**
+ * Return the optional unique child of an element.
+ *
+ * @param element the parent element
+ * @param strict true if the element must be present
+ * @return the child element or null if it does not exist and strict is false
+ * @throws IllegalArgumentException if an argument is null
+ * @throws java.util.NoSuchElementException if strict is true and the element is not
present
+ * @throws TooManyElementException if more than one element is found
+ */
+ public static Element getUniqueChild(Element element, boolean strict) throws
IllegalArgumentException,
+ NoSuchElementException, TooManyElementException
+ {
+ if (element == null)
+ {
+ throw new IllegalArgumentException("No element specified");
+ }
+ Element childElt = null;
+ NodeList list = element.getChildNodes();
+ for (int i = 0; i < list.getLength(); i++)
+ {
+ Node childNode = list.item(i);
+ if (childNode instanceof Element)
+ {
+ if (childElt == null)
+ {
+ childElt = (Element)childNode;
+ }
+ else
+ {
+ throw new TooManyElementException("More than one child element for
element " + element.getNodeName());
+ }
+ }
+ }
+ if (strict && childElt == null)
+ {
+ throw new NoSuchElementException("No child element for element " +
element.getNodeName());
+ }
+ return childElt;
+ }
+
+ /**
+ * Return an optional child of an element with the specified name.
+ *
+ * @param element the parent element
+ * @param name the child name
+ * @param strict if the child must be present
+ * @return the child element or null if it does not exist and strict is set to false
+ * @throws IllegalArgumentException if an argument is null
+ * @throws NoSuchElementException if strict is true and the element is not present
+ * @throws TooManyElementException if more than one element is found
+ */
+ public static Element getUniqueChild(Element element, String name, boolean strict)
throws IllegalArgumentException,
+ NoSuchElementException, TooManyElementException
+ {
+ return getUniqueChild(element, null, name, strict);
+ }
+
+ /**
+ * Return an optional child of an element with the specified name and the optionally
specified namespace uri.
+ *
+ * @param element the parent element
+ * @param name the child name
+ * @param uri the child uri
+ * @param strict if the child must be present
+ * @return the child element or null if it does not exist and strict is set to false
+ * @throws IllegalArgumentException if an argument is null
+ * @throws NoSuchElementException if strict is true and the element is not present
+ * @throws TooManyElementException if more than one element is found
+ */
+ public static Element getUniqueChild(Element element, String uri, String name, boolean
strict) throws IllegalArgumentException,
+ NoSuchElementException, TooManyElementException
+ {
+ List list = getChildren(element, uri, name);
+ switch (list.size())
+ {
+ case 0:
+ if (strict)
+ {
+ throw new NoSuchElementException("Missing child " + name +
" of element " + element.getNodeName());
+ }
+ else
+ {
+ return null;
+ }
+ case 1:
+ return (Element)list.get(0);
+ default:
+ throw new TooManyElementException("Too many children for element "
+ element.getNodeName());
+ }
+ }
+
+ /**
+ * Return an iterator for all the children of the given element having the specified
name.
+ *
+ * @param element the parent element
+ * @param name the child names
+ * @return an iterator for the designated elements
+ * @throws IllegalArgumentException if the element is null or the name is null
+ */
+ public static Iterator<Element> getChildrenIterator(Element element, String
name) throws IllegalArgumentException
+ {
+ return getChildren(element, name).iterator();
+ }
+
+ /**
+ * Return an iterator for all the children of the given element having the specified
name and the optionally
+ * specified namesspace uri.
+ *
+ * @param element the parent element
+ * @param uri the children uri
+ * @param name the children name
+ * @return an iterator for the designated elements
+ * @throws IllegalArgumentException if the element is null or the name is null
+ */
+ public static Iterator<Element> getChildrenIterator(Element element, String uri,
String name) throws IllegalArgumentException
+ {
+ return getChildren(element, uri, name).iterator();
+ }
+
+ /**
+ * Return all the children of the given element having the specified name. The
collection object can be modified.
+ *
+ * @param element the parent element
+ * @param name the child names
+ * @return a list of elements
+ * @throws IllegalArgumentException if the element is null or the name is null
+ */
+ public static List<Element> getChildren(Element element, String name) throws
IllegalArgumentException
+ {
+ return getChildren(element, null, name);
+ }
+
+ /**
+ * Return all the children of the given element having the specified name and the
optionally specified namespace URI.
+ * The collection object can be modified.
+ *
+ * @param element the parent element
+ * @param uri the children uri
+ * @param name the children name
+ * @return a list of elements
+ * @throws IllegalArgumentException if the element is null or the name is null
+ */
+ public static List<Element> getChildren(Element element, String uri, String
name) throws IllegalArgumentException
+ {
+ if (element == null)
+ {
+ throw new IllegalArgumentException("No element found");
+ }
+ if (name == null)
+ {
+ throw new IllegalArgumentException("No name specified");
+ }
+ ArrayList<Element> result = new ArrayList<Element>();
+ NodeList list = element.getChildNodes();
+ for (int i = 0; i < list.getLength(); i++)
+ {
+ Node node = list.item(i);
+ if (node.getNodeType() == Node.ELEMENT_NODE)
+ {
+ Element childElt = (Element)node;
+
+ //
+ if (uri == null)
+ {
+ if (childElt.getTagName().equals(name))
+ {
+ result.add(childElt);
+ }
+ }
+ else if (uri.equals(childElt.getNamespaceURI()))
+ {
+ if (childElt.getLocalName().equals(name))
+ {
+ result.add(childElt);
+ }
+ }
+ }
+ }
+ return result;
+ }
+
+ public static Properties loadXMLProperties(Element propertiesElt)
+ {
+ if (propertiesElt == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ Properties props = new Properties();
+ for (Element entryElt : getChildren(propertiesElt, "entry"))
+ {
+ String key = entryElt.getAttribute("key");
+ String value = asString(entryElt);
+ props.put(key, value);
+ }
+ return props;
+ }
+
+ public static Properties loadXMLProperties(Document doc)
+ {
+ if (doc == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ return loadXMLProperties(doc.getDocumentElement());
+ }
+
+}
\ No newline at end of file
Modified:
modules/test/trunk/test/src/main/java/org/jboss/portal/test/framework/embedded/DSConfig.java
===================================================================
---
modules/test/trunk/test/src/main/java/org/jboss/portal/test/framework/embedded/DSConfig.java 2008-02-22
16:28:22 UTC (rev 10090)
+++
modules/test/trunk/test/src/main/java/org/jboss/portal/test/framework/embedded/DSConfig.java 2008-02-22
23:26:34 UTC (rev 10091)
@@ -23,10 +23,10 @@
package org.jboss.portal.test.framework.embedded;
-import org.jboss.portal.common.xml.XMLTools;
-import org.jboss.portal.common.io.IOTools;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
+import org.jboss.portal.test.framework.common.xml.XMLTools;
+import org.jboss.portal.test.framework.common.io.IOTools;
import java.io.InputStream;
import java.net.URL;
Modified:
modules/test/trunk/test/src/main/java/org/jboss/portal/test/framework/embedded/DataSourceSupport.java
===================================================================
---
modules/test/trunk/test/src/main/java/org/jboss/portal/test/framework/embedded/DataSourceSupport.java 2008-02-22
16:28:22 UTC (rev 10090)
+++
modules/test/trunk/test/src/main/java/org/jboss/portal/test/framework/embedded/DataSourceSupport.java 2008-02-22
23:26:34 UTC (rev 10091)
@@ -23,10 +23,10 @@
package org.jboss.portal.test.framework.embedded;
-import org.jboss.portal.common.xml.XMLTools;
-import org.jboss.portal.common.io.IOTools;
import org.jboss.resource.adapter.jdbc.local.LocalTxDataSource;
import org.jboss.resource.connectionmanager.CachedConnectionManagerReference;
+import org.jboss.portal.test.framework.common.xml.XMLTools;
+import org.jboss.portal.test.framework.common.io.IOTools;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
Modified:
modules/test/trunk/test/src/main/java/org/jboss/portal/test/framework/embedded/HibernateSupport.java
===================================================================
---
modules/test/trunk/test/src/main/java/org/jboss/portal/test/framework/embedded/HibernateSupport.java 2008-02-22
16:28:22 UTC (rev 10090)
+++
modules/test/trunk/test/src/main/java/org/jboss/portal/test/framework/embedded/HibernateSupport.java 2008-02-22
23:26:34 UTC (rev 10091)
@@ -31,8 +31,8 @@
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Settings;
import org.hibernate.tool.hbm2ddl.SchemaExport;
-import org.jboss.portal.common.xml.XMLTools;
-import org.jboss.portal.common.io.IOTools;
+import org.jboss.portal.test.framework.common.xml.XMLTools;
+import org.jboss.portal.test.framework.common.io.IOTools;
import org.w3c.dom.Element;
import org.w3c.dom.Document;
import org.jboss.logging.Logger;
Modified:
modules/test/trunk/test/src/main/java/org/jboss/portal/test/framework/impl/generic/config/ServerConfig.java
===================================================================
---
modules/test/trunk/test/src/main/java/org/jboss/portal/test/framework/impl/generic/config/ServerConfig.java 2008-02-22
16:28:22 UTC (rev 10090)
+++
modules/test/trunk/test/src/main/java/org/jboss/portal/test/framework/impl/generic/config/ServerConfig.java 2008-02-22
23:26:34 UTC (rev 10091)
@@ -24,8 +24,8 @@
import org.w3c.dom.Element;
import org.w3c.dom.Document;
-import org.jboss.portal.common.xml.XMLTools;
-import org.jboss.portal.common.io.IOTools;
+import org.jboss.portal.test.framework.common.io.IOTools;
+import org.jboss.portal.test.framework.common.xml.XMLTools;
import java.net.URL;
import java.util.Iterator;
Modified: modules/test/trunk/tooling/ant/pom.xml
===================================================================
--- modules/test/trunk/tooling/ant/pom.xml 2008-02-22 16:28:22 UTC (rev 10090)
+++ modules/test/trunk/tooling/ant/pom.xml 2008-02-22 23:26:34 UTC (rev 10091)
@@ -3,7 +3,7 @@
<parent>
<groupId>org.jboss.unit</groupId>
<artifactId>module-parent</artifactId>
- <version>1.2.0-SNAPSHOT</version>
+ <version>1.2.0.Beta2</version>
<relativePath>../../build/pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Modified: modules/test/trunk/tooling/core/pom.xml
===================================================================
--- modules/test/trunk/tooling/core/pom.xml 2008-02-22 16:28:22 UTC (rev 10090)
+++ modules/test/trunk/tooling/core/pom.xml 2008-02-22 23:26:34 UTC (rev 10091)
@@ -3,7 +3,7 @@
<parent>
<groupId>org.jboss.unit</groupId>
<artifactId>module-parent</artifactId>
- <version>1.2.0-SNAPSHOT</version>
+ <version>1.2.0.Beta2</version>
<relativePath>../../build/pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Modified: modules/test/trunk/tooling/examples/maven2/pom.xml
===================================================================
--- modules/test/trunk/tooling/examples/maven2/pom.xml 2008-02-22 16:28:22 UTC (rev
10090)
+++ modules/test/trunk/tooling/examples/maven2/pom.xml 2008-02-22 23:26:34 UTC (rev
10091)
@@ -11,7 +11,7 @@
<dependency>
<groupId>org.jboss.unit</groupId>
<artifactId>jboss-unit</artifactId>
- <version>1.2.0-SNAPSHOT</version>
+ <version>1.2.0.Beta2</version>
</dependency>
</dependencies>
@@ -39,7 +39,7 @@
<plugin>
<groupId>org.jboss.unit</groupId>
<artifactId>jboss-unit-tooling-maven2</artifactId>
- <version>1.2.0-SNAPSHOT</version>
+ <version>1.2.0.Beta2</version>
<executions>
<execution>
<phase>test</phase>
Modified: modules/test/trunk/tooling/maven2/pom.xml
===================================================================
--- modules/test/trunk/tooling/maven2/pom.xml 2008-02-22 16:28:22 UTC (rev 10090)
+++ modules/test/trunk/tooling/maven2/pom.xml 2008-02-22 23:26:34 UTC (rev 10091)
@@ -3,7 +3,7 @@
<parent>
<groupId>org.jboss.unit</groupId>
<artifactId>module-parent</artifactId>
- <version>1.2.0-SNAPSHOT</version>
+ <version>1.2.0.Beta2</version>
<relativePath>../../build/pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Modified: modules/test/trunk/tooling/pom.xml
===================================================================
--- modules/test/trunk/tooling/pom.xml 2008-02-22 16:28:22 UTC (rev 10090)
+++ modules/test/trunk/tooling/pom.xml 2008-02-22 23:26:34 UTC (rev 10091)
@@ -3,7 +3,7 @@
<parent>
<groupId>org.jboss.unit</groupId>
<artifactId>module-parent</artifactId>
- <version>1.2.0-SNAPSHOT</version>
+ <version>1.2.0.Beta2</version>
<relativePath>../build/pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
@@ -11,7 +11,7 @@
<artifactId>jboss-unit-tooling-aggregator</artifactId>
<packaging>pom</packaging>
<name>JBoss Unit Tooling (aggregator)</name>
- <version>1.2.0-SNAPSHOT</version>
+ <version>1.2.0.Beta2</version>
<modules>
<module>core</module>
<module>ant</module>
Modified: modules/test/trunk/unit/pom.xml
===================================================================
--- modules/test/trunk/unit/pom.xml 2008-02-22 16:28:22 UTC (rev 10090)
+++ modules/test/trunk/unit/pom.xml 2008-02-22 23:26:34 UTC (rev 10091)
@@ -3,7 +3,7 @@
<parent>
<groupId>org.jboss.unit</groupId>
<artifactId>module-parent</artifactId>
- <version>1.2.0-SNAPSHOT</version>
+ <version>1.2.0.Beta2</version>
<relativePath>../build/pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
@@ -17,7 +17,7 @@
<groupId>junit</groupId>
</dependency>
</dependencies>
-
+
<build>
<plugins>
<plugin>