Package org.eurekastreams.server.domain.stream

Examples of org.eurekastreams.server.domain.stream.LinkInformation


     */
    @Test
    public final void noTitleTest()
    {
        final String html = "<html></html>";
        final LinkInformation link = new LinkInformation();
        link.setUrl("http:///www.someurl.com");

        sut.parseInformation(html, link, TEST_ACCOUNT);

        Assert.assertEquals(link.getUrl(), link.getTitle());
    }
View Full Code Here


     */
    @Test
    public final void parseTitleTest()
    {
        final String html = "<html><title>Some webpage</title></html>";
        final LinkInformation link = new LinkInformation();

        sut.parseInformation(html, link, TEST_ACCOUNT);

        Assert.assertEquals("Some webpage", link.getTitle());
    }
View Full Code Here

     * Test parsing with img tags with width/height less than the threshhold.
     */
    @Test
    public final void smallImgTagHeightTest()
    {
        final LinkInformation link = new LinkInformation();

        final String html = "<html><body>" + "<img src=\"http://www.someurl.com/someimg1.png\" width=\""
                + (BasicLinkImageParser.MIN_IMG_SIZE + 1) + "\" height=\"" + (BasicLinkImageParser.MIN_IMG_SIZE - 1)
                + "\">" + "<img src=\"http://www.someurl.com/someimg2.png\" width=\""
                + (BasicLinkImageParser.MIN_IMG_SIZE - 1) + "\" height=\"" + (BasicLinkImageParser.MIN_IMG_SIZE + 1)
View Full Code Here

     * Test parsing when the link is an image.
     */
    @Test
    public final void isImageTest()
    {
        final LinkInformation link = new LinkInformation();
        link.setUrl("http://www.someurl.com/image.png");

        // Wouldn't really happen, but shows that it's not actually parsing.
        final String html = "<html><body>" + "<img src=\"http://www.someurl.com/someimg1.png\" /></body></html>";

        // Shouldn't bother downloading images, this is an image.

        sut.parseInformation(html, link, TEST_ACCOUNT);
        Assert.assertTrue(link.getImageUrls().contains(link.getUrl()));
    }
View Full Code Here

     * Test parsing with a malformed img tag.
     */
    @Test
    public final void malformedTagTest()
    {
        final LinkInformation link = new LinkInformation();

        final String html = "<html><body>" + "<img s1rc=\"http://www.someurl.com/someimg1.png\" width=\""
                + (BasicLinkImageParser.MIN_IMG_SIZE + 1) + "\" height=\"" + (BasicLinkImageParser.MIN_IMG_SIZE - 1)
                + "\">" + "</body></html>";

View Full Code Here

     *             shouldn't happen.
     */
    @Test
    public final void smallImgHeightDownloadTest() throws IOException
    {
        final LinkInformation link = new LinkInformation();
        link.setUrl("http://www.someurl.com");

        final String html = "<html><body>" + "<img src=\"http://www.someurl.com/someimg1.png\" /></body></html>";

        // Shouldn't bother downloading images that have tags saying they're too small.

View Full Code Here

     *             shouldn't happen.
     */
    @Test
    public final void smallImgWidthDownloadTest() throws IOException
    {
        final LinkInformation link = new LinkInformation();
        link.setUrl("http://www.someurl.com");

        final String html = "<html><body>" + "<img src=\"http://www.someurl.com/someimg1.png\" /></body></html>";

        context.checking(new Expectations()
        {
            {
                oneOf(urlUtils).getImgHeight("http://www.someurl.com/someimg1.png", TEST_ACCOUNT);
                will(returnValue(BasicLinkImageParser.MIN_IMG_SIZE + 1));

                oneOf(urlUtils).getImgWidth("http://www.someurl.com/someimg1.png", TEST_ACCOUNT);
                will(returnValue(BasicLinkImageParser.MIN_IMG_SIZE - 1));
            }
        });

        sut.parseInformation(html, link, TEST_ACCOUNT);

        Assert.assertFalse(link.getImageUrls().contains("http://www.someurl.com/someimg1.png"));

        context.assertIsSatisfied();
    }
View Full Code Here

     *             shouldn't happen.
     */
    @Test
    public final void smallImgHeightWidthDownloadTest() throws IOException
    {
        final LinkInformation link = new LinkInformation();
        link.setUrl("http://www.someurl.com");

        final String html = "<html><body>" + "<img src=\"http://www.someurl.com/someimg1.png\" /></body></html>";

        context.checking(new Expectations()
        {
            {
                oneOf(urlUtils).getImgHeight("http://www.someurl.com/someimg1.png", TEST_ACCOUNT);
                will(returnValue(BasicLinkImageParser.MIN_IMG_SIZE - 1));

                 oneOf(urlUtils).getImgWidth("http://www.someurl.com/someimg1.png", TEST_ACCOUNT);
                 will(returnValue(BasicLinkImageParser.MIN_IMG_SIZE - 1));
            }
        });

        sut.parseInformation(html, link, TEST_ACCOUNT);

        Assert.assertFalse(link.getImageUrls().contains("http://www.someurl.com/someimg1.png"));

        context.assertIsSatisfied();
    }
View Full Code Here

     *             shouldn't happen.
     */
    @Test
    public final void imgDownloadTest() throws IOException
    {
        final LinkInformation link = new LinkInformation();
        link.setUrl("http://www.someurl.com");

        final String html = "<html><body>" + "<img src=\"http://www.someurl.com/someimg1.png\" /></body></html>";

        context.checking(new Expectations()
        {
            {
                oneOf(urlUtils).getImgHeight("http://www.someurl.com/someimg1.png", TEST_ACCOUNT);
                will(returnValue(BasicLinkImageParser.MIN_IMG_SIZE + 1));

                oneOf(urlUtils).getImgWidth("http://www.someurl.com/someimg1.png", TEST_ACCOUNT);
                will(returnValue(BasicLinkImageParser.MIN_IMG_SIZE + 1));
            }
        });

        sut.parseInformation(html, link, TEST_ACCOUNT);

        Assert.assertTrue(link.getImageUrls().contains("http://www.someurl.com/someimg1.png"));

        context.assertIsSatisfied();
    }
View Full Code Here

     *             shouldn't happen.
     */
    @Test
    public final void imgDownloadHostPathTest() throws IOException
    {
        final LinkInformation link = new LinkInformation();
        link.setUrl("http://www.someurl.com");

        final String html = "<html><body>" + "<img src=\"/someimg1.png\" /></body></html>";

        context.checking(new Expectations()
        {
            {
                oneOf(urlUtils).getImgHeight("http://www.someurl.com/someimg1.png", TEST_ACCOUNT);
                will(returnValue(BasicLinkImageParser.MIN_IMG_SIZE + 1));

                oneOf(urlUtils).getImgWidth("http://www.someurl.com/someimg1.png", TEST_ACCOUNT);
                will(returnValue(BasicLinkImageParser.MIN_IMG_SIZE + 1));

                oneOf(urlUtils).getProtocol("http://www.someurl.com");
                will(returnValue("http"));

                oneOf(urlUtils).getHost("http://www.someurl.com");
                will(returnValue("www.someurl.com"));

            }
        });

        sut.parseInformation(html, link, TEST_ACCOUNT);

        Assert.assertTrue(link.getImageUrls().contains("http://www.someurl.com/someimg1.png"));

        context.assertIsSatisfied();
    }
View Full Code Here

TOP

Related Classes of org.eurekastreams.server.domain.stream.LinkInformation

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.