Ejemplo n.º 1
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();
 }
Ejemplo n.º 2
0
  @Test
  public void testUnmodifibleList() throws Exception {
    BufferManager bm = BufferManagerFactory.getStandaloneBufferManager();
    final ExecutionFactory<Object, Object> ef =
        new ExecutionFactory<Object, Object>() {
          @Override
          public boolean isSourceRequired() {
            return false;
          }

          @Override
          public ResultSetExecution createResultSetExecution(
              QueryExpression command,
              ExecutionContext executionContext,
              RuntimeMetadata metadata,
              Object connection)
              throws TranslatorException {
            List<String> list1 = Collections.singletonList("1");
            final Iterator<List<String>> iter = Arrays.asList(list1).iterator();
            return new ResultSetExecution() {

              @Override
              public void execute() throws TranslatorException {}

              @Override
              public void close() {}

              @Override
              public void cancel() throws TranslatorException {}

              @Override
              public List<?> next() throws TranslatorException, DataNotAvailableException {
                if (iter.hasNext()) {
                  return iter.next();
                }
                return null;
              }
            };
          }
        };
    ConnectorManager cm =
        new ConnectorManager("FakeConnector", "FakeConnector") { // $NON-NLS-1$ //$NON-NLS-2$
          public ExecutionFactory getExecutionFactory() {
            return ef;
          }

          public Object getConnectionFactory() {
            return null;
          }
        };
    cm.start();
    AtomicRequestMessage requestMsg = createNewAtomicRequestMessage(1, 1);
    requestMsg.setCommand(
        helpGetCommand("SELECT intkey FROM bqt1.smalla", EXAMPLE_BQT)); // $NON-NLS-1$
    requestMsg.setBufferManager(bm);
    ConnectorWorkItem cwi = new ConnectorWorkItem(requestMsg, cm);
    cwi.execute();
    AtomicResultsMessage message = cwi.more();
    List[] results = message.getResults();
    assertEquals(1, results.length);
    List<?> tuple = results[0];
    assertEquals(1, tuple.get(0));
    assertEquals(1, message.getFinalRow());
  }
Ejemplo n.º 3
0
  @Test
  public void testLobs() throws Exception {
    BufferManager bm = BufferManagerFactory.getStandaloneBufferManager();
    final ExecutionFactory<Object, Object> ef =
        new ExecutionFactory<Object, Object>() {
          @Override
          public boolean isSourceRequired() {
            return false;
          }

          @Override
          public ResultSetExecution createResultSetExecution(
              QueryExpression command,
              ExecutionContext executionContext,
              RuntimeMetadata metadata,
              Object connection)
              throws TranslatorException {
            return new ResultSetExecution() {

              private boolean returned;

              @Override
              public void execute() throws TranslatorException {}

              @Override
              public void close() {}

              @Override
              public void cancel() throws TranslatorException {}

              @Override
              public List<?> next() throws TranslatorException, DataNotAvailableException {
                if (returned) {
                  return null;
                }
                returned = true;
                return Arrays.asList(AutoGenDataService.CLOB_VAL);
              }
            };
          }
        };
    ConnectorManager cm =
        new ConnectorManager("FakeConnector", "FakeConnector") { // $NON-NLS-1$ //$NON-NLS-2$
          public ExecutionFactory getExecutionFactory() {
            return ef;
          }

          public Object getConnectionFactory() {
            return null;
          }
        };
    cm.start();
    ef.setCopyLobs(true);
    AtomicRequestMessage requestMsg = createNewAtomicRequestMessage(1, 1);
    requestMsg.setCommand(
        helpGetCommand("SELECT CLOB_COLUMN FROM LOB_TESTING_ONE", EXAMPLE_BQT)); // $NON-NLS-1$
    requestMsg.setBufferManager(bm);
    ConnectorWorkItem cwi = new ConnectorWorkItem(requestMsg, cm);
    cwi.execute();
    AtomicResultsMessage message = cwi.more();
    List[] resutls = message.getResults();

    List<?> tuple = resutls[0];
    ClobType clob = (ClobType) tuple.get(0);
    assertEquals(StorageMode.MEMORY, InputStreamFactory.getStorageMode(clob));
    assertTrue(message.supportsImplicitClose());

    ef.setCopyLobs(false);
    cwi = new ConnectorWorkItem(requestMsg, cm);
    cwi.execute();
    message = cwi.more();
    resutls = message.getResults();

    tuple = resutls[0];
    clob = (ClobType) tuple.get(0);
    assertEquals(StorageMode.OTHER, InputStreamFactory.getStorageMode(clob));
    assertFalse(message.supportsImplicitClose());
  }