You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@harmony.apache.org by Stepan Mishura <st...@gmail.com> on 2006/03/03 11:56:57 UTC
Re: local test server (Was: Re: [jira] Commented: (HARMONY-71) java.net.URLConnection.setUseCaches throws unspecified IllegalAccessError)
Tim, George, I'd like to resume this topic
>
>There is no way to force a server to send you a chunked response using
>regular HTTP headers, so in this case the server and client have an
>understanding that when the client asks for a particular resource the
>server will send it back in chunks.
>
I've created a small local server that just demonstrates common approach
only. The idea is the next: a simple local server provides a way for a unit
test to configure a server's response (also it may be improved to save a
request message to be check by a unit test):
---invoke---> ---request--->
A unit tests tested API a local server instance
| <---result--- <---response--- ^
| |
-------------------configure server--------------------
I believe this approach may be applied for most of cases and allow us to
eliminate dependency on an external server.
I've created JIRA (see Harmony-164) and attached a file with local server
and 2 JUnit test cases (one of them sends a chunked response, please note
there is no server's code specific for a selected test). Could you please
review the code and let me know what you think?
Thanks,
Stepan
On 2/22/06, Tim Ellison <t....@gmail.com> wrote:
>
> Stepan Mishura wrote:
> > On 2/21/06, Tim Ellison <t....@gmail.com> wrote:
> >
> >> Stepan Mishura wrote:
> >>> I glanced through a local server code from HARMONY-57 contribution
> >> without
> >>> looking into implementation details and ... this made me think. I
> catch
> >> hold
> >>> of the following:
> >>> 1) The server contains some testing code that looks not good for me
> >> Care to explain?
> >
> >
> > Support_HttpServer.java has the following code:
> >
> > class ServerThread implements Runnable {
> > public void run() {
> > ....
> > // call the test function based on the requested resource
> > if (resourceName.equals(CHUNKEDTEST))
> > chunkedTest();
> > <... lot of 'else if' ...>
> > ...
> > }
> >
> > private void chunkedTest() {
> > <... construct server's respond and send it ...>
> > }
> >
> > I'd prefer to avoid this and to have a server implementation that
> provides a
> > way for unit test to check received request and to configure a server's
> > respond.
>
> and I thought you wanted it simple ;-)
>
> There is no way to force a server to send you a chunked response using
> regular HTTP headers, so in this case the server and client have an
> understanding that when the client asks for a particular resource the
> server will send it back in chunks.
>
> If that understanding was encoded differently, say in the search field
> of the URL rather than the path would that make you happier? do you
> have some other idea?
>
> <snip>
>
> >> Does it interfere with what you want to do?
> >
> > Sure, we have javax.security.auth.kerberos.KerberosTicket class that
> > currently contains a stub. I was thinking about implementing the stub
> and
> > how to test it. So I played a little bit with developing Kerberos stub
> > server. When I saw that tests for URLConnection class failed because
> they
> > need local stub server then I got interested how to solve this similar
> > issue.
>
> Not clear how that interferes. You should feel free to reuse the server
> code and extend it as you need to do a faux Kerberos server.
>
> Regards,
> Tim
>
> --
>
> Tim Ellison (t.p.ellison@gmail.com)
> IBM Java technology centre, UK.
>
--
Thanks,
Stepan Mishura
Intel Middleware Products Division
Re: local test server (Was: Re: [jira] Commented: (HARMONY-71) java.net.URLConnection.setUseCaches
throws unspecified IllegalAccessError)
Posted by Richard Liang <ri...@gmail.com>.
Yes, Jetty is a good option :-)
Richard Liang
China Software Development Lab, IBM
Geir Magnusson Jr wrote:
>
>
> Stepan Mishura wrote:
>> Tim, George, I'd like to resume this topic
>
> Thanks for posting to the dev list :)
>
>>
>>> There is no way to force a server to send you a chunked response using
>>> regular HTTP headers, so in this case the server and client have an
>>> understanding that when the client asks for a particular resource the
>>> server will send it back in chunks.
>>>
>>
>> I've created a small local server that just demonstrates common approach
>> only. The idea is the next: a simple local server provides a way for
>> a unit
>> test to configure a server's response (also it may be improved to save a
>> request message to be check by a unit test):
>> ---invoke---> ---request--->
>> A unit tests tested API a local server instance
>> | <---result--- <---response--- ^
>> | |
>> -------------------configure server--------------------
>>
>> I believe this approach may be applied for most of cases and allow us to
>> eliminate dependency on an external server.
>
> And give us tight control to be able to mimic misbehavior on the
> server side to be sure that the library behaves correctly.
>
>>
>> I've created JIRA (see Harmony-164) and attached a file with local
>> server
>> and 2 JUnit test cases (one of them sends a chunked response, please
>> note
>> there is no server's code specific for a selected test). Could you
>> please
>> review the code and let me know what you think?
>
> I took a quick look, and while I really am convinced that our own
> framework is necessary for all sorts of reasons I and others have
> listed already, I do wonder if we could simply do better via using
> jetty or tomcat in some way?
>
> geir
>
>
Re: local test server (Was: Re: [jira] Commented: (HARMONY-71) java.net.URLConnection.setUseCaches throws unspecified IllegalAccessError)
Posted by Stepan Mishura <st...@gmail.com>.
On 3/3/06, Geir Magnusson Jr <ge...@pobox.com> wrote:
<...snip...>
>> I believe this approach may be applied for most of cases and allow us to
>> eliminate dependency on an external server.
>
>And give us tight control to be able to mimic misbehavior on the server
>side to be sure that the library behaves correctly.
>
Sure, it is quite important to verify that the implementation functions
properly in case of incorrect server's respond. And this can not be tested
with a 'real' server because as was noted previously "there is no way to
force a server to send you a chunked response using regular HTTP headers". I
can add that there is no way to force a server to send you a corrupted
respond.
<...snip...>
>
>I took a quick look, and while I really am convinced that our own
>framework is necessary for all sorts of reasons I and others have listed
>already, I do wonder if we could simply do better via using jetty or
>tomcat in some way?
>
Sorry, I didn't catch your suggestion with using jetty or tomcat. I don't
understand the next: why we should introduce external dependency when there
is simple solution?
When I see that a complicated way is invented instead of using simple and
obvious (from my point of view) solution I always assume two options here:
- I missed something important and someone should point me out where I'm
wrong.
- A person tends to create sophisticated solutions due to some reasons, for
example, she/he worked with some http server for years and now believes that
it should be used everywhere.
Returning back to our case, I do believe that there must be strong arguments
for using external server for unit testing. Arguments like a server is free
and easy configurable don't work against 40 lines of code and absence of
special configuration.
Thanks,
Stepan
On 3/3/06, Geir Magnusson Jr <ge...@pobox.com> wrote:
>
>
>
> Stepan Mishura wrote:
> > Tim, George, I'd like to resume this topic
>
> Thanks for posting to the dev list :)
>
> >
> >> There is no way to force a server to send you a chunked response using
> >> regular HTTP headers, so in this case the server and client have an
> >> understanding that when the client asks for a particular resource the
> >> server will send it back in chunks.
> >>
> >
> > I've created a small local server that just demonstrates common approach
> > only. The idea is the next: a simple local server provides a way for a
> unit
> > test to configure a server's response (also it may be improved to save a
> > request message to be check by a unit test):
> > ---invoke---> ---request--->
> > A unit tests tested API a local server instance
> > | <---result--- <---response--- ^
> > | |
> > -------------------configure server--------------------
> >
> > I believe this approach may be applied for most of cases and allow us to
> > eliminate dependency on an external server.
>
> And give us tight control to be able to mimic misbehavior on the server
> side to be sure that the library behaves correctly.
>
> >
> > I've created JIRA (see Harmony-164) and attached a file with local
> server
> > and 2 JUnit test cases (one of them sends a chunked response, please
> note
> > there is no server's code specific for a selected test). Could you
> please
> > review the code and let me know what you think?
>
> I took a quick look, and while I really am convinced that our own
> framework is necessary for all sorts of reasons I and others have listed
> already, I do wonder if we could simply do better via using jetty or
> tomcat in some way?
>
> geir
>
>
--
Thanks,
Stepan Mishura
Intel Middleware Products Division
Re: local test server (Was: Re: [jira] Commented: (HARMONY-71) java.net.URLConnection.setUseCaches
throws unspecified IllegalAccessError)
Posted by Geir Magnusson Jr <ge...@pobox.com>.
Stepan Mishura wrote:
> Tim, George, I'd like to resume this topic
Thanks for posting to the dev list :)
>
>> There is no way to force a server to send you a chunked response using
>> regular HTTP headers, so in this case the server and client have an
>> understanding that when the client asks for a particular resource the
>> server will send it back in chunks.
>>
>
> I've created a small local server that just demonstrates common approach
> only. The idea is the next: a simple local server provides a way for a unit
> test to configure a server's response (also it may be improved to save a
> request message to be check by a unit test):
> ---invoke---> ---request--->
> A unit tests tested API a local server instance
> | <---result--- <---response--- ^
> | |
> -------------------configure server--------------------
>
> I believe this approach may be applied for most of cases and allow us to
> eliminate dependency on an external server.
And give us tight control to be able to mimic misbehavior on the server
side to be sure that the library behaves correctly.
>
> I've created JIRA (see Harmony-164) and attached a file with local server
> and 2 JUnit test cases (one of them sends a chunked response, please note
> there is no server's code specific for a selected test). Could you please
> review the code and let me know what you think?
I took a quick look, and while I really am convinced that our own
framework is necessary for all sorts of reasons I and others have listed
already, I do wonder if we could simply do better via using jetty or
tomcat in some way?
geir