use of org.apache.tools.ant.filters.StringInputStream in project plugin-compat-tester by jenkinsci.
the class PluginRemoting method retrievePomData.
public PomData retrievePomData() throws PluginSourcesUnavailableException {
String scmConnection = null;
String artifactId = null;
String pomContent = this.retrievePomContent();
MavenCoordinates parent;
DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
try {
DocumentBuilder builder = docBuilderFactory.newDocumentBuilder();
Document doc = builder.parse(new StringInputStream(pomContent));
XPathFactory xpathFactory = XPathFactory.newInstance();
XPath xpath = xpathFactory.newXPath();
XPathExpression scmConnectionXPath = xpath.compile("/project/scm/connection/text()");
XPathExpression artifactIdXPath = xpath.compile("/project/artifactId/text()");
scmConnection = (String) scmConnectionXPath.evaluate(doc, XPathConstants.STRING);
artifactId = (String) artifactIdXPath.evaluate(doc, XPathConstants.STRING);
parent = new MavenCoordinates(xpath.evaluate("/project/parent/groupId/text()", doc), xpath.evaluate("/project/parent/artifactId/text()", doc), xpath.evaluate("/project/parent/version/text()", doc));
} catch (ParserConfigurationException e) {
System.err.println("Error : " + e.getMessage());
throw new PluginSourcesUnavailableException("Problem during pom.xml parsing", e);
} catch (SAXException e) {
System.err.println("Error : " + e.getMessage());
throw new PluginSourcesUnavailableException("Problem during pom.xml parsing", e);
} catch (IOException e) {
System.err.println("Error : " + e.getMessage());
throw new PluginSourcesUnavailableException("Problem during pom.xml parsing", e);
} catch (XPathExpressionException e) {
System.err.println("Error : " + e.getMessage());
throw new PluginSourcesUnavailableException("Problem while retrieving plugin's scm connection", e);
}
PomData pomData = new PomData(artifactId, scmConnection, parent);
computeScmConnection(pomData);
return pomData;
}
use of org.apache.tools.ant.filters.StringInputStream in project data-access by pentaho.
the class MetadataServiceTest method testUploadMetadataFilesToTempDir.
@Test
public void testUploadMetadataFilesToTempDir() throws Exception {
InputStream metadataFile = mock(InputStream.class);
fillServiceMock(DOMAIN_ID, metadataFile);
doReturn(new StringInputStream("")).when(metadataService).createInputStreamFromFile(any(String.class));
doReturn(XMI_TEMP_FILE_NAME).when(metadataService).uploadFile(any(InputStream.class));
MetadataTempFilesListDto res = metadataService.uploadMetadataFilesToTempDir(metadataFile, null, null);
assertEquals(res.getXmiFileName(), XMI_TEMP_FILE_NAME);
}
Aggregations