You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jetspeed-dev@portals.apache.org by we...@apache.org on 2004/05/11 20:33:26 UTC
cvs commit: jakarta-jetspeed-2/components/page-manager/src/test/org/apache/jetspeed/om/page TestPageObjectModel.java
weaver 2004/05/11 11:33:25
Modified: components/page-manager/src/test/org/apache/jetspeed/page
Tag: NANOCONTAINER_DEPLOYER
TestDatabasePageManager.java
TestCastorXmlPageManager.java
components/page-manager/src/test/org/apache/jetspeed/om/page
Tag: NANOCONTAINER_DEPLOYER
TestPageObjectModel.java
Added: components/page-manager/src/test Tag: NANOCONTAINER_DEPLOYER
log4j.properties
Log:
- lowercased log4j so it is automatically loaded
- uses new test suite in test cases
Revision Changes Path
No revision
No revision
1.1.2.1 +43 -0 jakarta-jetspeed-2/components/page-manager/src/test/Attic/log4j.properties
No revision
No revision
1.1.2.2 +89 -90 jakarta-jetspeed-2/components/page-manager/src/test/org/apache/jetspeed/page/Attic/TestDatabasePageManager.java
Index: TestDatabasePageManager.java
===================================================================
RCS file: /home/cvs/jakarta-jetspeed-2/components/page-manager/src/test/org/apache/jetspeed/page/Attic/TestDatabasePageManager.java,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -r1.1.2.1 -r1.1.2.2
--- TestDatabasePageManager.java 20 Apr 2004 03:08:50 -0000 1.1.2.1
+++ TestDatabasePageManager.java 11 May 2004 18:33:25 -0000 1.1.2.2
@@ -1,90 +1,89 @@
-/*
- * Copyright 2000-2004 The Apache Software Foundation.
- *
- * Licensed 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 junit.framework.Test;
-
-import org.apache.jetspeed.components.AbstractComponentAwareTestCase;
-import org.apache.jetspeed.components.NanoDeployerBasedTestSuite;
-import org.apache.jetspeed.om.page.Fragment;
-import org.apache.jetspeed.om.page.Page;
-
-/**
- * TestPageService
- *
- * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
- * @version $Id$
- */
-public class TestDatabasePageManager extends AbstractComponentAwareTestCase
-{
- private PageManager service = null;
-
- /**
- * Defines the testcase name for JUnit.
- *
- * @param name the testcase's name.
- */
- public TestDatabasePageManager(String name)
- {
- super(name);
- }
-
- /**
- * Start the tests.
- *
- * @param args the arguments. Not used
- */
- public static void main(String args[])
- {
- junit.awtui.TestRunner.main(new String[] { TestDatabasePageManager.class.getName()});
- }
-
- public void setup()
- {
- System.out.println("Setup: Testing Page Service");
- }
-
- /**
- * Creates the test suite.
- *
- * @return a test suite (<code>TestSuite</code>) that includes all methods
- * starting with "test"
- */
- public static Test suite()
- {
- // All methods starting with "test" will be executed in the test suite.
- // return new TestSuite(TestDatabasePageManager.class);
- NanoDeployerBasedTestSuite suite = new NanoDeployerBasedTestSuite(TestDatabasePageManager.class);
- return suite;
- }
-
-
- public void testBuildBasePage()
- {
- PageManager pm = (PageManager)getContainer().getComponentInstance(PageManager.class);
- assertNotNull("page manager is null", pm);
-
- Page page = pm.newPage();
- page.setTitle("TEST");
-
- Fragment frag = pm.newFragment();
- frag.setId("Frag1");
- frag.setType(Fragment.LAYOUT);
-
- page.setRootFragment(frag);
- }
-
-}
+/*
+ * Copyright 2000-2004 The Apache Software Foundation.
+ *
+ * Licensed 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 junit.framework.Test;
+
+import org.apache.jetspeed.components.AbstractComponentAwareTestCase;
+import org.apache.jetspeed.components.ContainerDeployerTestSuite;
+import org.apache.jetspeed.om.page.Fragment;
+import org.apache.jetspeed.om.page.Page;
+
+/**
+ * TestPageService
+ *
+ * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
+ * @version $Id$
+ */
+public class TestDatabasePageManager extends AbstractComponentAwareTestCase
+{
+ private PageManager service = null;
+
+ /**
+ * Defines the testcase name for JUnit.
+ *
+ * @param name the testcase's name.
+ */
+ public TestDatabasePageManager(String name)
+ {
+ super(name);
+ }
+
+ /**
+ * Start the tests.
+ *
+ * @param args the arguments. Not used
+ */
+ public static void main(String args[])
+ {
+ junit.awtui.TestRunner.main(new String[] { TestDatabasePageManager.class.getName()});
+ }
+
+ public void setup()
+ {
+ System.out.println("Setup: Testing Page Service");
+ }
+
+ /**
+ * Creates the test suite.
+ *
+ * @return a test suite (<code>TestSuite</code>) that includes all methods
+ * starting with "test"
+ */
+ public static Test suite()
+ {
+ // All methods starting with "test" will be executed in the test suite.
+ // return new TestSuite(TestDatabasePageManager.class);
+ return new ContainerDeployerTestSuite(TestDatabasePageManager.class);
+ }
+
+
+ public void testBuildBasePage()
+ {
+ PageManager pm = (PageManager)getContainer().getComponentInstance(PageManager.class);
+ assertNotNull("page manager is null", pm);
+
+ Page page = pm.newPage();
+ page.setTitle("TEST");
+
+ Fragment frag = pm.newFragment();
+ frag.setId("Frag1");
+ frag.setType(Fragment.LAYOUT);
+
+ page.setRootFragment(frag);
+ }
+
+}
1.1.2.2 +277 -278 jakarta-jetspeed-2/components/page-manager/src/test/org/apache/jetspeed/page/Attic/TestCastorXmlPageManager.java
Index: TestCastorXmlPageManager.java
===================================================================
RCS file: /home/cvs/jakarta-jetspeed-2/components/page-manager/src/test/org/apache/jetspeed/page/Attic/TestCastorXmlPageManager.java,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -r1.1.2.1 -r1.1.2.2
--- TestCastorXmlPageManager.java 20 Apr 2004 03:08:50 -0000 1.1.2.1
+++ TestCastorXmlPageManager.java 11 May 2004 18:33:25 -0000 1.1.2.2
@@ -1,278 +1,277 @@
-/*
- * Copyright 2000-2004 The Apache Software Foundation.
- *
- * Licensed 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;
-
-// Java imports
-import java.util.Collection;
-import java.util.List;
-
-import junit.framework.Test;
-
-import org.apache.jetspeed.components.AbstractComponentAwareTestCase;
-import org.apache.jetspeed.components.NanoDeployerBasedTestSuite;
-import org.apache.jetspeed.om.common.GenericMetadata;
-import org.apache.jetspeed.om.page.Fragment;
-import org.apache.jetspeed.om.page.Page;
-import org.apache.jetspeed.om.page.Property;
-
-/**
- * TestPageXmlPersistence
- *
- * @author <a href="raphael@apache.org">Rapha�l Luta</a>
- * @version $Id$
- */
-public class TestCastorXmlPageManager extends AbstractComponentAwareTestCase
-{
- private String testId = "test002";
-
- /**
- * Defines the testcase name for JUnit.
- *
- * @param name the testcase's name.
- */
- public TestCastorXmlPageManager(String name)
- {
- super(name);
- }
-
- /**
- * Start the tests.
- *
- * @param args the arguments. Not used
- */
- public static void main(String args[])
- {
- junit.awtui.TestRunner.main(new String[] { TestCastorXmlPageManager.class.getName()});
- }
-
- /**
- * Creates the test suite.
- *
- * @return a test suite (<code>TestSuite</code>) that includes all methods
- * starting with "test"
- */
- public static Test suite()
- {
- // All methods starting with "test" will be executed in the test suite.
- //return new TestSuite(TestCastorXmlPageManager.class);
- //ComponentAwareTestSuite suite = new ComponentAwareTestSuite(TestCastorXmlPageManager.class);
- // suite.setScript("org/apache/jetspeed/page/impl/registry.container.groovy");
- // return suite ;
- NanoDeployerBasedTestSuite suite = new NanoDeployerBasedTestSuite(TestCastorXmlPageManager.class);
- return suite;
- }
-
- public void testNewPage()
- {
- PageManager pm = (PageManager)getContainer().getComponentInstance(PageManager.class);
- assertNotNull("castor xml manager is null", pm);
- Page testpage = pm.newPage();
- assertNotNull(testpage);
- assertNotNull(testpage.getId());
- assertNotNull(testpage.getRootFragment());
- assertNotNull(testpage.getRootFragment().getId());
- }
-
- public void testNewFragment()
- {
- PageManager pm = (PageManager)getContainer().getComponentInstance(PageManager.class);
- assertNotNull("castor xml manager is null", pm);
- Fragment f = pm.newFragment();
- assertNotNull(f);
- assertNotNull(f.getId());
- assertTrue(f.getType().equals(Fragment.LAYOUT));
- }
-
- public void testNewProperty()
- {
- // TODO: Fix Property manipulation API, too clumsy right now
- }
-
- public void testGetPage()
- {
- PageManager pm = (PageManager)getContainer().getComponentInstance(PageManager.class);
- assertNotNull("castor xml manager is null", pm);
- Page testpage = pm.getPage("test001");
- assertNotNull(testpage);
- assertTrue(testpage.getId().equals("test001"));
- assertTrue(testpage.getTitle().equals("Test Page"));
- assertTrue(testpage.getAcl().equals("owner-only"));
- assertTrue(testpage.getDefaultSkin().equals("test-skin"));
- assertTrue(testpage.getDefaultDecorator(Fragment.LAYOUT).equals("test-layout"));
- assertTrue(testpage.getDefaultDecorator(Fragment.PORTLET).equals("test-portlet"));
-
- GenericMetadata md = testpage.getMetadata();
- Collection descriptions = md.getFields("description");
- Collection subjects = md.getFields("subject");
- assertEquals(2, descriptions.size());
- assertEquals(1, subjects.size());
-
-
- Fragment root = testpage.getRootFragment();
- assertNotNull(root);
- assertTrue(root.getId().equals("f001"));
- assertTrue(root.getName().equals("TwoColumns"));
- assertTrue(root.getType().equals(Fragment.LAYOUT));
- assertNull(root.getDecorator());
-
- List children = root.getFragments();
- assertNotNull(children);
- assertTrue(children.size() == 3);
-
- Fragment f = (Fragment) children.get(0);
- assertTrue(f.getId().equals("pe001"));
- assertTrue(f.getName().equals("HelloPortlet"));
- assertTrue(f.getType().equals(Fragment.PORTLET));
-
- List properties = f.getProperties(root.getName());
- assertNotNull(properties);
- assertTrue(properties.size() == 2);
- assertTrue(((Property) properties.get(0)).getName().equals("row"));
- assertTrue(((Property) properties.get(0)).getValue().equals("0"));
- assertTrue(((Property) properties.get(1)).getName().equals("column"));
- assertTrue(((Property) properties.get(1)).getValue().equals("0"));
-
- f = (Fragment) children.get(1);
- assertTrue(f.getId().equals("pe002"));
- assertTrue(f.getName().equals("JMXPortlet"));
- assertTrue(f.getType().equals(Fragment.PORTLET));
-
- properties = f.getProperties(root.getName());
- assertNotNull(properties);
- assertTrue(properties.size() == 2);
- assertTrue(((Property) properties.get(0)).getName().equals("row"));
- assertTrue(((Property) properties.get(0)).getValue().equals("0"));
- assertTrue(((Property) properties.get(1)).getName().equals("column"));
- assertTrue(((Property) properties.get(1)).getValue().equals("1"));
-
- f = testpage.getFragmentById("f002");
- assertNotNull(f);
- assertTrue(f.getId().equals("f002"));
- assertTrue(f.getName().equals("Card"));
- assertTrue(f.getType().equals(Fragment.LAYOUT));
- assertTrue(f.getDecorator().equals("Tab"));
- assertNotNull(f.getFragments());
- assertTrue(f.getFragments().size() == 2);
- }
-
-
- public void testRegisterPage() throws Exception
- {
- PageManager pm = (PageManager)getContainer().getComponentInstance(PageManager.class);
- assertNotNull("castor xml manager is null", pm);
- Page page = pm.newPage();
- System.out.println("Retrieved test_id in register " + this.testId);
- page.setId(this.testId);
- page.setDefaultSkin("myskin");
- page.setTitle("Registered Page");
-
- Fragment root = page.getRootFragment();
- root.setName("TestLayout");
- Fragment f = pm.newFragment();
- f.setType(Fragment.PORTLET);
- f.setName("TestPortlet");
- Property p = pm.newProperty();
- p.setLayout("TestLayout");
- p.setName("row");
- p.setValue("0");
- f.addProperty(p);
- p = pm.newProperty();
- p.setLayout("TestLayout");
- p.setName("column");
- p.setValue("0");
- f.addProperty(p);
- root.getFragments().add(f);
-
- try
- {
- pm.registerPage(page);
- }
- catch (Exception e)
- {
- String errmsg = "Exception in page registratio: " + e.toString();
- e.printStackTrace();
- System.err.println(errmsg);
- assertNotNull(errmsg, null);
- }
-
- page = pm.getPage(this.testId);
- assertNotNull(page);
- assertTrue(page.getId().equals(this.testId));
- assertTrue(page.getTitle().equals("Registered Page"));
- assertNotNull(page.getRootFragment());
- assertTrue(page.getRootFragment().getName().equals("TestLayout"));
- assertTrue(page.getRootFragment().getFragments().size() == 1);
-
- f = (Fragment) page.getRootFragment().getFragments().get(0);
- assertNotNull(f.getProperties("TestLayout"));
- assertTrue(((Property) f.getProperties("TestLayout").get(0)).getValue().equals("0"));
- }
-
- public void testUpdatePage() throws Exception
- {
- PageManager pm = (PageManager)getContainer().getComponentInstance(PageManager.class);
- assertNotNull("castor xml manager is null", pm);
- Page page = pm.getPage(this.testId);
- page.setTitle("Updated Title");
-
- try
- {
- pm.updatePage(page);
- }
- catch (Exception e)
- {
- String errmsg = "Exception in page update: " + e.toString();
- e.printStackTrace();
- System.err.println(errmsg);
- assertNotNull(errmsg, null);
- }
-
- page = pm.getPage(this.testId);
- assertTrue(page.getTitle().equals("Updated Title"));
- }
-
- public void testListPages() throws Exception
- {
- PageManager pm = (PageManager)getContainer().getComponentInstance(PageManager.class);
- assertNotNull("castor xml manager is null", pm);
- List pages = pm.listPages();
- assertTrue(pages.size() == 3);
- assertTrue(pages.contains(this.testId));
- assertTrue(pages.contains("test001"));
- }
-
- public void testRemovePage() throws Exception
- {
- PageManager pm = (PageManager)getContainer().getComponentInstance(PageManager.class);
- assertNotNull("castor xml manager is null", pm);
- Page page = pm.getPage(this.testId);
-
- try
- {
- pm.removePage(page);
- }
- catch (Exception e)
- {
- String errmsg = "Exception in page remove: " + e.toString();
- e.printStackTrace();
- System.err.println(errmsg);
- assertNotNull(errmsg, null);
- }
-
- page = pm.getPage(this.testId);
- assertNull(page);
- }
-}
+/*
+ * Copyright 2000-2004 The Apache Software Foundation.
+ *
+ * Licensed 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;
+
+// Java imports
+import java.util.Collection;
+import java.util.List;
+
+import junit.framework.Test;
+
+import org.apache.jetspeed.components.AbstractComponentAwareTestCase;
+import org.apache.jetspeed.components.ContainerDeployerTestSuite;
+import org.apache.jetspeed.om.common.GenericMetadata;
+import org.apache.jetspeed.om.page.Fragment;
+import org.apache.jetspeed.om.page.Page;
+import org.apache.jetspeed.om.page.Property;
+
+/**
+ * TestPageXmlPersistence
+ *
+ * @author <a href="raphael@apache.org">Rapha�l Luta</a>
+ * @version $Id$
+ */
+public class TestCastorXmlPageManager extends AbstractComponentAwareTestCase
+{
+ private String testId = "test002";
+
+ /**
+ * Defines the testcase name for JUnit.
+ *
+ * @param name the testcase's name.
+ */
+ public TestCastorXmlPageManager(String name)
+ {
+ super(name);
+ }
+
+ /**
+ * Start the tests.
+ *
+ * @param args the arguments. Not used
+ */
+ public static void main(String args[])
+ {
+ junit.awtui.TestRunner.main(new String[] { TestCastorXmlPageManager.class.getName()});
+ }
+
+ /**
+ * Creates the test suite.
+ *
+ * @return a test suite (<code>TestSuite</code>) that includes all methods
+ * starting with "test"
+ */
+ public static Test suite()
+ {
+ // All methods starting with "test" will be executed in the test suite.
+ //return new TestSuite(TestCastorXmlPageManager.class);
+ //ComponentAwareTestSuite suite = new ComponentAwareTestSuite(TestCastorXmlPageManager.class);
+ // suite.setScript("org/apache/jetspeed/page/impl/registry.container.groovy");
+ // return suite ;
+ return new ContainerDeployerTestSuite(TestCastorXmlPageManager.class);
+ }
+
+ public void testNewPage()
+ {
+ PageManager pm = (PageManager)getContainer().getComponentInstance(PageManager.class);
+ assertNotNull("castor xml manager is null", pm);
+ Page testpage = pm.newPage();
+ assertNotNull(testpage);
+ assertNotNull(testpage.getId());
+ assertNotNull(testpage.getRootFragment());
+ assertNotNull(testpage.getRootFragment().getId());
+ }
+
+ public void testNewFragment()
+ {
+ PageManager pm = (PageManager)getContainer().getComponentInstance(PageManager.class);
+ assertNotNull("castor xml manager is null", pm);
+ Fragment f = pm.newFragment();
+ assertNotNull(f);
+ assertNotNull(f.getId());
+ assertTrue(f.getType().equals(Fragment.LAYOUT));
+ }
+
+ public void testNewProperty()
+ {
+ // TODO: Fix Property manipulation API, too clumsy right now
+ }
+
+ public void testGetPage()
+ {
+ PageManager pm = (PageManager)getContainer().getComponentInstance(PageManager.class);
+ assertNotNull("castor xml manager is null", pm);
+ Page testpage = pm.getPage("test001");
+ assertNotNull(testpage);
+ assertTrue(testpage.getId().equals("test001"));
+ assertTrue(testpage.getTitle().equals("Test Page"));
+ assertTrue(testpage.getAcl().equals("owner-only"));
+ assertTrue(testpage.getDefaultSkin().equals("test-skin"));
+ assertTrue(testpage.getDefaultDecorator(Fragment.LAYOUT).equals("test-layout"));
+ assertTrue(testpage.getDefaultDecorator(Fragment.PORTLET).equals("test-portlet"));
+
+ GenericMetadata md = testpage.getMetadata();
+ Collection descriptions = md.getFields("description");
+ Collection subjects = md.getFields("subject");
+ assertEquals(2, descriptions.size());
+ assertEquals(1, subjects.size());
+
+
+ Fragment root = testpage.getRootFragment();
+ assertNotNull(root);
+ assertTrue(root.getId().equals("f001"));
+ assertTrue(root.getName().equals("TwoColumns"));
+ assertTrue(root.getType().equals(Fragment.LAYOUT));
+ assertNull(root.getDecorator());
+
+ List children = root.getFragments();
+ assertNotNull(children);
+ assertTrue(children.size() == 3);
+
+ Fragment f = (Fragment) children.get(0);
+ assertTrue(f.getId().equals("pe001"));
+ assertTrue(f.getName().equals("HelloPortlet"));
+ assertTrue(f.getType().equals(Fragment.PORTLET));
+
+ List properties = f.getProperties(root.getName());
+ assertNotNull(properties);
+ assertTrue(properties.size() == 2);
+ assertTrue(((Property) properties.get(0)).getName().equals("row"));
+ assertTrue(((Property) properties.get(0)).getValue().equals("0"));
+ assertTrue(((Property) properties.get(1)).getName().equals("column"));
+ assertTrue(((Property) properties.get(1)).getValue().equals("0"));
+
+ f = (Fragment) children.get(1);
+ assertTrue(f.getId().equals("pe002"));
+ assertTrue(f.getName().equals("JMXPortlet"));
+ assertTrue(f.getType().equals(Fragment.PORTLET));
+
+ properties = f.getProperties(root.getName());
+ assertNotNull(properties);
+ assertTrue(properties.size() == 2);
+ assertTrue(((Property) properties.get(0)).getName().equals("row"));
+ assertTrue(((Property) properties.get(0)).getValue().equals("0"));
+ assertTrue(((Property) properties.get(1)).getName().equals("column"));
+ assertTrue(((Property) properties.get(1)).getValue().equals("1"));
+
+ f = testpage.getFragmentById("f002");
+ assertNotNull(f);
+ assertTrue(f.getId().equals("f002"));
+ assertTrue(f.getName().equals("Card"));
+ assertTrue(f.getType().equals(Fragment.LAYOUT));
+ assertTrue(f.getDecorator().equals("Tab"));
+ assertNotNull(f.getFragments());
+ assertTrue(f.getFragments().size() == 2);
+ }
+
+
+ public void testRegisterPage() throws Exception
+ {
+ PageManager pm = (PageManager)getContainer().getComponentInstance(PageManager.class);
+ assertNotNull("castor xml manager is null", pm);
+ Page page = pm.newPage();
+ System.out.println("Retrieved test_id in register " + this.testId);
+ page.setId(this.testId);
+ page.setDefaultSkin("myskin");
+ page.setTitle("Registered Page");
+
+ Fragment root = page.getRootFragment();
+ root.setName("TestLayout");
+ Fragment f = pm.newFragment();
+ f.setType(Fragment.PORTLET);
+ f.setName("TestPortlet");
+ Property p = pm.newProperty();
+ p.setLayout("TestLayout");
+ p.setName("row");
+ p.setValue("0");
+ f.addProperty(p);
+ p = pm.newProperty();
+ p.setLayout("TestLayout");
+ p.setName("column");
+ p.setValue("0");
+ f.addProperty(p);
+ root.getFragments().add(f);
+
+ try
+ {
+ pm.registerPage(page);
+ }
+ catch (Exception e)
+ {
+ String errmsg = "Exception in page registratio: " + e.toString();
+ e.printStackTrace();
+ System.err.println(errmsg);
+ assertNotNull(errmsg, null);
+ }
+
+ page = pm.getPage(this.testId);
+ assertNotNull(page);
+ assertTrue(page.getId().equals(this.testId));
+ assertTrue(page.getTitle().equals("Registered Page"));
+ assertNotNull(page.getRootFragment());
+ assertTrue(page.getRootFragment().getName().equals("TestLayout"));
+ assertTrue(page.getRootFragment().getFragments().size() == 1);
+
+ f = (Fragment) page.getRootFragment().getFragments().get(0);
+ assertNotNull(f.getProperties("TestLayout"));
+ assertTrue(((Property) f.getProperties("TestLayout").get(0)).getValue().equals("0"));
+ }
+
+ public void testUpdatePage() throws Exception
+ {
+ PageManager pm = (PageManager)getContainer().getComponentInstance(PageManager.class);
+ assertNotNull("castor xml manager is null", pm);
+ Page page = pm.getPage(this.testId);
+ page.setTitle("Updated Title");
+
+ try
+ {
+ pm.updatePage(page);
+ }
+ catch (Exception e)
+ {
+ String errmsg = "Exception in page update: " + e.toString();
+ e.printStackTrace();
+ System.err.println(errmsg);
+ assertNotNull(errmsg, null);
+ }
+
+ page = pm.getPage(this.testId);
+ assertTrue(page.getTitle().equals("Updated Title"));
+ }
+
+ public void testListPages() throws Exception
+ {
+ PageManager pm = (PageManager)getContainer().getComponentInstance(PageManager.class);
+ assertNotNull("castor xml manager is null", pm);
+ List pages = pm.listPages();
+ assertTrue(pages.size() == 3);
+ assertTrue(pages.contains(this.testId));
+ assertTrue(pages.contains("test001"));
+ }
+
+ public void testRemovePage() throws Exception
+ {
+ PageManager pm = (PageManager)getContainer().getComponentInstance(PageManager.class);
+ assertNotNull("castor xml manager is null", pm);
+ Page page = pm.getPage(this.testId);
+
+ try
+ {
+ pm.removePage(page);
+ }
+ catch (Exception e)
+ {
+ String errmsg = "Exception in page remove: " + e.toString();
+ e.printStackTrace();
+ System.err.println(errmsg);
+ assertNotNull(errmsg, null);
+ }
+
+ page = pm.getPage(this.testId);
+ assertNull(page);
+ }
+}
No revision
No revision
1.1.2.4 +181 -176 jakarta-jetspeed-2/components/page-manager/src/test/org/apache/jetspeed/om/page/Attic/TestPageObjectModel.java
Index: TestPageObjectModel.java
===================================================================
RCS file: /home/cvs/jakarta-jetspeed-2/components/page-manager/src/test/org/apache/jetspeed/om/page/Attic/TestPageObjectModel.java,v
retrieving revision 1.1.2.3
retrieving revision 1.1.2.4
diff -u -r1.1.2.3 -r1.1.2.4
--- TestPageObjectModel.java 20 Apr 2004 22:37:45 -0000 1.1.2.3
+++ TestPageObjectModel.java 11 May 2004 18:33:25 -0000 1.1.2.4
@@ -1,176 +1,181 @@
-/*
- * Copyright 2000-2004 The Apache Software Foundation.
- *
- * Licensed 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.om.page;
-
-// Java imports
-import java.util.Iterator;
-
-import junit.framework.Test;
-
-import org.apache.jetspeed.components.AbstractComponentAwareTestCase;
-import org.apache.jetspeed.components.NanoDeployerBasedTestSuite;
-import org.apache.jetspeed.om.page.psml.FragmentImpl;
-import org.apache.jetspeed.om.page.psml.PageImpl;
-
-/**
- * TestMarshalPsml
- *
- * @author <a href="taylor@apache.org">David Sean Taylor</a>
- * @version $Id$
- */
-public class TestPageObjectModel extends AbstractComponentAwareTestCase
-{
-
- /**
- * Defines the testcase name for JUnit.
- *
- * @param name the testcase's name.
- */
- public TestPageObjectModel( String name )
- {
- super( name );
- }
-
- /**
- * Start the tests.
- *
- * @param args the arguments. Not used
- */
- public static void main(String args[])
- {
- junit.awtui.TestRunner.main( new String[] { TestPageObjectModel.class.getName() } );
- }
-
- public void setup()
- {
- System.out.println("Setup: Testing Page Object Model Implementation");
- }
-
- /**
- * Creates the test suite.
- *
- * @return a test suite (<code>TestSuite</code>) that includes all methods
- * starting with "test"
- */
- public static Test suite()
- {
- // All methods starting with "test" will be executed in the test suite.
- return new NanoDeployerBasedTestSuite( TestPageObjectModel.class );
- }
-
- private Page buildBasePage()
- {
- PageImpl page = new PageImpl();
- page.setId("MyPageID");
-
- Fragment frag = new FragmentImpl();
- frag.setId("Frag1");
- frag.setType(Fragment.LAYOUT);
-
- page.setRootFragment(frag);
-
- return page;
- }
-
- public void testBasicPage() throws Exception
- {
- System.out.println("Testing simple Page creation");
-
- Page page = buildBasePage();
- assertTrue(page.getId().equals("MyPageID"));
- Fragment root = page.getRootFragment();
- assertNotNull(root);
- assertTrue(root.getId().equals("Frag1"));
- assertTrue(root.getType().equals(Fragment.LAYOUT));
- assertNull(root.getTitle());
- }
-
- public void testFragmentManipulation() throws Exception
- {
- System.out.println("Testing Fragments manipulation");
-
- // Build a page with a few fragments
- Page page = buildBasePage();
- Fragment root = page.getRootFragment();
- assertNotNull(root.getFragments());
-
- Fragment frag1 = new FragmentImpl();
- frag1.setId("F1");
- frag1.setType(Fragment.PORTLET);
- frag1.setName("Portlet1");
- root.getFragments().add(frag1);
-
- Fragment frag2 = new FragmentImpl();
- frag2.setId("F2");
- frag2.setType(Fragment.LAYOUT);
- frag2.setName("TwoColumns");
- frag2.setDecorator("test");
- frag2.setAcl("private");
-
- Fragment frag3 = new FragmentImpl();
- frag3.setId("F3");
- frag3.setType(Fragment.PORTLET);
- frag3.setName("Portlet3");
- frag3.setDecorator("test");
- frag3.setState("minimized");
- frag2.getFragments().add(frag3);
- root.getFragments().add(frag2);
-
- //Check the construct
- assertTrue(root.getFragments().size()==2);
- Iterator i = root.getFragments().iterator();
- Fragment f = (Fragment)i.next();
- assertNotNull(f);
- assertTrue(f.getName().equals("Portlet1"));
- assertTrue(f.getType().equals(Fragment.PORTLET));
- assertTrue(f.getId().equals("F1"));
- assertNull(f.getTitle());
- assertNull(f.getAcl());
- assertNull(f.getDecorator());
- assertNull(f.getState());
- assertTrue(f.getFragments().size()==0);
- f = (Fragment)i.next();
- assertNotNull(f);
- assertTrue(f.getName().equals("TwoColumns"));
- assertTrue(f.getType().equals(Fragment.LAYOUT));
- assertTrue(f.getFragments().size()==1);
- assertTrue(f.getDecorator().equals("test"));
- assertTrue(f.getAcl().equals("private"));
- assertTrue(f.getFragments().size()==1);
- i = f.getFragments().iterator();
- frag1 = (Fragment)i.next();
- assertNotNull(frag1);
- assertTrue(frag1.getName().equals("Portlet3"));
- assertTrue(frag1.getType().equals(Fragment.PORTLET));
-
- //Now change the inner child to a new portlet
- frag2 = new FragmentImpl();
- frag2.setId("FR4");
- frag2.setType(Fragment.PORTLET);
- frag2.setName("P4");
-
- frag3 = page.getFragmentById("F3");
- assertNotNull(frag3);
- f.getFragments().remove(frag3);
- frag3 = page.getFragmentById("F3");
- assertNull(frag3);
- f.getFragments().add(frag2);
- assertTrue(f.getFragments().size()==1);
- f = (Fragment)f.getFragments().get(0);
- assertNotNull(f);
- assertTrue(f.getName().equals("P4"));
- }
-}
+/*
+ * Copyright 2000-2004 The Apache Software Foundation.
+ *
+ * Licensed 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.om.page;
+
+// Java imports
+import java.util.Iterator;
+
+import junit.framework.Test;
+
+import org.apache.jetspeed.components.AbstractComponentAwareTestCase;
+import org.apache.jetspeed.components.ContainerDeployerTestSuite;
+import org.apache.jetspeed.om.page.psml.FragmentImpl;
+import org.apache.jetspeed.om.page.psml.PageImpl;
+
+/**
+ * TestMarshalPsml
+ *
+ * @author <a href="taylor@apache.org">David Sean Taylor </a>
+ * @version $Id: TestPageObjectModel.java,v 1.1.2.3 2004/04/20 22:37:45 weaver
+ * Exp $
+ */
+public class TestPageObjectModel extends AbstractComponentAwareTestCase
+{
+
+ /**
+ * Defines the testcase name for JUnit.
+ *
+ * @param name
+ * the testcase's name.
+ */
+ public TestPageObjectModel( String name )
+ {
+ super(name);
+ }
+
+ /**
+ * Start the tests.
+ *
+ * @param args
+ * the arguments. Not used
+ */
+ public static void main( String args[] )
+ {
+ junit.awtui.TestRunner.main(new String[]{TestPageObjectModel.class
+ .getName()});
+ }
+
+ public void setup()
+ {
+ System.out.println("Setup: Testing Page Object Model Implementation");
+ }
+
+ /**
+ * Creates the test suite.
+ *
+ * @return a test suite (<code>TestSuite</code>) that includes all
+ * methods starting with "test"
+ */
+ public static Test suite()
+ {
+ // All methods starting with "test" will be executed in the test suite.
+ //return new NanoDeployerBasedTestSuite( TestPageObjectModel.class );
+ return new ContainerDeployerTestSuite(TestPageObjectModel.class);
+ }
+
+ private Page buildBasePage()
+ {
+ PageImpl page = new PageImpl();
+ page.setId("MyPageID");
+
+ Fragment frag = new FragmentImpl();
+ frag.setId("Frag1");
+ frag.setType(Fragment.LAYOUT);
+
+ page.setRootFragment(frag);
+
+ return page;
+ }
+
+ public void testBasicPage() throws Exception
+ {
+ System.out.println("Testing simple Page creation");
+
+ Page page = buildBasePage();
+ assertTrue(page.getId().equals("MyPageID"));
+ Fragment root = page.getRootFragment();
+ assertNotNull(root);
+ assertTrue(root.getId().equals("Frag1"));
+ assertTrue(root.getType().equals(Fragment.LAYOUT));
+ assertNull(root.getTitle());
+ }
+
+ public void testFragmentManipulation() throws Exception
+ {
+ System.out.println("Testing Fragments manipulation");
+
+ // Build a page with a few fragments
+ Page page = buildBasePage();
+ Fragment root = page.getRootFragment();
+ assertNotNull(root.getFragments());
+
+ Fragment frag1 = new FragmentImpl();
+ frag1.setId("F1");
+ frag1.setType(Fragment.PORTLET);
+ frag1.setName("Portlet1");
+ root.getFragments().add(frag1);
+
+ Fragment frag2 = new FragmentImpl();
+ frag2.setId("F2");
+ frag2.setType(Fragment.LAYOUT);
+ frag2.setName("TwoColumns");
+ frag2.setDecorator("test");
+ frag2.setAcl("private");
+
+ Fragment frag3 = new FragmentImpl();
+ frag3.setId("F3");
+ frag3.setType(Fragment.PORTLET);
+ frag3.setName("Portlet3");
+ frag3.setDecorator("test");
+ frag3.setState("minimized");
+ frag2.getFragments().add(frag3);
+ root.getFragments().add(frag2);
+
+ //Check the construct
+ assertTrue(root.getFragments().size() == 2);
+ Iterator i = root.getFragments().iterator();
+ Fragment f = (Fragment) i.next();
+ assertNotNull(f);
+ assertTrue(f.getName().equals("Portlet1"));
+ assertTrue(f.getType().equals(Fragment.PORTLET));
+ assertTrue(f.getId().equals("F1"));
+ assertNull(f.getTitle());
+ assertNull(f.getAcl());
+ assertNull(f.getDecorator());
+ assertNull(f.getState());
+ assertTrue(f.getFragments().size() == 0);
+ f = (Fragment) i.next();
+ assertNotNull(f);
+ assertTrue(f.getName().equals("TwoColumns"));
+ assertTrue(f.getType().equals(Fragment.LAYOUT));
+ assertTrue(f.getFragments().size() == 1);
+ assertTrue(f.getDecorator().equals("test"));
+ assertTrue(f.getAcl().equals("private"));
+ assertTrue(f.getFragments().size() == 1);
+ i = f.getFragments().iterator();
+ frag1 = (Fragment) i.next();
+ assertNotNull(frag1);
+ assertTrue(frag1.getName().equals("Portlet3"));
+ assertTrue(frag1.getType().equals(Fragment.PORTLET));
+
+ //Now change the inner child to a new portlet
+ frag2 = new FragmentImpl();
+ frag2.setId("FR4");
+ frag2.setType(Fragment.PORTLET);
+ frag2.setName("P4");
+
+ frag3 = page.getFragmentById("F3");
+ assertNotNull(frag3);
+ f.getFragments().remove(frag3);
+ frag3 = page.getFragmentById("F3");
+ assertNull(frag3);
+ f.getFragments().add(frag2);
+ assertTrue(f.getFragments().size() == 1);
+ f = (Fragment) f.getFragments().get(0);
+ assertNotNull(f);
+ assertTrue(f.getName().equals("P4"));
+ }
+}
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jetspeed-dev-help@jakarta.apache.org