Java Code Examples for javax.ejb.EJBException

The following are top voted examples for showing how to use javax.ejb.EJBException. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: sample.daytrader3   File: TradeSLSBBean.java   View source code 6 votes vote down vote up
private OrderDataBean createOrder(AccountDataBean account, QuoteDataBean quote, HoldingDataBean holding, String orderType, double quantity) {

        OrderDataBean order;

        if (Log.doTrace())
            Log.trace("TradeSLSBBean:createOrder(orderID="
                      + " account=" + ((account == null) ? null : account.getAccountID())
                      + " quote=" + ((quote == null) ? null : quote.getSymbol())
                      + " orderType=" + orderType
                      + " quantity=" + quantity);
        try {
            order = new OrderDataBean(orderType, "open", new Timestamp(System.currentTimeMillis()), null, quantity, quote.getPrice().setScale(FinancialUtils.SCALE,
                                                                                                                                              FinancialUtils.ROUND),
                            TradeConfig.getOrderFee(orderType), account, quote, holding);
            entityManager.persist(order);
        } catch (Exception e) {
            Log.error("TradeSLSBBean:createOrder -- failed to create Order", e);
            throw new EJBException("TradeSLSBBean:createOrder -- failed to create Order", e);
        }
        return order;
    }
 
Example 2
Project: oscm   File: DataServiceBeanIT.java   View source code 6 votes vote down vote up
@Test(expected = InvalidUserSession.class)
public void testGetCurrentUserExistingButNoAdminClientCert()
        throws Exception {
    String dn = "dn=1";
    createOrgAndUserForWS(dn, false,
            OrganizationRoleType.TECHNOLOGY_PROVIDER);
    container.login(dn);
    PlatformUser user = runTX(new Callable<PlatformUser>() {
        @Override
        public PlatformUser call() throws Exception {
            return mgr.getCurrentUserIfPresent();
        }
    });
    Assert.assertNull("No valid user object expected", user);
    try {
        runTX(new Callable<PlatformUser>() {
            @Override
            public PlatformUser call() throws Exception {
                return mgr.getCurrentUser();
            }
        });
    } catch (EJBException e) {
        throw e.getCausedByException();
    }
}
 
Example 3
Project: oscm   File: ServiceProvisioningServiceBeanIT.java   View source code 6 votes vote down vote up
@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 4
Project: oscm   File: EventServiceBean.java   View source code 6 votes vote down vote up
/**
 * Tests whether this exception or any nested exception is a
 * {@link EntityExistsException}. Unfortunately {@link EJBException}
 * sometimes nests cause exception in {@link Throwable#getCause()},
 * sometimes in {@link EJBException#getCausedByException()}. Arrrrg.
 */
private boolean isEntityExistsException(final Throwable e) {
    if (e == null) {
        return false;
    }
    if (e instanceof PersistenceException) {
        return true;
    }
    if (e instanceof EJBException) {
        final EJBException ejbex = (EJBException) e;
        if (isEntityExistsException(ejbex.getCausedByException())) {
            return true;
        }
    }
    return isEntityExistsException(e.getCause());
}
 
Example 5
Project: oscm   File: OrganizationIT.java   View source code 6 votes vote down vote up
/**
 * <b>Testcase:</b> Modify an existing organization object <br>
 * <b>ExpectedResult:</b>
 * <ul>
 * <li>Modification is saved to the DB</li>
 * <li>History object created for the organization</li>
 * <li>usedPayment unchanged</li>
 * <li>No new history object for PaymentInfo</li>
 * </ul>
 * 
 * @throws Throwable
 */
@Test
public void testModifyOrganization() throws Throwable {
    try {
        runTX(new Callable<Void>() {
            public Void call() throws Exception {
                doTestModifyOrganizationPrepare();
                return null;
            }
        });
        runTX(new Callable<Void>() {
            public Void call() throws Exception {
                doTestModifyOrganization();
                return null;
            }
        });
        runTX(new Callable<Void>() {
            public Void call() throws Exception {
                doTestModifyOrganizationCheck();
                return null;
            }
        });
    } catch (EJBException e) {
        throw e.getCause();
    }
}
 
