@@ -0,0 +1,2660 @@
+/*%0A * Licensed to the Apache Software Foundation (ASF) under one%0A * or more contributor license agreements.  See the NOTICE file%0A * distributed with this work for additional information%0A * regarding copyright ownership.  The ASF licenses this file%0A * to you under the Apache License, Version 2.0 (the%0A * %22License%22); you may not use this file except in compliance%0A * with the License.  You may obtain a copy of the License at%0A *%0A *   http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing,%0A * software distributed under the License is distributed on an%0A * %22AS IS%22 BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY%0A * KIND, either express or implied.  See the License for the%0A * specific language governing permissions and limitations%0A * under the License.%0A */%0Apackage org.apache.felix.gogo.runtime;%0A%0Aimport java.io.BufferedReader;%0Aimport java.io.IOException;%0Aimport java.io.InputStreamReader;%0Aimport java.io.StringWriter;%0Aimport java.nio.file.Files;%0Aimport java.nio.file.Path;%0Aimport java.nio.file.Paths;%0Aimport java.util.ArrayList;%0Aimport java.util.Map.Entry;%0A%0A/*%0A * Test features of the new parser/tokenizer, many of which are not supported%0A * by the original parser.%0A */%0Apublic class TestParser4 extends AbstractParserTest%0A%7B%0A    public void testPipeErr() throws Exception%0A    %7B%0A        Context c = new Context();%0A        c.addCommand(%22echo%22, this);%0A        c.addCommand(%22echoerr%22, this);%0A        c.addCommand(%22tac%22, this);%0A%0A        assertEquals(%22hello%22, c.execute(%22echo %7C tac%22));%0A        assertEquals(%22hello%22, c.execute(%22echoerr %7C& tac%22));%0A    %7D%0A%0A    public void testRedir() throws Exception %7B%0A        Context c = new Context();%0A        c.addCommand(%22echo%22, this);%0A        c.addCommand(%22tac%22, this);%0A%0A        Path path = Paths.get(%22target/tmp%22);%0A        Files.createDirectories(path);%0A        c.currentDir(path);%0A%0A        Files.deleteIfExists(path.resolve(%22foo%22));%0A        assertEquals(%22hello%22, c.execute(%22echo %3Efoo %7C tac%22));%0A        assertEquals(%22hello%5Cn%22, new String(Files.readAllBytes(path.resolve(%22foo%22))));%0A    %7D%0A%0A    public void echo()%0A    %7B%0A        System.out.println(%22hello%22);%0A    %7D%0A%0A    public void echoerr()%0A    %7B%0A        System.err.println(%22hello%22);%0A    %7D%0A%0A    public String tac() throws IOException %7B%0A        StringWriter sw = new StringWriter();%0A        BufferedReader rdr = new BufferedReader(new InputStreamReader(System.in));%0A        boolean first = true;%0A        String s;%0A        while ((s = rdr.readLine()) != null) %7B%0A            if (!first) %7B%0A                sw.write(' ');%0A            %7D%0A            first = false;%0A            sw.write(s);%0A        %7D%0A        return sw.toString();%0A    %7D%0A%0A%7D%0A

Add a small test for redirections