harmony-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Stepan Mishura" <stepan.mish...@gmail.com>
Subject Re: local test server (Was: Re: [jira] Commented: (HARMONY-71) java.net.URLConnection.setUseCaches throws unspecified IllegalAccessError)
Date Mon, 27 Feb 2006 07:53:41 GMT
Tim,

 <..snip..>
> I agree that the tests in HARMONY-71 only need something to accept their
> connection, but I was simply pointing out that there will be a local
> server we can use if that contribution is accepted into the project, so
> probably not worth writing another.



I've developed a prototype of local server to be run with net unit tests,
started to play with it and ... realized that the current regression tests
for URLConnection class don't need any server at all :-)

I've filled JIRA bug attached a patch to fix tests. Please review it. (see
HARMONY-138)

Also I'd like to make a note on testing URLConnection class: I found that
creating an object of this class to be tested the following way in not
correct:
URLConnection u = new URL("http://www.apache.org").openConnection();

openConnection() returns a default implementation of HttpURLConnection
class, for example com.ibm.oti.net.www.protocol.http.HttpURLConnection, that
may override a tested method. IMHO, the correct approach is to subclass
URLConnection directly.

Thanks,
Stepan


> I'd like to start with the first issue (BTW, is it ok to discuss details
> of
> > contribution implementation if it is not accepted yet?).
>
> Sure -- I would expect people to be evaluating it thoroughly so that
> they can vote the code in/out.  The PPMC will shout early if the
> paperwork implies a contribution is unacceptable.
>
> > Can we avoid adding
> > a code that is specific for some test case to a local server?
>
> Does it interfere with what you want to do?
> In some cases, the test case needs to know what is on the server a
> priori, so that it can test the client behavior correctly.
>
> Regards,
> Tim
>
> > On 2/16/06, Tim Ellison wrote:
> >> I would rather that you just opened a new JIRA issue for that as it
> >> doesn't relate to the original problem.
> >>
> >> FYI there is a local server incoming in the HARMONY-57 contribution, so
> >> don't spend any time on it, see:
> >>
> >>
> <HARMONY-57>\Harmony\Harmony_Tests\src\test\java\tests\support\Support_HttpServer.java
> >>
> >> Regards,
> >> Tim
> >>
> >> Stepan Mishura (JIRA) wrote:
> >>>     [
> >>
> http://issues.apache.org/jira/browse/HARMONY-71?page=comments#action_12366637
> ]
> >>> Stepan Mishura commented on HARMONY-71:
> >>> ---------------------------------------
> >>>
> >>> Tim,
> >>>
> >>> Added test case (test_setUseCachesZ) depends on network and it fails
> if
> >> it can not create connection with apache.org. The same for HARMONY-72.
> I'm
> >> going to attach a patch file with a local server in it. Could you
> reopen
> >> this JIRA?
> >>> Thanks,
> >>> Stepan.
> >>>
> >>>>  java.net.URLConnection.setUseCaches throws unspecified
> >> IllegalAccessError
> >>
> --------------------------------------------------------------------------
> >>>>          Key: HARMONY-71
> >>>>          URL: http://issues.apache.org/jira/browse/HARMONY-71
> >>>>      Project: Harmony
> >>>>         Type: Bug
> >>>>   Components: Classlib
> >>>>     Reporter: Svetlana Samoilenko
> >>>>     Assignee: Tim Ellison
> >>>> According to j2se 1.4.2 specification method
> >> java.net.URLConnection.setUseCaches(boolean) throws
> IllegalStateException,
> >> if already connected. Harmony throws java.lang.IllegalAccessErrorinstead,
> >> that contradicts the specification.
> >>>> Code to reproduce:
> >>>> import java.io.IOException;
> >>>> import java.net.*;
> >>>> public class test2 {
> >>>>     public static void main(String[] args) {
> >>>>         HttpURLConnection u=null;
> >>>>         try {
> >>>>             u=(HttpURLConnection)(new URL("http://intel.com
> >> ").openConnection());
> >>>>             u.connect();
> >>>>         } catch (MalformedURLException e) {
> >>>>             System.out.println("unexpected MalformedURLException"+e);
> >>>>         } catch (IOException f) {
> >>>>             System.out.println("unexpected IOException"+f);
> >>>>         }
> >>>>         try {
> >>>>            u.setUseCaches(true);
> >>>>         } catch (IllegalStateException e) {
> >>>>            System.out.println("OK. Expected IllegalStateException");
> >>>>            e.printStackTrace();
> >>>>         };
> >>>>     }
> >>>> }
> >>>> Steps to Reproduce:
> >>>> 1. Build Harmony (check-out on 2006-01-30) j2se subset as described
> in
> >> README.txt.
> >>>> 2. Compile test2.java using BEA 1.4 javac
> >>>>> javac -d . test2.java
> >>>> 3. Run java using compatible VM (J9)
> >>>>> java -showversion test2
> >>>> Output:
> >>>> C:\tmp>C:\jrockit-j2sdk1.4.2_04\bin\java.exe -showversion test2
> >>>> java version "1.4.2_04"
> >>>> Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_04-b05)
> >>>> BEA WebLogic JRockit(TM) 1.4.2_04 JVM (build
> >> ari-31788-20040616-1132-win-ia32, Native Threads, GC strategy:
> parallel)
> >>>> OK. Expected IllegalStateException
> >>>> java.lang.IllegalStateException: Already connected
> >>>>         at java.net.URLConnection.setUseCaches(Z)V(URLConnection.java
> >> :828)
> >>>>         at test2.main([Ljava.lang.String;)V(test2.java:17)
> >>>> C:\tmp>C:\harmony\trunk\deploy\jre\bin\java -showversion test2
> >>>> (c) Copyright 1991, 2005 The Apache Software Foundation or its
> >> licensors, as applicable.
> >>>> java.lang.IllegalAccessError: Connection already established
> >>>>         at java.net.URLConnection.setUseCaches(URLConnection.java
> :923)
> >>>>         at test2.main(test2.java:17)
> >>>> Suggested junit test case:
> >>>> ------------------------
> URLConnectionTest.java-------------------------------------------------
> >>>> import java.io.IOException;
> >>>> import java.net.*;
> >>>> import junit.framework.*;
> >>>> public class URLConnectionTest extends TestCase {
> >>>>     public static void main(String[] args) {
> >>>>         junit.textui.TestRunner.run(URLConnectionTest.class);
> >>>>     }
> >>>>     public void test_setUseCaches () {
> >>>>         HttpURLConnection u=null;
> >>>>         try {
> >>>>             u=(HttpURLConnection)(new URL("http://intel.com
> >> ").openConnection());
> >>>>             u.connect();
> >>>>         } catch (MalformedURLException e) {
> >>>>             fail("unexpected MalformedURLException"+e);
> >>>>         } catch (IOException f) {
> >>>>             fail("unexpected IOException"+f);
> >>>>         }
> >>>>         try {
> >>>>            u.setUseCaches(true);
> >>>>         } catch (IllegalStateException e) { //expected
> >>>>         };
> >>>>    }
> >>>> }
> >> --
> >>
> >> Tim Ellison (t.p.ellison@gmail.com)
> >> IBM Java technology centre, UK.
> >>
> >
>
> --
>
> Tim Ellison (t.p.ellison@gmail.com)
> IBM Java technology centre, UK.
>



--
Thanks,
Stepan Mishura
Intel Middleware Products Division

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message