[undertow-dev] HttpServerExchange

Jason T. Greene jason.greene at redhat.com
Sat Oct 17 13:42:58 EDT 2015


Sorry for the delay. A number of us were traveling when you sent it.

The reason the class is final is just following the common practice of explicitly disallowing inheritance unless the class is explicitly designed for it. The rationale behind the practice is that a class that allows inheritance essentially has a fixed implementation that can not evolve without potentially breaking compatibility. Additionally if the class has concurrency behavior, inheritance that is not designed around an explicit synchronization contract can lead to all kinds of bugs.

If you do want to use mock testing, there are frameworks like easymock which can generate proxies for you, and your test code stays quite clean. 

> On Oct 17, 2015, at 9:40 AM, Greg Hellings <greg.hellings at gmail.com> wrote:
> 
> Ping.
> 
> --Greg
> 
>> On Oct 8, 2015 11:41 AM, "Greg Hellings" <greg.hellings at gmail.com> wrote:
>> I'm trying to mock out the HttpServerExchange object in my tests, but
>> I apparently cannot do so because the class is declared final. Why is
>> it final? Does that give Undertow anything beneficial?
>> 
>> If there's good reason to not remove the final, I can just wrap the
>> object in a proxy class that's not final, but I'd rather not do that
>> just to get around limitations in mocking. Another alternative would
>> be for me to skip unit tests on the handler methods and leverage
>> integration tests.But there are sometimes bits of logic in the handler
>> that I want to Unit Test directly.
>> 
>> Any help would be appreciated.
>> 
>> --Greg
> _______________________________________________
> undertow-dev mailing list
> undertow-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/undertow-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/undertow-dev/attachments/20151017/2c71a466/attachment-0001.html 


More information about the undertow-dev mailing list