java.io.StringBufferInputStream Java Examples

The following examples show how to use java.io.StringBufferInputStream. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MultipartMap.java    From openxds with Apache License 2.0 6 votes vote down vote up
/**
 * Used for testing and demonstration purposes.
 */
static public void main(String args[]) throws Exception, java.io.IOException {
    try {
        //String xx = "------=_Part_2_9110923.1073664290010\r\nContent-Type: text/plain\r\nContent-ID: urn:uuid:d4bfb124-7922-45bc-a03d-823351eed716\r\n\r\nhttp://ratbert.ncsl.nist.gov:8081/hl7services/transform.html\r\n------=_Part_2_9110923.1073664290010\r\nContent-Type: text/plain\r\nContent-ID: urn:uuid:45b90888-49c1-4b64-a8eb-e94f541368f0\r\n\r\nhttp://ratbert.ncsl.nist.gov:8081/hl7services/rawSQL.html\r\n------=_Part_2_9110923.1073664290010--\r\n";
        String xx = "------_Part_\r\nContent-Type: text/plain\r\nContent-ID: urn:uuid:d4bfb124-7922-45bc-a03d-823351eed716\r\n\r\nhttp://ratbert.ncsl.nist.gov:8081/hl7services/transform.html\r\n------_Part_\r\nContent-Type: text/plain\r\nContent-ID: urn:uuid:45b90888-49c1-4b64-a8eb-e94f541368f0\r\n\r\nhttp://ratbert.ncsl.nist.gov:8081/hl7services/rawSQL.html\r\n------_Part_--\r\n";
        StringBufferInputStream is = new StringBufferInputStream(xx);
        String contentType = "multipart/related; boundary=----_Part_";
        ByteArrayDataSource ds = new ByteArrayDataSource(is,  contentType);
        //ByteArrayDataSource ds = new ByteArrayDataSource();
        javax.mail.internet.MimeMultipart mp = new javax.mail.internet.MimeMultipart(ds);
        int i = mp.getCount();
    } catch (javax.mail.MessagingException me) {
        throw new Exception("messaging exception in parsing for MultipartMap");
    }
    System.out.println("Done");
}
 
Example #2
Source File: DellRestBridgeConfig.java    From onos with Apache License 2.0 6 votes vote down vote up
@Override
public void addPort(BridgeName bridgeName, String portName) {
    // bridgeName is not used
    checkNotNull(portName);
    portName = portNameForCli(portName);
    String portAddCommands = String.format(PORT_ADD_COMMANDS, portName);

    DriverHandler handler = handler();
    RestSBController controller = checkNotNull(handler.get(RestSBController.class));
    DeviceId deviceId = handler.data().deviceId();

    InputStream payload = new StringBufferInputStream(String.format(CONFIG_COMMANDS, portAddCommands));
    String resp = controller.post(deviceId, CLI_REQUEST, payload, MediaType.valueOf("*/*"), String.class);
    //TODO Parse resp and if error, return false
    log.info("{}", resp);
    return;
}
 
Example #3
Source File: DellRestOpenFlowControllerConfig.java    From onos with Apache License 2.0 6 votes vote down vote up
@Override
public void setControllers(List<ControllerInfo> controllers) {

    // Dell supports max 2 controllers per of-instance
    if (controllers.size() > MAX_CONTROLLERS) {
        log.warn("Cannot set more than 2 controllers.");
    }

    DriverHandler handler = handler();
    RestSBController controller = checkNotNull(handler.get(RestSBController.class));
    DeviceId deviceId = handler.data().deviceId();

    String controllerCommands = getControllerCommands(controllers).stream()
            .reduce(String::concat)
            .orElse("");

    InputStream payload = new StringBufferInputStream(String.format(SET_CONTROLLERS_XML, controllerCommands));
    String resp = controller.post(deviceId, CLI_REQUEST, payload, MediaType.valueOf("*/*"), String.class);
    log.info("{}", resp);
}
 
Example #4
Source File: DependencyTest.java    From groovy with Apache License 2.0 6 votes vote down vote up
public void testTransitiveDep(){
    cu.addSource("testTransitiveDep.gtest", new StringBufferInputStream(
            "class A1 {}\n" +
            "class A2 extends A1{}\n" +
            "class A3 extends A2{}\n"
    ));
    cu.compile(Phases.CLASS_GENERATION);
    cache.makeTransitiveHull();

    Set<String> dep = cache.get("A1");
    assertEquals(dep.size(),1);

    dep = cache.get("A2");
    assertEquals(dep.size(),2);
    assertTrue(dep.contains("A1"));

    dep = cache.get("A3");
    assertEquals(dep.size(),3);
    assertTrue(dep.contains("A1"));
    assertTrue(dep.contains("A2"));
}
 
Example #5
Source File: TreeApplet.java    From openbd-core with GNU General Public License v3.0 6 votes vote down vote up
private Vector getData(String a){
	//-- Put them together
	int x = 0;
	StringBuilder appletP	= new StringBuilder(128);
	String line	= thisApplet.getParameter("treedata" + x);
	while (line!=null){
		appletP.append( line.substring(1,line.length()-1) );
		x++;
		line	= thisApplet.getParameter("treedata" + x);
	}

	String appletParam	= appletP.toString();

	tags		= new Stack();
	params	= new Stack();
	StringBufferInputStream s = new StringBufferInputStream(appletParam);	

	try{
		parseXML(s);
	}catch(Throwable E){
		E.printStackTrace();
		return null;
	}

	return (Vector)params.peek();
}
 
Example #6
Source File: DomMatchersTest.java    From android-test with Apache License 2.0 6 votes vote down vote up
@Test
public void testWithBody_DocumentWithNoBody() throws Exception {
  Document documentWithNoBody =
      DocumentBuilderFactory.newInstance()
          .newDocumentBuilder()
          .parse(new StringBufferInputStream(HTML_NO_BODY));

  Matcher<Element> alwaysMatch =
      new TypeSafeMatcher<Element>() {
        @Override
        public void describeTo(Description description) {
          description.appendText("always a match");
        }

        @Override
        public boolean matchesSafely(Element element) {
          return true;
        }
      };
  assertFalse(withBody(alwaysMatch).matches(documentWithNoBody));
}
 
Example #7
Source File: OMSArchive.java    From webcurator with Apache License 2.0 5 votes vote down vote up
/**
 * @param targetInstanceOID The target instance oid 
 * @param SIP The METS xml structure for completion and archival
 * @param xAttributes Any extra attributes that may be required for archival (generally contains parameters for OMS meta-data)
 * @param files A list of files (@see org.webcurator.core.archive.ArchiveFile) to archive 
 * @return A unique archive identifier (IID returned form the OMS system)
 * @throws OMSArchiveException
 */
public String submitToArchive(String targetInstanceOID, String SIP, Map xAttributes, List<ArchiveFile> files) throws OMSUploadException{
	String IID = null;
	if(targetInstanceOID != null){
		OMSUploadUtil uploader = new OMSUploadUtil(targetInstanceOID);
		try {
			populateUploader(uploader, xAttributes);
			for(ArchiveFile f : files){
				FileInputStream fis = new FileInputStream(f.getFile());
				f.setMd5(uploader.uploadContent(fis,f.getFile().getName(),f.getFile().length()));
				fis.close();
			}
			// TODO finish SIP METS xml based on files
			String finalSIP = getFinalSIP(SIP, targetInstanceOID, files);
			InputStream sipIS = new StringBufferInputStream(finalSIP);
			String metsFileName = "METS-"+targetInstanceOID+".xml";
			uploader.uploadContent(sipIS,metsFileName,finalSIP.length());
			IID = uploader.uploadPub();
		} catch (FileNotFoundException fnfe) {
			// TODO Auto-generated catch block
			log.error("Content file not found",fnfe);
			throw new OMSUploadException(fnfe);
		} catch (OMSUploadException oue) {
			// TODO Auto-generated catch block
			log.error("Error submitting to archive",oue);
			throw new OMSUploadException(oue);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			log.error("Error submiting to archive",e);
			throw new OMSUploadException(e);
		}
	}
	return IID;
}
 
Example #8
Source File: MultipartMap.java    From openxds with Apache License 2.0 5 votes vote down vote up
static public void main(String args[]) throws Exception, java.io.IOException {
    try {
        //String xx = "------=_Part_2_9110923.1073664290010\r\nContent-Type: text/plain\r\nContent-ID: urn:uuid:d4bfb124-7922-45bc-a03d-823351eed716\r\n\r\nhttp://ratbert.ncsl.nist.gov:8081/hl7services/transform.html\r\n------=_Part_2_9110923.1073664290010\r\nContent-Type: text/plain\r\nContent-ID: urn:uuid:45b90888-49c1-4b64-a8eb-e94f541368f0\r\n\r\nhttp://ratbert.ncsl.nist.gov:8081/hl7services/rawSQL.html\r\n------=_Part_2_9110923.1073664290010--\r\n";
        String xx = "------_Part_\r\nContent-Type: text/plain\r\nContent-ID: urn:uuid:d4bfb124-7922-45bc-a03d-823351eed716\r\n\r\nhttp://ratbert.ncsl.nist.gov:8081/hl7services/transform.html\r\n------_Part_\r\nContent-Type: text/plain\r\nContent-ID: urn:uuid:45b90888-49c1-4b64-a8eb-e94f541368f0\r\n\r\nhttp://ratbert.ncsl.nist.gov:8081/hl7services/rawSQL.html\r\n------_Part_--\r\n";
        StringBufferInputStream is = new StringBufferInputStream(xx);
        String contentType = "multipart/related; boundary=----_Part_";
        ByteArrayDataSource ds = new ByteArrayDataSource(is,  contentType);
        //ByteArrayDataSource ds = new ByteArrayDataSource();
        javax.mail.internet.MimeMultipart mp = new javax.mail.internet.MimeMultipart(ds);
        int i = mp.getCount();
    } catch (javax.mail.MessagingException me) {
        throw new Exception("messaging exception in parsing for MultipartMap");
    }
    System.out.println("Done");
}
 
Example #9
Source File: WebResourceResponse.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
/**
 * Sets the input stream that provides the resource response's data. Callers
 * must implement {@link InputStream#read(byte[])}. {@link InputStream#close()}
 * will be called after the WebView has finished with the response.
 *
 * @param data the input stream that provides the resource response's data. Must not be a
 *             StringBufferInputStream.
 */
public void setData(InputStream data) {
    checkImmutable();
    // If data is (or is a subclass of) StringBufferInputStream
    if (data != null && StringBufferInputStream.class.isAssignableFrom(data.getClass())) {
        throw new IllegalArgumentException("StringBufferInputStream is deprecated and must " +
            "not be passed to a WebResourceResponse");
    }
    mInputStream = data;
}
 
Example #10
Source File: DependencyTest.java    From groovy with Apache License 2.0 5 votes vote down vote up
public void testDep(){
    cu.addSource("testDep.gtest", new StringBufferInputStream(
            "class C1 {}\n" +
            "class C2 {}\n" +
            "class C3 {}\n" +
            "class A1 {C1 x}\n" +
            "class A2 extends C2{}\n" +
            "class A3 {C1 foo(C2 x){new C3()}}\n"
    ));
    cu.compile(Phases.CLASS_GENERATION);
    assertEquals(cache.get("C1").size(),1);
    assertEquals(cache.get("C2").size(),1);
    assertEquals(cache.get("C3").size(),1);

    Set<String> dep = cache.get("A1");
    assertEquals(dep.size(),2);
    assertTrue(dep.contains("C1"));

    dep = cache.get("A2");
    assertEquals(dep.size(),2);
    assertTrue(dep.contains("C2"));

    dep = cache.get("A3");
    assertEquals(dep.size(),4);
    assertTrue(dep.contains("C1"));
    assertTrue(dep.contains("C2"));
    assertTrue(dep.contains("C3"));
}
 
Example #11
Source File: GridTestClassLoader.java    From ignite with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@SuppressWarnings("deprecation")
@Override public InputStream getResourceAsStream(String name) {
    if (rsrcs != null && rsrcs.containsKey(name))
        return new StringBufferInputStream(rsrcs.get(name));

    return getParent().getResourceAsStream(name);
}
 
Example #12
Source File: GamaGridFile.java    From gama with GNU General Public License v3.0 5 votes vote down vote up
public GamaGridReader fixFileHeader(IScope scope,final boolean fillBuffer) {
	final StringBuilder text = new StringBuilder();
	final String NL = System.getProperty("line.separator");

	try (Scanner scanner = new Scanner(getFile(scope))) {
		// final int cpt = 0;
		while (scanner.hasNextLine()) {
			final String line = scanner.nextLine();

			if (line.contains("dx")) {
				text.append(line.replace("dx", "cellsize") + NL);
			} else if (line.contains("dy")) {
				// continue;
			} else {
				text.append(line + NL);
			}

			// if (cpt < 10) {}
			// else {
			// text.append(line + NL);
			// }
		}
	} catch (final FileNotFoundException e2) {
		final GamaRuntimeException ex = GamaRuntimeException.error(
				"The format of " + getName(scope) + " is not correct. Error: " + e2.getMessage(), scope);
		ex.addContext("for file " + getPath(scope));
		throw ex;
	}

	text.append(NL);
	// fis = new StringBufferInputStream(text.toString());
	return new GamaGridReader(scope, new StringBufferInputStream(text.toString()), fillBuffer);
}
 
Example #13
Source File: TagSoupDocumentParser.java    From android-test with Apache License 2.0 5 votes vote down vote up
/** Parses the given html into an {@link Document}. */
// VisibleForTesting
public Document parse(String html) throws SAXException, IOException {
  checkNotNull(html);
  SAXSource in = new SAXSource(parser, new InputSource(new StringBufferInputStream(html)));
  DOMResult out = new DOMResult();
  try {
    transformerFactory.get().newTransformer().transform(in, out);
  } catch (TransformerException e) {
    throw new SAXException(e);
  }
  return (Document) out.getNode();
}
 
Example #14
Source File: CommandExecutionUtils.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
public InputStream getInputStream()
{
	try
	{
		// FIXME Use the encoding from the file/document!
		return new ByteArrayInputStream(string.getBytes(IOUtil.UTF_8));
	}
	catch (UnsupportedEncodingException e)
	{
		return new StringBufferInputStream(string);
	}
}
 
Example #15
Source File: Transform.java    From openxds with Apache License 2.0 5 votes vote down vote up
/**
 * Set the input as a String object.
 * @param input The input String.
 */
public void setInput(String input) {
	int display = 80;
	if (log.isDebugEnabled() ) {
		log.debug("Transform.setInput: " +
				input.substring(0,
						(input.length() < display) ? input.length() : display));
	}
	inputStream = new StringBufferInputStream(input);
	outputStream = new ByteArrayOutputStream();
}
 
Example #16
Source File: test_Validator.java    From xmlunit with Apache License 2.0 5 votes vote down vote up
private void passXMLTestCaseTest(String xml, String systemId, String doctype)
    throws Exception {
    assertXMLValid(xml, systemId, doctype);
    assertXMLValid(new InputSource(new StringReader(xml)), systemId,
                   doctype);
    assertXMLValid(new InputSource(new StringBufferInputStream(xml)),
                   systemId, doctype);
}
 
Example #17
Source File: AbstractXPathEngineTest.java    From xmlunit with Apache License 2.0 5 votes vote down vote up
@Test
public void selectNodesWithNS_NodeVersion() throws Exception {
    XPathEngine e = getEngine();
    sourceRootElement = db
        .parse(new StringBufferInputStream("<n:d xmlns:n='urn:test:1'><n:e/></n:d>"))
        .getDocumentElement();
    HashMap<String, String> m = new HashMap<String, String>();
    m.put("x", "urn:test:1");
    e.setNamespaceContext(m);
    Iterable<Node> it = e.selectNodes("/x:d/x:e", sourceRootElement);
    assertTrue(it.iterator().hasNext());
}
 
Example #18
Source File: AbstractXPathEngineTest.java    From xmlunit with Apache License 2.0 5 votes vote down vote up
@Test
public void selectNodesWithDefaultNS_NodeVersion() throws Exception {
    XPathEngine e = getEngine();
    sourceRootElement = db
        .parse(new StringBufferInputStream("<d xmlns='urn:test:1'><e/></d>"))
        .getDocumentElement();
    HashMap<String, String> m = new HashMap<String, String>();
    m.put("x", "urn:test:1");
    e.setNamespaceContext(m);
    Iterable<Node> it = e.selectNodes("/x:d/x:e", sourceRootElement);
    assertTrue(it.iterator().hasNext());
}
 
Example #19
Source File: AbstractXPathEngineTest.java    From xmlunit with Apache License 2.0 5 votes vote down vote up
@Test
public void selectNodesWithDefaultNSEmptyPrefix_NodeVersion() throws Exception {
    XPathEngine e = getEngine();
    sourceRootElement = db
        .parse(new StringBufferInputStream("<d xmlns='urn:test:1'><e/></d>"))
        .getDocumentElement();
    HashMap<String, String> m = new HashMap<String, String>();
    m.put("", "urn:test:1");
    e.setNamespaceContext(m);
    Iterable<Node> it = e.selectNodes("/:d/:e", sourceRootElement);
    assertTrue(it.iterator().hasNext());
}
 
Example #20
Source File: DellRestBridgeConfig.java    From onos with Apache License 2.0 5 votes vote down vote up
@Override
public void deletePort(BridgeName bridgeName, String portName) {
    // bridgeName is not used
    checkNotNull(portName);
    portName = portNameForCli(portName);
    String portRemoveCommands = String.format(PORT_REMOVE_COMMANDS, portName);

    DriverHandler handler = handler();
    RestSBController controller = checkNotNull(handler.get(RestSBController.class));
    DeviceId deviceId = handler.data().deviceId();

    InputStream payload = new StringBufferInputStream(String.format(CONFIG_COMMANDS, portRemoveCommands));
    String resp = controller.post(deviceId, CLI_REQUEST, payload, MediaType.valueOf("*/*"), String.class);
    log.info("{}", resp);
}
 
Example #21
Source File: TemplateUtils.java    From CppTools with Apache License 2.0 5 votes vote down vote up
public static void createOrResetFileContent(VirtualFile sourcePathDir, String fileName, StringBufferInputStream inputStream) throws IOException {
  VirtualFile child = sourcePathDir.findChild(fileName);
  if (child == null) child = sourcePathDir.createChildData(CppModuleBuilder.class, fileName);
  OutputStream outputStream = child.getOutputStream(CppModuleBuilder.class);

  FileUtil.copy(inputStream, outputStream);
  outputStream.flush();
  outputStream.close();
}
 
Example #22
Source File: TemplateUtils.java    From CppTools with Apache License 2.0 5 votes vote down vote up
public static void createOrResetFileContentFromTemplate(VirtualFile sourcePathDir, String fileName, 
                                                        String templateFileName, String ... additionalParameters) {
  try {
    createOrResetFileContent(sourcePathDir, fileName, new StringBufferInputStream(getTemplateText(templateFileName, additionalParameters)));
  } catch (IOException ex) {
    ex.printStackTrace();
  }
}
 
Example #23
Source File: BaseRowSetTests.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
@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}
    };
}
 
Example #24
Source File: OverflowInRead.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    String s = "_123456789_123456789_123456789_123456789"; // s.length() > 33
    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");
    }
}
 
Example #25
Source File: BaseRowSetTests.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
@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}
    };
}
 
Example #26
Source File: OverflowInRead.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    String s = "_123456789_123456789_123456789_123456789"; // s.length() > 33
    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");
    }
}
 
Example #27
Source File: BaseRowSetTests.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
@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}
    };
}
 
Example #28
Source File: BaseRowSetTests.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
@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}
    };
}
 
Example #29
Source File: OverflowInRead.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    String s = "_123456789_123456789_123456789_123456789"; // s.length() > 33
    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");
    }
}
 
Example #30
Source File: BaseRowSetTests.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
@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}
    };
}