Search code examples
restgroovyspock

Expected scheme-specific part at index 5: null:


I'm getting the following exception when trying to get HTTP get response using Spock framework.

java.net.URISyntaxException: Expected scheme-specific part at index 5: null:

def SERVER_URL = "http://localhost"
def SERVER_PORT = ":8082"
def USERNAME = "mail@gmail.com"
def PASSWORD = "123456"

   def client = new RESTClient("$SERVER_URL:$SERVER_PORT")


    def 'should return 200 code when used valid credentials'() {
        when: 'login with valid credentials'
        client.headers['Authorization'] = "Basic ${"$USERNAME:$PASSWORD".bytes.encodeBase64()}"
        def response = client.get(path:'/artifactory/ui/auth/screen/footer')

Solution

  • Remove the colon from

    def SERVER_PORT = "8082"
    

    Or remove the colon from

    def client = new RESTClient("$SERVER_URL$SERVER_PORT")
    

    You have one too many colons before the port