Project

General

Profile

« Previous | Next » 

Revision 8748

switch to use FIleUpload instead of O'Reilly COS library for handling chunked file uploads. https://projects.ecoinformatics.org/ecoinfo/issues/6517

View differences:

MetacatClientTest.java
155 155
      suite.addTest(new MetacatClientTest("getNewestDocRevision"));  // (also tries to insert)
156 156
      suite.addTest(new MetacatClientTest("upload"));
157 157
      suite.addTest(new MetacatClientTest("upload_stream"));
158
      suite.addTest(new MetacatClientTest("upload_stream_chunked"));
158 159
      suite.addTest(new MetacatClientTest("invalidRead"));
159 160
      suite.addTest(new MetacatClientTest("read"));
160 161
      suite.addTest(new MetacatClientTest("query"));
......
549 550
            fail("General exception:\n" + e.getMessage());
550 551
        }
551 552
    }
553
    
554
    /**
555
     * Test the upload() function by passing an InputStream
556
     */
557
    public void upload_stream_chunked()
558
    {
559
        debug("\nStarting upload_stream_chunked test...");
560
        try {
561
            newdocid = generateDocumentId();
562
            String identifier = newdocid + ".1";
563
            m.login(username, password);
564
            File testFile = new File(onlinetestdatafile);
565
            String response = m.upload(identifier, "onlineDataFile1",
566
                                       new FileInputStream(testFile), -1);
552 567

  
568
            assertTrue(response.indexOf("<success>") != -1);
569
            assertTrue(response.indexOf(identifier) != -1);
570
            identifier = newdocid + ".2";
571
            response = m.upload(identifier, "onlineDataFile1",
572
                    new FileInputStream(testFile), -1);
573

  
574
           assertTrue(response.indexOf("<success>") != -1);
575
           assertTrue(response.indexOf(identifier) != -1);
576
           debug("upload_stream_chunked(): response=" + response);
577

  
578
        } catch (MetacatAuthException mae) {
579
            fail("Authorization failed:\n" + mae.getMessage());
580
        } catch (MetacatInaccessibleException mie) {
581
          mie.printStackTrace();
582
            fail("Metacat Inaccessible:\n" + mie.getMessage());
583
        } catch (InsufficientKarmaException ike) {
584
            assertTrue(1 == 1);
585
            fail("Insufficient karma:\n" + ike.getMessage());
586
        } catch (MetacatException me) {
587
            fail("Metacat Error:\n" + me.getMessage());
588
        } catch (Exception e) {
589
            fail("General exception:\n" + e.getMessage());
590
        }
591
    }
592

  
553 593
    /**
554 594
     * Test the invalidUpdate() function. A user try to update a document
555 595
     * which it doesn't have permission

Also available in: Unified diff