use of com.github.jamesnetherton.zulip.client.Zulip in project zulip-java-client by jamesnetherton.
the class ZulipIntegrationTestBase method beforeAll.
@BeforeAll
public static void beforeAll() throws ZulipClientException {
File zuliprc = new File("./zuliprc");
assumeTrue(zuliprc.exists() && zuliprc.canRead());
configuration = ZulipConfiguration.fromZuliprc(zuliprc);
boolean zulipAvailable = false;
try {
InetAddress address = InetAddress.getByName(configuration.getZulipUrl().getHost());
zulipAvailable = address.isReachable(5000);
} catch (Exception e) {
// Host not available
}
assumeTrue(zulipAvailable);
zulip = new ThrottledZulip(new Zulip(configuration));
ownUser = zulip.users().getOwnUser().execute();
}
use of com.github.jamesnetherton.zulip.client.Zulip in project zulip-java-client by jamesnetherton.
the class ZulipCommonsHttpClientTest method proxyServerAuthentication.
@Test
public void proxyServerAuthentication() throws Exception {
CountDownLatch latch = new CountDownLatch(3);
FakeServer server = new FakeServer(latch, true);
server.start();
try {
Zulip zulip = new Zulip.Builder().site("http://foo.bar.com").email("test@test.com").apiKey("abc123").proxyUrl("http://localhost:" + server.getPort()).proxyUsername("foo").proxyPassword("bar").build();
zulip.messages().markAllAsRead().execute();
assertTrue(latch.await(5, TimeUnit.SECONDS));
} finally {
server.stop();
}
}
use of com.github.jamesnetherton.zulip.client.Zulip in project zulip-java-client by jamesnetherton.
the class ZulipCommonsHttpClientTest method proxyServer.
@Test
public void proxyServer() throws Exception {
CountDownLatch latch = new CountDownLatch(1);
FakeServer fakeServer = new FakeServer(latch, false);
fakeServer.start();
try {
Zulip zulip = new Zulip.Builder().site("http://foo.bar.com").email("test@test.com").apiKey("abc123").proxyUrl("http://localhost:" + fakeServer.getPort()).build();
zulip.messages().markAllAsRead().execute();
assertTrue(latch.await(5, TimeUnit.SECONDS));
} finally {
fakeServer.stop();
}
}
use of com.github.jamesnetherton.zulip.client.Zulip in project zulip-java-client by jamesnetherton.
the class CustomZulipHttpClientTest method customHttpClientFactory.
@Test
public void customHttpClientFactory() throws Exception {
CountDownLatch latch = new CountDownLatch(1);
Zulip customZulip = new Zulip.Builder().email("test@test.com").apiKey("test-key").site("http://localhost:" + server.port()).httpClientFactory(new ZulipJdkHttpClientFactory(latch)).build();
Map<String, StringValuePattern> params = QueryParams.create().add(GetApiKeyApiRequest.USERNAME, "test@test.com").add(GetApiKeyApiRequest.PASSWORD, "test").get();
stubZulipResponse(POST, "/fetch_api_key", params, "/com/github/jamesnetherton/zulip/client/api/server/getApiKey.json");
String key = customZulip.server().getApiKey("test@test.com", "test").execute();
assertTrue(latch.await(1, TimeUnit.SECONDS));
assertEquals("abc123zxy", key);
}
Aggregations