Search in sources :

Example 16 with Holder

use of org.eclipse.scout.rt.platform.holders.Holder in project scout.rt by eclipse.

the class SelectIntoArrayTest method testSelectIntoListInHolder.

@Test
public void testSelectIntoListInHolder() throws Exception {
    SqlServiceMock sql = createSqlServiceMock(ROLES_DATA);
    // 
    Holder<List> rolesHolder = new Holder<List>(List.class);
    sql.selectInto("SELECT ROLE_NR FROM USER_ROLE WHERE USER_NR = :personNr INTO :{roles}", new NVPair("personNr", 63L), new NVPair("roles", rolesHolder));
    List r = rolesHolder.getValue();
    assertNotNull(r);
    assertEquals(3, r.size());
    assertEquals("first role", 3L, r.get(0));
    assertEquals("second role", 5L, r.get(1));
    assertEquals("third role", 7L, r.get(2));
}
Also used : SqlServiceMock(org.eclipse.scout.rt.server.jdbc.fixture.SqlServiceMock) BeanArrayHolder(org.eclipse.scout.rt.platform.holders.BeanArrayHolder) ITableBeanHolder(org.eclipse.scout.rt.platform.holders.ITableBeanHolder) Holder(org.eclipse.scout.rt.platform.holders.Holder) NVPair(org.eclipse.scout.rt.platform.holders.NVPair) List(java.util.List) Test(org.junit.Test)

Example 17 with Holder

use of org.eclipse.scout.rt.platform.holders.Holder in project scout.rt by eclipse.

the class AbstractDesktopTest method testDataChangedSimple.

@Test
public void testDataChangedSimple() {
    TestEnvironmentDesktop desktop = (TestEnvironmentDesktop) IDesktop.CURRENT.get();
    final Holder<Object[]> resultHolder = new Holder<Object[]>(Object[].class);
    desktop.addDataChangeListener(new DataChangeListener() {

        @Override
        public void dataChanged(Object... dataTypes) {
            resultHolder.setValue(dataTypes);
        }
    }, TEST_DATA_TYPE_1, TEST_DATA_TYPE_2);
    desktop.dataChanged(TEST_DATA_TYPE_1, TEST_DATA_TYPE_2);
    verifyDataChanged(resultHolder);
}
Also used : Holder(org.eclipse.scout.rt.platform.holders.Holder) DataChangeListener(org.eclipse.scout.rt.client.ui.DataChangeListener) TestEnvironmentDesktop(org.eclipse.scout.rt.client.testenvironment.ui.desktop.TestEnvironmentDesktop) Test(org.junit.Test)

Example 18 with Holder

use of org.eclipse.scout.rt.platform.holders.Holder in project scout.rt by eclipse.

the class TransactionProcessorTest method testRequiresNewWithoutExistingTransactionAndSuccess.

@Test
public void testRequiresNewWithoutExistingTransactionAndSuccess() throws Exception {
    final Holder<ITransaction> actualTransaction = new Holder<>();
    CallableChain<Object> chain = new CallableChain<>();
    chain.add(new TransactionProcessor<Object>().withCallerTransaction(null).withTransactionScope(TransactionScope.REQUIRES_NEW));
    Object result = chain.call(new Callable<Object>() {

        @Override
        public Object call() throws Exception {
            actualTransaction.setValue(ITransaction.CURRENT.get());
            return "result";
        }
    });
    // verify
    assertSame(m_transaction, actualTransaction.getValue());
    assertEquals("result", result);
    verify(m_transaction, times(1)).release();
    InOrder inOrder = Mockito.inOrder(m_transaction);
    inOrder.verify(m_transaction, times(1)).commitPhase1();
    inOrder.verify(m_transaction, times(1)).commitPhase2();
    inOrder.verify(m_transaction, never()).rollback();
    inOrder.verify(m_transaction, times(1)).release();
}
Also used : InOrder(org.mockito.InOrder) Holder(org.eclipse.scout.rt.platform.holders.Holder) CallableChain(org.eclipse.scout.rt.platform.chain.callable.CallableChain) AssertionException(org.eclipse.scout.rt.platform.util.Assertions.AssertionException) Test(org.junit.Test)

Example 19 with Holder

use of org.eclipse.scout.rt.platform.holders.Holder in project scout.rt by eclipse.

the class TransactionProcessorTest method testRequiresNewWithExistingTransactionAndSuccess.

