From 7b673c0a2a50b20a8e1e75f43a2fc2e31b597e8c Mon Sep 17 00:00:00 2001 From: Myk Melez Date: Sat, 27 Sep 2014 03:13:48 -0700 Subject: [PATCH] also test FCOutputStream.openOffsetImpl --- tests/automation.js | 2 +- .../connection/file/TestFileConnection.java | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/tests/automation.js b/tests/automation.js index af908f22..271dd21d 100644 --- a/tests/automation.js +++ b/tests/automation.js @@ -36,7 +36,7 @@ casper.test.begin("unit tests", 5 + gfxTests.length, function(test) { casper .start("http://localhost:8000/index.html") .waitForText("DONE", function() { - test.assertTextExists("DONE: 4904 pass, 0 fail, 168 known fail, 0 unknown pass", "run unit tests"); + test.assertTextExists("DONE: 4907 pass, 0 fail, 168 known fail, 0 unknown pass", "run unit tests"); }); casper diff --git a/tests/com/ibm/oti/connection/file/TestFileConnection.java b/tests/com/ibm/oti/connection/file/TestFileConnection.java index f610ec3c..66153a7d 100644 --- a/tests/com/ibm/oti/connection/file/TestFileConnection.java +++ b/tests/com/ibm/oti/connection/file/TestFileConnection.java @@ -343,6 +343,24 @@ public class TestFileConnection implements Testlet { file.delete(); file.close(); + // Opening an output stream to a nonexistent file should create it + // even if we specify an offset. FCOutputStream doesn't say what to + // do if offset > fileSize, and our impl simply ignores the problem, + // although Connection sets offset to fileSize in that case, + // and presumably all callers are going to go through Connection + // rather than instantiating FCOutputStream directly, so our impl + // should be ok. + file = (FileConnection)Connector.open(dirPath + "provaDir/nonexistent.txt"); + th.check(!file.exists()); + // Create the stream ourselves because Connection.openOutputStream + // raises an exception when the file doesn't exist. + out = new FCOutputStream((file.getPath() + file.getName()).getBytes("UTF-8"), 5, null); + th.check(file.exists()); + th.check(file.fileSize(), 0, "Check file size"); + out.close(); + file.delete(); + file.close(); + dir = (FileConnection)Connector.open(dirPath + "provaDir"); dir.delete(); th.check(!dir.exists());