portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rwat...@apache.org
Subject svn commit: r749633 - in /portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/test/java/org/apache/jetspeed/page: TestDatabasePageManagerPerformance.java TestOpenJPADatabasePageManagerPerformance.java
Date Tue, 03 Mar 2009 15:37:22 GMT
Author: rwatler
Date: Tue Mar  3 15:37:21 2009
New Revision: 749633

URL: http://svn.apache.org/viewvc?rev=749633&view=rev
Log:
add DBPM performance tests

Added:
    portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/test/java/org/apache/jetspeed/page/TestDatabasePageManagerPerformance.java
    portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/test/java/org/apache/jetspeed/page/TestOpenJPADatabasePageManagerPerformance.java

Added: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/test/java/org/apache/jetspeed/page/TestDatabasePageManagerPerformance.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/test/java/org/apache/jetspeed/page/TestDatabasePageManagerPerformance.java?rev=749633&view=auto
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/test/java/org/apache/jetspeed/page/TestDatabasePageManagerPerformance.java
(added)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/test/java/org/apache/jetspeed/page/TestDatabasePageManagerPerformance.java
Tue Mar  3 15:37:21 2009
@@ -0,0 +1,377 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jetspeed.page;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Locale;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.jetspeed.components.util.jpa.JPADatasourceEnabledSpringTestCase;
+import org.apache.jetspeed.om.common.SecurityConstraint;
+import org.apache.jetspeed.om.common.SecurityConstraintsContext;
+import org.apache.jetspeed.om.folder.Folder;
+import org.apache.jetspeed.om.folder.FolderNotFoundException;
+import org.apache.jetspeed.om.folder.MenuDefinition;
+import org.apache.jetspeed.om.folder.MenuExcludeDefinition;
+import org.apache.jetspeed.om.folder.MenuIncludeDefinition;
+import org.apache.jetspeed.om.folder.MenuOptionsDefinition;
+import org.apache.jetspeed.om.folder.MenuSeparatorDefinition;
+import org.apache.jetspeed.om.page.Fragment;
+import org.apache.jetspeed.om.page.Link;
+import org.apache.jetspeed.om.page.Page;
+import org.apache.jetspeed.om.page.PageSecurity;
+import org.apache.jetspeed.om.page.SecurityConstraintsDef;
+import org.apache.jetspeed.om.portlet.GenericMetadata;
+import org.apache.jetspeed.om.preference.FragmentPreference;
+import org.apache.jetspeed.page.document.DocumentNotFoundException;
+import org.apache.jetspeed.page.document.FailedToUpdateDocumentException;
+import org.apache.jetspeed.page.document.Node;
+
+import junit.framework.Test;
+
+/**
+ * TestDatabasePageManagerPerformance
+ * 
+ * @author <a href="rwatler@apache.org">Randy Watler</a>
+ * @version $Id: $
+ */
+public class TestDatabasePageManagerPerformance extends JPADatasourceEnabledSpringTestCase
implements PageManagerTestShared
+{
+    private static final Log log = LogFactory.getLog(TestDatabasePageManagerPerformance.class);
+
+    private static final int N = 1;
+
+    /**
+     * Get ordered test suite.
+     * 
+     * @return test suite to execute.
+     */
+    public static Test suite()
+    {
+        return createFixturedTestSuite(TestDatabasePageManagerPerformance.class, new String[]{"setupTest",
"testPerformance", "teardownTest"});
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.components.test.AbstractSpringTestCase#getConfigurations()
+     */
+    protected String[] getConfigurations()
+    {
+        return new String[]{"database-page-manager.xml", "transaction.xml"};
+    }
+
+    /**
+     * Setup page manager state for performance test.
+     * 
+     * @throws Exception
+     */
+    public void setupTest() throws Exception
+    {
+        PageManager pageManager = (PageManager)scm.getComponent("pageManager");
+        if (pageManager.folderExists("/"))
+        {
+            pageManager.removeFolder(pageManager.getFolder("/"));
+        }
+        Folder root = makeNewFolder(pageManager, "/");
+        pageManager.updateFolder(root);
+        Page rootPage = makeNewPage(pageManager, "/page.psml");
+        pageManager.updatePage(rootPage);
+    }
+
+    /**
+     * Execute performance test for page manager.
+     * 
+     * @throws Exception
+     */
+    public void testPerformance() throws Exception
+    {
+        PageManager pageManager = (PageManager)scm.getComponent("pageManager");
+        pageManager.reset();
+
+        String msg = getClass().getSimpleName()+"."+getName()+" writing...";
+        log.info(msg);
+        System.out.println(msg);
+        long startWrite = System.currentTimeMillis();
+        for (int i = 0; (i < N); i++)
+        {
+            Page rootPage = makeNewPage(pageManager, "/page"+i+".psml");
+            pageManager.updatePage(rootPage);
+            Folder folder = makeNewFolder(pageManager, "/folder"+i);
+            pageManager.updateFolder(folder);
+            Page folderPage = makeNewPage(pageManager, "/folder"+i+"/page.psml");
+            pageManager.updatePage(folderPage);
+        }
+        long endWrite = System.currentTimeMillis();
+        msg = getClass().getSimpleName()+"."+getName()+" write time: "+(endWrite-startWrite);
+        log.info(msg);
+        System.out.println(msg);
+
+        msg = getClass().getSimpleName()+"."+getName()+" reading...";
+        log.info(msg);
+        System.out.println(msg);
+        long startRead = System.currentTimeMillis();
+        Folder rootFolder = pageManager.getFolder("/");
+        rootFolder.getFolders();
+        for (int i = 0; (i < N); i++)
+        {
+            Page rootPage = pageManager.getPage("/page"+i+".psml");
+            Folder folder = pageManager.getFolder("/folder"+i);
+            Page folderPage = pageManager.getPage("/folder"+i+"/page.psml");
+            folder.getPages();
+        }
+        long endRead = System.currentTimeMillis();
+        msg = getClass().getSimpleName()+"."+getName()+" read time: "+(endRead-startRead);
+        log.info(msg);
+        System.out.println(msg);
+
+        msg = getClass().getSimpleName()+"."+getName()+" removing...";
+        log.info(msg);
+        System.out.println(msg);
+        long startRemove = System.currentTimeMillis();
+        for (int i = 0; (i < N); i++)
+        {
+            Page rootPage = pageManager.getPage("/page"+i+".psml");
+            pageManager.removePage(rootPage);
+            Folder folder = pageManager.getFolder("/folder"+i);
+            pageManager.removeFolder(folder);
+        }
+        long endRemove = System.currentTimeMillis();
+        msg = getClass().getSimpleName()+"."+getName()+" remove time: "+(endRemove-startRemove);
+        log.info(msg);
+        System.out.println(msg);
+    }
+    
+    /**
+     * Teardown page manager state after performance test.
+     * 
+     * @throws Exception
+     */
+    public void teardownTest() throws Exception
+    {
+        PageManager pageManager = (PageManager)scm.getComponent("pageManager");
+        if (pageManager.folderExists("/"))
+        {
+            pageManager.removeFolder(pageManager.getFolder("/"));
+        }
+    }
+    
+    private Folder makeNewFolder(PageManager pageManager, String path)
+    {
+        Folder folder = pageManager.newFolder(path);
+        folder.setTitle("Folder "+path);
+        folder.setDefaultDecorator("jetspeed", Fragment.LAYOUT);
+        folder.setDefaultDecorator("gray-gradient", Fragment.PORTLET);
+        folder.setSkin("skin-1");
+        folder.setDefaultPage("page.psml");
+        folder.setShortTitle(path);
+        GenericMetadata metadata = folder.getMetadata();
+        metadata.addField(Locale.FRENCH, "title", "[fr] "+path);
+        SecurityConstraintsContext folderConstraints = pageManager.newSecurityConstraintsContext();
+        folderConstraints.setOwner("admin");
+        List inlineFolderConstraints = new ArrayList(2);
+        SecurityConstraint folderConstraint = pageManager.newFolderSecurityConstraint();
+        folderConstraint.setUsers(Shared.makeListFromCSV("user,admin"));
+        folderConstraint.setRoles(Shared.makeListFromCSV("manager"));
+        folderConstraint.setGroups(Shared.makeListFromCSV("*"));
+        folderConstraint.setPermissions(Shared.makeListFromCSV("view,edit"));
+        inlineFolderConstraints.add(folderConstraint);
+        folderConstraint = folder.newSecurityConstraint();
+        folderConstraint.setPermissions(Shared.makeListFromCSV("edit"));
+        inlineFolderConstraints.add(folderConstraint);
+        folderConstraints.setSecurityConstraints(inlineFolderConstraints);
+        List folderConstraintsRefs = new ArrayList(2);
+        folderConstraintsRefs.add("public-view");
+        folderConstraintsRefs.add("public-edit");
+        folderConstraints.setSecurityConstraintsRefs(folderConstraintsRefs);
+        folder.setSecurityConstraintsContext(folderConstraints);
+        List documentOrder = new ArrayList(2);
+        documentOrder.add("page.psml");
+        folder.setDocumentOrder(documentOrder);
+        MenuDefinition newMenu = folder.newMenuDefinition();
+        newMenu.setName("folder-menu");
+        newMenu.setTitle(path+" menu");
+        newMenu.setShortTitle(path);
+        newMenu.setProfile("group-fallback");
+        metadata = newMenu.getMetadata();
+        metadata.addField(Locale.FRENCH, "short-title", "[fr] "+path);
+        metadata.addField(Locale.FRENCH, "title", "[fr] "+path+" menu");
+        MenuSeparatorDefinition newSeparator = folder.newMenuSeparatorDefinition();
+        newSeparator.setText("-- "+path+" --");
+        newSeparator.setTitle(path+" menu");
+        newSeparator.setSkin("header");
+        metadata = newSeparator.getMetadata();
+        metadata.addField(Locale.FRENCH, "text", "-- [fr] "+path+" --");
+        metadata.addField(Locale.FRENCH, "title", "[fr] "+path+" menu");
+        newMenu.getMenuElements().add(newSeparator);
+        MenuOptionsDefinition newOptions0 = folder.newMenuOptionsDefinition();
+        newOptions0.setOptions("./*.psml");
+        newOptions0.setRegexp(true);
+        newOptions0.setSkin("flash");
+        newMenu.getMenuElements().add(newOptions0);
+        MenuOptionsDefinition newOptions1 = folder.newMenuOptionsDefinition();
+        newOptions1.setOptions("./page.psml");
+        newOptions1.setProfile("role-fallback");
+        newOptions1.setOrder("./page*");
+        newOptions1.setDepth(1);
+        newOptions1.setPaths(true);
+        newMenu.getMenuElements().add(newOptions1);
+        MenuDefinition newNestedMenu = folder.newMenuDefinition();
+        newNestedMenu.setOptions("./*.psml");
+        newNestedMenu.setRegexp(true);
+        newNestedMenu.setDepth(2);
+        newNestedMenu.setOrder("./page*");
+        newNestedMenu.setSkin("bold");
+        newMenu.getMenuElements().add(newNestedMenu);
+        MenuExcludeDefinition newExcludeMenu = folder.newMenuExcludeDefinition();
+        newExcludeMenu.setName("exclude-menu");
+        newMenu.getMenuElements().add(newExcludeMenu);
+        MenuIncludeDefinition newIncludeMenu = folder.newMenuIncludeDefinition();
+        newIncludeMenu.setName("include-menu");
+        newIncludeMenu.setNest(true);
+        newMenu.getMenuElements().add(newIncludeMenu);
+        folder.getMenuDefinitions().add(newMenu);
+        newMenu = folder.newMenuDefinition();
+        newMenu.setName("folder-breadcrumb-menu");
+        newMenu.setSkin("bread-crumbs");
+        newMenu.setOptions("./");
+        newMenu.setPaths(true);
+        folder.getMenuDefinitions().add(newMenu);
+        return folder;
+    }
+    
+    private Page makeNewPage(PageManager pageManager, String path)
+    {
+        Page page = pageManager.newPage(path);
+        page.setTitle("Page "+page);
+        page.setVersion("6.89");
+        page.setDefaultDecorator("tigris", Fragment.LAYOUT);
+        page.setDefaultDecorator("blue-gradient", Fragment.PORTLET);
+        page.setSkin("skin-1");
+        page.setShortTitle(path);
+        GenericMetadata metadata = page.getMetadata();
+        metadata.addField(Locale.FRENCH, "title", "[fr] "+path);
+        metadata.addField(Locale.JAPANESE, "title", "[ja] "+page);
+        SecurityConstraintsContext pageConstraintsContext = page.newSecurityConstraintsContext();
+        pageConstraintsContext.setOwner("user");
+        List inlinePageConstraints = new ArrayList(1);
+        SecurityConstraint pageConstraint = page.newSecurityConstraint();
+        pageConstraint.setUsers(Shared.makeListFromCSV("jetspeed"));
+        pageConstraint.setPermissions(Shared.makeListFromCSV("edit"));
+        inlinePageConstraints.add(pageConstraint);
+        pageConstraintsContext.setSecurityConstraints(inlinePageConstraints);
+        List pageConstraintsRefs = new ArrayList(1);
+        pageConstraintsRefs.add("manager-edit");
+        pageConstraintsContext.setSecurityConstraintsRefs(pageConstraintsRefs);
+        page.setSecurityConstraintsContext(pageConstraintsContext);
+        List pageMenus = new ArrayList();
+        MenuDefinition newMenu = page.newMenuDefinition();
+        newMenu.setName("page-menu-1");
+        newMenu.setTitle(path+" menu");
+        metadata = newMenu.getMetadata();
+        metadata.addField(Locale.FRENCH, "title", "[fr] "+path);
+        MenuSeparatorDefinition newSeparator = page.newMenuSeparatorDefinition();
+        newSeparator.setText("-- "+path+" --");
+        List menuElements = new ArrayList();
+        menuElements.add(newSeparator);
+        MenuOptionsDefinition newOptions0 = page.newMenuOptionsDefinition();
+        newOptions0.setOptions("./*.psml");
+        menuElements.add(newOptions0);
+        MenuDefinition newNestedMenu = page.newMenuDefinition();
+        newNestedMenu.setOptions("./*/");
+        menuElements.add(newNestedMenu);
+        MenuExcludeDefinition newExcludeMenu = page.newMenuExcludeDefinition();
+        newExcludeMenu.setName("exclude-menu");
+        menuElements.add(newExcludeMenu);
+        MenuIncludeDefinition newIncludeMenu = page.newMenuIncludeDefinition();
+        newIncludeMenu.setName("include-menu");
+        menuElements.add(newIncludeMenu);
+        newMenu.setMenuElements(menuElements);
+        pageMenus.add(newMenu);
+        newMenu = page.newMenuDefinition();
+        newMenu.setName("page-menu-2");
+        newMenu.setOptions("./");
+        pageMenus.add(newMenu);
+        page.setMenuDefinitions(pageMenus);
+        Fragment root = page.getRootFragment();
+        root.setDecorator("blue-gradient");
+        root.setName("jetspeed-layouts::VelocityTwoColumns");
+        root.setShortTitle(path+" root");
+        root.setTitle(path+" root");
+        root.setState("Normal");
+        root.setLayoutSizes("50%,50%");
+        root.getProperties().put("custom-prop1", "custom-prop-value1-"+path);
+        root.getProperties().put("custom-prop2", "custom-prop-value2-"+path);
+        Fragment portlet = pageManager.newPortletFragment();
+        portlet.setName("security::LoginPortlet");
+        portlet.setShortTitle(path+" portlet 1");
+        portlet.setTitle(path+" portlet 1");
+        portlet.setState("Normal");
+        portlet.setLayoutRow(88);
+        portlet.setLayoutColumn(99);
+        portlet.setLayoutX(12.34F);
+        portlet.setLayoutY(23.45F);
+        portlet.setLayoutZ(34.56F);
+        portlet.setLayoutWidth(45.67F);
+        portlet.setLayoutHeight(56.78F);
+        List preferences = new ArrayList(2);
+        FragmentPreference preference = pageManager.newFragmentPreference();
+        preference.setName("pref0");
+        preference.setReadOnly(true);
+        List preferenceValues = new ArrayList(2);
+        preferenceValues.add("pref0-value0-"+path);
+        preferenceValues.add("pref0-value1-"+path);
+        preference.setValueList(preferenceValues);
+        preferences.add(preference);
+        preference = pageManager.newFragmentPreference();
+        preference.setName("pref1");
+        preferenceValues = new ArrayList(1);
+        preferenceValues.add("pref1-value-"+path);
+        preference.setValueList(preferenceValues);
+        preferences.add(preference);
+        portlet.setPreferences(preferences);
+        root.getFragments().add(portlet);
+        portlet = pageManager.newPortletFragment();
+        portlet.setName("some-app::SomePortlet");
+        portlet.setShortTitle(path+" portlet 2");
+        portlet.setTitle(path+" portlet 2");
+        portlet.setState("Normal");
+        portlet.setLayoutRow(22);
+        portlet.setLayoutColumn(11);
+        portlet.setLayoutX(11.11F);
+        portlet.setLayoutY(22.22F);
+        portlet.setLayoutZ(33.33F);
+        portlet.setLayoutWidth(44.44F);
+        portlet.setLayoutHeight(55.55F);
+        SecurityConstraintsContext fragmentConstraintsContext = portlet.newSecurityConstraintsContext();
+        fragmentConstraintsContext.setOwner("user");
+        portlet.setSecurityConstraintsContext(fragmentConstraintsContext);
+        root.getFragments().add(portlet);
+        return page;
+    }
+    
+    /**
+     * Test main entry point.
+     * 
+     * @param args process args
+     */
+    public static void main(String args[])
+    {
+        junit.awtui.TestRunner.main(new String[]{TestDatabasePageManagerPerformance.class.getName()});
+    }
+}

Added: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/test/java/org/apache/jetspeed/page/TestOpenJPADatabasePageManagerPerformance.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/test/java/org/apache/jetspeed/page/TestOpenJPADatabasePageManagerPerformance.java?rev=749633&view=auto
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/test/java/org/apache/jetspeed/page/TestOpenJPADatabasePageManagerPerformance.java
(added)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/test/java/org/apache/jetspeed/page/TestOpenJPADatabasePageManagerPerformance.java
Tue Mar  3 15:37:21 2009
@@ -0,0 +1,88 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jetspeed.page;
+
+import org.apache.jetspeed.page.jpa.DatabasePageManagerContext;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ * TestOpenJPADatabasePageManagerPerformance
+ * 
+ * @author <a href="rwatler@apache.org">Randy Watler</a>
+ * @version $Id: $
+ */
+public class TestOpenJPADatabasePageManagerPerformance extends TestDatabasePageManagerPerformance
+{
+    private DatabasePageManagerContext context;
+    
+    /**
+     * Create test suite.
+     * 
+     * @return test suite to execute.
+     */
+    public static Test suite()
+    {
+        // All methods starting with "test" will be executed in the test suite.
+        return createFixturedTestSuite(TestOpenJPADatabasePageManagerPerformance.class, new
String[]{"setupTest", "testPerformance", "teardownTest"});
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.page.TestDatabasePageManager#getBeanDefinitionFilterCategories()
+     */
+    protected String getBeanDefinitionFilterCategories()
+    {
+        return "default,jpa,jndiDS";
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.page.TestDatabasePageManager#getConfigurations()
+     */
+    protected String[] getConfigurations()
+    {
+        return new String[]{"openjpa-database-page-manager.xml"};
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.components.util.jpa.JPADatasourceEnabledSpringTestCase#startConversationalTxn()
+     */
+    protected void startConversationalTxn()
+    {
+        // create scoped context bean for thread transaction
+        context = (DatabasePageManagerContext)scm.createPrototypeComponent("pageManagerContext");
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.components.util.jpa.JPADatasourceEnabledSpringTestCase#endConversationalTxn()
+     */
+    protected void endConversationalTxn()
+    {
+        // destroy scoped context bean for thread transaction
+        scm.destroyPrototypeComponent("pageManagerContext", context);
+    }
+
+    /**
+     * Test main entry point.
+     * 
+     * @param args process args
+     */
+    public static void main(String args[])
+    {
+        junit.awtui.TestRunner.main(new String[]{TestOpenJPADatabasePageManagerPerformance.class.getName()});
+    }
+}



---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org


Mime
View raw message