Package org.apache.ojb.ejb

Examples of org.apache.ojb.ejb.CategoryVO


    public void testODMGCollectionRetrieve() throws Exception
    {
        long timestamp = System.currentTimeMillis();
        String articleame = "collection_test_article" + timestamp;
        String categoryName = "collection_test_category" + timestamp;
        CategoryVO cat = odmgCreatePersistentCategoryWithArticles(categoryName, articleame, 5);

        assertNotNull(cat.getObjId());
        assertNotNull(cat.getAssignedArticles());
        assertEquals("Wrong number of referenced articles found", 5, cat.getAssignedArticles().size());

        Collection result = odmgArticleBean.getCategoryByName(categoryName);
        assertNotNull(result);
        assertEquals(1, result.size());
        cat = (CategoryVO) result.iterator().next();
        Collection articlesCol = cat.getAssignedArticles();
        assertNotNull(articlesCol);
        assertEquals("Wrong number of referenced articles found", 5, articlesCol.size());
    }
View Full Code Here


    public void testODMGQueryObjects() throws Exception
    {
        long timestamp = System.currentTimeMillis();
        String articleName = "query_test_article_" + timestamp;
        String categoryName = "query_test_category_" + timestamp;
        CategoryVO cat1 = odmgCreatePersistentCategoryWithArticles(categoryName, articleName, 6);
        CategoryVO cat2 = odmgCreatePersistentCategoryWithArticles(categoryName, articleName, 6);
        CategoryVO cat3 = odmgCreatePersistentCategoryWithArticles(categoryName, articleName, 6);

        Collection result = odmgArticleBean.getArticles(articleName);
        assertNotNull(result);
        assertEquals("Wrong number of articles", 18, result.size());

        result = odmgArticleBean.getCategoryByName(categoryName);
        assertNotNull(result);
        assertEquals("Wrong number of returned category objects", 3, result.size());
        CategoryVO cat = (CategoryVO) result.iterator().next();
        assertNotNull(cat);
        Collection articles = cat.getAssignedArticles();
        assertNotNull(articles);
        assertEquals("Wrong number of referenced articles", 6, articles.size());
    }
View Full Code Here

    }

    private CategoryVO odmgCreatePersistentCategoryWithArticles(
            String categoryName, String articleName, int articleCount) throws Exception
    {
        CategoryVO cat = VOHelper.createNewCategory(categoryName);
        // store new category
        cat = odmgArticleBean.storeCategory(cat);
        ArrayList articles = new ArrayList();
        for (int i = 0; i < articleCount; i++)
        {
            ArticleVO art = VOHelper.createNewArticle(articleName, 1);
            // set category
            art.setCategory(cat);
            // store article
            art = odmgArticleBean.storeArticle(art);
            articles.add(art);
        }
        // set article collection
        if(articles.size() > 0) cat.setAssignedArticles(articles);
        // persist updated category
        cat = odmgArticleBean.storeCategory(cat);

        return cat;
    }
View Full Code Here

    public void testPBCollectionRetrieve() throws Exception
    {
        long timestamp = System.currentTimeMillis();
        String articleame = "collection_test_article" + timestamp;
        String categoryName = "collection_test_category" + timestamp;
        CategoryVO cat = pbCreatePersistentCategoryWithArticles(categoryName, articleame, 5);

        assertNotNull(cat.getObjId());
        assertNotNull(cat.getAssignedArticles());
        assertEquals("Wrong number of referenced articles found", 5, cat.getAssignedArticles().size());

        Collection result = pbArticleBean.getCategoryByName(categoryName);
        assertNotNull(result);
        assertEquals(1, result.size());
        cat = (CategoryVO) result.iterator().next();
        Collection articlesCol = cat.getAssignedArticles();
        assertNotNull(articlesCol);
        assertEquals("Wrong number of referenced articles found", 5, articlesCol.size());
    }
View Full Code Here

    public void testPBQueryObjects() throws Exception
    {
        long timestamp = System.currentTimeMillis();
        String articleName = "query_test_article_" + timestamp;
        String categoryName = "query_test_category_" + timestamp;
        CategoryVO cat1 = pbCreatePersistentCategoryWithArticles(categoryName, articleName, 6);
        CategoryVO cat2 = pbCreatePersistentCategoryWithArticles(categoryName, articleName, 6);
        CategoryVO cat3 = pbCreatePersistentCategoryWithArticles(categoryName, articleName, 6);

        Collection result = pbArticleBean.getArticles(articleName);
        assertNotNull(result);
        assertEquals("Wrong number of articles", 18, result.size());

        result = pbArticleBean.getCategoryByName(categoryName);
        assertNotNull(result);
        assertEquals("Wrong number of returned category objects", 3, result.size());
        CategoryVO cat = (CategoryVO) result.iterator().next();
        assertNotNull(cat);
        Collection articles = cat.getAssignedArticles();
        assertNotNull(articles);
        assertEquals("Wrong number of referenced articles", 6, articles.size());
    }
