@@ -14,34 +14,30 @@ public class TestDBRefParsing {
1414
1515 @ Test
1616 public void testShortLine () throws IOException , StructureException {
17- String shortLine = "DBREF 2W6E A -42 510 UNP P19483 ATPA1_BOVIN 1 553" ;
18- InputStream is = new ByteArrayInputStream (shortLine .getBytes ());
17+ Structure s ,ref ;
1918 PDBFileParser pdbPars = new PDBFileParser ();
20- Structure s ;
21- try {
19+
20+ String shortLine = "DBREF 2W6E A -42 510 UNP P19483 ATPA1_BOVIN 1 553" ;
21+ // Parse short
22+ try (InputStream is = new ByteArrayInputStream (shortLine .getBytes ())) {
2223 s = pdbPars .parsePDBFile (is );
23- } catch (Exception e ) {
24- is .close ();
25- throw new AssertionError ("Unable to process truncated DBRef line" );
2624 }
27- is = new ByteArrayInputStream (String .format ("%1$-80s" , shortLine )
28- .getBytes ());
29- Structure ref = pdbPars .parsePDBFile (is );
30- is .close ();
25+ // Parse padded
26+ String longline = String .format ("%1$-80s" , shortLine );
27+ try (InputStream is = new ByteArrayInputStream (longline .getBytes ()) ){
28+ ref = pdbPars .parsePDBFile (is );
29+ }
3130 assertEquals (ref .getDBRefs ().get (0 ), s .getDBRefs ().get (0 ));
3231 }
3332
3433 @ Test
3534 public void testToPdbLength () throws IOException {
35+ Structure s ;
3636 String shortLine = "DBREF 2W6E A -42 510 UNP P19483 ATPA1_BOVIN 1 553" ;
37- InputStream is = new ByteArrayInputStream (shortLine .getBytes ());
3837 PDBFileParser pdbPars = new PDBFileParser ();
39- Structure s ;
40- try {
38+ // Parse short
39+ try ( InputStream is = new ByteArrayInputStream ( shortLine . getBytes ()) ) {
4140 s = pdbPars .parsePDBFile (is );
42- } catch (Exception e ) {
43- is .close ();
44- throw new AssertionError ("Unable to process truncated DBRef line" );
4541 }
4642 //Make sure that the record is true to the input
4743 assertEquals (shortLine , s .getDBRefs ().get (0 ).toPDB ().trim ());
0 commit comments