Search in sources :

Example 16 with StreamConsumer

use of org.codehaus.plexus.util.cli.StreamConsumer in project maven-scm by apache.

the class FileConsumerTest method testConsumeUpdate.

@Test
public void testConsumeUpdate() {
    List<File> extractedFiles = new ArrayList<File>();
    StreamConsumer consumer = new FileConsumer(extractedFiles, FileConsumer.UPDATE_PATTERN);
    consumer.consumeLine("Content (1 K) of \"readme.txt\" - ok");
    consumer.consumeLine("Creating dir \"src/main/java/org\" .");
    consumer.consumeLine("Updating (creating) dir /./src/test/java");
    consumer.consumeLine("Updating element \\.\\src\\main\\java\\Application.java");
    assertThat(extractedFiles.size(), is(2));
    assertThat(extractedFiles, hasItem(new File("readme.txt")));
    assertThat(extractedFiles, hasItem(new File("src\\main\\java\\Application.java")));
}
Also used : StreamConsumer(org.codehaus.plexus.util.cli.StreamConsumer) ArrayList(java.util.ArrayList) File(java.io.File) Test(org.junit.Test)

Example 17 with StreamConsumer

use of org.codehaus.plexus.util.cli.StreamConsumer in project maven-scm by apache.

the class FileConsumerTest method testConsumeAdd.

@Test
public void testConsumeAdd() {
    List<File> extractedFiles = new ArrayList<File>();
    StreamConsumer consumer = new FileConsumer(extractedFiles, FileConsumer.ADD_PATTERN);
    consumer.consumeLine("Added and kept element /./src/main/java/Application.java");
    consumer.consumeLine("Added and kept element \\.\\src\\main\\java\\Windows.java");
    assertThat(extractedFiles.size(), is(2));
    assertThat(extractedFiles, hasItem(new File("src/main/java/Application.java")));
    assertThat(extractedFiles, hasItem(new File("src\\main\\java\\Windows.java")));
}
Also used : StreamConsumer(org.codehaus.plexus.util.cli.StreamConsumer) ArrayList(java.util.ArrayList) File(java.io.File) Test(org.junit.Test)

Aggregations

StreamConsumer (org.codehaus.plexus.util.cli.StreamConsumer)17 File (java.io.File)10 Commandline (org.codehaus.plexus.util.cli.Commandline)9 ArrayList (java.util.ArrayList)7 CommandLineException (org.codehaus.plexus.util.cli.CommandLineException)5 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)4 Test (org.junit.Test)4 DebugLoggerConsumer (org.apache.maven.scm.provider.jazz.command.consumer.DebugLoggerConsumer)3 ErrorConsumer (org.apache.maven.scm.provider.jazz.command.consumer.ErrorConsumer)3 JazzScmProviderRepository (org.apache.maven.scm.provider.jazz.repository.JazzScmProviderRepository)3 IOException (java.io.IOException)2 URI (java.net.URI)2 AbstractArtifactResolutionException (org.apache.maven.artifact.resolver.AbstractArtifactResolutionException)2 JazzScmCommand (org.apache.maven.scm.provider.jazz.command.JazzScmCommand)2 JarArchiver (org.codehaus.plexus.archiver.jar.JarArchiver)2 Manifest (org.codehaus.plexus.archiver.jar.Manifest)2 Attribute (org.codehaus.plexus.archiver.jar.Manifest.Attribute)2 DefaultConsumer (org.codehaus.plexus.util.cli.DefaultConsumer)2 BufferedReader (java.io.BufferedReader)1 InputStreamReader (java.io.InputStreamReader)1