@Test
  public void testPrepareBuildProduct() throws Exception {
    File basedir = TestUtil.getBasedir("unitTestResources");
    File productFile = new File(basedir, "test.product");
    ProductConfiguration productConfiguration = ProductConfiguration.read(productFile);
    BuildOutputDirectory buildBasedir = new BuildOutputDirectory(new File(tempDir, "buildBasedir"));
    Product buildProduct =
        PublishProductMojo.prepareBuildProduct(
            productFile, productConfiguration, buildBasedir, "buildQualifier");

    Assert.assertEquals(
        buildBasedir.getChild("products/testproduct/p2.inf"), buildProduct.getP2infFile());
    Assert.assertTrue(buildBasedir.getChild("products/testproduct/p2.inf").exists());

    File buildProductRootDir = buildBasedir.getChild("products/testproduct");
    assertFileExists("icons/linux.xpm", buildProductRootDir);
    assertFileExists("icons/mac.ico", buildProductRootDir);
    assertFileExists("icons/solaris.ico", buildProductRootDir);
    assertFileExists("icons/win.ico", buildProductRootDir);
    assertFileExists("configs/config_linux.ini", buildProductRootDir);
    assertFileExists("configs/config_macosx.ini", buildProductRootDir);
    assertFileExists("configs/config_win32.ini", buildProductRootDir);
    assertFileExists("configs/config_solaris.ini", buildProductRootDir);
    ProductConfiguration buildProductConfiguration =
        ProductConfiguration.read(buildProduct.getProductFile());
    Assert.assertEquals("0.1.0.buildQualifier", buildProductConfiguration.getVersion());
  }
  @Test
  public void testQualifyVersionsEmptyVersions() throws IOException {
    File basedir = TestUtil.getBasedir("unitTestResources");
    File productFile = new File(basedir, "emptyVersion.product");
    ProductConfiguration product = ProductConfiguration.read(productFile);
    PublishProductMojo.qualifyVersions(product, "20100623");

    Assert.assertEquals("", product.getVersion());
  }
예제 #3
0
  @Test
  public void testExpandVersionInCapabilities() throws Exception {
    subject = new IUXmlTransformer();
    IU iu = IU.read(new File(TestUtil.getBasedir("projects/iuXmlValueReplacement/"), "p2iu.xml"));

    subject.replaceQualifierInCapabilities(iu.getProvidedCapabilites(), "CAPABILITY");
    assertThat(iu.getProvidedCapabilites(), hasItem(capability("anotherId", "2.0.0.CAPABILITY")));
    assertThat(iu.getProvidedCapabilites(), hasItem(capability("demo.iu", "1.0.0.CAPABILITY")));
    assertThat(iu.getProvidedCapabilites(), hasItem(capability("demo.iu", "1.1.1.CAPABILITY")));
  }
예제 #4
0
  @Test
  public void testExpandVersion() throws Exception {
    subject = new IUXmlTransformer();
    IU iu = IU.read(new File(TestUtil.getBasedir("projects/iuXmlValueReplacement/"), "p2iu.xml"));

    subject.replaceSelfQualifiers(iu, "1.0.0.ABC", "ABC");
    assertEquals(iu.getVersion(), "1.0.0.ABC");
    assertThat(iu.getProvidedCapabilites(), hasItem(capability("demo.iu", "1.0.0.ABC")));
    assertThat(iu.getArtifacts(), hasItem(artifact("demo.iu", "1.0.0.ABC")));
  }
  @Test
  public void testQualifyVersions() throws IOException {
    File basedir = TestUtil.getBasedir("unitTestResources");
    File productFile = new File(basedir, "test.product");
    ProductConfiguration product = ProductConfiguration.read(productFile);
    PublishProductMojo.qualifyVersions(product, "20100623");

    Assert.assertEquals("0.1.0.20100623", product.getVersion());
    Assert.assertEquals("0.1.0.20100623", product.getFeatures().get(0).getVersion());
    Assert.assertEquals("0.1.0.qual", product.getFeatures().get(1).getVersion());
    Assert.assertEquals("0.1.0.20100623", product.getPlugins().get(0).getVersion());
    Assert.assertEquals("0.1.0.qual", product.getPlugins().get(1).getVersion());
  }
  @Test
  public void testPrepareBuildProductEmptyQualifier() throws Exception {
    File basedir = TestUtil.getBasedir("unitTestResources");
    File productFile = new File(basedir, "test.product");
    ProductConfiguration productConfiguration = ProductConfiguration.read(productFile);
    BuildOutputDirectory buildBasedir = new BuildOutputDirectory(new File(tempDir, "buildBasedir"));
    Product buildProduct =
        PublishProductMojo.prepareBuildProduct(productFile, productConfiguration, buildBasedir, "");

    Assert.assertEquals(
        buildBasedir.getChild("products/testproduct/p2.inf"), buildProduct.getP2infFile());
    Assert.assertTrue(buildBasedir.getChild("products/testproduct/p2.inf").exists());

    ProductConfiguration buildProductConfiguration =
        ProductConfiguration.read(buildProduct.getProductFile());
    Assert.assertEquals("0.1.0", buildProductConfiguration.getVersion());
  }
예제 #7
0
  @Test
  public void testExpandReferences() throws Exception {
    subject = new IUXmlTransformer();
    IU iu = IU.read(new File(TestUtil.getBasedir("projects/iuXmlValueReplacement/"), "p2iu.xml"));

    TargetPlatform tp = mock(TargetPlatform.class);
    when(tp.resolveArtifact("p2-installable-unit", "org.junit4", "0.0.0")).thenReturn(junit4InTP);
    when(tp.resolveArtifact("p2-installable-unit", "org.hamcrest.core", "1.1.0.qualifier"))
        .thenReturn(hamcrestInTP);

    subject.replaceZerosInRequirements(iu, tp);
    subject.replaceQualifierInRequirements(iu, tp);

    assertThat(iu.getRequiredCapabilites(), hasItem(requirement("org.junit4", "4.8.1.v20100302")));
    assertThat(
        iu.getRequiredCapabilites(),
        hasItem(requirement("org.hamcrest.core", "1.1.0.v20090501071000")));
  }