Search in sources :

Example 1 with PojoConfigSource

use of org.apache.maven.plugins.assembly.testutils.PojoConfigSource in project maven-plugins by apache.

the class ReaderFormatterTest method lineDosFeed_withoutFiltering.

@Test
public void lineDosFeed_withoutFiltering() throws IOException, AssemblyFormattingException {
    final PojoConfigSource cfg = getPojoConfigSource();
    InputStreamTransformer fileSetTransformers = ReaderFormatter.getFileSetTransformers(cfg, false, "dos");
    InputStream fud = fileSetTransformers.transform(dummyResource(), payload("This is a\ntest."));
    assertEquals("This is a\r\ntest.", readResultStream(fud));
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) InputStreamTransformer(org.codehaus.plexus.components.io.functions.InputStreamTransformer) PojoConfigSource(org.apache.maven.plugins.assembly.testutils.PojoConfigSource) Test(org.junit.Test)

Example 2 with PojoConfigSource

use of org.apache.maven.plugins.assembly.testutils.PojoConfigSource in project maven-plugins by apache.

the class ReaderFormatterTest method getPojoConfigSource.

private PojoConfigSource getPojoConfigSource() {
    final PojoConfigSource cfg = new PojoConfigSource();
    cfg.setEncoding("UTF-8");
    DefaultMavenReaderFilter mavenReaderFilter = new DefaultMavenReaderFilter();
    mavenReaderFilter.enableLogging(new ConsoleLogger(2, "fud"));
    cfg.setMavenReaderFilter(mavenReaderFilter);
    cfg.setEscapeString(null);
    cfg.setMavenProject(createBasicMavenProject());
    /*        expect( configSource.getFilters()).andReturn( filters );

        expect( configSource.isIncludeProjectBuildFilters()).andReturn( includeProjectBuildFilters );

        expect( configSource.getDelimiters()).andReturn( delimiters );
*/
    return cfg;
}
Also used : DefaultMavenReaderFilter(org.apache.maven.shared.filtering.DefaultMavenReaderFilter) ConsoleLogger(org.codehaus.plexus.logging.console.ConsoleLogger) PojoConfigSource(org.apache.maven.plugins.assembly.testutils.PojoConfigSource)

Example 3 with PojoConfigSource

use of org.apache.maven.plugins.assembly.testutils.PojoConfigSource in project maven-plugins by apache.

the class AssemblyInterpolatorTest method testShouldResolveContextValueBeforeModelPropertyOrModelGroupIdInAssemblyId.

public void testShouldResolveContextValueBeforeModelPropertyOrModelGroupIdInAssemblyId() throws AssemblyInterpolationException, InvalidAssemblerConfigurationException, AssemblyReadException, IOException {
    final Model model = new Model();
    model.setArtifactId("artifact-id");
    model.setGroupId("group.id");
    model.setVersion("1");
    model.setPackaging("jar");
    final Properties props = new Properties();
    props.setProperty("groupId", "other.id");
    model.setProperties(props);
    final Assembly assembly = new Assembly();
    assembly.setId("assembly.${groupId}");
    final EasyMockSupport mm = new EasyMockSupport();
    final MavenSession session = mm.createMock(MavenSession.class);
    final Properties execProps = new Properties();
    execProps.setProperty("groupId", "still.another.id");
    expect(session.getExecutionProperties()).andReturn(execProps).anyTimes();
    expect(session.getUserProperties()).andReturn(new Properties()).anyTimes();
    final PojoConfigSource cs = new PojoConfigSource();
    final ArtifactRepository lr = mm.createMock(ArtifactRepository.class);
    cs.setLocalRepository(lr);
    cs.setMavenSession(session);
    cs.setRootInterpolator(FixedStringSearchInterpolator.create());
    cs.setEnvironmentInterpolator(FixedStringSearchInterpolator.create(new PropertiesBasedValueSource(execProps)));
    cs.setEnvInterpolator(FixedStringSearchInterpolator.empty());
    expect(lr.getBasedir()).andReturn("/path/to/local/repo").anyTimes();
    mm.replayAll();
    final MavenProject project = new MavenProject(model);
    cs.setMavenProject(project);
    final Assembly result = roundTripInterpolation(assembly, cs);
    assertEquals("assembly.still.another.id", result.getId());
    mm.verifyAll();
    mm.resetAll();
}
Also used : MavenSession(org.apache.maven.execution.MavenSession) EasyMockSupport(org.easymock.classextension.EasyMockSupport) MavenProject(org.apache.maven.project.MavenProject) Model(org.apache.maven.model.Model) ArtifactRepository(org.apache.maven.artifact.repository.ArtifactRepository) PojoConfigSource(org.apache.maven.plugins.assembly.testutils.PojoConfigSource) Properties(java.util.Properties) PropertiesBasedValueSource(org.codehaus.plexus.interpolation.fixed.PropertiesBasedValueSource) Assembly(org.apache.maven.plugins.assembly.model.Assembly)

