Exemplo n.º 1
0
 @Test(groups = "unit")
 public void canUpload() throws RemoteException {
   EasyMock.expect(authorizationProvider.canUpload(fileId, gridId)).andReturn(false);
   mockObjects.replay();
   assert !service.canUpload(fileId, gridId);
   mockObjects.verifyAndReset();
   allowUpload();
   mockObjects.replay();
   assert service.canUpload(fileId, gridId);
   mockObjects.verifyAndReset();
 }
Exemplo n.º 2
0
 @Test(groups = "unit")
 public void exists() throws RemoteException {
   EasyMock.expect(accessProvider.fileExists(fileId)).andReturn(true);
   mockObjects.replay();
   assert service.exists(fileId);
   mockObjects.verifyAndReset();
   EasyMock.expect(accessProvider.fileExists(fileId)).andReturn(false);
   mockObjects.replay();
   assert !service.exists(fileId);
   mockObjects.verifyAndReset();
 }
Exemplo n.º 3
0
 @Test(groups = "unit")
 public void canDownload() throws RemoteException {
   expectCannotDownload();
   mockObjects.replay();
   assert !service.canDownload(fileId, gridId);
   mockObjects.verifyAndReset();
   expectCanDownload();
   mockObjects.replay();
   assert service.canDownload(fileId, gridId);
   mockObjects.verifyAndReset();
 }
Exemplo n.º 4
0
 @Test(groups = "unit", dataProvider = "bool1", dataProviderClass = TestNGDataProviders.class)
 public void upload(final boolean shouldCommit) throws RemoteException {
   handleShouldCommit(shouldCommit);
   allowUpload();
   mockObjects.replay();
   final InputStream inputStream = new ByteArrayInputStream("moo".getBytes());
   final UploadCallback callback = service.upload(fileId, gridId);
   mockObjects.verifyAndReset();
   final long length = 3L;
   EasyMock.expect(accessProvider.putFile(EasyMock.eq(fileId), EasyMock.same(inputStream)))
       .andReturn(length);
   expectFinalizeAndReplay(shouldCommit, length);
   callback.onUpload(inputStream);
   mockObjects.verifyAndReset();
 }
 protected void postProcessAndVerify() {
   try {
     job.postprocess(completedNormally);
   } finally {
     mockObjects.verifyAndReset();
   }
 }
Exemplo n.º 6
0
 @Test(groups = "unit", dataProvider = "bool1", dataProviderClass = TestNGDataProviders.class)
 public void uploadStream(final boolean shouldCommit) throws IOException {
   handleShouldCommit(shouldCommit);
   allowUpload();
   final ByteArrayOutputStream underlyingOutputStream = new ByteArrayOutputStream();
   EasyMock.expect(accessProvider.getPutFileOutputStream(fileId))
       .andReturn(underlyingOutputStream);
   mockObjects.replay();
   final OutputStream outputStream = service.prepareUploadStream(fileId, gridId);
   mockObjects.verifyAndReset();
   expectFinalizeAndReplay(shouldCommit, 3L);
   InputContexts.forString("moo").get(outputStream);
   outputStream.close();
   mockObjects.verifyAndReset();
   assert new String(underlyingOutputStream.toByteArray()).equals("moo");
 }
Exemplo n.º 7
0
 @Test(groups = "unit")
 public void downloadSkipCheck() throws RemoteException {
   final HasStreamInputContext file = EasyMock.createMock(HasStreamInputContext.class);
   EasyMock.expect(accessProvider.getFile(fileId)).andReturn(file);
   mockObjects.replay();
   assert file.equals(service.download(fileId, gridId, false));
   mockObjects.verifyAndReset();
 }
Exemplo n.º 8
0
 @Test(groups = "unit")
 public void delete() throws RemoteException {
   EasyMock.expect(authorizationProvider.canDelete(fileId, gridId)).andReturn(true);
   EasyMock.expect(accessProvider.deleteFile(fileId)).andReturn(true);
   mockObjects.replay();
   assert service.delete(fileId, gridId);
   mockObjects.verifyAndReset();
 }
Exemplo n.º 9
0
 @AfterMethod(groups = "unit")
 public void verifyDispatched() {
   collection.verifyAndReset();
   verifyEvent();
 }