package com.github.terma.gigaspacesqlconsole;

import org.junit.Test;

import static junit.framework.Assert.assertEquals;

public class GigaSpaceUrlTest {

    @Test
    public void shouldGetLocatorFromUrl() {
        assertEquals("yy.com.ab:1200", GigaSpaceUrl.parseLocator("jini:/*/x?locators=yy.com.ab:1200"));
    }

    @Test
    public void shouldReturnFirstLocatorFromUrlIfThemMoreOne() {
        assertEquals("yy.com.ab:1200", GigaSpaceUrl.parseLocator("jini:/*/x?locators=yy.com.ab:1200,locator.eq:1"));
    }

    @Test(expected = IllegalArgumentException.class)
    public void shouldThrowExceptionIfEmptyLocator() {
        assertEquals("yy.com.ab:1200", GigaSpaceUrl.parseLocator("jini:/*/x?locators="));
    }

    @Test(expected = IllegalArgumentException.class)
    public void shouldThrowExceptionIfCantFindLocator() {
        GigaSpaceUrl.parseLocator("jini:/*/x?");
    }

    @Test
    public void shouldGetSpaceNameFromUrl() {
        assertEquals("space", GigaSpaceUrl.parseSpace("jini:/*/space?locators=yy.com.ab:1200"));
        assertEquals("space", GigaSpaceUrl.parseSpace("jini:/*/space?"));
        assertEquals("space", GigaSpaceUrl.parseSpace("/./space?"));
    }

    @Test(expected = IllegalArgumentException.class)
    public void shouldThrowExceptionIfEmptySpaceName() {
        assertEquals("yy.com.ab:1200", GigaSpaceUrl.parseSpace("jini:/*/?"));
    }

    @Test(expected = IllegalArgumentException.class)
    public void shouldThrowExceptionIfCantFindSpaceName() {
        GigaSpaceUrl.parseSpace("jini:/*/");
    }

}

@@ -1548,10 +1548,11 @@
 %0A    %7D%0A%0A
+%0A
 %7D%0A

Fix #1