use of java.io.StringBufferInputStream in project pentaho-platform by pentaho.
the class MondrianCatalogHelperTest method shouldNotFailAndReturnNullWhenMaliciousXmlIsGiven.
@Test(timeout = 2000, expected = SAXException.class)
public void shouldNotFailAndReturnNullWhenMaliciousXmlIsGiven() throws IOException, ParserConfigurationException, SAXException {
mch.getMondrianXmlDocument(new StringBufferInputStream(XmlTestConstants.MALICIOUS_XML));
fail();
}
use of java.io.StringBufferInputStream in project pentaho-platform by pentaho.
the class XActionImportHandlerTest method shouldNotFailAndReturnNullWhenMaliciousXmlIsGiven.
@Test(timeout = 2000, expected = SAXException.class)
public void shouldNotFailAndReturnNullWhenMaliciousXmlIsGiven() throws IOException, ParserConfigurationException, SAXException {
handler.getImportBundleDocument(new StringBufferInputStream(XmlTestConstants.MALICIOUS_XML));
fail();
}
use of java.io.StringBufferInputStream in project pentaho-platform by pentaho.
the class RepositorySyncWebService method getRepositoryMeta.
private static RepositoryMeta getRepositoryMeta(String repositoryId, String repositoryUrl) throws KettleException {
RepositoryMeta repMeta = PluginRegistry.getInstance().loadClass(RepositoryPluginType.class, "PentahoEnterpriseRepository", // $NON-NLS-1$
RepositoryMeta.class);
// this repository is not available
if (repMeta == null) {
return null;
}
String xml = // $NON-NLS-1$
"<repo>" + // $NON-NLS-1$
"<id>PentahoEnterpriseRepository</id>" + "<name>" + repositoryId + // $NON-NLS-1$ //$NON-NLS-2$
"</name>" + "<description>" + repositoryId + // $NON-NLS-1$ //$NON-NLS-2$
"</description>" + "<repository_location_url>" + repositoryUrl + // $NON-NLS-1$ //$NON-NLS-2$
"</repository_location_url> </repo>";
Element node;
try {
node = XMLParserFactoryProducer.createSecureDocBuilderFactory().newDocumentBuilder().parse(new StringBufferInputStream(xml)).getDocumentElement();
} catch (Exception e) {
node = null;
}
repMeta.loadXML(node, null);
return repMeta;
}
use of java.io.StringBufferInputStream in project webtools.sourceediting by eclipse.
the class TestStructuredPartitionerJSP method doTimedComputePartitioningTest.
/**
* Compute the partitions for the given filename using the default
* partitioner for that file type.
*
* @param filename
* @return int
* @throws IOException
* @throws BadLocationException
*/
protected int doTimedComputePartitioningTest(String filename) throws IOException, BadLocationException {
IModelManager modelManager = StructuredModelManager.getModelManager();
InputStream inStream = getClass().getResourceAsStream(filename);
if (inStream == null)
inStream = new StringBufferInputStream("");
IStructuredModel model = modelManager.getModelForEdit(filename, inStream, null);
IStructuredDocument structuredDocument = model.getStructuredDocument();
if (DEBUG_PRINT_RESULT && useFormatter) {
double baseTen = Math.log(10);
formatter.setMinimumIntegerDigits((int) (Math.log(structuredDocument.getLength()) / baseTen) + 1);
formatter.setGroupingUsed(false);
}
long startTime = System.currentTimeMillis();
partitions = structuredDocument.computePartitioning(0, structuredDocument.getLength());
long endTime = System.currentTimeMillis();
if (DEBUG_PRINT_RESULT) {
String contents = null;
System.out.println("\nfilename: " + filename);
System.out.println("Time to compute " + partitions.length + ": " + (endTime - startTime) + " (msecs)");
for (int i = 0; i < partitions.length; i++) {
try {
contents = structuredDocument.get(partitions[i].getOffset(), partitions[i].getLength());
} catch (BadLocationException e) {
contents = "*error*";
}
if (useFormatter)
System.out.println(formatter.format(partitions[i].getOffset()) + ":" + formatter.format(partitions[i].getLength()) + " - " + partitions[i].getType() + " [" + StringUtils.escape(contents) + "]");
else
System.out.println(partitions[i] + " [" + StringUtils.escape(contents) + "]");
}
}
checkSeams();
model.releaseFromEdit();
inStream.close();
if (partitions == null)
return -1;
return partitions.length;
}
use of java.io.StringBufferInputStream in project webtools.sourceediting by eclipse.
the class TestStructuredPartitionerJSP method doComputePartitioningTest.
/**
* Compute the partitions for the given filename using the default
* partitioner for that file type.
*
* @param filename
* @return int
* @throws IOException
* @throws BadLocationException
*/
protected int doComputePartitioningTest(String filename) throws IOException, BadLocationException {
IModelManager modelManager = StructuredModelManager.getModelManager();
InputStream inStream = getClass().getResourceAsStream(filename);
if (inStream == null)
inStream = new StringBufferInputStream("");
IStructuredModel model = modelManager.getModelForEdit(filename, inStream, null);
IStructuredDocument structuredDocument = model.getStructuredDocument();
if (DEBUG_PRINT_RESULT && useFormatter) {
double baseTen = Math.log(10);
formatter.setMinimumIntegerDigits((int) (Math.log(structuredDocument.getLength()) / baseTen) + 1);
formatter.setGroupingUsed(false);
}
partitions = structuredDocument.computePartitioning(0, structuredDocument.getLength());
if (DEBUG_PRINT_RESULT) {
String contents = null;
System.out.println("\nfilename: " + filename);
for (int i = 0; i < partitions.length; i++) {
try {
contents = structuredDocument.get(partitions[i].getOffset(), partitions[i].getLength());
} catch (BadLocationException e) {
contents = "*error*";
}
if (useFormatter)
System.out.println(formatter.format(partitions[i].getOffset()) + ":" + formatter.format(partitions[i].getLength()) + " - " + partitions[i].getType() + " [" + StringUtils.escape(contents) + "]");
else
System.out.println(partitions[i] + " [" + StringUtils.escape(contents) + "]");
}
}
checkSeams();
model.releaseFromEdit();
inStream.close();
if (partitions == null)
return -1;
return partitions.length;
}
Aggregations