org.apache.maven.plugin.testing.stubs.MavenProjectStub Java Examples

The following examples show how to use org.apache.maven.plugin.testing.stubs.MavenProjectStub. 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: CompileMojoTest.java    From eo with MIT License 6 votes vote down vote up
/**
 * Main can print a simple text.
 * @throws Exception If some problem inside
 */
public void testSimpleCompilation() throws Exception {
    final CompileMojo mojo = new CompileMojo();
    this.temp.create();
    final File src = this.temp.newFolder();
    this.setVariableValueToObject(mojo, "sourceDirectory", src);
    new LengthOf(
        new TeeInput(
            new InputOf(
                "type Pixel:\n  Pixel moveTo(Integer x, Integer y)"
            ),
            new OutputTo(new File(src, "main.eo"))
        )
    ).value();
    final File target = this.temp.newFolder();
    this.setVariableValueToObject(mojo, "targetDirectory", target);
    this.setVariableValueToObject(mojo, "project", new MavenProjectStub());
    mojo.execute();
    MatcherAssert.assertThat(
        new File(target, "Pixel.java").exists(),
        Matchers.is(true)
    );
}
 
Example #2
Source File: DslPlatformMojoIntegrationTest.java    From dsl-compiler-client with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Test
public void testGenerateCode() throws Exception {
	File pom = getTestFile("src/test/resources/properties-pom.xml");
	assertNotNull(pom);
	assertTrue(pom.exists());

	DslPlatformMojo mojo = (DslPlatformMojo) lookupMojo(DslPlatformMojo.GOAL, pom);
	assertNotNull(mojo);
	mojo.setProject(new MavenProjectStub());
	mojo.execute();

	File tempPath = TempPath.getTempProjectPath(mojo.getContext());
	String sourcesPath = tempPath.getAbsolutePath() + "/JAVA_POJO";
	TestUtils.assertDir(sourcesPath);
	TestUtils.assertDir(sourcesPath + "/DslPlatformMojoTestModule");
	TestUtils.assertFile(sourcesPath + "/DslPlatformMojoTestModule/Guards.java");
	TestUtils.assertFile(sourcesPath + "/DslPlatformMojoTestModule/DslPlatformMojoTestAggregate.java");
}
 
Example #3
Source File: GenerateCodeMojoIntegrationTest.java    From dsl-compiler-client with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Test
public void testGenerateCode() throws Exception {
	File pom = getTestFile("src/test/resources/generate-code-pom.xml");
	assertNotNull(pom);
	assertTrue(pom.exists());

	GenerateCodeMojo mojo = (GenerateCodeMojo) lookupMojo(GenerateCodeMojo.GOAL, pom);
	assertNotNull(mojo);
	mojo.setProject(new MavenProjectStub());
	mojo.execute();

	String sourcesPath = mojo.getGeneratedSources();
	TestUtils.assertDir(sourcesPath);
	TestUtils.assertDir(sourcesPath + "/MojoTestModule");
	TestUtils.assertFile(sourcesPath + "/MojoTestModule/Guards.java");
	TestUtils.assertFile(sourcesPath + "/MojoTestModule/MojoTestAggregate.java");

	String[] settings = mojo.getOptions();
	assertEquals(null, settings);
}
 
Example #4
Source File: PublisherTest.java    From apimanager-swagger-promote with Apache License 2.0 5 votes vote down vote up
@Before
public void setup() {
    sut = new Publisher();
    MockitoAnnotations.initMocks(this);
    AxwayPublishingAdapter.cleanInstance();
    when(sut.getLog()).thenReturn(log);
    when(sut.getPublicationReader()).thenReturn(publicationReader);
    when(sut.getAxwayPublishingAdapter()).thenReturn(axwayPublishingAdapter);
    when(sut.getStageConfigurationFile()).thenReturn("");
    when(sut.getProject()).thenReturn(new MavenProjectStub());
}
 
Example #5
Source File: SqlExecMojoTest.java    From sql-maven-plugin with Apache License 2.0 5 votes vote down vote up
public void setUp()
    throws Exception
{
    super.setUp();
    p = new Properties();
    p.load( getClass().getResourceAsStream( "/test.properties" ) );

    mojo = new SqlExecMojo();

    // populate parameters
    mojo.setDriver( p.getProperty( "driver" ) );
    mojo.setUsername( p.getProperty( "user" ) );
    mojo.setPassword( p.getProperty( "password" ) );
    mojo.setUrl( p.getProperty( "url" ) );
    mojo.setDriverProperties( p.getProperty( "driverProperties" ) );
    mojo.setSqlCommand( null );
    mojo.setDelimiter( SqlExecMojo.DEFAULT_DELIMITER );// This will simulate the defaultValue of @Parameter (...)
    mojo.setOnError( SqlExecMojo.ON_ERROR_ABORT );
    mojo.setDelimiterType( DelimiterType.NORMAL );
    mojo.setEscapeProcessing( true );

    MavenFileFilter filter =
        (MavenFileFilter) lookup( "org.apache.maven.shared.filtering.MavenFileFilter", "default" );
    mojo.setFileFilter( filter );

    SecDispatcher securityDispatcher =
        (SecDispatcher) lookup( "org.sonatype.plexus.components.sec.dispatcher.SecDispatcher", "default" );
    mojo.setSecurityDispatcher( securityDispatcher );

    MavenProject project = new MavenProjectStub();
    setVariableValueToObject( mojo, "project", project );
}
 
Example #6
Source File: LegStarAbstractMojoTestCase.java    From legstar-core2 with GNU Affero General Public License v3.0 5 votes vote down vote up
protected Mojo lookupAndPrepareMojo( String artifactId, File testPom )
    throws Exception
{
    Mojo mojo = lookupMojo( artifactId, testPom );
    MavenProject mavenProject = new MavenProjectStub();
    setVariableValueToObject( mojo, "project", mavenProject );

    return mojo;
}
 
Example #7
Source File: A_PackagingHandler.java    From deadcode4j with Apache License 2.0 5 votes vote down vote up
@Test
public void addsNoRepositoryIfThereAreNoCompileSourceRoots() throws MojoExecutionException {
    MavenProjectStub mavenProject = new MavenProjectStub();
    mavenProject.setCompileSourceRoots(null);

    Iterable<Repository> repositories = objectUnderTest.getAdditionalRepositoriesFor(mavenProject);

    assertThat(repositories, is(emptyIterable()));
}