View Javadoc

1   /*
2    * $Id: XmppChatSyncTestCase.java 22449 2011-07-19 07:40:43Z justin.calleja $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.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.transport.xmpp;
12  
13  import java.util.Arrays;
14  import java.util.Collection;
15  
16  import org.jivesoftware.smack.packet.Message;
17  import org.jivesoftware.smack.packet.Message.Type;
18  import org.junit.runners.Parameterized.Parameters;
19  import org.mule.transport.xmpp.JabberSender.Callback;
20  
21  public class XmppChatSyncTestCase extends XmppMessageSyncTestCase
22  {
23      
24      public XmppChatSyncTestCase(ConfigVariant variant, String configResources)
25      {
26          super(variant, configResources);
27      }
28  
29      @Parameters
30      public static Collection<Object[]> parameters()
31      {
32          return Arrays.asList(new Object[][]{
33              {ConfigVariant.SERVICE, AbstractXmppTestCase.COMMON_CONFIG + "," + "xmpp-chat-sync-config-service.xml"},
34              {ConfigVariant.FLOW, AbstractXmppTestCase.COMMON_CONFIG + "," + "xmpp-chat-sync-config-flow.xml"}
35          });
36      }
37  
38      @Override
39      public void testRequestSync() throws Exception
40      {
41          doTestRequest("xmpp://CHAT/mule2@localhost?exchangePattern=request-response");
42      }
43  
44      @Override
45      protected Type expectedXmppMessageType()
46      {
47          return Message.Type.chat;
48      }
49      
50      @Override
51      protected void sendJabberMessageFromNewThread()
52      {
53          JabberSender sender = new JabberSender(new Callback()
54          {
55              public void doit() throws Exception
56              {
57                  Thread.sleep(JABBER_SEND_THREAD_SLEEP_TIME);
58                  jabberClient.sendChatMessage(muleJabberUserId, TEST_MESSAGE);
59              }
60          });
61          startSendThread(sender);
62      }
63  }