Examples of LobChunk


Examples of org.teiid.client.lob.LobChunk

public class TestByteLobChunk extends TestCase {

    public void testGetBytes() {
        String testString = "This is test string for testing ByteLobChunk"; //$NON-NLS-1$
        LobChunk chunk = new LobChunk(testString.getBytes(), false);       
        assertEquals(testString, new String(chunk.getBytes()));
        assertFalse(chunk.isLast());
    }
View Full Code Here

Examples of org.teiid.client.lob.LobChunk

        assertFalse(chunk.isLast());
    }
   
    public void testSerialization() throws Exception {
      String testString = "This is test string for testing ByteLobChunk"; //$NON-NLS-1$
        LobChunk chunk = new LobChunk(testString.getBytes(), true);       
       
        LobChunk result = UnitTestUtil.helpSerialize(chunk);
        assertTrue(Arrays.equals(chunk.getBytes(), result.getBytes()));
        assertTrue(result.isLast());
    }
View Full Code Here

Examples of org.teiid.client.lob.LobChunk

public class TestLobChunkInputStream extends TestCase {

    public void testReadByteArray() throws Exception {
      LobChunkProducer chunkProducer = new LobChunkProducer() {
     
        Iterator<LobChunk> chuncks = Arrays.asList(new LobChunk("hello ".getBytes(), false), new LobChunk("world".getBytes(), true)).iterator(); //$NON-NLS-1$ //$NON-NLS-2$
       
      @Override
      public LobChunk getNextChunk() throws IOException {
        return chuncks.next();
      }
View Full Code Here

Examples of org.teiid.client.lob.LobChunk

    }
   
    @Test public void testXML() throws Exception {
      StatementImpl statement = createMockStatement(ResultSet.TYPE_FORWARD_ONLY);
      ResultsFuture<LobChunk> future = new ResultsFuture<LobChunk>();
      future.getResultsReceiver().receiveResults(new LobChunk("<a/>".getBytes(Charset.forName("UTF-8")), true));
      XMLType result = new XMLType();
      Mockito.stub(statement.getDQP().requestNextLobChunk(0, 0, result.getReferenceStreamId())).toReturn(future);
        ResultsMessage resultsMsg = new ResultsMessage();
        result.setEncoding("UTF-8");
        resultsMsg.setResults(new List<?>[] {Arrays.asList(result)});
View Full Code Here

Examples of org.teiid.client.lob.LobChunk

               
        // read contents from the stream
        byte[] cbuf = new byte[this.chunkSize];
        int read = this.stream.read(cbuf);
        if (read == -1) {
            return new LobChunk(new byte[0], true);
        }
        boolean isLast = false;
        if (read != this.chunkSize) {
            byte[] buf = new byte[read];
            System.arraycopy(cbuf, 0, buf, 0, read);
            cbuf = buf;
        }
        int next = this.stream.read();
        if (next == -1) {
          isLast = true;
        } else {
          this.stream.unread(next);
        }
        return new LobChunk(cbuf, isLast);
    }
View Full Code Here

Examples of org.teiid.client.lob.LobChunk

    this.parent = parent;
    this.streamRequestId = streamRequestId;
  }

  public void run() {
    LobChunk chunk = null;
    Exception ex = null;
    boolean shouldClose = false;
   
      try {
          // If no previous stream is not found for this request create one and
            // save for future
            if (stream == null) {
                stream = createLobStream(streamId);
            }
           
            // now get the chunk from stream
            chunk = stream.getNextChunk();
            shouldClose = chunk.isLast();
        } catch (TeiidComponentException e) {           
            LogManager.logWarning(org.teiid.logging.LogConstants.CTX_DQP, e, QueryPlugin.Util.getString("ProcessWorker.LobError")); //$NON-NLS-1$
            ex = e;
        } catch (IOException e) {
      ex = e;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.