You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@netbeans.apache.org by ma...@apache.org on 2017/11/25 13:54:25 UTC

[incubator-netbeans] branch master updated (2acccd3 -> af3dbdb)

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

matthiasblaesing pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-netbeans.git.


    from 2acccd3  Fix the license header template for NetBeans modules
     new 4ba4300  fix AssertionFailedError in org.netbeans.modules.templates.SCFTHandlerTest - windows (replace crlf characters with lf)
     new f2abb7c  Fix SCFTHandlerTest#testUTF8 and reduce duplicate code
     new af3dbdb  Merge branch 'failing-tests-in-api.templates'

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../modules/templates/SCFTHandlerTest.java         | 41 +++++++++-------------
 1 file changed, 16 insertions(+), 25 deletions(-)

-- 
To stop receiving notification emails like this one, please contact
['"commits@netbeans.apache.org" <co...@netbeans.apache.org>'].

[incubator-netbeans] 03/03: Merge branch 'failing-tests-in-api.templates'

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit af3dbdb5455ad536a79ca4a7f6d4e4c33b9c2624
Merge: 2acccd3 f2abb7c
Author: Matthias Bläsing <mb...@doppel-helix.eu>
AuthorDate: Sat Nov 25 14:52:33 2017 +0100

    Merge branch 'failing-tests-in-api.templates'
    
    - Fix checked on windows and linux
    - Merged under "trivial change does not need ICLA" rule
    
    This closes #248

 .../modules/templates/SCFTHandlerTest.java         | 41 +++++++++-------------
 1 file changed, 16 insertions(+), 25 deletions(-)

-- 
To stop receiving notification emails like this one, please contact
"commits@netbeans.apache.org" <co...@netbeans.apache.org>.

[incubator-netbeans] 01/03: fix AssertionFailedError in org.netbeans.modules.templates.SCFTHandlerTest - windows (replace crlf characters with lf)

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 4ba430016273040c52c6cf9dab72ae4095e160c0
Author: Sarvesh Kesharwani <sa...@oracle.com>
AuthorDate: Wed Nov 8 11:02:53 2017 +0530

    fix AssertionFailedError in org.netbeans.modules.templates.SCFTHandlerTest - windows (replace crlf characters with lf)
---
 .../unit/src/org/netbeans/modules/templates/SCFTHandlerTest.java  | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/api.templates/test/unit/src/org/netbeans/modules/templates/SCFTHandlerTest.java b/api.templates/test/unit/src/org/netbeans/modules/templates/SCFTHandlerTest.java
