Package org.apache.marmotta.commons.http

Examples of org.apache.marmotta.commons.http.ContentType


    public FacebookGraphEndpoint() {

        super("Facebook Graph API Provider", FacebookGraphProvider.PROVIDER_NAME, "^http(s?)://([^.]+)\\.facebook\\.com/.*", null, 86400L);
        setPriority(PRIORITY_HIGH);
        addContentType(new ContentType("application", "json"));

    }
View Full Code Here


public class YoutubeVideoPageEndpointGData extends Endpoint {

    public YoutubeVideoPageEndpointGData() {
        super("YouTube Page (GData)", "YouTube Page", "^http://gdata\\.youtube\\.com/feeds/api/videos/.*", null, 86400L);
        setPriority(PRIORITY_HIGH);
        addContentType(new ContentType("text","html"));
    }
View Full Code Here

public class YoutubeVideoEndpoint extends Endpoint {

    public YoutubeVideoEndpoint() {
        super("YouTube Video", "YouTube Video", "^http://youtu\\.be/.*", null, 86400L);
        setPriority(PRIORITY_HIGH);
        addContentType(new ContentType("application","atom+xml"));
    }
View Full Code Here

public class ContentTypeMatchingTest {


    @Test
    public void testMatchNormal1() throws Exception {
        ContentType type1 = new ContentType("application","json");
        ContentType type2 = new ContentType("application","json");

        Assert.assertTrue(type2.matches(type1));
        Assert.assertTrue(type1.matches(type2));
    }
View Full Code Here

    }


    @Test
    public void testMatchNormal2() throws Exception {
        ContentType type1 = new ContentType("application","json");
        ContentType type2 = new ContentType("application","*");

        Assert.assertTrue(type2.matchesWildcard(type1));
        Assert.assertFalse(type1.matches(type2));
        Assert.assertFalse(type2.matches(type1));
    }
View Full Code Here

        Assert.assertFalse(type2.matches(type1));
    }

    @Test
    public void testMatchNormal3() throws Exception {
        ContentType type1 = new ContentType("application","json");
        ContentType type2 = new ContentType("*","*");

        Assert.assertTrue(type2.matchesWildcard(type1));
        Assert.assertFalse(type2.matches(type1));
        Assert.assertFalse(type1.matches(type2));
    }
View Full Code Here

        Assert.assertFalse(type1.matches(type2));
    }

    @Test
    public void testMatchQualifier1() throws Exception {
        ContentType type1 = new ContentType("application","rdf+json");
        ContentType type2 = new ContentType("application","json");

        Assert.assertFalse(type2.matches(type1));
        Assert.assertTrue(type2.matchesSubtype(type1));
        Assert.assertFalse(type1.matchesSubtype(type2));
    }
View Full Code Here

        Assert.assertTrue(type2.matchesSubtype(type1));
        Assert.assertFalse(type1.matchesSubtype(type2));
    }
    @Test
    public void testMatchQualifier2() throws Exception {
        ContentType type1 = new ContentType("application","rdf+json");
        ContentType type2 = new ContentType("application","*");

        Assert.assertTrue(type2.matchesWildcard(type1));
        Assert.assertFalse(type2.matchesSubtype(type1));
        Assert.assertFalse(type1.matchesSubtype(type2));
    }
View Full Code Here

    }


    @Test
    public void testGetBestMatch1() throws Exception {
        ContentType offered1 = new ContentType("text","html");
        ContentType offered2 = new ContentType("application","rdf+json");
        ContentType offered3 = new ContentType("application","ld+json");

        List<ContentType> offered = new ArrayList<ContentType>(3);
        offered.add(offered1);
        offered.add(offered2);
        offered.add(offered3);

        ContentType accepted1 = new ContentType("application","json");
        ContentType accepted2 = new ContentType("*","*");
        List<ContentType> accepted = new ArrayList<ContentType>(2);
        accepted.add(accepted1);
        accepted.add(accepted2);

        Assert.assertEquals(offered2, MarmottaHttpUtils.bestContentType(offered,accepted));
View Full Code Here

        Assert.assertEquals(offered2, MarmottaHttpUtils.bestContentType(offered,accepted));
    }

    @Test
    public void testGetBestMatch2() throws Exception {
        ContentType offered1 = new ContentType("text","html");
        ContentType offered2 = new ContentType("application","rdf+json");
        ContentType offered3 = new ContentType("application","ld+json");

        List<ContentType> offered = new ArrayList<ContentType>(3);
        offered.add(offered1);
        offered.add(offered2);
        offered.add(offered3);

        ContentType accepted1 = new ContentType("application","xml");
        ContentType accepted2 = new ContentType("*","*");
        List<ContentType> accepted = new ArrayList<ContentType>(2);
        accepted.add(accepted1);
        accepted.add(accepted2);

        Assert.assertEquals(offered1, MarmottaHttpUtils.bestContentType(offered,accepted));
View Full Code Here

TOP

Related Classes of org.apache.marmotta.commons.http.ContentType

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.