Package org.apache.lucene.gdata.data

Examples of org.apache.lucene.gdata.data.ServerBaseEntry


     */
    @SuppressWarnings("unchecked")
    public void testStoreEntry() throws StorageException {
        Storage storage = this.controller.getStorage();
        try {
            ServerBaseEntry e = createServerBaseEntry();
            storage.storeEntry(e);
            fail("excption exp. for feed for the entry");
        } catch (StorageException e) {
            //
        }

        try {

            storage.storeEntry(null);
            fail("entry is null");
        } catch (StorageException e) {
            //
        }
        ServerBaseEntry exEntry = new ServerBaseEntry();
        exEntry.setFeedId("some");
        try {

            storage.storeEntry(exEntry);
            fail("entry id is null");
        } catch (StorageException e) {
            //
        }
        exEntry.setId("someID");
        exEntry.setFeedId(null);
        try {

            storage.storeEntry(exEntry);
            fail("feed id is null");
        } catch (StorageException e) {
            //
        }

        storeServerBaseFeed();
        ServerBaseEntry e = createServerBaseEntry();
        storage.storeEntry(e);
        ServerBaseEntry e1 = createServerBaseEntry();
        storage.storeEntry(e1);

        storage = this.controller.getStorage();
        Query query = getContainer().query();
        query.constrain(BaseEntry.class);
        query.descend("id").constrain(e.getId());
        ObjectSet resultSet = query.execute();
        assertEquals(1, resultSet.size());
        BaseEntry storedEntry = (BaseEntry) resultSet.next();
        assertEquals("1", storedEntry.getVersionId());

        ServerBaseFeed bFeed = new ServerBaseFeed();
        bFeed.setItemsPerPage(25);
        bFeed.setId(FEEDID);
        bFeed.setStartIndex(1);
        bFeed.setServiceType(SERVICENAME);
        BaseFeed<BaseFeed, BaseEntry> feed = storage.getFeed(bFeed);
        assertEquals(2, feed.getEntries().size());
        assertEquals(e.getId(), feed.getEntries().get(1).getId()); // last post
        // ->
        // previously
        // created
        assertEquals(e1.getId(), feed.getEntries().get(0).getId()); // first pos
        // -> last
        // created
        assertEquals(feed.getUpdated(), feed.getEntries().get(0).getUpdated());
    }
