Author: julien(a)jboss.com
Date: 2008-04-02 11:29:09 -0400 (Wed, 02 Apr 2008)
New Revision: 10484
Added:
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/model2/state/
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/model2/state/ConstraintViolationException.java
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/model2/state/NoSuchStateException.java
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/model2/state/StaleStateException.java
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/model2/state/StateChangeVetoException.java
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/model2/state/StateException.java
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/model2/state/navigational/
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/model2/state/navigational/NavigationalStateContext.java
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/model2/state/structural/
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/model2/state/structural/StructuralObject.java
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/model2/state/structural/StructuralState.java
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/model2/state/structural/StructuralStateContext.java
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/state/navigational/
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/state/navigational/NavigationalStateContextImpl.java
Removed:
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/EventAssert.java
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/EventTestCase.java
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/ModelTestCase.java
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/UIModelTester.java
Modified:
modules/presentation/trunk/presentation/pom.xml
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model2/UIModelImpl.java
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model2/UIObjectImpl.java
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model2/diff/CreateDiffPhase.java
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model2/ui/UIObjectImpl.java
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model2/update/ObjectUpdate.java
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/model/state/structural/StructuralStateContext.java
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/model2/ui/UIPage.java
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/AbstractModelTestCase.java
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/MockModelTestCase.java
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/state/structural/MockModel.java
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/state/structural/MockModelImpl.java
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/state/structural/MockObject.java
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/state/structural/StructuralObjectImpl.java
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/state/structural/StructuralStateImpl.java
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model3/AbstractModelTestCase.java
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model3/AddChildTestCase.java
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model3/NodeDef.java
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model3/TraversalModelTestCase.java
Log:
- had to fork the previous model package state package
- added junit test to pom.xml
Modified: modules/presentation/trunk/presentation/pom.xml
===================================================================
--- modules/presentation/trunk/presentation/pom.xml 2008-04-02 14:34:34 UTC (rev 10483)
+++ modules/presentation/trunk/presentation/pom.xml 2008-04-02 15:29:09 UTC (rev 10484)
@@ -169,6 +169,24 @@
</execution>
</executions>
</plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <!-- To use in conjonctin with
+ export MAVEN_OPTS="-Xdebug -Xnoagent -Djava.compiler=NONE
-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000"
+ -->
+ <forkMode>never</forkMode>
+ <argLine>-enableassertions</argLine>
+ <excludes>
+
<exclude>org/jboss/portal/presentation/test/layout/TestFlexibleGrid.java</exclude>
+
<exclude>org/jboss/portal/presentation/test/layout/TestRegionLayoutManager.java</exclude>
+
<exclude>org/jboss/portal/presentation/test/model/AbstractModelTestCase.java</exclude>
+ </excludes>
+ </configuration>
+ </plugin>
+
</plugins>
</build>
</project>
Modified:
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model2/UIModelImpl.java
===================================================================
---
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model2/UIModelImpl.java 2008-04-02
14:34:34 UTC (rev 10483)
+++
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model2/UIModelImpl.java 2008-04-02
15:29:09 UTC (rev 10484)
@@ -22,8 +22,8 @@
******************************************************************************/
package org.jboss.portal.presentation.impl.model2;
-import org.jboss.portal.presentation.model.state.structural.StructuralStateContext;
-import org.jboss.portal.presentation.model.state.navigational.NavigationalStateContext;
+import org.jboss.portal.presentation.model2.state.structural.StructuralStateContext;
+import org.jboss.portal.presentation.model2.state.navigational.NavigationalStateContext;
import org.jboss.portal.presentation.model2.UIModel;
import org.jboss.portal.presentation.model2.ViewPortContext;
import org.jboss.portal.presentation.model2.ViewPortScope;
Modified:
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model2/UIObjectImpl.java
===================================================================
---
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model2/UIObjectImpl.java 2008-04-02
14:34:34 UTC (rev 10483)
+++
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model2/UIObjectImpl.java 2008-04-02
15:29:09 UTC (rev 10484)
@@ -23,8 +23,8 @@
package org.jboss.portal.presentation.impl.model2;
import org.jboss.portal.presentation.model2.ui.UIObject;
-import org.jboss.portal.presentation.model.state.StateException;
-import org.jboss.portal.presentation.model.state.structural.StructuralObject;
+import org.jboss.portal.presentation.model2.state.StateException;
+import org.jboss.portal.presentation.model2.state.structural.StructuralObject;
import java.util.Map;
import java.util.Set;
Modified:
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model2/diff/CreateDiffPhase.java
===================================================================
---
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model2/diff/CreateDiffPhase.java 2008-04-02
14:34:34 UTC (rev 10483)
+++
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model2/diff/CreateDiffPhase.java 2008-04-02
15:29:09 UTC (rev 10484)
@@ -26,8 +26,8 @@
import org.jboss.portal.presentation.model2.ViewPortContext;
import org.jboss.portal.presentation.model2.ObjectTraversalType;
import org.jboss.portal.presentation.impl.model2.ui.UIObjectImpl;
-import org.jboss.portal.presentation.model.state.structural.StructuralStateContext;
-import org.jboss.portal.presentation.model.state.structural.StructuralObject;
+import org.jboss.portal.presentation.model2.state.structural.StructuralStateContext;
+import org.jboss.portal.presentation.model2.state.structural.StructuralObject;
/**
* @author <a href="mailto:julien@jboss-portal.org">Julien
Viet</a>
Modified:
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model2/ui/UIObjectImpl.java
===================================================================
---
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model2/ui/UIObjectImpl.java 2008-04-02
14:34:34 UTC (rev 10483)
+++
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model2/ui/UIObjectImpl.java 2008-04-02
15:29:09 UTC (rev 10484)
@@ -23,8 +23,8 @@
package org.jboss.portal.presentation.impl.model2.ui;
import org.jboss.portal.presentation.model2.ui.UIObject;
-import org.jboss.portal.presentation.model.state.StateException;
-import org.jboss.portal.presentation.model.state.structural.StructuralObject;
+import org.jboss.portal.presentation.model2.state.StateException;
+import org.jboss.portal.presentation.model2.state.structural.StructuralObject;
import org.jboss.portal.presentation.impl.model2.UIObjectRef;
import java.util.Map;
Modified:
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model2/update/ObjectUpdate.java
===================================================================
---
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model2/update/ObjectUpdate.java 2008-04-02
14:34:34 UTC (rev 10483)
+++
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model2/update/ObjectUpdate.java 2008-04-02
15:29:09 UTC (rev 10484)
@@ -25,7 +25,7 @@
import org.jboss.portal.presentation.impl.model2.ui.UIObjectImpl;
import org.jboss.portal.presentation.impl.model2.UIObjectRef;
import org.jboss.portal.presentation.model2.ViewPortContext;
-import org.jboss.portal.presentation.model.state.structural.StructuralObject;
+import org.jboss.portal.presentation.model2.state.structural.StructuralObject;
import java.util.List;
import java.util.HashMap;
@@ -124,7 +124,7 @@
}
// Perform state update
- if (object.structuralObject.compareTo(structuralObject))
+ if (object.structuralObject.equals(structuralObject))
{
object.structuralObject = structuralObject;
context.updateObject(structuralObject.getId());
Modified:
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/model/state/structural/StructuralStateContext.java
===================================================================
---
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/model/state/structural/StructuralStateContext.java 2008-04-02
14:34:34 UTC (rev 10483)
+++
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/model/state/structural/StructuralStateContext.java 2008-04-02
15:29:09 UTC (rev 10484)
@@ -25,9 +25,7 @@
import org.jboss.portal.presentation.model.UIObject;
import org.jboss.portal.presentation.model.state.StateChangeVetoException;
import org.jboss.portal.presentation.model.state.StateException;
-import org.jboss.portal.presentation.model.state.NoSuchStateException;
-import java.util.List;
import java.util.Map;
import java.util.Collection;
Copied:
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/model2/state/ConstraintViolationException.java
(from rev 10476,
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/model/state/ConstraintViolationException.java)
===================================================================
---
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/model2/state/ConstraintViolationException.java
(rev 0)
+++
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/model2/state/ConstraintViolationException.java 2008-04-02
15:29:09 UTC (rev 10484)
@@ -0,0 +1,49 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, 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. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.presentation.model2.state;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class ConstraintViolationException extends StateException
+{
+ public ConstraintViolationException()
+ {
+ }
+
+ public ConstraintViolationException(String s)
+ {
+ super(s);
+ }
+
+ public ConstraintViolationException(String s, Throwable throwable)
+ {
+ super(s, throwable);
+ }
+
+ public ConstraintViolationException(Throwable throwable)
+ {
+ super(throwable);
+ }
+}
\ No newline at end of file
Copied:
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/model2/state/NoSuchStateException.java
(from rev 10476,
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/model/state/NoSuchStateException.java)
===================================================================
---
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/model2/state/NoSuchStateException.java
(rev 0)
+++
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/model2/state/NoSuchStateException.java 2008-04-02
15:29:09 UTC (rev 10484)
@@ -0,0 +1,49 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, 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. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.presentation.model2.state;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class NoSuchStateException extends StateException
+{
+ public NoSuchStateException()
+ {
+ }
+
+ public NoSuchStateException(String s)
+ {
+ super(s);
+ }
+
+ public NoSuchStateException(String s, Throwable throwable)
+ {
+ super(s, throwable);
+ }
+
+ public NoSuchStateException(Throwable throwable)
+ {
+ super(throwable);
+ }
+}
\ No newline at end of file
Copied:
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/model2/state/StaleStateException.java
(from rev 10476,
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/model/state/StaleStateException.java)
===================================================================
---
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/model2/state/StaleStateException.java
(rev 0)
+++
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/model2/state/StaleStateException.java 2008-04-02
15:29:09 UTC (rev 10484)
@@ -0,0 +1,49 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, 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. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.presentation.model2.state;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class StaleStateException extends StateException
+{
+ public StaleStateException()
+ {
+ }
+
+ public StaleStateException(String s)
+ {
+ super(s);
+ }
+
+ public StaleStateException(String s, Throwable throwable)
+ {
+ super(s, throwable);
+ }
+
+ public StaleStateException(Throwable throwable)
+ {
+ super(throwable);
+ }
+}
\ No newline at end of file
Copied:
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/model2/state/StateChangeVetoException.java
(from rev 10476,
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/model/state/StateChangeVetoException.java)
===================================================================
---
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/model2/state/StateChangeVetoException.java
(rev 0)
+++
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/model2/state/StateChangeVetoException.java 2008-04-02
15:29:09 UTC (rev 10484)
@@ -0,0 +1,49 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, 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. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.presentation.model2.state;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class StateChangeVetoException extends StateException
+{
+ public StateChangeVetoException()
+ {
+ }
+
+ public StateChangeVetoException(String s)
+ {
+ super(s);
+ }
+
+ public StateChangeVetoException(String s, Throwable throwable)
+ {
+ super(s, throwable);
+ }
+
+ public StateChangeVetoException(Throwable throwable)
+ {
+ super(throwable);
+ }
+}
\ No newline at end of file
Added:
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/model2/state/StateException.java
===================================================================
---
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/model2/state/StateException.java
(rev 0)
+++
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/model2/state/StateException.java 2008-04-02
15:29:09 UTC (rev 10484)
@@ -0,0 +1,49 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, 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. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.presentation.model2.state;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class StateException extends RuntimeException
+{
+ public StateException()
+ {
+ }
+
+ public StateException(String s)
+ {
+ super(s);
+ }
+
+ public StateException(String s, Throwable throwable)
+ {
+ super(s, throwable);
+ }
+
+ public StateException(Throwable throwable)
+ {
+ super(throwable);
+ }
+}
\ No newline at end of file
Copied:
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/model2/state/navigational/NavigationalStateContext.java
(from rev 10476,
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/model/state/navigational/NavigationalStateContext.java)
===================================================================
---
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/model2/state/navigational/NavigationalStateContext.java
(rev 0)
+++
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/model2/state/navigational/NavigationalStateContext.java 2008-04-02
15:29:09 UTC (rev 10484)
@@ -0,0 +1,37 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, 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. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.presentation.model2.state.navigational;
+
+import org.jboss.portal.presentation.model2.state.StateException;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public interface NavigationalStateContext
+{
+ Object get(String objectId, String key) throws IllegalArgumentException;
+
+ void set(String objectId, String key, Object navigationalState) throws StateException,
IllegalArgumentException;
+
+}
\ No newline at end of file
Copied:
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/model2/state/structural/StructuralObject.java
(from rev 10476,
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/model/state/structural/StructuralObject.java)
===================================================================
---
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/model2/state/structural/StructuralObject.java
(rev 0)
+++
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/model2/state/structural/StructuralObject.java 2008-04-02
15:29:09 UTC (rev 10484)
@@ -0,0 +1,127 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, 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. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.presentation.model2.state.structural;
+
+import java.util.Set;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public interface StructuralObject
+{
+
+ String getId();
+
+ StructuralState getState();
+
+ boolean equals(Object obj);
+
+ /**
+ * A comparison between two structural objects.
+ */
+ public static class Refresh
+ {
+
+ /** . */
+ private final StructuralObject parent;
+
+ /** . */
+ private final StructuralObject object;
+
+ /** . */
+ private final Set<StructuralObject> addedChildren;
+
+ /** . */
+ private final Set<String> removedChildren;
+
+ /** . */
+ private final Map<String, StructuralObject> staleChildren;
+
+ /** . */
+ private final Set<String> validChildren;
+
+ public Refresh(
+ StructuralObject parent,
+ StructuralObject object,
+ Set<StructuralObject> addedChildren,
+ Set<String> removedChildren,
+ Map<String, StructuralObject> staleChildren,
+ Set<String> validChildren)
+ {
+ if (addedChildren == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (validChildren == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (staleChildren == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (removedChildren == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ this.parent = parent;
+ this.object = object;
+ this.addedChildren = addedChildren;
+ this.validChildren = validChildren;
+ this.staleChildren = staleChildren;
+ this.removedChildren = removedChildren;
+ }
+
+ public StructuralObject getParent()
+ {
+ return parent;
+ }
+
+ public StructuralObject getObject()
+ {
+ return object;
+ }
+
+ public Set<StructuralObject> getAddedChildren()
+ {
+ return addedChildren;
+ }
+
+ public Map<String, StructuralObject> getStaleChildren()
+ {
+ return staleChildren;
+ }
+
+ public Set<String> getValidChildren()
+ {
+ return validChildren;
+ }
+
+ public Set<String> getRemovedChildren()
+ {
+ return removedChildren;
+ }
+ }
+}
\ No newline at end of file
Copied:
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/model2/state/structural/StructuralState.java
(from rev 10476,
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/model/state/structural/StructuralState.java)
===================================================================
---
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/model2/state/structural/StructuralState.java
(rev 0)
+++
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/model2/state/structural/StructuralState.java 2008-04-02
15:29:09 UTC (rev 10484)
@@ -0,0 +1,43 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, 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. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.presentation.model2.state.structural;
+
+import org.jboss.portal.presentation.model2.ui.UIObject;
+
+import java.util.Map;
+
+/**
+ * The structural state.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public interface StructuralState
+{
+
+ Class<? extends UIObject> getType();
+
+ String getName();
+
+ Map<String, String> getProperties();
+}
\ No newline at end of file
Copied:
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/model2/state/structural/StructuralStateContext.java
(from rev 10476,
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/model/state/structural/StructuralStateContext.java)
===================================================================
---
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/model2/state/structural/StructuralStateContext.java
(rev 0)
+++
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/model2/state/structural/StructuralStateContext.java 2008-04-02
15:29:09 UTC (rev 10484)
@@ -0,0 +1,95 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, 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. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.presentation.model2.state.structural;
+
+import org.jboss.portal.presentation.model2.state.StateException;
+
+import java.util.Collection;
+
+/**
+ * The structural state context.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public interface StructuralStateContext
+{
+
+ /**
+ * Load the state of the specified object.
+ *
+ * @param objectId the object id
+ * @return the state of the object or null if such state does not exist
+ * @throws IllegalArgumentException if the object id argument is null
+ */
+ StructuralObject load(String objectId) throws IllegalArgumentException;
+
+ /**
+ * Load the children of the provided object.
+ *
+ * @param parent the parent
+ * @return the list of children as structural objects
+ * @throws IllegalArgumentException if the provided object is null
+ * @throws StateException any useful exception that would make the object non valid
+ */
+ Collection<StructuralObject> loadChildren(StructuralObject parent) throws
IllegalArgumentException, StateException;
+
+ /**
+ * Load the parent of the specified object.
+ *
+ * @param child the child
+ * @return the parent or null if it does not exist
+ * @throws IllegalArgumentException if the provided object is null
+ * @throws StateException any useful exception that would make the object non valid
+ */
+ StructuralObject loadParent(StructuralObject child) throws IllegalArgumentException,
StateException;
+
+ /**
+ * Validate the state of the provided object. The operation is idempotent and does not
modify any state.
+ * If validation is succesfull the method returns otherwise it throws an exception
that indicates
+ * the nature of the non validation failure.
+ *
+ * @param object the object to check
+ * @throws IllegalArgumentException if the provided object is null
+ * @throws StateException any useful exception that would make the object non valid
+ */
+ void validate(StructuralObject object) throws IllegalArgumentException,
StateException;
+
+ /**
+ * Returns the id of the root object.
+ *
+ * @return the id of the root object.
+ */
+ String getRootId();
+
+ /**
+ * Attempt to return an object that contains the difference between the provided
object
+ * and the up to date object.
+ *
+ * @param object the object to refresh
+ * @return the refresh
+ * @throws IllegalArgumentException if the object argument is null
+ * @throws StateException if the object cannot be refreshed
+ */
+ StructuralObject.Refresh refresh(StructuralObject object) throws
IllegalArgumentException, StateException;
+}
\ No newline at end of file
Modified:
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/model2/ui/UIPage.java
===================================================================
---
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/model2/ui/UIPage.java 2008-04-02
14:34:34 UTC (rev 10483)
+++
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/model2/ui/UIPage.java 2008-04-02
15:29:09 UTC (rev 10484)
@@ -22,8 +22,6 @@
******************************************************************************/
package org.jboss.portal.presentation.model2.ui;
-import org.jboss.portal.presentation.model.UIObject;
-
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 1.1 $
Modified:
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/AbstractModelTestCase.java
===================================================================
---
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/AbstractModelTestCase.java 2008-04-02
14:34:34 UTC (rev 10483)
+++
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/AbstractModelTestCase.java 2008-04-02
15:29:09 UTC (rev 10484)
@@ -24,10 +24,6 @@
import org.jboss.portal.presentation.test.model.state.structural.MockModel;
import org.jboss.portal.presentation.test.model.state.structural.MockModelImpl;
-import org.jboss.portal.presentation.model.UIContext;
-import org.jboss.portal.presentation.model.UIObject;
-import org.jboss.portal.presentation.impl.model.container.UIObjectContainer;
-import
org.jboss.portal.presentation.impl.model.state.navigational.NavigationalStateContextImpl;
import junit.framework.TestCase;
/**
@@ -59,30 +55,8 @@
this.model = null;
}
- protected final UIContext createContext()
- {
- return new UIObjectContainer(model.getStructuralStateContext(), new
NavigationalStateContextImpl()).getRoot();
- }
-
protected final void resetModel()
{
this.model = new MockModelImpl();
}
-
- protected static final UIObject.Visitor CRAWLER = new UIObject.Visitor()
- {
- public boolean enterObject(UIObject object)
- {
- return true;
- }
-
- public void leaveObject(UIObject object)
- {
- }
-
- public boolean enterChildren(UIObject object, boolean loaded)
- {
- return loaded;
- }
- };
}
Deleted:
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/EventAssert.java
===================================================================
---
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/EventAssert.java 2008-04-02
14:34:34 UTC (rev 10483)
+++
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/EventAssert.java 2008-04-02
15:29:09 UTC (rev 10484)
@@ -1,105 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, 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. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.presentation.test.model;
-
-import junit.framework.Assert;
-import org.jboss.portal.presentation.model.ModelEvent;
-import org.jboss.portal.presentation.model.ModelListener;
-import org.jboss.portal.presentation.model.event.state.StateChange;
-import org.jboss.portal.presentation.model.event.state.StateChangeEvent;
-import
org.jboss.portal.presentation.model.event.state.navigational.NavigationalStateModification;
-import
org.jboss.portal.presentation.model.event.state.structural.StructuralStateModification;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 630 $
- */
-public class EventAssert implements ModelListener
-{
-
- /** . */
- private final List<ModelEvent> events = new ArrayList<ModelEvent>();
-
- /** . */
- private int index = 0;
-
- public void onEvent(ModelEvent event)
- {
- events.add(event);
- }
-
- public <T> T next(Class<T> clazz)
- {
- Assert.assertTrue(index < events.size());
- ModelEvent event = events.get(index++);
- Assert.assertNotNull(event);
- Assert.assertTrue(clazz.isInstance(event));
- return clazz.cast(event);
- }
-
- public void next(String targetId, StructuralStateModification.Update sp)
- {
- StateChangeEvent ste = next(StateChangeEvent.class);
- StateChange change = ste.getChange();
- Assert.assertEquals(targetId, change.getTargetId());
- StructuralStateModification.Update mod =
(StructuralStateModification.Update)change.getModification();
- Assert.assertEquals(sp.getChanges(), mod.getChanges());
- }
-
- public void next(String targetId, StructuralStateModification.Creation sp)
- {
- StateChangeEvent ste = next(StateChangeEvent.class);
- StateChange change = ste.getChange();
- Assert.assertEquals(targetId, change.getTargetId());
- StructuralStateModification.Creation mod =
(StructuralStateModification.Creation)change.getModification();
- Assert.assertEquals(sp.getName(), mod.getName());
- Assert.assertEquals(sp.getType(), mod.getType());
- Assert.assertEquals(sp.getProperties(), mod.getProperties());
- }
-
- public void next(String targetId, StructuralStateModification.Destruction sp)
- {
- StateChangeEvent ste = next(StateChangeEvent.class);
- StateChange change = ste.getChange();
- Assert.assertEquals(targetId, change.getTargetId());
- StructuralStateModification.Destruction mod =
(StructuralStateModification.Destruction)change.getModification();
- }
-
- public void next(String targetId, NavigationalStateModification ns)
- {
- StateChangeEvent ste = next(StateChangeEvent.class);
- StateChange change = ste.getChange();
- Assert.assertEquals(targetId, change.getTargetId());
- NavigationalStateModification mod =
(NavigationalStateModification)change.getModification();
- Assert.assertEquals(ns.getKey(), mod.getKey());
- Assert.assertEquals(ns.getNavigationalState(), mod.getNavigationalState());
- }
-
- public void assertEmpty()
- {
- Assert.assertEquals(events.size(), index);
- }
-}
Deleted:
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/EventTestCase.java
===================================================================
---
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/EventTestCase.java 2008-04-02
14:34:34 UTC (rev 10483)
+++
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/EventTestCase.java 2008-04-02
15:29:09 UTC (rev 10484)
@@ -1,79 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, 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. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.presentation.test.model;
-
-import org.jboss.portal.presentation.model.UIContext;
-import org.jboss.portal.presentation.model.UIPortal;
-import org.jboss.portal.presentation.model.UIObject;
-import
org.jboss.portal.presentation.model.event.state.structural.StructuralStateModification;
-import org.jboss.portal.presentation.model.event.lifecycle.RelationshipAddedEvent;
-import org.jboss.portal.presentation.model.event.lifecycle.RelationshipRemovedEvent;
-
-import java.util.HashMap;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 630 $
- */
-public class EventTestCase extends AbstractModelTestCase
-{
-
- public EventTestCase()
- {
- }
-
- public void testCreateChildEvents()
- {
- UIContext context = createContext();
- context.getChildren().size();
-
- EventAssert eventAssert = new EventAssert();
- context.addModelListener(eventAssert);
-
- //
- UIObject foo = context.createChild("foo", UIPortal.class);
- String fooId = foo.getId();
-
- //
- eventAssert.next(RelationshipAddedEvent.class);
- eventAssert.next(fooId, new StructuralStateModification.Creation(UIPortal.class,
"foo", new HashMap<String, String>()));
- }
-
- public void testDestroyChildEvents()
- {
- UIContext context = createContext();
- UIObject foo = context.createChild("foo", UIPortal.class);
- String fooId = foo.getId();
- context.getChildren().size();
-
- EventAssert eventAssert = new EventAssert();
- context.addModelListener(eventAssert);
-
- //
- context.destroyChild("foo");
-
- //
- eventAssert.next(RelationshipRemovedEvent.class);
- eventAssert.next(fooId, new StructuralStateModification.Destruction());
- }
-}
Modified:
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/MockModelTestCase.java
===================================================================
---
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/MockModelTestCase.java 2008-04-02
14:34:34 UTC (rev 10483)
+++
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/MockModelTestCase.java 2008-04-02
15:29:09 UTC (rev 10484)
@@ -23,23 +23,20 @@
package org.jboss.portal.presentation.test.model;
import junit.framework.TestCase;
-import org.jboss.portal.presentation.model.UIContext;
-import org.jboss.portal.presentation.model.UIPortal;
-import org.jboss.portal.presentation.model.UIPage;
-import org.jboss.portal.presentation.model.state.StaleStateException;
-import org.jboss.portal.presentation.model.state.StateException;
-import org.jboss.portal.presentation.model.state.NoSuchStateException;
-import org.jboss.portal.presentation.model.state.structural.StructuralObject;
-import org.jboss.portal.presentation.model.state.structural.StructuralState;
-import org.jboss.portal.presentation.model.state.structural.StructuralStateContext;
+import org.jboss.portal.presentation.model2.ui.UIContext;
+import org.jboss.portal.presentation.model2.ui.UIPage;
+import org.jboss.portal.presentation.model2.state.StaleStateException;
+import org.jboss.portal.presentation.model2.state.StateException;
+import org.jboss.portal.presentation.model2.state.NoSuchStateException;
+import org.jboss.portal.presentation.model2.state.structural.StructuralObject;
+import org.jboss.portal.presentation.model2.state.structural.StructuralState;
+import org.jboss.portal.presentation.model2.state.structural.StructuralStateContext;
import org.jboss.portal.presentation.test.model.state.structural.MockModel;
import org.jboss.portal.presentation.test.model.state.structural.MockObject;
import org.jboss.portal.presentation.test.model.state.structural.MockException;
import org.jboss.portal.presentation.test.model.state.structural.MockModelImpl;
import java.util.Collections;
-import java.util.List;
-import java.util.HashMap;
import java.util.Set;
import java.util.Map;
import java.util.Collection;
@@ -94,39 +91,6 @@
assertEquals(Collections.EMPTY_MAP, state.getProperties());
}
- public void testSetProperty()
- {
- MockObject mockRoot = model.getRoot();
- String rootId = mockRoot.getId();
- int rootV0 = mockRoot.getVersion();
-
- //
- StructuralObject root0 = ssc.load(rootId);
- StructuralState rootState0 = root0.getState();
- assertEquals(Collections.EMPTY_MAP, rootState0.getProperties());
-
- // Set
- StructuralObject.Update update = ssc.update(root0,
Collections.singletonMap("foo", "bar"));
-
- //
- int rootV1 = mockRoot.getVersion();
- assertTrue(rootV1 > rootV0);
- assertEquals(Collections.singleton("foo"), mockRoot.getPropertyNames());
- assertEquals("bar", mockRoot.getPropertyValue("foo"));
- assertEquals(Collections.EMPTY_MAP, rootState0.getProperties());
- assertStale(root0);
- StructuralObject root1_0 = update.getObject();
- assertNotNull(root1_0);
- assertNotStale(root1_0);
- StructuralState rootState1_0 = root1_0.getState();
- assertEquals(Collections.singletonMap("foo", "bar"),
rootState1_0.getProperties());
- StructuralObject root1_1 = ssc.load(rootId);
- assertNotNull(root1_1);
- assertNotStale(root1_1);
- StructuralState rootState1_1 = root1_1.getState();
- assertEquals(Collections.singletonMap("foo", "bar"),
rootState1_1.getProperties());
- }
-
public void testUpdateProperty() throws MockException
{
MockObject mockRoot = model.getRoot();
@@ -153,30 +117,6 @@
assertNotStale(root1);
StructuralState rootState1 = root1.getState();
assertEquals(Collections.singletonMap("foo", "bar"),
rootState1.getProperties());
-
- // Update
- StructuralObject.Update update = ssc.update(root1,
Collections.singletonMap("foo", "bar2"));
-
- //
- int rootV2 = mockRoot.getVersion();
- assertTrue(rootV2 > rootV1);
- assertEquals(Collections.singleton("foo"), mockRoot.getPropertyNames());
- assertEquals("bar2", mockRoot.getPropertyValue("foo"));
- assertEquals(Collections.EMPTY_MAP, rootState0.getProperties());
- assertStale(root0);
- assertStale(root1);
-
- //
- StructuralObject root2_0 = update.getObject();
- assertNotNull(root2_0);
- assertNotStale(root2_0);
- StructuralState rootState2_0 = root2_0.getState();
- assertEquals(Collections.singletonMap("foo", "bar2"),
rootState2_0.getProperties());
- StructuralObject root2_1 = ssc.load(rootId);
- assertNotNull(root2_1);
- assertNotStale(root2_1);
- StructuralState rootState2_1 = root2_1.getState();
- assertEquals(Collections.singletonMap("foo", "bar2"),
rootState2_1.getProperties());
}
public void testAddChild() throws MockException
@@ -189,14 +129,14 @@
StructuralObject root = ssc.load(rootId);
//
- MockObject mockFoo = mockRoot.addChild("foo", MockObject.Type.PORTAL);
+ MockObject mockFoo = mockRoot.addChild("foo", MockObject.Type.PAGE);
assertNotNull(mockFoo);
String fooId = mockFoo.getId();
//
assertNotNull(fooId);
assertEquals("foo", mockFoo.getName());
- assertEquals(MockObject.Type.PORTAL, mockFoo.getType());
+ assertEquals(MockObject.Type.PAGE, mockFoo.getType());
assertSame(mockRoot, mockFoo.getParent());
assertEquals(Collections.singletonList(mockFoo), mockRoot.getChildren());
assertEquals(Collections.EMPTY_SET, mockFoo.getPropertyNames());
@@ -236,7 +176,7 @@
assertNotNull(fooState);
assertEquals("foo", fooState.getName());
assertEquals(Collections.EMPTY_MAP, fooState.getProperties());
- assertEquals(UIPortal.class, fooState.getType());
+ assertEquals(UIPage.class, fooState.getType());
root = ssc.loadParent(foo);
assertNotNull(root);
assertEquals(rootId, root.getId());
@@ -245,7 +185,7 @@
public void testDestroy() throws MockException
{
MockObject mockRoot = model.getRoot();
- MockObject mockFoo = mockRoot.addChild("foo", MockObject.Type.PORTAL);
+ MockObject mockFoo = mockRoot.addChild("foo", MockObject.Type.PAGE);
MockObject mockBar = mockFoo.addChild("bar", MockObject.Type.PAGE);
MockObject mockJuu = mockFoo.addChild("juu", MockObject.Type.PAGE);
int rootV0 = mockRoot.getVersion();
@@ -360,49 +300,6 @@
assertEquals(Collections.singletonList(mockBar), mockRoot.getChildren());
}
- public void testMove2() throws MockException
- {
- MockObject mockRoot = model.getRoot();
- MockObject mockFoo = mockRoot.addChild("foo", MockObject.Type.PAGE);
- MockObject mockBar = mockRoot.addChild("bar", MockObject.Type.PAGE);
-
- //
- String fooId = mockFoo.getId();
- String barId = mockBar.getId();
- String rootId = mockRoot.getId();
-
- //
- StructuralObject fooSO = ssc.load(fooId);
- StructuralObject barSO = ssc.load(barId);
- StructuralObject rootSO = ssc.load(rootId);
-
- //
- StructuralObject.Move move = ssc.move(fooSO, barSO);
-
- //
- assertNotNull(move);
-
- //
- StructuralObject newFooSO = move.getSource();
- StructuralObject newBarSO = move.getDestination();
- StructuralObject newRootSO = move.getParent();
-
- //
- assertEquals(rootId, newRootSO.getId());
- assertEquals(fooId, newFooSO.getId());
- assertEquals(barId, newBarSO.getId());
-
- //
- assertStale(fooSO);
- assertStale(barSO);
- assertStale(rootSO);
-
- //
- assertNotStale(newRootSO);
- assertNotStale(newBarSO);
- assertNotStale(newFooSO);
- }
-
public void testMoveViolatesConstraint() throws MockException
{
MockObject mockRoot = model.getRoot();
@@ -549,16 +446,16 @@
{
MockObject mockRoot = model.getRoot();
String rootId = mockRoot.getId();
- MockObject mockFoo = mockRoot.addChild("foo", MockObject.Type.PORTAL);
+ MockObject mockFoo = mockRoot.addChild("foo", MockObject.Type.PAGE);
String fooId = mockFoo.getId();
- MockObject mockJuu = mockRoot.addChild("juu", MockObject.Type.PORTAL);
+ MockObject mockJuu = mockRoot.addChild("juu", MockObject.Type.PAGE);
String juuId = mockJuu.getId();
- MockObject mockFaa = mockRoot.addChild("faa", MockObject.Type.PORTAL);
+ MockObject mockFaa = mockRoot.addChild("faa", MockObject.Type.PAGE);
String faaId = mockFaa.getId();
StructuralObject rootV0 = ssc.load(rootId);
//
- MockObject mockBar = mockRoot.addChild("bar", MockObject.Type.PORTAL);
+ MockObject mockBar = mockRoot.addChild("bar", MockObject.Type.PAGE);
String barId = mockBar.getId();
model.destroy(mockFoo);
mockJuu.setPropertyValue("blah", "blah");
@@ -628,50 +525,6 @@
assertTrue(expected.isInstance(e));
}
- //
- try
- {
- StructuralObject bar = model.getRoot().addChild("bar",
MockObject.Type.PAGE).takeSnapshot();
- ssc.move(object, bar);
- fail();
- }
- catch (StateException e)
- {
- assertTrue(expected.isInstance(e));
- }
-
- //
- try
- {
- ssc.create(object, UIPage.class, "juu", new HashMap<String,
String>());
- fail();
- }
- catch (StateException e)
- {
- assertTrue(expected.isInstance(e));
- }
-
- //
- try
- {
- ssc.destroy(object);
- fail();
- }
- catch (StateException e)
- {
- assertTrue(expected.isInstance(e));
- }
-
- //
- try
- {
- ssc.update(object, new HashMap<String, String>());
- fail();
- }
- catch (StateException e)
- {
- assertTrue(expected.isInstance(e));
- }
}
private void assertStale(StructuralObject object)
Deleted:
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/ModelTestCase.java
===================================================================
---
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/ModelTestCase.java 2008-04-02
14:34:34 UTC (rev 10483)
+++
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/ModelTestCase.java 2008-04-02
15:29:09 UTC (rev 10484)
@@ -1,903 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, 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. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.presentation.test.model;
-
-import junit.framework.Assert;
-import org.jboss.portal.presentation.model.StateType;
-import org.jboss.portal.presentation.model.UIContext;
-import org.jboss.portal.presentation.model.UIObject;
-import org.jboss.portal.presentation.model.UIPage;
-import org.jboss.portal.presentation.model.UIPortal;
-import
org.jboss.portal.presentation.model.event.state.structural.StructuralStateModification;
-import org.jboss.portal.presentation.model.event.lifecycle.RelationshipAddedEvent;
-import org.jboss.portal.presentation.model.state.NoSuchStateException;
-import org.jboss.portal.presentation.model.state.StaleStateException;
-import org.jboss.portal.presentation.model.state.StateChangeVetoException;
-import org.jboss.portal.presentation.test.model.state.structural.MockObject;
-import org.jboss.portal.presentation.test.model.state.structural.MockException;
-import org.jboss.portal.common.util.Tools;
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Collection;
-
-/**
- * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- */
-public class ModelTestCase extends AbstractModelTestCase
-{
-
- public void testUIContextParentIsNull()
- {
- UIContext context = createContext();
- assertEquals(null, context.getParent());
- }
-
- public void testSetPropertyThrowsIAE()
- {
- UIContext context = createContext();
-
- //
- try
- {
- context.setProperty(null, "foo", "foo_value");
- fail();
- }
- catch (IllegalArgumentException ignore)
- {
- }
-
- //
- try
- {
- context.setProperty(StateType.STRUCTURAL, null, "foo_value");
- fail();
- }
- catch (IllegalArgumentException ignore)
- {
- }
- }
-
- public void testGetPropertyThrowsIAE()
- {
- UIContext context = createContext();
-
- //
- try
- {
- context.getProperty(null, "foo");
- fail();
- }
- catch (IllegalArgumentException ignore)
- {
- }
-
- //
- try
- {
- context.getProperty(StateType.STRUCTURAL, null);
- fail();
- }
- catch (IllegalArgumentException ignore)
- {
- }
- }
-
- public void testLoadChildren() throws Exception
- {
- MockObject mockDefaultPortal = model.getRoot().addChild("defaultPortal",
MockObject.Type.PORTAL);
- MockObject mockSomeOtherPortal =
model.getRoot().addChild("someOtherPortal", MockObject.Type.PORTAL);
- UIContext context = createContext();
-
- //
- Collection<? extends UIObject> children = context.getChildren();
- assertNotNull(children);
- assertEquals(2, children.size());
- Map childrenMap = toMap(children);
-
- //
- UIPortal defaultPortal = (UIPortal)childrenMap.get(mockDefaultPortal.getId());
- assertNotNull(defaultPortal);
- assertSame(defaultPortal, context.getObject(defaultPortal.getId()));
- assertEquals("defaultPortal", defaultPortal.getName());
- assertEquals(mockDefaultPortal.getId(), defaultPortal.getId());
- assertSame(context, defaultPortal.getParent());
- assertEquals(0, defaultPortal.getChildren().size());
-
- //
- UIPortal someOtherPortal = (UIPortal)childrenMap.get(mockSomeOtherPortal.getId());
- assertNotNull(someOtherPortal);
- assertSame(someOtherPortal, context.getObject(someOtherPortal.getId()));
- assertEquals("someOtherPortal", someOtherPortal.getName());
- assertEquals(mockSomeOtherPortal.getId(), someOtherPortal.getId());
- assertSame(context, someOtherPortal.getParent());
- assertEquals(0, defaultPortal.getChildren().size());
- }
-
- Map<String, UIObject> toMap(Collection<? extends UIObject> objects)
- {
- Map<String, UIObject> map = new HashMap<String, UIObject>();
- for (UIObject o : objects)
- {
- map.put(o.getId(), o);
- }
- return map;
- }
-
- public void testLoadChildrenFromStale() throws Exception
- {
- MockObject mockRoot = model.getRoot();
- MockObject mockFoo = mockRoot.addChild("foo", MockObject.Type.PORTAL);
- MockObject mockBar = mockFoo.addChild("bar", MockObject.Type.PORTAL);
-
- // Load the context object
- UIObject foo = createContext().getObject(mockFoo.getId());
-
- // Make a concurrent modification of the children
- model.destroy(mockBar);
-
- // Access children
- try
- {
- Collection<? extends UIObject> children = foo.getChildren();
- for (UIObject child : children)
- {
- }
- fail();
- }
- catch (StaleStateException expected)
- {
- }
-
- // Now state should be stale
- assertEquals(UIObject.Status.STALE, foo.getStatus());
- }
-
- public void testLoadParentFromStale() throws Exception
- {
- MockObject mockRoot = model.getRoot();
- MockObject mockFoo = mockRoot.addChild("foo", MockObject.Type.PORTAL);
- MockObject mockBar = mockFoo.addChild("bar", MockObject.Type.PORTAL);
-
- // Load the context object
- UIObject foo = createContext().getObject(mockFoo.getId());
-
- // Make a concurrent modification of the children
- model.destroy(mockBar);
-
- // Access children
- try
- {
- foo.getParent();
- fail();
- }
- catch (StaleStateException expected)
- {
- }
-
- // Now state should be stale
- assertEquals(UIObject.Status.STALE, foo.getStatus());
- }
-
- public void loadChildrenFromDestroyed() throws Exception
- {
- MockObject mockRoot = model.getRoot();
- MockObject mockFoo = mockRoot.addChild("foo", MockObject.Type.PORTAL);
- MockObject mockBar = mockFoo.addChild("bar", MockObject.Type.PORTAL);
-
- // Load the context object
- UIObject foo = createContext().getObject(mockFoo.getId());
-
- // Make a concurrent modification of the children
- model.destroy(mockFoo);
-
- // Access children
- try
- {
- Collection<? extends UIObject> children = foo.getChildren();
- for (UIObject child : children)
- {
- }
- fail();
- }
- catch (NoSuchStateException expected)
- {
- }
-
- // Now state should be invalid
- assertEquals(UIObject.Status.INVALID, foo.getStatus());
- }
-
- public void loadParentFromDestroyed() throws Exception
- {
- MockObject mockRoot = model.getRoot();
- MockObject mockFoo = mockRoot.addChild("foo", MockObject.Type.PORTAL);
- MockObject mockBar = mockFoo.addChild("bar", MockObject.Type.PORTAL);
-
- // Load the context object
- UIObject foo = createContext().getObject(mockFoo.getId());
-
- // Make a concurrent modification of the children
- model.destroy(mockFoo);
-
- // Access children
- try
- {
- foo.getParent();
- fail();
- }
- catch (NoSuchStateException expected)
- {
- }
-
- // Now state should be invalid
- assertEquals(UIObject.Status.INVALID, foo.getStatus());
- }
-
- public void testLoadParent() throws Exception
- {
- MockObject mockDefaultPortal = model.getRoot().addChild("defaultPortal",
MockObject.Type.PORTAL);
- MockObject mockDefaultPage = mockDefaultPortal.addChild("defaultPage",
MockObject.Type.PAGE);
- UIContext context = createContext();
-
- //
- UIPage defaultPage = (UIPage)context.getObject(mockDefaultPage.getId());
- assertNotNull(defaultPage);
- assertEquals("defaultPage", defaultPage.getName());
- assertEquals(mockDefaultPage.getId(), defaultPage.getId());
-
- //
- UIPortal defaultPortal = (UIPortal)defaultPage.getParent();
- assertNotNull(defaultPortal);
- assertEquals(defaultPortal.getName(), "defaultPortal");
- assertEquals(mockDefaultPortal.getId(), defaultPortal.getId());
- }
-
- private static class PropertyAssert
- {
- /** . */
- private final UIObject object;
-
- private PropertyAssert(UIObject object)
- {
- this.object = object;
- }
-
- private static final class Blah
- {
- }
-
- void assertStructuralEquals(String propertyName, String propertyValue)
- {
- assertEquals(StateType.STRUCTURAL, propertyName, propertyValue, String.class);
- }
-
- <T> void assertNavigationalEquals(String propertyName, T propertyValue,
Class<T> propertyClass)
- {
- assertEquals(StateType.NAVIGATIONAL, propertyName, propertyValue,
propertyClass);
- }
-
- <T> void assertEquals(StateType stateType, String propertyName, T
propertyValue, Class<T> propertyClass)
- {
- Assert.assertEquals(propertyValue, object.getProperty(stateType, propertyName,
propertyClass));
- Assert.assertEquals(propertyValue, object.getProperty(stateType, propertyName,
Object.class));
- Assert.assertEquals(propertyValue, object.getProperty(stateType,
propertyName));
- Assert.assertEquals(null, object.getProperty(stateType, propertyName,
Blah.class)); }
- }
-
- public void testUpdatePropertyNonExistingObject() throws MockException
- {
- UIContext context = createContext();
- MockObject mockFoo = model.getRoot().addChild("foo",
MockObject.Type.PORTAL);
- UIPortal foo = (UIPortal)context.getObject(mockFoo.getId());
- model.destroy(mockFoo);
-
- //
- try
- {
- foo.setProperty(StateType.STRUCTURAL, "foo", "foo_value");
- fail();
- }
- catch (NoSuchStateException e)
- {
- }
- }
-
- public void testUpdateExistingMutableStructuralProperty() throws MockException
- {
- MockObject mockFoo = model.getRoot().addChild("foo",
MockObject.Type.PORTAL);
- String fooId = mockFoo.getId();
- mockFoo.setPropertyValue("foo", "foo_value");
- UIContext context = createContext();
- EventAssert eventAssert = new EventAssert();
- context.addModelListener(eventAssert);
-
- // Check initial state
- UIPortal foo = (UIPortal)context.getObject(fooId);
- PropertyAssert fooAssert = new PropertyAssert(foo);
- fooAssert.assertStructuralEquals("foo", "foo_value");
-
- // Update structural property
- foo.setProperty(StateType.STRUCTURAL, "foo", "foo_new_value");
- fooAssert.assertStructuralEquals("foo", "foo_new_value");
- eventAssert.next(fooId, new
StructuralStateModification.Update(Collections.singletonMap("foo",
"foo_new_value")));
-
- // Try a non string type
- try
- {
- foo.setProperty(StateType.STRUCTURAL, "foo", 2);
- fail("Property update should have been vetoed");
- }
- catch (StateChangeVetoException ignore)
- {
- }
- fooAssert.assertStructuralEquals("foo", "foo_new_value");
- eventAssert.assertEmpty();
- }
-
- public void testUpdateExistingNonMutableStructuralProperty() throws MockException
- {
- MockObject mockFoo = model.getRoot().addChild("foo",
MockObject.Type.PORTAL);
- String fooId = mockFoo.getId();
- mockFoo.setPropertyValue("foo", "foo_value");
- mockFoo.setPropertyBehavior("foo", MockObject.Failure.veto());
- UIContext context = createContext();
- EventAssert eventAssert = new EventAssert();
-
- // Check initial state
- UIPortal foo = (UIPortal)context.getObject(fooId);
- PropertyAssert fooAssert = new PropertyAssert(foo);
- fooAssert.assertStructuralEquals("foo", "foo_value");
-
- // Try an update
- try
- {
- foo.setProperty(StateType.STRUCTURAL, "foo",
"foo_new_value");
- fail("Property update should have been vetoed");
- }
- catch (StateChangeVetoException ignore)
- {
- }
- fooAssert.assertStructuralEquals("foo", "foo_value");
- eventAssert.assertEmpty();
-
- // Try a non string type
- try
- {
- foo.setProperty(StateType.STRUCTURAL, "foo", 2);
- fail("Property update should have been vetoed");
- }
- catch (StateChangeVetoException ignore)
- {
- }
- fooAssert.assertStructuralEquals("foo", "foo_value");
- eventAssert.assertEmpty();
- }
-
- public void testUpdateNonExistingMutableStructuralProperty() throws MockException
- {
- MockObject mockFoo = model.getRoot().addChild("foo",
MockObject.Type.PORTAL);
- String fooId = mockFoo.getId();
- UIContext context = createContext();
- EventAssert eventAssert = new EventAssert();
- context.addModelListener(eventAssert);
-
- // Check initial state
- UIPortal foo = (UIPortal)context.getObject(fooId);
- PropertyAssert fooAssert = new PropertyAssert(foo);
- fooAssert.assertStructuralEquals("foo", null);
-
- // Update structural property
- foo.setProperty(StateType.STRUCTURAL, "foo", "foo_new_value");
- fooAssert.assertStructuralEquals("foo", "foo_new_value");
- eventAssert.next(fooId, new
StructuralStateModification.Update(Collections.singletonMap("foo",
"foo_new_value")));
-
- // Try a non string type
- try
- {
- foo.setProperty(StateType.STRUCTURAL, "foo", 2);
- fail("Property update should have been vetoed");
- }
- catch (StateChangeVetoException ignore)
- {
- }
- fooAssert.assertStructuralEquals("foo", "foo_new_value");
- eventAssert.assertEmpty();
- }
-
- public void testUpdateNonExistingNonMutableStructuralProperty() throws MockException
- {
- MockObject mockFoo = model.getRoot().addChild("foo",
MockObject.Type.PORTAL);
- mockFoo.setPropertyBehavior("foo", MockObject.Failure.veto());
- UIContext context = createContext();
- EventAssert eventAssert = new EventAssert();
- context.addModelListener(eventAssert);
-
- // Check initial state
- UIPortal foo = (UIPortal)context.getObject(mockFoo.getId());
- PropertyAssert fooAssert = new PropertyAssert(foo);
- fooAssert.assertStructuralEquals("foo", null);
-
- // Try an update
- try
- {
- foo.setProperty(StateType.STRUCTURAL, "foo",
"foo_new_value");
- fail("Property update should have been vetoed");
- }
- catch (StateChangeVetoException ignore)
- {
- }
- fooAssert.assertStructuralEquals("foo", null);
- eventAssert.assertEmpty();
-
- // Try a non string type
- try
- {
- foo.setProperty(StateType.STRUCTURAL, "foo", 2);
- fail("Property update should have been vetoed");
- }
- catch (StateChangeVetoException ignore)
- {
- }
- fooAssert.assertStructuralEquals("foo", null);
- eventAssert.assertEmpty();
- }
-
- public void testUpdateNavigationalProperty() throws MockException
- {
- MockObject mockFoo = model.getRoot().addChild("foo",
MockObject.Type.PORTAL);
- UIContext context = createContext();
- EventAssert eventAssert = new EventAssert();
- context.addModelListener(eventAssert);
-
- // Check initial state
- UIPortal foo = (UIPortal)context.getObject(mockFoo.getId());
- PropertyAssert fooAssert = new PropertyAssert(foo);
- fooAssert.assertNavigationalEquals("foo", null, String.class);
-
- // Update navigational state
- foo.setProperty(StateType.NAVIGATIONAL, "foo",
"foo_new_value");
- fooAssert.assertNavigationalEquals("foo", "foo_new_value",
String.class);
-
- // Update navigational state
- foo.setProperty(StateType.NAVIGATIONAL, "foo", 2);
- fooAssert.assertNavigationalEquals("foo", 2, Integer.class);
- }
-
- public void testStructuralPropertyUpdateKeepModelStateConsistent()
- {
- UIContext context = createContext();
-
- //
- context.setProperty(StateType.STRUCTURAL, "foo", "bar");
- context.setProperty(StateType.STRUCTURAL, "foo", "bar2");
- }
-
- public void testConcurrentStructuralPropertyDetection() throws MockException
- {
- UIContext context = createContext();
-
- //
- context.setProperty(StateType.STRUCTURAL, "foo", "bar");
-
- // The concurrent update
- model.getRoot().setPropertyValue("foo", "bar2");
-
- //
- try
- {
- context.setProperty(StateType.STRUCTURAL, "foo", "bar3");
- fail("Was expecting an stale state exception");
- }
- catch (StaleStateException ignore)
- {
- }
- }
-
- public void testCreateChild()
- {
- UIContext context = createContext();
- EventAssert eventAssert = new EventAssert();
- context.addModelListener(eventAssert);
-
- //
- Collection<? extends UIObject> rootChildren = context.getChildren();
- assertNotNull(rootChildren);
- assertEquals(0, rootChildren.size());
- assertNull(context.getChild("foo"));
-
- //
- UIPortal portal = context.createChild("foo", UIPortal.class);
- assertNotNull(portal);
- assertSame(context, portal.getParent());
- assertSame(portal, context.getChild("foo"));
- assertEquals(1, rootChildren.size());
- assertSame(portal, rootChildren.iterator().next());
- eventAssert.next(portal.getId(), new
StructuralStateModification.Creation(UIPortal.class, "foo", new
HashMap<String, String>()));
- }
-
- public void testDestroyChildUpdatesLoadedDescendant() throws Exception
- {
- MockObject mockRoot = model.getRoot();
- MockObject mockFoo = mockRoot.addChild("foo", MockObject.Type.PORTAL);
- MockObject mockJuu = mockFoo.addChild("juu", MockObject.Type.PAGE);
- MockObject mockDaa = mockJuu.addChild("daa", MockObject.Type.PAGE);
-
- //
- String daaId = mockDaa.getId();
-
- //
- UIContext context = createContext();
-
- // Load only the descendant
- UIObject daa = context.getObject(daaId);
- Collection<? extends UIObject> daaChildren = daa.getChildren();
-
- // Destroy foo
- context.destroyChild("foo");
-
- // Check daa state
- assertEquals(UIObject.Status.INVALID, daa.getStatus());
- assertEquals(null, context.getObject(daaId));
- try
- {
- daaChildren.size();
- fail();
- }
- catch (NoSuchStateException ignore)
- {
- }
- }
-
- public void testDestroyChildUpdatesLoadedSubtree() throws Exception
- {
- MockObject mockRoot = model.getRoot();
- MockObject mockFoo = mockRoot.addChild("foo", MockObject.Type.PORTAL);
- MockObject mockJuu = mockFoo.addChild("juu", MockObject.Type.PAGE);
- MockObject mockDaa = mockJuu.addChild("daa", MockObject.Type.PAGE);
-
- //
- String fooId = mockFoo.getId();
- String juuId = mockJuu.getId();
- String daaId = mockDaa.getId();
-
- //
- UIContext context = createContext();
-
- // Load subtree entirely
- UIObject foo = context.getChild("foo");
- UIObject juu = foo.getChild("juu");
- UIObject daa = juu.getChild("daa");
- Collection<? extends UIObject> fooChildren = foo.getChildren();
- Collection<? extends UIObject> juuChildren = juu.getChildren();
- Collection<? extends UIObject> daaChildren = daa.getChildren();
-
- //
- foo.destroyChild("juu");
-
- //
- try
- {
- juuChildren.size();
- fail();
- }
- catch (NoSuchStateException ignore)
- {
- }
- try
- {
- daaChildren.size();
- fail();
- }
- catch (NoSuchStateException ignore)
- {
- }
- assertEquals(0, fooChildren.size());
- assertEquals(UIObject.Status.VALID, foo.getStatus());
- assertEquals(UIObject.Status.INVALID, juu.getStatus());
- assertEquals(UIObject.Status.INVALID, daa.getStatus());
- assertSame(foo, context.getObject(fooId));
- assertEquals(null, context.getObject(juuId));
- assertEquals(null, context.getObject(daaId));
- }
-
- public void testParentNavigationUpdatesExistingParentStatus() throws Exception
- {
- MockObject mockRoot = model.getRoot();
- MockObject mockFoo = mockRoot.addChild("foo", MockObject.Type.PORTAL);
- MockObject mockJuu = mockFoo.addChild("juu", MockObject.Type.PAGE);
-
- //
- String fooId = mockFoo.getId();
- String juuId = mockJuu.getId();
-
- //
- UIContext context = createContext();
-
- // Get the object
- UIObject foo = context.getObject(fooId);
- UIObject juu = context.getObject(juuId);
-
- //
- assertEquals(UIObject.Status.VALID, juu.getStatus());
- assertEquals(UIObject.Status.VALID, foo.getStatus());
-
- // Now update foo concurrently
- mockFoo.setPropertyValue("abc", "def");
-
- // Now navigate
- UIObject foo2 = juu.getParent();
-
- //
- assertSame(foo, foo2);
- assertEquals(UIObject.Status.VALID, juu.getStatus());
- assertEquals(UIObject.Status.STALE, foo.getStatus());
- }
-
- public void testChildrenNavigationUpdatesExistingChildStatus() throws Exception
- {
- MockObject mockRoot = model.getRoot();
- MockObject mockFoo = mockRoot.addChild("foo", MockObject.Type.PORTAL);
- MockObject mockJuu = mockFoo.addChild("juu", MockObject.Type.PAGE);
-
- //
- String fooId = mockFoo.getId();
- String juuId = mockJuu.getId();
-
- //
- UIContext context = createContext();
-
- // Get the object
- UIObject foo = context.getObject(fooId);
- UIObject juu = context.getObject(juuId);
-
- //
- assertEquals(UIObject.Status.VALID, juu.getStatus());
- assertEquals(UIObject.Status.VALID, foo.getStatus());
-
- // Now update juu concurrently
- mockJuu.setPropertyValue("abc", "def");
-
- // Now navigate
- Collection<? extends UIObject> fooChildren = foo.getChildren();
-
- //
- assertNotNull(fooChildren);
- assertEquals(1, fooChildren.size());
- assertSame(juu, fooChildren.iterator().next());
- assertEquals(UIObject.Status.STALE, juu.getStatus());
- assertEquals(UIObject.Status.VALID, foo.getStatus());
- }
-
- public void testChildrenNavigationCombinesExistingChildrenAndLoadAbsentChildren()
throws Exception
- {
- MockObject mockRoot = model.getRoot();
- MockObject mockFoo = mockRoot.addChild("foo", MockObject.Type.PORTAL);
- MockObject mockJuu = mockFoo.addChild("juu", MockObject.Type.PAGE);
- MockObject mockDaa = mockFoo.addChild("daa", MockObject.Type.PAGE);
-
- //
- String fooId = mockFoo.getId();
- String juuId = mockJuu.getId();
- String daaId = mockDaa.getId();
-
- //
- UIContext context = createContext();
-
- // Load foo and juu but not daa
- UIObject foo = context.getObject(fooId);
- UIObject juu = context.getObject(juuId);
-
- // Now navigate
- Collection<? extends UIObject> fooChildren = foo.getChildren();
-
- //
- assertNotNull(fooChildren);
- Map<String, UIObject> tmp = new HashMap<String, UIObject>();
- for (UIObject o : fooChildren)
- {
- tmp.put(o.getId(), o);
- }
-
- //
- assertEquals(2, tmp.size());
- assertEquals(Tools.toSet(juuId, daaId), tmp.keySet());
- assertSame(juu, tmp.get(juuId));
- UIObject daa = tmp.get(daaId);
- assertSame(context.getObject(daaId), daa);
- }
-
- public void testRefreshAfterConcurrentMove() throws Exception
- {
- MockObject mockRoot = model.getRoot();
-
- MockObject mockFoo = mockRoot.addChild("foo", MockObject.Type.PORTAL);
- MockObject mockBar = mockRoot.addChild("bar", MockObject.Type.PORTAL);
-
- MockObject mockFooJuu = mockFoo.addChild("juu", MockObject.Type.PAGE);
- MockObject mockFooDaa = mockFoo.addChild("daa", MockObject.Type.PAGE);
-
- MockObject mockBarDaa = mockBar.addChild("daa", MockObject.Type.PAGE);
-
- // Load fully the context 1
- UIContext context1 = createContext();
- loadSubTree(context1);
-
- // Concurrent move
- UIContext context2 = createContext();
-
context2.getChild("foo").getChild("juu").move(context2.getChild("bar"));
-
- //
- context1.getChild("bar").refresh();
- }
-
- public void testPartialRefreshAfterConcurrentMove() throws Exception
- {
- MockObject mockRoot = model.getRoot();
- MockObject mockFoo = mockRoot.addChild("foo", MockObject.Type.PORTAL);
- MockObject mockBar = mockRoot.addChild("bar", MockObject.Type.PORTAL);
- MockObject mockJuu = mockFoo.addChild("juu", MockObject.Type.PAGE);
-
- //
- doTestPartialRefreshAfterConcurrentMove(true);
-
- //
- resetModel();
-
- //
- mockRoot = model.getRoot();
- mockBar = mockRoot.addChild("bar", MockObject.Type.PORTAL);
- mockFoo = mockRoot.addChild("foo", MockObject.Type.PORTAL);
- mockJuu = mockFoo.addChild("juu", MockObject.Type.PAGE);
-
- //
- doTestPartialRefreshAfterConcurrentMove(false);
- }
-
- public void doTestPartialRefreshAfterConcurrentMove(boolean bilto) throws Exception
- {
-
- // Load fully the context 1
- UIContext context1 = createContext();
- loadSubTree(context1);
- UIObject foo1 = context1.getChild("foo");
- UIObject juu1 = foo1.getChild("juu");
- UIObject bar1 = context1.getChild("bar");
-
- // Load fully the context 2
- UIContext context2 = createContext();
- loadSubTree(context2);
- UIObject foo2 = context2.getChild("foo");
- UIObject juu2 = foo2.getChild("juu");
- UIObject bar2 = context2.getChild("bar");
-
- // Load fully the context 3
- UIContext context3 = createContext();
- loadSubTree(context3);
- UIObject foo3 = context3.getChild("foo");
- UIObject juu3 = foo3.getChild("juu");
- UIObject bar3 = context3.getChild("bar");
-
- // Load fully the context 4
- UIContext context4 = createContext();
- loadSubTree(context4);
- UIObject foo4 = context4.getChild("foo");
- UIObject juu4 = foo4.getChild("juu");
- UIObject bar4 = context4.getChild("bar");
- String juu4id = juu4.getId();
-
- // Concurrent move
- UIContext context = createContext();
-
context.getChild("foo").getChild("juu").move(context.getChild("bar"));
-
- //
- System.err.println("-------------");
- foo1.refresh(CRAWLER);
- assertEquals(UIObject.Status.VALID, foo1.getStatus());
- assertEquals(0, foo1.getChildren().size());
-
- //
- bar2.refresh(CRAWLER);
- assertEquals(UIObject.Status.VALID, foo2.getStatus());
- assertEquals(UIObject.Status.VALID, bar2.getStatus());
- assertEquals(Tools.toSet(juu2), new HashSet<UIObject>(bar2.getChildren()));
- assertEquals(bar2, juu2.getParent());
-
- //
- System.err.println("bilto = " + bilto);
- context3.refresh(CRAWLER);
- assertEquals(UIObject.Status.VALID, foo3.getStatus());
- assertEquals(UIObject.Status.VALID, bar3.getStatus());
- if (bilto)
- {
- assertEquals(UIObject.Status.INVALID, juu3.getStatus());
- juu3 = context3.getObject(juu4id);
- }
- assertEquals(UIObject.Status.VALID, juu3.getStatus());
- assertEquals(Tools.toSet(juu3), new HashSet<UIObject>(bar3.getChildren()));
-
- //
- }
-
- private void loadSubTree(UIObject object)
- {
- for (UIObject child : object.getChildren())
- {
- child.getParent();
- loadSubTree(child);
- }
- }
-
- public void testMove() throws Exception
- {
- MockObject mockRoot = model.getRoot();
-
- MockObject mockFoo = mockRoot.addChild("foo", MockObject.Type.PORTAL);
- MockObject mockBar = mockRoot.addChild("bar", MockObject.Type.PORTAL);
-
- MockObject mockFooJuu = mockFoo.addChild("juu", MockObject.Type.PAGE);
- MockObject mockFooDaa = mockFoo.addChild("daa", MockObject.Type.PAGE);
-
- MockObject mockBarDaa = mockBar.addChild("daa", MockObject.Type.PAGE);
-
- //
- UIContext context = createContext();
-
- //
- UIObject foo = context.getChild("foo");
- Collection<? extends UIObject> fooChildren = foo.getChildren();
- UIObject fooJuu = foo.getChild("juu");
- UIObject fooDaa = foo.getChild("daa");
- UIObject bar = context.getChild("bar");
- UIObject barDaa = bar.getChild("daa");
- Collection<? extends UIObject> barChildren = bar.getChildren();
-
- //
- fooJuu.move(bar);
-
- //
- assertEquals(bar, fooJuu.getParent());
- assertEquals(Collections.singleton(fooDaa), new
HashSet<UIObject>(fooChildren));
- assertEquals(Tools.toSet(barDaa, fooJuu), new
HashSet<UIObject>(barChildren));
- }
-
- public void testBlah() throws Exception
- {
- MockObject mockRoot = model.getRoot();
- MockObject mockFoo = mockRoot.addChild("foo", MockObject.Type.PORTAL);
- MockObject mockBar = mockRoot.addChild("bar", MockObject.Type.PORTAL);
-
- EventAssert blah = new EventAssert();
-
- UIContext context = createContext();
- context.addModelListener(blah);
- UIObject foo = context.getObject(mockFoo.getId());
- blah.assertEmpty();
- foo.getParent();
- blah.next(RelationshipAddedEvent.class);
- }
-
-}
Deleted:
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/UIModelTester.java
===================================================================
---
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/UIModelTester.java 2008-04-02
14:34:34 UTC (rev 10483)
+++
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/UIModelTester.java 2008-04-02
15:29:09 UTC (rev 10484)
@@ -1,186 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, 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. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.presentation.test.model;
-
-import junit.framework.TestCase;
-import org.apache.log4j.Logger;
-import org.jboss.portal.presentation.impl.model.container.UIObjectContainer;
-import
org.jboss.portal.presentation.impl.model.state.navigational.NavigationalStateContextImpl;
-import org.jboss.portal.presentation.model.UIContext;
-import org.jboss.portal.presentation.test.model.state.structural.MockModelImpl;
-
-/**
- * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
- *
- */
-public class UIModelTester extends TestCase
-{
- private Logger logger = Logger.getLogger(this.getClass());
- private UIContext uiContext = null;
-
- /**
- *
- */
- protected void setUp() throws Exception
- {
- this.uiContext = new UIObjectContainer(new
MockModelImpl().getStructuralStateContext(), new
NavigationalStateContextImpl()).getRoot();
- }
-
- /**
- *
- */
- protected void tearDown() throws Exception
- {
- this.uiContext = null;
- }
-
- /**
- *
- * @throws Exception
- */
- /*public void testCreateChild() throws Exception
- {
- //Adding a UIContext...this should result in an IllegalArgumentException
- try
- {
- this.uiContext.createChild("duplicateRoot", UIContext.class);
- }
- catch(Exception e)
- {
- this.assertEquals(e.getClass(), IllegalArgumentException.class);
- }
-
- //Assert the state of UIPortal added to the UIObject tree
- UIPortal portal = this.uiContext.createChild("defaultPortal",
UIPortal.class);
- assertEquals(portal.getName(), "defaultPortal");
- assertEquals(portal.getId(), "/defaultPortal");
- assertTrue(portal.getParent() instanceof UIContext);
-
- //Add a UIPage to the UIPortal
- UIPage page = portal.createChild("defaultPage", UIPage.class);
- assertEquals(page.getName(), "defaultPage");
- assertEquals(page.getId(), "/defaultPortal/defaultPage");
- assertTrue(page.getParent() instanceof UIPortal);
-
- //Add a UIPage to the UIContainer
- UIContainer container = page.createChild("defaultContainer",
UIContainer.class);
- assertEquals(container.getName(), "defaultContainer");
- assertEquals(container.getId(),
"/defaultPortal/defaultPage/defaultContainer");
- assertTrue(container.getParent() instanceof UIPage);
-
- //Add a UIWindow to UIPage
- UIWindow window = container.createChild("defaultWindow", UIWindow.class);
- assertEquals(window.getName(), "defaultWindow");
- assertEquals(window.getId(),
"/defaultPortal/defaultPage/defaultContainer/defaultWindow");
- assertTrue(window.getParent() instanceof UIContainer);
- }*/
-
- /**
- *
- * @throws Exception
- */
- /*public void testDestroyChild() throws Exception
- {
- //Assert the state of UIPortal added to the UIObject tree
- UIPortal portal = this.uiContext.createChild("defaultPortal",
UIPortal.class);
-
- //Add a UIPage to the UIPortal
- UIPage page = portal.createChild("defaultPage", UIPage.class);
-
- //Add a UIPage to the UIContainer
- UIContainer container = page.createChild("defaultContainer",
UIContainer.class);
-
- //Add a UIWindow to UIPage
- UIWindow window = container.createChild("defaultWindow", UIWindow.class);
-
- //Destroy the container. When this is done, both container and window must be
destroyed from the UIObject tree
- page.removeChild(container.getName());
- List<UIObject> pageChildren = page.getChildren();
- assertTrue(pageChildren == null || pageChildren.size() == 0);
- }*/
-
- /**
- *
- * @throws Exception
- */
- /*public void testModelLoading() throws Exception
- {
- //Setup rootChildrenInfo
- Map rootChildrenInfo = new HashMap();
- rootChildrenInfo.put("defaultPortal", UIPortal.class);
- rootChildrenInfo.put("someOtherPortal", UIPortal.class);
-
- UIContext objectTree = this.uiContext.initUIObjectTree(rootChildrenInfo);
- UIPortal defaultPortal = objectTree.getChildren(UIPortal.class).get(0);
- UIPortal someOtherPortal = objectTree.getChildren(UIPortal.class).get(1);
-
- assertEquals(defaultPortal.getName(), "defaultPortal");
- assertEquals(defaultPortal.getId(), "/defaultPortal");
- assertEquals(someOtherPortal.getName(), "someOtherPortal");
- assertEquals(someOtherPortal.getId(), "/someOtherPortal");
- }*/
-
- /**
- *
- * @throws Exception
- */
- /*public void testParentLoading() throws Exception
- {
- //Setup rootChildrenInfo
- Map rootChildrenInfo = new HashMap();
- rootChildrenInfo.put("defaultPortal", UIPortal.class);
-
- UIContext objectTree = this.uiContext.initUIObjectTree(rootChildrenInfo);
-
- UIPortal portal = objectTree.getObject("/defaultPortal/defaultPage",
UIPortal.class);
- UIObject parent = portal.getParent();
-
- assertEquals(parent.getName(), "defaultPortal");
- assertEquals(parent.getId(), "/defaultPortal");
- }*/
-
- /**
- *
- * @throws Exception
- */
- /*public void testLazyLoading() throws Exception
- {
- Map rootChildrenInfo = new HashMap();
- rootChildrenInfo.put("testingLazyLoading", UIPortal.class);
-
- UIContext objectTree = this.uiContext.initUIObjectTree(rootChildrenInfo);
- UIPortal defaultPortal = objectTree.getChildren(UIPortal.class).get(0);
- List<UIObject> lazyLoadedChildren = defaultPortal.getChildren();
-
- assertTrue((lazyLoadedChildren != null &&
lazyLoadedChildren.size()>0));
-
logger.info("-----------------------------------------------------------");
- for(int i=0; i<lazyLoadedChildren.size(); i++)
- {
- UIObject child = lazyLoadedChildren.get(i);
- logger.info(child.getId());
- assertEquals(child.getParent().getName(), "testingLazyLoading");
- assertEquals(child.getParent().getId(), "/testingLazyLoading");
- }
- logger.info("--------------------------------------------------------");
- }*/
-}
Copied:
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/state/navigational/NavigationalStateContextImpl.java
(from rev 10476,
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/state/navigational/NavigationalStateContextImpl.java)
===================================================================
---
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/state/navigational/NavigationalStateContextImpl.java
(rev 0)
+++
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/state/navigational/NavigationalStateContextImpl.java 2008-04-02
15:29:09 UTC (rev 10484)
@@ -0,0 +1,113 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, 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. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.presentation.test.model.state.navigational;
+
+import org.jboss.portal.presentation.model2.state.navigational.NavigationalStateContext;
+import org.jboss.portal.presentation.model2.state.StateChangeVetoException;
+import org.jboss.portal.presentation.model2.state.StateException;
+
+import java.util.Map;
+import java.util.HashMap;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class NavigationalStateContextImpl implements NavigationalStateContext
+{
+
+ /** . */
+ private final Map<Key, Object> map;
+
+ public NavigationalStateContextImpl(Map<Key, Object> map)
+ {
+ this.map = map;
+ }
+
+ public NavigationalStateContextImpl()
+ {
+ this(new HashMap<Key, Object>());
+ }
+
+ public void set(String objectId, String key, Object navigationalState) throws
StateChangeVetoException, StateException, IllegalArgumentException
+ {
+ Key key2 = new Key(objectId, key);
+
+ //
+ if (navigationalState != null)
+ {
+ map.put(key2, navigationalState);
+ }
+ else
+ {
+ map.remove(key2);
+ }
+ }
+
+ public Object get(String objectId, String key) throws IllegalArgumentException
+ {
+ return map.get(new Key(objectId, key));
+ }
+
+ private final class Key
+ {
+ /** . */
+ private final String objectId;
+
+ /** . */
+ private final String key;
+
+ private Key(String objectId, String key)
+ {
+ if (objectId == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (key == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ this.objectId = objectId;
+ this.key = key;
+ }
+
+ public int hashCode()
+ {
+ return objectId.hashCode() * 43 + key.hashCode();
+ }
+
+ public boolean equals(Object o)
+ {
+ if (o == this)
+ {
+ return true;
+ }
+ if (o instanceof Key)
+ {
+ Key that = (Key)o;
+ return objectId.equals(that.objectId) && key.equals(that.key);
+ }
+ return false;
+ }
+ }
+}
\ No newline at end of file
Modified:
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/state/structural/MockModel.java
===================================================================
---
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/state/structural/MockModel.java 2008-04-02
14:34:34 UTC (rev 10483)
+++
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/state/structural/MockModel.java 2008-04-02
15:29:09 UTC (rev 10484)
@@ -22,7 +22,7 @@
******************************************************************************/
package org.jboss.portal.presentation.test.model.state.structural;
-import org.jboss.portal.presentation.model.state.structural.StructuralStateContext;
+import org.jboss.portal.presentation.model2.state.structural.StructuralStateContext;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
Modified:
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/state/structural/MockModelImpl.java
===================================================================
---
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/state/structural/MockModelImpl.java 2008-04-02
14:34:34 UTC (rev 10483)
+++
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/state/structural/MockModelImpl.java 2008-04-02
15:29:09 UTC (rev 10484)
@@ -22,19 +22,15 @@
******************************************************************************/
package org.jboss.portal.presentation.test.model.state.structural;
-import org.jboss.portal.presentation.model.UIContext;
-import org.jboss.portal.presentation.model.UIObject;
-import org.jboss.portal.presentation.model.UIPage;
-import org.jboss.portal.presentation.model.UIPortal;
-import org.jboss.portal.presentation.model.UIWindow;
-import org.jboss.portal.presentation.model.state.NoSuchStateException;
-import org.jboss.portal.presentation.model.state.StaleStateException;
-import org.jboss.portal.presentation.model.state.StateChangeVetoException;
-import org.jboss.portal.presentation.model.state.StateException;
-import org.jboss.portal.presentation.model.state.ConstraintViolationException;
-import
org.jboss.portal.presentation.model.state.structural.AbstractStructuralStateContext;
-import org.jboss.portal.presentation.model.state.structural.StructuralObject;
-import org.jboss.portal.presentation.model.state.structural.StructuralStateContext;
+import org.jboss.portal.presentation.model2.ui.UIContext;
+import org.jboss.portal.presentation.model2.ui.UIObject;
+import org.jboss.portal.presentation.model2.ui.UIPage;
+import org.jboss.portal.presentation.model2.ui.UIWindow;
+import org.jboss.portal.presentation.model2.state.NoSuchStateException;
+import org.jboss.portal.presentation.model2.state.StaleStateException;
+import org.jboss.portal.presentation.model2.state.StateException;
+import org.jboss.portal.presentation.model2.state.structural.StructuralObject;
+import org.jboss.portal.presentation.model2.state.structural.StructuralStateContext;
import java.util.ArrayList;
import java.util.HashMap;
@@ -43,7 +39,6 @@
import java.util.HashSet;
import java.util.Set;
import java.util.Collection;
-import java.util.Collections;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -69,7 +64,6 @@
map = new HashMap<Class<? extends UIObject>, MockObject.Type>();
map.put(UIContext.class, MockObject.Type.CONTEXT);
map.put(UIPage.class, MockObject.Type.PAGE);
- map.put(UIPortal.class, MockObject.Type.PORTAL);
map.put(UIWindow.class, MockObject.Type.WINDOW);
}
@@ -112,7 +106,7 @@
return mockObject;
}
- private final StructuralStateContext structuralStateContext = new
AbstractStructuralStateContext()
+ private final StructuralStateContext structuralStateContext = new
StructuralStateContext()
{
public StructuralObject load(String objectId) throws IllegalArgumentException
{
@@ -224,124 +218,6 @@
return new StructuralObject.Refresh(parent, current, addedChildren,
removedChildren, staleChildrenHandleMap, validChildren);
}
- public StructuralObject.Update update(StructuralObject object, Map<String,
String> changes) throws StateChangeVetoException
- {
- MockObject mockObject = getValidMockObject(object);
-
- // Create an non mutable clone (for the event)
- changes = Collections.unmodifiableMap(new HashMap<String,
String>(changes));
-
- //
- for (Map.Entry<String, String> entry : changes.entrySet())
- {
- String propertyName = entry.getKey();
- MockObject.UpdateBehavior behavior =
mockObject.getPropertyBehavior(propertyName);
- if (behavior instanceof MockObject.Veto)
- {
- throw new StateChangeVetoException("Cannot modify non behavior
property");
- }
- else if (behavior instanceof MockObject.Failure)
- {
- MockObject.Failure failure = (MockObject.Failure)behavior;
- failure.throwAs(IllegalArgumentException.class).
- throwAs(StateChangeVetoException.class).
- throwAs(StateException.class);
- }
- else
- {
- try
- {
- mockObject.setPropertyValue(propertyName, entry.getValue());
- }
- catch (MockException e)
- {
- throw new AssertionError();
- }
- }
- }
-
- //
- return new StructuralObject.Update(mockObject.takeSnapshot(), changes);
- }
-
- public StructuralObject.Creation create(StructuralObject parent, Class<? extends
UIObject> classType, String name, Map<String, String> properties) throws
StateException, IllegalArgumentException
- {
- MockObject mockParent = getValidMockObject(parent);
-
- //
- MockObject.Type type = map.get(classType);
-
- //
- try
- {
- MockObject mockChild = mockParent.addChild(name, type, properties);
-
- //
- return new StructuralObject.Creation(mockParent.takeSnapshot(),
mockChild.takeSnapshot());
- }
- catch (MockException e)
- {
- switch (e.getCode())
- {
- case CONSTRAINT_VIOLATION:
- throw new ConstraintViolationException();
- default:
- throw new AssertionError();
- }
- }
- }
-
- public StructuralObject.Destruction destroy(StructuralObject object) throws
StateException, IllegalArgumentException
- {
- MockObjectImpl mockObject = getValidMockObject(object);
-
- //
- MockObjectImpl parent = mockObject.getParent();
-
- //
- List<String> ids = new ArrayList<String>();
-
- //
- try
- {
- MockModelImpl.this.destroy(mockObject, ids);
- }
- catch (MockException e)
- {
- // It is kind of unexpected since we are destroying something valid
- throw new StateException(e);
- }
-
- //
- return new StructuralObject.Destruction(parent.takeSnapshot(), ids);
- }
-
- public StructuralObject.Move move(StructuralObject source, StructuralObject
destination) throws StateException, IllegalArgumentException
- {
- MockObject mockSource = getValidMockObject(source);
- MockObject mockDestination = getValidMockObject(destination);
- MockObject mockParent = mockSource.getParent();
-
- //
- try
- {
- mockSource.move(mockDestination);
-
- //
- return new StructuralObject.Move(mockParent.takeSnapshot(),
mockSource.takeSnapshot(), mockDestination.takeSnapshot());
- }
- catch (MockException e)
- {
- switch (e.getCode())
- {
- default:
- throw new AssertionError();
- case CONSTRAINT_VIOLATION:
- throw new ConstraintViolationException();
- }
- }
- }
-
public Collection<StructuralObject> loadChildren(StructuralObject parent)
{
MockObject mockParent = getValidMockObject(parent);
Modified:
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/state/structural/MockObject.java
===================================================================
---
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/state/structural/MockObject.java 2008-04-02
14:34:34 UTC (rev 10483)
+++
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/state/structural/MockObject.java 2008-04-02
15:29:09 UTC (rev 10484)
@@ -22,12 +22,11 @@
******************************************************************************/
package org.jboss.portal.presentation.test.model.state.structural;
-import org.jboss.portal.presentation.model.UIContext;
-import org.jboss.portal.presentation.model.UIObject;
-import org.jboss.portal.presentation.model.UIPage;
-import org.jboss.portal.presentation.model.UIPortal;
-import org.jboss.portal.presentation.model.UIWindow;
-import org.jboss.portal.presentation.model.state.structural.StructuralObject;
+import org.jboss.portal.presentation.model2.ui.UIContext;
+import org.jboss.portal.presentation.model2.ui.UIObject;
+import org.jboss.portal.presentation.model2.ui.UIPage;
+import org.jboss.portal.presentation.model2.ui.UIWindow;
+import org.jboss.portal.presentation.model2.state.structural.StructuralObject;
import java.util.List;
import java.util.Map;
@@ -46,7 +45,7 @@
public enum Type
{
- PORTAL(UIPortal.class), PAGE(UIPage.class), WINDOW(UIWindow.class),
CONTEXT(UIContext.class);
+ PAGE(UIPage.class), WINDOW(UIWindow.class), CONTEXT(UIContext.class);
/** . */
final Class<? extends UIObject> clazz;
Modified:
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/state/structural/StructuralObjectImpl.java
===================================================================
---
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/state/structural/StructuralObjectImpl.java 2008-04-02
14:34:34 UTC (rev 10483)
+++
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/state/structural/StructuralObjectImpl.java 2008-04-02
15:29:09 UTC (rev 10484)
@@ -22,8 +22,8 @@
******************************************************************************/
package org.jboss.portal.presentation.test.model.state.structural;
-import org.jboss.portal.presentation.model.state.structural.StructuralObject;
-import org.jboss.portal.presentation.model.state.structural.StructuralState;
+import org.jboss.portal.presentation.model2.state.structural.StructuralObject;
+import org.jboss.portal.presentation.model2.state.structural.StructuralState;
import java.util.List;
@@ -68,15 +68,15 @@
return state;
}
- public boolean compareTo(StructuralObject other)
+ public boolean equals(Object obj)
{
- if (other == this)
+ if (obj == this)
{
return true;
}
- if (other instanceof StructuralObjectImpl)
+ if (obj instanceof StructuralObjectImpl)
{
- StructuralObjectImpl that = (StructuralObjectImpl)other;
+ StructuralObjectImpl that = (StructuralObjectImpl)obj;
//
return handle.equals(that.handle);
Modified:
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/state/structural/StructuralStateImpl.java
===================================================================
---
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/state/structural/StructuralStateImpl.java 2008-04-02
14:34:34 UTC (rev 10483)
+++
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/state/structural/StructuralStateImpl.java 2008-04-02
15:29:09 UTC (rev 10484)
@@ -22,8 +22,8 @@
******************************************************************************/
package org.jboss.portal.presentation.test.model.state.structural;
-import org.jboss.portal.presentation.model.state.structural.StructuralState;
-import org.jboss.portal.presentation.model.UIObject;
+import org.jboss.portal.presentation.model2.state.structural.StructuralState;
+import org.jboss.portal.presentation.model2.ui.UIObject;
import java.util.Map;
Modified:
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model3/AbstractModelTestCase.java
===================================================================
---
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model3/AbstractModelTestCase.java 2008-04-02
14:34:34 UTC (rev 10483)
+++
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model3/AbstractModelTestCase.java 2008-04-02
15:29:09 UTC (rev 10484)
@@ -25,16 +25,16 @@
import org.jboss.portal.presentation.model2.UIModel;
import org.jboss.portal.presentation.test.model.state.structural.MockModel;
import org.jboss.portal.presentation.test.model.state.structural.MockModelImpl;
-import org.jboss.portal.presentation.model.state.structural.StructuralStateContext;
+import
org.jboss.portal.presentation.test.model.state.navigational.NavigationalStateContextImpl;
+import org.jboss.portal.presentation.model2.state.structural.StructuralStateContext;
import org.jboss.portal.presentation.impl.model2.UIModelImpl;
-import
org.jboss.portal.presentation.impl.model.state.navigational.NavigationalStateContextImpl;
import junit.framework.TestCase;
/**
* @author <a href="mailto:julien@jboss-portal.org">Julien
Viet</a>
* @version $Revision: 630 $
*/
-public class AbstractModelTestCase extends TestCase
+public abstract class AbstractModelTestCase extends TestCase
{
/** . */
Modified:
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model3/AddChildTestCase.java
===================================================================
---
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model3/AddChildTestCase.java 2008-04-02
14:34:34 UTC (rev 10483)
+++
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model3/AddChildTestCase.java 2008-04-02
15:29:09 UTC (rev 10484)
@@ -59,7 +59,7 @@
context.assertConsistency(model.getRootId());
//
- mockModel.getRoot().getChild("foo").addChild("juu",
MockObject.Type.PORTAL);
+ mockModel.getRoot().getChild("foo").addChild("juu",
MockObject.Type.PAGE);
fooDef.addChild("juu");
fooDef.setTraversal(after[0]);
Modified:
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model3/NodeDef.java
===================================================================
---
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model3/NodeDef.java 2008-04-02
14:34:34 UTC (rev 10483)
+++
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model3/NodeDef.java 2008-04-02
15:29:09 UTC (rev 10484)
@@ -164,7 +164,7 @@
{
for (Map.Entry<String, NodeDef> childNodeEntry : children.entrySet())
{
- MockObject child = object.addChild(childNodeEntry.getKey(),
MockObject.Type.PORTAL, properties);
+ MockObject child = object.addChild(childNodeEntry.getKey(),
MockObject.Type.PAGE, properties);
childNodeEntry.getValue().populate(child);
}
}
Modified:
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model3/TraversalModelTestCase.java
===================================================================
---
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model3/TraversalModelTestCase.java 2008-04-02
14:34:34 UTC (rev 10483)
+++
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model3/TraversalModelTestCase.java 2008-04-02
15:29:09 UTC (rev 10484)
@@ -26,9 +26,9 @@
import org.jboss.portal.presentation.model2.UIModel;
import org.jboss.portal.presentation.test.model.state.structural.MockModel;
import org.jboss.portal.presentation.test.model.state.structural.MockModelImpl;
-import org.jboss.portal.presentation.model.state.structural.StructuralStateContext;
+import
org.jboss.portal.presentation.test.model.state.navigational.NavigationalStateContextImpl;
+import org.jboss.portal.presentation.model2.state.structural.StructuralStateContext;
import org.jboss.portal.presentation.impl.model2.UIModelImpl;
-import
org.jboss.portal.presentation.impl.model.state.navigational.NavigationalStateContextImpl;
import java.util.Collection;
import java.util.Collections;