5353import org .junit .BeforeClass ;
5454import org .junit .Rule ;
5555import org .junit .Test ;
56+ import org .junit .runner .RunWith ;
5657
5758import java .io .File ;
5859import java .io .IOException ;
6162import java .util .List ;
6263import java .util .Random ;
6364
65+ import androidx .test .ext .junit .runners .AndroidJUnit4 ;
66+
6467import static com .owncloud .android .lib .resources .status .OwnCloudVersion .nextcloud_19 ;
6568import static junit .framework .TestCase .assertEquals ;
6669import static junit .framework .TestCase .assertFalse ;
6770import static junit .framework .TestCase .assertNotNull ;
6871import static junit .framework .TestCase .assertTrue ;
6972import static org .junit .Assume .assumeTrue ;
7073
74+ @ RunWith (AndroidJUnit4 .class )
7175public class EndToEndRandomIT extends AbstractOnServerIT {
7276 public enum Action {
7377 CREATE_FOLDER ,
@@ -88,8 +92,9 @@ public enum Action {
8892 public RetryTestRule retryTestRule = new RetryTestRule ();
8993
9094 @ BeforeClass
91- public static void initClass () {
95+ public static void initClass () throws Exception {
9296 arbitraryDataProvider = new ArbitraryDataProvider (targetContext .getContentResolver ());
97+ createKeys ();
9398 }
9499
95100 @ Before
@@ -230,6 +235,29 @@ public void deleteFile() throws Exception {
230235 deleteFile (1 );
231236 }
232237
238+ @ Test
239+ public void deleteFolder () throws Exception {
240+ init ();
241+
242+ // create folder, go into it
243+ OCFile createdFolder = createFolder (0 );
244+ assertNotNull (createdFolder );
245+ currentFolder = createdFolder ;
246+
247+ uploadFile (1 );
248+ goUp (1 );
249+
250+ // delete folder
251+ assertTrue (new RemoveFileOperation (createdFolder ,
252+ false ,
253+ user ,
254+ false ,
255+ targetContext ,
256+ getStorageManager ())
257+ .execute (client )
258+ .isSuccess ());
259+ }
260+
233261 @ Test
234262 public void downloadFile () throws Exception {
235263 init ();
@@ -488,7 +516,6 @@ public void reInit() throws Exception {
488516 encFolder .setEncrypted (true );
489517 getStorageManager ().saveFolder (encFolder , new ArrayList <>(), new ArrayList <>());
490518
491- createKeys ();
492519
493520 // delete keys
494521 arbitraryDataProvider .deleteKeyForAccount (account .name , EncryptionUtils .PRIVATE_KEY );
@@ -503,7 +530,7 @@ private void useExistingKeys() throws Exception {
503530 GetPublicKeyOperation publicKeyOperation = new GetPublicKeyOperation ();
504531 RemoteOperationResult publicKeyResult = publicKeyOperation .execute (account , targetContext );
505532
506- assertTrue (publicKeyResult .isSuccess ());
533+ assertTrue ("Result code:" + publicKeyResult . getHttpCode (), publicKeyResult .isSuccess ());
507534
508535 String publicKeyFromServer = (String ) publicKeyResult .getData ().get (0 );
509536 arbitraryDataProvider .storeOrUpdateKeyValue (account .name ,
@@ -530,7 +557,7 @@ private void useExistingKeys() throws Exception {
530557 /*
531558 TODO do not c&p code
532559 */
533- private void createKeys () throws Exception {
560+ private static void createKeys () throws Exception {
534561 String publicKey ;
535562
536563 // Create public/private key pair
@@ -571,7 +598,7 @@ private void createKeys() throws Exception {
571598 }
572599 }
573600
574- private String generateMnemonicString () {
601+ private static String generateMnemonicString () {
575602 return "1 2 3 4 5 6" ;
576603 }
577604
0 commit comments