Exemplo n.º 1
0
  @Ignore
  @Test(expected = TranslatorException.class)
  public void testIsImmutablePropertyFails() throws Exception {
    /*
     * Setup:
     *  1. requestMsg.isTransactional() must be TRUE
     *  2. manager.isXa() must be FALSE  ()
     *  3. command must NOT be a SELECT
     *  4. Then, set isImmutable to FALSE, and we should FAIL
     */
    ConnectorManager cm = TestConnectorManager.getConnectorManager();
    ((FakeConnector) cm.getExecutionFactory()).setImmutable(false);

    // command must not be a SELECT
    Command command =
        helpGetCommand(
            "update bqt1.smalla set stringkey = 1 where stringkey = 2", EXAMPLE_BQT); // $NON-NLS-1$
    AtomicRequestMessage requestMsg = createNewAtomicRequestMessage(1, 1);
    requestMsg.setCommand(command);

    // To make the AtomicRequestMessage transactional, construct your own
    requestMsg.setTransactionContext(
        new TransactionContext() {
          @Override
          public Xid getXid() {
            return Mockito.mock(Xid.class);
          }
        });

    new ConnectorWorkItem(requestMsg, cm);
  }
Exemplo n.º 2
0
 @Test
 public void testSourceNotRequired() throws Exception {
   Command command =
       helpGetCommand(
           "update bqt1.smalla set stringkey = 1 where stringkey = 2", EXAMPLE_BQT); // $NON-NLS-1$
   AtomicRequestMessage arm = createNewAtomicRequestMessage(1, 1);
   arm.setCommand(command);
   ConnectorManager cm = TestConnectorManager.getConnectorManager();
   cm.getExecutionFactory().setSourceRequired(false);
   ConnectorWork synchConnectorWorkItem = cm.registerRequest(arm);
   synchConnectorWorkItem.execute();
   synchConnectorWorkItem.close();
   FakeConnector fc = (FakeConnector) cm.getExecutionFactory();
   assertEquals(1, fc.getConnectionCount());
   assertEquals(1, fc.getCloseCount());
 }
Exemplo n.º 3
0
 @Test
 public void testConvertIn() throws Exception {
   Command command =
       helpGetCommand(
           "select intkey from bqt1.smalla where stringkey in ('1', '2')",
           EXAMPLE_BQT); //$NON-NLS-1$
   AtomicRequestMessage arm = createNewAtomicRequestMessage(1, 1);
   arm.setCommand(command);
   ConnectorManager cm = TestConnectorManager.getConnectorManager();
   cm.getExecutionFactory().setSourceRequired(false);
   ConnectorWork synchConnectorWorkItem = cm.registerRequest(arm);
   synchConnectorWorkItem.execute();
   synchConnectorWorkItem.close();
   FakeConnector fc = (FakeConnector) cm.getExecutionFactory();
   assertEquals(
       "SELECT SmallA.IntKey FROM SmallA WHERE SmallA.StringKey = '2' OR SmallA.StringKey = '1'",
       fc.getCommands().get(0).toString());
   assertEquals(1, fc.getConnectionCount());
   assertEquals(1, fc.getCloseCount());
 }
Exemplo n.º 4
0
 private AtomicResultsMessage helpExecuteUpdate(boolean batch, boolean single)
     throws Exception, Throwable {
   Command command =
       helpGetCommand(
           "update bqt1.smalla set stringkey = 1 where stringkey = 2", EXAMPLE_BQT); // $NON-NLS-1$
   if (batch) {
     command = new BatchedUpdateCommand(Arrays.asList(command, command));
   }
   AtomicRequestMessage arm = createNewAtomicRequestMessage(1, 1);
   arm.setCommand(command);
   ConnectorManager connectorManager = TestConnectorManager.getConnectorManager();
   ((FakeConnector) connectorManager.getExecutionFactory()).setReturnSingleUpdate(single);
   ConnectorWorkItem synchConnectorWorkItem = new ConnectorWorkItem(arm, connectorManager);
   synchConnectorWorkItem.execute();
   return synchConnectorWorkItem.more();
 }