Skip to content

Commit 7b24e84

Browse files
added module-info
1 parent c7b713b commit 7b24e84

21 files changed

+88
-95
lines changed

pom.xml

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@
1818
<maven.compiler.release>16</maven.compiler.release>
1919

2020
<!-- dependencies -->
21-
<cryptolib.version>2.0.0-rc1</cryptolib.version>
21+
<cryptolib.version>2.0.0-rc2</cryptolib.version>
2222
<jwt.version>3.15.0</jwt.version>
2323
<dagger.version>2.35.1</dagger.version>
2424
<guava.version>30.1.1-jre</guava.version>
2525
<slf4j.version>1.7.30</slf4j.version>
2626

2727
<!-- test dependencies -->
28-
<junit.jupiter.version>5.7.1</junit.jupiter.version>
29-
<mockito.version>3.9.0</mockito.version>
28+
<junit.jupiter.version>5.7.2</junit.jupiter.version>
29+
<mockito.version>3.10.0</mockito.version>
3030
<hamcrest.version>2.2</hamcrest.version>
3131

3232
<!-- build plugin dependencies -->
@@ -140,19 +140,12 @@
140140
<plugin>
141141
<groupId>org.apache.maven.plugins</groupId>
142142
<artifactId>maven-surefire-plugin</artifactId>
143-
<version>2.22.2</version>
143+
<version>3.0.0-M5</version>
144144
</plugin>
145145
<plugin>
146146
<groupId>org.apache.maven.plugins</groupId>
147147
<artifactId>maven-jar-plugin</artifactId>
148148
<version>3.2.0</version>
149-
<configuration>
150-
<archive>
151-
<manifestEntries>
152-
<Automatic-Module-Name>org.cryptomator.cryptofs</Automatic-Module-Name>
153-
</manifestEntries>
154-
</archive>
155-
</configuration>
156149
</plugin>
157150
<plugin>
158151
<artifactId>maven-source-plugin</artifactId>

src/main/java/module-info.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import org.cryptomator.cryptofs.CryptoFileSystemProvider;
2+
3+
import java.nio.file.spi.FileSystemProvider;
4+
5+
module org.cryptomator.cryptofs {
6+
requires transitive org.cryptomator.cryptolib;
7+
requires com.google.common;
8+
requires org.slf4j;
9+
10+
/* TODO: filename-based modules: */
11+
requires java.jwt;
12+
requires dagger;
13+
requires static javax.inject; // probably no longer needed if dagger is an automatic module (but might require --patch-module in case of split packages)
14+
15+
exports org.cryptomator.cryptofs;
16+
exports org.cryptomator.cryptofs.common;
17+
exports org.cryptomator.cryptofs.migration;
18+
exports org.cryptomator.cryptofs.migration.api;
19+
20+
provides FileSystemProvider with CryptoFileSystemProvider;
21+
}

src/main/java/org/cryptomator/cryptofs/CryptoFileSystems.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
import java.nio.file.NoSuchFileException;
1919
import java.nio.file.Path;
2020
import java.security.SecureRandom;
21-
import java.util.Arrays;
2221
import java.util.EnumSet;
2322
import java.util.Set;
2423
import java.util.concurrent.ConcurrentHashMap;