Example 6
Project: oscm   File: ServiceProvisioningServiceBeanPermissionIT.java   View source code 6 votes vote down vote up
@Test
public void savePriceModelForCustomer_asBroker() throws Exception {
    // given
    container.login(1L, UserRoleType.BROKER_MANAGER.name());

    // when
    try {
        sps.savePriceModelForCustomer(new VOServiceDetails(),
                new VOPriceModel(), new VOOrganization());
        fail();
    } catch (EJBException e) {

        // then
        assertTrue(e.getCausedByException() instanceof EJBAccessException);
    }
}
 
Example 7
Project: Mastering-Java-EE-Development-with-WildFly   File: XMLTestCase.java   View source code 6 votes vote down vote up
@Test
@RunAsClient
public void testRemoteXML() throws Exception {
	logger.info("starting remoting ejb client test");

	try {
		createInitialContext();
		String hostname = getLocalHost().getHostName().toLowerCase();
		final UserTransaction userTransaction = getUserTransaction(hostname);
		XMLRemote bean = lookup(XMLRemote.class, "bank");
		assertEquals(STATUS_NO_TRANSACTION, bean.transactionStatus());

		try {
			userTransaction.begin();
			bean.transactionStatus();
			fail("the transaction is not supported");
		} catch (EJBException | IllegalStateException e) {
			logger.info("the transaction is not supported");
		}
	} finally {
		closeContext();
	}
}
 
Example 8
Project: oscm   File: IdentityServiceBeanLdapWithDbIT.java   View source code 6 votes vote down vote up
@Test(expected = UnsupportedOperationException.class)
public void createUser_LDAPUsed() throws Exception {
    try {
        final VOUserDetails userToCreate = new VOUserDetails();
        userToCreate.setUserId("newUser");
        runTX(new Callable<Void>() {
            @Override
            public Void call() throws Exception {
                idMgmt.createUser(userToCreate, Collections.singletonList(
                        UserRoleType.ORGANIZATION_ADMIN), null);
                return null;
            }
        });
    } catch (EJBException e) {
        throw e.getCausedByException();
    }
}
 
Example 9
Project: oscm   File: ProductToPaymentTypeIT.java   View source code 6 votes vote down vote up
@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 10
Project: jboss-eap7.1-playground   File: SimpleWildFlyConfigClient.java   View source code 6 votes vote down vote up
public static void main(String[] args) throws NamingException {
	checkArgs(args);

	// One option is to use the java context, the INITIAL_CONTEXT_FACTORY is added by jndi.properties
	// the URI and credentials by wildfly-config.xml
	InitialContext ic = new InitialContext();

	Simple proxy = (Simple) ic.lookup("ejb:EAP71-PLAYGROUND-server/ejb/SimpleBean!" + Simple.class.getName());
	
	try {
		if(proxy.checkApplicationUser("user1")) {
			log.info("Expected 'user1'");
		} else {
			log.severe("Unexpected user, see server.log");
		}
	} catch (EJBException e) {
		throw e;
	}
}
 
Example 11
Project: tap17-muggl-javaee   File: RequestBean.java   View source code 6 votes vote down vote up
public List<String> locateVendorsByPartialName(String name) {
    
    List<String> names = new ArrayList<>();
    try {
        List vendors = em.createNamedQuery(
                "findVendorsByPartialName")
                .setParameter("name", name)
                .getResultList();
        for (Iterator iterator = vendors.iterator(); iterator.hasNext();) {
            Vendor vendor = (Vendor)iterator.next();
            names.add(vendor.getName());
        }
    } catch (Exception e) {
        throw new EJBException(e.getMessage());
    }
    return names;
}
 
