Ejemplo n.º 1
0
  @Test
  public void testPersistArtifactPO_XML() throws Exception {
    String artifactFileName = "PO.xml";
    InputStream POXml =
        this.getClass().getResourceAsStream("/sample-files/core/" + artifactFileName);

    Document document = new Document();
    document.setName(artifactFileName);
    document.setArtifactType(BaseArtifactEnum.XML_DOCUMENT);

    BaseArtifactType artifact = persistenceManager.persistArtifact(document, POXml);

    Assert.assertNotNull(artifact);
    log.info("persisted PO.xml to JCR, returned artifact uuid=" + artifact.getUuid());

    // print out the derived node
    if (log.isDebugEnabled()) {
      persistenceManager.printArtifactGraph(artifact.getUuid(), ArtifactType.XmlDocument());
    }
    Assert.assertEquals(XmlDocument.class, artifact.getClass());
    long size = ((DocumentArtifactType) artifact).getContentSize();
    Assert.assertTrue(
        size
            >= 825L); // Not doing an equals here due to the vagaries of Windows vs *nix line
                      // endings
  }
Ejemplo n.º 2
0
 /**
  * Try to figure out what kind of artifact we're dealing with.
  *
  * @param file
  */
 private ArtifactType determineArtifactType(File file) {
   ArtifactType type = null;
   String extension = FilenameUtils.getExtension(file.getName());
   if ("wsdl".equals(extension)) { // $NON-NLS-1$
     type = ArtifactType.WsdlDocument();
   } else if ("xsd".equals(extension)) { // $NON-NLS-1$
     type = ArtifactType.XsdDocument();
   } else if ("wspolicy".equals(extension)) { // $NON-NLS-1$
     type = ArtifactType.PolicyDocument();
   } else if ("xml".equals(extension)) { // $NON-NLS-1$
     type = ArtifactType.XmlDocument();
   } else {
     type = ArtifactType.Document();
   }
   return type;
 }
Ejemplo n.º 3
0
 /**
  * Gets the artifact type from the resource.
  *
  * @param gavInfo
  * @param archiveType
  */
 private ArtifactType getArtifactType(MavenGavInfo gavInfo, String archiveType) {
   String customAT = getParamFromRepositoryUrl("artifactType"); // $NON-NLS-1$
   if (gavInfo.getType().equals("pom")) { // $NON-NLS-1$
     return ArtifactType.valueOf("MavenPom"); // $NON-NLS-1$
   } else if (isPrimaryArtifact(gavInfo) && customAT != null) {
     return ArtifactType.valueOf(customAT);
   } else if (isPrimaryArtifact(gavInfo) && archiveType != null) {
     return ArtifactType.valueOf("ext", archiveType, true); // $NON-NLS-1$
   } else if ("jar".equals(gavInfo.getType())) { // $NON-NLS-1$
     return ArtifactType.valueOf(JavaModel.TYPE_ARCHIVE);
   } else if ("xml".equals(gavInfo.getType())) { // $NON-NLS-1$
     return ArtifactType.XmlDocument();
   } else {
     return ArtifactType.valueOf(ArtifactTypeEnum.Document.name());
   }
 }
Ejemplo n.º 4
0
  @Test
  public void testPersistArtifact_ExtendedArtifactType() throws Exception {
    ExtendedArtifactType extendedArtifact = new ExtendedArtifactType();
    extendedArtifact.setArtifactType(BaseArtifactEnum.EXTENDED_ARTIFACT_TYPE);
    extendedArtifact.setExtendedType("FooArtifactType");
    extendedArtifact.setName("MyExtendedArtifact");
    extendedArtifact.setDescription("This is a simple description for testing.");

    BaseArtifactType artifact = persistenceManager.persistArtifact(extendedArtifact, null);
    Assert.assertNotNull(artifact);
    log.info("persisted extended artifact to JCR, returned artifact uuid=" + artifact.getUuid());

    // print out the derived node
    if (log.isDebugEnabled()) {
      persistenceManager.printArtifactGraph(artifact.getUuid(), ArtifactType.XmlDocument());
    }
    Assert.assertEquals(ExtendedArtifactType.class, artifact.getClass());

    String name = ((ExtendedArtifactType) artifact).getName();
    String description = ((ExtendedArtifactType) artifact).getDescription();

    Assert.assertEquals("MyExtendedArtifact", name);
    Assert.assertEquals("This is a simple description for testing.", description);
  }