Nuspec implements Serializable { public static Nuspec parse(InputStream inputStream) throws NugetFormatException { try { JAXBContext context = JAXBContext.newInstance(Nuspec.class); Unmarshaller unmarshaller = context.createUnmarshaller(); unmarshaller.setEventHandler(new NuspecXmlValidationEventHandler()); XMLReader reader = XMLReaderFactory.createXMLReader(); NugetNamespaceFilter inFilter = new NugetNamespaceFilter(); inFilter.setParent(reader); InputSource inputSource = new InputSource(inputStream); SAXSource saxSource = new SAXSource(inFilter, inputSource); Nuspec result = (Nuspec) unmarshaller.unmarshal(saxSource); return result; } catch (JAXBException | SAXException e) { throw new NugetFormatException("Can not read nuspec from XML stream", e); } }  static Nuspec parse(InputStream inputStream); Metadata getMetadata(); List<NugetFile> getFiles(); String getId(); SemanticVersion getVersion(); String getTitle(); String getAuthors(); String getOwners(); boolean isRequireLicenseAcceptance(); String getDescription(); String getLicenseUrl(); String getProjectUrl(); String getProjectSourceUrl(); String getPackageSourceUrl(); String getDocsUrl(); String getMailingListUrl(); String getBugTrackerUrl(); String getIconUrl(); String getReleaseNotes(); void setReleaseNotes(String releaseNotes); String getSummary(); String getCopyright(); String getLanguage(); List<String> getTags(); List<Reference> getReferences(); List<Dependency> getDependencies(); List<DependenciesGroup> getDependenciesGroups(); List<FrameworkAssembly> getFrameworkAssembly(); void setFrameworkAssembly(List<FrameworkAssembly> frameworkAssembly); void saveTo(OutputStream outputStream); static final String NUSPEC_XML_NAMESPACE_2012; static final String NUSPEC_XML_NAMESPACE_2013; static final String NUSPEC_XML_NAMESPACE_2016; static final String NUSPEC_XML_NAMESPACE_2013_01; static final String NUSPEC_XML_NAMESPACE_2011; static final String NUSPEC_XML_NAMESPACE_2010; static final String NUSPEC_XML_NAMESPACE_2017; static final String NUSPEC_XML_NAMESPACE_EMPTY; static final String DEFAULT_FILE_EXTENSION; }
@Test public void testCreateWithIncorrectVersion() throws Exception { InputStream inputStream = NugetTestResourceUtil.getAsStream("nuspec/incorrect.version.nuspec.xml"); assertThatExceptionOfType(NugetFormatException.class) .isThrownBy(() -> Nuspec.parse(inputStream)); }
@Test public void testParseNewNamespace() throws NugetFormatException { InputStream inputStream = NugetTestResourceUtil.getAsStream("nuspec/Spring.Data.nuspec.xml"); Nuspec result = Nuspec.parse(inputStream); assertThat(result).isNotNull(); }
@Test public void testParsePackageWithFiles() throws NugetFormatException { InputStream inputStream = NugetTestResourceUtil.getAsStream("nuspec/v3/Package.with.files.nuspec.xml"); Nuspec result = Nuspec.parse(inputStream); assertThat(result).isNotNull(); }
@Test public void testEmptyStringAssemblyFrameworks() throws NugetFormatException { InputStream inputStream = NugetTestResourceUtil.getAsStream("nuspec/DockPanelSuite.nuspec.xml"); Nuspec nuspecFile = Nuspec.parse(inputStream); assertThat(nuspecFile).isNotNull(); }
@Test public void testNamespace2013() throws NugetFormatException { InputStream inputStream = NugetTestResourceUtil.getAsStream("nuspec/NLog.nuspec.2.0.1.xml"); Nuspec nuspecFile = Nuspec.parse(inputStream); assertThat(nuspecFile).isNotNull(); }
@Test public void testReadNuspecV3() throws NugetFormatException { InputStream inputStream = NugetTestResourceUtil.getAsStream("nuspec/v3/Package.v3.nuspec.xml"); Nuspec nuspecFile = Nuspec.parse(inputStream); assertThat(nuspecFile).isNotNull(); }