Package org.mule.extras.client

Examples of org.mule.extras.client.MuleClient


        servers.setUser("mule@symphonysoft.com", "login", "password");
    }

    public void testPlainMessageAPI() throws Exception
    {
        MuleClient client = new MuleClient();
        UMOMessage msg = null;
        String result;
        final String subject = servers.util().random();
        final String body = servers.util().random();

        for (int i = 0; i < messageCount; i++)
        {
            // Send Messages to Inbox
            servers.util().sendTextEmailTest("mule@symphonysoft.com", "from@symphonysoft.com", subject,
                body + " " + i);
            assertEquals(i + 1, servers.getReceivedMessages().length);
        }

        // Retrieve using Mule Client
        for (int i = 0; i < messageCount; i++)
        {
            msg = client.receive("pop3://login:password@localhost:3110", 100);
            assertNotNull(msg);
            assertTrue(msg.getPayload() instanceof String);
            result = (String)msg.getPayload();
            assertEquals(result.trim(), body + " " + i);
        }
View Full Code Here


        servers.setUser("mule@symphonysoft.com", "login", "password");
    }

    public void testPlainMessage() throws Exception
    {
        MuleClient client = new MuleClient();
        UMOMessage msg = null;
        String result;
        String[] split;
        int messageNumber;
        final String subject = servers.util().random();
        final String body = servers.util().random();
        boolean[] received = new boolean[messageCount];

        for (int i = 0; i < messageCount; i++)
        {
            // Send Messages to Inbox
            servers.util().sendTextEmailTest("mule@symphonysoft.com", "from@symphonysoft.com", subject,
                body + " " + i);
            assertEquals(i + 1, servers.getReceivedMessages().length);
            received[i] = false;
        }

        // Retrieve using Mule Client
        for (int i = 0; i < messageCount; i++)
        {
            msg = client.receive("vm://outbound", 30000);
            assertNotNull(msg);
            assertTrue(msg.getPayload() instanceof String);
            result = (String)msg.getPayload();
            split = result.trim().split(" ");
            // assertTrue(result.trim().compareTo(body+" "+i)==0);
            assertEquals(split[0], body);
            messageNumber = Integer.parseInt(split[1]);
            assertFalse("Message Received : " + messageNumber, received[messageNumber]);
            received[messageNumber] = true;
        }

        for (int i = 0; i < messageCount; i++)
        {
            assertTrue(received[i]);
        }

        assertNull(client.receive("vm://outbound", 50));
    }
View Full Code Here

        assertNull(client.receive("vm://outbound", 50));
    }

    public void testLatinEncodedMessage() throws Exception
    {
        MuleClient client = new MuleClient();
        UMOMessage msg = null;
        String result;
        String[] split;
        int messageNumber;
        final String subject = servers.util().random();
        boolean[] received = new boolean[messageCount];

        Properties props = new Properties();
        props.put("mail.smtp.host", "localhost");
        props.put("mail.smtp.port", "3025");
        props.put("mail.smtp.ssl", "false");
        Session session = Session.getInstance(props, null);

        for (int i = 0; i < messageCount; i++)
        {
            // Send Messages to Inbox
            Address[] tos = new InternetAddress[]{new InternetAddress("mule@symphonysoft.com")};
            Address[] froms = new InternetAddress[]{new InternetAddress("from@symphonysoft.com")};
            MimeMessage mimeMessage = new MimeMessage(session);
            mimeMessage.setSubject(subject);
            mimeMessage.setFrom(froms[0]);

            mimeMessage.setContent("\u00CB\u00C7" + " " + i, "text/plain; charset=ISO-8859-1");
            Transport.send(mimeMessage, tos);

            // servers.util().sendTextEmailTest("mule@symphonysoft.com",
            // "from@symphonysoft.com",
            // subject,"\u65e5\u672c\u8a9e\u6587\u5b57\u5217"+body+" "+i);
            assertEquals(i + 1, servers.getReceivedMessages().length);
            received[i] = false;
        }

        // Retrieve using Mule Client
        for (int i = 0; i < messageCount; i++)
        {
            msg = client.receive("vm://outbound", 1000000000);
            assertNotNull(msg);
            assertTrue(msg.getPayload() instanceof String);
            result = (String)msg.getPayload();
            split = result.trim().split(" ");
            // assertTrue(result.trim().compareTo("\u00CB\u00C7"+" "+i)==0);
            // assertEquals(result.trim(),"\u00CB\u00C7"+" "+i);
            assertEquals(split[0], "\u00CB\u00C7");
            messageNumber = Integer.parseInt(split[1]);
            assertFalse("Message Received : " + messageNumber, received[messageNumber]);
            received[messageNumber] = true;
        }

        for (int i = 0; i < messageCount; i++)
        {
            assertTrue(received[i]);
        }

        assertNull(client.receive("vm://outbound", 50));
    }
