Пример #1
0
 @Before
 public void setUp() {
   pomFilterContainerMock = createPomFilterContainerMock();
   artifactPomContainerMock = context.mock(ArtifactPomContainer.class);
   pomMock = context.mock(MavenPom.class);
   mavenSettingsMock = context.mock(Settings.class);
   loggingManagerMock = context.mock(LoggingManagerInternal.class);
 }
Пример #2
0
 @Test
 public void setFilter() {
   final PublishFilter publishFilterMock = context.mock(PublishFilter.class);
   context.checking(
       new Expectations() {
         {
           one(pomFilterContainerMock).setFilter(publishFilterMock);
         }
       });
   getMavenResolver().setFilter(publishFilterMock);
 }
Пример #3
0
 @Test
 public void addFilter() {
   final String testName = "somename";
   final PublishFilter publishFilterMock = context.mock(PublishFilter.class);
   context.checking(
       new Expectations() {
         {
           one(pomFilterContainerMock).addFilter(testName, publishFilterMock);
         }
       });
   getMavenResolver().addFilter(testName, publishFilterMock);
 }
Пример #4
0
 @Test
 public void getFilter() {
   final PublishFilter publishFilterMock = context.mock(PublishFilter.class);
   context.checking(
       new Expectations() {
         {
           allowing(pomFilterContainerMock).getFilter();
           will(returnValue(publishFilterMock));
         }
       });
   assertSame(publishFilterMock, getMavenResolver().getFilter());
 }
Пример #5
0
 @Test
 public void filter() {
   final String testName = "somename";
   final PublishFilter publishFilterMock = context.mock(PublishFilter.class);
   context.checking(
       new Expectations() {
         {
           one(pomFilterContainerMock).filter(testName);
           will(returnValue(publishFilterMock));
         }
       });
   assertSame(publishFilterMock, getMavenResolver().filter(testName));
 }
Пример #6
0
 protected void checkTransaction(
     final Set<DefaultMavenDeployment> defaultMavenDeployments,
     final AttachedArtifact attachedArtifact,
     PublishArtifact classifierArtifact)
     throws IOException, PlexusContainerException {
   context.checking(
       new Expectations() {
         {
           one(getInstallDeployTask()).setProject(with(any(Project.class)));
           for (DefaultMavenDeployment defaultMavenDeployment : defaultMavenDeployments) {
             one(getInstallDeployTask())
                 .setFile(defaultMavenDeployment.getMainArtifact().getFile());
             one(getInstallDeployTask())
                 .addPom(
                     with(
                         pomMatcher(
                             defaultMavenDeployment.getPomArtifact().getFile(),
                             getInstallDeployTask().getProject())));
             one(loggingManagerMock).captureStandardOutput(LogLevel.INFO);
             will(returnValue(loggingManagerMock));
             one(loggingManagerMock).start();
             one(getInstallDeployTask()).execute();
             one(loggingManagerMock).stop();
             will(returnValue(loggingManagerMock));
           }
           one(getMavenResolver().mavenSettingsSupplier).supply(getInstallDeployTask());
           one(getMavenResolver().mavenSettingsSupplier).done();
         }
       });
   getMavenResolver().commitPublishTransaction();
   assertThat(attachedArtifact.getFile(), equalTo(classifierArtifact.getFile()));
   assertThat(attachedArtifact.getType(), equalTo(classifierArtifact.getType()));
   assertThat(attachedArtifact.getClassifier(), equalTo(classifierArtifact.getClassifier()));
 }
Пример #7
0
  @Test
  public void deployOrInstall() throws IOException, PlexusContainerException {
    getMavenResolver().mavenSettingsSupplier = context.mock(MavenSettingsSupplier.class);

    PublishArtifact classifierArtifact = artifact(new File("classifier.jar"));
    final DefaultMavenDeployment deployment1 =
        new DefaultMavenDeployment(
            artifact(new File("pom1.pom")),
            artifact(new File("artifact1.jar")),
            Collections.<PublishArtifact>emptySet());
    final DefaultMavenDeployment deployment2 =
        new DefaultMavenDeployment(
            artifact(new File("pom2.pom")),
            artifact(new File("artifact2.jar")),
            WrapUtil.toSet(classifierArtifact));
    final Set<DefaultMavenDeployment> testDefaultMavenDeployments =
        WrapUtil.toSet(deployment1, deployment2);
    final AttachedArtifact attachedArtifact = new AttachedArtifact();
    @SuppressWarnings("unchecked")
    final Action<MavenDeployment> action = context.mock(Action.class);

    context.checking(
        new Expectations() {
          {
            allowing((CustomInstallDeployTaskSupport) getInstallDeployTask())
                .clearAttachedArtifactsList();
            allowing((CustomInstallDeployTaskSupport) getInstallDeployTask()).getSettings();
            will(returnValue(mavenSettingsMock));
            allowing((CustomInstallDeployTaskSupport) getInstallDeployTask()).getProject();
            will(returnValue(AntUtil.createProject()));
            allowing((CustomInstallDeployTaskSupport) getInstallDeployTask()).createAttach();
            will(returnValue(attachedArtifact));
            one(artifactPomContainerMock).addArtifact(TEST_ARTIFACT, TEST_JAR_FILE);
            allowing(artifactPomContainerMock).createDeployableFilesInfos();
            will(returnValue(testDefaultMavenDeployments));
            one(action).execute(deployment1);
            one(action).execute(deployment2);
          }
        });

    getMavenResolver().beforeDeployment(action);
    getMavenResolver().publish(TEST_IVY_ARTIFACT, TEST_IVY_FILE, true);
    getMavenResolver().publish(TEST_ARTIFACT, TEST_JAR_FILE, true);
    checkTransaction(testDefaultMavenDeployments, attachedArtifact, classifierArtifact);
    assertSame(mavenSettingsMock, getMavenResolver().getSettings());
  }
Пример #8
0
 @Test
 public void setPom() {
   context.checking(
       new Expectations() {
         {
           one(pomFilterContainerMock).setPom(pomMock);
         }
       });
   getMavenResolver().setPom(pomMock);
 }
Пример #9
0
 @Test
 public void getPom() {
   context.checking(
       new Expectations() {
         {
           allowing(pomFilterContainerMock).getPom();
           will(returnValue(pomMock));
         }
       });
   assertSame(pomMock, getMavenResolver().getPom());
 }
Пример #10
0
 @Test
 public void pom() {
   final String testName = "somename";
   context.checking(
       new Expectations() {
         {
           one(pomFilterContainerMock).pom(testName);
           will(returnValue(pomMock));
         }
       });
   assertSame(pomMock, getMavenResolver().pom(testName));
 }