src/test/java/org/cryptomator/cryptofs/CryptoFileStoreTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public class CryptoFileStoreTest {
3838

3939
@Nested
4040
@DisplayName("with delegate present")
41-
class DelegatingCryptoFileStoreTest {
41+
public class DelegatingCryptoFileStoreTest {
4242

4343
private final FileStore delegate = mock(FileStore.class);
4444
private CryptoFileStore cryptoFileStore;
@@ -128,7 +128,7 @@ public void testGetAttribute() {
128128

129129
@Nested
130130
@DisplayName("with delegate absent")
131-
class FallbackCryptoFileStoreTest {
131+
public class FallbackCryptoFileStoreTest {
132132

133133
private CryptoFileStore cryptoFileStore;
134134

src/test/java/org/cryptomator/cryptofs/CryptoFileSystemProviderIntegrationTest.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public class CryptoFileSystemProviderIntegrationTest {
7474

7575
@Nested
7676
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
77-
class WithLimitedPaths {
77+
public class WithLimitedPaths {
7878

7979
private MasterkeyLoader keyLoader = Mockito.mock(MasterkeyLoader.class);
8080
private CryptoFileSystem fs;
@@ -170,7 +170,7 @@ public void testCopyExceedingPathLengthLimit(String path) {
170170
@Nested
171171
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
172172
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
173-
class InMemory {
173+
public class InMemory {
174174

175175
private FileSystem tmpFs;
176176
private MasterkeyLoader keyLoader1;
@@ -523,7 +523,7 @@ public void testMoveFileFromOneCryptoFileSystemToAnother() throws IOException {
523523
@EnabledOnOs({OS.MAC, OS.LINUX})
524524
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
525525
@DisplayName("On POSIX Systems")
526-
class PosixTests {
526+
public class PosixTests {
527527

528528
private FileSystem fs;
529529

@@ -540,7 +540,7 @@ public void setup(@TempDir Path tmpDir) throws IOException, MasterkeyLoadingFail
540540

541541
@Nested
542542
@DisplayName("File Locks")
543-
class FileLockTests {
543+
public class FileLockTests {
544544

545545
private Path file = fs.getPath("/lock.txt");
546546

@@ -615,7 +615,7 @@ public void testOverlappingLocks(boolean shared) throws IOException {
615615
@EnabledOnOs(OS.WINDOWS)
616616
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
617617
@DisplayName("On Windows Systems")
618-
class WindowsTests {
618+
public class WindowsTests {
619619

620620
private FileSystem fs;
621621

@@ -661,7 +661,7 @@ public void testDosFileAttributes() throws IOException {
661661

662662
@Nested
663663
@DisplayName("read-only file")
664-
class OnReadOnlyFile {
664+
public class OnReadOnlyFile {
665665

666666
private Path file = fs.getPath("/readonly.txt");
667667
private DosFileAttributeView attrView;

src/test/java/org/cryptomator/cryptofs/CryptoFileSystemProviderTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public class CryptoFileSystemProviderTest {
7070

7171
private CryptoFileSystemProvider inTest;
7272

73-
private static final Stream<InvocationWhichShouldFail> shouldFailWithProviderMismatch() {
73+
public static Stream<InvocationWhichShouldFail> shouldFailWithProviderMismatch() {
7474
return Stream.of( //
7575
invocation("newAsynchronousFileChannel", (inTest, path) -> inTest.newAsynchronousFileChannel(path, new HashSet<>(), mock(ExecutorService.class))), //
7676
invocation("newFileChannel", (inTest, path) -> inTest.newFileChannel(path, new HashSet<>())), //
@@ -91,7 +91,7 @@ private static final Stream<InvocationWhichShouldFail> shouldFailWithProviderMis
9191
}
9292

9393
@SuppressWarnings("unchecked")
94-
private static final Stream<InvocationWhichShouldFail> shouldFailWithRelativePath() {
94+
public static Stream<InvocationWhichShouldFail> shouldFailWithRelativePath() {
9595
return Stream.of( //
9696
invocation("newAsynchronousFileChannel", (inTest, path) -> inTest.newAsynchronousFileChannel(path, new HashSet<>(), mock(ExecutorService.class))), //
9797
invocation("newFileChannel", (inTest, path) -> inTest.newFileChannel(path, new HashSet<>())), //

src/test/java/org/cryptomator/cryptofs/DirStructureTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public class DirStructureTest {
2020
private static final String CONFIG = "config";
2121

2222
@TempDir
23-
Path vaultPath;
23+
public Path vaultPath;
2424

2525
@Test
2626
public void testNonExistingVaultPathThrowsIOException() {
@@ -59,7 +59,7 @@ public void testAllCombosOfDataAndConfigAndKey(boolean createDataDir, boolean cr
5959
Assertions.assertEquals(expectedResult, DirStructure.checkDirStructure(vaultPath, CONFIG, KEY));
6060
}
6161

62-
private static Stream<Arguments> provideAllCases() {
62+
public static Stream<Arguments> provideAllCases() {
6363
return Stream.of(
6464
Arguments.of(true, true, true, DirStructure.VAULT),
6565
Arguments.of(true, true, false, DirStructure.VAULT),

src/test/java/org/cryptomator/cryptofs/attr/CryptoDosFileAttributesTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public void setup() {
4545
@Nested
4646
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
4747
@DisplayName("on read-write filesystem")
48-
class ReadWriteFileSystem {
48+
public class ReadWriteFileSystem {
4949

5050
private CryptoDosFileAttributes inTest;
5151

@@ -96,7 +96,7 @@ public void testIsSystemDelegates(boolean value) {
9696
@Nested
9797
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
9898
@DisplayName("on read-only filesystem")
99-
class ReadOnlyFileSystem {
99+
public class ReadOnlyFileSystem {
100100

101101
private CryptoDosFileAttributes inTest;
102102

src/test/java/org/cryptomator/cryptofs/ch/CleartextFileChannelTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ public void testMapThrowsUnsupportedOperationException() throws IOException {
252252
}
253253

254254
@Nested
255-
class Locking {
255+
public class Locking {
256256

257257
private FileLock delegate = Mockito.mock(FileLock.class);
258258

src/test/java/org/cryptomator/cryptofs/ch/CleartextFileLockTest.java

Lines changed: 13 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,18 @@ public class CleartextFileLockTest {
2222
@BeforeEach
2323
public void setup() {
2424
channel = Mockito.mock(FileChannel.class);
25+
delegate = Mockito.mock(FileLock.class);
2526
Mockito.when(channel.isOpen()).thenReturn(true);
2627
}
2728

2829
@Nested
2930
@DisplayName("Shared Locks")
30-
class ValidSharedLockTests {
31+
public class SharedLockTests {
3132

3233
@BeforeEach
3334
public void setup() {
34-
delegate = Mockito.spy(new FileLockMock(channel, position, size, true));
35+
Mockito.when(delegate.isValid()).thenReturn(true);
36+
Mockito.when(delegate.isShared()).thenReturn(true);
3537
inTest = new CleartextFileLock(channel, delegate, position, size);
3638
}
3739

@@ -73,11 +75,12 @@ public void testIsValid() {
7375

7476
@Nested
7577
@DisplayName("After releasing the lock")
76-
class ReleasedLock {
78+
public class ReleasedLock {
7779

7880
@BeforeEach
7981
public void setup() throws IOException {
8082
inTest.release();
83+
Mockito.when(delegate.isValid()).thenReturn(false);
8184
}
8285

8386
@Test
@@ -96,7 +99,7 @@ public void testReleaseDelegate() throws IOException {
9699

97100
@Nested
98101
@DisplayName("After closing the channel")
99-
class ClosedChannel {
102+
public class ClosedChannel {
100103

101104
@BeforeEach
102105
public void setup() throws IOException {
@@ -115,11 +118,12 @@ public void testIsValid() {
115118

116119
@Nested
117120
@DisplayName("Exclusive Locks")
118-
class InvalidSharedLockTests {
121+
public class ExclusiveLockTests {
119122

120123
@BeforeEach
121124
public void setup() {
122-
delegate = Mockito.spy(new FileLockMock(channel, position, size, false));
125+
Mockito.when(delegate.isValid()).thenReturn(true);
126+
Mockito.when(delegate.isShared()).thenReturn(false);
123127
inTest = new CleartextFileLock(channel, delegate, position, size);
124128
}
125129

@@ -161,11 +165,12 @@ public void testIsValid() {
161165

162166
@Nested
163167
@DisplayName("After releasing the lock")
164-
class ReleasedLock {
168+
public class ReleasedLock {
165169

166170
@BeforeEach
167171
public void setup() throws IOException {
168172
inTest.release();
173+
Mockito.when(delegate.isValid()).thenReturn(false);
169174
}
170175

171176
@Test
@@ -184,7 +189,7 @@ public void testReleaseDelegate() throws IOException {
184189

185190
@Nested
186191
@DisplayName("After closing the channel")
187-
class ClosedChannel {
192+
public class ClosedChannel {
188193

189194
@BeforeEach
190195
public void setup() throws IOException {
@@ -201,24 +206,4 @@ public void testIsValid() {
201206

202207
}
203208

204-
private static class FileLockMock extends FileLock {
205-
206-
private boolean valid;
207-
208-
protected FileLockMock(FileChannel channel, long position, long size, boolean shared) {
209-
super(channel, position, size, shared);
210-
this.valid = true;
211-
}
212-
213-
@Override
214-
public boolean isValid() {
215-
return valid;
216-
}
217-
218-
@Override
219-
public void release() {
220-
valid = false;
221-
}
222-
}
223-
224209
}

0 commit comments

Comments
 (0)