Skip to content

Commit 22cf7d8

Browse files
committed
Cleanup
1 parent afc52e1 commit 22cf7d8

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

src/test/java/io/fusionauth/http/MultipartTest.java

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
import io.fusionauth.http.server.HTTPServerConfiguration;
4040
import org.testng.annotations.Test;
4141
import static org.testng.Assert.assertEquals;
42-
import static org.testng.Assert.assertNotNull;
4342
import static org.testng.Assert.assertNull;
4443

4544
/**
@@ -128,7 +127,7 @@ public void post_server_configuration_fileTooBig(String scheme) throws Exception
128127
content-length: 0\r
129128
\r
130129
""")
131-
.expectExceptionOnWrite(SocketException.class);
130+
.assertOptionalExceptionOnWrite(SocketException.class);
132131
}
133132

134133
@Test(dataProvider = "schemes")
@@ -187,7 +186,7 @@ public void post_server_configuration_file_upload_reject(String scheme) throws E
187186
""")
188187
// If the request is large enough, because we throw an exception before we have emptied the InputStream
189188
// we will take an exception while trying to write all the bytes to the server.
190-
.expectExceptionOnWrite(SocketException.class);
189+
.assertOptionalExceptionOnWrite(SocketException.class);
191190

192191
}
193192

@@ -212,7 +211,7 @@ public void post_server_configuration_requestTooBig(String scheme) throws Except
212211
""")
213212
// If the request is large enough, because we throw an exception before we have emptied the InputStream
214213
// we will take an exception while trying to write all the bytes to the server.
215-
.expectExceptionOnWrite(SocketException.class);
214+
.assertOptionalExceptionOnWrite(SocketException.class);
216215
}
217216

218217
@Test(dataProvider = "schemes")
@@ -240,7 +239,7 @@ public void post_server_configuration_requestTooBig_maxBodySize(String scheme) t
240239
""")
241240
// If the request is large enough, because we throw an exception before we have emptied the InputStream
242241
// we will take an exception while trying to write all the bytes to the server.
243-
.expectExceptionOnWrite(SocketException.class);
242+
.assertOptionalExceptionOnWrite(SocketException.class);
244243
}
245244

246245
private Builder withConfiguration(Consumer<HTTPServerConfiguration> configuration) throws Exception {
@@ -269,9 +268,14 @@ public Builder(String scheme) {
269268
this.scheme = scheme;
270269
}
271270

272-
public Builder expectExceptionOnWrite(Class<? extends Exception> clazz) {
273-
assertNotNull(thrownOnWrite);
274-
assertEquals(thrownOnWrite.getClass(), clazz);
271+
public Builder assertOptionalExceptionOnWrite(Class<? extends Exception> clazz) {
272+
// Note that this assertion really depends upon the system the test is run on, the size of the request, and the amount of data that can be cached.
273+
// - So this is an optional assertion - if exception is not null, then we should be able to assert some attributes.
274+
// - With the larger sizes this exception is mostly always thrown when running tests locally, but in GHA, it doesn't always occur.
275+
if (thrownOnWrite != null) {
276+
assertEquals(thrownOnWrite.getClass(), clazz);
277+
}
278+
275279
return this;
276280
}
277281

0 commit comments

Comments
 (0)