3 Replies Latest reply on Sep 23, 2006 4:37 AM by Chris Lowe

    Interpolated Log String Causes Exception During TestNG Execu

    Chris Lowe Apprentice

      Hi,

      I have the following log statement within a SFSB action.

      log.debug("Attempting to registister account for user: #{user.id}; account: number '#0'; postcode '#1'; telephone = '#2'", originalRef, postcode, phoneNumber);

      When the action is invoked from the main application the log statement works as expected. However, when I invoke the same action from a TestNG test I get the following exception:
      Caused by: java.lang.IllegalArgumentException: can't parse argument number user.id
       at java.text.MessageFormat.makeFormat(MessageFormat.java:1330)
       at java.text.MessageFormat.applyPattern(MessageFormat.java:450)
       at java.text.MessageFormat.<init>(MessageFormat.java:368)
       at org.jboss.seam.core.Interpolator.interpolate(Interpolator.java:62)
       at org.jboss.seam.log.LogImpl.interpolate(LogImpl.java:162)
       at org.jboss.seam.log.LogImpl.info(LogImpl.java:98)
       at com.triggersoft.business.RegisterSubscriptionAction.findSubscription(RegisterSubscriptionAction.java:60)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:585)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeTarget(MethodInvocation.java:121)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:110)

      The test is defined as follows:
      new Script() {
       RegisterSubscription registerSubscription;
      
       @Override
       protected void applyRequestValues() {
       // add request parameters required by the @LoggedIn interceptor.
       Contexts.getSessionContext().set("loggedIn", true);
      
       final UserDao userDao = (UserDao) Component.getInstance("userDao", true);
      
       assert userDao != null;
      
       final User user = userDao.findById(44);
      
       assert user != null;
      
       Contexts.getSessionContext().set("user", user);
       }
      
      
       @Override
       protected void updateModelValues() throws Exception
       {
       // configure the action component
       registerSubscription = (RegisterSubscription)
       Component.getInstance("registerSubscription", true);
      
       registerSubscription.setOriginalRef("1234567");
       registerSubscription.setPhoneNumber("01234 678900");
       registerSubscription.setPostcode("A12 BB1");
       }
      
       @Override
       protected void invokeApplication()
       {
       assert Contexts.getSessionContext().get("user") != null;
      
       final String outcome = registerSubscription.findSubscription();
      
       assert "registerSubscriptionComplete".equals(outcome);
      
       final Account confirmAccount =
       (Account) Component.getInstance("confirmAccount", true);
      
       assert confirmAccount != null;
       }
       }.run();


      The action also has the user component injected which I have verified is non null when at the log line during a debug session.

      What am I doing wrong?

      Cheers,

      Chris.