List of usage examples for javax.naming NoPermissionException NoPermissionException
public NoPermissionException()
From source file:org.obm.push.contacts.ContactsBackendTest.java
@Test(expected = NoPermissionException.class) public void testCreateNoPermissionLetsPropagateTheException() throws Exception { MSContact msContact = new MSContact(); CollectionId collectionId = CollectionId.of(1); int bookId = 5; ServerId serverId = null;// www .j a v a2 s . c o m String clientId = "1"; String clientIdHash = "146565647814688"; expect(folderSnapshotDao.get(user, device, collectionId)) .andReturn(org.obm.push.bean.change.hierarchy.Folder.builder().displayName("folder") .collectionId(collectionId).backendId(AddressBookId.of(bookId)) .folderType(FolderType.DEFAULT_CONTACTS_FOLDER).build()); expect(creationIdempotenceService.find(userDataRequest, collectionId, msContact)) .andReturn(Optional.<ServerId>absent()); expect(clientIdService.hash(userDataRequest, clientId)).andReturn(clientIdHash); expect(bookClient.storeContact(token, bookId, new Contact(), clientIdHash)) .andThrow(new NoPermissionException()); mocks.replay(); try { contactsBackend.createOrUpdate(userDataRequest, collectionId, serverId, clientId, msContact); } catch (NoPermissionException e) { mocks.verify(); throw e; } }
From source file:org.obm.push.contacts.ContactsBackendTest.java
@Test(expected = NoPermissionException.class) public void testUpdateNoPermissionLetsPropagateTheException() throws Exception { MSContact msContact = new MSContact(); CollectionId collectionId = CollectionId.of(1); int bookId = 5; ServerId serverId = collectionId.serverId(215); String clientId = "1"; String clientIdHash = "146565647814688"; expect(folderSnapshotDao.get(user, device, collectionId)) .andReturn(org.obm.push.bean.change.hierarchy.Folder.builder().displayName("folder") .collectionId(collectionId).backendId(AddressBookId.of(bookId)) .folderType(FolderType.DEFAULT_CONTACTS_FOLDER).build()); expect(clientIdService.hash(userDataRequest, clientId)).andReturn(clientIdHash); Contact contact = newContactObject(serverId.getItemId()); expect(bookClient.storeContact(token, bookId, contact, clientIdHash)).andThrow(new NoPermissionException()); mocks.replay();/*from ww w .j av a2 s . c o m*/ try { contactsBackend.createOrUpdate(userDataRequest, collectionId, serverId, clientId, msContact); } catch (NoPermissionException e) { mocks.verify(); throw e; } }
From source file:org.obm.opush.command.sync.SyncHandlerTest.java
@Test public void testAddLeadingToNoPermissionExceptionReplyNothing() throws Exception { TimeZone defaultTimeZone = TimeZone.getDefault(); TimeZone.setDefault(DateTimeZone.UTC.toTimeZone()); SyncKey syncKey = new SyncKey("13424"); CollectionId collectionId = CollectionId.of(1); ServerId serverId = collectionId.serverId(1); String clientId = "156"; DataDelta serverDataDelta = DataDelta.newEmptyDelta(date("2012-10-10T16:22:53"), syncKey); MSEmail clientData = MSEmail.builder().header(MSEmailHeader.builder().build()) .body(MSEmailBody.builder().mimeData(Optional.of(new SerializableInputStream("obm"))) .bodyType(MSEmailBodyType.PlainText).estimatedDataSize(0).charset(Charsets.UTF_8) .truncated(false).build()) .build();/* w ww . j a v a 2 s . c om*/ syncKeyTestUtils.mockNextGeneratedSyncKey(new SyncKey("2342")); syncTestUtils.mockEmailSyncClasses(syncKey, serverDataDelta, userAsList); UserDataRequest udr = new UserDataRequest(users.jaures.credentials, "Sync", users.jaures.device); expect(contentsImporter.importMessageChange(udr, collectionId, serverId, clientId, clientData)) .andThrow(new NoPermissionException()); mocksControl.replay(); opushServer.start(); OPClient opClient = testUtils.buildWBXMLOpushClient(users.jaures, opushServer.getHttpPort(), httpClient); SyncResponse syncResponse = opClient .run(syncBuilder.device(users.jaures.device) .request(ClientSyncRequest.builder().addCollection(AnalysedSyncCollection.builder() .collectionId(collectionId).syncKey(syncKey).dataType(PIMDataType.EMAIL) .command(SyncCollectionCommandRequest.builder().type(SyncCommand.ADD) .serverId(serverId).clientId(clientId).applicationData(clientData).build()) .build()).build()) .build()); assertThat(syncResponse.getStatus()).isEqualTo(SyncStatus.OK); syncTestUtils.checkMailFolderHasNoChange(syncResponse, collectionId); TimeZone.setDefault(defaultTimeZone); }
From source file:org.obm.opush.command.sync.SyncHandlerTest.java
@Test public void testChangeLeadingToNoPermissionExceptionReplyNothing() throws Exception { TimeZone defaultTimeZone = TimeZone.getDefault(); TimeZone.setDefault(DateTimeZone.UTC.toTimeZone()); SyncKey syncKey = new SyncKey("13424"); CollectionId collectionId = CollectionId.of(1); ServerId serverId = CollectionId.of(432).serverId(1456); String clientId = null;/*ww w . ja v a 2s . c o m*/ DataDelta serverDataDelta = DataDelta.newEmptyDelta(date("2012-10-10T16:22:53"), syncKey); MSEmail clientData = MSEmail.builder().header(MSEmailHeader.builder().build()) .body(MSEmailBody.builder().mimeData(Optional.of(new SerializableInputStream("obm"))) .bodyType(MSEmailBodyType.PlainText).estimatedDataSize(0).charset(Charsets.UTF_8) .truncated(false).build()) .build(); syncKeyTestUtils.mockNextGeneratedSyncKey(new SyncKey("2345")); syncTestUtils.mockEmailSyncClasses(syncKey, serverDataDelta, userAsList); UserDataRequest udr = new UserDataRequest(users.jaures.credentials, "Sync", users.jaures.device); expect(contentsImporter.importMessageChange(udr, collectionId, serverId, clientId, clientData)) .andThrow(new NoPermissionException()); mocksControl.replay(); opushServer.start(); OPClient opClient = testUtils.buildWBXMLOpushClient(users.jaures, opushServer.getHttpPort(), httpClient); SyncResponse syncResponse = opClient .run(syncBuilder.device(users.jaures.device) .request(ClientSyncRequest.builder().addCollection(AnalysedSyncCollection.builder() .collectionId(collectionId).syncKey(syncKey).dataType(PIMDataType.EMAIL) .command(SyncCollectionCommandRequest.builder().type(SyncCommand.ADD) .serverId(serverId).clientId(clientId).applicationData(clientData).build()) .build()).build()) .build()); assertThat(syncResponse.getStatus()).isEqualTo(SyncStatus.OK); syncTestUtils.checkMailFolderHasNoChange(syncResponse, collectionId); TimeZone.setDefault(defaultTimeZone); }