下面列出了怎么用java.io.StringBufferInputStream的API类实例代码及写法,或者点击链接到github查看源代码。
/**
* 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");
}
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"));
}
@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));
}
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();
}
@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);
}
@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;
}
/**
* 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;
}
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");
}
}
@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}
};
}
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");
}
}
@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}
};
}
@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}
};
}
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");
}
}
@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}
};
}
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");
}
}
@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}
};
}
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");
}
}
@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}
};
}
void runTest(String xmlString) {
Bug6573786ErrorHandler handler = new Bug6573786ErrorHandler();
try {
InputStream is = new StringBufferInputStream(xmlString);
SAXParser parser = SAXParserFactory.newInstance().newSAXParser();
parser.parse(is, handler);
} catch (Exception e) {
if (handler.fail) {
Assert.fail("The value of standalone attribute should be merged into the error message.");
}
}
}
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");
}
}
@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}
};
}
@Test
public void checkSSLOverrides() throws Exception {
File inputFile = new File("./src/test/resources/MINIFI-516/config.yml");
final Properties bootstrapProperties = getTestBootstrapProperties("MINIFI-516/bootstrap.conf");
ConfigTransformer.transformConfigFile(new FileInputStream(inputFile), "./target/", bootstrapProperties);
// nifi.properties testing
File nifiPropertiesFile = new File("./target/nifi.properties");
assertTrue(nifiPropertiesFile.exists());
assertTrue(nifiPropertiesFile.canRead());
nifiPropertiesFile.deleteOnExit();
// flow.xml.gz testing
File flowXml = new File("./target/flow.xml.gz");
assertTrue(flowXml.exists());
assertTrue(flowXml.canRead());
String flow = loadFlowXML(new FileInputStream(flowXml));
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
Document xml = db.parse(new StringBufferInputStream(flow));
XPath xPath = XPathFactory.newInstance().newXPath();
String result = xPath.evaluate("/flowController/rootGroup/processor/property[name = \"SSL Context Service\"]/value/text()", xml);
assertEquals(result, "SSL-Context-Service");
flowXml.deleteOnExit();
}
@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}
};
}
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");
}
}
@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}
};
}
@Override
public ServletInputStream getInputStream() throws IOException {
if (throwExceptionForISAccess) {
throw new IOException();
}
return new BufferedServletInputStream(new StringBufferInputStream(
bodyContent));
}
/**
* Tests whether initialLocation() gets called correctly when settings up
* a SimScenario
*
* @throws Exception
*/
@Test
public void testInitialLocation()
throws Exception {
// TODO: If more test cases are added that use Settings, they might
// be run in parallel and break.
// Setup the settings
Settings.initFromStream(
new StringBufferInputStream(INITIAL_LOC_TEST_SETTINGS));
final DTNSimUI ui = new DTNSimUI() {
@Override
protected void runSim() {
super.done();
}
};
// Set the delegate for MovementListenerTestReport
MovementListenerTestReport.setDelegate(new MovementReport());
// Start the DTNSimUI, this will create SimScenario instance with all
// the nodes and reports based on the configuration.
ui.start();
assertEquals("initialLocation() called incorrect number of time.",
INITIAL_LOC_TEST_NODE_COUNT, INITIAL_LOC_CALL_COUNT);
}
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");
}
/**
* 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();
}
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"));
}