View Full Code Here


            storage.deleteEntry(null);
            fail("entry is null");
        } catch (StorageException e) {
            //
        }
        ServerBaseEntry exEntry = new ServerBaseEntry();
        exEntry.setFeedId("some");
        try {

            storage.deleteEntry(exEntry);
            fail("entry id is null");
        } catch (StorageException e) {
            //
        }
        exEntry.setId("someID");
        exEntry.setFeedId(null);
        try {

            storage.storeEntry(exEntry);
            fail("feed id is null");
        } catch (StorageException e) {
            //
        }
       
       
        ServerBaseEntry e = createServerBaseEntry();
        storage.storeEntry(e);
        ServerBaseEntry e1 = createServerBaseEntry();
        storage.storeEntry(e1);

        storage.deleteEntry(e);

        container.close();
        container = getContainer();
        Query query = container.query();
        query.constrain(BaseEntry.class);
        query.descend("id").constrain(e.getId());
        ObjectSet resultSet = query.execute();
        assertEquals(0, resultSet.size());

        // #### test version matching
        ServerBaseEntry eVersion = createServerBaseEntry();
        storage.storeEntry(eVersion);
        eVersion.setVersion(33);
        try {
            storage.deleteEntry(eVersion);
            fail("version does not match");
        } catch (Exception ex) {
            // TODO: handle exception
View Full Code Here

     * 'org.apache.lucene.gdata.storage.db4o.DB4oStorage.updateEntry(ServerBaseEntry)'
     */
    public void testUpdateEntry() throws StorageException, InterruptedException {
        storeServerBaseFeed();
        Storage storage = this.controller.getStorage();
        ServerBaseEntry exEntry = new ServerBaseEntry();
       

        try {

            storage.updateEntry(null);
            fail("entry is null");
        } catch (StorageException e) {
            //
        }

        try {

            storage.updateEntry(exEntry);
            fail("entry id is null");
        } catch (StorageException e) {
            //
        }
        exEntry.setId("someID");
        try {

            storage.updateEntry(exEntry);
            fail("feed id is null");
        } catch (StorageException e) {
            //
        }
       
       
       
        ServerBaseEntry e = createServerBaseEntry();
        ServerBaseEntry e1 = createServerBaseEntry();
        try {
            storage.updateEntry(e);
            fail("entry does not exist");
        } catch (StorageException ex) {
            ex.printStackTrace();
        }
        storage.storeEntry(e);

        storage = this.controller.getStorage();

        storage.storeEntry(e1);
        ServerBaseEntry e2 = createServerBaseEntry();
        e2.setId(e.getId());
        e2.setTitle(new PlainTextConstruct("new"));
        e2.setUpdated(DateTime.now());
        storage.updateEntry(e2);
        ObjectContainer container = getContainer();
        Query query = container.query();
        query.constrain(BaseEntry.class);
        query.descend("id").constrain(e.getId());
        ObjectSet resultSet = query.execute();
        assertEquals(1, resultSet.size());
        BaseEntry result = (BaseEntry) resultSet.next();
        assertEquals("new", result.getTitle().getPlainText());
        assertEquals("2", result.getVersionId());

        ServerBaseFeed bFeed = new ServerBaseFeed();
        bFeed.setItemsPerPage(25);
        bFeed.setId(FEEDID);
        bFeed.setStartIndex(1);
        bFeed.setServiceType(SERVICENAME);
        storage = this.controller.getStorage();
        BaseFeed<BaseFeed, BaseEntry> feed = storage.getFeed(bFeed);

        assertEquals(2, feed.getEntries().size());
        assertEquals(e.getId(), feed.getEntries().get(0).getId());
        assertEquals(feed.getUpdated(), feed.getEntries().get(0).getUpdated());

        storage = this.controller.getStorage();
        storage.storeEntry(e);

        e2.setVersion(5);
        try {
            storage.updateEntry(e2);
            fail("version does not match");
        } catch (Exception ex) {
            // TODO: handle exception
View Full Code Here

        feed.setId(FEEDID);
        BaseFeed result = storage.getFeed(feed);
        assertNotNull(result);
        assertEquals(0, result.getEntries().size());
        List<String> idlist = new ArrayList<String>(30);
        ServerBaseEntry e1 = null;
        for (int i = 0; i < 30; i++) {
            e1 = createServerBaseEntry();
            storage.storeEntry(e1);
            idlist.add(0, e1.getId());
        }
        String firstId = e1.getId();

        storage = this.controller.getStorage();
        result = storage.getFeed(feed);
        assertNotNull(result);
        assertEquals(25, result.getEntries().size());
View Full Code Here

     * 'org.apache.lucene.gdata.storage.db4o.DB4oStorage.getEntry(ServerBaseEntry)'
     */
    public void testGetEntry() throws StorageException {
        storeServerBaseFeed();
        Storage storage = this.controller.getStorage();
        ServerBaseEntry exEntry = createServerBaseEntry();
        exEntry.setId(null);
        try{
        storage.getEntry(exEntry);
        fail("id is null");
        }catch (StorageException e) {

        }
        ServerBaseEntry e = createServerBaseEntry();
        storage.storeEntry(e);
        ServerBaseEntry e1 = createServerBaseEntry();
        storage.storeEntry(e1);
       
        storage = this.controller.getStorage();
        BaseEntry result = storage.getEntry(e);
        assertNotNull(result);
        assertEquals(e.getId(), result.getId());
        try {
            e1.setId("hello");
            result = storage.getEntry(e1);
            fail("no such entry");
        } catch (StorageException ex) {
            ex.printStackTrace();
        }
View Full Code Here

        }

    }

    private static ServerBaseEntry createServerBaseEntry() {
        ServerBaseEntry e = new ServerBaseEntry();
        e.setId(System.currentTimeMillis() + "");
        ProvidedServiceConfig conf = new ProvidedServiceConfig();
        conf.setName(SERVICENAME);
        e.setServiceConfig(conf);
        e.setUpdated(DateTime.now());
        e.setFeedId(FEEDID);
        try {
            Thread.sleep(2);
        } catch (InterruptedException e1) {

            e1.printStackTrace();
View Full Code Here

    }

    public void testEntryLastModified() {
        ServerBaseFeed feed = storeServerBaseFeed();
        Storage s = this.controller.getStorage();
        ServerBaseEntry en = createServerBaseEntry();
        s.storeEntry(en);
        assertEquals(en.getUpdated().getValue(), s.getEntryLastModified(
                en.getId(), FEEDID).longValue());
        try {
            s.getEntryLastModified(null, null);
            fail("id is null");
        } catch (StorageException e) {
View Full Code Here

            throws ServiceException {

        if (LOG.isInfoEnabled())
            LOG.info("create Entry for feedId: " + request.getFeedId());

        ServerBaseEntry entry = buildEntry(request, response);
        entry.setFeedId(request.getFeedId());
        entry.setServiceConfig(request.getConfigurator());
        BaseEntry tempEntry = entry.getEntry();
        tempEntry.setPublished(getCurrentDateTime());
        tempEntry.setUpdated(getCurrentDateTime());
        BaseEntry retVal = null;
        removeDynamicElements(entry.getEntry());
        try {
            retVal = this.storage.storeEntry(entry);
        } catch (Exception e) {
           
            ServiceException ex = new ServiceException("Could not store entry",
View Full Code Here

     */

    public BaseEntry deleteEntry(GDataRequest request, GDataResponse response)
            throws ServiceException {

        ServerBaseEntry entry = new ServerBaseEntry();
        entry.setServiceConfig(request.getConfigurator());
        entry.setFeedId(request.getFeedId());
        entry.setId(request.getEntryId());
        setVersionId(entry,request,response);
        if (entry.getId() == null)
            throw new ServiceException(
                    "entry id is null -- can not delete null entry",GDataResponse.SERVER_ERROR);
        try {
            this.storage.deleteEntry(entry);
           
View Full Code Here

        fail("not initialized");
        }catch (IllegalStateException e) {
            // TODO: handle exception
        }
        this.controller.initialize();
        ServerBaseEntry e = new ServerBaseEntry();
        e.setId("someId");
        e.setFeedId("someId");
        e.setServiceConfig(new ProvidedServiceStub());
        this.controller.fireInsertEvent(e);
    }
View Full Code Here

TOP

Related Classes of org.apache.lucene.gdata.data.ServerBaseEntry

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.