@Test
public void testRequiresNewWithExistingTransactionAndSuccess() throws Exception {
    ITransaction callingTransaction = mock(ITransaction.class);
    final Holder<ITransaction> actualTransaction = new Holder<>();
    CallableChain<Object> chain = new CallableChain<>();
    chain.add(new TransactionProcessor<Object>().withCallerTransaction(callingTransaction).withTransactionScope(TransactionScope.REQUIRES_NEW));
    Object result = chain.call(new Callable<Object>() {

        @Override
        public Object call() throws Exception {
            actualTransaction.setValue(ITransaction.CURRENT.get());
            return "result";
        }
    });
    // verify
    assertSame(m_transaction, actualTransaction.getValue());
    assertEquals("result", result);
    verifyZeroInteractions(callingTransaction);
    verify(m_transaction, times(1)).release();
    InOrder inOrder = Mockito.inOrder(m_transaction);
    inOrder.verify(m_transaction, times(1)).commitPhase1();
    inOrder.verify(m_transaction, times(1)).commitPhase2();
    inOrder.verify(m_transaction, never()).rollback();
    inOrder.verify(m_transaction, times(1)).release();
}
Also used : InOrder(org.mockito.InOrder) Holder(org.eclipse.scout.rt.platform.holders.Holder) CallableChain(org.eclipse.scout.rt.platform.chain.callable.CallableChain) AssertionException(org.eclipse.scout.rt.platform.util.Assertions.AssertionException) Test(org.junit.Test)

Example 20 with Holder

use of org.eclipse.scout.rt.platform.holders.Holder in project scout.rt by eclipse.

the class TransactionProcessorTest method testRequiredWithoutExistingTransactionAndSuccess.

@Test
public void testRequiredWithoutExistingTransactionAndSuccess() throws Exception {
    final Holder<ITransaction> actualTransaction = new Holder<>();
    CallableChain<Object> chain = new CallableChain<>();
    chain.add(new TransactionProcessor<Object>().withCallerTransaction(null).withTransactionScope(TransactionScope.REQUIRED));
    Object result = chain.call(new Callable<Object>() {

        @Override
        public Object call() throws Exception {
            actualTransaction.setValue(ITransaction.CURRENT.get());
            return "result";
        }
    });
    // verify
    assertEquals("result", result);
    assertSame(m_transaction, actualTransaction.getValue());
    verify(m_transaction, times(1)).release();
    InOrder inOrder = Mockito.inOrder(m_transaction);
    inOrder.verify(m_transaction, times(1)).commitPhase1();
    inOrder.verify(m_transaction, times(1)).commitPhase2();
    inOrder.verify(m_transaction, never()).rollback();
    inOrder.verify(m_transaction, times(1)).release();
}
Also used : InOrder(org.mockito.InOrder) Holder(org.eclipse.scout.rt.platform.holders.Holder) CallableChain(org.eclipse.scout.rt.platform.chain.callable.CallableChain) AssertionException(org.eclipse.scout.rt.platform.util.Assertions.AssertionException) Test(org.junit.Test)

Aggregations

Holder (org.eclipse.scout.rt.platform.holders.Holder)28 Test (org.junit.Test)20 ProcessingException (org.eclipse.scout.rt.platform.exception.ProcessingException)6 IRunnable (org.eclipse.scout.rt.platform.util.concurrent.IRunnable)6 BlockingCountDownLatch (org.eclipse.scout.rt.testing.platform.util.BlockingCountDownLatch)6 IHolder (org.eclipse.scout.rt.platform.holders.IHolder)4 IPropertyHolder (org.eclipse.scout.rt.shared.data.form.IPropertyHolder)4 SocketTimeoutException (java.net.SocketTimeoutException)3 List (java.util.List)3 WebServiceException (javax.xml.ws.WebServiceException)3 JaxWsConsumerTestServicePortType (org.eclipse.scout.jaxws.consumer.jaxwsconsumertestservice.JaxWsConsumerTestServicePortType)3 IFormFieldVisitor (org.eclipse.scout.rt.client.ui.form.IFormFieldVisitor)3 IFormField (org.eclipse.scout.rt.client.ui.form.fields.IFormField)3 CallableChain (org.eclipse.scout.rt.platform.chain.callable.CallableChain)3 PlatformError (org.eclipse.scout.rt.platform.exception.PlatformError)3 AssertionException (org.eclipse.scout.rt.platform.util.Assertions.AssertionException)3 IExtensibleObject (org.eclipse.scout.rt.shared.extension.IExtensibleObject)3 InOrder (org.mockito.InOrder)3 InvocationHandler (java.lang.reflect.InvocationHandler)2 Method (java.lang.reflect.Method)2