[jbossseam-issues] [JBoss JIRA] Created: (JBSEAM-1804) Page context instance not recognized in SeamTest

Christian Bauer (JIRA) jira-events at lists.jboss.org
Wed Aug 15 14:19:00 EDT 2007


Page context instance not recognized in SeamTest
------------------------------------------------

                 Key: JBSEAM-1804
                 URL: http://jira.jboss.com/jira/browse/JBSEAM-1804
             Project: JBoss Seam
          Issue Type: Bug
          Components: Test Harness
            Reporter: Christian Bauer


I didn't try CVS yet, this is 3 weeks old CVS. The issue with the following test is that 'beanB' is instantiated again on every call, be it a Component.getInstance() lookup or an Event that is fired. The goal of the test is to modify a value in BeanA and then get this new value into BeanB through a chain of events.

@Name("beanA")
@Scope(ScopeType.CONVERSATION)
@AutoCreate
public class BeanA {

    private String myValue;

    public String getMyValue() {
        return myValue;
    }

    public void setMyValue(String myValue) {
        this.myValue = myValue;
    }

    @Create
    public void create() {
        myValue = "Foo";
    }

    @Observer(value = "BeanA.refreshMyValue")
    public void refreshMyValue() {
        myValue = "Bar";
        Events.instance().raiseEvent("BeanA.valueModified");
    }

}

@Name("beanB")
@Scope(ScopeType.PAGE)
@AutoCreate
public class BeanB implements Serializable {

    private String myValue;

    public String getMyValue() {
        return myValue;
    }

    public void setMyValue(String myValue) {
        this.myValue = myValue;
    }

    @Observer(value = "BeanA.valueModified")
    public void takeValueFromBeanA() {
        BeanA beanA = (BeanA) Component.getInstance("beanA");
        myValue = beanA.getMyValue();
    }

}

public class MiscTests extends SeamTest {

    @Test
    public void eventChain() throws Exception {

        new FacesRequest("/docDisplay.xhtml") {

            protected void invokeApplication() throws Exception {
                BeanA beanA = (BeanA) Component.getInstance("beanA");
                BeanB beanB = (BeanB) Component.getInstance("beanB");

                assert "Foo".equals(beanA.getMyValue());
                assert beanB.getMyValue() == null;

                Events.instance().raiseEvent("BeanA.refreshMyValue");

                beanA = (BeanA) Component.getInstance("beanA");
                beanB = (BeanB) Component.getInstance("beanB");

                assert "Bar".equals(beanA.getMyValue());
                assert "Bar".equals(beanB.getMyValue());
            }
        }.run();
    }

}



-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the seam-issues mailing list