Java 类org.apache.maven.plugin.AbstractMojoExecutionException 实例源码

项目:msbuild-maven-plugin    文件:CxxTestRunnerMojoTest.java   
public final void testSkipCxxTest() throws Exception 
{
    CxxTestRunnerMojo cxxTestRunnerMojo = ( CxxTestRunnerMojo ) lookupConfiguredMojo( CxxTestRunnerMojo.MOJO_NAME, 
            "/unit/cxxtest/skip-cxxtest.pom" ) ;

    try
    {
        cxxTestRunnerMojo.execute();
    }
    catch ( AbstractMojoExecutionException ame )
    {
        fail( ame.getCause() != null ? ame.getCause().getMessage() : ame.getMessage() );
    }

    if ( !outputStream.toString().contains( CXXTEST_SKIP_MESSAGE ) ) 
    {
        fail();
    }
}
项目:msbuild-maven-plugin    文件:CxxTestRunnerMojoTest.java   
@Test
public final void testFailingCxxTest() throws Exception 
{
    CxxTestRunnerMojo cxxTestRunnerMojo = ( CxxTestRunnerMojo ) lookupConfiguredMojo( CxxTestRunnerMojo.MOJO_NAME, 
            "/unit/cxxtest/failing-test-config.pom" ) ;

    try
    {
        cxxTestRunnerMojo.execute();
    }
    catch ( MojoFailureException mfe )
    {
        return;
    }
    catch ( AbstractMojoExecutionException ame )
    {
        fail( ame.getCause() != null ? ame.getCause().getMessage() : ame.getMessage() );
    }

    fail ( "Expected CxxTest failure." );
}
项目:deadcode4j    文件:An_AbstractSlf4jMojo.java   
@Test
public void resetsMockEvenWhenExceptionOccurs() {
    Log logMock = mock(Log.class);
    AbstractSlf4jMojo objectUnderTest = new AbstractSlf4jMojo() {
        @Override
        protected void doExecute() throws MojoExecutionException, MojoFailureException {
            throw new MojoFailureException("FAIL");
        }
    };
    objectUnderTest.setLog(logMock);

    try {
        objectUnderTest.execute();
    } catch (AbstractMojoExecutionException ignored) {
    }
    LoggerFactory.getLogger(getClass()).info("Hello JUnit!");

    verifyZeroInteractions(logMock);
}
项目:fsm-packagetype    文件:ModuleXmlParser.java   
private FileWriter setupTargetFile() throws AbstractMojoExecutionException, IOException {
  if (!target.exists()) {
    target.getParentFile().mkdirs();

    final boolean fileCreated;
    fileCreated = target.createNewFile();
    if (!fileCreated) {
      throw new MojoFailureException("Could not create target file '"
          + target.getAbsolutePath() + "'!");
    }
  }
  return new FileWriter(target);
}
项目:msbuild-maven-plugin    文件:CxxTestRunnerMojoTest.java   
@Test
public final void testPassingCxxTest() throws Exception 
{
    CxxTestRunnerMojo cxxTestRunnerMojo = ( CxxTestRunnerMojo ) lookupConfiguredMojo( CxxTestRunnerMojo.MOJO_NAME, 
            "/unit/cxxtest/passing-test-config.pom" ) ;

    try
    {
        cxxTestRunnerMojo.execute();
    }
    catch ( AbstractMojoExecutionException ame )
    {
        fail( ame.getCause() != null ? ame.getCause().getMessage() : ame.getMessage() );
    }
}
项目:oceano    文件:DefaultExceptionHandler.java   
private String getMessage( String message, Throwable exception )
{
    String fullMessage = ( message != null ) ? message : "";

    for ( Throwable t = exception; t != null; t = t.getCause() )
    {
        String exceptionMessage = t.getMessage();

        if ( t instanceof AbstractMojoExecutionException )
        {
            String longMessage = ( (AbstractMojoExecutionException) t ).getLongMessage();
            if ( StringUtils.isNotEmpty( longMessage ) )
            {
                if ( StringUtils.isEmpty( exceptionMessage ) || longMessage.contains( exceptionMessage ) )
                {
                    exceptionMessage = longMessage;
                }
                else if ( !exceptionMessage.contains( longMessage ) )
                {
                    exceptionMessage = join( exceptionMessage, '\n' + longMessage );
                }
            }
        }

        if ( StringUtils.isEmpty( exceptionMessage ) )
        {
            exceptionMessage = t.getClass().getSimpleName();
        }

        if ( t instanceof UnknownHostException && !fullMessage.contains( "host" ) )
        {
            fullMessage = join( fullMessage, "Unknown host " + exceptionMessage );
        }
        else if ( !fullMessage.contains( exceptionMessage ) )
        {
            fullMessage = join( fullMessage, exceptionMessage );
        }
    }

    return fullMessage.trim();
}