3 Replies Latest reply on Dec 22, 2008 4:15 PM by Naresh Bhatia

    Component not created in SeamTest

    Naresh Bhatia Newbie

      I have written the following SeamTest to test a Seam component I have written:

      public class CreateUserTest extends SeamTest {
          public void testCreateUser() throws Exception {
              new ComponentTest() {
                  protected void testComponents() throws Exception {
                      setValue("#{securityService.username}", "jdoe");
                      setValue("#{securityService.password}", "bluemoon");

      When I run this test I get the following error:

      javax.el.PropertyNotFoundException: Property 'username' is not found on type: myApp.SecurityService_$$_javassist_0
           at javax.el.BeanELResolver.setValue(BeanELResolver.java:332)
           at javax.el.CompositeELResolver.setValue(CompositeELResolver.java:275)
           at org.jboss.el.parser.AstPropertySuffix.setValue(AstPropertySuffix.java:73)
           at org.jboss.el.parser.AstValue.setValue(AstValue.java:84)
           at org.jboss.el.ValueExpressionImpl.setValue(ValueExpressionImpl.java:249)
           at org.jboss.seam.core.Expressions$1.setValue(Expressions.java:117)
           at org.jboss.seam.mock.AbstractSeamTest$ComponentTest.setValue(AbstractSeamTest.java:153)

      I think that securityService is not being created although I have set @AutoCreate on it.

      public class SecurityService {
          private String username;
          private String password;
          public void createUser() {

      What could be going wrong?


        • 1. Re: Component not created in SeamTest
          Matt Nirgue Newbie

          the username property is private so if you don't have a getter/setter you won't be able to use getValue nor setValue on this property... since it's private, you shouldn't be able to access it outside of your class which is why you get a property not found exception. Either you add the getter/setter for this property or you find a workaround...

          You have to be careful though: you shouldn't have to change your component JUST for your test... IMO, that would mean there's a conception problem with your component: if your test can't use your component as it is, then how can another component use it?



          • 2. Re: Component not created in SeamTest
            Matt Nirgue Newbie

            BTW, your component is created... as I said, this is not the problem here!

            Property 'username' is not found on type: myApp.SecurityService_$$_javassist_0

            >> This means that Seam is trying to access the username property of a SecurityService component... which means that Seam knows that the component securityService is a SecurityService component, which also means that this component has been created... you would have had a NullPointerException (or something like) that if your component has not been created!

            • 3. Re: Component not created in SeamTest
              Naresh Bhatia Newbie

              Matt, indeed there was a conceptual problem with my component :-). This is related to my another post that you answered so nicely.

              Originally my component was written so that username and password were passed in as parameters to the createUser() method. However since I did not know how to invoke the method with parameters in SeamTest, I switched to properties - obviously a bad decision! However, now that I have the answer to my original problem, I have switched back to parameters and life is good!