コード例 #1
0
ファイル: JCRPersistenceTest.java プロジェクト: rhauch/s-ramp
  /**
   * Tests that we can update basic s-ramp meta data.
   *
   * @throws Exception
   */
  @Test
  public void testUpdateMetaData() throws Exception {
    // First, add an artifact to the repo
    String artifactFileName = "PO.xsd";
    InputStream POXsd =
        this.getClass().getResourceAsStream("/sample-files/xsd/" + artifactFileName);
    Document document = new Document();
    document.setName(artifactFileName);
    document.setArtifactType(BaseArtifactEnum.XSD_DOCUMENT);
    BaseArtifactType artifact = persistenceManager.persistArtifact(document, POXsd);
    Assert.assertNotNull(artifact);
    log.info("persisted PO.xsd to JCR, returned artifact uuid=" + artifact.getUuid());
    Assert.assertEquals(XsdDocument.class, artifact.getClass());
    long size = ((DocumentArtifactType) artifact).getContentSize();
    Assert.assertTrue(
        size
            >= 2376L); // Not doing an equals here due to the vagaries of Windows vs *nix line
                       // endings
    Assert.assertEquals(artifactFileName, artifact.getName());

    // Now update the artifact
    artifact = persistenceManager.getArtifact(artifact.getUuid(), ArtifactType.XsdDocument());
    artifact.setName("My PO");
    artifact.setDescription("A new description of the PO.xsd artifact.");
    artifact.setVersion("2.0.13");
    persistenceManager.updateArtifact(artifact, ArtifactType.XsdDocument());

    // Now verify the meta-data was updated
    artifact = persistenceManager.getArtifact(artifact.getUuid(), ArtifactType.XsdDocument());
    Assert.assertEquals("My PO", artifact.getName());
    Assert.assertEquals("A new description of the PO.xsd artifact.", artifact.getDescription());
    Assert.assertEquals("2.0.13", artifact.getVersion());
  }