Skip to content

Commit 288822a

Browse files
committed
8367068: Remove redundant HttpRequest.BodyPublisher tests
Reviewed-by: dfuchs
1 parent f993f90 commit 288822a

File tree

6 files changed

+8
-199
lines changed

6 files changed

+8
-199
lines changed

test/jdk/java/net/httpclient/FilePublisherTest.java

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
import org.testng.annotations.Test;
4040

4141
import javax.net.ssl.SSLContext;
42-
import java.io.FileNotFoundException;
4342
import java.io.IOException;
4443
import java.io.InputStream;
4544
import java.io.OutputStream;
@@ -60,7 +59,6 @@
6059
import static java.net.http.HttpClient.Version.HTTP_1_1;
6160
import static java.net.http.HttpClient.Version.HTTP_2;
6261
import static org.testng.Assert.assertEquals;
63-
import static org.testng.Assert.fail;
6462

6563
public class FilePublisherTest implements HttpServerAdapters {
6664
SSLContext sslContext;
@@ -156,26 +154,6 @@ public void testZipFs(String uriString,
156154
send(uriString, path, expectedMsg, sameClient);
157155
}
158156

159-
@Test
160-
public void testFileNotFound() throws Exception {
161-
out.printf("\n\n--- testFileNotFound(): starting\n");
162-
try (FileSystem fs = newZipFs()) {
163-
Path fileInZip = fs.getPath("non-existent.txt");
164-
BodyPublishers.ofFile(fileInZip);
165-
fail();
166-
} catch (FileNotFoundException e) {
167-
out.println("Caught expected: " + e);
168-
}
169-
var path = Path.of("fileNotFound.txt");
170-
try {
171-
Files.deleteIfExists(path);
172-
BodyPublishers.ofFile(path);
173-
fail();
174-
} catch (FileNotFoundException e) {
175-
out.println("Caught expected: " + e);
176-
}
177-
}
178-
179157
private static final int ITERATION_COUNT = 3;
180158

181159
private void send(String uriString,

test/jdk/java/net/httpclient/FlowAdapterPublisherTest.java

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
import java.util.Arrays;
3434
import java.util.Optional;
3535
import java.util.concurrent.Flow;
36-
import java.util.concurrent.Flow.Publisher;
3736
import java.util.concurrent.atomic.AtomicBoolean;
3837
import java.util.concurrent.atomic.AtomicInteger;
3938
import java.util.concurrent.atomic.AtomicLong;
@@ -55,8 +54,6 @@
5554
import static java.net.http.HttpRequest.BodyPublishers.fromPublisher;
5655
import static java.net.http.HttpResponse.BodyHandlers.ofString;
5756
import static org.testng.Assert.assertEquals;
58-
import static org.testng.Assert.assertThrows;
59-
import static org.testng.Assert.assertTrue;
6057
import static org.testng.Assert.fail;
6158

6259
/*
@@ -123,20 +120,6 @@ private HttpRequest.Builder newRequestBuilder(String uri) {
123120
return builder;
124121
}
125122

126-
@Test
127-
public void testAPIExceptions() {
128-
assertThrows(NPE, () -> fromPublisher(null));
129-
assertThrows(NPE, () -> fromPublisher(null, 1));
130-
assertThrows(IAE, () -> fromPublisher(new BBPublisher(), 0));
131-
assertThrows(IAE, () -> fromPublisher(new BBPublisher(), -1));
132-
assertThrows(IAE, () -> fromPublisher(new BBPublisher(), Long.MIN_VALUE));
133-
134-
Publisher publisher = fromPublisher(new BBPublisher());
135-
assertThrows(NPE, () -> publisher.subscribe(null));
136-
}
137-
138-
// Flow.Publisher<ByteBuffer>
139-
140123
@Test(dataProvider = "uris")
141124
void testByteBufferPublisherUnknownLength(String uri) {
142125
String[] body = new String[] { "You know ", "it's summer ", "in Ireland ",

test/jdk/java/net/httpclient/HttpRequestBodyPublishers/OfByteArraysTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444

4545
/*
4646
* @test
47-
* @bug 8364733
47+
* @bug 8226303 8364733
4848
* @summary Verify all specified `HttpRequest.BodyPublishers::ofByteArrays` behavior
4949
* @build ByteBufferUtils
5050
* RecordingSubscriber

test/jdk/java/net/httpclient/HttpRequestBodyPublishers/OfFileTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949

5050
/*
5151
* @test
52-
* @bug 8364733
52+
* @bug 8226303 8235459 8358688 8364733
5353
* @summary Verify all specified `HttpRequest.BodyPublishers::ofFile` behavior
5454
* @build ByteBufferUtils
5555
* RecordingSubscriber

test/jdk/java/net/httpclient/RelayingPublishers.java

Lines changed: 0 additions & 113 deletions
This file was deleted.

test/jdk/java/net/httpclient/SubscriberPublisherAPIExceptions.java renamed to test/jdk/java/net/httpclient/SubscriberAPIExceptions.java

Lines changed: 6 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -21,7 +21,6 @@
2121
* questions.
2222
*/
2323

24-
import java.io.FileNotFoundException;
2524
import java.nio.ByteBuffer;
2625
import java.nio.file.Files;
2726
import java.nio.file.Path;
@@ -30,17 +29,15 @@
3029
import java.util.List;
3130
import java.util.concurrent.CompletableFuture;
3231
import java.util.concurrent.Flow;
33-
import java.net.http.HttpHeaders;
34-
import java.net.http.HttpRequest.BodyPublishers;
3532
import java.net.http.HttpResponse.BodyHandler;
3633
import java.net.http.HttpResponse.ResponseInfo;
3734
import java.net.http.HttpResponse.BodyHandlers;
3835
import java.net.http.HttpResponse.BodySubscriber;
3936
import java.net.http.HttpResponse.BodySubscribers;
4037
import java.util.function.Function;
41-
import org.testng.annotations.DataProvider;
38+
4239
import org.testng.annotations.Test;
43-
import static java.nio.charset.StandardCharsets.UTF_8;
40+
4441
import static java.nio.file.StandardOpenOption.CREATE;
4542
import static java.nio.file.StandardOpenOption.DELETE_ON_CLOSE;
4643
import static java.nio.file.StandardOpenOption.WRITE;
@@ -49,53 +46,17 @@
4946

5047
/*
5148
* @test
52-
* @summary Basic tests for API specified exceptions from Publisher, Handler,
49+
* @summary Basic tests for API specified exceptions from Handler,
5350
* and Subscriber convenience static factory methods.
54-
* @run testng SubscriberPublisherAPIExceptions
51+
* @run testng SubscriberAPIExceptions
5552
*/
5653

57-
public class SubscriberPublisherAPIExceptions {
54+
public class SubscriberAPIExceptions {
5855

5956
static final Class<NullPointerException> NPE = NullPointerException.class;
6057
static final Class<IllegalArgumentException> IAE = IllegalArgumentException.class;
6158
static final Class<IndexOutOfBoundsException> IOB = IndexOutOfBoundsException.class;
6259

63-
@Test
64-
public void publisherAPIExceptions() {
65-
assertThrows(NPE, () -> BodyPublishers.ofByteArray(null));
66-
assertThrows(NPE, () -> BodyPublishers.ofByteArray(null, 0, 1));
67-
assertThrows(IOB, () -> BodyPublishers.ofByteArray(new byte[100], 0, 101));
68-
assertThrows(IOB, () -> BodyPublishers.ofByteArray(new byte[100], 1, 100));
69-
assertThrows(IOB, () -> BodyPublishers.ofByteArray(new byte[100], -1, 10));
70-
assertThrows(IOB, () -> BodyPublishers.ofByteArray(new byte[100], 99, 2));
71-
assertThrows(IOB, () -> BodyPublishers.ofByteArray(new byte[1], -100, 1));
72-
assertThrows(NPE, () -> BodyPublishers.ofByteArray(null));
73-
assertThrows(NPE, () -> BodyPublishers.ofFile(null));
74-
assertThrows(NPE, () -> BodyPublishers.ofInputStream(null));
75-
assertThrows(NPE, () -> BodyPublishers.ofString(null));
76-
assertThrows(NPE, () -> BodyPublishers.ofString("A", null));
77-
assertThrows(NPE, () -> BodyPublishers.ofString(null, UTF_8));
78-
assertThrows(NPE, () -> BodyPublishers.ofString(null, null));
79-
}
80-
81-
@DataProvider(name = "nonExistentFiles")
82-
public Object[][] nonExistentFiles() {
83-
List<Path> paths = List.of(Paths.get("doesNotExist"),
84-
Paths.get("tsixEtoNseod"),
85-
Paths.get("doesNotExist2"));
86-
paths.forEach(p -> {
87-
if (Files.exists(p))
88-
throw new AssertionError("Unexpected " + p);
89-
});
90-
91-
return paths.stream().map(p -> new Object[] { p }).toArray(Object[][]::new);
92-
}
93-
94-
@Test(dataProvider = "nonExistentFiles", expectedExceptions = FileNotFoundException.class)
95-
public void fromFileCheck(Path path) throws Exception {
96-
BodyPublishers.ofFile(path);
97-
}
98-
9960
@Test
10061
public void handlerAPIExceptions() throws Exception {
10162
Path path = Paths.get(".").resolve("tt");

0 commit comments

Comments
 (0)