You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by sk...@apache.org on 2007/12/05 09:47:15 UTC

svn commit: r601253 - in /myfaces/orchestra/trunk/core/src/test/java/org/apache/myfaces/orchestra/conversation: SimpleBean.java TestScope.java

Author: skitching
Date: Wed Dec  5 00:47:13 2007
New Revision: 601253

URL: http://svn.apache.org/viewvc?rev=601253&view=rev
Log:
Verify that the CurrentConversationAdvice is attached to orchestra-scoped beans.

Modified:
    myfaces/orchestra/trunk/core/src/test/java/org/apache/myfaces/orchestra/conversation/SimpleBean.java
    myfaces/orchestra/trunk/core/src/test/java/org/apache/myfaces/orchestra/conversation/TestScope.java

Modified: myfaces/orchestra/trunk/core/src/test/java/org/apache/myfaces/orchestra/conversation/SimpleBean.java
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/core/src/test/java/org/apache/myfaces/orchestra/conversation/SimpleBean.java?rev=601253&r1=601252&r2=601253&view=diff
==============================================================================
--- myfaces/orchestra/trunk/core/src/test/java/org/apache/myfaces/orchestra/conversation/SimpleBean.java (original)
+++ myfaces/orchestra/trunk/core/src/test/java/org/apache/myfaces/orchestra/conversation/SimpleBean.java Wed Dec  5 00:47:13 2007
@@ -92,4 +92,9 @@
 		// TODO Auto-generated method stub
 		
 	}
+	
+	public void callback(Runnable callback)
+	{
+		callback.run();
+	}
 }

Modified: myfaces/orchestra/trunk/core/src/test/java/org/apache/myfaces/orchestra/conversation/TestScope.java
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/core/src/test/java/org/apache/myfaces/orchestra/conversation/TestScope.java?rev=601253&r1=601252&r2=601253&view=diff
==============================================================================
--- myfaces/orchestra/trunk/core/src/test/java/org/apache/myfaces/orchestra/conversation/TestScope.java (original)
+++ myfaces/orchestra/trunk/core/src/test/java/org/apache/myfaces/orchestra/conversation/TestScope.java Wed Dec  5 00:47:13 2007
@@ -141,4 +141,30 @@
 
 		assertEquals(1, b1.getConversationAwareCount());
 	}
+	
+	public void testCorrectConversation() throws Exception
+	{
+		// Set up the FrameworkAdapter. This is needed by any ConversationManager operation.
+		LocalFrameworkAdapter frameworkAdapter = new LocalFrameworkAdapter();
+		frameworkAdapter.setApplicationContext(applicationContext);
+		frameworkAdapter.setConversationMessager(new LogConversationMessager());
+        FrameworkAdapter.setCurrentInstance(frameworkAdapter);
+
+        final SimpleBean b1 = (SimpleBean) applicationContext.getBean("unscopedBean");
+		assertNotNull(b1);
+
+		// We are not within any method of an orchestra bean, so no current bean exists
+		Object currentBean = ConversationUtils.getCurrentBean();
+		assertNull(currentBean);
+
+		b1.callback(new Runnable() {
+			public void run()
+			{
+				// We are within a method of the orchestra bean b1, so it should be the 
+				// current bean.
+				Object currentBean = ConversationUtils.getCurrentBean();
+				assertTrue(b1 == currentBean);
+			}
+		});
+	}
 }