org.apache.maven.plugin.logging.SystemStreamLog Java Examples

The following examples show how to use org.apache.maven.plugin.logging.SystemStreamLog. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DockerAssemblyManagerTest.java    From docker-maven-plugin with Apache License 2.0 6 votes vote down vote up
@Test
public void assemblyFiles(@Injectable final MojoParameters mojoParams,
                          @Injectable final MavenProject project,
                          @Injectable final Assembly assembly) throws AssemblyFormattingException, ArchiveCreationException, InvalidAssemblerConfigurationException, MojoExecutionException, AssemblyReadException, IllegalAccessException {

    ReflectionUtils.setVariableValueInObject(assemblyManager, "trackArchiver", trackArchiver);

    new Expectations() {{
        mojoParams.getOutputDirectory();
        result = "target/"; times = 3;

        mojoParams.getProject();
        project.getBasedir();
        result = ".";

        assemblyReader.readAssemblies((AssemblerConfigurationSource) any);
        result = Arrays.asList(assembly);

    }};

    BuildImageConfiguration buildConfig = createBuildConfig();

    assemblyManager.getAssemblyFiles("testImage", buildConfig, mojoParams, new AnsiLogger(new SystemStreamLog(),true,"build"));
}
 
Example #2
Source File: SpringMavenDocumentSourceTest.java    From swagger-maven-plugin with Apache License 2.0 6 votes vote down vote up
@Test
public void testGetValidClasses() throws Exception
{
    Log log = new SystemStreamLog();

    ApiSource apiSource = new ApiSource();
    apiSource.setLocations(Collections.singletonList(this.getClass().getPackage().getName()));
    apiSource.setSwaggerDirectory("./");

    SpringMavenDocumentSource springMavenDocumentSource = new SpringMavenDocumentSource(apiSource, log, "UTF-8");

    Set<Class<?>> validClasses = springMavenDocumentSource.getValidClasses();

    Assert.assertEquals(validClasses.size(), 2);
    Assert.assertTrue(validClasses.contains(ExampleController1.class));
    Assert.assertTrue(validClasses.contains(ExampleController2.class));
}
 
Example #3
Source File: ShrinkWrapFatJarPackageServiceTest.java    From vertx-maven-plugin with Apache License 2.0 6 votes vote down vote up
@Test
public void testEmpty() throws PackagingException, IOException {
    AbstractVertxMojo mojo = mock(AbstractVertxMojo.class);
    when(mojo.getLog()).thenReturn(new SystemStreamLog());

    Archive archive = new Archive();
    archive.setIncludeClasses(false);

    File output = new File(out, "test-empty.jar");
    PackageConfig config = new PackageConfig()
        .setMojo(mojo)
        .setOutput(output)
        .setArchive(archive);
    service.doPackage(config);

    assertThat(output).isFile();
    JarFile jar = new JarFile(output);
    List<String> list = jar.stream().map(ZipEntry::getName)
        .filter(s -> ! s.endsWith("/")) // Directories
        .collect(Collectors.toList());
    assertThat(list).containsExactly("META-INF/MANIFEST.MF");
}
 
Example #4
Source File: ShrinkWrapFatJarPackageServiceTest.java    From vertx-maven-plugin with Apache License 2.0 6 votes vote down vote up
@Test
public void testEmbeddingDependencies() throws IOException, PackagingException {
    AbstractVertxMojo mojo = mock(AbstractVertxMojo.class);
    when(mojo.getLog()).thenReturn(new SystemStreamLog());

    Archive archive = new Archive();
    archive.setIncludeClasses(false);
    archive.setDependencySets(ImmutableList.of(new DependencySet()));

    Set<Artifact> artifacts = ImmutableSet.of(getFirstArtifact(), getSecondArtifact());

    File output = new File(out, "test-all-dependencies.jar");
    PackageConfig config = new PackageConfig()
        .setMojo(mojo)
        .setOutput(output)
        .setArtifacts(artifacts)
        .setArchive(archive);
    service.doPackage(config);

    assertThat(output).isFile();
    JarFile jar = new JarFile(output);
    List<String> list = jar.stream().map(ZipEntry::getName)
        .filter(s -> ! s.endsWith("/")) // Directories
        .collect(Collectors.toList());
    assertThat(list).containsOnly("META-INF/MANIFEST.MF", "testconfig.yaml", "out/some-config.yaml");
}
 
