1   /*
2    * $Id: XmppFunctionalTestCase.java 10489 2008-01-23 17:53:38Z dfeist $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSource, Inc.  All rights reserved.  http://www.mulesource.com
5    *
6    * The software in this package is published under the terms of the CPAL v1.0
7    * license, a copy of which has been included with this distribution in the
8    * LICENSE.txt file.
9    */
10  
11  package org.mule.test.integration.transport.xmpp;
12  
13  import org.mule.api.endpoint.EndpointException;
14  import org.mule.api.endpoint.EndpointURI;
15  import org.mule.api.transport.Connector;
16  import org.mule.endpoint.MuleEndpointURI;
17  import org.mule.tck.FunctionalTestCase;
18  import org.mule.transport.xmpp.XmppConnector;
19  
20  import org.jivesoftware.smack.XMPPConnection;
21  
22  // TODO Convert this test to an XML-based configuration.
23  public class XmppFunctionalTestCase extends FunctionalTestCase
24  {
25      private XMPPConnection cnn;
26      private XmppConnector connector;
27  
28      public void testSanity()
29      {
30          fail("Convert this test to an XML-based configuration");
31      }
32      
33      protected String getConfigResources()
34      {
35          // TODO
36          return null;
37      }
38  
39      protected void sendTestData(int iterations) throws Exception
40      {
41          cnn = connector.createXmppConnection(getInDest());
42          for (int i = 0; i < 100; i++)
43          {
44              cnn.createChat("mule1").sendMessage("Test Message:" + i);
45          }
46      }
47  
48      protected void receiveAndTestResults() throws Exception
49      {
50  
51          Thread.sleep(7000);
52          // seem to be getting messages after the test messages??
53          // TODO Enable this assert
54          //assertTrue(callbackCount > 100);
55      }
56  
57      protected EndpointURI getInDest()
58      {
59          try
60          {
61              return new MuleEndpointURI("xmpp://mule1:mule@jabber.org.au/foo");
62          }
63          catch (EndpointException e)
64          {
65              fail(e.getMessage());
66              return null;
67          }
68      }
69  
70      protected EndpointURI getOutDest()
71      {
72          try
73          {
74              return new MuleEndpointURI("xmpp://mule2:mule@jabber.org.au/foobar");
75          }
76          catch (EndpointException e)
77          {
78              fail(e.getMessage());
79              return null;
80          }
81      }
82  
83      protected Connector createConnector() throws Exception
84      {
85          connector = new XmppConnector();
86          connector.setName("test");
87          return connector;
88      }
89  
90  }