SraWriter { public static void writeStudy(final Study study, final Writer writer) throws IOException { checkNotNull(study); checkNotNull(writer); try { JAXBContext context = JAXBContext.newInstance(Study.class); Marshaller marshaller = context.createMarshaller(); SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); URL commonSchemaURL = SraReader.class.getResource("/org/nmdp/ngs/sra/xsd/SRA.common.xsd"); URL studySchemaURL = SraReader.class.getResource("/org/nmdp/ngs/sra/xsd/SRA.study.xsd"); Schema schema = schemaFactory.newSchema(new StreamSource[] { new StreamSource(commonSchemaURL.toString()), new StreamSource(studySchemaURL.toString()) }); marshaller.setSchema(schema); marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); marshaller.marshal(study, writer); } catch (JAXBException | SAXException e) { throw new IOException("could not marshal Study", e); } } private  SraWriter(); static void writeAnalysis(final Analysis analysis, final Writer writer); static void writeAnalysis(final Analysis analysis, final File file); static void writeAnalysis(final Analysis analysis, final OutputStream outputStream); static void writeExperiment(final Experiment experiment, final Writer writer); static void writeExperiment(final Experiment experiment, final File file); static void writeExperiment(final Experiment experiment, final OutputStream outputStream); static void writeRunSet(final RunSet runSet, final Writer writer); static void writeRunSet(final RunSet runSet, final File file); static void writeRunSet(final RunSet runSet, final OutputStream outputStream); static void writeSample(final Sample sample, final Writer writer); static void writeSample(final Sample sample, final File file); static void writeSample(final Sample sample, final OutputStream outputStream); static void writeStudy(final Study study, final Writer writer); static void writeStudy(final Study study, final File file); static void writeStudy(final Study study, final OutputStream outputStream); static void writeSubmission(final Submission submission, final Writer writer); static void writeSubmission(final Submission submission, final File file); static void writeSubmission(final Submission submission, final OutputStream outputStream);  }
@Test(expected=NullPointerException.class) public void testWriteStudyNullWriter() throws Exception { writeStudy(study, (Writer) null); }
@Test(expected=NullPointerException.class) public void testWriteStudyNullFile() throws Exception { writeStudy(study, (File) null); }
@Test(expected=NullPointerException.class) public void testWriteStudyNullOutputStream() throws Exception { writeStudy(study, (OutputStream) null); }
@Test public void testWriteStudyWriter() throws Exception { try (BufferedWriter writer = new BufferedWriter(new FileWriter(createFile()))) { writeStudy(study, writer); } }
@Test public void testWriteStudyFile() throws Exception { writeStudy(study, createFile()); }
@Test public void testWriteStudyOutputStream() throws Exception { try (OutputStream outputStream = createOutputStream()) { writeStudy(study, outputStream); } }