Example #5
Source File: NpmRunnerMojoTest.java    From wisdom with Apache License 2.0 6 votes vote down vote up
@Before
public void setUp() throws IOException {
    nodeDirectory = new File("target/test/node");
    nodeDirectory.mkdirs();
    Log log = new SystemStreamLog();
    AbstractWisdomMojo mojo = new AbstractWisdomMojo() {
        @Override
        public void execute() throws MojoExecutionException, MojoFailureException {
            // Do nothing.
        }
    };
    mojo.basedir = this.baseDir;
    manager = new NodeManager(log, nodeDirectory, mojo);

    File assets = new File(baseDir, "src/main/resources/assets");
    assets.mkdirs();

    FileUtils.copyDirectory(new File("src/test/resources"), assets);
}
 
Example #6
Source File: ShrinkWrapFatJarPackageServiceTest.java    From vertx-maven-plugin with Apache License 2.0 6 votes vote down vote up
@Test
public void testEmbeddingDependenciesUsingInclusion() throws IOException, PackagingException {
    AbstractVertxMojo mojo = mock(AbstractVertxMojo.class);
    when(mojo.getLog()).thenReturn(new SystemStreamLog());

    Archive archive = new Archive();
    archive.setIncludeClasses(false);
    archive.setDependencySets(ImmutableList.of(new DependencySet().addInclude("org.acme:jar1")));

    Set<Artifact> artifacts = ImmutableSet.of(getFirstArtifact(), getSecondArtifact());

    File output = new File(out, "test-inclusion.jar");
    PackageConfig config = new PackageConfig()
        .setMojo(mojo)
        .setOutput(output)
        .setArtifacts(artifacts)
        .setArchive(archive);
    service.doPackage(config);

    assertThat(output).isFile();
    JarFile jar = new JarFile(output);
    List<String> list = jar.stream().map(ZipEntry::getName)
        .filter(s -> ! s.endsWith("/")) // Directories
        .collect(Collectors.toList());
    assertThat(list).contains("META-INF/MANIFEST.MF", "testconfig.yaml").hasSize(2);
}
 
Example #7
Source File: ShrinkWrapFatJarPackageServiceTest.java    From vertx-maven-plugin with Apache License 2.0 6 votes vote down vote up
@Test
public void testEmbeddingDependenciesUsingExclusion() throws IOException, PackagingException {
    AbstractVertxMojo mojo = mock(AbstractVertxMojo.class);
    when(mojo.getLog()).thenReturn(new SystemStreamLog());

    Archive archive = new Archive();
    archive.setIncludeClasses(false);
    archive.setDependencySets(ImmutableList.of(new DependencySet().addExclude("org.acme:jar2")));

    Set<Artifact> artifacts = ImmutableSet.of(getFirstArtifact(), getSecondArtifact());

    File output = new File(out, "test-exclusion.jar");
    PackageConfig config = new PackageConfig()
        .setMojo(mojo)
        .setOutput(output)
        .setArtifacts(artifacts)
        .setArchive(archive);
    service.doPackage(config);

    assertThat(output).isFile();
    JarFile jar = new JarFile(output);
    List<String> list = jar.stream().map(ZipEntry::getName)
        .filter(s -> ! s.endsWith("/")) // Directories
        .collect(Collectors.toList());
    assertThat(list).contains("META-INF/MANIFEST.MF", "testconfig.yaml").hasSize(2);
}
 
Example #8
Source File: SpringSwaggerExtensionTest.java    From swagger-maven-plugin with Apache License 2.0 5 votes vote down vote up
@Test
public void testExtractParametersNoModelAttributeAnnotation() {
    List<Parameter> parameters = new SpringSwaggerExtension(new SystemStreamLog()).extractParameters(
            Lists.newArrayList(),
            PaginationHelper.class,
            Sets.<Type>newHashSet(),
            Lists.<SwaggerExtension>newArrayList().iterator());

    assertEquals(parameters.size(), 2);
}
 
