} else if (artifact instanceof XsdDocument) { XsdDocument xsdDocument = (XsdDocument) artifact; String[] key = new String[] { xsdDocument.getTargetNamespace(), xsdDocument.getName() }; xsdDocumentIndex.put(key, xsdDocument); } else if (artifact instanceof WsdlDocument) {
/** * Unmarshall an xml fragment. */ @Test public void unmarshall() { try { JAXBContext jaxbContext=JAXBContext.newInstance("org.oasis_open.docs.s_ramp.ns.s_ramp_v1"); Unmarshaller unMarshaller = jaxbContext.createUnmarshaller(); Assert.assertNotNull("Cannot locate file XsdDocument-entry.xml", this.getClass().getResourceAsStream("XsdDocument-entry.xml")); String expectedXML = new Scanner(this.getClass().getResourceAsStream("XsdDocument-entry.xml")).useDelimiter("\\Z").next(); StringReader reader = new StringReader(expectedXML); JAXBElement<Artifact> element = unMarshaller.unmarshal(new StreamSource(reader),Artifact.class); Artifact artifact = element.getValue(); Assert.assertEquals("accountingTypes.xsd", artifact.getXsdDocument().getName()); } catch (JAXBException jaxbe) { jaxbe.printStackTrace(); fail("No exception should be thrown"); } }
/** * Unmarshall an xml fragment. */ @Test public void unmarshall2() { try { JAXBContext jaxbContext=JAXBContext.newInstance("org.oasis_open.docs.s_ramp.ns.s_ramp_v1"); Unmarshaller unMarshaller = jaxbContext.createUnmarshaller(); Assert.assertNotNull("Cannot locate file XsdDocument-entry2.xml", this.getClass().getResourceAsStream("XsdDocument-entry2.xml")); String expectedXML = new Scanner(this.getClass().getResourceAsStream("XsdDocument-entry2.xml")).useDelimiter("\\Z").next(); StringReader reader = new StringReader(expectedXML); JAXBElement<Artifact> element = unMarshaller.unmarshal(new StreamSource(reader),Artifact.class); Artifact artifact = element.getValue(); Assert.assertEquals("accountingTypes.xsd", artifact.getXsdDocument().getName()); } catch (JAXBException jaxbe) { jaxbe.printStackTrace(); fail("No exception should be thrown"); } }
Assert.assertEquals("PO.xsd", xsdDoc.getName()); //$NON-NLS-1$ Assert.assertEquals("1.1", xsdDoc.getVersion()); //$NON-NLS-1$
Assert.assertEquals("PO.xsd", xsdDoc.getName()); //$NON-NLS-1$ Assert.assertEquals("1.1", xsdDoc.getVersion()); //$NON-NLS-1$
Assert.assertEquals("sample.xsd", sampleXsdMetaData.getName()); //$NON-NLS-1$ Assert.assertEquals("1.0.3", sampleXsdMetaData.getVersion()); //$NON-NLS-1$ Assert.assertEquals("Just a sample XML Schema.", sampleXsdMetaData.getDescription()); //$NON-NLS-1$ Assert.assertEquals("PO.xsd", poXsdMetaData.getName()); //$NON-NLS-1$ Assert.assertEquals("2.1.4", poXsdMetaData.getVersion()); //$NON-NLS-1$ Assert.assertEquals("The Purchase Order schema.", poXsdMetaData.getDescription()); //$NON-NLS-1$ Assert.assertEquals("coremodel.xsd", coremodelXsdMetaData.getName()); //$NON-NLS-1$ Assert.assertEquals("1.6.1", coremodelXsdMetaData.getVersion()); //$NON-NLS-1$ Assert.assertEquals("S-RAMP core schema.", coremodelXsdMetaData.getDescription()); //$NON-NLS-1$ Assert.assertEquals("xlink.xsd", xlinkXsdMetaData.getName()); //$NON-NLS-1$ Assert.assertEquals("1.6.1", xlinkXsdMetaData.getVersion()); //$NON-NLS-1$ Assert.assertEquals("X-LINK schema.", xlinkXsdMetaData.getDescription()); //$NON-NLS-1$
/** * Test method for {@link org.overlord.sramp.atom.archive.jar.ZipToSrampArchive.jar.JarToSrampArchive#createSrampArchive()}. */ @Test public void testMetaData() throws Exception { InputStream resourceAsStream = ZipToSrampArchiveTest.class.getResourceAsStream("sample-webservice-0.0.1.jar"); //$NON-NLS-1$ ZipToSrampArchive j2sramp = null; SrampArchive archive = null; try { j2sramp = new ZipToSrampArchive(resourceAsStream){}; archive = j2sramp.createSrampArchive(); Assert.assertNotNull(archive); SrampArchiveEntry entry = archive.getEntry("schema/teetime.xsd"); //$NON-NLS-1$ Assert.assertNotNull(entry); BaseArtifactType metaData = entry.getMetaData(); Assert.assertNotNull(metaData); Assert.assertTrue(metaData instanceof XsdDocument); XsdDocument md = (XsdDocument) metaData; Assert.assertEquals("teetime.xsd", md.getName()); //$NON-NLS-1$ Assert.assertNotNull(md.getUuid()); } finally { ZipToSrampArchive.closeQuietly(j2sramp); SrampArchive.closeQuietly(archive); } }
Assert.assertEquals("jcr-sample-externalrefs.xsd", xsd.getName()); //$NON-NLS-1$ Assert.assertEquals("urn:s-ramp:test:jcr-sample-externalrefs:types", xsd.getTargetNamespace()); //$NON-NLS-1$