Package org.apache.abdera.model

Examples of org.apache.abdera.model.Service


     */
    @Test
    public void testCollectionAccepts() throws Exception {
        Abdera abdera = new Abdera();
        Factory factory = abdera.getFactory();
        Service svc = factory.newService();
        Workspace ws = svc.addWorkspace("test-ws");
        Collection coll = ws.addCollection("test-coll", ws.getTitle() + "/test-coll");
        coll.setAcceptsEntry();
        assertTrue("Collection does not accept entries.", coll.acceptsEntry());
        coll.addAccepts("application/apples");
        assertTrue("Collection does not accept apples.", coll.accepts("application/apples"));
        StringWriter sw = new StringWriter();
        svc.writeTo(sw);
        // System.out.println(sw);
        String s = sw.toString();
        assertTrue("Service document does not specify acceptance of entries.", s
            .contains("application/atom+xml; type=entry"));
        assertTrue("Service document does not specify acceptance of apples.", s.contains("application/apples"));
View Full Code Here


     */
    @Test
    public void testCollectionAcceptsMultipart() throws Exception {
        Abdera abdera = new Abdera();
        Factory factory = abdera.getFactory();
        Service svc = factory.newService();
        Workspace ws = svc.addWorkspace("test-ws");
        FOMMultipartCollection coll =
            (FOMMultipartCollection)ws.addMultipartCollection("test multipart coll", "/test-coll");
        coll.setAcceptsEntry();
        coll.addAccepts("image/*", "multipart-related");

        assertTrue("Collection does not accept entries.", coll.acceptsEntry());
        assertTrue("Collection does not accept multipart related images", coll.acceptsMultipart("image/*"));

        StringWriter sw = new StringWriter();
        svc.writeTo(sw);

        String s = sw.toString();
        assertTrue("Service document does not specify acceptance of entries.", s
            .contains("application/atom+xml; type=entry"));
        assertTrue("Service document does not specify acceptance of apples.", s.contains("image/*"));
 
View Full Code Here

        ClientResponse resp = client.get("http://localhost:9002/");
        assertNotNull(resp);
        assertEquals(ResponseType.SUCCESS, resp.getType());
        assertTrue(MimeTypeHelper.isMatch(resp.getContentType().toString(), Constants.APP_MEDIA_TYPE));
        Document<Service> doc = resp.getDocument();
        Service service = doc.getRoot();
        assertEquals(1, service.getWorkspaces().size());
        Workspace workspace = service.getWorkspace("Abdera");
        assertEquals(1, workspace.getCollections().size());
        Collection collection = workspace.getCollection("title for any sample feed");
        assertNotNull(collection);
        assertTrue(collection.acceptsEntry());
        assertEquals("http://localhost:9002/sample", collection.getResolvedHref().toString());
View Full Code Here

        Document<Service> doc = resp.getDocument();
        try {
            prettyPrint(doc);
        } catch (Exception e) {
        }
        Service service = doc.getRoot();
        prettyPrint(service);
        assertEquals(1, service.getWorkspaces().size());
        Workspace workspace = service.getWorkspaces().get(0);
        assertEquals(1, workspace.getCollections().size());
        Collection collection = workspace.getCollections().get(0);
        assertEquals(BASE + "/feed", collection.getResolvedHref().toString());
        assertEquals("A simple feed", collection.getTitle().toString());
        resp.release();
View Full Code Here

        AbderaClient abderaClient = new AbderaClient(abdera);
        abderaClient.addCredentials(start, null, null, new UsernamePasswordCredentials("username", "password"));

        // Get the service document and look up the collection uri
        Document<Service> service_doc = abderaClient.get(start).getDocument();
        Service service = service_doc.getRoot();
        Collection collection = service.getWorkspaces().get(0).getCollections().get(0);
        String uri = collection.getHref().toString();

        // Post the entry to the collection
        Response response = abderaClient.post(uri, entry);
View Full Code Here

        AbderaClient abderaClient = new AbderaClient(abdera);
        abderaClient.addCredentials(start, null, null, new UsernamePasswordCredentials("username", "password"));

        // Get the service doc and locate the href of the collection
        Document<Service> service_doc = abderaClient.get(start).getDocument();
        Service service = service_doc.getRoot();
        Collection collection = service.getWorkspaces().get(0).getCollections().get(1);
        String uri = collection.getHref().toString();

        // Set the filename. Note: the Title header was used by older drafts
        // of the Atom Publishing Protocol and should no longer be used. The
        // current Roller APP implementation still currently requires it.
View Full Code Here

    @Test
    public void testSelectors() throws Exception {

        Abdera abdera = Abdera.getInstance();
        Service service = abdera.newService();
        Workspace workspace = service.addWorkspace("a");
        Collection collection1 = workspace.addCollection("a1", "a1");
        collection1.setAcceptsEntry();
        Features features = FeaturesHelper.addFeaturesElement(collection1);
        features.addFeature(FeaturesHelper.FEATURE_SUPPORTS_DRAFTS);
        Collection collection2 = workspace.addCollection("a2", "a2");
View Full Code Here

            String workspaceURL = new String( href );
            int pathIndex = workspaceURL.indexOf( request.getServletPath() );
            if ( -1 != pathIndex )
              workspaceURL = workspaceURL.substring( 0, pathIndex ) + "/";

            Service service = abderaFactory.newService();
            //service.setText("service");
           
            Workspace workspace = abderaFactory.newWorkspace();
            if ( title != null )
                workspace.setTitle(title);
            else
                workspace.setTitle("workspace");
            workspace.setBaseUri( new IRI( workspaceURL ));
           
          Collection collection = workspace.addCollection("collection", href );
            Feed feed = getFeed( request );
            if ( feed != null ) {
              String title = feed.getTitle();
              if ( title != null )
                collection.setTitle(title);
              else
                  collection.setTitle("entries");
              collection.addAccepts("application/atom+xml;type=feed");
              collection.addAccepts("application/json;type=feed");
              collection.addAccepts("application/atom+xml;type=entry");
              collection.addAccepts("application/json;type=entry");
              List<Category> categories = feed.getCategories();
              if ( categories != null ) {
                     collection.addCategories(categories, false, null);
              } else
                  collection.addCategories().setFixed(false);                           
             
            } else {
              collection.setTitle("entries");
              // collection.addAccepts("application/atom+xml;type=feed");
              collection.addAccepts("application/atom+xml; type=entry");
              collection.addAccepts("application/json;type=entry");
              collection.addCategories().setFixed(false);           
            }
          workspace.addCollection(collection);

            service.addWorkspace(workspace);

            //FIXME add prettyPrint support
            try {
                service.getDocument().writeTo(response.getOutputStream());
            } catch (IOException ioe) {
                throw new ServletException(ioe);
            }

        } else if (path == null || path.length() == 0 || path.equals("/")) {
View Full Code Here

      Assert.assertEquals(ResponseType.SUCCESS, res.getType());

        // Perform other tests on feed.
        // AtomTestCaseUtils.prettyPrint(abdera, res.getDocument());       
      Document<Service> serviceDoc = res.getDocument();
      Service service = serviceDoc.getRoot();
      Assert.assertNotNull( service );
      org.apache.abdera.model.Collection collection =  service.getCollection( "workspace", "customers" );
      String title = collection.getTitle();
      Assert.assertEquals("customers", title);
      String href = collection.getHref().toString();
      Assert.assertTrue( href.contains( "customer") );
    } finally {
View Full Code Here

            int pathIndex = workspaceURL.indexOf( request.getServletPath() );
            if ( -1 != pathIndex ) {
                workspaceURL = workspaceURL.substring( 0, pathIndex ) + "/";
            }

            Service service = abderaFactory.newService();
            //service.setText("service");

            Workspace workspace = abderaFactory.newWorkspace();
            if ( title != null ) {
                workspace.setTitle(title);
            } else {
                workspace.setTitle("workspace");
            }
            workspace.setBaseUri( new IRI( workspaceURL ));

            Collection collection = workspace.addCollection("collection", href );
            Feed feed = getFeed( request );
            if ( feed != null ) {
                String title = feed.getTitle();
                if ( title != null ) {
                    collection.setTitle(title);
                } else {
                    collection.setTitle("entries");
                }
                collection.addAccepts("application/atom+xml");
                collection.addAccepts("application/json");
                List<Category> categories = feed.getCategories();
                if ( categories != null ) {
                    collection.addCategories(categories, false, null);
                } else {
                    collection.addCategories().setFixed(false);
                }

            } else {
                collection.setTitle("entries");

                collection.addAccepts("application/atom+xml");
                collection.addAccepts("application/json");
                collection.addCategories().setFixed(false);
            }
            workspace.addCollection(collection);
            service.addWorkspace(workspace);

            //FIXME add prettyPrint support
            try {
                service.getDocument().writeTo(response.getOutputStream());
            } catch (IOException ioe) {
                throw new ServletException(ioe);
            }

        } else if (path == null || path.length() == 0 || path.equals("/")) {
View Full Code Here

TOP

Related Classes of org.apache.abdera.model.Service

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.