// Path: cocaine-client/src/main/java/cocaine/ServiceInfo.java
// public class ServiceInfo {
// 
//     private final String name;
//     private final SocketAddress endpoint;
//     private final ServiceApi api;
// 
//     public ServiceInfo(String name, SocketAddress endpoint, ServiceApi api) {
//         this.name = name;
//         this.endpoint = endpoint;
//         this.api = api;
//     }
// 
//     public String getName() {
//         return name;
//     }
// 
//     public SocketAddress getEndpoint() {
//         return endpoint;
//     }
// 
//     public ServiceApi getApi() {
//         return api;
//     }
// 
//     @Override
//     public String toString() {
//         return "Service: " + name + "; Endpoint: " + endpoint + "; Service API: { " + api.toString() + " }";
//     }
// }


import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.SocketAddress;
import java.util.Arrays;
import java.util.Collections;
import java.util.Map;
import cocaine.ServiceInfo;
import org.junit.Assert;
import org.junit.Test;
import org.msgpack.MessagePack;
package cocaine.msgpack;



/**
 * @author Anton Bobukh <abobukh@yandex-team.ru>
 */
public class ServiceInfoTemplateTest {

    @Test
    public void read() throws IOException {
        String service = "locator";
        SocketAddress endpoint = new InetSocketAddress("localhost", 3456);
        long session = 0L;
        Map<Integer, String> api = Collections.singletonMap(0, "invoke");

        MessagePack pack = new MessagePack();
        pack.register(SocketAddress.class, SocketAddressTemplate.getInstance());
        byte[] bytes = pack.write(Arrays.asList(endpoint, session, api));

// Path: cocaine-client/src/main/java/cocaine/ServiceInfo.java
// public class ServiceInfo {
// 
//     private final String name;
//     private final SocketAddress endpoint;
//     private final ServiceApi api;
// 
//     public ServiceInfo(String name, SocketAddress endpoint, ServiceApi api) {
//         this.name = name;
//         this.endpoint = endpoint;
//         this.api = api;
//     }
// 
//     public String getName() {
//         return name;
//     }
// 
//     public SocketAddress getEndpoint() {
//         return endpoint;
//     }
// 
//     public ServiceApi getApi() {
//         return api;
//     }
// 
//     @Override
//     public String toString() {
//         return "Service: " + name + "; Endpoint: " + endpoint + "; Service API: { " + api.toString() + " }";
//     }
// }


// Path: cocaine-client/src/test/java/cocaine/msgpack/ServiceInfoTemplateTest.java
import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.SocketAddress;
import java.util.Arrays;
import java.util.Collections;
import java.util.Map;
import cocaine.ServiceInfo;
import org.junit.Assert;
import org.junit.Test;
import org.msgpack.MessagePack;

package cocaine.msgpack;



/**
 * @author Anton Bobukh <abobukh@yandex-team.ru>
 */
public class ServiceInfoTemplateTest {

    @Test
    public void read() throws IOException {
        String service = "locator";
        SocketAddress endpoint = new InetSocketAddress("localhost", 3456);
        long session = 0L;
        Map<Integer, String> api = Collections.singletonMap(0, "invoke");

        MessagePack pack = new MessagePack();
        pack.register(SocketAddress.class, SocketAddressTemplate.getInstance());
        byte[] bytes = pack.write(Arrays.asList(endpoint, session, api));

        ServiceInfo result = pack.read(bytes, ServiceInfoTemplate.create(service));