You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@netbeans.apache.org by lk...@apache.org on 2019/08/26 05:43:42 UTC
[netbeans] branch master updated: [NETBEANS-2480] Fixed filtering
out UTF8 characters from Gradle output.
This is an automated email from the ASF dual-hosted git repository.
lkishalmi 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 3efc6cf [NETBEANS-2480] Fixed filtering out UTF8 characters from Gradle output.
3efc6cf is described below
commit 3efc6cf7f149e37b0c7c12029fae8abc93a510ef
Author: Laszlo Kishalmi <la...@gmail.com>
AuthorDate: Sun Aug 25 07:18:09 2019 -0700
[NETBEANS-2480] Fixed filtering out UTF8 characters from Gradle output.
---
.../execute/EscapeProcessingOutputStream.java | 2 +-
.../execute/EscapeProcessingOutputStreamTest.java | 98 ++++++++++++++++++++++
2 files changed, 99 insertions(+), 1 deletion(-)
diff --git a/groovy/gradle/src/org/netbeans/modules/gradle/execute/EscapeProcessingOutputStream.java b/groovy/gradle/src/org/netbeans/modules/gradle/execute/EscapeProcessingOutputStream.java
index d4f6d22..6675c8c 100644
--- a/groovy/gradle/src/org/netbeans/modules/gradle/execute/EscapeProcessingOutputStream.java
+++ b/groovy/gradle/src/org/netbeans/modules/gradle/execute/EscapeProcessingOutputStream.java
@@ -64,7 +64,7 @@ class EscapeProcessingOutputStream extends OutputStream {
if (b == '\n') {
buffer.put(b);
processBulk();
- } else if ((b >= 0x20) || (b == 0x09)) {
+ } else if ((b >= 0x20) || (b == 0x09) || (b < 0)) {
buffer.put(b);
}
}
diff --git a/groovy/gradle/test/unit/src/org/netbeans/modules/gradle/execute/EscapeProcessingOutputStreamTest.java b/groovy/gradle/test/unit/src/org/netbeans/modules/gradle/execute/EscapeProcessingOutputStreamTest.java
new file mode 100644
index 0000000..29d1606
--- /dev/null
+++ b/groovy/gradle/test/unit/src/org/netbeans/modules/gradle/execute/EscapeProcessingOutputStreamTest.java
@@ -0,0 +1,98 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.netbeans.modules.gradle.execute;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.nio.charset.StandardCharsets;
+import static org.junit.Assert.*;
+import org.junit.Test;
+
+/**
+ *
+ * @author lkishalmi
+ */
+public class EscapeProcessingOutputStreamTest {
+
+ private static final String COLORED_TEST = "Hello \033[31mRed Robin\033[0m.";
+ private static final String UTF8_TEST = "大通西(20~28丁目)";
+
+ private static class DummyEscapeProcessor implements EscapeProcessor {
+
+ final StringBuilder output = new StringBuilder();
+
+ @Override
+ public void processCommand(String sequence, char command, int... args) {
+ }
+
+ @Override
+ public void processText(String text) {
+ output.append(text);
+ }
+
+ public String toString() {
+ return output.toString();
+ }
+ }
+
+ @Test
+ public void testUTF8() {
+ DummyEscapeProcessor ep = new DummyEscapeProcessor();
+ try (EscapeProcessingOutputStream os = new EscapeProcessingOutputStream(ep)) {
+ os.write(UTF8_TEST.getBytes(StandardCharsets.UTF_8));
+ os.flush();
+ } catch(IOException ex) {
+ fail(ex.getMessage());
+ }
+ assertEquals(UTF8_TEST, ep.toString());
+ }
+
+ @Test
+ public void testEscape() {
+ DummyEscapeProcessor ep = new DummyEscapeProcessor();
+ try (EscapeProcessingOutputStream os = new EscapeProcessingOutputStream(ep)) {
+ os.write(COLORED_TEST.getBytes(StandardCharsets.UTF_8));
+ } catch(IOException ex) {
+ fail(ex.getMessage());
+ }
+ assertEquals("Hello Red Robin.", ep.toString());
+ }
+
+ @Test
+ public void testMultiLine() {
+ DummyEscapeProcessor ep = new DummyEscapeProcessor();
+ try (PrintWriter out = new PrintWriter(new EscapeProcessingOutputStream(ep), true)) {
+ out.print("Line1");
+ assertEquals("", ep.toString());
+ out.println();
+ assertEquals("Line1\n", ep.toString());
+ out.print("Line2");
+ }
+ assertEquals("Line1\nLine2", ep.toString());
+ }
+
+ @Test
+ public void testMultiLine2() {
+ DummyEscapeProcessor ep = new DummyEscapeProcessor();
+ try (PrintWriter out = new PrintWriter(new EscapeProcessingOutputStream(ep), true)) {
+ out.print("Line1\015\012Line2");
+ }
+ assertEquals("Line1\nLine2", ep.toString());
+ }
+}
---------------------------------------------------------------------
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