Package net.sf.uadetector.internal.data

Examples of net.sf.uadetector.internal.data.XmlDataHandler


    public static void parse(@Nonnull final InputStream stream, @Nonnull final DataBuilder builder)
        throws ParserConfigurationException, SAXException, IOException {
      final SAXParserFactory factory = SAXParserFactory.newInstance();
      factory.setValidating(true);
      final SAXParser parser = factory.newSAXParser();
      final XmlDataHandler handler = new XmlDataHandler(builder);
      parser.parse(stream, handler);
      validate(handler);
    }
View Full Code Here


@PrepareForTest(XmlDataHandler.class)
public class XmlParserTest {

  @Test(expected = IllegalStateException.class)
  public void validate_hasError() {
    final XmlDataHandler mock = PowerMock.createMock(XmlDataHandler.class);
    EasyMock.expect(mock.hasError()).andReturn(true).anyTimes();
    EasyMock.expect(mock.hasWarning()).andReturn(false).anyTimes();
    PowerMock.replay(mock);

    XmlParser.validate(mock);

    PowerMock.verify(mock);
View Full Code Here

    PowerMock.verify(mock);
  }

  @Test(expected = IllegalStateException.class)
  public void validate_hasErrorAndWarning() {
    final XmlDataHandler mock = PowerMock.createMock(XmlDataHandler.class);
    EasyMock.expect(mock.hasError()).andReturn(true).anyTimes();
    EasyMock.expect(mock.hasWarning()).andReturn(true).anyTimes();
    PowerMock.replay(mock);

    XmlParser.validate(mock);

    PowerMock.verify(mock);
View Full Code Here

    PowerMock.verify(mock);
  }

  @Test
  public void validate_hasWarning() {
    final XmlDataHandler mock = PowerMock.createMock(XmlDataHandler.class);
    EasyMock.expect(mock.hasError()).andReturn(false).anyTimes();
    EasyMock.expect(mock.hasWarning()).andReturn(true).anyTimes();
    PowerMock.replay(mock);

    XmlParser.validate(mock);

    PowerMock.verify(mock);
View Full Code Here

    PowerMock.verify(mock);
  }

  @Test
  public void validate_noErrorAndWarning() {
    final XmlDataHandler mock = PowerMock.createMock(XmlDataHandler.class);
    EasyMock.expect(mock.hasError()).andReturn(false).anyTimes();
    EasyMock.expect(mock.hasWarning()).andReturn(false).anyTimes();
    PowerMock.replay(mock);

    XmlParser.validate(mock);

    PowerMock.verify(mock);
View Full Code Here

TOP

Related Classes of net.sf.uadetector.internal.data.XmlDataHandler

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.