import io.fabric8.kubernetes.api.model.Service;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import org.arquillian.cube.kubernetes.annotations.Named;
import org.arquillian.cube.kubernetes.annotations.PortForward;
import org.arquillian.cube.kubernetes.impl.requirement.RequiresKubernetes;
import org.arquillian.cube.requirement.ArquillianConditionalRunner;
import org.jboss.arquillian.test.api.ArquillianResource;
import org.junit.Test;
import org.junit.runner.RunWith;

import java.io.IOException;
import java.net.URL;

import static junit.framework.TestCase.assertFalse;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;


@RunWith(ArquillianConditionalRunner.class)
@RequiresKubernetes
public class HelloWorldTest {

    @Named("hello-world")
    @ArquillianResource
    Service helloWorld;


    @Named("hello-world")
    @PortForward
    @ArquillianResource
    URL url;

    @Test
    public void shouldFindServiceInstance() throws IOException {
        assertNotNull(helloWorld);
        assertNotNull(helloWorld.getSpec());
        assertNotNull(helloWorld.getSpec().getPorts());
        assertFalse(helloWorld.getSpec().getPorts().isEmpty());
    }

    @Test
    public void shouldShowHelloWorld() throws IOException {
        assertNotNull(url);
        OkHttpClient okHttpClient = new OkHttpClient();
        Request request = new Request.Builder().get().url(url).build();
        Response response = okHttpClient.newCall(request).execute();
        assertNotNull(response);
        assertEquals(200, response.code());
        assertTrue(response.body().string().contains("Hello world!"));
    }
}

@@ -1490,24 +1490,146 @@
 l).build();%0A
+%0A        //#641 mentions issues on repeated calls to the portforwarded service.%0A        for (int i = 0; i %3C 5; i++) %7B%0A    
         Resp
@@ -1681,24 +1681,28 @@
 .execute();%0A
+    
         asse
@@ -1726,24 +1726,28 @@
 e);%0A        
+    
 assertEquals
@@ -1766,24 +1766,28 @@
 se.code());%0A
+    
         asse
@@ -1841,20 +1841,30 @@
  world!%22));%0A
+        %7D%0A
     %7D%0A%7D%0A

Access the forwarded port multiple times. (#643)