Example 12
Project: oscm   File: ADMUMStartupTest.java   View source code 6 votes vote down vote up
@Before
public void setUp() {
    cfg = new ConfigurationServiceStub() {
        @Override
        public ConfigurationSetting getConfigurationSetting(
                ConfigurationKey key, String context) {
            if (throwExceptionWhenRetrievingSettings) {
                throw new EJBException();
            }
            if (key == ConfigurationKey.LOG_FILE_PATH) {
                return new ConfigurationSetting(
                        ConfigurationKey.LOG_FILE_PATH,
                        Configuration.GLOBAL_CONTEXT, ".");
            }
            return new ConfigurationSetting();
        }
    };
    testClass = new ADMUMStartup();

    testClass.cs = cfg;
    testClass.localizer = mock(LocalizerServiceLocal.class);
    testClass.prodSessionMgmt = mock(SessionServiceLocal.class);
    testClass.timerMgmt = mock(TimerServiceBean.class);
    testClass.searchService = mock(SearchServiceLocal.class);
}
 
Example 13
Project: oscm   File: OrganizationIT.java   View source code 6 votes vote down vote up
/**
 * <b>Testcase:</b> Delete an existing organization object <br>
 * <b>ExpectedResult:</b>
 * <ul>
 * <li>Organization marked as deleted in the DB</li>
 * <li>History object created for the deleted organization</li>
 * <li>PaymentInfo (usedPayment) marked as deleted in the DB</li>
 * <li>History object created for the deleted PaymentInfo</li>
 * </ul>
 * 
 * @throws Throwable
 */
@Test
public void testDeleteOrganization() throws Throwable {
    try {
        runTX(new Callable<Void>() {
            public Void call() throws Exception {
                doTestDeleteOrganizationPrepare();
                return null;
            }
        });
        runTX(new Callable<Void>() {
            public Void call() throws Exception {
                doTestDeleteOrganization();
                return null;
            }
        });
        runTX(new Callable<Void>() {
            public Void call() throws Exception {
                doTestDeleteOrganizationCheck();
                return null;
            }
        });
    } catch (EJBException e) {
        throw e.getCause();
    }
}
 
Example 14
Project: oscm-app   File: APPTimerServiceBeanIT.java   View source code 6 votes vote down vote up
/**
 * Validates error handling on case of EJB exception during creation
 * (Bugzilla #9566)
 */
@Test
public void testHandleEJBErrorDuringCreation() throws Exception {
    // given
    createServiceInstance(ProvisioningStatus.WAITING_FOR_SYSTEM_CREATION);

    // Throw EJB exception when creation status is invoked
    EJBException e = new EJBException("ejb_error");
    when(controller.getInstanceStatus(matches("appInstanceId"),
            any(ProvisioningSettings.class))).thenThrow(e);

    // when
    handleTimer();

    // then
    verify(besDAOMock, times(1)).notifyAsyncSubscription(
            any(ServiceInstance.class), any(InstanceResult.class),
            eq(false), any(APPlatformException.class));
}
 
Example 15
Project: tap17-muggl-javaee   File: RequestBeanQueries.java   View source code 6 votes vote down vote up
public List<PlayerDetails> getPlayersByCity(String city) {
    logger.info("getPlayersByCity");
    List<Player> players = null;

    try {
        CriteriaQuery<Player> cq = cb.createQuery(Player.class);
        if (cq != null) {
            Root<Player> player = cq.from(Player.class);
            Join<Player, Team> team = player.join(Player_.team);

            // Get MetaModel from Root
            //EntityType<Player> Player_ = player.getModel();

            // set the where clause
            cq.where(cb.equal(team.get(Team_.city), city));
            cq.select(player).distinct(true);
            TypedQuery<Player> q = em.createQuery(cq);
            players = q.getResultList();
        }
        return copyPlayersToDetails(players);
    } catch (Exception ex) {
        throw new EJBException(ex);
    }
}
 
Example 16
Project: oscm   File: ServiceProvisioningServiceBeanCopyIT.java   View source code 6 votes vote down vote up
private void validateNoCategories(final VOServiceDetails copy)
        throws Exception {
    try {
        runTX(new Callable<Void>() {

            @Override
            public Void call() throws Exception {
                Product c = dataManager.getReference(Product.class,
                        copy.getKey());
                assertEquals(1, c.getCatalogEntries().size());
                CatalogEntry cCe = c.getCatalogEntries().get(0);
                assertTrue(cCe.getCategoryToCatalogEntry().isEmpty());
                assertNull(cCe.getMarketplace());
                return null;
            }
        });
    } catch (EJBException e) {
        throw e.getCausedByException();
    }
}
 
