6060import java .util .stream .Collectors ;
6161import java .util .stream .Stream ;
6262
63- import static org .junit .Assert .assertEquals ;
64- import static org .junit .Assert .assertTrue ;
63+ import static org .junit .Assert .*;
6564
6665/**
6766 * Test {@link UVFVault} implementation against test data from
@@ -127,7 +126,10 @@ public void listMinio() throws BackgroundException, IOException {
127126 for (final String fi : files ) {
128127 final Path file = new Path ("/" + bucketName + "/" + fi , EnumSet .of (AbstractPath .Type .file ));
129128 byte [] content = new byte [1000 ];
130- final int size = UVFIntegrationTest .class .getResourceAsStream ("/uvf/first_vault" + fi ).read (content );
129+ final int size ;
130+ try (InputStream in = UVFIntegrationTest .class .getResourceAsStream ("/uvf/first_vault" + fi )) {
131+ size = in .read (content );
132+ }
131133 final TransferStatus transferStatus = new TransferStatus ().withLength (size );
132134 transferStatus .setChecksum (storage .getFeature (Write .class ).checksum (file , transferStatus ).compute (new ByteArrayInputStream (content ), transferStatus ));
133135 storage .getFeature (Bulk .class ).pre (Transfer .Type .upload , Collections .singletonMap (new TransferItem (file ), transferStatus ), new DisabledConnectionCallback ());
@@ -148,7 +150,7 @@ public Credentials prompt(final Host bookmark, final String title, final String
148150 final PathAttributes attr = storage .getFeature (AttributesFinder .class ).find (vault .getHome ());
149151 storage .withRegistry (vaults );
150152 try (final UVFMasterkey masterKey = UVFMasterkey .fromDecryptedPayload (jwe )) {
151- assertTrue ( Arrays . equals ( masterKey .rootDirId (), vault .getRootDirId () ));
153+ assertArrayEquals ( masterKey .rootDirId (), vault .getRootDirId ());
152154 }
153155
154156 final Path home = vault .getHome ().withAttributes (attr ).withType (EnumSet .of (AbstractPath .Type .directory , AbstractPath .Type .vault ));
@@ -158,10 +160,11 @@ public Credentials prompt(final Host bookmark, final String title, final String
158160 final Path foo = new Path ("/cyberduckbucket/foo.txt" , EnumSet .of (AbstractPath .Type .file , AbstractPath .Type .decrypted ));
159161 assertTrue (Arrays .toString (list .toArray ()), list .contains (foo ));
160162 assertTrue (Arrays .toString (list .toArray ()), list .contains (new Path ("/cyberduckbucket/subdir" , EnumSet .of (AbstractPath .Type .directory , AbstractPath .Type .placeholder , AbstractPath .Type .decrypted ))));
163+
161164 assertEquals ("Hello Foo" , readFile (storage , foo ));
162165 }
163166 {
164- final byte [] expected = writeRandomFile (storage , new Path ("/cyberduckbucket/alice.txt" , EnumSet .of (AbstractPath .Type .file , AbstractPath .Type .decrypted )), 55 );
167+ final byte [] expected = writeRandomFile (storage , new Path ("/cyberduckbucket/alice.txt" , EnumSet .of (AbstractPath .Type .file , AbstractPath .Type .decrypted )), 57 );
165168 final AttributedList <Path > list = storage .getFeature (ListService .class ).list (home , new DisabledListProgressListener ());
166169 assertEquals (3 , list .size ());
167170 assertTrue (Arrays .toString (list .toArray ()), list .contains (new Path ("/cyberduckbucket/foo.txt" , EnumSet .of (AbstractPath .Type .file , AbstractPath .Type .decrypted ))));
@@ -178,6 +181,15 @@ public Credentials prompt(final Host bookmark, final String title, final String
178181 assertTrue (Arrays .toString (list .toArray ()), list .contains (bar ));
179182 assertEquals ("Hello Bar" , readFile (storage , bar ));
180183 }
184+ {
185+ final byte [] expected = writeRandomFile (storage , new Path ("/cyberduckbucket/subdir/alice.txt" , EnumSet .of (AbstractPath .Type .file , AbstractPath .Type .decrypted )), 55 );
186+ final AttributedList <Path > list = storage .getFeature (ListService .class ).list (new Path ("/cyberduckbucket/subdir" , EnumSet .of (AbstractPath .Type .directory , AbstractPath .Type .placeholder , AbstractPath .Type .decrypted )), new DisabledListProgressListener ());
187+ assertEquals (2 , list .size ());
188+ assertTrue (Arrays .toString (list .toArray ()), list .contains (new Path ("/cyberduckbucket/subdir/bar.txt" , EnumSet .of (AbstractPath .Type .file , AbstractPath .Type .decrypted ))));
189+ assertTrue (Arrays .toString (list .toArray ()), list .contains (new Path ("/cyberduckbucket/subdir/alice.txt" , EnumSet .of (AbstractPath .Type .file , AbstractPath .Type .decrypted ))));
190+
191+ assertEquals (new String (expected ), readFile (storage , new Path ("/cyberduckbucket/subdir/alice.txt" , EnumSet .of (AbstractPath .Type .file , AbstractPath .Type .decrypted ))));
192+ }
181193 }
182194 finally {
183195 storage .withRegistry (new DefaultVaultRegistry (new DisabledPasswordCallback ()));
0 commit comments