Exemplo n.º 1
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()));
 }
Exemplo n.º 2
0
 @Test
 public void setPom() {
   context.checking(
       new Expectations() {
         {
           one(pomFilterContainerMock).setPom(pomMock);
         }
       });
   getMavenResolver().setPom(pomMock);
 }
Exemplo n.º 3
0
 @Test
 public void getPom() {
   context.checking(
       new Expectations() {
         {
           allowing(pomFilterContainerMock).getPom();
           will(returnValue(pomMock));
         }
       });
   assertSame(pomMock, getMavenResolver().getPom());
 }
Exemplo n.º 4
0
 @Test
 public void setFilter() {
   final PublishFilter publishFilterMock = context.mock(PublishFilter.class);
   context.checking(
       new Expectations() {
         {
           one(pomFilterContainerMock).setFilter(publishFilterMock);
         }
       });
   getMavenResolver().setFilter(publishFilterMock);
 }
Exemplo n.º 5
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));
 }
Exemplo n.º 6
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);
 }
Exemplo n.º 7
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());
 }
Exemplo n.º 8
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));
 }
Exemplo n.º 9
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());
  }