Example 17
Project: oscm   File: MarketplaceIT.java   View source code 6 votes vote down vote up
/**
 * Tests the creation of a Marketplace object and compare the persisted
 * object with the original and the history.
 * 
 * @throws Throwable
 */
@Test
public void testAdd() throws Throwable {
    try {
        runTX(new Callable<Void>() {
            public Void call() throws Exception {
                doTestAdd();
                return null;
            }
        });
        runTX(new Callable<Void>() {
            public Void call() throws Exception {
                doTestAddCheck();
                return null;
            }
        });
    } catch (EJBException e) {
        throw e.getCause();
    }
}
 
Example 18
Project: oscm   File: VatServiceBeanPermissionIT.java   View source code 6 votes vote down vote up
@Test
public void saveDefaultVat_asReseller() throws Exception {
    // given
    container.login(givenReseller().getKey(),
            UserRoleType.RESELLER_MANAGER.name());

    // when
    try {
        vatService.saveDefaultVat(new VOVatRate());
        fail("EJBException expected as operation must fail due to not allowed role!");
    } catch (EJBException e) {

        // then
        assertTrue(e.getCausedByException() instanceof EJBAccessException);
    }
}
 
Example 19
Project: oscm   File: ProductClassBridgeIT.java   View source code 6 votes vote down vote up
@Test
public void test3() throws Throwable {
    try {
        runTX(new Callable<Void>() {
            public Void call() throws Exception {
                Product product = createProductAndExpectedFields();
                expectedFields.clear();
                productKey = createAndPublishCustomerCopy(product).getKey();
                expectedFields.put(ProductClassBridge.MP_ID, "est");
                return null;
            }
        });
        runTX(new Callable<Void>() {
            public Void call() {
                verifyIndexedFieldsForProduct(productKey);
                return null;
            }
        });
    } catch (EJBException e) {
        throw e.getCause();
    }
}
 
Example 20
Project: oscm   File: ServiceProvisioningServiceBean2IT.java   View source code 6 votes vote down vote up
@Test(expected = SaaSSystemException.class)
public void testSetCompatibleProductsTargetIsCopy() throws Exception {
    VOTechnicalService tp = createTechnicalProduct(svcProv);
    container.login(supplierUserKey, ROLE_SERVICE_MANAGER);
    VOService product1 = createProduct(tp, "1", svcProv);
    publishToLocalMarketplaceSupplier(product1, mpSupplier);
    VOServiceDetails product2 = createProduct(tp, "2", svcProv);
    publishToLocalMarketplaceSupplier(product2, mpSupplier);
    VOPriceModel priceModel = createPriceModel();
    VOOrganization customer = getOrganizationForOrgId(customerOrgId);
    product2 = svcProv.savePriceModelForCustomer(product2, priceModel,
            customer);
    try {
        svcProv.setCompatibleServices(product1,
                Collections.singletonList((VOService) product2));
    } catch (EJBException e) {
        throw e.getCausedByException();
    }
}
 
Example 21
Project: oscm   File: ExceptionHandler.java   View source code 6 votes vote down vote up
/**
 * Get the causing SaasApplicationException for the given Throwable or null
 * if the Throwable was not caused by an SaasApplicationException.
 * 
 * @param t
 *            the Throwable to be analyzed
 * @return the causing SaasApplicationException or null
 */
public static SaaSApplicationException getSaasApplicationException(
        Throwable t) {
    while (t != null && t != t.getCause()
            && !(t instanceof SaaSApplicationException)
            && !(t instanceof SaaSSystemException)) {
        if (t instanceof EJBException && t.getCause() instanceof Exception
                && (((EJBException) t).getCausedByException() != null)) {
            t = ((EJBException) t).getCausedByException();
        } else {
            t = t.getCause();
        }
    }
    if (t instanceof SaaSApplicationException) {
        return (SaaSApplicationException) t;
    }
    return null;
}
 
