public void testSimpleUpload() { try { mediaFire.startSessionWithEmail("*****@*****.**", "badtestemail", null); } catch (MFApiException e) { fail("Exception should not have been thrown: " + e); } catch (MFException e) { fail("Exception should not have been thrown: " + e); } String prefix = "foobar2mb"; String suffix = ".tmp"; File file = null; try { file = File.createTempFile(prefix, suffix); Random random = new Random(); byte dataToWrite[] = new byte[100000]; random.nextBytes(dataToWrite); FileOutputStream out = new FileOutputStream(file); out.write(dataToWrite); out.close(); } catch (IOException e) { fail("Exception should not have been thrown: " + e); } System.out.println(getName() + " file: " + file + ", size: " + file.length()); MediaFireUpload upload = new MediaFireUpload( mediaFire, 98, file, file.getName(), MediaFireUpload.ActionOnInAccount.UPLOAD_ALWAYS, MediaFireUploadTest.this, 1); Thread thread = new Thread(upload); thread.start(); try { thread.join(); boolean deleted = file.delete(); } catch (InterruptedException e) { fail("Exception should not have been thrown: " + e); } assertTrue(true); }
public void testWebUpload() { try { mediaFire.startSessionWithEmail("*****@*****.**", "badtestemail", null); } catch (MFApiException e) { fail("Exception should not have been thrown: " + e); } catch (MFException e) { fail("Exception should not have been thrown: " + e); } MediaFireUpload upload = new MediaFireUpload( mediaFire, 98, "http://i.imgur.com/cGIyKyR.gif", "cGIyKyR.gif", this, 0); Thread thread = new Thread(upload); thread.start(); try { thread.join(); } catch (InterruptedException e) { fail("Exception should not have been thrown: " + e); } assertTrue(true); }