Author: julien(a)jboss.com
Date: 2007-03-26 18:43:28 -0400 (Mon, 26 Mar 2007)
New Revision: 6838
Removed:
branches/JBoss_Portal_Branch_2_4/common/src/main/org/jboss/portal/common/util/ThrowableBean.java
branches/JBoss_Portal_Branch_2_4/common/src/main/org/jboss/portal/test/common/ThrowableBeanTestCase.java
Modified:
branches/JBoss_Portal_Branch_2_4/common/build.xml
branches/JBoss_Portal_Branch_2_4/common/src/main/org/jboss/portal/test/common/URLNavigatorTestCase.java
branches/JBoss_Portal_Branch_2_4/tools/etc/buildfragments/buildmagic.ent
Log:
removing unused class + fix a test where the build.lib location was not provided to the
test
Modified: branches/JBoss_Portal_Branch_2_4/common/build.xml
===================================================================
--- branches/JBoss_Portal_Branch_2_4/common/build.xml 2007-03-26 22:34:33 UTC (rev 6837)
+++ branches/JBoss_Portal_Branch_2_4/common/build.xml 2007-03-26 22:43:28 UTC (rev 6838)
@@ -206,7 +206,7 @@
<target name="most" depends="_default:most"/>
<target name="help" depends="_default:help"/>
- <target name="tests" depends="compile">
+ <target name="tests" depends="init">
<execute-tests>
<x-test>
<test todir="${test.reports}"
name="org.jboss.portal.test.common.LocaleInfoTestCase"/>
@@ -221,12 +221,10 @@
<test todir="${test.reports}"
name="org.jboss.portal.test.common.URLNavigatorTestCase"/>
<test todir="${test.reports}"
name="org.jboss.portal.test.common.PathTestCase"/>
<test todir="${test.reports}"
name="org.jboss.portal.test.common.JavaBeanModelMBeanBuilderTestCase"/>
- <test todir="${test.reports}"
name="org.jboss.portal.test.common.ThrowableBeanTestCase"/>
<test todir="${test.reports}"
name="org.jboss.portal.test.common.ParameterMapTestCase"/>
<test todir="${test.reports}"
name="org.jboss.portal.test.common.LocalizedStringTestCase"/>
<test todir="${test.reports}"
name="org.jboss.portal.test.common.ImplodeTestCase"/>
- <test todir="${test.reports}"
-
name="org.jboss.portal.test.common.Application_XWWWFormURLEncodedFormatTestCase"/>
+ <test todir="${test.reports}"
name="org.jboss.portal.test.common.Application_XWWWFormURLEncodedFormatTestCase"/>
</x-test>
<x-classpath>
<pathelement location="${build.classes}"/>
Deleted:
branches/JBoss_Portal_Branch_2_4/common/src/main/org/jboss/portal/common/util/ThrowableBean.java
===================================================================
---
branches/JBoss_Portal_Branch_2_4/common/src/main/org/jboss/portal/common/util/ThrowableBean.java 2007-03-26
22:34:33 UTC (rev 6837)
+++
branches/JBoss_Portal_Branch_2_4/common/src/main/org/jboss/portal/common/util/ThrowableBean.java 2007-03-26
22:43:28 UTC (rev 6838)
@@ -1,285 +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.common.util;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.Field;
-
-/**
- * A bean to manipulate throwable.
- *
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision$
- */
-public class ThrowableBean
-{
-
- /** The stack trace. */
- private StackTraceElementBean[] stackTrace;
-
- /** The throwable with its stack trace and its cause cleared. */
- private Throwable state;
-
- /** The nested cause if any. */
- private ThrowableBean cause;
-
- public ThrowableBean()
- {
- }
-
- public ThrowableBean(Throwable throwable)
- {
- if (throwable == null)
- {
- throw new IllegalArgumentException();
- }
-
- // Clone first the throwable
- this.state = clone(throwable);
-
- // Then get its stack trace and clear it on the object itself
- StackTraceElement[] stackTrace = throwable.getStackTrace();
- this.stackTrace = new StackTraceElementBean[stackTrace.length];
- for (int i = 0; i < stackTrace.length; i++)
- {
- this.stackTrace[i] = new StackTraceElementBean(stackTrace[i]);
- }
- state.setStackTrace(new StackTraceElement[0]);
-
- // If the throwable has a cause, process recursively and clear the cause as well
- if (this.state.getCause() != null)
- {
- try
- {
- this.cause = new ThrowableBean(this.state.getCause());
- Field f = Throwable.class.getDeclaredField("cause");
- f.setAccessible(true);
- f.set(this.state, null);
- }
- catch (Exception unexpected)
- {
- throw new RuntimeException(unexpected);
- }
- }
- }
-
- public Throwable getState()
- {
- return state;
- }
-
- public void setState(Throwable state)
- {
- this.state = state;
- }
-
- public StackTraceElementBean[] getStackTrace()
- {
- return stackTrace;
- }
-
- public void setStackTrace(StackTraceElementBean[] stackTrace)
- {
- this.stackTrace = stackTrace;
- }
-
- public static class StackTraceElementBean
- {
-
- private String declaringClass;
- private String methodName;
- private String fileName;
- private int lineNumber;
-
- public StackTraceElementBean()
- {
- }
-
- public StackTraceElementBean(StackTraceElement ste)
- {
- declaringClass = ste.getClassName();
- methodName = ste.getMethodName();
- fileName = ste.getFileName();
- lineNumber = ste.getLineNumber();
- }
-
- public String getDeclaringClass()
- {
- return declaringClass;
- }
-
- public void setDeclaringClass(String declaringClass)
- {
- this.declaringClass = declaringClass;
- }
-
- public String getMethodName()
- {
- return methodName;
- }
-
- public void setMethodName(String methodName)
- {
- this.methodName = methodName;
- }
-
- public String getFileName()
- {
- return fileName;
- }
-
- public void setFileName(String fileName)
- {
- this.fileName = fileName;
- }
-
- public int getLineNumber()
- {
- return lineNumber;
- }
-
- public void setLineNumber(int lineNumber)
- {
- this.lineNumber = lineNumber;
- }
-
- /** Create a <code>java.lang.StackTraceElement</code> from this object.
*/
- public StackTraceElement toStackTraceElement()
- {
- if (declaringClass == null)
- {
- throw new IllegalStateException("No declaring class");
- }
- if (methodName == null)
- {
- throw new IllegalStateException("No method name");
- }
- if (fileName == null)
- {
- throw new IllegalStateException("No file name");
- }
- try
- {
- Constructor ctor = StackTraceElement.class.getDeclaredConstructor(new
Class[0]);
- ctor.setAccessible(true);
- StackTraceElement ste = (StackTraceElement)ctor.newInstance(new Object[0]);
-
- //
- Field methodNameSetter =
StackTraceElement.class.getDeclaredField("methodName");
- methodNameSetter.setAccessible(true);
- methodNameSetter.set(ste, methodName);
-
- //
- Field declaringClassSetter =
StackTraceElement.class.getDeclaredField("declaringClass");
- declaringClassSetter.setAccessible(true);
- declaringClassSetter.set(ste, declaringClass);
-
- //
- Field fileNameSetter =
StackTraceElement.class.getDeclaredField("fileName");
- fileNameSetter.setAccessible(true);
- fileNameSetter.set(ste, fileName);
-
- //
- Field lineNumberSetter =
StackTraceElement.class.getDeclaredField("lineNumber");
- lineNumberSetter.setAccessible(true);
- lineNumberSetter.setInt(ste, lineNumber);
-
- //
- return ste;
- }
- catch (Exception e)
- {
- throw new Error("Not expected", e);
- }
- }
- }
-
- public Throwable toThrowable()
- {
- if (this.state == null)
- {
- throw new IllegalStateException("No throwable present");
- }
- if (this.stackTrace == null)
- {
- throw new IllegalStateException("No stack trace present");
- }
-
- // Clone the state
- Throwable throwable = clone(this.state);
-
- // Set the stack trace back
- StackTraceElement[] stackTrace = new StackTraceElement[this.stackTrace.length];
- for (int i = 0; i < stackTrace.length; i++)
- {
- if (this.stackTrace[i] == null)
- {
- throw new IllegalStateException("No stack trace element present at
index=" + i);
- }
- stackTrace[i] = this.stackTrace[i].toStackTraceElement();
- }
- throwable.setStackTrace(stackTrace);
-
- // Process the cause recursively
- if (cause != null)
- {
- try
- {
- Field f = Throwable.class.getDeclaredField("cause");
- f.setAccessible(true);
- f.set(throwable, cause.toThrowable());
- }
- catch (Exception unexpected)
- {
- throw new RuntimeException(unexpected);
- }
- }
-
- //
- return throwable;
- }
-
- /** Clone a throwable using serialization. */
- private Throwable clone(Throwable t)
- {
- try
- {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- ObjectOutputStream oos = new ObjectOutputStream(baos);
- oos.writeObject(t);
- oos.close();
- ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
- ObjectInputStream ois = new ObjectInputStream(bais);
- t = (Throwable)ois.readObject();
- return t;
- }
- catch (Exception unexpected)
- {
- throw new RuntimeException(unexpected);
- }
- }
-}
Deleted:
branches/JBoss_Portal_Branch_2_4/common/src/main/org/jboss/portal/test/common/ThrowableBeanTestCase.java
===================================================================
---
branches/JBoss_Portal_Branch_2_4/common/src/main/org/jboss/portal/test/common/ThrowableBeanTestCase.java 2007-03-26
22:34:33 UTC (rev 6837)
+++
branches/JBoss_Portal_Branch_2_4/common/src/main/org/jboss/portal/test/common/ThrowableBeanTestCase.java 2007-03-26
22:43:28 UTC (rev 6838)
@@ -1,110 +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.common;
-
-import junit.framework.AssertionFailedError;
-import junit.framework.TestCase;
-import org.jboss.portal.common.util.ThrowableBean;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision$
- */
-public class ThrowableBeanTestCase extends TestCase
-{
-
- public void testException()
- {
- Exception e1 = new Exception();
- ThrowableBean tb = new ThrowableBean(e1);
- Exception e2 = (Exception)tb.toThrowable();
- assertEquals(e1, e2);
- }
-
- public void testNestedException()
- {
- Exception e1 = new Exception(new Exception());
- ThrowableBean tb = new ThrowableBean(e1);
- Exception e2 = (Exception)tb.toThrowable();
- assertEquals(e1, e2);
- }
-
- public void testExceptionNotEquals()
- {
- Exception e1 = (Exception)new ThrowableBean(new Exception()).toThrowable();
- Exception e2 = (Exception)new ThrowableBean(new Exception()).toThrowable();
- assertNotEquals(e1, e2);
- }
-
- private void assertNotEquals(Throwable t1, Throwable t2)
- {
- try
- {
- assertEquals(t1, t2);
- fail();
- }
- catch (AssertionFailedError expected)
- {
- }
- }
-
- private void assertEquals(Throwable t1, Throwable t2)
- {
- if (t1 == null || t2 == null)
- {
- fail();
- }
- if (!t1.getClass().equals(t2.getClass()))
- {
- fail();
- }
- StackTraceElement[] st1 = t1.getStackTrace();
- assertNotNull(st1);
- StackTraceElement[] st2 = t2.getStackTrace();
- assertNotNull(st2);
- assertEquals(st1.length, st2.length);
- for (int i = 0; i < st2.length; i++)
- {
- assertEquals(st1[i], st2[i]);
- }
- Throwable cause1 = t1.getCause();
- Throwable cause2 = t2.getCause();
- if (cause1 == null)
- {
- assertNull(cause2);
- }
- else
- {
- assertNotNull(cause2);
- assertEquals(cause1, cause2);
- }
- }
-
-// private void assertBinaryEquals(Throwable t1, Throwable t2)
-// {
-// String a1 = Base64.encodeObject(t1);
-// String a2 = Base64.encodeObject(t2);
-// assertEquals(a1, a2);
-//
-// }
-}
Modified:
branches/JBoss_Portal_Branch_2_4/common/src/main/org/jboss/portal/test/common/URLNavigatorTestCase.java
===================================================================
---
branches/JBoss_Portal_Branch_2_4/common/src/main/org/jboss/portal/test/common/URLNavigatorTestCase.java 2007-03-26
22:34:33 UTC (rev 6837)
+++
branches/JBoss_Portal_Branch_2_4/common/src/main/org/jboss/portal/test/common/URLNavigatorTestCase.java 2007-03-26
22:43:28 UTC (rev 6838)
@@ -114,7 +114,9 @@
public void testJar() throws Exception
{
- File libDir = new File(System.getProperty("build.lib"));
+ String pathname = System.getProperty("build.lib");
+ assertNotNull(pathname);
+ File libDir = new File(pathname);
assertTrue(libDir.exists());
assertTrue(libDir.isDirectory());
File jarFile = new File(libDir, "test.jar");
Modified: branches/JBoss_Portal_Branch_2_4/tools/etc/buildfragments/buildmagic.ent
===================================================================
--- branches/JBoss_Portal_Branch_2_4/tools/etc/buildfragments/buildmagic.ent 2007-03-26
22:34:33 UTC (rev 6837)
+++ branches/JBoss_Portal_Branch_2_4/tools/etc/buildfragments/buildmagic.ent 2007-03-26
22:43:28 UTC (rev 6838)
@@ -658,6 +658,7 @@
usefile="${junit.formatter.usefile}"
extension="${jboss-junit-configuration}.xml"/>
<sysproperty key="build.resources"
value="${build.resources}"/>
+ <sysproperty key="build.lib"
value="${build.lib}"/>
<!-- definition of the property for keeping results between configuration
-->
<sysproperty key="jboss-junit-configuration"
value="${jboss-junit-configuration}"/>
<x-sysproperty/>