Commit 0b547417 authored by Hermann Zellner's avatar Hermann Zellner

Merge branch 'Sonar-report' into 'master'

Manage resource with try-with-resources

See merge request uniprot-public/unifire!16
parents 6fe144d2 b6f40cb9
......@@ -17,16 +17,15 @@
package uk.ac.ebi.uniprot.urml.core.xml.writers;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import javax.xml.bind.JAXBException;
import javax.xml.stream.XMLStreamException;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
import org.uniprot.urml.facts.FactSet;
import javax.xml.bind.JAXBException;
import javax.xml.stream.XMLStreamException;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.uniprot.urml.facts.ProteinAnnotation.builder;
......@@ -39,18 +38,18 @@ class URMLFactWriterTest {
File tempDir;
@Test
void testShouldVerifyThatFactSuperSetIsWrittenSuccessfully() throws FileNotFoundException, JAXBException, XMLStreamException {
void testShouldVerifyThatFactSuperSetIsWrittenSuccessfully() throws IOException, JAXBException, XMLStreamException {
//given
File outputFile = new File(tempDir.getAbsolutePath()+"/test.xml");
URMLFactWriter factWriter = new URMLFactWriter(new FileOutputStream(outputFile));
FactSet factSet = FactSet.builder()
.withFact(builder().withType("type1").build(), builder().withType("type2").build())
.build();
//when and then
assertDoesNotThrow(() -> factWriter.write(factSet));
try(URMLFactWriter factWriter = new URMLFactWriter(new FileOutputStream(outputFile))) {
FactSet factSet = FactSet.builder()
.withFact(builder().withType("type1").build(), builder().withType("type2").build())
.build();
//when and then
assertDoesNotThrow(() -> factWriter.write(factSet));
}
}
......
......@@ -20,7 +20,6 @@ package uk.ac.ebi.uniprot.urml.output.xml;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import org.junit.jupiter.api.Test;
import org.junit.rules.TemporaryFolder;
import org.uniprot.urml.facts.*;
import org.xmlunit.builder.DiffBuilder;
import org.xmlunit.diff.Diff;
......@@ -32,8 +31,6 @@ import static org.junit.jupiter.api.Assertions.assertFalse;
*/
public class AnnotationXMLWriterTest {
public TemporaryFolder folder= new TemporaryFolder();
private final static String ACCESSION_1 = "P12345";
private final static String ACCESSION_2 = "P12346";
private final static String ANNOTATION_1 = "Some annotation value";
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment