SraWriter { public static void writeExperiment(final Experiment experiment, final Writer writer) throws IOException { checkNotNull(experiment); checkNotNull(writer); try { JAXBContext context = JAXBContext.newInstance(Experiment.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 experimentSchemaURL = SraReader.class.getResource("/org/nmdp/ngs/sra/xsd/SRA.experiment.xsd"); Schema schema = schemaFactory.newSchema(new StreamSource[] { new StreamSource(commonSchemaURL.toString()), new StreamSource(experimentSchemaURL.toString()) }); marshaller.setSchema(schema); marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); marshaller.marshal(experiment, writer); } catch (JAXBException | SAXException e) { throw new IOException("could not marshal Experiment", 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 testWriteExperimentNullWriter() throws Exception { writeExperiment(experiment, (Writer) null); }
@Test(expected=NullPointerException.class) public void testWriteExperimentNullFile() throws Exception { writeExperiment(experiment, (File) null); }
@Test(expected=NullPointerException.class) public void testWriteExperimentNullOutputStream() throws Exception { writeExperiment(experiment, (OutputStream) null); }
@Test public void testWriteExperimentWriter() throws Exception { try (BufferedWriter writer = new BufferedWriter(new FileWriter(createFile()))) { writeExperiment(experiment, writer); } }
@Test public void testWriteExperimentFile() throws Exception { writeExperiment(experiment, createFile()); }
@Test public void testWriteExperimentOutputStream() throws Exception { try (OutputStream outputStream = createOutputStream()) { writeExperiment(experiment, outputStream); } }