package com.airhacks.breakr;

import static com.airhacks.rulz.jaxrsclient.HttpMatchers.successful;
import com.airhacks.rulz.jaxrsclient.JAXRSClientProvider;
import javax.ws.rs.client.WebTarget;
import javax.ws.rs.core.Response;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.startsWith;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import org.junit.Rule;
import org.junit.Test;

/**
 *
 * @author airhacks.com
 */
public class BreakrIT {

    @Rule
    public JAXRSClientProvider provider = JAXRSClientProvider.buildWithURI("http://localhost:8080/breakr-st/resources/tests");

    @Test
    public void timeout() {
        WebTarget target = provider.target();
        Response response = target.
                path("slow").
                path("5").
                request().
                get(Response.class);
        assertThat(response, successful());
        String result = response.readEntity(String.class);
        assertTrue(result.isEmpty());

        //reset
        target.request().delete();
        result = target.
                path("slow").
                path("2").
                request().
                get(String.class);
        assertThat(result, startsWith("Slow"));
    }

    @Test
    public void brittle() {
        WebTarget target = provider.target();
        Response response = target.
                path("brittle").
                path("5").
                request().
                get(Response.class);
        assertThat(response, successful());
        String result = response.readEntity(String.class);
        assertThat(result, is("+"));
    }

}

@@ -1050,43 +1050,419 @@
 eset
-%0A        target.request().delete();
+ of other service shouldn't have any effect%0A        target.path(%22brittle%22).%0A                request().%0A                delete();%0A%0A        result = target.%0A                path(%22slow%22).%0A                path(%221%22).%0A                request().%0A                get(String.class);%0A        assertTrue(result.isEmpty());%0A%0A        //reset%0A        target.path(%22slow%22).%0A                request().%0A                delete();%0A
 %0A   

Reset of "slow" tested