Package org.apache.abdera.ext.opensearch.model

Examples of org.apache.abdera.ext.opensearch.model.OpenSearchDescription


        XMLUnit.setXpathNamespaceContext(new SimpleNamespaceContext(nsContext));
    }
   
    @Test
    public void testOpenSearchDescriptionDocumentCreation() throws Exception {
        OpenSearchDescription document = new OpenSearchDescription(Abdera.getInstance());
       
        document.setShortName(SHORT_NAME);
        document.setDescription(DESCRIPTION);
        document.setTags(TAG1, TAG2);
       
        Url url = new Url(Abdera.getInstance());
        url.setType(URL_TYPE);
        url.setTemplate(URL_TEMPLATE);
       
        Query query = new Query(Abdera.getInstance());
        query.setRole(Query.Role.EXAMPLE);
        query.setSearchTerms(QUERY_TERMS);
       
        document.addUrls(url);
        document.addQueries(query);
       
        StringWriter writer = new StringWriter();
        document.writeTo(writer);
       
        String result = writer.toString();
       
        System.out.print(result);
       
View Full Code Here


        expect(requestMock.getAbdera()).andReturn(Abdera.getInstance()).anyTimes();
        expect(requestMock.getBaseUri()).andReturn(new IRI("http://www.acme.org/")).anyTimes();
       
        replay(requestMock);
       
        OpenSearchDescription description = this.osInfo.asOpenSearchDescriptionElement(requestMock);
        StringWriter writer = new StringWriter();
        description.writeTo(writer);
       
        String result = writer.toString();
        System.out.print(result);
       
        assertXpathEvaluatesTo(SHORT_NAME, "/os:OpenSearchDescription/os:ShortName", result);
View Full Code Here

    private OpenSearchInfo openSearchInfo;

    public ResponseContext process(RequestContext requestContext, WorkspaceManager workspaceManager, CollectionAdapter collectionAdapter) {
        String method = requestContext.getMethod();
        if (method.equalsIgnoreCase("GET")) {
            OpenSearchDescription description = this.openSearchInfo.asOpenSearchDescriptionElement(requestContext);
            ResponseContext response = new BaseResponseContext(description);
            response.setContentType(OpenSearchConstants.OPENSEARCH_DESCRIPTION_CONTENT_TYPE);
            return response;
        } else {
            return null;
View Full Code Here

        expect(requestMock.getAbdera()).andReturn(Abdera.getInstance()).anyTimes();
        expect(requestMock.getBaseUri()).andReturn(new IRI("http://www.acme.org/")).anyTimes();

        replay(requestMock);

        OpenSearchDescription description = this.osInfo.asOpenSearchDescriptionElement(requestMock);
        StringWriter writer = new StringWriter();
        description.writeTo(writer);

        String result = writer.toString();
        System.out.print(result);

        assertXpathEvaluatesTo(SHORT_NAME, "/os:OpenSearchDescription/os:ShortName", result);
View Full Code Here

    public void setUrls(OpenSearchUrlInfo... urls) {
        this.urls = urls;
    }

    public OpenSearchDescription asOpenSearchDescriptionElement(RequestContext request) {
        OpenSearchDescription document = new OpenSearchDescription(request.getAbdera());
        document.setShortName(this.shortName);
        document.setDescription(this.description);
        document.setTags(this.tags);

        if (this.urls != null) {
            List<Url> urlElements = new ArrayList<Url>(this.urls.length);
            for (OpenSearchUrlInfo urlInfo : this.urls) {
                urlElements.add(urlInfo.asUrlElement(request));
            }
            document.addUrls(urlElements.toArray(new Url[this.urls.length]));
        }

        if (this.queries != null) {
            List<Query> queryElements = new ArrayList<Query>(this.queries.length);
            for (OpenSearchQueryInfo queryInfo : this.queries) {
                queryElements.add(queryInfo.asQueryElement(request));
            }
            document.addQueries(queryElements.toArray(new Query[this.queries.length]));
        }

        return document;
    }
View Full Code Here

        XMLUnit.setXpathNamespaceContext(new SimpleNamespaceContext(nsContext));
    }

    @Test
    public void testOpenSearchDescriptionDocumentCreation() throws Exception {
        OpenSearchDescription document = new OpenSearchDescription(Abdera.getInstance());

        document.setShortName(SHORT_NAME);
        document.setDescription(DESCRIPTION);
        document.setTags(TAG1, TAG2);

        Url url = new Url(Abdera.getInstance());
        url.setType(URL_TYPE);
        url.setTemplate(URL_TEMPLATE);

        Query query = new Query(Abdera.getInstance());
        query.setRole(Query.Role.EXAMPLE);
        query.setSearchTerms(QUERY_TERMS);

        document.addUrls(url);
        document.addQueries(query);

        StringWriter writer = new StringWriter();
        document.writeTo(writer);

        String result = writer.toString();

        System.out.print(result);
View Full Code Here

    public ResponseContext process(RequestContext requestContext,
                                   WorkspaceManager workspaceManager,
                                   CollectionAdapter collectionAdapter) {
        String method = requestContext.getMethod();
        if (method.equalsIgnoreCase("GET")) {
            OpenSearchDescription description = this.openSearchInfo.asOpenSearchDescriptionElement(requestContext);
            ResponseContext response = new BaseResponseContext(description);
            response.setContentType(OpenSearchConstants.OPENSEARCH_DESCRIPTION_CONTENT_TYPE);
            return response;
        } else {
            return null;
View Full Code Here

TOP

Related Classes of org.apache.abdera.ext.opensearch.model.OpenSearchDescription

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.