Author: julien(a)jboss.com
Date: 2008-02-22 19:17:20 -0500 (Fri, 22 Feb 2008)
New Revision: 10094
Added:
modules/test/trunk/test/src/main/java/org/jboss/portal/test/framework/common/xml/NoSuchElementException.java
Removed:
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/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
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/common/io/IOTools.java
modules/test/trunk/test/src/main/java/org/jboss/portal/test/framework/common/xml/XMLTools.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:
back to 1.2.0.SNAPSHOT + trim down forked utils
Modified: modules/test/trunk/build/pom.xml
===================================================================
--- modules/test/trunk/build/pom.xml 2008-02-22 23:35:21 UTC (rev 10093)
+++ modules/test/trunk/build/pom.xml 2008-02-23 00:17:20 UTC (rev 10094)
@@ -18,7 +18,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.jboss.unit</groupId>
<artifactId>module-parent</artifactId>
- <version>1.2.0.Beta2</version>
+ <version>1.2.0.SNAPSHOT</version>
<packaging>pom</packaging>
<name>JBoss Portal Test Module</name>
<
url>http://www.jboss.com/products/jbossmc</url>
Modified: modules/test/trunk/docs/pom.xml
===================================================================
--- modules/test/trunk/docs/pom.xml 2008-02-22 23:35:21 UTC (rev 10093)
+++ modules/test/trunk/docs/pom.xml 2008-02-23 00:17:20 UTC (rev 10094)
@@ -4,13 +4,13 @@
<parent>
<groupId>org.jboss.unit</groupId>
<artifactId>module-parent</artifactId>
- <version>1.2.0.Beta2</version>
+ <version>1.2.0.SNAPSHOT</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.Beta2</version>
+ <version>1.2.0.SNAPSHOT</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 23:35:21 UTC (rev 10093)
+++ modules/test/trunk/docs/user-guide/pom.xml 2008-02-23 00:17:20 UTC (rev 10094)
@@ -60,7 +60,7 @@
<groupId>org.jboss.unit</groupId>
<artifactId>user-guide-${translation}</artifactId>
- <version>1.2.0.Beta2</version>
+ <version>1.2.0.SNAPSHOT</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 23:35:21 UTC (rev 10093)
+++ modules/test/trunk/mc/pom.xml 2008-02-23 00:17:20 UTC (rev 10094)
@@ -3,7 +3,7 @@
<parent>
<groupId>org.jboss.unit</groupId>
<artifactId>module-parent</artifactId>
- <version>1.2.0.Beta2</version>
+ <version>1.2.0.SNAPSHOT</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 23:35:21 UTC (rev 10093)
+++ modules/test/trunk/pom.xml 2008-02-23 00:17:20 UTC (rev 10094)
@@ -5,7 +5,7 @@
<artifactId>module-aggregator</artifactId>
<packaging>pom</packaging>
<name>JBoss Portal Modules Test</name>
- <version>1.2.0.Beta2</version>
+ <version>1.2.0.SNAPSHOT</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 23:35:21 UTC (rev 10093)
+++ modules/test/trunk/remote/pom.xml 2008-02-23 00:17:20 UTC (rev 10094)
@@ -3,7 +3,7 @@
<parent>
<groupId>org.jboss.unit</groupId>
<artifactId>module-parent</artifactId>
- <version>1.2.0.Beta2</version>
+ <version>1.2.0.SNAPSHOT</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 23:35:21 UTC (rev 10093)
+++ modules/test/trunk/test/agent/pom.xml 2008-02-23 00:17:20 UTC (rev 10094)
@@ -3,7 +3,7 @@
<parent>
<groupId>org.jboss.unit</groupId>
<artifactId>module-parent</artifactId>
- <version>1.2.0.Beta2</version>
+ <version>1.2.0.SNAPSHOT</version>
<relativePath>../../build/pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Modified: modules/test/trunk/test/core/pom.xml
===================================================================
--- modules/test/trunk/test/core/pom.xml 2008-02-22 23:35:21 UTC (rev 10093)
+++ modules/test/trunk/test/core/pom.xml 2008-02-23 00:17:20 UTC (rev 10094)
@@ -3,7 +3,7 @@
<parent>
<groupId>org.jboss.unit</groupId>
<artifactId>module-parent</artifactId>
- <version>1.2.0.Beta2</version>
+ <version>1.2.0.SNAPSHOT</version>
<relativePath>../../build/pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Modified: modules/test/trunk/test/generic/pom.xml
===================================================================
--- modules/test/trunk/test/generic/pom.xml 2008-02-22 23:35:21 UTC (rev 10093)
+++ modules/test/trunk/test/generic/pom.xml 2008-02-23 00:17:20 UTC (rev 10094)
@@ -3,7 +3,7 @@
<parent>
<groupId>org.jboss.unit</groupId>
<artifactId>module-parent</artifactId>
- <version>1.2.0.Beta2</version>
+ <version>1.2.0.SNAPSHOT</version>
<relativePath>../../build/pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Modified: modules/test/trunk/test/jboss/pom.xml
===================================================================
--- modules/test/trunk/test/jboss/pom.xml 2008-02-22 23:35:21 UTC (rev 10093)
+++ modules/test/trunk/test/jboss/pom.xml 2008-02-23 00:17:20 UTC (rev 10094)
@@ -3,7 +3,7 @@
<parent>
<groupId>org.jboss.unit</groupId>
<artifactId>module-parent</artifactId>
- <version>1.2.0.Beta2</version>
+ <version>1.2.0.SNAPSHOT</version>
<relativePath>../../build/pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Modified: modules/test/trunk/test/opends/pom.xml
===================================================================
--- modules/test/trunk/test/opends/pom.xml 2008-02-22 23:35:21 UTC (rev 10093)
+++ modules/test/trunk/test/opends/pom.xml 2008-02-23 00:17:20 UTC (rev 10094)
@@ -3,7 +3,7 @@
<parent>
<groupId>org.jboss.unit</groupId>
<artifactId>module-parent</artifactId>
- <version>1.2.0.Beta2</version>
+ <version>1.2.0.SNAPSHOT</version>
<relativePath>../../build/pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Deleted:
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 2008-02-22
23:35:21 UTC (rev 10093)
+++
modules/test/trunk/test/src/main/java/org/jboss/portal/test/framework/common/Log4JWriter.java 2008-02-23
00:17:20 UTC (rev 10094)
@@ -1,86 +0,0 @@
-/*
-* 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;
- }
-}
-
Deleted:
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 2008-02-22
23:35:21 UTC (rev 10093)
+++
modules/test/trunk/test/src/main/java/org/jboss/portal/test/framework/common/MultiValuedPropertyMap.java 2008-02-23
00:17:20 UTC (rev 10094)
@@ -1,44 +0,0 @@
-/*
-* 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;
-}
Deleted:
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 2008-02-22
23:35:21 UTC (rev 10093)
+++
modules/test/trunk/test/src/main/java/org/jboss/portal/test/framework/common/ParameterValidation.java 2008-02-23
00:17:20 UTC (rev 10094)
@@ -1,67 +0,0 @@
-/*
-* 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);
- }
- }
-}
-
Deleted:
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 2008-02-22
23:35:21 UTC (rev 10093)
+++
modules/test/trunk/test/src/main/java/org/jboss/portal/test/framework/common/Tools.java 2008-02-23
00:17:20 UTC (rev 10094)
@@ -1,1023 +0,0 @@
-/*
-* 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
Modified:
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 2008-02-22
23:35:21 UTC (rev 10093)
+++
modules/test/trunk/test/src/main/java/org/jboss/portal/test/framework/common/io/IOTools.java 2008-02-23
00:17:20 UTC (rev 10094)
@@ -22,7 +22,6 @@
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;
@@ -32,16 +31,9 @@
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;
+import java.io.BufferedInputStream;
/**
* IO tools.
@@ -53,7 +45,7 @@
{
/** The logger. */
- public static final Logger log = Logger.getLogger(IOTools.class);
+ private static final Logger log = Logger.getLogger(IOTools.class);
/** . */
private static final Object[] EMPTY_ARGS = new Object[0];
@@ -205,241 +197,6 @@
}
/**
- * @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.
*
Deleted:
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 2008-02-22
23:35:21 UTC (rev 10093)
+++
modules/test/trunk/test/src/main/java/org/jboss/portal/test/framework/common/io/Serialization.java 2008-02-23
00:17:20 UTC (rev 10094)
@@ -1,121 +0,0 @@
-/*
-* 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;
-
-}
Deleted:
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 2008-02-22
23:35:21 UTC (rev 10093)
+++
modules/test/trunk/test/src/main/java/org/jboss/portal/test/framework/common/io/SerializationFilter.java 2008-02-23
00:17:20 UTC (rev 10094)
@@ -1,77 +0,0 @@
-/*
-* 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;
-
-}
-
Deleted:
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 2008-02-22
23:35:21 UTC (rev 10093)
+++
modules/test/trunk/test/src/main/java/org/jboss/portal/test/framework/common/io/UndeclaredIOException.java 2008-02-23
00:17:20 UTC (rev 10094)
@@ -1,45 +0,0 @@
-/*
-* 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/NoSuchElementException.java
===================================================================
---
modules/test/trunk/test/src/main/java/org/jboss/portal/test/framework/common/xml/NoSuchElementException.java
(rev 0)
+++
modules/test/trunk/test/src/main/java/org/jboss/portal/test/framework/common/xml/NoSuchElementException.java 2008-02-23
00:17:20 UTC (rev 10094)
@@ -0,0 +1,49 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2008, 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: 630 $
+ */
+public class NoSuchElementException extends RuntimeException
+{
+ public NoSuchElementException()
+ {
+ }
+
+ public NoSuchElementException(String message)
+ {
+ super(message);
+ }
+
+ public NoSuchElementException(String message, Throwable cause)
+ {
+ super(message, cause);
+ }
+
+ public NoSuchElementException(Throwable cause)
+ {
+ super(cause);
+ }
+}
Modified:
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 2008-02-22
23:35:21 UTC (rev 10093)
+++
modules/test/trunk/test/src/main/java/org/jboss/portal/test/framework/common/xml/XMLTools.java 2008-02-23
00:17:20 UTC (rev 10094)
@@ -48,7 +48,6 @@
import java.util.Iterator;
import java.util.List;
import java.util.Properties;
-import java.util.NoSuchElementException;
/**
* Utilities for dealing with XML.
Modified: modules/test/trunk/tooling/ant/pom.xml
===================================================================
--- modules/test/trunk/tooling/ant/pom.xml 2008-02-22 23:35:21 UTC (rev 10093)
+++ modules/test/trunk/tooling/ant/pom.xml 2008-02-23 00:17:20 UTC (rev 10094)
@@ -3,7 +3,7 @@
<parent>
<groupId>org.jboss.unit</groupId>
<artifactId>module-parent</artifactId>
- <version>1.2.0.Beta2</version>
+ <version>1.2.0.SNAPSHOT</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 23:35:21 UTC (rev 10093)
+++ modules/test/trunk/tooling/core/pom.xml 2008-02-23 00:17:20 UTC (rev 10094)
@@ -3,7 +3,7 @@
<parent>
<groupId>org.jboss.unit</groupId>
<artifactId>module-parent</artifactId>
- <version>1.2.0.Beta2</version>
+ <version>1.2.0.SNAPSHOT</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 23:35:21 UTC (rev
10093)
+++ modules/test/trunk/tooling/examples/maven2/pom.xml 2008-02-23 00:17:20 UTC (rev
10094)
@@ -11,7 +11,7 @@
<dependency>
<groupId>org.jboss.unit</groupId>
<artifactId>jboss-unit</artifactId>
- <version>1.2.0.Beta2</version>
+ <version>1.2.0.SNAPSHOT</version>
</dependency>
</dependencies>
@@ -39,7 +39,7 @@
<plugin>
<groupId>org.jboss.unit</groupId>
<artifactId>jboss-unit-tooling-maven2</artifactId>
- <version>1.2.0.Beta2</version>
+ <version>1.2.0.SNAPSHOT</version>
<executions>
<execution>
<phase>test</phase>
Modified: modules/test/trunk/tooling/maven2/pom.xml
===================================================================
--- modules/test/trunk/tooling/maven2/pom.xml 2008-02-22 23:35:21 UTC (rev 10093)
+++ modules/test/trunk/tooling/maven2/pom.xml 2008-02-23 00:17:20 UTC (rev 10094)
@@ -3,7 +3,7 @@
<parent>
<groupId>org.jboss.unit</groupId>
<artifactId>module-parent</artifactId>
- <version>1.2.0.Beta2</version>
+ <version>1.2.0.SNAPSHOT</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 23:35:21 UTC (rev 10093)
+++ modules/test/trunk/tooling/pom.xml 2008-02-23 00:17:20 UTC (rev 10094)
@@ -3,7 +3,7 @@
<parent>
<groupId>org.jboss.unit</groupId>
<artifactId>module-parent</artifactId>
- <version>1.2.0.Beta2</version>
+ <version>1.2.0.SNAPSHOT</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.Beta2</version>
+ <version>1.2.0.SNAPSHOT</version>
<modules>
<module>core</module>
<module>ant</module>
Modified: modules/test/trunk/unit/pom.xml
===================================================================
--- modules/test/trunk/unit/pom.xml 2008-02-22 23:35:21 UTC (rev 10093)
+++ modules/test/trunk/unit/pom.xml 2008-02-23 00:17:20 UTC (rev 10094)
@@ -3,7 +3,7 @@
<parent>
<groupId>org.jboss.unit</groupId>
<artifactId>module-parent</artifactId>
- <version>1.2.0.Beta2</version>
+ <version>1.2.0.SNAPSHOT</version>
<relativePath>../build/pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>