Skip to content

Commit

Permalink
8304174: Remove delays from httpserver tests
Browse files Browse the repository at this point in the history
Reviewed-by: jpai, dfuchs
  • Loading branch information
djelinski committed Mar 20, 2023
1 parent c09f83e commit 4505670
Show file tree
Hide file tree
Showing 40 changed files with 88 additions and 111 deletions.
4 changes: 2 additions & 2 deletions test/jdk/com/sun/net/httpserver/DateFormatterTest.java
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -87,7 +87,7 @@ public void setUp() throws IOException, URISyntaxException {

@AfterTest
public void cleanUp() {
server.stop(1);
server.stop(0);
}

@Test
Expand Down
4 changes: 2 additions & 2 deletions test/jdk/com/sun/net/httpserver/HttpServerTest.java
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -60,7 +60,7 @@ public void handle(HttpExchange ex) throws IOException {
sendHttpStatusCode(HTTP_STATUS_CODE_OK, ex);

System.out.println("Stopping server ...");
server.stop(1);
server.stop(0);
serverStopped.countDown();
}

Expand Down
7 changes: 3 additions & 4 deletions test/jdk/com/sun/net/httpserver/SelCacheTest.java
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2006, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2006, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -89,9 +89,8 @@ public static void main(String[] args) throws Exception {
test(false, "https", root+"/test1", loopback, httpsport, "largefile.txt", 2730088);
System.out.println("OK");
} finally {
delay();
s1.stop(2);
s2.stop(2);
s1.stop(0);
s2.stop(0);
executor.shutdown();
}
}
Expand Down
8 changes: 1 addition & 7 deletions test/jdk/com/sun/net/httpserver/Test.java
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -35,10 +35,4 @@ static void enableLogging() {
logger.setLevel(Level.ALL);
logger.addHandler(h);
}

