Package org.apache.ojb.odmg.shared

Examples of org.apache.ojb.odmg.shared.Article


        tx.commit();
    }

    private Article createArticle()
    {
        Article example = new Article();
        example.setArticleName(testProductGroup.getName());
        example.setProductGroupId(testProductGroup.getId());
        return example;
    }
View Full Code Here


    {
        String bindingName = "testBind_" + System.currentTimeMillis();
        TransactionImpl tx = (TransactionImpl) odmg.newTransaction();
        //bind object to name
        tx.begin();
        Article example = createArticle();
        database.bind(example, bindingName);
        Article value = (Article) database.lookup(bindingName);
        assertTrue("Could not lookup object for binding name: "+bindingName, value != null);
        tx.commit();

        try
        {
View Full Code Here

    public void testDoubleBindInOneTx() throws Exception
    {
        String bindingName = "testDoubleBindInOneTx_" + System.currentTimeMillis();

        Article article = createArticle();
        Article foundArticle = null;

        Transaction tx = odmg.newTransaction();
        tx.begin();
        database.bind(article, bindingName);
View Full Code Here

        String bindingName = "testLookup_" + System.currentTimeMillis();
        // clear named roots.
        TransactionImpl tx = (TransactionImpl) odmg.newTransaction();
        //bind object to name
        tx.begin();
        Article example = createArticle();
        database.makePersistent(example);
        tx.commit();

        tx.begin();
        database.bind(example, bindingName);
        tx.commit();

        // TestThreadsNLocks look up
        Article lookedUp1 = null;
        tx = (TransactionImpl) odmg.newTransaction();
        tx.begin();
        // lookup by name binding
        lookedUp1 = (Article) database.lookup(bindingName);
        tx.commit();
View Full Code Here

        String name = "testUnBind_" + System.currentTimeMillis();

        Transaction tx = odmg.newTransaction();
        //bind object to name
        tx.begin();
        Article example = createArticle();
        database.makePersistent(example);
        tx.commit();

        // 1. perform binding
        tx.begin();
        try
        {
            database.bind(example, name);
            tx.commit();
        }
        catch (ObjectNameNotUniqueException ex)
        {
            tx.abort();
            fail(ex.getMessage());
        }

        // 2. perform unbind
        tx = odmg.newTransaction();
        tx.begin();
        try
        {
            database.unbind(name);
            tx.commit();
        }
        catch (ObjectNameNotFoundException ex)
        {
            tx.abort();
            fail("name " + name + "should be known");
        }

        // 3. check if name is really unknown now
        tx = odmg.newTransaction();
        tx.begin();
        try
        {
            Article value = (Article) database.lookup(name);
            assertNotNull("Should not find unbind name '" + name+"'", value);
            fail("name " + name + " should not be known after unbind");
        }
        catch (ObjectNameNotFoundException ex)
        {
View Full Code Here

    }

    protected Article createArticle(String name) throws Exception
    {

        Article a = new Article();
        a.setArticleName(productGroup.getName() + name);
        a.setStock(234);
        a.setProductGroup(productGroup);
        return a;
    }
View Full Code Here

        tx.begin();
        DMap map = odmg.newDMap();

        database.bind(map, namedObject);
        Article key1 = createArticle(name + "_key1");
        Article val1 = createArticle(name + "_val1");
        Article key2 = createArticle(name + "_key2");
        Article val2 = createArticle(name + "_val2");

        map.put(key1, val1);
        map.put(key2, val2);
        tx.commit();


        tx = (TransactionExt) odmg.newTransaction();
        tx.begin();
        tx.getBroker().clearCache();

        DMap mapA = (DMap) database.lookup(namedObject);
        assertNotNull(mapA);
        Article val1A = (Article) mapA.get(key1);
        assertNotNull(val1A);
        assertEquals(val1.getArticleId(), val1A.getArticleId());
        Article val2A = (Article) mapA.get(key2);
        assertNotNull(val2A);
        assertEquals(val2.getArticleId(), val2A.getArticleId());
        tx.commit();
    }
View Full Code Here

        tx.begin();
        DMap map = odmg.newDMap();

        database.bind(map, namedObject);
        Article key1 = createArticle(name + "_key1");
        Article val1 = createArticle(name + "_val1");
        Article key2 = createArticle(name + "_key2");
        Article val2 = createArticle(name + "_val2");

        map.put(key1, val1);
        map.put(key2, val2);
        tx.commit();


        tx = (TransactionExt) odmg.newTransaction();
        tx.begin();
        tx.getBroker().clearCache();

        DMap mapA = (DMap) database.lookup(namedObject);
        assertNotNull(mapA);
        Article val1A = (Article) mapA.get(key1);
        assertNotNull(val1A);
        assertEquals(val1.getArticleId(), val1A.getArticleId());
        Article val2A = (Article) mapA.get(key2);
        assertNotNull(val2A);
        assertEquals(val2.getArticleId(), val2A.getArticleId());
        tx.commit();

        tx.begin();
        mapA.remove(key1);

        tx.checkpoint();

        mapA = (DMap) database.lookup(namedObject);
        assertNotNull(mapA);
        val1A = (Article) mapA.get(key1);
        assertNull(val1A);
        val2A = (Article) mapA.get(key2);
        assertNotNull(val2A);
        assertEquals(val2.getArticleId(), val2A.getArticleId());
        tx.commit();

        tx.begin();
        mapA.remove(key2);
        mapA.put(key2, val2);

        tx.checkpoint();

        mapA = (DMap) database.lookup(namedObject);
        assertNotNull(mapA);
        val1A = (Article) mapA.get(key1);
        assertNull(val1A);
        val2A = (Article) mapA.get(key2);
        assertNotNull(val2A);
        assertEquals(val2.getArticleId(), val2A.getArticleId());
        tx.commit();

        tx.begin();
        mapA.remove(key2);
        tx.commit();
View Full Code Here

    }

    private static int count = 0;
    private Article createArticle()
    {
        Article example = new Article();
        example.setArticleId(++count);
        example.setArticleName("named roots article No. "+(count));
        example.setProductGroupId(1);

        return example;
    }
View Full Code Here

        //open database
        db.open(databaseName, Database.OPEN_READ_WRITE);
        // clean up roots map
        clearNRM();

        Article example = createArticle();

        Transaction tx = odmg.newTransaction();
        tx.begin();
        try
        {
            db.bind(example, bindingName);
            Article value = (Article) db.lookup(bindingName);
            assertTrue("Could not lookup object for binding name: "+bindingName, value != null);
            tx.commit();
        }
        catch (ObjectNameNotFoundException ex)
        {
View Full Code Here

TOP

Related Classes of org.apache.ojb.odmg.shared.Article

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.