Example usage for junit.framework Assert assertSame

List of usage examples for junit.framework Assert assertSame

Introduction

In this page you can find the example usage for junit.framework Assert assertSame.

Prototype

static public void assertSame(String message, Object expected, Object actual) 

Source Link

Document

Asserts that two objects refer to the same object.

Usage

From source file:org.apache.any23.Any23Test.java

/**
 * This test checks the extraction behavior when the library is used programatically.
 * This test is related to the issue #45, to verify the different behaviors between Maven and Ant.
 * The behavior was related to a 2nd-level dependency introduced by Maven.
 *
 * @throws org.apache.any23.extractor.ExtractionException
 * @throws IOException/*from   w ww.  j av  a  2s  .  c o m*/
 * @throws URISyntaxException
 */
@Test
public void testProgrammaticExtraction() throws ExtractionException, IOException, URISyntaxException {
    Any23 any23 = new Any23();
    any23.setHTTPUserAgent("Any23-Servlet");
    any23.setHTTPClient(new DefaultHTTPClient() {
        @Override
        protected int getConnectionTimeout() {
            return 5000;
        }

        @Override
        protected int getSoTimeout() {
            return 2000;
        }
    });
    ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
    TripleHandler handler = new RDFXMLWriter(byteArrayOutputStream);
    TripleHandler rdfWriter = new IgnoreAccidentalRDFa(handler);
    ReportingTripleHandler reporting = new ReportingTripleHandler(rdfWriter);

    DocumentSource source = getDocumentSourceFromResource("/html/rdfa/ansa_2010-02-26_12645863.html",
            "http://host.com/service");

    Assert.assertTrue(any23.extract(source, reporting).hasMatchingExtractors());
    try {
        handler.close();
    } catch (TripleHandlerException e) {
        Assert.fail(e.getMessage());
    }

    final String bufferContent = byteArrayOutputStream.toString();
    logger.debug(bufferContent);
    Assert.assertSame("Unexpected number of triples.", 60, StringUtils.countNL(bufferContent));

}