View Full Code Here

    }

    private CategoryVO pbCreatePersistentCategoryWithArticles(
            String categoryName, String articleName, int articleCount) throws Exception
    {
        CategoryVO cat = VOHelper.createNewCategory(categoryName);
        // store new category
        cat = pbArticleBean.storeCategory(cat);
        ArrayList articles = new ArrayList();
        for (int i = 0; i < articleCount; i++)
        {
            ArticleVO art = VOHelper.createNewArticle(articleName, 1);
            // set category
            art.setCategory(cat);
            // store article
            art = pbArticleBean.storeArticle(art);
            articles.add(art);
        }
        // set article collection
        if(articles.size() > 0) cat.setAssignedArticles(articles);
        // persist updated category
        cat = pbArticleBean.storeCategory(cat);

        return cat;
    }
View Full Code Here

    public void testODMGCollectionRetrieve() throws Exception
    {
        long timestamp = System.currentTimeMillis();
        String articleame = "collection_test_article" + timestamp;
        String categoryName = "collection_test_category" + timestamp;
        CategoryVO cat = odmgCreatePersistentCategoryWithArticles(categoryName, articleame, 5);

        assertNotNull(cat.getObjId());
        assertNotNull(cat.getAssignedArticles());
        assertEquals("Wrong number of referenced articles found", 5, cat.getAssignedArticles().size());

        Collection result = odmgArticleBean.getCategoryByName(categoryName);
        assertNotNull(result);
        assertEquals(1, result.size());
        cat = (CategoryVO) result.iterator().next();
        Collection articlesCol = cat.getAssignedArticles();
        assertNotNull(articlesCol);
        assertEquals("Wrong number of referenced articles found", 5, articlesCol.size());
    }
View Full Code Here

    public void testODMGQueryObjects() throws Exception
    {
        long timestamp = System.currentTimeMillis();
        String articleName = "query_test_article_" + timestamp;
        String categoryName = "query_test_category_" + timestamp;
        CategoryVO cat1 = odmgCreatePersistentCategoryWithArticles(categoryName, articleName, 6);
        CategoryVO cat2 = odmgCreatePersistentCategoryWithArticles(categoryName, articleName, 6);
        CategoryVO cat3 = odmgCreatePersistentCategoryWithArticles(categoryName, articleName, 6);

        Collection result = odmgArticleBean.getArticles(articleName);
        assertNotNull(result);
        assertEquals("Wrong number of articles", 18, result.size());

        result = odmgArticleBean.getCategoryByName(categoryName);
        assertNotNull(result);
        assertEquals("Wrong number of returned category objects", 3, result.size());
        CategoryVO cat = (CategoryVO) result.iterator().next();
        assertNotNull(cat);
        Collection articles = cat.getAssignedArticles();
        assertNotNull(articles);
        assertEquals("Wrong number of referenced articles", 6, articles.size());
    }
View Full Code Here

    }

    private CategoryVO odmgCreatePersistentCategoryWithArticles(
            String categoryName, String articleName, int articleCount) throws Exception
    {
        CategoryVO cat = VOHelper.createNewCategory(categoryName);
        // store new category
        cat = odmgArticleBean.storeCategory(cat);
        ArrayList articles = new ArrayList();
        for (int i = 0; i < articleCount; i++)
        {
            ArticleVO art = VOHelper.createNewArticle(articleName, 1);
            // set category
            art.setCategory(cat);
            // store article
            art = odmgArticleBean.storeArticle(art);
            articles.add(art);
        }
        // set article collection
        if(articles.size() > 0) cat.setAssignedArticles(articles);
        // persist updated category
        cat = odmgArticleBean.storeCategory(cat);

        return cat;
    }
View Full Code Here

    public void testPBCollectionRetrieve() throws Exception
    {
        long timestamp = System.currentTimeMillis();
        String articleame = "collection_test_article" + timestamp;
        String categoryName = "collection_test_category" + timestamp;
        CategoryVO cat = pbCreatePersistentCategoryWithArticles(categoryName, articleame, 5);

        assertNotNull(cat.getObjId());
        assertNotNull(cat.getAssignedArticles());
        assertEquals("Wrong number of referenced articles found", 5, cat.getAssignedArticles().size());

        Collection result = pbArticleBean.getCategoryByName(categoryName);
        assertNotNull(result);
        assertEquals(1, result.size());
        cat = (CategoryVO) result.iterator().next();
        Collection articlesCol = cat.getAssignedArticles();
        assertNotNull(articlesCol);
        assertEquals("Wrong number of referenced articles found", 5, articlesCol.size());
    }
View Full Code Here

TOP

Related Classes of org.apache.ojb.ejb.CategoryVO

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.