File tree Expand file tree Collapse file tree 2 files changed +14
-1
lines changed
main/java/fi/helsinki/cs/tmc/langs/io/zip
test/java/fi/helsinki/cs/tmc/langs/io/zip Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -97,6 +97,12 @@ public byte[] zip(Path rootDirectory) throws IOException {
97
97
throw new IllegalArgumentException ("Filesystem root zipping is not supported" );
98
98
}
99
99
100
+ if (filePolicy == null ) {
101
+ log .error ("Attepted to zip before setting the filePolicy" );
102
+ throw new IllegalStateException (
103
+ "The student file policy must be set before zipping files" );
104
+ }
105
+
100
106
ByteArrayOutputStream buffer = new ByteArrayOutputStream ();
101
107
try (ZipArchiveOutputStream zipStream = new ZipArchiveOutputStream (buffer )) {
102
108
zipRecursively (rootDirectory , zipStream , rootDirectory );
Original file line number Diff line number Diff line change @@ -89,6 +89,13 @@ public void zipperThrowsExceptionWhenZippingRoot() throws IOException {
89
89
zipper .zip (Paths .get ("/" ).toAbsolutePath ());
90
90
}
91
91
92
+ @ Test (expected = IllegalStateException .class )
93
+ public void zipperThrowsExceptionWhenZippingWithoutSettingPolicy () throws IOException {
94
+ Path existingPath = TestUtils .getPath (StudentFileAwareUnzipperTest .class ,
95
+ "tmcnosubmit_test_case" );
96
+ new StudentFileAwareZipper ().zip (existingPath );
97
+ }
98
+
92
99
@ Test
93
100
public void zipperCorrectlyZipsSingleFile () throws IOException {
94
101
@@ -108,7 +115,7 @@ public void zipperCorrectlyZipsSingleFile() throws IOException {
108
115
@ Test
109
116
public void zipperCorrectlyZipsFolderWithFilesAndSubFolders () throws IOException {
110
117
// Create empty dir that is not in git
111
- Path emptyDir = ( TEST_DIR .resolve ("dir" ) );
118
+ Path emptyDir = TEST_DIR .resolve ("dir" );
112
119
if (Files .notExists (emptyDir )) {
113
120
Files .createDirectory (emptyDir );
114
121
}
You can’t perform that action at this time.
0 commit comments