Search in sources :

Example 16 with StringInputStream

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;
}
Also used : XPath(javax.xml.xpath.XPath) XPathExpression(javax.xml.xpath.XPathExpression) DocumentBuilderFactory(javax.xml.parsers.DocumentBuilderFactory) XPathExpressionException(javax.xml.xpath.XPathExpressionException) IOException(java.io.IOException) Document(org.w3c.dom.Document) SAXException(org.xml.sax.SAXException) XPathFactory(javax.xml.xpath.XPathFactory) StringInputStream(org.apache.tools.ant.filters.StringInputStream) DocumentBuilder(javax.xml.parsers.DocumentBuilder) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) PluginSourcesUnavailableException(org.jenkins.tools.test.exception.PluginSourcesUnavailableException)

Example 17 with StringInputStream

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);
}
Also used : StringInputStream(org.apache.tools.ant.filters.StringInputStream) MetadataTempFilesListDto(org.pentaho.platform.dataaccess.datasource.api.resources.MetadataTempFilesListDto) ByteArrayInputStream(java.io.ByteArrayInputStream) StringInputStream(org.apache.tools.ant.filters.StringInputStream) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Aggregations

StringInputStream (org.apache.tools.ant.filters.StringInputStream)17 IOException (java.io.IOException)6 InputStream (java.io.InputStream)5 Test (org.junit.Test)5 IFile (org.eclipse.core.resources.IFile)4 Node (org.kie.workbench.common.stunner.core.graph.Node)4 DocumentBuilder (javax.xml.parsers.DocumentBuilder)3 BusinessKnowledgeModelNode (org.kie.dmn.api.core.ast.BusinessKnowledgeModelNode)3 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)2 IFolder (org.eclipse.core.resources.IFolder)2 IPath (org.eclipse.core.runtime.IPath)2 Path (org.eclipse.core.runtime.Path)2 PMMLDocumentMetadata (org.kie.workbench.common.dmn.api.editors.included.PMMLDocumentMetadata)2 DiagramImpl (org.kie.workbench.common.stunner.core.diagram.DiagramImpl)2 Metadata (org.kie.workbench.common.stunner.core.diagram.Metadata)2 Graph (org.kie.workbench.common.stunner.core.graph.Graph)2 Matchers.anyString (org.mockito.Matchers.anyString)2 Statistics (org.opensolaris.opengrok.web.Statistics)2 Document (org.w3c.dom.Document)2 SAXException (org.xml.sax.SAXException)2