Example 4 with PojoConfigSource

use of org.apache.maven.plugins.assembly.testutils.PojoConfigSource in project maven-plugins by apache.

the class AssemblyInterpolatorTest method testShouldNotTouchUnresolvedExpression.

public void testShouldNotTouchUnresolvedExpression() throws AssemblyInterpolationException, InvalidAssemblerConfigurationException, AssemblyReadException, IOException {
    final Model model = new Model();
    model.setArtifactId("artifact-id");
    model.setGroupId("group.id");
    model.setVersion("1");
    model.setPackaging("jar");
    final Assembly assembly = new Assembly();
    assembly.setId("assembly.${unresolved}");
    final PojoConfigSource configSourceStub = new PojoConfigSource();
    configSourceStub.setRootInterpolator(FixedStringSearchInterpolator.create());
    configSourceStub.setEnvironmentInterpolator(FixedStringSearchInterpolator.create());
    final MavenProject project = new MavenProject(model);
    configSourceStub.setMavenProject(project);
    final Assembly result = roundTripInterpolation(assembly, configSourceStub);
    assertEquals("assembly.${unresolved}", result.getId());
}
Also used : MavenProject(org.apache.maven.project.MavenProject) Model(org.apache.maven.model.Model) PojoConfigSource(org.apache.maven.plugins.assembly.testutils.PojoConfigSource) Assembly(org.apache.maven.plugins.assembly.model.Assembly)

Example 5 with PojoConfigSource

use of org.apache.maven.plugins.assembly.testutils.PojoConfigSource in project maven-plugins by apache.

the class AssemblyInterpolatorTest method testShouldInterpolateMultiDotProjectExpression.

public void testShouldInterpolateMultiDotProjectExpression() throws AssemblyInterpolationException, InvalidAssemblerConfigurationException, AssemblyReadException, IOException {
    final Build build = new Build();
    build.setFinalName("final-name");
    final Model model = new Model();
    model.setBuild(build);
    final Assembly assembly = new Assembly();
    assembly.setId("assembly.${project.build.finalName}");
    final PojoConfigSource configSourceStub = new PojoConfigSource();
    configSourceStub.setRootInterpolator(FixedStringSearchInterpolator.create());
    configSourceStub.setEnvironmentInterpolator(FixedStringSearchInterpolator.create());
    final MavenProject project = new MavenProject(model);
    configSourceStub.setMavenProject(project);
    final Assembly result = roundTripInterpolation(assembly, configSourceStub);
    assertEquals("assembly.final-name", result.getId());
}
Also used : MavenProject(org.apache.maven.project.MavenProject) Build(org.apache.maven.model.Build) Model(org.apache.maven.model.Model) PojoConfigSource(org.apache.maven.plugins.assembly.testutils.PojoConfigSource) Assembly(org.apache.maven.plugins.assembly.model.Assembly)

Aggregations

PojoConfigSource (org.apache.maven.plugins.assembly.testutils.PojoConfigSource)11 Model (org.apache.maven.model.Model)7 Assembly (org.apache.maven.plugins.assembly.model.Assembly)7 MavenProject (org.apache.maven.project.MavenProject)7 ByteArrayInputStream (java.io.ByteArrayInputStream)3 InputStream (java.io.InputStream)3 InputStreamTransformer (org.codehaus.plexus.components.io.functions.InputStreamTransformer)3 Test (org.junit.Test)3 Properties (java.util.Properties)2 DependencySet (org.apache.maven.plugins.assembly.model.DependencySet)2 ArtifactRepository (org.apache.maven.artifact.repository.ArtifactRepository)1 MavenSession (org.apache.maven.execution.MavenSession)1 Build (org.apache.maven.model.Build)1 DefaultMavenReaderFilter (org.apache.maven.shared.filtering.DefaultMavenReaderFilter)1 PropertiesBasedValueSource (org.codehaus.plexus.interpolation.fixed.PropertiesBasedValueSource)1 ConsoleLogger (org.codehaus.plexus.logging.console.ConsoleLogger)1 EasyMockSupport (org.easymock.classextension.EasyMockSupport)1