2 Replies Latest reply: Jan 5, 2012 10:35 AM by Bela Ban RSS

    Problems with @BMRule.targetLocation

    Bela Ban Master

      I have a problem using targetLocation() in @BMRule on a TestNG test.

       

      The same rule in a script file works.

       

      The test method is:

        @BMRule(name="test script",

                  targetClass="Person",

                  targetMethod="say",

                  targetLocation="AT READ name",

                  action="System.out.println(\"hello before returning\");")

          // @BMScript(value="bela", dir="target/test-classes")

          @Test

          public void testFoo() {

              Person p=new Person("Bela Ban");

              System.out.println(p.say());

              String name=p.getName();

              System.out.println("name = " + name);

          }

       

      Class Person is:

       

      package org.my;

       

      public class Person {

          protected String name;

       

          public Person(String name) {

              this.name=name;

          }

       

          public String getName() {

              return name;

          }

       

          public void setName(String name) {

              this.name=name;

          }

       

          public String say() {

              String tmp=name;

              return "hello world, my name is " + tmp;

          }

      }

       

       

      The rule is:

      RULE belas test

      CLASS org.my.Person

      METHOD say

      AT READ name

      IF TRUE

      DO System.out.println("say() was called");

      ENDRULE

       

      If I used @BMScript, it works, but if I use @BMRule and set targetLocation to "AT READ name", it fails.

       

      I tried different location specifiers, and so far, only "CALL method(parms)" seemed to work.

       

      Even simple stuff like targetLocation="AT EXIT" fails !

       

      The failure is:

      TransformListener() : accepting requests on localhost:9091

      TransformListener() : handling connection on port 9091

      retransforming org.jgroups.util.RingBuffer

      org.jboss.byteman.agent.Transformer : error parsing rule DelayRemove

      org.jboss.byteman.rule.exception.ParseException: rule DelayRemove

      org.jgroups.tests.RingBufferTest+testRemoveAndConcurrentAdd line 5 : unable to recover from previous errors

       

      Thoughts ?

        • 1. Re: Problems with @BMRule.targetLocation
          Andrew Dinn Master

          Hi Bela,

          Bela Ban wrote:

           

          I have a problem using targetLocation() in @BMRule on a TestNG test.

           

          The same rule in a script file works.

           

          The test method is:

            @BMRule(name="test script",

                      targetClass="Person",

                      targetMethod="say",

                      targetLocation="AT READ name",

                      action="System.out.println(\"hello before returning\");")

              // @BMScript(value="bela", dir="target/test-classes")

              . . .

           

          This is a known problem. With the current releases of BMUnit the AT is added by the annotation processor so you need to write

           

          . . .

          targetLocation="READ name",

          . . .

           

          When 2.0.0 is released you will be able to write "AT READ name. Also, you will also be able to write AFTER locations like  "AFTER READ name".