Example #9
Source File: CodeGeneratorMojo.java    From vaadinator with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
	// only for local development (in Project root of gen)
	CodeGeneratorMojo mojo = new CodeGeneratorMojo();
	mojo.processJavaFiles(new File("../../VaadinatorExample/AddressbookExample/src/main/java"),
			new File("../../VaadinatorExample/AddressbookExample/target/generated-sources"), new SourceDao(new SystemStreamLog()),
			"AddressbookExample", "AddressbookExample", "0.10-SNAPSHOT", true, VaadinatorConfig.ArtifactType.ALL,
			VaadinatorConfig.GenType.ALL);
}
 
Example #10
Source File: URILastModifiedResolverTest.java    From maven-jaxb2-plugin with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Test
public void getsFileURIFromJarFileURICorrectly() throws URISyntaxException,
		MalformedURLException, IOException {
	final URI jarURI = Test.class.getResource("Test.class").toURI();
	final String jarURIString = jarURI.toString();
	System.out.println(jarURIString);
	final String partJarURIString = jarURIString.substring(0,
			jarURIString.indexOf(JarURILastModifiedResolver.SEPARATOR));
	final URI partJarURI = new URI(partJarURIString);
	final URILastModifiedResolver resolver = new CompositeURILastModifiedResolver(
			new SystemStreamLog());
	final URI fileURI = getClass().getResource(
			getClass().getSimpleName() + ".class").toURI();

	Assert.assertNotNull(resolver.getLastModified(jarURI));
	Assert.assertNotNull(resolver.getLastModified(partJarURI));
	Assert.assertNotNull(resolver.getLastModified(fileURI));

	// Switch to true to tests HTTP/HTTPs
	boolean online = false;
	if (online) {
		final URI httpsURI = new URI("https://ya.ru/");
		final URI httpURI = new URI("http://schemas.opengis.net/ogc_schema_updates.rss");
		Assert.assertNotNull(resolver.getLastModified(httpsURI));
		Assert.assertNotNull(resolver.getLastModified(httpURI));
	}
}
 
Example #11
Source File: ClassDefScannerTest.java    From nexus-public with Eclipse Public License 1.0 5 votes vote down vote up
@Before
public void setUp() throws Exception {
  Log log = new SystemStreamLog()
  {
    @Override
    public boolean isDebugEnabled() {
      return true;
    }
  };
  this.scanner = new ClassDefScanner(log);
}
 
Example #12
Source File: ExecMojoTest.java    From exec-maven-plugin with Apache License 2.0 5 votes vote down vote up
private void setUpProject( File pomFile, ExecMojo mojo )
    throws Exception
{
    super.setUp();
    
    MockitoAnnotations.initMocks( this );
    
    ProjectBuildingRequest buildingRequest = mock( ProjectBuildingRequest.class );
    when( session.getProjectBuildingRequest() ).thenReturn( buildingRequest );
    MavenRepositorySystemSession repositorySession = new MavenRepositorySystemSession();
    repositorySession.setLocalRepositoryManager( new SimpleLocalRepositoryManager( LOCAL_REPO ) );
    when( buildingRequest.getRepositorySession() ).thenReturn( repositorySession );
    
    ProjectBuilder builder = lookup( ProjectBuilder.class );

    mojo.setBasedir( File.createTempFile( "mvn-temp", "txt" ).getParentFile() );

    MavenProject project = builder.build( pomFile, buildingRequest ).getProject();

    // this gets the classes for these tests of this mojo (exec plugin) onto the project classpath for the test
    project.getBuild().setOutputDirectory( new File( "target/test-classes" ).getAbsolutePath() );

    mojo.setProject( project );

    mojo.setLog( new SystemStreamLog()
    {
        public boolean isDebugEnabled()
        {
            return true;
        }
    } );
}
 
Example #13
Source File: NodeManagerTest.java    From wisdom with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() {
    nodeDirectory = new File("target/test/node");
    nodeDirectory.mkdirs();
    log = new SystemStreamLog();
    AbstractWisdomMojo mojo = new AbstractWisdomMojo() {
        @Override
        public void execute() throws MojoExecutionException, MojoFailureException {
            // Do nothing.
        }
    };
    mojo.basedir = new File("target/test");
    manager = new NodeManager(log, nodeDirectory, mojo);
}
 
Example #14
Source File: CoffeeScriptCompilerMojoTest.java    From wisdom with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() throws IOException {
    nodeDirectory = new File("target/test/node");
    nodeDirectory.mkdirs();
    Log log = new SystemStreamLog();
    mojo = new CoffeeScriptCompilerMojo();
    NodeManager manager = new NodeManager(log, nodeDirectory, mojo);
    manager.installIfNotInstalled();
    mojo.basedir = new File(FAKE_PROJECT);
    mojo.buildDirectory = new File(FAKE_PROJECT_TARGET);
    mojo.buildDirectory.mkdirs();
    mojo.coffeeScriptVersion = CoffeeScriptCompilerMojo.COFFEESCRIPT_VERSION;
    cleanup();
}
 
Example #15
Source File: CSSMinifierMojoTest.java    From wisdom with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() throws IOException {
    MavenProject project = new MavenProject();
    project.setArtifactId("test-artifact");

    nodeDirectory = new File("target/test/node");
    nodeDirectory.mkdirs();
    Log log = new SystemStreamLog();
    mojo = new CSSMinifierMojo();
    mojo.project = project;
    NodeManager manager = new NodeManager(log, nodeDirectory, mojo);
    manager.installIfNotInstalled();
    mojo.basedir = new File(FAKE_PROJECT);
    mojo.buildDirectory = new File(FAKE_PROJECT_TARGET);
    mojo.buildDirectory.mkdirs();
    mojo.cleanCssVersion = CSSMinifierMojo.CLEANCSS_NPM_VERSION;
    mojo.cssMinifierSuffix = "-min";

    // Less stuff
    less = new LessCompilerMojo();
    NodeManager manager2 = new NodeManager(log, nodeDirectory, less);
    manager2.installIfNotInstalled();
    less.project = project;
    less.basedir = new File(FAKE_PROJECT);
    less.buildDirectory = new File(FAKE_PROJECT_TARGET);
    less.lessVersion = LessCompilerMojo.LESS_VERSION;

    cleanup();
}
 
Example #16
Source File: IssueITest.java    From web3j-maven-plugin with Apache License 2.0 5 votes vote down vote up
@Test
public void issue09() throws MojoExecutionException {
    SolidityCompiler solidityCompiler = SolidityCompiler.getInstance(new SystemStreamLog());
    Set<String> sources = Collections.singleton("issue-09.sol");

    CompilerResult compilerResult = solidityCompiler.compileSrc("src/test/resources/", sources, new String[0], SolidityCompiler.Options.ABI, SolidityCompiler.Options.BIN);

    assertFalse(compilerResult.isFailed());
}
 
Example #17
Source File: TypeScriptCompilerMojoTest.java    From wisdom with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() throws IOException {
    nodeDirectory = new File("target/test/node");
    nodeDirectory.mkdirs();
    Log log = new SystemStreamLog();
    mojo = new TypeScriptCompilerMojo();
    mojo.basedir = new File(FAKE_PROJECT);
    mojo.buildDirectory = new File(FAKE_PROJECT_TARGET);
    mojo.buildDirectory.mkdirs();

    mojo.typescript = new TypeScript();

    NodeManager manager = new NodeManager(log, nodeDirectory, mojo);
    manager.installIfNotInstalled();
}
 
Example #18
Source File: LessCompilerMojoTest.java    From wisdom with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() throws IOException {
    nodeDirectory = new File("target/test/node");
    nodeDirectory.mkdirs();
    Log log = new SystemStreamLog();
    mojo = new LessCompilerMojo();
    NodeManager manager = new NodeManager(log, nodeDirectory, mojo);
    manager.installIfNotInstalled();
    mojo.basedir = new File(FAKE_PROJECT);
    mojo.buildDirectory = new File(FAKE_PROJECT_TARGET);
    mojo.buildDirectory.mkdirs();
    mojo.lessVersion = LessCompilerMojo.LESS_VERSION;
    cleanup();
}
 
Example #19
Source File: ShrinkWrapFatJarPackageServiceTest.java    From vertx-maven-plugin with Apache License 2.0 5 votes vote down vote up
@Test
public void testAddingFileUsingFileItem() throws IOException, PackagingException {
    AbstractVertxMojo mojo = mock(AbstractVertxMojo.class);
    MavenProject project = mock(MavenProject.class);
    when(mojo.getLog()).thenReturn(new SystemStreamLog());
    when(project.getBasedir()).thenReturn(new File("."));
    when(mojo.getProject()).thenReturn(project);

    Archive archive = new Archive();
    archive.setIncludeClasses(false);
    archive.setDependencySets(Collections.emptyList());
    archive.addFile(new FileItem()
        .setOutputDirectory("config")
        .setSource("src/test/resources/testconfig.yaml")
        .setDestName("some-config.yaml"));


    File output = new File(out, "test-file-item.jar");
    PackageConfig config = new PackageConfig()
        .setProject(project)
        .setMojo(mojo)
        .setOutput(output)
        .setArtifacts(Collections.emptySet())
        .setArchive(archive);
    service.doPackage(config);

    assertThat(output).isFile();
    JarFile jar = new JarFile(output);
    List<String> list = jar.stream().map(ZipEntry::getName)
        .filter(s -> ! s.endsWith("/")) // Directories
        .collect(Collectors.toList());
    assertThat(list).contains("META-INF/MANIFEST.MF", "config/some-config.yaml").hasSize(2);
}
 
Example #20
Source File: ShrinkWrapFatJarPackageServiceTest.java    From vertx-maven-plugin with Apache License 2.0 5 votes vote down vote up
@Test
public void testAddingFileUsingFileSetsAndExclusion() throws IOException, PackagingException {
    AbstractVertxMojo mojo = mock(AbstractVertxMojo.class);
    MavenProject project = mock(MavenProject.class);
    when(mojo.getLog()).thenReturn(new SystemStreamLog());
    when(project.getBasedir()).thenReturn(new File("."));
    when(mojo.getProject()).thenReturn(project);

    Archive archive = new Archive();
    archive.setIncludeClasses(false);
    archive.setDependencySets(Collections.emptyList());
    archive.addFileSet(new FileSet()
        .setOutputDirectory("config")
        .addInclude("*.yaml")
        .addExclude("*2.yaml")
        .setDirectory("src/test/resources"));


    File output = new File(out, "test-fileset-with-exclusion.jar");
    PackageConfig config = new PackageConfig()
        .setProject(project)
        .setMojo(mojo)
        .setOutput(output)
        .setArtifacts(Collections.emptySet())
        .setArchive(archive);
    service.doPackage(config);

    assertThat(output).isFile();
    JarFile jar = new JarFile(output);
    List<String> list = jar.stream().map(ZipEntry::getName)
        .filter(s -> ! s.endsWith("/")) // Directories
        .collect(Collectors.toList());
    assertThat(list).contains("META-INF/MANIFEST.MF", "config/testconfig.yaml").hasSize(2);
}
 
Example #21
Source File: ShrinkWrapFatJarPackageServiceTest.java    From vertx-maven-plugin with Apache License 2.0 5 votes vote down vote up
@Test
public void testAddingFileUsingFileSets() throws IOException, PackagingException {
    AbstractVertxMojo mojo = mock(AbstractVertxMojo.class);
    MavenProject project = mock(MavenProject.class);
    when(mojo.getLog()).thenReturn(new SystemStreamLog());
    when(project.getBasedir()).thenReturn(new File("."));
    when(mojo.getProject()).thenReturn(project);

    Archive archive = new Archive();
    archive.setIncludeClasses(false);
    archive.setDependencySets(Collections.emptyList());
    archive.addFileSet(new FileSet()
        .setOutputDirectory("config")
        .addInclude("*.yaml")
        .setDirectory("src/test/resources"));


    File output = new File(out, "test-filesets.jar");
    PackageConfig config = new PackageConfig()
        .setProject(project)
        .setMojo(mojo)
        .setOutput(output)
        .setArtifacts(Collections.emptySet())
        .setArchive(archive);
    service.doPackage(config);

    assertThat(output).isFile();
    JarFile jar = new JarFile(output);
    List<String> list = jar.stream().map(ZipEntry::getName)
        .filter(s -> ! s.endsWith("/")) // Directories
        .collect(Collectors.toList());
    assertThat(list).contains("META-INF/MANIFEST.MF", "config/testconfig.yaml", "config/testconfig2.yaml").hasSize(3);
}
 
Example #22
Source File: ShrinkWrapFatJarPackageServiceTest.java    From vertx-maven-plugin with Apache License 2.0 5 votes vote down vote up
@Test
public void testEmbeddingDependenciesWithAMissingArtifactFile() throws IOException, PackagingException {
    AbstractVertxMojo mojo = mock(AbstractVertxMojo.class);
    when(mojo.getLog()).thenReturn(new SystemStreamLog());

    Archive archive = new Archive();
    archive.setIncludeClasses(false);
    archive.setDependencySets(ImmutableList.of(new DependencySet()));

    DefaultArtifact artifact = getSecondArtifact();
    artifact.setFile(new File("missing-on-purpose"));
    Set<Artifact> artifacts = ImmutableSet.of(getFirstArtifact(), artifact);

    File output = new File(out, "test-all-dependencies-missing-artifact-file.jar");
    PackageConfig config = new PackageConfig()
        .setMojo(mojo)
        .setOutput(output)
        .setArtifacts(artifacts)
        .setArchive(archive);
    service.doPackage(config);

    assertThat(output).isFile();
    JarFile jar = new JarFile(output);
    List<String> list = jar.stream().map(ZipEntry::getName)
        .filter(s -> ! s.endsWith("/")) // Directories
        .collect(Collectors.toList());
    assertThat(list).containsOnly("META-INF/MANIFEST.MF", "testconfig.yaml");
}
 
Example #23
Source File: SpringSwaggerExtensionTest.java    From swagger-maven-plugin with Apache License 2.0 5 votes vote down vote up
@Test
public void testExtractParametersReturnsRetrievedParameters() {
    List<Parameter> parameters = new SpringSwaggerExtension(new SystemStreamLog()).extractParameters(
            Lists.newArrayList(getTestAnnotation()),
            PaginationHelper.class,
            Sets.<Type>newHashSet(),
            Lists.<SwaggerExtension>newArrayList().iterator());

    assertEquals(parameters.size(), 2);
}
 
Example #24
Source File: TomEEEmbeddedMojoTest.java    From tomee with Apache License 2.0 4 votes vote down vote up
@Test
public void customScript() throws Exception {
    Assume.assumeFalse(System.getProperty("java.version").startsWith("1.7"));

    // we use a dynamic InputStream to be able to simulate commands without hacking System.in
    final Input input = new Input();
    final Semaphore reloaded = new Semaphore(0);
    final CountDownLatch started = new CountDownLatch(1);
    final TomEEEmbeddedMojo mojo = new TomEEEmbeddedMojo() {
        @Override
        protected Scanner newScanner() {
            return new Scanner(input);
        }
    };
    mojo.classpathAsWar = true;
    mojo.httpPort = NetworkUtil.getNextAvailablePort();
    mojo.ssl = false;
    mojo.webResourceCached = false;
    mojo.jsCustomizers = singletonList(
            "var File = Java.type('java.io.File');" +
                    "var FileWriter = Java.type('java.io.FileWriter');" +
                    "var out = new File(catalinaBase, 'conf/app.conf');" +
                    "var writer = new FileWriter(out);" +
                    "writer.write('test=ok');" +
                    "writer.close();");
    mojo.setLog(new SystemStreamLog() { // not the best solution but fine for now...
        @Override
        public void info(final CharSequence charSequence) {
            final String string = charSequence.toString();
            if (string.startsWith("TomEE embedded started on") || string.equals("can't start TomEE")) {
                started.countDown();
            } else if (string.contains("Redeployed /")) {
                reloaded.release();
            }
            super.info(charSequence);
        }
    });

    CountDownLatch stopped = null;
    try {
        stopped = doStart(started, mojo);
        final File appConf = new File(System.getProperty("catalina.base"), "conf/app.conf");
        assertTrue(appConf.exists());
        assertEquals("ok", IO.readProperties(appConf).getProperty("test", "ko"));
    } finally {
        input.write("exit");
        if (stopped != null) {
            stopped.await(5, TimeUnit.MINUTES);
        }
        input.close();
    }
}
 
Example #25
Source File: TomEEEmbeddedMojoTest.java    From tomee with Apache License 2.0 4 votes vote down vote up
@Test
public void customWebResource() throws Exception {
    final File docBase = new File("target/TomEEEmbeddedMojoTest/customWebResource");
    docBase.mkdirs();
    try (final FileWriter w = new FileWriter(new File(docBase, "index.html"))) {
        w.write("resource");
    }

    // we use a dynamic InputStream to be able to simulate commands without hacking System.in
    final Input input = new Input();
    final Semaphore reloaded = new Semaphore(0);
    final CountDownLatch started = new CountDownLatch(1);
    final TomEEEmbeddedMojo mojo = new TomEEEmbeddedMojo() {
        @Override
        protected Scanner newScanner() {
            return new Scanner(input);
        }
    };
    mojo.classpathAsWar = true;
    mojo.httpPort = NetworkUtil.getNextAvailablePort();
    mojo.ssl = false;
    mojo.webResources = singletonList(docBase);
    mojo.webResourceCached = false;
    mojo.setLog(new SystemStreamLog() { // not the best solution but fine for now...
        @Override
        public void info(final CharSequence charSequence) {
            final String string = charSequence.toString();
            if (string.startsWith("TomEE embedded started on") || string.equals("can't start TomEE")) {
                started.countDown();
            } else if (string.contains("Redeployed /")) {
                reloaded.release();
            }
            super.info(charSequence);
        }
    });

    final CountDownLatch stopped = doStart(started, mojo);
    assertEquals("resource", IO.slurp(new URL("http://localhost:" + mojo.httpPort + "/")).trim());

    input.write("exit");
    stopped.await(5, TimeUnit.MINUTES);
    input.close();
}
 
Example #26
Source File: SpringMVCResponseStatusTest.java    From swagger-maven-plugin with Apache License 2.0 4 votes vote down vote up
@BeforeMethod
public void setUp() {
    reader = new SpringMvcApiReader(new Swagger(), new SystemStreamLog());
}
 
Example #27
Source File: Main.java    From cougar with Apache License 2.0 4 votes vote down vote up
/**
 * @param args
 */
public static void main(String[] args) throws Exception {

	Transformations transform = new CougarTransformations();
	IDLReader reader = new IDLReader();
	Log log = new SystemStreamLog();

	File idd = new File("src\\main\\resources\\BaselineService.xml");
	InterceptingResolver resolver = new InterceptingResolver();

	Document iddDoc = XmlUtil.parse(idd, resolver);

	File ext = new File("src\\main\\resources\\BaselineService-Extensions.xml");
	Document extDoc = null;
	if (ext.exists()) {
		extDoc = XmlUtil.parse(ext, resolver);
	}

	reader.init(iddDoc, extDoc, "BaselineService",
					"com.betfair.baseline", ".", "/target/generated-sources", log,
					new Service().getOutputDir(), true, true);

       // First let's mangle the document if need be.
       if (transform.getManglers() != null) {
       	log.debug("mangling IDL using "+transform.getManglers().size()+" pre validations");
       	for(DocumentMangler m : transform.getManglers()) {
       		log.debug(m.getName());
          	 	reader.mangle(m);
           }
   		log.debug(reader.serialize());
       }

	for (Validator v: transform.getPreValidations()) {
		reader.validate(v);
	}
	log.debug(reader.serialize());
	reader.runMerge(transform.getTransformations());

	reader.writeResult();

}
 
Example #28
Source File: InterceptingResolver.java    From cougar with Apache License 2.0 4 votes vote down vote up
public InterceptingResolver() {
	this(new SystemStreamLog(), null, new String[0]);
}
 
Example #29
Source File: JarResourcesGeneratorTest.java    From webstart with MIT License 4 votes vote down vote up
public void testGetDependenciesText()
        throws Exception
    {

        MavenProject mavenProject = new MavenProject();
        File resourceLoaderPath = new File( System.getProperty( "java.io.tmpdir" ) );
        File outputFile = File.createTempFile( "bogus", "jnlp" );
        outputFile.deleteOnExit();

        File templateFile = File.createTempFile( "bogusTemplate", ".vm" );
        templateFile.deleteOnExit();

        List<ResolvedJarResource> jarResources = new ArrayList<>();
        String mainClass = "fully.qualified.ClassName";

        GeneratorTechnicalConfig generatorTechnicalConfig =
            new GeneratorTechnicalConfig( mavenProject, resourceLoaderPath, "default-jnlp-template.vm",
                                          outputFile, templateFile.getName(), mainClass,
                                          "jar:file:/tmp/path/to/webstart-plugin.jar", "utf-8" );
        JarResourceGeneratorConfig jarResourceGeneratorConfig = new JarResourceGeneratorConfig( jarResources, null, null, null, null );
        JarResourcesGenerator generator  =
            new JarResourcesGenerator( new SystemStreamLog(), generatorTechnicalConfig, jarResourceGeneratorConfig );

//        JarResourcesGenerator generator =
//            new JarResourcesGenerator( new SystemStreamLog(), mavenProject, resourceLoaderPath,
//                                       "default-jnlp-template.vm", outputFile, templateFile.getName(), jarResources,
//                                       mainClass, "jar:file:/tmp/path/to/webstart-plugin.jar", null, "utf-8" );

        //The list of jarResources is empty so the output text should be an empty string
        assertEquals( "", generator.getDependenciesText() );

        //Add some JarResources and confirm the correct output
        ResolvedJarResource jarResource1 = buildJarResource( "href1", "1.1", "bogus.Class", true, true );
        ResolvedJarResource jarResource2 = buildJarResource( "href2", "1.2", null, true, true );
        ResolvedJarResource jarResource3 = buildJarResource( "href3", "1.3", null, false, true );
        ResolvedJarResource jarResource4 = buildJarResource( "href4", "1.4", null, false, false );

        jarResources.add( jarResource1 );
        jarResources.add( jarResource2 );
        jarResources.add( jarResource3 );
        jarResources.add( jarResource4 );

        String expectedText =EOL + "<jar href=\"href1\" version=\"1.1\" main=\"true\"/>" + 
        		EOL + "<jar href=\"href2\" version=\"1.2\"/>" +
        		EOL + "<jar href=\"href3\"/>" + EOL;

        String actualText = generator.getDependenciesText();

        Assert.assertEquals( expectedText, actualText );

        JarResourceGeneratorConfig jarResourceGeneratorConfig2 = new JarResourceGeneratorConfig( jarResources, "myLib", null, null, null );
        JarResourcesGenerator generator2  =
            new JarResourcesGenerator( new SystemStreamLog(), generatorTechnicalConfig, jarResourceGeneratorConfig2 );

//        JarResourcesGenerator generator2 =
//            new JarResourcesGenerator( new SystemStreamLog(), mavenProject, resourceLoaderPath,
//                                       "default-jnlp-template.vm", outputFile, templateFile.getName(), jarResources,
//                                       mainClass, "jar:file:/tmp/path/to/webstart-plugin.jar", "myLib", "utf-8" );

        String expectedText2 = EOL + "<jar href=\"myLib/href1\" version=\"1.1\" main=\"true\"/>" +
        		EOL + "<jar href=\"myLib/href2\" version=\"1.2\"/>" + 
        		EOL + "<jar href=\"myLib/href3\"/>" + EOL;

        String actualText2 = generator2.getDependenciesText();

        Assert.assertEquals( expectedText2, actualText2 );

    }
 
Example #30
Source File: MappingTrackArchiverTest.java    From docker-maven-plugin with Apache License 2.0 4 votes vote down vote up
@Before
public void setup() throws IllegalAccessException {
    archiver = new MappingTrackArchiver();
    archiver.init(new AnsiLogger(new SystemStreamLog(),false,"build"), "maven");
}