Commit 593c89df authored by Mirko Friedenhagen's avatar Mirko Friedenhagen

`assumeThat` not working as expected, throw an AssertionError when

we do not get an `401 Unauthorized` during `setup`.
parent 2b60bfd1
package org.gitlab.api; package org.gitlab.api;
import org.gitlab.api.models.GitlabUser; import org.gitlab.api.models.GitlabUser;
import static org.hamcrest.CoreMatchers.is;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
...@@ -13,7 +12,6 @@ import java.util.UUID; ...@@ -13,7 +12,6 @@ import java.util.UUID;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assume.assumeNoException; import static org.junit.Assume.assumeNoException;
import static org.junit.Assume.assumeThat;
import java.net.ConnectException; import java.net.ConnectException;
...@@ -34,10 +32,12 @@ public class GitlabAPIT { ...@@ -34,10 +32,12 @@ public class GitlabAPIT {
try { try {
_api.dispatch().with("login", "INVALID").with("password", rand).to("session", GitlabUser.class); _api.dispatch().with("login", "INVALID").with("password", rand).to("session", GitlabUser.class);
} catch (ConnectException e) { } catch (ConnectException e) {
assumeNoException("GITLAB not running on localhost, skipping...", e); assumeNoException("GITLAB not running on '" + TEST_URL + "', skipping...", e);
} catch (IOException e) { } catch (IOException e) {
final String message = e.getMessage(); final String message = e.getMessage();
assumeThat(message, is("{\"message\":\"401 Unauthorized\"}")); if (!message.equals("{\"message\":\"401 Unauthorized\"}")) {
throw new AssertionError("Expected an unauthorized message", e);
}
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment