You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Jörg Schaible <jo...@gmx.de> on 2013/05/07 00:32:41 UTC
Fwd: svn commit: r1479663 - /commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/exception/ContextedRuntimeExceptionTest.java
-1
The test for this constructor showed, that you could use an own implementation
for the last parameter. Providing a DefaultExceptionContext makes no
difference to providing null (as it is done implicitly by the other
constructors).
--------------- Weitergeleitete Nachricht (Anfang)
Betreff: svn commit: r1479663 -
/commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/exception/ContextedRuntimeExceptionTest.java
Absender: britter-1oDqGaOF3Lkdnm+yROfE0A@public.gmane.org
Datum: Mon, 06 May 2013 18:05:38 +0000
Newsgruppe: gmane.comp.jakarta.commons.scm
Author: britter
Date: Mon May 6 18:05:37 2013
New Revision: 1479663
URL: http://svn.apache.org/r1479663
Log:
No need to define an anonymous subclass here
Modified:
commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/exception/ContextedRuntimeExceptionTest.java
Modified:
commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/exception/ContextedRuntimeExceptionTest.java
URL:
http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/exception/ContextedRuntimeExceptionTest.java?rev=1479663&r1=1479662&r2=1479663&view=diff
==============================================================================
---
commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/exception/ContextedRuntimeExceptionTest.java
(original)
+++
commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/exception/ContextedRuntimeExceptionTest.java
Mon May 6 18:05:37 2013
@@ -79,7 +79,7 @@ public class ContextedRuntimeExceptionTe
@Test
public void testContextedExceptionStringThrowableContext() {
- exceptionContext = new ContextedRuntimeException(TEST_MESSAGE_2, new
Exception(TEST_MESSAGE), new DefaultExceptionContext() {});
+ exceptionContext = new ContextedRuntimeException(TEST_MESSAGE_2, new
Exception(TEST_MESSAGE), new DefaultExceptionContext());
final String message = exceptionContext.getMessage();
final String trace = ExceptionUtils.getStackTrace(exceptionContext);
assertTrue(trace.indexOf("ContextedException")>=0);
--------------- Weitergeleitete Nachricht (Ende)
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org
Re: svn commit: r1479663 - /commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/exception/ContextedRuntimeExceptionTest.java
Posted by Jörg Schaible <Jo...@scalaris.com>.
Hi Benedikt,
Benedikt Ritter wrote:
> I have reverted the commit and commented why we use an anonymous subclass
> of DefaultExpectionContext. But to be honest I don't really see the point.
> Since the signature of the constructor is
>
> public ContextedRuntimeException(final String message, final Throwable
> cause, ExceptionContext context)
>
> every class that implements ExceptionContext can be passed in. Surely all
> subclasses of DefaultExceptionContext implement ExceptionContext. This is
> just how the language works...
>
> What am I missing here?
The constructor code does:
if (expectionContext == null) {
exceptionContext = new DefaultExceptionContext();
}
Therefore the difference of passing "null" or "new
DefaultExceptionContext()" is moot ... however passing "null" is tested
implicitly by all other constructors.
Basically I admit, that the test could really be improved to show that the
implementation can use an arbitrary ExceptionContext implementation (e.g. by
using a mock), but that's currently all we have ;-)
Cheers,
Jörg
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org
Re: svn commit: r1479663 - /commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/exception/ContextedRuntimeExceptionTest.java
Posted by Benedikt Ritter <br...@apache.org>.
I have reverted the commit and commented why we use an anonymous subclass
of DefaultExpectionContext. But to be honest I don't really see the point.
Since the signature of the constructor is
public ContextedRuntimeException(final String message, final Throwable
cause, ExceptionContext context)
every class that implements ExceptionContext can be passed in. Surely all
subclasses of DefaultExceptionContext implement ExceptionContext. This is
just how the language works...
What am I missing here?
Benedikt
2013/5/7 sebb <se...@gmail.com>
> On 6 May 2013 23:32, Jörg Schaible <jo...@gmx.de> wrote:
> >
> > -1
> >
> > The test for this constructor showed, that you could use an own
> implementation
> > for the last parameter. Providing a DefaultExceptionContext makes no
> > difference to providing null (as it is done implicitly by the other
> > constructors).
> >
>
> When fixed, this needs to be clearly documented in the test code please.
>
> > --------------- Weitergeleitete Nachricht (Anfang)
> >
> > Betreff: svn commit: r1479663 -
> >
> /commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/exception/ContextedRuntimeExceptionTest.java
> > Absender: britter-1oDqGaOF3Lkdnm+yROfE0A@public.gmane.org
> > Datum: Mon, 06 May 2013 18:05:38 +0000
> > Newsgruppe: gmane.comp.jakarta.commons.scm
> >
> > Author: britter
> > Date: Mon May 6 18:05:37 2013
> > New Revision: 1479663
> >
> > URL: http://svn.apache.org/r1479663
> > Log:
> > No need to define an anonymous subclass here
> >
> > Modified:
> >
> commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/exception/ContextedRuntimeExceptionTest.java
> >
> > Modified:
> >
> commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/exception/ContextedRuntimeExceptionTest.java
> > URL:
> >
> http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/exception/ContextedRuntimeExceptionTest.java?rev=1479663&r1=1479662&r2=1479663&view=diff
> >
> ==============================================================================
> > ---
> >
> commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/exception/ContextedRuntimeExceptionTest.java
> > (original)
> > +++
> >
> commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/exception/ContextedRuntimeExceptionTest.java
> > Mon May 6 18:05:37 2013
> > @@ -79,7 +79,7 @@ public class ContextedRuntimeExceptionTe
> >
> > @Test
> > public void testContextedExceptionStringThrowableContext() {
> > - exceptionContext = new
> ContextedRuntimeException(TEST_MESSAGE_2, new
> > Exception(TEST_MESSAGE), new DefaultExceptionContext() {});
> > + exceptionContext = new
> ContextedRuntimeException(TEST_MESSAGE_2, new
> > Exception(TEST_MESSAGE), new DefaultExceptionContext());
> > final String message = exceptionContext.getMessage();
> > final String trace =
> ExceptionUtils.getStackTrace(exceptionContext);
> > assertTrue(trace.indexOf("ContextedException")>=0);
> >
> >
> >
> > --------------- Weitergeleitete Nachricht (Ende)
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> > For additional commands, e-mail: dev-help@commons.apache.org
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
>
>
--
http://people.apache.org/~britter/
http://www.systemoutprintln.de/
http://twitter.com/BenediktRitter
http://github.com/britter
Re: svn commit: r1479663 - /commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/exception/ContextedRuntimeExceptionTest.java
Posted by sebb <se...@gmail.com>.
On 6 May 2013 23:32, Jörg Schaible <jo...@gmx.de> wrote:
>
> -1
>
> The test for this constructor showed, that you could use an own implementation
> for the last parameter. Providing a DefaultExceptionContext makes no
> difference to providing null (as it is done implicitly by the other
> constructors).
>
When fixed, this needs to be clearly documented in the test code please.
> --------------- Weitergeleitete Nachricht (Anfang)
>
> Betreff: svn commit: r1479663 -
> /commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/exception/ContextedRuntimeExceptionTest.java
> Absender: britter-1oDqGaOF3Lkdnm+yROfE0A@public.gmane.org
> Datum: Mon, 06 May 2013 18:05:38 +0000
> Newsgruppe: gmane.comp.jakarta.commons.scm
>
> Author: britter
> Date: Mon May 6 18:05:37 2013
> New Revision: 1479663
>
> URL: http://svn.apache.org/r1479663
> Log:
> No need to define an anonymous subclass here
>
> Modified:
> commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/exception/ContextedRuntimeExceptionTest.java
>
> Modified:
> commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/exception/ContextedRuntimeExceptionTest.java
> URL:
> http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/exception/ContextedRuntimeExceptionTest.java?rev=1479663&r1=1479662&r2=1479663&view=diff
> ==============================================================================
> ---
> commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/exception/ContextedRuntimeExceptionTest.java
> (original)
> +++
> commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/exception/ContextedRuntimeExceptionTest.java
> Mon May 6 18:05:37 2013
> @@ -79,7 +79,7 @@ public class ContextedRuntimeExceptionTe
>
> @Test
> public void testContextedExceptionStringThrowableContext() {
> - exceptionContext = new ContextedRuntimeException(TEST_MESSAGE_2, new
> Exception(TEST_MESSAGE), new DefaultExceptionContext() {});
> + exceptionContext = new ContextedRuntimeException(TEST_MESSAGE_2, new
> Exception(TEST_MESSAGE), new DefaultExceptionContext());
> final String message = exceptionContext.getMessage();
> final String trace = ExceptionUtils.getStackTrace(exceptionContext);
> assertTrue(trace.indexOf("ContextedException")>=0);
>
>
>
> --------------- Weitergeleitete Nachricht (Ende)
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org