Example 22
Project: oscm   File: AccountServiceBeanPermissionIT.java   View source code 6 votes vote down vote up
@Test
public void updateCustomerDiscount_asBroker() throws Exception {
    // given
    container.login(givenBroker().getKey(),
            UserRoleType.BROKER_MANAGER.name());

    // when
    try {
        as.updateCustomerDiscount(new VOOrganization());
        fail();
    } catch (EJBException e) {

        // then
        assertTrue(e.getCausedByException() instanceof EJBAccessException);
    }
}
 
Example 23
Project: oscm   File: AccountServiceBeanPermissionIT.java   View source code 6 votes vote down vote up
@Test
public void getCustomerPaymentConfiguration_asBroker() throws Exception {
    // given
    container.login(givenBroker().getKey(),
            UserRoleType.BROKER_MANAGER.name());

    try {
        // when
        as.getCustomerPaymentConfiguration();
        fail();
    } catch (EJBException e) {

        // then
        assertTrue(e.getCausedByException() instanceof EJBAccessException);
    }
}
 
Example 24
Project: oscm   File: ADMUMStartup.java   View source code 6 votes vote down vote up
/**
 * Checks the currently existing configuration settings. If a mandatory
 * setting is not present, an exception will be logged. It also checks for
 * the setting of the node name.
 */
private void checkSettings() {
    ConfigurationKey[] keys = ConfigurationKey.values();
    for (ConfigurationKey key : keys) {
        if (key.isMandatory()) {
            try {
                cs.getConfigurationSetting(key,
                        Configuration.GLOBAL_CONTEXT);
            } catch (EJBException e) {
                // will always log to the application server log file
                logger.logError(Log4jLogger.SYSTEM_LOG, e,
                        LogMessageIdentifier.ERROR_MANDATORY_PROPERTY_NOT_SET,
                        key.getKeyName());
            }
        }
    }

    // check if the node name is configured
    String nodeName = cs.getNodeName();
    if (nodeName == null) {
        logger.logError(
                LogMessageIdentifier.ERROR_MANDATORY_SETTING_OF_NODE_NOT_SET);
    }
}
 
Example 25
Project: oscm   File: PricingServiceBeanContainerIT.java   View source code 6 votes vote down vote up
@Test
public void getPartnerRevenueSharesForMarketplace_invalidRole()
        throws Exception {

    // given
    container.login(mpOwnerUserKey, UserRoleType.TECHNOLOGY_MANAGER.name());

    // when
    try {
        pricingService.getPartnerRevenueSharesForMarketplace(MARKETPLACEID);
        fail();
    } catch (EJBException e) {

        // then
        assertTrue(e.getCausedByException() instanceof EJBAccessException);
    }
}
 
