[jboss-cvs] jboss-seam/src/test/misc/org/jboss/seam/test ...
Gavin King
gavin.king at jboss.com
Wed Oct 11 01:35:09 EDT 2006
User: gavin
Date: 06/10/11 01:35:09
Modified: src/test/misc/org/jboss/seam/test Bar.java
ComponentTest.java ContextTest.java
InitializationTest.java InterceptorTest.java
PhaseListenerTest.java
Log:
fixed tests
Revision Changes Path
1.4 +5 -1 jboss-seam/src/test/misc/org/jboss/seam/test/Bar.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: Bar.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/test/misc/org/jboss/seam/test/Bar.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- Bar.java 27 Jul 2006 12:26:33 -0000 1.3
+++ Bar.java 11 Oct 2006 05:35:09 -0000 1.4
@@ -19,7 +19,7 @@
/**
* @author <a href="mailto:theute at jboss.org">Thomas Heute </a>
- * @version $Revision: 1.3 $
+ * @version $Revision: 1.4 $
*/
@Name("bar")
@Scope(ScopeType.CONVERSATION)
@@ -36,6 +36,9 @@
@Out(required=false)
String string;
+ @Out(required=false, scope=ScopeType.EVENT)
+ String otherString;
+
@Begin
public String begin()
{
@@ -44,6 +47,7 @@
public String foo()
{
string = "out";
+ otherString = "outAgain";
return "foo";
}
1.6 +2 -2 jboss-seam/src/test/misc/org/jboss/seam/test/ComponentTest.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: ComponentTest.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/test/misc/org/jboss/seam/test/ComponentTest.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- ComponentTest.java 27 Sep 2006 03:53:50 -0000 1.5
+++ ComponentTest.java 11 Oct 2006 05:35:09 -0000 1.6
@@ -1,4 +1,4 @@
-//$Id: ComponentTest.java,v 1.5 2006/09/27 03:53:50 gavin Exp $
+//$Id: ComponentTest.java,v 1.6 2006/10/11 05:35:09 gavin Exp $
package org.jboss.seam.test;
import org.jboss.seam.Component;
@@ -44,7 +44,7 @@
assert c.getInFields().size()==2;
assert c.getInMethods().size()==0;
assert c.getUnwrapMethod()==null;
- assert c.getOutFields().size()==1;
+ assert c.getOutFields().size()==2;
assert c.getOutMethods().size()==0;
assert c.getRemoveMethods().size()==0;
assert c.getValidateMethods().size()==0;
1.18 +16 -7 jboss-seam/src/test/misc/org/jboss/seam/test/ContextTest.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: ContextTest.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/test/misc/org/jboss/seam/test/ContextTest.java,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -b -r1.17 -r1.18
--- ContextTest.java 27 Jul 2006 12:26:33 -0000 1.17
+++ ContextTest.java 11 Oct 2006 05:35:09 -0000 1.18
@@ -1,4 +1,4 @@
-//$Id: ContextTest.java,v 1.17 2006/07/27 12:26:33 gavin Exp $
+//$Id: ContextTest.java,v 1.18 2006/10/11 05:35:09 gavin Exp $
package org.jboss.seam.test;
import javax.faces.context.ExternalContext;
@@ -16,6 +16,7 @@
import org.jboss.seam.contexts.ServerConversationContext;
import org.jboss.seam.contexts.WebRequestContext;
import org.jboss.seam.contexts.WebSessionContext;
+import org.jboss.seam.core.ConversationEntries;
import org.jboss.seam.core.Init;
import org.jboss.seam.core.Manager;
import org.jboss.seam.jsf.SeamVariableResolver;
@@ -39,6 +40,10 @@
MockExternalContext externalContext = new MockExternalContext(servletContext);
Context appContext = new FacesApplicationContext(externalContext);
appContext.set(
+ Seam.getComponentName(ConversationEntries.class) + ".component",
+ new Component(ConversationEntries.class, appContext)
+ );
+ appContext.set(
Seam.getComponentName(Manager.class) + ".component",
new Component(Manager.class)
);
@@ -103,8 +108,8 @@
assert !Contexts.isSessionContextActive();
assert !Contexts.isConversationContextActive();
assert !Contexts.isApplicationContextActive();
- assert ((MockHttpSession)externalContext.getSession(false)).getAttributes().size()==4;
- assert ((MockServletContext)externalContext.getContext()).getAttributes().size()==6;
+ assert ((MockHttpSession)externalContext.getSession(false)).getAttributes().size()==5;
+ assert ((MockServletContext)externalContext.getContext()).getAttributes().size()==7;
Lifecycle.beginRequest(externalContext);
@@ -137,8 +142,8 @@
assert Contexts.getSessionContext().get("foo")==foo;
assert Contexts.getConversationContext().getNames().length==2;
- assert Contexts.getApplicationContext().getNames().length==6;
- assert Contexts.getSessionContext().getNames().length==2;
+ assert Contexts.getApplicationContext().getNames().length==7;
+ assert Contexts.getSessionContext().getNames().length==3;
assert seamVariableResolver.resolveVariable(null, "zzz").equals("bar");
assert seamVariableResolver.resolveVariable(null, "xxx").equals("yyy");
@@ -157,8 +162,8 @@
assert !Contexts.isSessionContextActive();
assert !Contexts.isConversationContextActive();
assert !Contexts.isApplicationContextActive();
- assert ((MockHttpSession)externalContext.getSession(false)).getAttributes().size()==2;
- assert ((MockServletContext)externalContext.getContext()).getAttributes().size()==6;
+ assert ((MockHttpSession)externalContext.getSession(false)).getAttributes().size()==3;
+ assert ((MockServletContext)externalContext.getContext()).getAttributes().size()==7;
Lifecycle.endSession( servletContext, new ServletSessionImpl( (HttpSession) externalContext.getSession(true) ) );
@@ -182,6 +187,10 @@
ContextAdaptor requestAdaptor = new ServletRequestImpl(request);
Context appContext = new FacesApplicationContext(externalContext);
appContext.set(
+ Seam.getComponentName(ConversationEntries.class) + ".component",
+ new Component(ConversationEntries.class, appContext)
+ );
+ appContext.set(
Seam.getComponentName(Manager.class) + ".component",
new Component(Manager.class)
);
1.29 +2 -23 jboss-seam/src/test/misc/org/jboss/seam/test/InitializationTest.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: InitializationTest.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/test/misc/org/jboss/seam/test/InitializationTest.java,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -b -r1.28 -r1.29
--- InitializationTest.java 13 Aug 2006 11:06:48 -0000 1.28
+++ InitializationTest.java 11 Oct 2006 05:35:09 -0000 1.29
@@ -1,44 +1,23 @@
-//$Id: InitializationTest.java,v 1.28 2006/08/13 11:06:48 sbryzak2 Exp $
-
+//$Id: InitializationTest.java,v 1.29 2006/10/11 05:35:09 gavin Exp $
package org.jboss.seam.test;
-
-
import org.jboss.seam.contexts.Contexts;
-
import org.jboss.seam.init.Initialization;
-
import org.jboss.seam.mock.MockServletContext;
-
import org.testng.annotations.Test;
-
-
public class InitializationTest
-
{
-
@Test
-
public void testEmptyInitialization()
-
{
-
MockServletContext servletContext = new MockServletContext();
-
new Initialization(servletContext).setScannerEnabled(false).init();
-
- assert servletContext.getAttributes().size()==25 + 2*10;
-
+ assert servletContext.getAttributes().size()==51;
assert !Contexts.isApplicationContextActive();
-
}
-
-
//TODO: write a test for components.xml
-
-
}
1.24 +85 -10 jboss-seam/src/test/misc/org/jboss/seam/test/InterceptorTest.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: InterceptorTest.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/test/misc/org/jboss/seam/test/InterceptorTest.java,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -b -r1.23 -r1.24
--- InterceptorTest.java 12 Jul 2006 20:44:55 -0000 1.23
+++ InterceptorTest.java 11 Oct 2006 05:35:09 -0000 1.24
@@ -1,4 +1,4 @@
-//$Id: InterceptorTest.java,v 1.23 2006/07/12 20:44:55 gavin Exp $
+//$Id: InterceptorTest.java,v 1.24 2006/10/11 05:35:09 gavin Exp $
package org.jboss.seam.test;
import java.lang.reflect.Method;
@@ -15,6 +15,7 @@
import org.jboss.seam.contexts.Contexts;
import org.jboss.seam.contexts.FacesApplicationContext;
import org.jboss.seam.contexts.Lifecycle;
+import org.jboss.seam.core.ConversationEntries;
import org.jboss.seam.core.FacesMessages;
import org.jboss.seam.core.Init;
import org.jboss.seam.core.Interpolator;
@@ -42,6 +43,10 @@
Context appContext = new FacesApplicationContext(externalContext);
appContext.set( Seam.getComponentName(Init.class), new Init() );
appContext.set(
+ Seam.getComponentName(ConversationEntries.class) + ".component",
+ new Component(ConversationEntries.class, appContext)
+ );
+ appContext.set(
Seam.getComponentName(Manager.class) + ".component",
new Component(Manager.class, appContext)
);
@@ -81,13 +86,22 @@
}
});
assert "foo".equals(result);
- assert Contexts.getEventContext().get("string").equals("out");
- Foo created = bar.foo;
- assert created!=null;
- assert Contexts.getSessionContext().get("foo")==created;
+ assert Contexts.getEventContext().get("otherString").equals("outAgain");
+ assert Contexts.getConversationContext().get("string").equals("out");
+ assert Contexts.getSessionContext().isSet("foo");
+ assert bar.foo==null;
+ assert bar.otherFoo==null;
+
+ final Method method;
+ try
+ {
+ method = Bar.class.getMethod("foo");
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
- bar.foo=null;
- bar.otherFoo=null;
bi.bijectTargetComponent( new MockInvocationContext() {
@Override
public Object getTarget()
@@ -102,8 +116,14 @@
assert bar.foo!=null;
return bar.foo();
}
+ @Override
+ public Method getMethod()
+ {
+ return method;
+ }
});
- assert bar.foo==created;
+ assert bar.foo==null;
+ assert bar.otherFoo==null;
try
{
@@ -120,6 +140,11 @@
assert false;
return null;
}
+ @Override
+ public Method getMethod()
+ {
+ return method;
+ }
});
assert false;
}
@@ -128,6 +153,16 @@
assert e instanceof RequiredException;
}
+ final Method method2;
+ try
+ {
+ method2 = BrokenAction.class.getMethod("go");
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+
final BrokenAction brokenAction = new BrokenAction();
BijectionInterceptor biba = new BijectionInterceptor();
biba.setComponent( new Component(BrokenAction.class, appContext) );
@@ -139,13 +174,18 @@
public Object getTarget() {
return brokenAction;
}
-
@Override
public Object proceed() throws Exception {
assert false;
return null;
}
+ @Override
+ public Method getMethod()
+ {
+ return method2;
+ }
+
} );
assert false;
}
@@ -154,6 +194,16 @@
assert e instanceof RequiredException;
}
+ final Method method3;
+ try
+ {
+ method3 = Action.class.getMethod("go");
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+
final Action action = new Action();
BijectionInterceptor bia = new BijectionInterceptor();
bia.setComponent( new Component(Action.class, appContext) );
@@ -170,6 +220,12 @@
return action.go();
}
+ @Override
+ public Method getMethod()
+ {
+ return method3;
+ }
+
} );
assert "success".equals(result);
assert Contexts.getConversationContext().get("name").equals("Gavin King");
@@ -185,6 +241,10 @@
Context appContext = new FacesApplicationContext(externalContext);
appContext.set( Seam.getComponentName(Init.class), new Init() );
appContext.set(
+ Seam.getComponentName(ConversationEntries.class) + ".component",
+ new Component(ConversationEntries.class, appContext)
+ );
+ appContext.set(
Seam.getComponentName(Manager.class) + ".component",
new Component(Manager.class, appContext)
);
@@ -213,6 +273,8 @@
assert !Manager.instance().isLongRunningConversation();
assert "foo".equals(result);
+ Manager.instance().initializeTemporaryConversation();
+
result = (String) ci.endOrBeginLongRunningConversation( new MockInvocationContext() {
@Override
public Method getMethod()
@@ -432,6 +494,10 @@
Context appContext = new FacesApplicationContext(externalContext);
appContext.set( Seam.getComponentName(Init.class), new Init() );
appContext.set(
+ Seam.getComponentName(ConversationEntries.class) + ".component",
+ new Component(ConversationEntries.class, appContext)
+ );
+ appContext.set(
Seam.getComponentName(Manager.class) + ".component",
new Component(Manager.class, appContext)
);
@@ -479,6 +545,7 @@
}
});
+ Manager.instance().initializeTemporaryConversation();
Manager.instance().beginConversation("bar");
//assert Manager.instance().isLongRunningConversation();
@@ -532,6 +599,10 @@
Context appContext = new FacesApplicationContext(externalContext);
appContext.set( Seam.getComponentName(Init.class), new Init() );
appContext.set(
+ Seam.getComponentName(ConversationEntries.class) + ".component",
+ new Component(ConversationEntries.class, appContext)
+ );
+ appContext.set(
Seam.getComponentName(Manager.class) + ".component",
new Component(Manager.class, appContext)
);
@@ -671,6 +742,10 @@
Context appContext = new FacesApplicationContext(externalContext);
appContext.set( Seam.getComponentName(Init.class), new Init() );
appContext.set(
+ Seam.getComponentName(ConversationEntries.class) + ".component",
+ new Component(ConversationEntries.class, appContext)
+ );
+ appContext.set(
Seam.getComponentName(Manager.class) + ".component",
new Component(Manager.class, appContext)
);
1.20 +9 -1 jboss-seam/src/test/misc/org/jboss/seam/test/PhaseListenerTest.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: PhaseListenerTest.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/test/misc/org/jboss/seam/test/PhaseListenerTest.java,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -b -r1.19 -r1.20
--- PhaseListenerTest.java 10 Oct 2006 21:05:09 -0000 1.19
+++ PhaseListenerTest.java 11 Oct 2006 05:35:09 -0000 1.20
@@ -1,4 +1,4 @@
-//$Id: PhaseListenerTest.java,v 1.19 2006/10/10 21:05:09 gavin Exp $
+//$Id: PhaseListenerTest.java,v 1.20 2006/10/11 05:35:09 gavin Exp $
package org.jboss.seam.test;
import java.util.ArrayList;
@@ -45,6 +45,10 @@
Context appContext = new FacesApplicationContext(externalContext);
appContext.set( Seam.getComponentName(Init.class), new Init() );
appContext.set(
+ Seam.getComponentName(ConversationEntries.class) + ".component",
+ new Component(ConversationEntries.class, appContext)
+ );
+ appContext.set(
Seam.getComponentName(Manager.class) + ".component",
new Component(Manager.class)
);
@@ -227,6 +231,10 @@
Context appContext = new FacesApplicationContext(externalContext);
appContext.set( Seam.getComponentName(Init.class), new Init() );
appContext.set(
+ Seam.getComponentName(ConversationEntries.class) + ".component",
+ new Component(ConversationEntries.class, appContext)
+ );
+ appContext.set(
Seam.getComponentName(Manager.class) + ".component",
new Component(Manager.class)
);
More information about the jboss-cvs-commits
mailing list