index 745a312..da750ca 100644
--- a/api.templates/test/unit/src/org/netbeans/modules/templates/SCFTHandlerTest.java
+++ b/api.templates/test/unit/src/org/netbeans/modules/templates/SCFTHandlerTest.java
@@ -226,7 +226,8 @@ public class SCFTHandlerTest extends NbTestCase {
         byte[] arr = new byte[(int)fo.getSize()];
         int len = fo.getInputStream().read(arr);
         assertEquals("Fully read", arr.length, len);
-        return new String(arr);
+        String foRead = new String(arr).replace(System.getProperty("line.separator"), "\n");
+        return foRead;
     }
 
     private static String readChars(FileObject fo, Charset set) throws IOException {
@@ -329,9 +330,10 @@ public class SCFTHandlerTest extends NbTestCase {
             fail("no input stream for " + snd);
         }
         String read = new String(cbuf, 0, len);
-        txt = txt.replaceAll("print\\('", "").replaceAll("'\\)", "") +'\n';
+        String normRead = read.replace(System.getProperty("line.separator"), "\n");
+        txt = txt.replaceAll("print\\('", "").replaceAll("'\\)", "") + "\n";
         
-        assertEquals(txt, read);
+        assertEquals(txt, normRead);
     }
      
     public static final class DD extends DialogDisplayer {

-- 
To stop receiving notification emails like this one, please contact
"commits@netbeans.apache.org" <co...@netbeans.apache.org>.

[incubator-netbeans] 02/03: Fix SCFTHandlerTest#testUTF8 and reduce duplicate code

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit f2abb7c091820a3fe1a2c5ca65cf1628809d5cb4
Author: Matthias Bläsing <mb...@doppel-helix.eu>
AuthorDate: Sat Nov 25 14:38:04 2017 +0100

    Fix SCFTHandlerTest#testUTF8 and reduce duplicate code
    
    From the previous commit the testUTF8 test still failed on windows.
    This change applies the solution from the previous commit (normalization
    of line-endings) also to the testUTF8 case.
---
 .../modules/templates/SCFTHandlerTest.java         | 39 ++++++++--------------
 1 file changed, 14 insertions(+), 25 deletions(-)

diff --git a/api.templates/test/unit/src/org/netbeans/modules/templates/SCFTHandlerTest.java b/api.templates/test/unit/src/org/netbeans/modules/templates/SCFTHandlerTest.java
index da750ca..6c559e3 100644
--- a/api.templates/test/unit/src/org/netbeans/modules/templates/SCFTHandlerTest.java
+++ b/api.templates/test/unit/src/org/netbeans/modules/templates/SCFTHandlerTest.java
@@ -20,13 +20,11 @@
 package org.netbeans.modules.templates;
 
 import java.awt.Dialog;
-import java.io.BufferedReader;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.io.OutputStream;
 import java.io.OutputStreamWriter;
-import java.nio.CharBuffer;
 import java.nio.charset.Charset;
 import java.util.Collections;
 import java.util.Enumeration;
@@ -223,25 +221,22 @@ public class SCFTHandlerTest extends NbTestCase {
     }
     
     private static String readFile(FileObject fo) throws IOException {
-        byte[] arr = new byte[(int)fo.getSize()];
-        int len = fo.getInputStream().read(arr);
-        assertEquals("Fully read", arr.length, len);
-        String foRead = new String(arr).replace(System.getProperty("line.separator"), "\n");
-        return foRead;
+        return readChars(fo, Charset.defaultCharset());
     }
 
     private static String readChars(FileObject fo, Charset set) throws IOException {
-        CharBuffer arr = CharBuffer.allocate((int)fo.getSize() * 2);
-        BufferedReader r = new BufferedReader(new InputStreamReader(fo.getInputStream(), set));
-        while (r.read(arr) != -1) {
-            // again
+        try (InputStream is = fo.getInputStream()) {
+            StringBuilder sb = new StringBuilder();
+            int read = 0;
+            char[] buffer = new char[1024];
+            InputStreamReader r = new InputStreamReader(is, set);
+            while ((read = r.read(buffer)) > 0) {
+                sb.append(buffer, 0, read);
+            }
+            return sb.toString().replace(System.getProperty("line.separator"), "\n");
         }
-        r.close();
-        
-        arr.flip();
-        return arr.toString();
     }
-
+    
      public void testUTF8() throws Exception {
          FileObject root = FileUtil.getConfigRoot();
          FileObject xmldir = FileUtil.createFolder(root, "xml");
@@ -322,15 +317,9 @@ public class SCFTHandlerTest extends NbTestCase {
         if (length <= 0) {
             fail("Too small file: " + length + " for " + snd);
         }
-        InputStream is = snd.getInputStream();
-        InputStreamReader r = new InputStreamReader(is, "UTF-8");
-        char[] cbuf = new char[1024];
-        int len = r.read(cbuf);
-        if (len == -1) {
-            fail("no input stream for " + snd);
-        }
-        String read = new String(cbuf, 0, len);
-        String normRead = read.replace(System.getProperty("line.separator"), "\n");
+        
+        String normRead = readChars(snd, Charset.forName("UTF-8"));
+
         txt = txt.replaceAll("print\\('", "").replaceAll("'\\)", "") + "\n";
         
         assertEquals(txt, normRead);

-- 
To stop receiving notification emails like this one, please contact
"commits@netbeans.apache.org" <co...@netbeans.apache.org>.