Example 26
Project: oscm   File: ExceptionHandler.java   View source code 6 votes vote down vote up
/**
 * 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 27
Project: oscm   File: TimerServiceBean2Test.java   View source code 6 votes vote down vote up
@Test(expected = ValidationException.class)
public void initTimers_nextExpirationDateNegative()
        throws ValidationException {

    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_ORGANIZATION,
            "9223372036854775807");

    tm.initTimers();
}
 
Example 28
Project: oscm   File: ServiceProvisioningServiceBeanCopyIT.java   View source code 6 votes vote down vote up
private void validateCatalogEntry(final VOServiceDetails template,
        final VOServiceDetails copy) throws Exception {
    try {
        runTX(new Callable<Void>() {

            @Override
            public Void call() throws Exception {
                Product c1 = dataManager.getReference(Product.class,
                        template.getKey());
                Product c2 = dataManager.getReference(Product.class,
                        copy.getKey());
                assertEquals(1, c1.getCatalogEntries().size());
                assertEquals(1, c2.getCatalogEntries().size());
                CatalogEntry cCe1 = c1.getCatalogEntries().get(0);
                CatalogEntry cCe2 = c2.getCatalogEntries().get(0);
                assertTrue(cCe1.isAnonymousVisible() == cCe2
                        .isAnonymousVisible());
                assertTrue(cCe1.isVisibleInCatalog() == cCe2
                        .isVisibleInCatalog());
                return null;
            }
        });
    } catch (EJBException e) {
        throw e.getCausedByException();
    }
}
 
Example 29
Project: oscm   File: SubscriptionServiceBeanCustomerSubscriptionsIT.java   View source code 5 votes vote down vote up
@Test
public void getSubscriptionIdentifiers_NotAuthorized() throws Exception {
    // given
    container.login(brokerUserKey, ROLE_TECHNOLOGY_MANAGER);
    try {
        // when
        subscriptionSvc.getSubscriptionIdentifiers();
        fail();
    } catch (EJBException ex) {
        // then
        assertTrue(ex.getCause() instanceof EJBAccessException);
    }
}
 
Example 30
Project: oscm   File: TransactionInvocationHandlersTest.java   View source code 5 votes vote down vote up
@Test
public void testHANDLER_NOTX_Exception() throws Exception {
    final Exception root = new IOException();
    try {
        TransactionInvocationHandlers.HANDLER_NOTX.call(
                callableException(root), ctxStub);
        fail("Exception expected");
    } catch (EJBException ejbex) {
        assertSame(root, ejbex.getCause());
        assertSame(root, ejbex.getCausedByException());
    }
    assertEquals(Arrays.asList("call()"), stubCalls);
}
 
Example 31
Project: oscm   File: ProductReviewIT.java   View source code 5 votes vote down vote up
/**
 * <b>Testcase:</b> Modify an existing product review object <br>
 * <b>ExpectedResult:</b>
 * <ul>
 * <li>Modification is saved to the DB</li>
 * <li>History object created for the product review</li>
 * <li>PlatformUser unchanged</li>
 * <li>No new history object for PlatformUser</li>
 * </ul>
 * 
 * @throws Throwable
 */
@Test
public void testModify() throws Throwable {
    try {
        runTX(new Callable<Void>() {
            @Override
            public Void call() throws Exception {
                createProductReview();
                return null;
            }
        });
        runTX(new Callable<Void>() {
            @Override
            public Void call() throws Exception {
                doTestModify();
                return null;
            }
        });
        runTX(new Callable<Void>() {
            @Override
            public Void call() throws Exception {
                doTestModifyCheck();
                return null;
            }
        });
    } catch (EJBException e) {
        throw e.getCause();
    }
}
 
Example 32
Project: oscm   File: ProductIT.java   View source code 5 votes vote down vote up
/**
 * <b>Testcase:</b> Delete priceModel of an existing product object and add
 * a new PriceModel<br>
 * <b>ExpectedResult:</b>
 * <ul>
 * <li>Old PriceModel marked as deleted in the DB</li>
 * <li>History object created for the deleted object</li>
 * <li>New PriceModel stored in the DB</li>
 * <li>History object created for the new PriceModel</li>
 * </ul>
 * 
 * @throws Throwable
 */
@Test
public void testNewPriceModel() throws Throwable {
    try {
        runTX(new Callable<Void>() {
            @Override
            public Void call() throws Exception {
                doTestNewPriceModelPrepare();
                return null;
            }
        });
        runTX(new Callable<Void>() {
            @Override
            public Void call() throws Exception {
                doTestNewPriceModel();
                return null;
            }
        });
        runTX(new Callable<Void>() {
            @Override
            public Void call() {
                doTestNewPriceModelCheck();
                return null;
            }
        });
    } catch (EJBException e) {
        throw e.getCause();
    }
}
 
Example 33
Project: oscm   File: SubscriptionIT.java   View source code 5 votes vote down vote up
/**
 * <b>Testcase:</b> Modify an existing Subscription object <br>
 * <b>ExpectedResult:</b>
 * <ul>
 * <li>Modification is saved to the DB</li>
 * <li>History object created for the subscription</li>
 * <li>No history object created for the priceModel (unchanged)</li>
 * <li>No new history object for UsageLicense (unchanged)</li>
 * </ul>
 * 
 * @throws Throwable
 */
@Test
public void testModifySubscription() throws Throwable {
    try {
        runTX(new Callable<Void>() {
            @Override
            public Void call() throws Exception {
                doTestModifySubPrepare();
                return null;
            }
        });
        runTX(new Callable<Void>() {
            @Override
            public Void call() throws Exception {
                doTestModifySub();
                return null;
            }
        });
        runTX(new Callable<Void>() {
            @Override
            public Void call() throws Exception {
                doTestModifySubCheck();
                return null;
            }
        });
    } catch (EJBException e) {
        throw e.getCause();
    }
}
 
