Java Code Examples for javax.ejb.EJBException#getCause()

The following examples show how to use javax.ejb.EJBException#getCause() . 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: ProductClassBridgeIT.java    From development with Apache License 2.0 6 votes vote down vote up
@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 2
Source File: MarketplaceIT.java    From development with Apache License 2.0 6 votes vote down vote up
/**
 * <b>Test case:</b> Check that at least one marketplace is defined in the
 * system and can be retrieved using a named query.<br>
 * 
 * @throws Throwable
 */
@Test
public void testOneGlobalExists() throws Throwable {
    try {
        runTX(new Callable<Void>() {
            public Void call() throws Exception {
                Marketplace marketplace = Marketplaces
                        .findOneGlobalMarketplace(mgr);
                Assert.assertNotNull("No marketplace found", marketplace);
                Assert.assertNotNull("No owner set",
                        marketplace.getOrganization());
                Assert.assertNotNull("Missing mp list", marketplace
                        .getOrganization().getMarketplaces());
                Assert.assertTrue("object relations incomplete",
                        marketplace.getOrganization().getMarketplaces()
                                .size() > 0);
                return null;
            }
        });
    } catch (EJBException e) {
        throw e.getCause();
    }
}
 
Example 3
Source File: ExceptionHandler.java    From development with Apache License 2.0 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 4
Source File: LandingpageServiceBeanIT.java    From development with Apache License 2.0 6 votes vote down vote up
@Test(expected = EJBAccessException.class)
public void resetLandingpage_invalidRole() throws Throwable {
    // given
    String invalidRole = UserRoleType.ORGANIZATION_ADMIN.name();
    container.login(mpOwnerUserKey, invalidRole);

    // when
    try {
        landingpageServiceLocal.resetLandingpage(MARKETPLACEID);
    } catch (EJBException e) {
        throw e.getCause();
    }

    // then
    fail();
}
 
Example 5
Source File: RevenueShareModelIT.java    From development with Apache License 2.0 6 votes vote down vote up
@Test
public void testModify() 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 6
Source File: ProductReviewIT.java    From development with Apache License 2.0 6 votes vote down vote up
/**
 * <b>Test case:</b> Add a new product review entry<br>
 * <b>ExpectedResult:</b>
 * <ul>
 * <li>The product review entry can be retrieved from DB and is identical to
 * the provided object</li>
 * <li>A history object is created for the product review entry</li>
 * </ul>
 * 
 * @throws Exception
 */
@Test
public void testAdd() 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 {
                doTestAddCheck();
                return null;
            }
        });
    } catch (EJBException e) {
        throw e.getCause();
    }
}
 
Example 7
Source File: OrganizationIT.java    From development with Apache License 2.0 6 votes vote down vote up
/**
 * <b>Testcase:</b> Add new Organization objects <br>
 * <b>ExpectedResult:</b>
 * <ul>
 * <li>All objects can be retrieved from DB and are identical to provided
 * Organization objects</li>
 * <li>Cascaded objects (i.e. PaymentInfo) is also stored</li>
 * <li>A history object is created for each organization 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>() {
            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 8
Source File: ProductClassBridgeIT.java    From development with Apache License 2.0 6 votes vote down vote up
@Test
public void test1() throws Throwable {
    try {
        runTX(new Callable<Void>() {
            public Void call() throws Exception {
                productKey = createProductAndExpectedFields().getKey();
                return null;
            }
        });
        runTX(new Callable<Void>() {
            public Void call() throws Exception {
                verifyIndexedFieldsForProduct(productKey);
                return null;
            }
        });
    } catch (EJBException e) {
        throw e.getCause();
    }
}
 
Example 9
Source File: PlatformUserIT.java    From development with Apache License 2.0 6 votes vote down vote up
/**
 * <b>Testcase:</b> Add new Platform user objects <br>
 * <b>ExpectedResult:</b>
 * <ul>
 * <li>All objects can be retrieved from DB and are identical to provided
 * Platform user objects</li>
 * <li>Relations to the organization are set (bidirectional)</li>
 * <li>A history object is created for each PlatformUser stored</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() throws Exception {
                doTestAddCheck();
                return null;
            }
        });
    } catch (EJBException e) {
        throw e.getCause();
    }
}
 
Example 10
Source File: ParameterDefinitionIT.java    From development with Apache License 2.0 6 votes vote down vote up
@Test
public void add() 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 11
Source File: ParameterDefinitionIT.java    From development with Apache License 2.0 6 votes vote down vote up
@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 12
Source File: MarketplaceIT.java    From development with Apache License 2.0 5 votes vote down vote up
@Test
public void testGetGlobalByOwner() throws Throwable {
    try {
        runTX(new Callable<Void>() {
            public Void call() throws Exception {
                Marketplace marketplace = Marketplaces
                        .findOneGlobalMarketplace(mgr);
                Assert.assertNotNull("No marketplace found", marketplace);
                Assert.assertNotNull("No owner set",
                        marketplace.getOrganization());

                Query query = mgr
                        .createNamedQuery("Marketplace.getByOwner");
                String oId = marketplace.getOrganization()
                        .getOrganizationId();
                query.setParameter("organizationId", oId);
                List<Marketplace> result = ParameterizedTypes.list(
                        query.getResultList(), Marketplace.class);
                Assert.assertNotNull("No marketplace found", result);
                Assert.assertTrue("No marketplace found", result.size() > 0);
                for (Marketplace mp : result) {
                    Assert.assertNotNull("No owner set",
                            mp.getOrganization());
                    Assert.assertEquals("Wrong owner - ", oId, mp
                            .getOrganization().getOrganizationId());
                }
                return null;
            }
        });
    } catch (EJBException e) {
        throw e.getCause();
    }
}
 
Example 13
Source File: CatalogEntryIT.java    From development with Apache License 2.0 5 votes vote down vote up
@Test
public void testModify() throws Throwable {
    try {
        runTX(new Callable<Void>() {
            @Override
            public Void call() throws Exception {
                doTestModifyPrepare();
                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 14
Source File: UserGroupToUserIT.java    From development with Apache License 2.0 5 votes vote down vote up
@Test
public void testDeleteByUserGroup() throws Throwable {
    try {
        runTX(new Callable<Void>() {
            @Override
            public Void call() throws Exception {
                doTestAdd();
                return null;
            }
        });
        runTX(new Callable<Void>() {
            @Override
            public Void call() throws Exception {
                doTestDeleteByUserGroup();
                return null;
            }
        });
        runTX(new Callable<Void>() {
            @Override
            public Void call() throws Exception {
                doTestDeleteCheckByUserGroup();
                return null;
            }
        });
    } catch (EJBException e) {
        throw e.getCause();
    }
}
 
Example 15
Source File: SearchServiceBeanListIT.java    From development with Apache License 2.0 5 votes vote down vote up
@Test(expected = IllegalArgumentException.class)
public void testGetServicesByCriteria_NullLocale() throws Throwable {
    container.login(customerUserKey, ROLE_ORGANIZATION_ADMIN);
    setLocaleCurrentUser("en", customerUserKey);
    try {
        search.getServicesByCriteria(supplier.getOrganizationId(), null,
                new ListCriteria());
    } catch (EJBException e) {
        throw e.getCause();
    }
    Assert.fail();
}
 
Example 16
Source File: ProductIT.java    From development with Apache License 2.0 5 votes vote down vote up
/**
 * <b>Testcase:</b> Modify an existing product object <br>
 * <b>ExpectedResult:</b>
 * <ul>
 * <li>Modification is saved to the DB</li>
 * <li>History object created for the product</li>
 * <li>priceModel unchanged</li>
 * <li>No new history object for PriceModel</li>
 * </ul>
 * 
 * @throws Throwable
 */
@Test
public void testModifyProduct() throws Throwable {
    try {
        runTX(new Callable<Void>() {
            @Override
            public Void call() throws Exception {
                doTestModifyProductPrepare("TP_ID_0");
                return null;
            }
        });
        runTX(new Callable<Void>() {
            @Override
            public Void call() {
                doTestModifyProduct();
                return null;
            }
        });
        runTX(new Callable<Void>() {
            @Override
            public Void call() {
                doTestModifyProductCheck();
                return null;
            }
        });
    } catch (EJBException e) {
        throw e.getCause();
    }
}
 
Example 17
Source File: SearchServiceBeanListIT.java    From development with Apache License 2.0 5 votes vote down vote up
@Test(expected = IllegalArgumentException.class)
public void testGetServicesByCriteria_NullMarketplaceId() throws Throwable {
    container.login(customerUserKey, ROLE_ORGANIZATION_ADMIN);
    setLocaleCurrentUser("en", customerUserKey);
    try {
        search.getServicesByCriteria(null, "en", new ListCriteria());
    } catch (EJBException e) {
        throw e.getCause();
    }
    Assert.fail();
}
 
Example 18
Source File: ProductReviewIT.java    From development with Apache License 2.0 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 19
Source File: SearchServiceBeanListIT.java    From development with Apache License 2.0 5 votes vote down vote up
@Test(expected = IllegalArgumentException.class)
public void testSearchServices_NullLocale() throws Throwable {
    try {
        search.searchServices(FUJITSU, null, "wicked_de");
    } catch (EJBException e) {
        throw e.getCause();
    }
    Assert.fail();
}
 
Example 20
Source File: SearchServiceBeanListIT.java    From development with Apache License 2.0 5 votes vote down vote up
@Test(expected = IllegalArgumentException.class)
public void testSearchServices_EmptyMarketplaceId() throws Throwable {
    try {
        search.searchServices("", "de", "wicked_de");
    } catch (EJBException e) {
        throw e.getCause();
    }
    Assert.fail();
}