package client.iron.ironmq;


import io.iron.ironmq.*;
import org.junit.Assert;
import org.junit.Test;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

public class ClientIronMQTest {

    private String queueName = "java-testing-queue";
    private String token = "";
    private String projectId = "";

    @Test
    public void testPostMultipleMessagesAndIdsShouldNotBeNull() throws IOException {
        Client client = setCredentials();
        Queue queue = new Queue(client, queueName);
        String body = "Hello, IronMQ!";
        queue.push(body, 10);
        QueueModel infoAboutQueue = queue.getInfoAboutQueue();
        int queueSize = infoAboutQueue.getSize();

        String[] messages = {"c", "d"};
        Ids ids = queue.pushMessages(messages);

        infoAboutQueue = queue.getInfoAboutQueue();
        Assert.assertEquals(messages.length, ids.getSize());
        Assert.assertEquals(queueSize + 2, infoAboutQueue.getSize());

        queue.deleteMessages(ids);

        infoAboutQueue = queue.getInfoAboutQueue();
        Assert.assertEquals(queueSize, infoAboutQueue.getSize());
        queue.destroy();
    }

    private Client setCredentials() throws IOException {
        Properties prop = new Properties();
        InputStream input;
        try {
            input = new FileInputStream("config.properties");
        } catch (FileNotFoundException fnfe) {
            System.out.println("config.properties not found");
            input = new FileInputStream("../../config.properties"); //maven release hack
        }
        prop.load(input);
        String token = prop.getProperty("token");
        String projectId = prop.getProperty("project_id");

        String host = prop.getProperty("serverHost");
        String scheme = prop.getProperty("serverScheme");
        int port = Integer.parseInt(prop.getProperty("serverPort"));

        return new Client(projectId, token, new Cloud(scheme, host, port), 3);
    }
}

@@ -73,16 +73,41 @@
 Assert;%0A
+import org.junit.Before;%0A
 import o
@@ -121,16 +121,16 @@
 t.Test;%0A
-
 %0Aimport 
@@ -429,16 +429,136 @@
 Id = %22%22;
+%0A    private Client client;%0A%0A    @Before%0A    public void setUp() throws Exception %7B%0A        client = new Client();%0A    %7D
 %0A%0A    @T
@@ -650,50 +650,8 @@
 n %7B%0A
-        Client client = setCredentials();%0A
     
@@ -1301,32 +1301,32 @@
 eue.getSize());%0A
+
         queue.de
@@ -1343,824 +1343,7 @@
    %7D
-%0A%0A    private Client setCredentials() throws IOException %7B%0A        Properties prop = new Properties();%0A        InputStream input;%0A        try %7B%0A            input = new FileInputStream(%22config.properties%22);%0A        %7D catch (FileNotFoundException fnfe) %7B%0A            System.out.println(%22config.properties not found%22);%0A            input = new FileInputStream(%22../../config.properties%22); //maven release hack%0A        %7D%0A        prop.load(input);%0A        String token = prop.getProperty(%22token%22);%0A        String projectId = prop.getProperty(%22project_id%22);%0A%0A        String host = prop.getProperty(%22serverHost%22);%0A        String scheme = prop.getProperty(%22serverScheme%22);%0A        int port = Integer.parseInt(prop.getProperty(%22serverPort%22));%0A%0A        return new Client(projectId, token, new Cloud(scheme, host, port), 3);%0A    %7D
 %0A%7D%0A

modify ClientIronMQTest for v3