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 } };
}
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");
}
}
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);
}
}
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);
}
}
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);
}
}
Aggregations