You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@netbeans.apache.org by sk...@apache.org on 2020/05/05 11:53:15 UTC

[netbeans] branch master updated: test NbIOProvider.resetIO(io) as used by api.io InputOutput.reset()

This is an automated email from the ASF dual-hosted git repository.

skygo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/netbeans.git


The following commit(s) were added to refs/heads/master by this push:
     new af1c77f  test NbIOProvider.resetIO(io) as used by api.io InputOutput.reset()
     new 5c7a07f  Merge pull request #2130 from errael/InputOutputResetTest
af1c77f is described below

commit af1c77f5a28c30dd6ef11b3b061bb40ccb4ab96a
Author: Ernie Rael <er...@raelity.com>
AuthorDate: Mon May 4 20:36:27 2020 +0100

    test NbIOProvider.resetIO(io) as used by api.io InputOutput.reset()
---
 .../org/netbeans/core/output2/LifecycleTest.java   | 44 +++++++++++++++++++++-
 1 file changed, 43 insertions(+), 1 deletion(-)

diff --git a/platform/core.output2/test/unit/src/org/netbeans/core/output2/LifecycleTest.java b/platform/core.output2/test/unit/src/org/netbeans/core/output2/LifecycleTest.java
index 48e3dcf..50e01d3 100644
--- a/platform/core.output2/test/unit/src/org/netbeans/core/output2/LifecycleTest.java
+++ b/platform/core.output2/test/unit/src/org/netbeans/core/output2/LifecycleTest.java
@@ -60,6 +60,7 @@ public class LifecycleTest extends NbTestCase {
 
     private IOContainer container;
     private NbIO io;
+    private NbIOProvider ioProvider;
     JFrame jf = null;
 
     OutputTab tab = null;
@@ -75,7 +76,8 @@ public class LifecycleTest extends NbTestCase {
                 jf.getContentPane().add(getIOWindow(), BorderLayout.CENTER);
                 jf.setBounds(20, 20, 700, 300);
                 jf.setVisible(true);
-                io = (NbIO) new NbIOProvider().getIO("Test", false);
+                ioProvider = new NbIOProvider();
+                io = (NbIO) ioProvider.getIO("Test", false);
                 io.select();
                 tab = (OutputTab) container.getSelected();
                 pane = (OutputPane) tab.getOutputPane();
@@ -99,6 +101,7 @@ public class LifecycleTest extends NbTestCase {
         }
         io.closeInputOutput();
         io = null;
+        ioProvider = null;
         container = null;
         sleep();
     }
@@ -240,6 +243,45 @@ public class LifecycleTest extends NbTestCase {
             "fetch its storage after it was disposed.  It appears it wasn't disposed.", e);
     }
 
+    /**
+     * org.netbeans.api.io.InputOutput uses InputOutput.reset(),
+     * NOT writer.reset().[NETBEANS-4203]
+     * <p>
+     * Identical to testReset, expcept use ioProvider.resetIO(io) not writer.reset()
+     * </p>
+     * @throws Exception 
+     */
+    public void testNbIOReset() throws Exception {
+        System.out.println("testNbIOReset");
+        ErrWriter err = io.writer().getErr();
+        OutWriter out = io.writer().out();
+        NbWriter writer = io.writer();
+
+        OutputDocument doc = (OutputDocument) pane.getDocument();
+        assertNotNull ("Document should not be null", doc);
+
+        err.println ("hello");
+        writer.println ("world");
+        sleep();
+        ioProvider.resetIO(io);
+        sleep();
+
+        assertTrue ("Same writer object should be used after a reset", io.writer() == writer);
+        assertTrue ("Same err object should be used after a reset", io.writer().err() == err);
+        assertTrue ("Different output should be used afer a reset", out != io.writer().out());
+
+        assertNull ("Old document's Lines object not disposed - that means neither was its writer", doc.getLines());
+
+        Exception e = null;
+        try {
+            out.getStorage();
+        } catch (Exception exc) {
+            e = exc;
+        }
+        assertNotNull ("OutWriter should have thrown an exception on trying to " +
+            "fetch its storage after it was disposed.  It appears it wasn't disposed.", e);
+    }
+
     public void testCloseInputOutput() throws Exception {
 
         System.out.println("testCloseInputOutput");


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@netbeans.apache.org
For additional commands, e-mail: commits-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists