Search in sources :

Example 1 with OprofileSAXHandler

use of org.eclipse.linuxtools.internal.oprofile.core.opxml.OprofileSAXHandler in project linuxtools by eclipse.

the class TestingOpModelEvent method getNewImage.

@Override
protected OpModelImage getNewImage() {
    /* this code mostly taken from OpxmlRunner */
    OpModelImage parsedImage = null;
    try {
        XMLReader reader = null;
        parsedImage = new OpModelImage();
        ModelDataProcessor.CallData image = new ModelDataProcessor.CallData(parsedImage);
        OprofileSAXHandler handler = OprofileSAXHandler.getInstance(image);
        // Create XMLReader
        SAXParserFactory factory = SAXParserFactory.newInstance();
        reader = factory.newSAXParser().getXMLReader();
        // Set content/error handlers
        reader.setContentHandler(handler);
        reader.setErrorHandler(handler);
        String filePath = FileLocator.toFileURL(FileLocator.find(TestPlugin.getDefault().getBundle(), new Path(REL_PATH_TO_TEST_XML), null)).getFile();
        reader.parse(new InputSource(new FileReader(filePath)));
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    } catch (SAXException e) {
        e.printStackTrace();
    } catch (ParserConfigurationException e) {
        e.printStackTrace();
    }
    return parsedImage;
}
Also used : Path(org.eclipse.core.runtime.Path) OpModelImage(org.eclipse.linuxtools.internal.oprofile.core.model.OpModelImage) InputSource(org.xml.sax.InputSource) FileNotFoundException(java.io.FileNotFoundException) OprofileSAXHandler(org.eclipse.linuxtools.internal.oprofile.core.opxml.OprofileSAXHandler) IOException(java.io.IOException) SAXException(org.xml.sax.SAXException) ModelDataProcessor(org.eclipse.linuxtools.internal.oprofile.core.opxml.modeldata.ModelDataProcessor) FileReader(java.io.FileReader) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) XMLReader(org.xml.sax.XMLReader) SAXParserFactory(javax.xml.parsers.SAXParserFactory)

Example 2 with OprofileSAXHandler

use of org.eclipse.linuxtools.internal.oprofile.core.opxml.OprofileSAXHandler in project linuxtools by eclipse.

the class TestingOpModelEvent3 method getNewImage.

@Override
protected OpModelImage getNewImage() {
    /* this code mostly taken from OpxmlRunner */
    OpModelImage parsedImage = null;
    try {
        XMLReader reader = null;
        parsedImage = new OpModelImage();
        ModelDataProcessor.CallData image = new ModelDataProcessor.CallData(parsedImage);
        OprofileSAXHandler handler = OprofileSAXHandler.getInstance(image);
        // Create XMLReader
        SAXParserFactory factory = SAXParserFactory.newInstance();
        reader = factory.newSAXParser().getXMLReader();
        // Set content/error handlers
        reader.setContentHandler(handler);
        reader.setErrorHandler(handler);
        String filePath = FileLocator.toFileURL(FileLocator.find(TestPlugin.getDefault().getBundle(), new Path(REL_PATH_TO_TEST_XML), null)).getFile();
        reader.parse(new InputSource(new FileReader(filePath)));
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    } catch (SAXException e) {
        e.printStackTrace();
    } catch (ParserConfigurationException e) {
        e.printStackTrace();
    }
    return parsedImage;
}
Also used : Path(org.eclipse.core.runtime.Path) OpModelImage(org.eclipse.linuxtools.internal.oprofile.core.model.OpModelImage) InputSource(org.xml.sax.InputSource) FileNotFoundException(java.io.FileNotFoundException) OprofileSAXHandler(org.eclipse.linuxtools.internal.oprofile.core.opxml.OprofileSAXHandler) IOException(java.io.IOException) SAXException(org.xml.sax.SAXException) ModelDataProcessor(org.eclipse.linuxtools.internal.oprofile.core.opxml.modeldata.ModelDataProcessor) FileReader(java.io.FileReader) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) XMLReader(org.xml.sax.XMLReader) SAXParserFactory(javax.xml.parsers.SAXParserFactory)

Example 3 with OprofileSAXHandler

use of org.eclipse.linuxtools.internal.oprofile.core.opxml.OprofileSAXHandler in project linuxtools by eclipse.

the class TestCheckEventsParse method setUpHelper.

// helper
private void setUpHelper(String fileToParse, final int[] resultArray) throws Exception {
    /* this code mostly taken from OpxmlRunner */
    XMLReader reader = null;
    OprofileSAXHandler handler = OprofileSAXHandler.getInstance(resultArray);
    // Create XMLReader
    SAXParserFactory factory = SAXParserFactory.newInstance();
    reader = factory.newSAXParser().getXMLReader();
    // Set content/error handlers
    reader.setContentHandler(handler);
    reader.setErrorHandler(handler);
    String filePath = FileLocator.toFileURL(FileLocator.find(FrameworkUtil.getBundle(this.getClass()), new Path(fileToParse), null)).getFile();
    reader.parse(new InputSource(new FileReader(filePath)));
}
Also used : Path(org.eclipse.core.runtime.Path) InputSource(org.xml.sax.InputSource) FileReader(java.io.FileReader) OprofileSAXHandler(org.eclipse.linuxtools.internal.oprofile.core.opxml.OprofileSAXHandler) XMLReader(org.xml.sax.XMLReader) SAXParserFactory(javax.xml.parsers.SAXParserFactory)

Example 4 with OprofileSAXHandler

use of org.eclipse.linuxtools.internal.oprofile.core.opxml.OprofileSAXHandler in project linuxtools by eclipse.

the class TestModelDataParse method setUp.

@Before
public void setUp() throws Exception {
    /* this code mostly taken from OpxmlRunner */
    XMLReader reader = null;
    parsedImage = new OpModelImage();
    ModelDataProcessor.CallData image = new ModelDataProcessor.CallData(parsedImage);
    OprofileSAXHandler handler = OprofileSAXHandler.getInstance(image);
    // Create XMLReader
    SAXParserFactory factory = SAXParserFactory.newInstance();
    reader = factory.newSAXParser().getXMLReader();
    // Set content/error handlers
    reader.setContentHandler(handler);
    reader.setErrorHandler(handler);
    String filePath = FileLocator.toFileURL(FileLocator.find(FrameworkUtil.getBundle(this.getClass()), new Path(REL_PATH_TO_TEST_XML), null)).getFile();
    reader.parse(new InputSource(new FileReader(filePath)));
    // 2nd test image
    parsedErrorImage = new OpModelImage();
    ModelDataProcessor.CallData errorImage = new ModelDataProcessor.CallData(parsedErrorImage);
    handler = OprofileSAXHandler.getInstance(errorImage);
    // Set content/error handlers
    reader.setContentHandler(handler);
    reader.setErrorHandler(handler);
    filePath = FileLocator.toFileURL(FileLocator.find(FrameworkUtil.getBundle(this.getClass()), new Path(REL_PATH_TO_TEST_XML_MULTI_IMAGE), null)).getFile();
    reader.parse(new InputSource(new FileReader(filePath)));
}
Also used : Path(org.eclipse.core.runtime.Path) OpModelImage(org.eclipse.linuxtools.internal.oprofile.core.model.OpModelImage) InputSource(org.xml.sax.InputSource) ModelDataProcessor(org.eclipse.linuxtools.internal.oprofile.core.opxml.modeldata.ModelDataProcessor) FileReader(java.io.FileReader) OprofileSAXHandler(org.eclipse.linuxtools.internal.oprofile.core.opxml.OprofileSAXHandler) XMLReader(org.xml.sax.XMLReader) SAXParserFactory(javax.xml.parsers.SAXParserFactory) Before(org.junit.Before)

Example 5 with OprofileSAXHandler

use of org.eclipse.linuxtools.internal.oprofile.core.opxml.OprofileSAXHandler in project linuxtools by eclipse.

the class TestSessionsParse method setUp.

@Before
public void setUp() throws Exception {
    /* this code mostly taken from OpxmlRunner */
    XMLReader reader = null;
    eventList = new ArrayList<>();
    SessionsProcessor.SessionInfo sessioninfo = new SessionsProcessor.SessionInfo(eventList);
    OprofileSAXHandler handler = OprofileSAXHandler.getInstance(sessioninfo);
    // Create XMLReader
    SAXParserFactory factory = SAXParserFactory.newInstance();
    reader = factory.newSAXParser().getXMLReader();
    // Set content/error handlers
    reader.setContentHandler(handler);
    reader.setErrorHandler(handler);
    String filePath = FileLocator.toFileURL(FileLocator.find(FrameworkUtil.getBundle(this.getClass()), new Path(REL_PATH_TO_TEST_XML), null)).getFile();
    reader.parse(new InputSource(new FileReader(filePath)));
}
Also used : Path(org.eclipse.core.runtime.Path) InputSource(org.xml.sax.InputSource) FileReader(java.io.FileReader) OprofileSAXHandler(org.eclipse.linuxtools.internal.oprofile.core.opxml.OprofileSAXHandler) XMLReader(org.xml.sax.XMLReader) SessionsProcessor(org.eclipse.linuxtools.internal.oprofile.core.opxml.sessions.SessionsProcessor) SAXParserFactory(javax.xml.parsers.SAXParserFactory) Before(org.junit.Before)

Aggregations

FileReader (java.io.FileReader)8 SAXParserFactory (javax.xml.parsers.SAXParserFactory)8 OprofileSAXHandler (org.eclipse.linuxtools.internal.oprofile.core.opxml.OprofileSAXHandler)8 InputSource (org.xml.sax.InputSource)8 XMLReader (org.xml.sax.XMLReader)8 Path (org.eclipse.core.runtime.Path)7 IOException (java.io.IOException)4 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)4 OpModelImage (org.eclipse.linuxtools.internal.oprofile.core.model.OpModelImage)4 ModelDataProcessor (org.eclipse.linuxtools.internal.oprofile.core.opxml.modeldata.ModelDataProcessor)4 SAXException (org.xml.sax.SAXException)4 FileNotFoundException (java.io.FileNotFoundException)3 Before (org.junit.Before)3 BufferedReader (java.io.BufferedReader)1 File (java.io.File)1 InputStreamReader (java.io.InputStreamReader)1 CoreException (org.eclipse.core.runtime.CoreException)1 OpInfo (org.eclipse.linuxtools.internal.oprofile.core.daemon.OpInfo)1 AbstractDataAdapter (org.eclipse.linuxtools.internal.oprofile.core.opxml.AbstractDataAdapter)1 CheckEventAdapter (org.eclipse.linuxtools.internal.oprofile.core.opxml.checkevent.CheckEventAdapter)1