Search in sources :

Example 1 with StringBufferInputStream

use of java.io.StringBufferInputStream in project jdk8u_jdk by JetBrains.

the class BaseRowSetTests method testAdvancedParameters.

/*
     * DataProvider used to set advanced parameters for types that are supported
     */
@DataProvider(name = "testAdvancedParameters")
private Object[][] testAdvancedParameters() throws SQLException {
    byte[] bytes = new byte[10];
    Ref aRef = new SerialRef(new StubRef("INTEGER", query));
    Array aArray = new SerialArray(new StubArray("INTEGER", new Object[1]));
    Blob aBlob = new SerialBlob(new StubBlob());
    Clob aClob = new SerialClob(new StubClob());
    Reader rdr = new StringReader(query);
    InputStream is = new StringBufferInputStream(query);
    ;
    brs = new StubBaseRowSet();
    brs.setBytes(1, bytes);
    brs.setAsciiStream(2, is, query.length());
    brs.setRef(3, aRef);
    brs.setArray(4, aArray);
    brs.setBlob(5, aBlob);
    brs.setClob(6, aClob);
    brs.setBinaryStream(7, is, query.length());
    brs.setUnicodeStream(8, is, query.length());
    brs.setCharacterStream(9, rdr, query.length());
    return new Object[][] { { 1, bytes }, { 2, is }, { 3, aRef }, { 4, aArray }, { 5, aBlob }, { 6, aClob }, { 7, is }, { 8, is }, { 9, rdr } };
}
Also used : SerialArray(javax.sql.rowset.serial.SerialArray) StubBlob(util.StubBlob) SerialBlob(javax.sql.rowset.serial.SerialBlob) Blob(java.sql.Blob) StringBufferInputStream(java.io.StringBufferInputStream) InputStream(java.io.InputStream) Reader(java.io.Reader) StringReader(java.io.StringReader) SerialBlob(javax.sql.rowset.serial.SerialBlob) StubClob(util.StubClob) StubBlob(util.StubBlob) SerialClob(javax.sql.rowset.serial.SerialClob) StubRef(util.StubRef) StubArray(util.StubArray) Array(java.sql.Array) SerialArray(javax.sql.rowset.serial.SerialArray) StubRef(util.StubRef) SerialRef(javax.sql.rowset.serial.SerialRef) Ref(java.sql.Ref) StringBufferInputStream(java.io.StringBufferInputStream) StringReader(java.io.StringReader) StubBaseRowSet(util.StubBaseRowSet) SerialRef(javax.sql.rowset.serial.SerialRef) Clob(java.sql.Clob) StubClob(util.StubClob) SerialClob(javax.sql.rowset.serial.SerialClob) StubArray(util.StubArray) DataProvider(org.testng.annotations.DataProvider)

Example 2 with StringBufferInputStream

use of java.io.StringBufferInputStream in project jdk8u_jdk by JetBrains.

the class OverflowInRead method main.

public static void main(String[] args) throws Exception {
    // s.length() > 33
    String s = "_123456789_123456789_123456789_123456789";
    try (StringBufferInputStream sbis = new StringBufferInputStream(s)) {
        int len1 = 33;
        byte[] buf1 = new byte[len1];
        if (sbis.read(buf1, 0, len1) != len1)
            throw new Exception("Expected to read " + len1 + " bytes");
        int len2 = Integer.MAX_VALUE - 32;
        byte[] buf2 = new byte[len2];
        int expLen2 = s.length() - len1;
        if (sbis.read(buf2, 0, len2) != expLen2)
            throw new Exception("Expected to read " + expLen2 + " bytes");
    }
}
Also used : StringBufferInputStream(java.io.StringBufferInputStream)

Example 3 with StringBufferInputStream

use of java.io.StringBufferInputStream in project geode by apache.

the class GemFireCacheImpl method initializeDeclarativeCache.

/**
   * Initializes the contents of this {@code Cache} according to the declarative caching XML file
   * specified by the given {@code DistributedSystem}. Note that this operation cannot be performed
   * in the constructor because creating regions in the cache, etc. uses the cache itself (which
   * isn't initialized until the constructor returns).
   *
   * @throws CacheXmlException If something goes wrong while parsing the declarative caching XML
   *         file.
   * @throws TimeoutException If a {@link Region#put(Object, Object)}times out while initializing
   *         the cache.
   * @throws CacheWriterException If a {@code CacheWriterException} is thrown while initializing the
   *         cache.
   * @throws RegionExistsException If the declarative caching XML file describes a region that
   *         already exists (including the root region).
   * @throws GatewayException If a {@code GatewayException} is thrown while initializing the cache.
   * 
   * @see #loadCacheXml
   */
