Hi,
I've been out of the office for a few days (postcards arriving any day
now :-)) and have just started catching up with what has been going on
round here so apologies for not responding on this topic sooner.
Comments inlined below.
Best regards,
George
IBM UK
Stepan Mishura wrote:
Hi Richard,
Yes, I'm always for simplifying testing routine. And creating a detail guide
for configuring some testing server is a possible way to do it. However I'd
prefer to try to develop a simple local test server that is easy to
configure. I believe that it will cover most of cases.
First of all, thanks for taking the time to peruse the contents of
HARMONY-57 and for considering the implications for testing of
java.net.* types. As someone who regularly configures and runs the test
code and resources in HARMONY-57 I can assure you that there is nothing
particularly complicated in the set up.
In the file <HARMONY-57 ZIP EXTRACT
DIR>/Harmony/Harmony_Tests/src/test/resources/net.resources/README.txt I
did my best to document what the set up entails and how the tests can be
customised to run against servers running on any machine whether it be
the localhost or another machine across the network. Without wanting to
re-state the contents of that README file here, I would like to draw
your attention to some key parts of the setup which are :
* resources (e.g. text files, jars) are provided to the test user that
can be deployed on *whatever* kind of server (e.g. HTTP and FTP) they
wish to run. There are already a number of free, high quality HTTP, FTP,
SOCKS etc servers out there so there is really no point in writing a new
server just for the purposes of running these tests.
* the location of the servers can be specified in a simple Java
properties file. <HARMONY-57 ZIP EXTRACT
DIR>/Harmony/Harmony_Tests/src/test/resources/config/localhosttest.ini
is an example for running the tests on the localhost. The user may
specify any equivalent file (equivalent in the sense that it provides
values for the expected properties) for a test run.
Together, these two facets of the HARMONY-57 unit test code provide a
dynamic but simple way of enabling the same test suite to be run against
*any* HTTP, FTP, SOCKS server running on *any* machine. Given that I
fail to understand the need to develop any new server for the purposes
of running java.net.* tests.
And I assume that there may be a number of sophisticated test cases that
requires a special server set up. But I'd place them separately this was
discussed in '[testing] code for exotic configurations' topic.
If there is a need to develop sophisticated test cases above and beyond
the server set up in HARMONY-57 then I would vote for initially trying
to enhance the configuration of the HARMONY-57 support classes (add in
any new properties etc). If that were to prove unfeasible then it would
make sense to place such tests into the corresponding exclusion file and
run separately from the rest of the test cases.
Otherwise there is a chance to get the following detailed instructions:
1) Download http server from http://www.apache.org
...
50) Do this and that
...
100) Now you can run net tests
Thanks,
Stepan
My bet is that developers wishing to run the java.net.* tests are smart
enough to get an HTTP/FTP/SOCKS server working out of the box in a
matter of minutes. After that the issue becomes one of placing the
required test resource files into the expected locations and then
setting the required access. Where is the problem in that ?
On 2/22/06, Richard Liang <[EMAIL PROTECTED]> wrote:
Dears,
Agree that server (maybe not local) is required for some sophisticated
test cases. To make thing simply, we may provide more detail guide
(step-by-step) on how to setup/configure a typical testing server. Or
shall we setup a test server and allow user to share our testing server?
Richard Liang
China Software Development Lab, IBM
Hi Richard,
Ideally it should be possible to run the same tests (and get the same
results) when using the HTTP/FTP/SOCKS/whatever on any host - localhost
or else some remote machine that is available to all testers. Whether or
not this project has the resources to make a test server machine
available to all of us is not clear to me (can someone else comment on
this ?). At any rate, the objective should be to make the configuration
of any server machine as simple as possible.
Tim Ellison 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?
2) It is not as simple as I expected - my impression was that a local
server
implementation should be very simple because we are not going to test
whether it corresponds to http spec. or not. IMHO, it should only
provide a
test case with:
- a port number to open communication
- access to a server's input/output streams to verify a request to a
server
or to form a server's response.
Naive? Well, I'm aware that I'm not so experienced in java.netdevelopment
and testing and may be I'm wrong.
The local server I referenced can be used for a number of the java.net
tests, some of which do require more sophisticated behavior, like basic
authentication, eTags, etc.
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'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 ([EMAIL PROTECTED])
IBM Java technology centre, UK.
--
Thanks,
Stepan Mishura
Intel Middleware Products Division