|
32 | 32 | import org.apache.maven.artifact.repository.ArtifactRepository;
|
33 | 33 | import org.apache.maven.execution.MavenSession;
|
34 | 34 | import org.apache.maven.plugin.MojoExecutionException;
|
| 35 | +import org.apache.maven.plugin.MojoFailureException; |
35 | 36 | import org.apache.maven.plugin.testing.AbstractMojoTestCase;
|
36 | 37 | import org.apache.maven.plugin.testing.stubs.MavenProjectStub;
|
37 | 38 | import org.apache.maven.plugins.deploy.stubs.ArtifactDeployerStub;
|
@@ -551,7 +552,141 @@ public void _testBasicDeployWithScpAsProtocol()
|
551 | 552 |
|
552 | 553 | FileUtils.deleteDirectory( sshFile );
|
553 | 554 | }
|
554 |
| - |
| 555 | + |
| 556 | + public void testLegacyAltDeploymentRepositoryWithDefaultLayout() |
| 557 | + throws Exception |
| 558 | + { |
| 559 | + DeployMojo mojo = spy( new DeployMojo() ); |
| 560 | + |
| 561 | + ArtifactRepository repository = mock( ArtifactRepository.class ); |
| 562 | + when( mojo.createDeploymentArtifactRepository( "altDeploymentRepository", "http://localhost" |
| 563 | + ) ).thenReturn( repository ); |
| 564 | + |
| 565 | + project.setVersion( "1.0-SNAPSHOT" ); |
| 566 | + |
| 567 | + ProjectDeployerRequest pdr = |
| 568 | + new ProjectDeployerRequest() |
| 569 | + .setProject( project ) |
| 570 | + .setAltDeploymentRepository( "altDeploymentRepository::default::http://localhost" ); |
| 571 | + try |
| 572 | + { |
| 573 | + mojo.getDeploymentRepository( pdr ); |
| 574 | + fail( "Should throw: Invalid legacy syntax for repository." ); |
| 575 | + } |
| 576 | + catch( MojoFailureException e ) |
| 577 | + { |
| 578 | + assertEquals( e.getMessage(), "Invalid legacy syntax for repository."); |
| 579 | + assertEquals( e.getLongMessage(), "Invalid legacy syntax for alternative repository. Use \"altDeploymentRepository::http://localhost\" instead."); |
| 580 | + } |
| 581 | + } |
| 582 | + |
| 583 | + public void testLegacyAltDeploymentRepositoryWithLegacyLayout() |
| 584 | + throws Exception |
| 585 | + { |
| 586 | + DeployMojo mojo = spy( new DeployMojo() ); |
| 587 | + |
| 588 | + ArtifactRepository repository = mock( ArtifactRepository.class ); |
| 589 | + when( mojo.createDeploymentArtifactRepository( "altDeploymentRepository", "http://localhost" |
| 590 | + ) ).thenReturn( repository ); |
| 591 | + |
| 592 | + project.setVersion( "1.0-SNAPSHOT" ); |
| 593 | + |
| 594 | + ProjectDeployerRequest pdr = |
| 595 | + new ProjectDeployerRequest() |
| 596 | + .setProject( project ) |
| 597 | + .setAltDeploymentRepository( "altDeploymentRepository::legacy::http://localhost" ); |
| 598 | + try |
| 599 | + { |
| 600 | + mojo.getDeploymentRepository( pdr ); |
| 601 | + fail( "Should throw: Invalid legacy syntax and layout for repository." ); |
| 602 | + } |
| 603 | + catch( MojoFailureException e ) |
| 604 | + { |
| 605 | + assertEquals( e.getMessage(), "Invalid legacy syntax and layout for repository."); |
| 606 | + assertEquals( e.getLongMessage(), "Invalid legacy syntax and layout for alternative repository. Use \"altDeploymentRepository::http://localhost\" instead, and only default layout is supported."); |
| 607 | + } |
| 608 | + } |
| 609 | + |
| 610 | + public void testInsaneAltDeploymentRepository() |
| 611 | + throws Exception |
| 612 | + { |
| 613 | + DeployMojo mojo = spy( new DeployMojo() ); |
| 614 | + |
| 615 | + ArtifactRepository repository = mock( ArtifactRepository.class ); |
| 616 | + when( mojo.createDeploymentArtifactRepository( "altDeploymentRepository", "http://localhost" |
| 617 | + ) ).thenReturn( repository ); |
| 618 | + |
| 619 | + project.setVersion( "1.0-SNAPSHOT" ); |
| 620 | + |
| 621 | + ProjectDeployerRequest pdr = |
| 622 | + new ProjectDeployerRequest() |
| 623 | + .setProject( project ) |
| 624 | + .setAltDeploymentRepository( "altDeploymentRepository::hey::wow::foo::http://localhost" ); |
| 625 | + try |
| 626 | + { |
| 627 | + mojo.getDeploymentRepository( pdr ); |
| 628 | + fail( "Should throw: Invalid legacy syntax and layout for repository." ); |
| 629 | + } |
| 630 | + catch( MojoFailureException e ) |
| 631 | + { |
| 632 | + assertEquals( e.getMessage(), "Invalid legacy syntax and layout for repository."); |
| 633 | + assertEquals( e.getLongMessage(), "Invalid legacy syntax and layout for alternative repository. Use \"altDeploymentRepository::wow::foo::http://localhost\" instead, and only default layout is supported."); |
| 634 | + } |
| 635 | + } |
| 636 | + |
| 637 | + public void testDefaultScmSvnAltDeploymentRepository() |
| 638 | + throws Exception |
| 639 | + { |
| 640 | + DeployMojo mojo = spy( new DeployMojo() ); |
| 641 | + |
| 642 | + ArtifactRepository repository = mock( ArtifactRepository.class ); |
| 643 | + when( mojo.createDeploymentArtifactRepository( "altDeploymentRepository", "http://localhost" |
| 644 | + ) ).thenReturn( repository ); |
| 645 | + |
| 646 | + project.setVersion( "1.0-SNAPSHOT" ); |
| 647 | + |
| 648 | + ProjectDeployerRequest pdr = |
| 649 | + new ProjectDeployerRequest() |
| 650 | + .setProject( project ) |
| 651 | + .setAltDeploymentRepository( "altDeploymentRepository::default::scm:svn:http://localhost" ); |
| 652 | + try |
| 653 | + { |
| 654 | + mojo.getDeploymentRepository( pdr ); |
| 655 | + fail( "Should throw: Invalid legacy syntax for repository." ); |
| 656 | + } |
| 657 | + catch( MojoFailureException e ) |
| 658 | + { |
| 659 | + assertEquals( e.getMessage(), "Invalid legacy syntax for repository."); |
| 660 | + assertEquals( e.getLongMessage(), "Invalid legacy syntax for alternative repository. Use \"altDeploymentRepository::scm:svn:http://localhost\" instead."); |
| 661 | + } |
| 662 | + } |
| 663 | + public void testLegacyScmSvnAltDeploymentRepository() |
| 664 | + throws Exception |
| 665 | + { |
| 666 | + DeployMojo mojo = spy( new DeployMojo() ); |
| 667 | + |
| 668 | + ArtifactRepository repository = mock( ArtifactRepository.class ); |
| 669 | + when( mojo.createDeploymentArtifactRepository( "altDeploymentRepository", "http://localhost" |
| 670 | + ) ).thenReturn( repository ); |
| 671 | + |
| 672 | + project.setVersion( "1.0-SNAPSHOT" ); |
| 673 | + |
| 674 | + ProjectDeployerRequest pdr = |
| 675 | + new ProjectDeployerRequest() |
| 676 | + .setProject( project ) |
| 677 | + .setAltDeploymentRepository( "altDeploymentRepository::legacy::scm:svn:http://localhost" ); |
| 678 | + try |
| 679 | + { |
| 680 | + mojo.getDeploymentRepository( pdr ); |
| 681 | + fail( "Should throw: Invalid legacy syntax and layout for repository." ); |
| 682 | + } |
| 683 | + catch( MojoFailureException e ) |
| 684 | + { |
| 685 | + assertEquals( e.getMessage(), "Invalid legacy syntax and layout for repository."); |
| 686 | + assertEquals( e.getLongMessage(), "Invalid legacy syntax and layout for alternative repository. Use \"altDeploymentRepository::scm:svn:http://localhost\" instead, and only default layout is supported."); |
| 687 | + } |
| 688 | + } |
| 689 | + |
555 | 690 | public void testAltSnapshotDeploymentRepository()
|
556 | 691 | throws Exception
|
557 | 692 | {
|
|
0 commit comments