本文整理汇总了Java中org.apache.tools.ant.filters.StringInputStream类的典型用法代码示例。如果您正苦于以下问题:Java StringInputStream类的具体用法?Java StringInputStream怎么用?Java StringInputStream使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
StringInputStream类属于org.apache.tools.ant.filters包,在下文中一共展示了StringInputStream类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parseSettings_account_identities
import org.apache.tools.ant.filters.StringInputStream; //导入依赖的package包/类
@Test
public void parseSettings_account_identities() throws SettingsImportExportException {
String validUUID = UUID.randomUUID().toString();
InputStream inputStream = new StringInputStream("<k9settings format=\"1\" version=\"1\">" +
"<accounts><account uuid=\"" + validUUID + "\"><name>Account</name>" +
"<identities><identity><email>[email protected]</email></identity></identities>" +
"</account></accounts></k9settings>");
List<String> accountUuids = new ArrayList<>();
accountUuids.add("1");
SettingsImporter.Imported results = SettingsImporter.parseSettings(inputStream, true, accountUuids, true);
assertEquals(1, results.accounts.size());
assertEquals(validUUID, results.accounts.get(validUUID).uuid);
assertEquals(1, results.accounts.get(validUUID).identities.size());
assertEquals("[email protected]", results.accounts.get(validUUID).identities.get(0).email);
}
示例2: parseSettings_account_cram_md5
import org.apache.tools.ant.filters.StringInputStream; //导入依赖的package包/类
@Test
public void parseSettings_account_cram_md5() throws SettingsImportExportException {
String validUUID = UUID.randomUUID().toString();
InputStream inputStream = new StringInputStream("<k9settings format=\"1\" version=\"1\">" +
"<accounts><account uuid=\"" + validUUID + "\"><name>Account</name>" +
"<incoming-server><authentication-type>CRAM_MD5</authentication-type></incoming-server>" +
"</account></accounts></k9settings>");
List<String> accountUuids = new ArrayList<>();
accountUuids.add(validUUID);
SettingsImporter.Imported results = SettingsImporter.parseSettings(inputStream, true, accountUuids, false);
assertEquals("Account", results.accounts.get(validUUID).name);
assertEquals(validUUID, results.accounts.get(validUUID).uuid);
assertEquals(AuthType.CRAM_MD5, results.accounts.get(validUUID).incoming.authenticationType);
}
示例3: getImportStreamContents_account
import org.apache.tools.ant.filters.StringInputStream; //导入依赖的package包/类
@Test
public void getImportStreamContents_account() throws SettingsImportExportException {
String validUUID = UUID.randomUUID().toString();
InputStream inputStream = new StringInputStream("<k9settings format=\"1\" version=\"1\">" +
"<accounts>" +
"<account uuid=\"" + validUUID + "\">" +
"<name>Account</name>" +
"<identities>" +
"<identity>" +
"<email>[email protected]</email>" +
"</identity>" +
"</identities>" +
"</account>" +
"</accounts></k9settings>");
SettingsImporter.ImportContents results = SettingsImporter.getImportStreamContents(inputStream);
assertEquals(false, results.globalSettings);
assertEquals(1, results.accounts.size());
assertEquals("Account", results.accounts.get(0).name);
assertEquals(validUUID, results.accounts.get(0).uuid);
}
示例4: getImportStreamContents_alternativeName
import org.apache.tools.ant.filters.StringInputStream; //导入依赖的package包/类
@Test
public void getImportStreamContents_alternativeName() throws SettingsImportExportException {
String validUUID = UUID.randomUUID().toString();
InputStream inputStream = new StringInputStream("<k9settings format=\"1\" version=\"1\">" +
"<accounts>" +
"<account uuid=\"" + validUUID + "\">" +
"<name></name>" +
"<identities>" +
"<identity>" +
"<email>[email protected]</email>" +
"</identity>" +
"</identities>" +
"</account>" +
"</accounts></k9settings>");
SettingsImporter.ImportContents results = SettingsImporter.getImportStreamContents(inputStream);
assertEquals(false, results.globalSettings);
assertEquals(1, results.accounts.size());
assertEquals("[email protected]", results.accounts.get(0).name);
assertEquals(validUUID, results.accounts.get(0).uuid);
}
示例5: testRunCommandWithLogging_badProcessOutput
import org.apache.tools.ant.filters.StringInputStream; //导入依赖的package包/类
@Test
public void testRunCommandWithLogging_badProcessOutput()
throws IOException, InterruptedException {
List<String> command = Arrays.asList("someCommand", "someOption");
InputStream processOutput = new StringInputStream("");
processOutput.close();
when(processMock.getInputStream()).thenReturn(processOutput);
new CommandExecutor()
.setLogger(loggerMock)
.setProcessBuilderFactory(processBuilderFactoryMock)
.run(command);
loggerInOrder.verify(loggerMock).warn("IO Exception reading process output");
}
示例6: getEmailsForComponent
import org.apache.tools.ant.filters.StringInputStream; //导入依赖的package包/类
public String[] getEmailsForComponent( String component ) throws IOException, SAXException, ParserConfigurationException, InterruptedException {
String s = curl.execProjectCommand( "notebooks/7161/pages/23056/latest" );
XMLObject xml = new XMLObject( s );
String body = xml.getTextContent( "body" );
Properties p = new Properties();
p.load( new StringInputStream( body ) );
ArrayList<String> emails = new ArrayList<String>();
Set set = p.keySet();
for ( Object element : set ) {
String key = (String) element;
String value = p.getProperty( key );
StringTokenizer st = new StringTokenizer( value, ", " );
while ( st.hasMoreTokens() ) {
String listedComponent = st.nextToken();
String email = getEmail( key );
if ( ( listedComponent.equals( "*" ) || listedComponent.equalsIgnoreCase( component ) ) &&
( !emails.contains( email ) && email != null ) ) {
emails.add( email );
}
}
}
return emails.toArray( new String[emails.size()] );
}
示例7: testWriteFile
import org.apache.tools.ant.filters.StringInputStream; //导入依赖的package包/类
@Test
public void testWriteFile(){
String path = "smb://administrator:[email protected]/install/ftp/email-attachements";
String fn = NiceDate.New().formatAsDate()+"test.txt";
String content = "test中文";
InputStream in = new StringInputStream(content);
FileUtils.writeInputStreamTo(in, path, fn);
in = FileUtils.newSmbInputStream("administrator", "Admin123456", "192.168.104.217/install/ftp/email-attachements/"+fn);
List<String> list = FileUtils.readAsList(in);
System.out.println("list0: " + list.get(0));
Assert.assertEquals(content, list.get(0));
String smbPath = path+"\\"+fn;
String data = FileUtils.readAsString(smbPath);
Assert.assertEquals(content, data);
String srcDir = "D:/fileutil-test/smb";
File localFile = SmbFileUtils.copyFileToDir(SmbFileUtils.newSmbFile(smbPath), srcDir);
data = FileUtils.readAsString(localFile);
Assert.assertEquals(content, data);
}
示例8: createTokenReturnsConnectionError
import org.apache.tools.ant.filters.StringInputStream; //导入依赖的package包/类
@Test
public void createTokenReturnsConnectionError() throws Exception {
HttpResponseStub response = new TestHttpResponse(200, "") {
@Override
public HttpEntity getEntity() {
return new InputStreamEntity(new StringInputStream("foo"), 3) {
@Override
public InputStream getContent() throws IOException {
throw new IOException("Test exception");
}
};
}
};
Robolectric.addPendingHttpResponse(response);
Throwable throwable = createTokenThenError(ApiSample.testCard);
assertThat(throwable, instanceOf(IOException.class));
assertEquals(throwable.getMessage(), "Test exception");
}
示例9: roundTripUnmarshalThenMarshalUnmarshal
import org.apache.tools.ant.filters.StringInputStream; //导入依赖的package包/类
public void roundTripUnmarshalThenMarshalUnmarshal(InputStream dmnXmlInputStream,
Consumer<Graph<?, Node<?, ?>>> checkGraphConsumer) throws IOException {
DMNMarshaller m = new DMNMarshaller(new XMLEncoderDiagramMetadataMarshaller(),
applicationFactoryManager);
// first unmarshal from DMN XML to Stunner DMN Graph
@SuppressWarnings("unchecked")
Graph<?, Node<?, ?>> g = m.unmarshall(null,
dmnXmlInputStream);
checkGraphConsumer.accept(g);
// round trip to Stunner DMN Graph back to DMN XML
DiagramImpl diagram = new DiagramImpl("",
null);
diagram.setGraph(g);
String mString = m.marshall(diagram);
System.out.println(mString);
// now unmarshal once more, from the marshalled just done above, back again to Stunner DMN Graph to complete check for round-trip
@SuppressWarnings("unchecked")
Graph<?, Node<?, ?>> g2 = m.unmarshall(null,
new StringInputStream(mString));
checkGraphConsumer.accept(g2);
}
示例10: importSettings_throwsExceptionOnBlankFile
import org.apache.tools.ant.filters.StringInputStream; //导入依赖的package包/类
@Test(expected = SettingsImportExportException.class)
public void importSettings_throwsExceptionOnBlankFile() throws SettingsImportExportException {
InputStream inputStream = new StringInputStream("");
List<String> accountUuids = new ArrayList<>();
SettingsImporter.importSettings(RuntimeEnvironment.application, inputStream, true, accountUuids, true);
}
示例11: importSettings_throwsExceptionOnMissingFormat
import org.apache.tools.ant.filters.StringInputStream; //导入依赖的package包/类
@Test(expected = SettingsImportExportException.class)
public void importSettings_throwsExceptionOnMissingFormat() throws SettingsImportExportException {
InputStream inputStream = new StringInputStream("<k9settings version=\"1\"></k9settings>");
List<String> accountUuids = new ArrayList<>();
SettingsImporter.importSettings(RuntimeEnvironment.application, inputStream, true, accountUuids, true);
}
示例12: importSettings_throwsExceptionOnInvalidFormat
import org.apache.tools.ant.filters.StringInputStream; //导入依赖的package包/类
@Test(expected = SettingsImportExportException.class)
public void importSettings_throwsExceptionOnInvalidFormat() throws SettingsImportExportException {
InputStream inputStream = new StringInputStream("<k9settings version=\"1\" format=\"A\"></k9settings>");
List<String> accountUuids = new ArrayList<>();
SettingsImporter.importSettings(RuntimeEnvironment.application, inputStream, true, accountUuids, true);
}
示例13: importSettings_throwsExceptionOnNonPositiveFormat
import org.apache.tools.ant.filters.StringInputStream; //导入依赖的package包/类
@Test(expected = SettingsImportExportException.class)
public void importSettings_throwsExceptionOnNonPositiveFormat() throws SettingsImportExportException {
InputStream inputStream = new StringInputStream("<k9settings version=\"1\" format=\"0\"></k9settings>");
List<String> accountUuids = new ArrayList<>();
SettingsImporter.importSettings(RuntimeEnvironment.application, inputStream, true, accountUuids, true);
}
示例14: importSettings_throwsExceptionOnMissingVersion
import org.apache.tools.ant.filters.StringInputStream; //导入依赖的package包/类
@Test(expected = SettingsImportExportException.class)
public void importSettings_throwsExceptionOnMissingVersion() throws SettingsImportExportException {
InputStream inputStream = new StringInputStream("<k9settings format=\"1\"></k9settings>");
List<String> accountUuids = new ArrayList<>();
SettingsImporter.importSettings(RuntimeEnvironment.application, inputStream, true, accountUuids, true);
}
示例15: importSettings_throwsExceptionOnInvalidVersion
import org.apache.tools.ant.filters.StringInputStream; //导入依赖的package包/类
@Test(expected = SettingsImportExportException.class)
public void importSettings_throwsExceptionOnInvalidVersion() throws SettingsImportExportException {
InputStream inputStream = new StringInputStream("<k9settings format=\"1\" version=\"A\"></k9settings>");
List<String> accountUuids = new ArrayList<>();
SettingsImporter.importSettings(RuntimeEnvironment.application, inputStream, true, accountUuids, true);
}