Java 类javax.ejb.EJBTransactionRequiredException 实例源码

项目:oscm    文件:ServiceProvisioningPartnerServiceLocalBeanContainerIT.java   
@Test(expected = EJBTransactionRequiredException.class)
public void getTemplateProducts_NoTransaction() {
    // given
    // when
    localService.getTemplateProducts();
    // then EJBTransactionRequiredException happens
}
项目:oscm    文件:ServiceProvisioningPartnerServiceLocalBeanContainerIT.java   
@Test(expected = EJBTransactionRequiredException.class)
public void getProductsForVendor_NoTransaction() {
    // given
    // when
    localService.getProductsForVendor();
    // then EJBTransactionRequiredException happens
}
项目:development    文件:ServiceProvisioningPartnerServiceLocalBeanContainerIT.java   
@Test(expected = EJBTransactionRequiredException.class)
public void getTemplateProducts_NoTransaction() {
    // given
    // when
    localService.getTemplateProducts();
    // then EJBTransactionRequiredException happens
}
项目:development    文件:ServiceProvisioningPartnerServiceLocalBeanContainerIT.java   
@Test(expected = EJBTransactionRequiredException.class)
public void getProductsForVendor_NoTransaction() {
    // given
    // when
    localService.getProductsForVendor();
    // then EJBTransactionRequiredException happens
}
项目:tomee    文件:TransactionAttributesTest.java   
private void assertAttribute(final String attribute, final Method method) throws Exception {
    final MethodTransactionInfo info = (MethodTransactionInfo) attributes.get(method);
    assertEquals(method.toString(), attribute, info.transAttribute);

    try {
        final Object[] args = new Object[method.getParameterTypes().length];
        final Object result = method.invoke(bean, args);
        assertEquals(attribute, result);
    } catch (final InvocationTargetException e) {
        assertEquals(attribute, "Mandatory");
        assertTrue(e.getTargetException() instanceof EJBTransactionRequiredException);
    }
}
项目:oscm    文件:TransactionInvocationHandlersTest.java   
@Test(expected = EJBTransactionRequiredException.class)
public void testMANDATORY_NoTx() throws Exception {
    TransactionInvocationHandlers.TX_MANDATORY.call(
            callableReturns(new Object()), ctxStub);
}
项目:oscm    文件:TransactionInvocationHandlers.java   
public Object call(Callable<Object> callable, IInvocationCtx ctx)
        throws Exception {
    throw new EJBTransactionRequiredException(
            "Transaction required (MANDATORY).");
}
项目:oscm    文件:MarketplaceServiceLocalBeanQueryIT.java   
@Test(expected = EJBTransactionRequiredException.class)
public void getAllMarketplace_TransactionMandatory() {
    marketplaceLocalService.getAllMarketplaces();
}
项目:oscm    文件:TransactionInvocationHandlersTest.java   
@Test(expected = EJBTransactionRequiredException.class)
public void testMANDATORY_NoTx() throws Exception {
    TransactionInvocationHandlers.TX_MANDATORY.call(
            callableReturns(new Object()), ctxStub);
}
项目:development    文件:TransactionInvocationHandlersTest.java   
@Test(expected = EJBTransactionRequiredException.class)
public void testMANDATORY_NoTx() throws Exception {
    TransactionInvocationHandlers.TX_MANDATORY.call(
            callableReturns(new Object()), ctxStub);
}
项目:development    文件:TransactionInvocationHandlers.java   
public Object call(Callable<Object> callable, IInvocationCtx ctx)
        throws Exception {
    throw new EJBTransactionRequiredException(
            "Transaction required (MANDATORY).");
}
项目:development    文件:MarketplaceServiceLocalBeanQueryIT.java   
@Test(expected = EJBTransactionRequiredException.class)
public void getAllMarketplace_TransactionMandatory() {
    marketplaceLocalService.getAllMarketplaces();
}
项目:development    文件:TransactionInvocationHandlersTest.java   
@Test(expected = EJBTransactionRequiredException.class)
public void testMANDATORY_NoTx() throws Exception {
    TransactionInvocationHandlers.TX_MANDATORY.call(
            callableReturns(new Object()), ctxStub);
}
项目:training    文件:TransactionExerciseTest.java   
@Test(expected = EJBTransactionRequiredException.class)
public void testPersistWithNoTx() {
    employeeDAO.persist(new Employee());
}
项目:tomee    文件:BaseEjbProxyHandler.java   
/**
 * Renamed method so it shows up with a much more understandable purpose as it
 * will be the top element in the stacktrace
 *
 * @param e        Throwable
 * @param method   Method
 * @param interfce Class
 */
protected Throwable convertException(Throwable e, final Method method, final Class interfce) {
    final boolean rmiRemote = Remote.class.isAssignableFrom(interfce);
    if (e instanceof TransactionRequiredException) {
        if (!rmiRemote && interfaceType.isBusiness()) {
            return new EJBTransactionRequiredException(e.getMessage()).initCause(getCause(e));
        } else if (interfaceType.isLocal()) {
            return new TransactionRequiredLocalException(e.getMessage()).initCause(getCause(e));
        } else {
            return e;
        }
    }
    if (e instanceof TransactionRolledbackException) {
        if (!rmiRemote && interfaceType.isBusiness()) {
            return new EJBTransactionRolledbackException(e.getMessage()).initCause(getCause(e));
        } else if (interfaceType.isLocal()) {
            return new TransactionRolledbackLocalException(e.getMessage()).initCause(getCause(e));
        } else {
            return e;
        }
    }
    if (e instanceof NoSuchObjectException) {
        if (!rmiRemote && interfaceType.isBusiness()) {
            return new NoSuchEJBException(e.getMessage()).initCause(getCause(e));
        } else if (interfaceType.isLocal()) {
            return new NoSuchObjectLocalException(e.getMessage()).initCause(getCause(e));
        } else {
            return e;
        }
    }
    if (e instanceof AccessException) {
        if (!rmiRemote && interfaceType.isBusiness()) {
            return new AccessLocalException(e.getMessage()).initCause(getCause(e));
        } else if (interfaceType.isLocal()) {
            return new AccessLocalException(e.getMessage()).initCause(getCause(e));
        } else {
            return e;
        }
    }
    if (e instanceof RemoteException) {
        if (!rmiRemote && interfaceType.isBusiness()) {
            return new EJBException(e.getMessage()).initCause(getCause(e));
        } else if (interfaceType.isLocal()) {
            return new EJBException(e.getMessage()).initCause(getCause(e));
        } else {
            return e;
        }
    }

    for (final Class<?> type : method.getExceptionTypes()) {
        if (type.isAssignableFrom(e.getClass())) {
            return e;
        }
    }

    // Exception is undeclared
    // Try and find a runtime exception in there
    while (e.getCause() != null && !(e instanceof RuntimeException)) {
        e = e.getCause();
    }
    return e;
}