/*
 * Copyright (c) 2017 Inocybe, Inc. and others. All rights reserved.
 *
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
 * and is available at http://www.eclipse.org/legal/epl-v10.html
 */

package org.opendaylight.neutron.hostconfig.vpp;

import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;

public class SocketInfoTest {

    private static final String SOCKET_PATH = "/tmp";
    private static final String SOCKET_PREFIX = "socket_";
    private static final String VHOSTUSER_MODE = "server";

    // For equal test
    private static final String SOCKET_PATH_BIS = "/opt";
    private static final String SOCKET_PREFIX_BIS = "socket_bis_";
    private static final String VHOSTUSER_MODE_BIS = "server_bis";
    private SocketInfo socketInfo;

    @Before
    public void init() {
        socketInfo = new SocketInfo(SOCKET_PATH, SOCKET_PREFIX, VHOSTUSER_MODE);
    }

    @Test
    public void getSocketPathTest() {
        Assert.assertEquals(socketInfo.getSocketPath(), SOCKET_PATH);
    }

    @Test
    public void getSocketPrefixTest() {
        Assert.assertEquals(socketInfo.getSocketPrefix(), SOCKET_PREFIX);
    }

    @Test
    public void getVhostuserModeTest() {
        Assert.assertEquals(socketInfo.getVhostuserMode(), VHOSTUSER_MODE);
    }

    @Test
    public void getVhostUserSocketTest() {
        final String expectedResult = "/tmpsocket_$PORT_ID";
        Assert.assertEquals(socketInfo.getVhostUserSocket(), expectedResult);
    }

    @Test
    public void hashCodeTest() {
        final int expectedResult = 1774869086;
        Assert.assertEquals(socketInfo.hashCode(), expectedResult);
    }

    @Test
    public void equalTest() {
        Assert.assertTrue(socketInfo.equals(socketInfo));
        Assert.assertFalse(socketInfo.equals(null));
        Assert.assertFalse(socketInfo.equals(0));
        Assert.assertFalse(socketInfo.equals(new SocketInfo(SOCKET_PATH_BIS, SOCKET_PREFIX, VHOSTUSER_MODE)));
        Assert.assertFalse(socketInfo.equals(new SocketInfo(SOCKET_PATH, SOCKET_PREFIX_BIS, VHOSTUSER_MODE)));
        Assert.assertFalse(socketInfo.equals(new SocketInfo(SOCKET_PATH, SOCKET_PATH, VHOSTUSER_MODE_BIS)));
    }



}

@@ -669,32 +669,36 @@
 ic final String 
+ALT_
 SOCKET_PATH_BIS 
@@ -692,20 +692,16 @@
 KET_PATH
-_BIS
  = %22/opt
@@ -727,32 +727,36 @@
 ic final String 
+ALT_
 SOCKET_PREFIX_BI
@@ -752,20 +752,16 @@
 T_PREFIX
-_BIS
  = %22sock
@@ -794,32 +794,36 @@
 ic final String 
+ALT_
 VHOSTUSER_MODE_B
@@ -820,20 +820,16 @@
 SER_MODE
-_BIS
  = %22serv
@@ -2005,32 +2005,36 @@
 (new SocketInfo(
+ALT_
 SOCKET_PATH_BIS,
@@ -2028,20 +2028,16 @@
 KET_PATH
-_BIS
 , SOCKET
@@ -2129,32 +2129,36 @@
 fo(SOCKET_PATH, 
+ALT_
 SOCKET_PREFIX_BI
@@ -2154,20 +2154,16 @@
 T_PREFIX
-_BIS
 , VHOSTU
@@ -2261,16 +2261,20 @@
 T_PATH, 
+ALT_
 VHOSTUSE
@@ -2283,12 +2283,8 @@
 MODE
-_BIS
 )));

rename SocketInfoTest alternative val