Search in sources :

Example 21 with PipedOutputStream

use of java.io.PipedOutputStream in project sonarlint-core by SonarSource.

the class SettingsDownloaderTest method testFetchProjectSettings.

@Test
public void testFetchProjectSettings() throws Exception {
    SonarLintWsClient wsClient = WsClientTestUtils.createMock();
    Settings.FieldValues.Value.Builder valuesBuilder = Value.newBuilder();
    valuesBuilder.getMutableValue().put("filepattern", "**/*.xml");
    valuesBuilder.getMutableValue().put("rulepattern", "*:S12345");
    Value value1 = valuesBuilder.build();
    valuesBuilder.clear();
    valuesBuilder.getMutableValue().put("filepattern", "**/*.java");
    valuesBuilder.getMutableValue().put("rulepattern", "*:S456");
    Value value2 = valuesBuilder.build();
    ValuesWsResponse response = ValuesWsResponse.newBuilder().addSettings(Setting.newBuilder().setKey("sonar.inclusions").setValues(Values.newBuilder().addValues("**/*.java"))).addSettings(Setting.newBuilder().setKey("sonar.java.fileSuffixes").setValue("*.java")).addSettings(Setting.newBuilder().setKey("sonar.issue.exclusions.multicriteria").setFieldValues(FieldValues.newBuilder().addFieldValues(value1).addFieldValues(value2)).build()).build();
    PipedInputStream in = new PipedInputStream();
    final PipedOutputStream out = new PipedOutputStream(in);
    response.writeTo(out);
    out.close();
    WsClientTestUtils.addResponse(wsClient, "/api/settings/values.protobuf?component=foo", in);
    Builder builder = ModuleConfiguration.newBuilder();
    new SettingsDownloader(wsClient).fetchProjectSettings("6.3", "foo", null, builder);
    assertThat(builder.getPropertiesMap()).containsOnly(entry("sonar.inclusions", "**/*.java"), entry("sonar.java.fileSuffixes", "*.java"), entry("sonar.issue.exclusions.multicriteria", "1,2"), entry("sonar.issue.exclusions.multicriteria.1.filepattern", "**/*.xml"), entry("sonar.issue.exclusions.multicriteria.1.rulepattern", "*:S12345"), entry("sonar.issue.exclusions.multicriteria.2.filepattern", "**/*.java"), entry("sonar.issue.exclusions.multicriteria.2.rulepattern", "*:S456"));
}
Also used : ValuesWsResponse(org.sonarqube.ws.Settings.ValuesWsResponse) Builder(org.sonarsource.sonarlint.core.proto.Sonarlint.ModuleConfiguration.Builder) Value(org.sonarqube.ws.Settings.FieldValues.Value) PipedOutputStream(java.io.PipedOutputStream) PipedInputStream(java.io.PipedInputStream) Settings(org.sonarqube.ws.Settings) SonarLintWsClient(org.sonarsource.sonarlint.core.container.connected.SonarLintWsClient) Test(org.junit.Test)

Example 22 with PipedOutputStream

use of java.io.PipedOutputStream in project sonarlint-core by SonarSource.

the class CommandExecutor method createStreamHandler.

private ExecuteStreamHandler createStreamHandler() throws IOException {
    out = new ByteArrayOutputStream();
    err = new ByteArrayOutputStream();
    PipedOutputStream outPiped = new PipedOutputStream();
    InputStream inPiped = new PipedInputStream(outPiped);
    in = outPiped;
    TeeOutputStream teeOut = new TeeOutputStream(out, System.out);
    TeeOutputStream teeErr = new TeeOutputStream(err, System.err);
    return new PumpStreamHandler(teeOut, teeErr, inPiped);
}
Also used : TeeOutputStream(org.apache.commons.io.output.TeeOutputStream) PumpStreamHandler(org.apache.commons.exec.PumpStreamHandler) PipedInputStream(java.io.PipedInputStream) InputStream(java.io.InputStream) PipedOutputStream(java.io.PipedOutputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) PipedInputStream(java.io.PipedInputStream)

Example 23 with PipedOutputStream

use of java.io.PipedOutputStream in project hale by halestudio.

the class ConsoleController method makeConsoleOutput.

/**
 * Creates an InputStream that can be used by the console service to write
 * command results. The output stream will be connected via a pipe with
 * {@link #_input}, so results can be read from that input stream.
 *
 * @return the output stream
 */
private OutputStream makeConsoleOutput() {
    PipedInputStream input = new PipedInputStream(1024 * 1024);
    _input = input;
    try {
        return new PipedOutputStream(input);
    } catch (IOException e) {
        throw new IllegalStateException("Could not create console pipe");
    }
}
Also used : PipedOutputStream(java.io.PipedOutputStream) PipedInputStream(java.io.PipedInputStream) IOException(java.io.IOException)

Example 24 with PipedOutputStream

use of java.io.PipedOutputStream in project hale by halestudio.

the class ConsoleController method makeConsoleInput.

/**
 * Creates an InputStream that can be used in the console service to read
 * the commands. The input stream will be connected via a pipe with
 * {@link #_output}, so commands can be written to the output stream and
 * will be read by the console service.
 *
 * @return the input stream
 */
private InputStream makeConsoleInput() {
    PipedInputStream result = new PipedInputStream(1024 * 1024);
    try {
        OutputStream output = new PipedOutputStream(result);
        _output = new PrintWriter(new OutputStreamWriter(output));
    } catch (IOException e) {
        throw new IllegalStateException("Could not create console pipe");
    }
    return result;
}
Also used : OutputStream(java.io.OutputStream) PipedOutputStream(java.io.PipedOutputStream) PipedOutputStream(java.io.PipedOutputStream) OutputStreamWriter(java.io.OutputStreamWriter) PipedInputStream(java.io.PipedInputStream) IOException(java.io.IOException) PrintWriter(java.io.PrintWriter)

Example 25 with PipedOutputStream

use of java.io.PipedOutputStream in project pentaho-kettle by pentaho.

the class Log4jPipedAppenderTest method close.

@Test
public void close() throws IOException {
    PipedOutputStream pipedOutputStream = mock(PipedOutputStream.class);
    log4jPipedAppender.setPipedOutputStream(pipedOutputStream);
    log4jPipedAppender.close();
    verify(pipedOutputStream).close();
}
Also used : PipedOutputStream(java.io.PipedOutputStream) Test(org.junit.Test)

Aggregations

PipedOutputStream (java.io.PipedOutputStream)227 PipedInputStream (java.io.PipedInputStream)204 IOException (java.io.IOException)91 Test (org.junit.Test)55 InputStream (java.io.InputStream)28 OutputStream (java.io.OutputStream)24 BinaryDecoder (co.cask.cdap.common.io.BinaryDecoder)21 BinaryEncoder (co.cask.cdap.common.io.BinaryEncoder)21 PrintStream (java.io.PrintStream)21 ByteArrayOutputStream (java.io.ByteArrayOutputStream)19 ReflectionDatumReader (co.cask.cdap.internal.io.ReflectionDatumReader)17 TypeToken (com.google.common.reflect.TypeToken)17 InputStreamReader (java.io.InputStreamReader)16 DataInputStream (java.io.DataInputStream)14 DataOutputStream (java.io.DataOutputStream)14 BufferedReader (java.io.BufferedReader)13 Before (org.junit.Before)12 ByteArrayInputStream (java.io.ByteArrayInputStream)10 ExecutorService (java.util.concurrent.ExecutorService)8 ArrayList (java.util.ArrayList)7