47
47
@ EnabledForRepository (SCCS )
48
48
class SCCSgetTest {
49
49
50
- private File sccs_file ;
51
- private File sccs_dir ;
50
+ private File sccsFile ;
51
+ private File sccsDir ;
52
52
53
53
@ BeforeEach
54
54
public void setUp () throws IOException {
55
- try {
56
- sccs_dir = File .createTempFile ("s.test" , "sccs" );
57
- assertTrue (sccs_dir .delete ());
58
- assertTrue (sccs_dir .mkdirs (), "Failed to set up the test-directory" );
59
- sccs_file = new File (sccs_dir , "s.note.txt" );
60
- try (InputStream in = getClass ().getResourceAsStream ("/history/s.note.txt" );
61
- FileOutputStream out = new FileOutputStream (sccs_file )) {
62
-
63
- byte [] buffer = new byte [8192 ];
64
- int nr ;
65
-
66
- while ((nr = in .read (buffer , 0 , buffer .length )) != -1 ) {
67
- out .write (buffer , 0 , nr );
68
- }
69
- out .flush ();
55
+ sccsDir = File .createTempFile ("s.test" , "sccs" );
56
+ assertTrue (sccsDir .delete ());
57
+ assertTrue (sccsDir .mkdirs (), "Failed to set up the test-directory" );
58
+ sccsFile = new File (sccsDir , "s.note.txt" );
59
+ try (InputStream in = getClass ().getResourceAsStream ("/history/s.note.txt" );
60
+ FileOutputStream out = new FileOutputStream (sccsFile )) {
61
+
62
+ byte [] buffer = new byte [8192 ];
63
+ int nr ;
64
+
65
+ while ((nr = in .read (buffer , 0 , buffer .length )) != -1 ) {
66
+ out .write (buffer , 0 , nr );
70
67
}
71
- } catch (IOException ex ) {
72
- if (sccs_file != null ) {
73
- sccs_file .delete ();
74
- sccs_dir .delete ();
75
- }
76
- throw ex ;
68
+ out .flush ();
77
69
}
78
70
}
79
71
80
72
@ AfterEach
81
73
public void tearDown () {
82
- if (sccs_file != null ) {
83
- sccs_file .delete ();
74
+ if (sccsFile != null ) {
75
+ sccsFile .delete ();
84
76
}
85
77
86
- if (sccs_dir != null ) {
87
- sccs_dir .delete ();
78
+ if (sccsDir != null ) {
79
+ sccsDir .delete ();
88
80
}
89
81
}
90
82
@@ -107,19 +99,20 @@ private String readInput(InputStream in) throws IOException {
107
99
*/
108
100
@ Test
109
101
void getRevision () throws Exception {
110
- InputStream inputStream = getClass ().getResourceAsStream ("/history/sccs-revisions.zip" );
111
- assertNotNull (inputStream );
112
- ZipInputStream zstream = new ZipInputStream (inputStream );
113
- ZipEntry entry ;
114
-
115
- while ((entry = zstream .getNextEntry ()) != null ) {
116
- String expected = readInput (zstream );
117
- InputStream sccs = SCCSget .getRevision ("sccs" , sccs_file , entry .getName ());
118
- String got = readInput (sccs );
119
- sccs .close ();
120
- zstream .closeEntry ();
121
- assertEquals (expected , got );
102
+ try (InputStream inputStream = getClass ().getResourceAsStream ("/history/sccs-revisions.zip" )) {
103
+ assertNotNull (inputStream );
104
+ ZipInputStream zstream = new ZipInputStream (inputStream );
105
+ ZipEntry entry ;
106
+
107
+ while ((entry = zstream .getNextEntry ()) != null ) {
108
+ String expected = readInput (zstream );
109
+ InputStream sccs = SCCSget .getRevision ("sccs" , sccsFile , entry .getName ());
110
+ String got = readInput (sccs );
111
+ sccs .close ();
112
+ zstream .closeEntry ();
113
+ assertEquals (expected , got );
114
+ }
115
+ zstream .close ();
122
116
}
123
- zstream .close ();
124
117
}
125
118
}
0 commit comments