Search in sources :

Example 1 with MemoryGlobalLocker

use of org.killbill.commons.locker.memory.MemoryGlobalLocker in project killbill by killbill.

the class UtilTestSuiteWithEmbeddedDB method beforeClass.

@BeforeClass(groups = "slow")
public void beforeClass() throws Exception {
    final Injector g = Guice.createInjector(Stage.PRODUCTION, new TestUtilModuleWithEmbeddedDB(configSource));
    g.injectMembers(this);
    if (DBEngine.MYSQL.equals(helper.getDBEngine())) {
        Assert.assertTrue(locker instanceof MySqlGlobalLocker);
    } else if (DBEngine.POSTGRESQL.equals(helper.getDBEngine())) {
        Assert.assertTrue(locker instanceof PostgreSQLGlobalLocker);
    } else {
        Assert.assertTrue(locker instanceof MemoryGlobalLocker);
    }
    Assert.assertTrue(locker.isFree("a", "b"));
}
Also used : TestUtilModuleWithEmbeddedDB(org.killbill.billing.util.glue.TestUtilModuleWithEmbeddedDB) MemoryGlobalLocker(org.killbill.commons.locker.memory.MemoryGlobalLocker) Injector(com.google.inject.Injector) PostgreSQLGlobalLocker(org.killbill.commons.locker.postgresql.PostgreSQLGlobalLocker) MySqlGlobalLocker(org.killbill.commons.locker.mysql.MySqlGlobalLocker) BeforeClass(org.testng.annotations.BeforeClass)

Example 2 with MemoryGlobalLocker

use of org.killbill.commons.locker.memory.MemoryGlobalLocker in project killbill by killbill.

the class TestPaymentOperation method setUp.

private void setUp(final PaymentPluginStatus paymentPluginStatus) throws Exception {
    final GlobalLocker locker = new MemoryGlobalLocker();
    final PluginDispatcher<OperationResult> paymentPluginDispatcher = new PluginDispatcher<OperationResult>(1, paymentExecutors);
    paymentStateContext = new PaymentStateContext(true, UUID.randomUUID(), null, null, UUID.randomUUID().toString(), UUID.randomUUID().toString(), TransactionType.CAPTURE, Mockito.mock(Account.class), UUID.randomUUID(), new BigDecimal("192.3920111"), Currency.BRL, null, null, false, null, ImmutableList.<PluginProperty>of(), internalCallContext, callContext);
    final PaymentMethodModelDao paymentMethodModelDao = new PaymentMethodModelDao(paymentStateContext.getPaymentMethodId(), UUID.randomUUID().toString(), clock.getUTCNow(), clock.getUTCNow(), paymentStateContext.getAccount().getId(), MockPaymentProviderPlugin.PLUGIN_NAME, true);
    final PaymentDao paymentDao = Mockito.mock(PaymentDao.class);
    Mockito.when(paymentDao.getPaymentMethod(paymentStateContext.getPaymentMethodId(), internalCallContext)).thenReturn(paymentMethodModelDao);
    final PaymentPluginServiceRegistration paymentPluginServiceRegistration = new PaymentPluginServiceRegistration(paymentDao, registry);
    final PaymentAutomatonDAOHelper daoHelper = new PaymentAutomatonDAOHelper(paymentStateContext, clock.getUTCNow(), paymentDao, paymentPluginServiceRegistration, internalCallContext, eventBus, paymentSMHelper);
    paymentOperation = new PaymentOperationTest(paymentPluginStatus, daoHelper, locker, paymentPluginDispatcher, paymentConfig, paymentStateContext);
}
Also used : GlobalLocker(org.killbill.commons.locker.GlobalLocker) MemoryGlobalLocker(org.killbill.commons.locker.memory.MemoryGlobalLocker) PaymentMethodModelDao(org.killbill.billing.payment.dao.PaymentMethodModelDao) OperationResult(org.killbill.automaton.OperationResult) BigDecimal(java.math.BigDecimal) PluginProperty(org.killbill.billing.payment.api.PluginProperty) MemoryGlobalLocker(org.killbill.commons.locker.memory.MemoryGlobalLocker) PluginDispatcher(org.killbill.billing.payment.dispatcher.PluginDispatcher) PaymentPluginServiceRegistration(org.killbill.billing.payment.core.PaymentPluginServiceRegistration) PaymentDao(org.killbill.billing.payment.dao.PaymentDao)

Aggregations

MemoryGlobalLocker (org.killbill.commons.locker.memory.MemoryGlobalLocker)2 Injector (com.google.inject.Injector)1 BigDecimal (java.math.BigDecimal)1 OperationResult (org.killbill.automaton.OperationResult)1 PluginProperty (org.killbill.billing.payment.api.PluginProperty)1 PaymentPluginServiceRegistration (org.killbill.billing.payment.core.PaymentPluginServiceRegistration)1 PaymentDao (org.killbill.billing.payment.dao.PaymentDao)1 PaymentMethodModelDao (org.killbill.billing.payment.dao.PaymentMethodModelDao)1 PluginDispatcher (org.killbill.billing.payment.dispatcher.PluginDispatcher)1 TestUtilModuleWithEmbeddedDB (org.killbill.billing.util.glue.TestUtilModuleWithEmbeddedDB)1 GlobalLocker (org.killbill.commons.locker.GlobalLocker)1 MySqlGlobalLocker (org.killbill.commons.locker.mysql.MySqlGlobalLocker)1 PostgreSQLGlobalLocker (org.killbill.commons.locker.postgresql.PostgreSQLGlobalLocker)1 BeforeClass (org.testng.annotations.BeforeClass)1