/** * @return a new artifact * @throws SrampException */ private BaseArtifactType createXsdArtifact() throws SrampException { String artifactFileName = "PO.xsd"; //$NON-NLS-1$ InputStream content = this.getClass().getResourceAsStream("/sample-files/xsd/" + artifactFileName); //$NON-NLS-1$ XsdDocument document = new XsdDocument(); document.setName(artifactFileName); document.setArtifactType(BaseArtifactEnum.XSD_DOCUMENT); BaseArtifactType artifact = persistenceManager.persistArtifact(document, content); Assert.assertNotNull(artifact); log.info("persisted PO.xsd to JCR, returned artifact uuid=" + artifact.getUuid()); //$NON-NLS-1$ return artifact; }
/** * Sets some meta data on the artifact model. * @param artifactMetaData * @param name * @param version * @param desc */ private void setMetaData(XsdDocument artifactMetaData, String name, String version, String desc) { artifactMetaData.setArtifactType(BaseArtifactEnum.XSD_DOCUMENT); artifactMetaData.setName(name); artifactMetaData.setVersion(version); artifactMetaData.setDescription(desc); }
/** * @throws RepositoryException * @throws DerivedArtifactsCreationException */ private XsdDocument addXsdDoc() throws SrampException { String artifactFileName = "PO.xsd"; //$NON-NLS-1$ InputStream contentStream = this.getClass().getResourceAsStream("/sample-files/xsd/" + artifactFileName); //$NON-NLS-1$ try { XsdDocument xsdDoc = new XsdDocument(); xsdDoc.setArtifactType(BaseArtifactEnum.XSD_DOCUMENT); xsdDoc.setName(artifactFileName); xsdDoc.setContentEncoding("application/xml"); //$NON-NLS-1$ // Persist the artifact BaseArtifactType artifact = persistenceManager.persistArtifact(xsdDoc, contentStream); Assert.assertNotNull(artifact); return (XsdDocument) artifact; } finally { IOUtils.closeQuietly(contentStream); } }
@Test public void testPersistArtifactPO_XSD() throws Exception { String artifactFileName = "PO.xsd"; //$NON-NLS-1$ InputStream POXsd = this.getClass().getResourceAsStream("/sample-files/xsd/" + artifactFileName); //$NON-NLS-1$ XsdDocument document = new XsdDocument(); 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()); //$NON-NLS-1$ //print out the derived node if (log.isDebugEnabled()) { persistenceManager.printArtifactGraph(artifact.getUuid(), ArtifactType.XsdDocument()); } 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 }
xsdDocument.setName("accountingTypes.xsd"); xsdDocument.setDescription("accountingTypes.xsd"); xsdDocument.setCreatedBy("Bellwood");
/** * Test method for {@link SrampAtomApiClient#uploadArtifact(java.lang.String, java.lang.String, java.io.InputStream, java.lang.String)}. */ @Test public void testUploadArtifactAndContent() throws Exception { String artifactFileName = "PO.xsd"; //$NON-NLS-1$ InputStream is = this.getClass().getResourceAsStream("/sample-files/xsd/" + artifactFileName); //$NON-NLS-1$ try { SrampAtomApiClient client = new SrampAtomApiClient(generateURL("/s-ramp")); //$NON-NLS-1$ XsdDocument xsdDocument = new XsdDocument(); xsdDocument.setName(artifactFileName); xsdDocument.setUuid("my-client-side-supplied-UUID"); //$NON-NLS-1$ BaseArtifactType artifact = client.uploadArtifact(xsdDocument, is); Assert.assertNotNull(artifact); Assert.assertEquals(artifactFileName, artifact.getName()); Assert.assertEquals("my-client-side-supplied-UUID", artifact.getUuid()); //$NON-NLS-1$ } finally { IOUtils.closeQuietly(is); } }
testSrcArtifact.setArtifactType(BaseArtifactEnum.XSD_DOCUMENT); testSrcArtifact.setUuid(UUID.randomUUID().toString()); testSrcArtifact.setName("ws-humantask.xsd"); //$NON-NLS-1$ testSrcArtifact.setVersion("1.0"); //$NON-NLS-1$ testSrcArtifact.setContentEncoding("UTF-8"); //$NON-NLS-1$