Example 34
Project: oscm   File: MarketplaceServiceBeanGetMarketplaceAndOrganizationIT.java   View source code 5 votes vote down vote up
@Test(expected = ObjectNotFoundException.class)
public void getMarketplacesForService_SvcNotFound() throws Exception {
    VOService svc = new VOService();
    svc.setServiceId("UNKNOWN_SVC_ID");
    try {
        container.login(supplier1Key, ROLE_SERVICE_MANAGER);
        marketplaceService.getMarketplacesForService(svc);
    } catch (EJBException e) {
        throw e.getCausedByException();
    }
}
 
Example 35
Project: tap17-muggl-javaee   File: RequestBean.java   View source code 5 votes vote down vote up
public List<CustomerOrder> getOrders() {
    try {
        return (List<CustomerOrder>) em.createNamedQuery("findAllOrders").getResultList();
    } catch (Exception e) {
        throw new EJBException(e.getMessage());
    }
}
 
Example 36
Project: oscm   File: MarketplaceServiceManagePartnerBeanRolesIT.java   View source code 5 votes vote down vote up
@Test
public void updateMarketplace_Admin() throws Exception {
    container.login(user.getKey(), ROLE_ORGANIZATION_ADMIN);
    try {
        service.updateMarketplace(null, null, null);
        fail();
    } catch (EJBException ex) {
        assertTrue(ex.getCause() instanceof EJBAccessException);
    }
}
 
Example 37
Project: oscm   File: PriceModelIT.java   View source code 5 votes vote down vote up
@Test(expected = ObjectNotFoundException.class)
public void testDeleteWithSteppedPrice() throws Exception {
    runTX(new Callable<Void>() {
        public Void call() throws Exception {
            doTestAdd();
            return null;
        }
    });
    final SteppedPrice sp = addSteppedPrice();
    runTX(new Callable<Void>() {
        public Void call() throws Exception {
            PriceModel pm = mgr.getReference(PriceModel.class, models
                    .get(0).getKey());
            mgr.remove(pm.getProduct());
            return null;
        }
    });
    try {
        runTX(new Callable<Void>() {
            public Void call() throws Exception {
                mgr.getReference(SteppedPrice.class, sp.getKey());
                return null;
            }
        });
    } catch (EJBException e) {
        throw e.getCausedByException();
    }
}
 
Example 38
Project: oscm   File: BillingServiceGetShareDataIT.java   View source code 5 votes vote down vote up
@Test(expected = org.oscm.internal.types.exception.IllegalArgumentException.class)
public void getRevenueShareData_NoToDate() throws Exception {
    // given
    container.login(brokerUser.getKey(), ROLE_SERVICE_MANAGER);

    // when
    try {
        bs.getRevenueShareData(Long.valueOf(PERIOD_START_MONTH1), null,
                BillingSharesResultType.BROKER);
    } catch (EJBException ex) {
        // then
        throw ex.getCausedByException();
    }
}
 
Example 39
Project: oscm   File: ServiceProvisioningPotentialCompatibleServicesIT.java   View source code 5 votes vote down vote up
@Test(expected = EJBAccessException.class)
public void getPotentialCompatibleServices_OrganizationAdmin()
        throws Exception {
    container.login(userKey, UserRoleType.ORGANIZATION_ADMIN.name());
    try {
        sps.getPotentialCompatibleServices(null);
    } catch (EJBException e) {
        throw e.getCausedByException();
    }
}
 
Example 40
Project: oscm   File: SessionServiceBeanIT.java   View source code 5 votes vote down vote up
@Test(expected = EJBException.class)
public void testDeletePlatformSession() throws Exception {
    String sessionid = "sessionId";
    testPlatformSession();
    sessionMgmt.deletePlatformSession(sessionid);

    sessionMgmtLocal.getPlatformSessionForSessionId(sessionid);
}