private void initializeDeclarativeCache() throws TimeoutException, CacheWriterException, GatewayException, RegionExistsException {
    URL url = getCacheXmlURL();
    String cacheXmlDescription = this.cacheConfig.getCacheXMLDescription();
    if (url == null && cacheXmlDescription == null) {
        if (isClient()) {
            determineDefaultPool();
            initializeClientRegionShortcuts(this);
        } else {
            initializeRegionShortcuts(this);
        }
        initializePdxRegistry();
        readyDynamicRegionFactory();
        // nothing needs to be done
        return;
    }
    InputStream stream = null;
    try {
        logCacheXML(url, cacheXmlDescription);
        if (cacheXmlDescription != null) {
            if (logger.isTraceEnabled()) {
                logger.trace("initializing cache with generated XML: {}", cacheXmlDescription);
            }
            stream = new StringBufferInputStream(cacheXmlDescription);
        } else {
            stream = url.openStream();
        }
        loadCacheXml(stream);
    } catch (IOException ex) {
        throw new CacheXmlException(LocalizedStrings.GemFireCache_WHILE_OPENING_CACHE_XML_0_THE_FOLLOWING_ERROR_OCCURRED_1.toLocalizedString(url.toString(), ex));
    } catch (CacheXmlException ex) {
        CacheXmlException newEx = new CacheXmlException(LocalizedStrings.GemFireCache_WHILE_READING_CACHE_XML_0_1.toLocalizedString(url, ex.getMessage()));
        /*
       * TODO: why use setStackTrace and initCause? removal breaks several tests: OplogRVVJUnitTest,
       * NewDeclarativeIndexCreationJUnitTest CacheXml70DUnitTest, CacheXml80DUnitTest,
       * CacheXml81DUnitTest, CacheXmlGeode10DUnitTest RegionManagementDUnitTest
       */
        newEx.setStackTrace(ex.getStackTrace());
        newEx.initCause(ex.getCause());
        throw newEx;
    } finally {
        closeQuietly(stream);
    }
}
Also used : StringBufferInputStream(java.io.StringBufferInputStream) CacheXmlException(org.apache.geode.cache.CacheXmlException) ByteArrayInputStream(java.io.ByteArrayInputStream) StringBufferInputStream(java.io.StringBufferInputStream) InputStream(java.io.InputStream) IOException(java.io.IOException) URL(java.net.URL)

Example 4 with StringBufferInputStream

use of java.io.StringBufferInputStream in project cubrid-manager by CUBRID.

the class CUBRIDPreparedStatementProxyTest method methodSetBinaryStreamIntInputStream.

/**
	 * Test method for
	 * {@link com.cubrid.jdbc.proxy.driver.CUBRIDPreparedStatementProxy#setBinaryStream(int, java.io.InputStream)}
	 * .
	 */
public void methodSetBinaryStreamIntInputStream(CUBRIDPreparedStatementProxy pstmt) {
    String sql = "select * from " + testTableName + " where name = ?";
    CUBRIDPreparedStatementProxy ps = null;
    try {
        ps = (CUBRIDPreparedStatementProxy) conn.prepareStatement(sql);
        ps.setBinaryStream(5, new StringBufferInputStream("string buffer input stream"));
    } catch (SQLException e) {
        assertTrue(false);
    }
}
Also used : StringBufferInputStream(java.io.StringBufferInputStream) SQLException(java.sql.SQLException)

Example 5 with StringBufferInputStream

use of java.io.StringBufferInputStream in project cubrid-manager by CUBRID.

the class CUBRIDPreparedStatementProxyTest method methodSetAsciiStreamIntInputStreamLong.

/**
	 * Test method for
	 * {@link com.cubrid.jdbc.proxy.driver.CUBRIDPreparedStatementProxy#setAsciiStream(int, java.io.InputStream, long)}
	 * .
	 */
public void methodSetAsciiStreamIntInputStreamLong(CUBRIDPreparedStatementProxy pstmt) {
    String sql = "select * from " + testTableName + " where name = ?";
    CUBRIDPreparedStatementProxy ps = null;
    try {
        ps = (CUBRIDPreparedStatementProxy) conn.prepareStatement(sql);
        ps.setAsciiStream(1, new StringBufferInputStream("string buffer input string for long"), 3L);
    } catch (SQLException e) {
        assertTrue(false);
    }
}
Also used : StringBufferInputStream(java.io.StringBufferInputStream) SQLException(java.sql.SQLException)

Aggregations

StringBufferInputStream (java.io.StringBufferInputStream)34 Test (org.junit.Test)10 InputStream (java.io.InputStream)9 SQLException (java.sql.SQLException)6 IModelManager (org.eclipse.wst.sse.core.internal.provisional.IModelManager)5 IStructuredModel (org.eclipse.wst.sse.core.internal.provisional.IStructuredModel)5 BadLocationException (org.eclipse.jface.text.BadLocationException)3 IStructuredDocument (org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument)3 InputStreamBuilder (io.vertigo.dynamo.file.model.InputStreamBuilder)2 VFile (io.vertigo.dynamo.file.model.VFile)2 ByteArrayInputStream (java.io.ByteArrayInputStream)2 IOException (java.io.IOException)2 Instant (java.time.Instant)2 Matchers.anyString (org.mockito.Matchers.anyString)2 KettleException (org.pentaho.di.core.exception.KettleException)2 RepositoryMeta (org.pentaho.di.repository.RepositoryMeta)2 Element (org.w3c.dom.Element)2 Table (com.mapr.db.Table)1 Description (io.qameta.allure.Description)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1