static void delay () {
try {
Thread.sleep (1000);
} catch (Exception e) {}
}
}
7 changes: 3 additions & 4 deletions test/jdk/com/sun/net/httpserver/Test1.java
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -95,11 +95,10 @@ public static void main (String[] args) throws Exception {
test (false, "https", root+"/test1", httpsport, "largefile.txt", 2730088);
System.out.println ("OK");
} finally {
delay();
if (s1 != null)
s1.stop(2);
s1.stop(0);
if (s2 != null)
s2.stop(2);
s2.stop(0);
if (executor != null)
executor.shutdown ();
}
Expand Down
5 changes: 2 additions & 3 deletions test/jdk/com/sun/net/httpserver/Test10.java
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2010, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -57,9 +57,8 @@ public static void main (String[] args) throws Exception {
doClient(port);
System.out.println ("OK");
} finally {
delay();
if (server != null)
server.stop(2);
server.stop(0);
if (exec != null)
exec.shutdown();
}
Expand Down
4 changes: 2 additions & 2 deletions test/jdk/com/sun/net/httpserver/Test11.java
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -78,7 +78,7 @@ public static void main (String[] args) throws Exception {
System.out.println ("OK");
} finally {
s.shutdown();
server.stop(2);
server.stop(0);
}
}
}
7 changes: 3 additions & 4 deletions test/jdk/com/sun/net/httpserver/Test12.java
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -88,11 +88,10 @@ public static void main (String[] args) throws Exception {
join (r);
System.out.println ("OK");
} finally {
delay();
if (s1 != null)
s1.stop(2);
s1.stop(0);
if (s2 != null)
s2.stop(2);
s2.stop(0);
if (executor != null)
executor.shutdown ();
}
Expand Down
7 changes: 3 additions & 4 deletions test/jdk/com/sun/net/httpserver/Test13.java
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -93,11 +93,10 @@ public static void main (String[] args) throws Exception {
join (r);
System.out.println ("OK");
} finally {
delay();
if (s1 != null)
s1.stop(2);
s1.stop(0);
if (s2 != null)
s2.stop(2);
s2.stop(0);
if (executor != null)
executor.shutdown ();
}
Expand Down
4 changes: 2 additions & 2 deletions test/jdk/com/sun/net/httpserver/Test14.java
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -114,7 +114,7 @@ public static void main (String[] args) throws Exception {
output = output + (char)x;
}
error = !output.equals (test_output);
server.stop(2);
server.stop(0);
executor.shutdown();
if (error ) {
throw new RuntimeException ("test failed error");
Expand Down
4 changes: 2 additions & 2 deletions test/jdk/com/sun/net/httpserver/Test2.java
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -79,7 +79,7 @@ public boolean checkCredentials (String username, String pw) {
while (is.read()!= -1) {
c ++;
}
server.stop(2);
server.stop(0);
executor.shutdown();
if (error ) {
throw new RuntimeException ("test failed error");
Expand Down
5 changes: 2 additions & 3 deletions test/jdk/com/sun/net/httpserver/Test3.java
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -64,9 +64,8 @@ public static void main (String[] args) throws Exception {
doClient(port);
System.out.println ("OK");
} finally {
delay();
if (server != null)
server.stop(2);
server.stop(0);
if (exec != null)
exec.shutdown();
}
Expand Down
5 changes: 2 additions & 3 deletions test/jdk/com/sun/net/httpserver/Test4.java
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -62,9 +62,8 @@ public static void main (String[] args) throws Exception {
doClient(port);
System.out.println ("OK");
} finally {
delay();
if (server != null)
server.stop(2);
server.stop(0);
if (exec != null)
exec.shutdown();
}
Expand Down
5 changes: 2 additions & 3 deletions test/jdk/com/sun/net/httpserver/Test5.java
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -63,9 +63,8 @@ public static void main (String[] args) throws Exception {
doClient(port);
System.out.println ("OK");
} finally {
delay ();
if (server != null)
server.stop(2);
server.stop(0);
if (exec != null)
exec.shutdown();
}
Expand Down
5 changes: 2 additions & 3 deletions test/jdk/com/sun/net/httpserver/Test6.java
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -81,8 +81,7 @@ public static void main (String[] args) throws Exception {
if (error) {
throw new RuntimeException ("test failed error");
}
delay();
server.stop(2);
server.stop(0);
executor.shutdown();
System.out.println ("OK");

Expand Down
5 changes: 2 additions & 3 deletions test/jdk/com/sun/net/httpserver/Test6a.java
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -86,8 +86,7 @@ public static void main (String[] args) throws Exception {
if (error) {
throw new RuntimeException ("test failed error");
}
delay();
server.stop(2);
server.stop(0);
executor.shutdown();
System.out.println ("OK");

Expand Down
5 changes: 2 additions & 3 deletions test/jdk/com/sun/net/httpserver/Test7.java
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -80,8 +80,7 @@ public static void main (String[] args) throws Exception {
if (error) {
throw new RuntimeException ("test failed error");
}
delay();
server.stop(2);
server.stop(0);
executor.shutdown();
System.out.println ("OK");

Expand Down
5 changes: 2 additions & 3 deletions test/jdk/com/sun/net/httpserver/Test7a.java
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -89,8 +89,7 @@ public static void main (String[] args) throws Exception {
if (error) {
throw new RuntimeException ("test failed error");
}
delay();
server.stop(2);
server.stop(0);
executor.shutdown();
System.out.println ("OK");

Expand Down
5 changes: 2 additions & 3 deletions test/jdk/com/sun/net/httpserver/Test8.java
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -80,8 +80,7 @@ public static void main (String[] args) throws Exception {
if (error) {
throw new RuntimeException ("test failed error");
}
delay();
server.stop(2);
server.stop(0);
executor.shutdown();
System.out.println ("OK");

Expand Down
5 changes: 2 additions & 3 deletions test/jdk/com/sun/net/httpserver/Test8a.java
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -99,8 +99,7 @@ public static void main (String[] args) throws Exception {
}
is.close();
} finally {
delay();
if (server != null) server.stop(2);
if (server != null) server.stop(0);
if (executor != null) executor.shutdown();
}
if (error) {
Expand Down
7 changes: 3 additions & 4 deletions test/jdk/com/sun/net/httpserver/Test9.java
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -100,11 +100,10 @@ public static void main (String[] args) throws Exception {

System.out.println ("OK");
} finally {
delay();
if (s1 != null)
s1.stop(2);
s1.stop(0);
if (s2 != null)
s2.stop(2);
s2.stop(0);
if (executor != null)
executor.shutdown ();
}
Expand Down
5 changes: 2 additions & 3 deletions test/jdk/com/sun/net/httpserver/Test9a.java
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -96,9 +96,8 @@ public static void main (String[] args) throws Exception {

System.out.println ("OK");
} finally {
delay();
if (server != null)
server.stop(2);
server.stop(0);
if (executor != null)
executor.shutdown();
}
Expand Down

1 comment on commit 4505670

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.