changeset 544:c71ce17fa724 onclient

Add another error handling test
author Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
date Tue, 07 Sep 2021 13:30:14 +0200 (2021-09-07)
parents 70a827c6ced4
children 79393647d7fb
files tests/OnClientTester.java
diffstat 1 files changed, 21 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/tests/OnClientTester.java
+++ b/tests/OnClientTester.java
@@ -212,6 +212,27 @@ public final class OnClientTester extend
 		assertEq("connection is closed", true, conn.isClosed());
 	}
 
+
+	public void test_FailUploadLate2() throws SQLException, Failure {
+		// Here we send empty lines only, to check if the server detects is properly instead
+		// of simply complaining about an incomplete file.
+		prepare();
+		UploadHandler handler = new UploadHandler() {
+			@Override
+			public void handleUpload(MonetConnection.Upload handle, String name, boolean textMode, int offset) throws IOException {
+				PrintStream stream = handle.getStream();
+				for (int i = 1; i <= 20_000; i++)
+					stream.println();
+				stream.flush();
+				throw new IOException("exception after all");
+			}
+		};
+		conn.setUploadHandler(handler);
+		expectError("COPY INTO foo(t) FROM 'banana'(t) ON CLIENT", "after all");
+		assertEq("connection is closed", true, conn.isClosed());
+		// Cannot check the server log, but at the time I checked, it said "prematurely stopped client", which is fine.
+	}
+
 	// Disabled because it hangs, triggering the watchdog timer
 	public void testx_FailDownloadLate() throws SQLException, Failure {
 		prepare();