javax.ejb.EJBException Java Examples
The following examples show how to use
javax.ejb.EJBException.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MarketplaceToOrganizationIT.java From development with Apache License 2.0 | 6 votes |
@Test(expected = NonUniqueBusinessKeyException.class) public void testAdd_Duplicate() throws Exception { try { runTX(new Callable<Void>() { @Override public Void call() throws Exception { doTestAdd(); return null; } }); runTX(new Callable<Void>() { @Override public Void call() throws Exception { doTestAdd(); return null; } }); } catch (EJBException e) { throw e.getCausedByException(); } }
Example #2
Source File: APPTimerServiceBean.java From development with Apache License 2.0 | 6 votes |
/** * Convert given exception into a well designed platform exception. * * @param ex * the exception * @return the converted platform exception */ private APPlatformException getPlatformException(Throwable ex) { if (ex instanceof EJBException) { if (ex.getCause() != null) { ex = ex.getCause(); } else if (((EJBException) ex).getCausedByException() != null) { ex = ((EJBException) ex).getCausedByException(); } } if (ex instanceof APPlatformException) { return (APPlatformException) ex; } String causeMessage = (ex.getMessage() != null) ? ex.getMessage() : ex.getClass().getName(); return new APPlatformException(causeMessage, ex); }
Example #3
Source File: AccountServiceBeanPermissionIT.java From development with Apache License 2.0 | 6 votes |
@Test public void getDefaultServicePaymentConfiguration_asBroker() throws Exception { // given container.login(givenBroker().getKey(), UserRoleType.BROKER_MANAGER.name()); try { // when as.getDefaultServicePaymentConfiguration(); fail(); } catch (EJBException e) { // then assertTrue(e.getCausedByException() instanceof EJBAccessException); } }
Example #4
Source File: ProductToPaymentTypeIT.java From development with Apache License 2.0 | 6 votes |
@Test public void testAdd() throws Exception { try { runTX(new Callable<Void>() { @Override public Void call() throws Exception { doTestAdd(); return null; } }); runTX(new Callable<Void>() { @Override public Void call() throws Exception { doTestAddCheck(); return null; } }); } catch (EJBException e) { throw e.getCausedByException(); } }
Example #5
Source File: TimerServiceBean2Test.java From development with Apache License 2.0 | 6 votes |
@Test(expected = ValidationException.class) public void initTimers_nextExpirationDateNegative_userCount() throws ValidationException { // given tss = new TimerServiceStub() { @Override public Timer createTimer(Date arg0, Serializable arg1) throws IllegalArgumentException, IllegalStateException, EJBException { initTimer((TimerType) arg1, arg0); getTimers().add(timer); return null; } }; when(ctx.getTimerService()).thenReturn(tss); cfs.setConfigurationSetting(ConfigurationKey.TIMER_INTERVAL_USER_COUNT, "9223372036854775807"); // when tm.initTimers(); }
Example #6
Source File: AccountServiceBeanPermissionIT.java From development with Apache License 2.0 | 6 votes |
@Test public void getDefaultPaymentConfiguration_asBroker() throws Exception { // given container.login(givenBroker().getKey(), UserRoleType.BROKER_MANAGER.name()); try { // when as.getDefaultPaymentConfiguration(); fail(); } catch (EJBException e) { // then assertTrue(e.getCausedByException() instanceof EJBAccessException); } }
Example #7
Source File: PlatformUserIT.java From development with Apache License 2.0 | 6 votes |
/** * <b>Testcase:</b> Try to insert two Users with the same login for the same * organization<br> * <b>ExpectedResult:</b> SaasNonUniqueBusinessKeyException * * @throws Throwable */ @Test(expected = NonUniqueBusinessKeyException.class) public void testViolateUniqueConstraintSameOrganizationInOneTX() throws Throwable { try { runTX(new Callable<Void>() { @Override public Void call() throws Exception { doTestViolateUniqueConstraintInOneTX(); return null; } }); } catch (EJBException e) { throw e.getCause(); } }
Example #8
Source File: AuthorizationFilter.java From development with Apache License 2.0 | 6 votes |
private void handleServletException(HttpServletRequest httpRequest, HttpServletResponse httpResponse, ServletException e) throws IOException, ServletException { EJBException ejbEx = ExceptionHandler.getEJBException(e); if (ejbEx != null && ejbEx.getCause() instanceof Exception && ejbEx.getCausedByException() instanceof AccessException) { String forwardErrorPage; if (BesServletRequestReader.isMarketplaceRequest(httpRequest)) { forwardErrorPage = Marketplace.MARKETPLACE_ROOT + Constants.INSUFFICIENT_AUTHORITIES_URI; } else { forwardErrorPage = Constants.INSUFFICIENT_AUTHORITIES_URI; } JSFUtils.sendRedirect(httpResponse, httpRequest.getContextPath() + forwardErrorPage); } else { // make sure we do not catch exceptions cause by // ViewExpiredException here, they'll be handled directly in the // doFilter() throw e; } }
Example #9
Source File: PublishServiceBeanPermissionIT.java From development with Apache License 2.0 | 6 votes |
@Test public void getBrokerOrganizations_asReseller() throws Exception { // given container.login(givenReseller().getKey(), UserRoleType.RESELLER_MANAGER.name()); try { // when publishService.getBrokers(0L); fail(); } catch (EJBException e) { // then assertTrue(e.getCausedByException() instanceof EJBAccessException); } }
Example #10
Source File: ParameterDefinitionIT.java From development with Apache License 2.0 | 6 votes |
@Test public void modify() throws Throwable { try { runTX(new Callable<Void>() { public Void call() throws Exception { doTestAdd(); return null; } }); runTX(new Callable<Void>() { public Void call() throws Exception { doTestModify(); return null; } }); runTX(new Callable<Void>() { public Void call() throws Exception { doTestModifyCheck(); return null; } }); } catch (EJBException e) { throw e.getCause(); } }
Example #11
Source File: PricingServiceBeanAllStatesServiceRevenueSharesIT.java From development with Apache License 2.0 | 6 votes |
@Test public void getPartnerRevenueShareForAllStatesService_invalidRole() throws Exception { setupWithContainer(); // given container.login(mpOwnerUserKey, UserRoleType.TECHNOLOGY_MANAGER.name()); // when try { pricingService.getPartnerRevenueShareForAllStatesService( new POServiceForPricing()); fail(); } catch (EJBException e) { // then assertTrue(e.getCausedByException() instanceof EJBAccessException); } }
Example #12
Source File: ExceptionHandler.java From development with Apache License 2.0 | 6 votes |
/** * Convert a EJBException into FacesMessage which is presented to the user. * * @param ex * the EJBException to be analyzed */ public static void execute(EJBException ex) { if (ex != null && ex.getCause() instanceof Exception && ex.getCausedByException() instanceof AccessException) { handleOrganizationAuthoritiesException(); } else if (ex != null && isInvalidUserSession(ex)) { HttpServletRequest request = JSFUtils.getRequest(); request.getSession().removeAttribute(Constants.SESS_ATTR_USER); request.getSession().invalidate(); handleInvalidSession(); } else if (ex != null && isConnectionException(ex)) { handleMissingConnect(BaseBean.ERROR_DATABASE_NOT_AVAILABLE); } else { throw new FacesException(ex); } }
Example #13
Source File: ModifiedUdaIT.java From development with Apache License 2.0 | 6 votes |
/** * <b>Testcase:</b> Add new ModifiedUda objects <br> * <b>ExpectedResult:</b> * <ul> * <li>All objects can be retrieved from DB and are identical to provided * ModifiedUda objects</li> * <li>A history object is created for each ModifiedUda stored</li> * <li>History objects are created for CascadeAudit-annotated associated * objects</li> * </ul> * * @throws Throwable */ @Test public void testAdd() throws Throwable { try { runTX(new Callable<Void>() { @Override public Void call() throws Exception { doTestAdd(); return null; } }); runTX(new Callable<Void>() { @Override public Void call() { doTestAddCheck(); return null; } }); } catch (EJBException e) { throw e.getCause(); } }
Example #14
Source File: ServiceProvisioningServiceBean3IT.java From development with Apache License 2.0 | 6 votes |
@Test public void createMarketingProductForExternal() throws Exception { VOTechnicalService tp = createTechnicalProduct(svcProv); svcProv.deleteTechnicalService(tp); tp.setAccessType(ServiceAccessType.EXTERNAL); tp.setKey(0); tp = svcProv.createTechnicalService(tp); VOServiceDetails product = new VOServiceDetails(); product.setServiceId("test"); OrganizationReference ref = createOrgRef(provider.getKey()); createMarketingPermission(tp.getKey(), ref.getKey()); try { VOServiceDetails svc = svcProv.createService(tp, product, null); validateCopiedProductPaymentConfiguration(svc.getKey(), ENABLED_PAYMENTTYPES); // is price model created and not chargeable? assertFalse(svc.getPriceModel().isChargeable()); assertTrue(svc.getPriceModel().getKey() > 0L); } catch (EJBException e) { throw e.getCausedByException(); } }
Example #15
Source File: ProductClassBridgeIT.java From development with Apache License 2.0 | 6 votes |
@Test public void test2() throws Throwable { try { runTX(new Callable<Void>() { public Void call() throws Exception { Product product = createProductAndExpectedFields(); expectedFields.clear(); productKey = createAndPublishPartnerCopy(product).getKey(); // Bug 9784 // The ID of the marketplace where the partner publishes // must be written in the index. expectedFields.put(ProductClassBridge.MP_ID, RESELLER_MP.toLowerCase()); return null; } }); runTX(new Callable<Void>() { public Void call() throws Exception { verifyIndexedFieldsForProduct(productKey); return null; } }); } catch (EJBException e) { throw e.getCause(); } }
Example #16
Source File: ServiceProvisioningServiceBeanIT.java From development with Apache License 2.0 | 6 votes |
@Test(expected = SaaSSystemException.class) public void testCreateMarketingProductImageTypeNull() throws Exception { VOTechnicalService tp = createTechnicalProduct(svcProv); VOServiceDetails product = new VOServiceDetails(); product.setServiceId("test"); VOImageResource imageResource = new VOImageResource(); byte[] content = BaseAdmUmTest.getFileAsByteArray( ServiceProvisioningServiceBeanIT.class, "icon1.png"); imageResource.setBuffer(content); imageResource.setContentType("image/png"); try { container.login(supplierUserKey, ROLE_SERVICE_MANAGER); svcProv.createService(tp, product, imageResource); } catch (EJBException e) { throw e.getCausedByException(); } }
Example #17
Source File: BillingServiceGetShareDataIT.java From development with Apache License 2.0 | 6 votes |
@Test(expected = EJBAccessException.class) public void getRevenueShareData_invalidRoleTechnologyManager() throws Exception { // given no revenue share result entries. Login with invalid user role container.login(brokerUser.getKey(), ROLE_TECHNOLOGY_MANAGER); // when try { bs.getRevenueShareData(Long.valueOf(PERIOD_START_MONTH1), Long.valueOf(PERIOD_END_MONTH1), BillingSharesResultType.BROKER); fail(); } catch (EJBException e) { throw (EJBAccessException) e.getCause(); } }
Example #18
Source File: ServiceProvisioningServiceBeanIT.java From development with Apache License 2.0 | 6 votes |
@Test(expected = SaaSSystemException.class) public void testCreateMarketingProductImageTypeInvalid() throws Exception { VOTechnicalService tp = createTechnicalProduct(svcProv); VOServiceDetails product = new VOServiceDetails(); product.setServiceId("test"); VOImageResource imageResource = new VOImageResource(); byte[] content = BaseAdmUmTest.getFileAsByteArray( ServiceProvisioningServiceBeanIT.class, "icon1.png"); imageResource.setBuffer(content); imageResource.setContentType("image/png"); imageResource.setImageType(ImageType.SHOP_LOGO_LEFT); try { container.login(supplierUserKey, ROLE_SERVICE_MANAGER); svcProv.createService(tp, product, imageResource); } catch (EJBException e) { throw e.getCausedByException(); } }
Example #19
Source File: DataServiceBeanIT.java From development with Apache License 2.0 | 6 votes |
@Test public void testGetCurrentUserNonExisting() throws Exception { container.login("1000"); try { runTX(new Callable<Void>() { @Override public Void call() throws Exception { mgr.getCurrentUser(); return null; } }); Assert.fail( "Call must fail, as no dataset is present in the database for this user!"); } catch (EJBException e) { Assert.assertTrue( e.getCausedByException() instanceof InvalidUserSession); Assert.assertNotNull(e.getCausedByException().getCause()); } }
Example #20
Source File: MarketplaceServiceBeanPublishServiceIT.java From development with Apache License 2.0 | 6 votes |
@Test(expected = ValidationException.class) public void publishService_MultipleGlobalMPs() throws Exception { // currently, each service instance can only be published to exactly one // MP; this might change in the future container.login(supplier1Key, ROLE_SERVICE_MANAGER); final Marketplace mpglobal2 = runTX(new Callable<Marketplace>() { @Override public Marketplace call() throws Exception { return Marketplaces.createMarketplace(mpOwner, "GLOBAL_MP2", false, mgr); } }); VOCatalogEntry voCESvc1_3 = createCatalogEntry(p1_1.getKey(), mpglobal2); try { marketplaceService.publishService(new VOService(), Arrays.asList(voCESvc1_2, voCESvc1_3)); } catch (EJBException e) { throw e.getCausedByException(); } }
Example #21
Source File: MarketplaceServiceBeanOpenMPIT.java From development with Apache License 2.0 | 5 votes |
@Test(expected = EJBAccessException.class) public void testBanSupplier_callingOrghasWrongRole() throws Throwable { container.login(adminUserSupp1.getKey(), ROLE_SERVICE_MANAGER); try { marketplaceService.banOrganizationsFromMarketplace( Collections.singletonList(supplier1_orgId), GLOBAL_OPEN_MP_ID); } catch (EJBException e) { assertTrue(e.getMessage() .contains("Allowed roles are: [MARKETPLACE_OWNER]")); throw e.getCause(); } }
Example #22
Source File: ExceptionMapper.java From development with Apache License 2.0 | 5 votes |
Throwable findCause(Throwable e) { Throwable cause = null; if (e instanceof EJBException && e.getCause() instanceof Exception) { cause = ((EJBException) e).getCausedByException(); } if (cause == null) { cause = e.getCause(); } return cause; }
Example #23
Source File: TriggerDefinitionServiceBeanIT.java From development with Apache License 2.0 | 5 votes |
private void deleteTriggerDefinition(long key) throws Exception { try { triggerDefinitionService.deleteTriggerDefinition(key); } catch (EJBException ex) { throw ex.getCausedByException(); } }
Example #24
Source File: ServiceProvisioningServiceBeanIT.java From development with Apache License 2.0 | 5 votes |
@Test(expected = EJBException.class) public void testGetProductForCustomerSubscriptionAsCustomer() throws Exception { VOTechnicalService tp = createTechnicalProduct(svcProv); container.login(supplierUserKey, ROLE_SERVICE_MANAGER); final VOServiceDetails product = createProduct(tp, "test", svcProv); VOPriceModel priceModel = createPriceModel(); svcProv.savePriceModel(product, priceModel); VOOrganization customer = getOrganizationForOrgId(customerOrgId); String subId = createSubscription(customer, SubscriptionStatus.ACTIVE, product, "testSub", null); Assert.assertNotNull(subId); container.login(customerUserKey); svcProv.getServiceForSubscription(customer, subId); }
Example #25
Source File: ProductToPaymentTypeIT.java From development with Apache License 2.0 | 5 votes |
@Test public void testModify() throws Exception { try { runTX(new Callable<Void>() { @Override public Void call() throws Exception { doTestAdd(); return null; } }); final PaymentType newPt = runTX(new Callable<PaymentType>() { @Override public PaymentType call() throws Exception { ProductToPaymentType ref = mgr.getReference( ProductToPaymentType.class, prodToPt.getKey()); PaymentType pt = findPaymentType(INVOICE, mgr); ref.setPaymentType(pt); mgr.persist(ref); return pt; } }); runTX(new Callable<Void>() { @Override public Void call() throws Exception { doTestModifyCheck(newPt); return null; } }); } catch (EJBException e) { throw e.getCausedByException(); } }
Example #26
Source File: ServiceProvisioningServiceBeanIT.java From development with Apache License 2.0 | 5 votes |
@Test(expected = EJBAccessException.class) public void testImportTechnicalProduct_WrongRole() throws Exception { container.login(supplierUserKey, ROLE_SERVICE_MANAGER); try { svcProv.importTechnicalServices(readBytesFromFile("TechnicalServices.xml")); } catch (EJBException e) { throw e.getCausedByException(); } }
Example #27
Source File: LdapSettingsMangementServiceBeanIT.java From development with Apache License 2.0 | 5 votes |
@Test(expected = IllegalArgumentException.class) public void setOrganizationSettings_emptyOrgId() throws Throwable { try { runTX(new Callable<Void>() { @Override public Void call() throws Exception { ldapSettingsMgmtSvc.setOrganizationSettings("", null); return null; } }); } catch (EJBException e) { throw e.getCausedByException(); } }
Example #28
Source File: SearchServiceBeanListIT.java From development with Apache License 2.0 | 5 votes |
@Test(expected = IllegalArgumentException.class) public void testSearchServices_NullMarketplaceId() throws Throwable { try { search.searchServices(null, "de", "wicked_de"); } catch (EJBException e) { throw e.getCause(); } Assert.fail(); }
Example #29
Source File: OperatorServiceBeanIT.java From development with Apache License 2.0 | 5 votes |
/** * Tries to invoke the register organization functionality as a non platform * operator. */ @Test(expected = EJBException.class) public void testRegisterOrganizationNotAuthorized() throws Exception { final VOOrganization org = newVOOrganization(); final VOUserDetails user = newVOUser(); operatorService.registerOrganization(org, null, user, null, null); }
Example #30
Source File: AccountServiceBean2IT.java From development with Apache License 2.0 | 5 votes |
@Test public void removeMarketingPermission_Unauthorized() throws Exception { try { container.login(2); accountMgmt.removeSuppliersFromTechnicalService( new VOTechnicalService(), new ArrayList<String>()); fail("Operation should have failed"); } catch (EJBException e) { assertTrue(e.getMessage().contains("EJBAccessException")); } }