1 Reply Latest reply on Jul 26, 2011 8:37 AM by Keith Babo

    Next evolution of SwitchYard testing ... ???

    Tom Fennelly Master

      SwitchYard testing at the moment involves:

       

      1. Extending the SwitchYardTestCase class and
      2. Annotating the test with @SwitchYardTestCaseConfig annotation to define one or all of:
        • A SwitchYard XML configuration file.
        • A set of one or more Test MixIns.
        • A set of one or more.

       

      E.g.

      @SwitchYardTestCaseConfig(
                 config = "/jaxbautoregister/switchyard-config-02.xml", 
                 mixins = CDIMixIn.class)
      public class CoolTest extends SwitchYardTestCase {
      
          @Test
          public void test() {
               ServiceDomain serviceDomain = getServiceDomain();
                
               newInvoker("A.opp").sendInOut(payload);
      
               // etc....
          }
      }
      

       

      Going forward (I hate that term ), we'd like to have better support for Arquillian and also be better able to utilise test infrastructures provided by other frameworks we've integrated with in SwitchYard e.g. Camel and it's great test support.

       

      I looked at creating a MixIn for Camel and to cut a long story short... it won't really work from what I can see.  Even if we did get it to work I'm 100% it will keep breaking on us and we'd be tweaking it forever.  The Camel test infrastructure is designed to be used by extension (your test class extending one of the camel test classes).  If we go using it in a way it was not designed to b used... we're asking for trouble !!

       

      The problem with our current model in SwitchYard is that we also work via the extension model... people need to extend the SwitchYardTestCase (as outlined above).  This gets in the way of using e.g. camel base test case classes.

       

      How SwitchYardTestCase works (it uses a TestRunner under the hood) also makes it difficult for us to get tighter integration with Arquillian because it too uses @RunWith.

       

      (I hope I haven't lost you at this stage)

       

      So... I'm starting to think we need to get away from our extension model and move to a pure @RunWith model.  I created a JIRA for this at https://issues.jboss.org/browse/SWITCHYARD-348 with an initial suggestion for what that might look like, but after thinking a little more, I think something like the following might be easier for users....

       

      @SwitchYardTestCaseConfig(
                 config = "/jaxbautoregister/switchyard-config-02.xml", 
                 mixins = CDIMixIn.class)
      @RunWith(SwitchYardRunner.class)
      public class CoolTest {
      
          SwitchYardRunner runner;
      
          @Test
          public void test() {
               ServiceDomain serviceDomain = runner.getServiceDomain();
               
               runner.newInvoker("A.opp").sendInOut(payload);
      
              // etc....
          }
      }
      

       

      This model now allows the test to extend a Camel (or whatever) base test case, which would mean we'd be using it as it was designed to be used (safer etc).

       

      I think it would also mean that we could now integrate more cleanly with Arquillian because the test is using the @RunWith directly.  This is just a hunch however... would need to investigate it more.   I def think it would not introduce any issues wrt tighter Arquillian integration.