View Full Code Here

    protected static transient Log logger = LogFactory.getLog(SmtpAttachmentTestCaseAPI.class);

    public void testAttachmentAPI() throws Exception
    {
        MuleClient client = new MuleClient();
        boolean[] received = new boolean[messageCount];

        for (int i = 0; i < messageCount; i++)
        {
            client.dispatch("vm://smtpinbound", "Message : " + i + ";email.jpg;test.doc", null);
            received[i] = false;
        }

        // wait for max 5s for 1 email to arrive
        assertTrue(servers.waitForIncomingEmail(5000, messageCount));
View Full Code Here

    public void send() throws UMOException {
        byte[] msg = new byte[config.getMessageSize()];
        Arrays.fill(msg, (byte) 0);
        String message = new String(msg);

        MuleClient client = new MuleClient();
        String endpoint = config.getEndpointsArray()[0];

        System.out.println("Starting sender on : " + endpoint);
        System.out.println("Message length: " + message.length());
        for (int i = 0; i < config.getMessages(); i++) {
            client.dispatch(endpoint, message, null);
            count(1);
        }
        printReport();
    }
View Full Code Here

    protected static transient Log logger = LogFactory.getLog(SmtpAttachmentTestCase.class);

    public void testAttachment() throws Exception
    {
        MuleClient client = new MuleClient();
        boolean[] received = new boolean[messageCount];

        for (int i = 0; i < messageCount; i++)
        {
            client.dispatch("vm://smtpinbound", "Message : " + i + ";email.jpg;email.jpg", null);
            received[i] = false;
        }

        // wait for max 5s for 1 email to arrive
        assertTrue(servers.waitForIncomingEmail(5000, messageCount));
View Full Code Here

public class SmtpAndSmtpsTestCase extends MailFunctionalTestCase
{

    public void testPlainMessage() throws Exception
    {
        MuleClient client = new MuleClient();
        boolean[] received = new boolean[messageCount];

        // smtp
        for (int i = 0; i < messageCount; i++)
        {
            client.dispatch("vm://smtpinbound", "Message : " + i, null);
            received[i] = false;
        }

        // wait for max 5s for 1 email to arrive
        assertTrue(servers.waitForIncomingEmail(5000, messageCount));

        // Retrieve using GreenMail API
        Message[] messages = servers.getReceivedMessages();
        assertEquals(messageCount, messages.length);
        for (int i = 0; i < messageCount; i++)
        {
            String message = servers.util().getBody(messages[i]).trim();
            int messageNumber = Integer.parseInt(message.substring(message.lastIndexOf(" ") + 1));
            assertFalse(received[messageNumber]);
            received[messageNumber] = true;
        }
        for (int i = 0; i < messageCount; i++)
        {
            assertTrue(received[i]);
        }

        // smtps
        for (int i = 0; i < messageCount; i++)
        {
            client.dispatch("vm://smtpsinbound", "Message : " + i, null);
            received[i] = false;
        }

        // wait for max 5s for 1 email to arrive
        assertTrue(servers.waitForIncomingEmail(5000, messageCount * 2));
 
View Full Code Here

        }
    }

    public void testBothPlainMessage() throws Exception
    {
        MuleClient client = new MuleClient();
        int[] checklist = new int[messageCount];
        int tmpResult;
        for (int i = 0; i < messageCount; i++)
        {
            client.dispatch("vm://bothinbound", "Message : " + i, null);
            checklist[i] = 0;
        }

        // wait for max 5s for 1 email to arrive
        assertTrue(servers.waitForIncomingEmail(5000, messageCount * 2));
 
View Full Code Here

    public void testFunctional() throws Exception {

        MQQueueConnectionFactory f = null;
        String TEST_MSG = "tresting";
        MuleClient client = new MuleClient();
        MQSeriesConnector c = new MQSeriesConnector();
        try {
            f = new MQQueueConnectionFactory();
            f.setHostName("vmmachine"); //Change this to the name of the server running MQ
            f.setPort(6969)//Change this accordingly too. Default is 1414
            f.setQueueManager("QM_vmmachine");             // Queue Manager with this name needs to be pre-configured!

            f.setTransportType(JMSC.MQJMS_TP_CLIENT_MQ_TCPIP);
            f.createQueueConnection().start();
        } catch (JMSException e) {
            e.printStackTrace()//To change body of catch statement use File | Settings | File Templates.
            e.getLinkedException().printStackTrace();
        }

        c.setName("WSSeries");
        c.setHostname("vmmachine");
        c.setConnectionFactory(f);

        client.getManager().registerConnector(c);
        client.sendNoReceive("mqs://QM_vmmachine/MuleQueue", TEST_MSG, null);
        UMOMessage result = client.receive("mqs://QM_vmmachine/MuleQueue", 3000);
        assertNotNull(result);
        assertEquals(TEST_MSG, result.getPayloadAsString());    }
View Full Code Here

        corp.setQueueManager("QM_vmmachine");
        corp.setTransportType(JMSC.MQJMS_TP_CLIENT_MQ_TCPIP);
        //corp.createQueueConnection().start();

        String TEST_MSG = "tresting";
        MuleClient client = new MuleClient();
        MQSeriesConnector dmzCnn = new MQSeriesConnector();
        dmzCnn.setName("dmz");
        dmzCnn.setHostname("VMMachine");
        dmzCnn.setConnectionFactory(dmz);
        client.getManager().registerConnector(dmzCnn);

        MQSeriesConnector corpCnn = new MQSeriesConnector();
        corpCnn.setName("corp");
        corpCnn.setHostname("VMMachine"); // AB
        corpCnn.setPort(6969);
       
        corpCnn.setConnectionFactory(corp);
        client.getManager().registerConnector(corpCnn);
        client.getManager().start();

        client.sendNoReceive("mqs://QM_vmmachine/MuleQueue", TEST_MSG, null);
        UMOMessage result = client.receive("mqs://QM_vmmachine/MuleQueue", 3000);
        assertNotNull(result);
        assertEquals(TEST_MSG, result.getPayloadAsString());

    }
View Full Code Here

TOP

Related Classes of org.mule.extras.client.MuleClient

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.