Author: hlship
Date: Sun Feb 25 10:25:08 2007
New Revision: 511569
URL: http://svn.apache.org/viewvc?view=rev&rev=511569
Log:
Add equals() and hashCode() methods to LocationImpl, so that we can track which
locations have been rendered so far.
Change LocationRenderer into a perthread service and add logic to only print
out the full location (with source snippet) once per render.
Change ExceptionAnalyzer to identify and remove intermediate exceptions that
add no value (where value is defined in terms of either message content not
present in a containing exception, or properties not present in a containing
exception).
TAPESTRY-1298
Modified:
tapestry/tapestry5/tapestry-core/trunk/pom.xml
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/InternalModule.java
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/LocationRenderer.java
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/RequestRenderer.java
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/services/TapestryModule.java
tapestry/tapestry5/tapestry-ioc/trunk/pom.xml
tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/services/ExceptionAnalyzerImpl.java
tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/util/LocationImpl.java
tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/services/ExceptionAnalyzerImplTest.java
tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/util/LocationImplTest.java
tapestry/tapestry5/tapestry-project/trunk/pom.xml
Modified: tapestry/tapestry5/tapestry-core/trunk/pom.xml
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/pom.xml?view=diff&rev=511569&r1=511568&r2=511569
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/pom.xml (original)
+++ tapestry/tapestry5/tapestry-core/trunk/pom.xml Sun Feb 25 10:25:08 2007
@@ -5,11 +5,11 @@
<groupId>org.apache.tapestry</groupId>
<artifactId>tapestry-core</artifactId>
<packaging>jar</packaging>
- <version>5.0.2</version>
+ <version>5.0.3-SNAPSHOT</version>
<parent>
<groupId>org.apache.tapestry</groupId>
<artifactId>tapestry-project</artifactId>
- <version>5.0.2</version>
+ <version>5.0.3-SNAPSHOT</version>
<relativePath>../tapestry-project/pom.xml</relativePath>
</parent>
<name>Tapestry Core Library</name>
Modified:
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/InternalModule.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/InternalModule.java?view=diff&rev=511569&r1=511568&r2=511569
==============================================================================
---
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/InternalModule.java
(original)
+++
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/InternalModule.java
Sun Feb 25 10:25:08 2007
@@ -61,6 +61,7 @@
import org.apache.tapestry.services.Context;
import org.apache.tapestry.services.InfrastructureContribution;
import org.apache.tapestry.services.MarkupWriterFactory;
+import org.apache.tapestry.services.ObjectRenderer;
import org.apache.tapestry.services.PageRenderInitializer;
import org.apache.tapestry.services.PersistentFieldManager;
import org.apache.tapestry.services.PersistentLocale;
@@ -674,5 +675,11 @@
ComponentEventResultProcessor resultProcessor)
{
return new PageLinkHandlerImpl(_pageCache, resultProcessor);
+ }
+
+ @Lifecycle("perthread")
+ public static ObjectRenderer buildLocationRenderer()
+ {
+ return new LocationRenderer();
}
}
Modified:
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/LocationRenderer.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/LocationRenderer.java?view=diff&rev=511569&r1=511568&r2=511569
==============================================================================
---
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/LocationRenderer.java
(original)
+++
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/LocationRenderer.java
Sun Feb 25 10:25:08 2007
@@ -14,6 +14,8 @@
package org.apache.tapestry.internal.services;
+import static org.apache.tapestry.ioc.internal.util.CollectionFactory.newSet;
+
import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.IOException;
@@ -21,6 +23,7 @@
import java.io.InputStreamReader;
import java.io.LineNumberReader;
import java.net.URL;
+import java.util.Set;
import org.apache.tapestry.MarkupWriter;
import org.apache.tapestry.internal.TapestryUtils;
@@ -28,14 +31,27 @@
import org.apache.tapestry.ioc.Resource;
import org.apache.tapestry.services.ObjectRenderer;
+/**
+ * Responsible for rendering a [EMAIL PROTECTED] Location}. It is designed to
only perform the full output
+ * (which includes a snippet of the source file) once per render. This
requires the use of the
+ * "perthread" model (since the service tracks, internally,
+ */
public class LocationRenderer implements ObjectRenderer<Location>
{
private static final int RANGE = 5;
+ private final Set<Location> _rendered = newSet();
+
public void render(Location location, MarkupWriter writer)
{
writer.write(location.toString());
+ /** If the full details were already rendered this request, then skip
the rest. */
+ if (_rendered.contains(location))
+ return;
+
+ _rendered.add(location);
+
Resource r = location.getResource();
int line = location.getLine();
@@ -65,36 +81,40 @@
while (true)
{
String input = reader.readLine();
-
- if (input == null) break;
-
+
+ if (input == null)
+ break;
+
int current = reader.getLineNumber();
-
- if (current < start) continue;
-
- if (current > end) break;
-
+
+ if (current < start)
+ continue;
+
+ if (current > end)
+ break;
+
writer.element("tr");
-
- writer.element("td");
- writer.attributes("class", line == current ? "t-location-line
t-location-current" : "t-location-line");
+
+ writer.element("td");
+ writer.attributes("class", line == current ? "t-location-line
t-location-current"
+ : "t-location-line");
writer.write(Integer.toString(current));
writer.end();
-
+
String css = "t-location-content";
if (line == current)
css += " t-location-current";
if (start == current)
css += " t-location-content-first";
-
+
writer.element("td");
writer.attributes("class", css);
writer.write(input);
writer.end();
-
+
writer.end(); // tr
}
-
+
reader.close();
reader = null;
}
@@ -107,7 +127,7 @@
TapestryUtils.close(reader);
}
- writer.end(); // div
+ writer.end(); // div
}
}
Modified:
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/RequestRenderer.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/RequestRenderer.java?view=diff&rev=511569&r1=511568&r2=511569
==============================================================================
---
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/RequestRenderer.java
(original)
+++
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/RequestRenderer.java
Sun Feb 25 10:25:08 2007
@@ -45,8 +45,6 @@
}
writer.end(); // dd
- dd(writer, request.getContextPath());
-
dt(writer, "Request Path");
dd(writer, request.getPath());
Modified:
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/services/TapestryModule.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/services/TapestryModule.java?view=diff&rev=511569&r1=511568&r2=511569
==============================================================================
---
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/services/TapestryModule.java
(original)
+++
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/services/TapestryModule.java
Sun Feb 25 10:25:08 2007
@@ -108,7 +108,6 @@
import org.apache.tapestry.internal.services.InternalModule;
import org.apache.tapestry.internal.services.LinkActionResponseGenerator;
import org.apache.tapestry.internal.services.LinkFactory;
-import org.apache.tapestry.internal.services.LocationRenderer;
import org.apache.tapestry.internal.services.MarkupWriterImpl;
import org.apache.tapestry.internal.services.MetaDataLocatorImpl;
import org.apache.tapestry.internal.services.MetaWorker;
@@ -1476,7 +1475,10 @@
* Contributes a default object renderer for type Object, plus specialized
renderers for
* [EMAIL PROTECTED] Request} and [EMAIL PROTECTED] Location}.
*/
- public void contributeObjectRenderer(MappedConfiguration<Class,
ObjectRenderer> configuration)
+ public void contributeObjectRenderer(MappedConfiguration<Class,
ObjectRenderer> configuration,
+
+ @Inject("service:tapestry.internal.LocationRenderer")
+ ObjectRenderer locationRenderer)
{
configuration.add(Object.class, new ObjectRenderer()
{
@@ -1488,6 +1490,6 @@
configuration.add(Request.class, new RequestRenderer());
- configuration.add(Location.class, new LocationRenderer());
+ configuration.add(Location.class, locationRenderer);
}
}
Modified: tapestry/tapestry5/tapestry-ioc/trunk/pom.xml
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/pom.xml?view=diff&rev=511569&r1=511568&r2=511569
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/pom.xml (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/pom.xml Sun Feb 25 10:25:08 2007
@@ -5,12 +5,12 @@
<groupId>org.apache.tapestry</groupId>
<artifactId>tapestry-ioc</artifactId>
<packaging>jar</packaging>
- <version>5.0.2</version>
+ <version>5.0.3-SNAPSHOT</version>
<!-- This should change to tapestry-project -->
<parent>
<groupId>org.apache.tapestry</groupId>
<artifactId>tapestry-project</artifactId>
- <version>5.0.2</version>
+ <version>5.0.3-SNAPSHOT</version>
<relativePath>../tapestry-project/pom.xml</relativePath>
</parent>
<name>Tapestry Inversion of Control Container</name>
Modified:
tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/services/ExceptionAnalyzerImpl.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/services/ExceptionAnalyzerImpl.java?view=diff&rev=511569&r1=511568&r2=511569
==============================================================================
---
tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/services/ExceptionAnalyzerImpl.java
(original)
+++
tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/services/ExceptionAnalyzerImpl.java
Sun Feb 25 10:25:08 2007
@@ -1,4 +1,4 @@
-// Copyright 2006 The Apache Software Foundation
+// Copyright 2006, 2007 The Apache Software Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -30,9 +30,6 @@
import org.apache.tapestry.ioc.services.ExceptionInfo;
import org.apache.tapestry.ioc.services.PropertyAccess;
-/**
- *
- */
public class ExceptionAnalyzerImpl implements ExceptionAnalyzer
{
private final PropertyAccess _propertyAccess;
@@ -53,16 +50,54 @@
Throwable t = rootException;
+ ExceptionInfo previousInfo = null;
+
while (t != null)
{
ExceptionInfo info = extractInfo(t);
- list.add(info);
+ if (addsValue(previousInfo, info))
+ {
+ list.add(info);
+ previousInfo = info;
+ }
t = t.getCause();
}
return new ExceptionAnalysisImpl(list);
+ }
+
+ /**
+ * We want to filter out exceptions that do not provide any additional
value. Additional value
+ * includes: an exception message not present in the containing exception
or a property value
+ * not present in the containing exception. Also the first exception is
always valued and the
+ * last exception (with the stack trace) is valued.
+ *
+ * @param previousInfo
+ * @param info
+ * @return
+ */
+ private boolean addsValue(ExceptionInfo previousInfo, ExceptionInfo info)
+ {
+ if (previousInfo == null) return true;
+
+ if (!info.getStackTrace().isEmpty()) return true;
+
+ if (!previousInfo.getMessage().contains(info.getMessage())) return
true;
+
+ for (String name : info.getPropertyNames())
+ {
+ if (info.getProperty(name).equals(previousInfo.getProperty(name)))
continue;
+
+ // Found something new and different at this level.
+
+ return true;
+ }
+
+ // This exception adds nothing that is not present at a higher level.
+
+ return false;
}
private ExceptionInfo extractInfo(Throwable t)
Modified:
tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/util/LocationImpl.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/util/LocationImpl.java?view=diff&rev=511569&r1=511568&r2=511569
==============================================================================
---
tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/util/LocationImpl.java
(original)
+++
tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/util/LocationImpl.java
Sun Feb 25 10:25:08 2007
@@ -1,4 +1,4 @@
-// Copyright 2006 The Apache Software Foundation
+// Copyright 2006, 2007 The Apache Software Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -12,73 +12,97 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-package org.apache.tapestry.ioc.internal.util;
-
-import java.util.Formatter;
-
+package org.apache.tapestry.ioc.internal.util;
+
+import java.util.Formatter;
+
import org.apache.tapestry.ioc.Location;
import org.apache.tapestry.ioc.Resource;
-
-/**
- * Implementation class for [EMAIL PROTECTED]
org.apache.tapestry.ioc.Location}.
- *
- *
- */
-public final class LocationImpl implements Location
-{
- private final Resource _resource;
-
- private final int _line;
-
- private final int _column;
-
- private static final int UNKNOWN = -1;
-
- public LocationImpl(Resource resource)
- {
- this(resource, UNKNOWN);
- }
-
- public LocationImpl(Resource resource, int line)
- {
- this(resource, line, UNKNOWN);
- }
-
- public LocationImpl(Resource resource, int line, int column)
- {
- _resource = resource;
- _line = line;
- _column = column;
- }
-
- public Resource getResource()
- {
- return _resource;
- }
-
- public int getLine()
- {
- return _line;
- }
-
- public int getColumn()
- {
- return _column;
- }
-
- @Override
- public String toString()
- {
- StringBuilder buffer = new StringBuilder(_resource.toString());
- Formatter formatter = new Formatter(buffer);
-
- if (_line != UNKNOWN)
- formatter.format(", line %d", _line);
-
- if (_column != UNKNOWN)
- formatter.format(", column %d", _column);
-
- return buffer.toString();
- }
-
-}
+
+/**
+ * Implementation class for [EMAIL PROTECTED]
org.apache.tapestry.ioc.Location}.
+ */
+public final class LocationImpl implements Location
+{
+ private final Resource _resource;
+
+ private final int _line;
+
+ private final int _column;
+
+ private static final int UNKNOWN = -1;
+
+ public LocationImpl(Resource resource)
+ {
+ this(resource, UNKNOWN);
+ }
+
+ public LocationImpl(Resource resource, int line)
+ {
+ this(resource, line, UNKNOWN);
+ }
+
+ public LocationImpl(Resource resource, int line, int column)
+ {
+ _resource = resource;
+ _line = line;
+ _column = column;
+ }
+
+ public Resource getResource()
+ {
+ return _resource;
+ }
+
+ public int getLine()
+ {
+ return _line;
+ }
+
+ public int getColumn()
+ {
+ return _column;
+ }
+
+ @Override
+ public String toString()
+ {
+ StringBuilder buffer = new StringBuilder(_resource.toString());
+ Formatter formatter = new Formatter(buffer);
+
+ if (_line != UNKNOWN) formatter.format(", line %d", _line);
+
+ if (_column != UNKNOWN) formatter.format(", column %d", _column);
+
+ return buffer.toString();
+ }
+
+ @Override
+ public int hashCode()
+ {
+ final int PRIME = 31;
+ int result = 1;
+ result = PRIME * result + _column;
+ result = PRIME * result + _line;
+ result = PRIME * result + ((_resource == null) ? 0 :
_resource.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (this == obj) return true;
+ if (obj == null) return false;
+ if (getClass() != obj.getClass()) return false;
+ final LocationImpl other = (LocationImpl) obj;
+ if (_column != other._column) return false;
+ if (_line != other._line) return false;
+ if (_resource == null)
+ {
+ if (other._resource != null) return false;
+ }
+ else if (!_resource.equals(other._resource)) return false;
+ return true;
+ }
+
+}
Modified:
tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/services/ExceptionAnalyzerImplTest.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/services/ExceptionAnalyzerImplTest.java?view=diff&rev=511569&r1=511568&r2=511569
==============================================================================
---
tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/services/ExceptionAnalyzerImplTest.java
(original)
+++
tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/services/ExceptionAnalyzerImplTest.java
Sun Feb 25 10:25:08 2007
@@ -1,4 +1,4 @@
-// Copyright 2006 The Apache Software Foundation
+// Copyright 2006, 2007 The Apache Software Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -12,8 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-package org.apache.tapestry.ioc.internal.services;
-
+package org.apache.tapestry.ioc.internal.services;
+
import java.util.Arrays;
import org.apache.tapestry.ioc.Location;
@@ -25,84 +25,139 @@
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
-
-public class ExceptionAnalyzerImplTest extends IOCInternalTestCase
-{
- private ExceptionAnalyzer _analyzer;
-
- @BeforeClass
- public void setup_analyzer()
- {
- _analyzer = getService("tapestry.ioc.ExceptionAnalyzer",
ExceptionAnalyzer.class);
- }
-
- @AfterClass
- public void cleanup_analyzer()
- {
- _analyzer = null;
- }
-
- @Test
- public void basic_exception()
- {
- String message = "Hey! We've Got Not Tomatoes!";
-
- Throwable t = new RuntimeException(message);
-
- ExceptionAnalysis ea = _analyzer.analyze(t);
-
- assertEquals(ea.getExceptionInfos().size(), 1);
-
- ExceptionInfo ei = ea.getExceptionInfos().get(0);
-
- assertEquals(ei.getClassName(), RuntimeException.class.getName());
- assertEquals(ei.getMessage(), message);
-
- assertTrue(ei.getPropertyNames().isEmpty());
- assertFalse(ei.getStackTrace().isEmpty());
- }
-
- @Test
- public void exception_properties()
- {
- Location l = newLocation();
-
- replay();
-
- Throwable t = new TapestryException("Message", l, null);
-
- ExceptionAnalysis ea = _analyzer.analyze(t);
-
- assertEquals(ea.getExceptionInfos().size(), 1);
-
- ExceptionInfo ei = ea.getExceptionInfos().get(0);
-
- assertEquals(ei.getPropertyNames(), Arrays.asList("location"));
-
- assertEquals(ei.getProperty("location"), l);
-
- verify();
- }
-
- @Test
- public void nested_exceptions()
- {
- Throwable inner = new RuntimeException("Inner");
- Throwable outer = new RuntimeException("Outer", inner);
-
- ExceptionAnalysis ea = _analyzer.analyze(outer);
-
- assertEquals(ea.getExceptionInfos().size(), 2);
-
- ExceptionInfo ei = ea.getExceptionInfos().get(0);
-
- assertEquals(ei.getMessage(), "Outer");
- assertTrue(ei.getStackTrace().isEmpty());
-
- ei = ea.getExceptionInfos().get(1);
-
- assertEquals(ei.getMessage(), "Inner");
- assertFalse(ei.getStackTrace().isEmpty());
- }
-
-}
+
+public class ExceptionAnalyzerImplTest extends IOCInternalTestCase
+{
+ private ExceptionAnalyzer _analyzer;
+
+ @BeforeClass
+ public void setup_analyzer()
+ {
+ _analyzer = getService("tapestry.ioc.ExceptionAnalyzer",
ExceptionAnalyzer.class);
+ }
+
+ @AfterClass
+ public void cleanup_analyzer()
+ {
+ _analyzer = null;
+ }
+
+ @Test
+ public void basic_exception()
+ {
+ String message = "Hey! We've Got Not Tomatoes!";
+
+ Throwable t = new RuntimeException(message);
+
+ ExceptionAnalysis ea = _analyzer.analyze(t);
+
+ assertEquals(ea.getExceptionInfos().size(), 1);
+
+ ExceptionInfo ei = ea.getExceptionInfos().get(0);
+
+ assertEquals(ei.getClassName(), RuntimeException.class.getName());
+ assertEquals(ei.getMessage(), message);
+
+ assertTrue(ei.getPropertyNames().isEmpty());
+ assertFalse(ei.getStackTrace().isEmpty());
+ }
+
+ @Test
+ public void exception_properties()
+ {
+ Location l = newLocation();
+
+ replay();
+
+ Throwable t = new TapestryException("Message", l, null);
+
+ ExceptionAnalysis ea = _analyzer.analyze(t);
+
+ assertEquals(ea.getExceptionInfos().size(), 1);
+
+ ExceptionInfo ei = ea.getExceptionInfos().get(0);
+
+ assertEquals(ei.getPropertyNames(), Arrays.asList("location"));
+
+ assertEquals(ei.getProperty("location"), l);
+
+ verify();
+ }
+
+ @Test
+ public void nested_exceptions()
+ {
+ Throwable inner = new RuntimeException("Inner");
+ Throwable outer = new RuntimeException("Outer", inner);
+
+ ExceptionAnalysis ea = _analyzer.analyze(outer);
+
+ assertEquals(ea.getExceptionInfos().size(), 2);
+
+ ExceptionInfo ei = ea.getExceptionInfos().get(0);
+
+ assertEquals(ei.getMessage(), "Outer");
+ assertTrue(ei.getStackTrace().isEmpty());
+
+ ei = ea.getExceptionInfos().get(1);
+
+ assertEquals(ei.getMessage(), "Inner");
+ assertFalse(ei.getStackTrace().isEmpty());
+ }
+
+ @Test
+ public void middle_exception_removed_with_no_value()
+ {
+ Throwable inner = new RuntimeException("Inner");
+ Throwable middle = new RuntimeException("Middle", inner);
+ Throwable outer = new RuntimeException("Outer: Middle", middle);
+
+ ExceptionAnalysis ea = _analyzer.analyze(outer);
+
+ assertEquals(ea.getExceptionInfos().size(), 2);
+
+ ExceptionInfo ei = ea.getExceptionInfos().get(0);
+
+ assertEquals(ei.getMessage(), "Outer: Middle");
+ assertTrue(ei.getStackTrace().isEmpty());
+
+ ei = ea.getExceptionInfos().get(1);
+
+ assertEquals(ei.getMessage(), "Inner");
+ assertFalse(ei.getStackTrace().isEmpty());
+ }
+
+ @Test
+ public void middle_exception_retained_due_to_extra_property()
+ {
+ Location l = newLocation();
+
+ replay();
+
+ Throwable inner = new RuntimeException("Inner");
+ Throwable middle = new TapestryException("Middle", l, inner);
+ Throwable outer = new RuntimeException("Outer: Middle", middle);
+
+ ExceptionAnalysis ea = _analyzer.analyze(outer);
+
+ assertEquals(ea.getExceptionInfos().size(), 3);
+
+ ExceptionInfo ei = ea.getExceptionInfos().get(0);
+
+ assertEquals(ei.getMessage(), "Outer: Middle");
+ assertTrue(ei.getStackTrace().isEmpty());
+
+ ei = ea.getExceptionInfos().get(1);
+
+ assertEquals(ei.getMessage(), "Middle");
+ assertTrue(ei.getStackTrace().isEmpty());
+
+ ei = ea.getExceptionInfos().get(2);
+
+ assertEquals(ei.getMessage(), "Inner");
+ assertFalse(ei.getStackTrace().isEmpty());
+
+ verify();
+ }
+
+}
Modified:
tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/util/LocationImplTest.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/util/LocationImplTest.java?view=diff&rev=511569&r1=511568&r2=511569
==============================================================================
---
tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/util/LocationImplTest.java
(original)
+++
tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/util/LocationImplTest.java
Sun Feb 25 10:25:08 2007
@@ -1,4 +1,4 @@
-// Copyright 2006 The Apache Software Foundation
+// Copyright 2006, 2007 The Apache Software Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -7,6 +7,7 @@
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
+
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
@@ -60,7 +61,6 @@
@Test
public void unknown_line_and_column()
{
-
Location l = new LocationImpl(_resource);
assertSame(l.getResource(), _resource);
@@ -68,5 +68,34 @@
assertEquals(l.getColumn(), -1);
assertEquals(l.toString(), _resource.toString());
+ }
+
+ @Test
+ public void equality()
+ {
+ Location l1 = new LocationImpl(_resource, 22, 7);
+ Location l2 = new LocationImpl(_resource, 22, 7);
+ Location l3 = new LocationImpl(null, 22, 7);
+ Location l4 = new LocationImpl(_resource, 99, 7);
+ Location l5 = new LocationImpl(_resource, 22, 99);
+ Location l6 = new LocationImpl(new ClasspathResource("/baz/Biff.txt"),
22, 7);
+
+ assertEquals(l1, l1);
+ assertFalse(l1.equals(null));
+
+ assertEquals(l1, l2);
+ assertEquals(l2.hashCode(), l1.hashCode());
+
+ assertFalse(l3.equals(l1));
+ assertFalse(l3.hashCode() == l1.hashCode());
+
+ assertFalse(l4.equals(l1));
+ assertFalse(l4.hashCode() == l1.hashCode());
+
+ assertFalse(l5.equals(l1));
+ assertFalse(l5.hashCode() == l1.hashCode());
+
+ assertFalse(l6.equals(l1));
+ assertFalse(l6.hashCode() == l1.hashCode());
}
}
Modified: tapestry/tapestry5/tapestry-project/trunk/pom.xml
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-project/trunk/pom.xml?view=diff&rev=511569&r1=511568&r2=511569
==============================================================================
--- tapestry/tapestry5/tapestry-project/trunk/pom.xml (original)
+++ tapestry/tapestry5/tapestry-project/trunk/pom.xml Sun Feb 25 10:25:08 2007
@@ -5,7 +5,7 @@
<groupId>org.apache.tapestry</groupId>
<artifactId>tapestry-project</artifactId>
<packaging>pom</packaging>
- <version>5.0.2</version>
+ <version>5.0.3-SNAPSHOT</version>
<name>Tapestry Project</name>
<inceptionYear>2006</inceptionYear>
<url>http://tapestry.apache.org/tapestry5/</url>
@@ -141,13 +141,13 @@
<dependency>
<groupId>org.apache.tapestry</groupId>
<artifactId>tapestry-ioc</artifactId>
- <version>5.0.2</version>
+ <version>5.0.3-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.tapestry</groupId>
<artifactId>tapestry-core</artifactId>
- <version>5.0.2</version>
+ <version>5.0.3-SNAPSHOT</version>
</dependency>
</dependencies>
</dependencyManagement>