public void testPrompterException()
throws Exception
{
Mock mockPrompter = new Mock( Prompter.class );
mockPrompter.expects( new InvokeOnceMatcher() ).method( "prompt" ).will(
new ThrowStub( new PrompterException( "..." ) ) );
phase.setPrompter( (Prompter) mockPrompter.proxy() );
List<MavenProject> reactorProjects = Collections.singletonList( createProject( "artifactId", "1.0" ) );
ReleaseDescriptor releaseDescriptor = new ReleaseDescriptor();
releaseDescriptor.mapReleaseVersion( "groupId:artifactId", "1.0" );
releaseDescriptor.setScmSourceUrl( "scm:svn:file://localhost/tmp/scm-repo" );
try
{
phase.execute( releaseDescriptor, new DefaultReleaseEnvironment(), reactorProjects );
fail( "Expected an exception" );
}
catch ( ReleaseExecutionException e )
{
assertEquals( "check cause", PrompterException.class, e.getCause().getClass() );
}
releaseDescriptor = new ReleaseDescriptor();
releaseDescriptor.mapReleaseVersion( "groupId:artifactId", "1.0" );
releaseDescriptor.setScmSourceUrl( "scm:svn:file://localhost/tmp/scm-repo" );
mockPrompter.reset();
mockPrompter.expects( new InvokeOnceMatcher() ).method( "prompt" ).will(
new ThrowStub( new PrompterException( "..." ) ) );
try
{
phase.simulate( releaseDescriptor, new DefaultReleaseEnvironment(), reactorProjects );