Author: chris.laprun(a)jboss.com
Date: 2009-01-26 17:47:49 -0500 (Mon, 26 Jan 2009)
New Revision: 12654
Modified:
branches/Enterprise_Portal_Platform_4_3/core/src/main/org/jboss/portal/core/impl/model/portal/PortalObjectImpl.java
branches/Enterprise_Portal_Platform_4_3/core/src/main/org/jboss/portal/test/core/model/portal/PortalObjectContainerTestCase.java
branches/Enterprise_Portal_Platform_4_3/core/src/main/org/jboss/portal/test/core/model/portal/PortalObjectTestCase.java
Log:
- JBPORTAL-2281: Fix incompatible behavior between Java 5 and Java 6.
Modified:
branches/Enterprise_Portal_Platform_4_3/core/src/main/org/jboss/portal/core/impl/model/portal/PortalObjectImpl.java
===================================================================
---
branches/Enterprise_Portal_Platform_4_3/core/src/main/org/jboss/portal/core/impl/model/portal/PortalObjectImpl.java 2009-01-26
22:29:30 UTC (rev 12653)
+++
branches/Enterprise_Portal_Platform_4_3/core/src/main/org/jboss/portal/core/impl/model/portal/PortalObjectImpl.java 2009-01-26
22:47:49 UTC (rev 12654)
@@ -280,7 +280,7 @@
public Object[] toArray()
{
- return toArray(new Object[children.size()]);
+ return toArray(new Object[size()]);
}
public Iterator iterator()
@@ -291,22 +291,26 @@
public Object[] toArray(Object a[])
{
ArrayList tmp = new ArrayList(children.size());
+ for (Object child : this)
+ {
+ // no need to add to accessedChildren here as it's already done by
ChildrenIterator.next()...
+ tmp.add(child);
+ }
- //
- Set accessedChildren = getAccessedChildren();
+ return tmp.toArray(a);
+ }
- //
- for (Iterator i = iterator(); i.hasNext();)
+ @Override
+ public String toString()
+ {
+ StringBuilder sb = new StringBuilder(512);
+ sb.append("[");
+ for (Object o : this)
{
- PortalObject childObject = (PortalObject)i.next();
-
- //
- accessedChildren.add(childObject);
-
- //
- tmp.add(childObject);
+ sb.append(" ").append(o);
}
- return tmp.toArray(a);
+ sb.append(" ]");
+ return sb.toString();
}
private class ChildrenIterator implements Iterator
Modified:
branches/Enterprise_Portal_Platform_4_3/core/src/main/org/jboss/portal/test/core/model/portal/PortalObjectContainerTestCase.java
===================================================================
---
branches/Enterprise_Portal_Platform_4_3/core/src/main/org/jboss/portal/test/core/model/portal/PortalObjectContainerTestCase.java 2009-01-26
22:29:30 UTC (rev 12653)
+++
branches/Enterprise_Portal_Platform_4_3/core/src/main/org/jboss/portal/test/core/model/portal/PortalObjectContainerTestCase.java 2009-01-26
22:47:49 UTC (rev 12654)
@@ -1,6 +1,6 @@
/******************************************************************************
* JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * Copyright 2009, Red Hat Middleware, LLC, and individual *
* contributors as indicated by the @authors tag. See the *
* copyright.txt in the distribution for a full listing of *
* individual contributors. *
@@ -130,7 +130,7 @@
duplicate = true;
}
assertTrue(duplicate);
-
+
TransactionAssert.commitTransaction();
}
@@ -144,9 +144,9 @@
n1.createPage("default");
TransactionAssert.commitTransaction();
-
+
boolean rollback = false;
-
+
TransactionAssert.beginTransaction();
try
{
@@ -361,11 +361,6 @@
TransactionAssert.commitTransaction();
}
- public void testPortalNode() throws Exception
- {
-
- }
-
public void testRecreate() throws Exception
{
PortalObjectId defaultId = PortalObjectId.parse("/default",
PortalObjectPath.CANONICAL_FORMAT);
@@ -443,16 +438,6 @@
TransactionAssert.commitTransaction();
}
-// private void constructPortalObjects() throws Exception
-// {
-// Context root = container.getContext();
-// assertNotNull(root);
-// Portal portal = root.createPortal("default");
-// assertNotNull(portal);
-// Page page = portal.createPage("default");
-// assertNotNull(page);
-// }
-
private static class PortalObjectComparator implements Comparator
{
public int compare(Object o1, Object o2)
Modified:
branches/Enterprise_Portal_Platform_4_3/core/src/main/org/jboss/portal/test/core/model/portal/PortalObjectTestCase.java
===================================================================
---
branches/Enterprise_Portal_Platform_4_3/core/src/main/org/jboss/portal/test/core/model/portal/PortalObjectTestCase.java 2009-01-26
22:29:30 UTC (rev 12653)
+++
branches/Enterprise_Portal_Platform_4_3/core/src/main/org/jboss/portal/test/core/model/portal/PortalObjectTestCase.java 2009-01-26
22:47:49 UTC (rev 12654)
@@ -147,7 +147,10 @@
}
}
- /*public void testPerformanceGetChildren() throws DuplicatePortalObjectException,
NoSuchPortalObjectException
+ /*
+ // This is commented out because this test is meant to test performance and takes a
long time
+ // TODO: Should be moved to a performance test suite
+ public void testPerformanceToArray() throws NoSuchPortalObjectException,
DuplicatePortalObjectException
{
Portal portal;
Page page;
@@ -155,6 +158,41 @@
long time = System.currentTimeMillis();
TransactionAssert.beginTransaction();
root.destroyChild(p_1.getName());
+ portal = root.createPortal("portal");
+ page = portal.createPage("page");
+ int nbPages = 200;
+ int nbWindows = 100;
+ for(int j = 0; j < nbPages; j++)
+ {
+ page.createPage("page" + j);
+ }
+ for (int k = 0; k < nbWindows; k++)
+ {
+ page.createWindow("window" + k, ContentType.PORTLET, "foo" +
k);
+ }
+ TransactionAssert.commitTransaction();
+ System.out.println("Creation time = " + (System.currentTimeMillis() -
time));
+
+ time = System.currentTimeMillis();
+ for (int i = 0; i < 100000; i++)
+ {
+ assertEquals(nbWindows,
page.getChildren(PortalObject.WINDOW_MASK).toArray().length);
+ assertEquals(nbPages,
page.getChildren(PortalObject.PAGE_MASK).toArray().length);
+ }
+ System.out.println("Tests time = " + (System.currentTimeMillis() -
time));
+ }*/
+
+ /*
+ // This is commented out because this test is meant to test performance and takes a
long time
+ // TODO: Should be moved to a performance test suite
+ public void testPerformanceGetChildren() throws DuplicatePortalObjectException,
NoSuchPortalObjectException
+ {
+ Portal portal;
+ Page page;
+
+ long time = System.currentTimeMillis();
+ TransactionAssert.beginTransaction();
+ root.destroyChild(p_1.getName());
int nbPortals = 5;
int nbPages = 20;
int nbWindows = 20;
Show replies by date