Search in sources :

Example 1 with TDJobList

use of com.treasuredata.client.model.TDJobList in project td-client-java by treasure-data.

the class TestProxyAccess method proxyApiAccess.

@Test
public void proxyApiAccess() {
    TDClient client = TDClient.newBuilder().setProxy(proxyBaseConfig()).build();
    try {
        client.serverStatus();
        List<TDTable> tableList = client.listTables("sample_datasets");
        assertTrue(tableList.size() >= 2);
        TDJobList jobList = client.listJobs();
        assertTrue(jobList.getJobs().size() > 0);
    } finally {
        logger.debug("proxy access count: {}", proxyAccessCount);
        assertEquals(1, proxyAccessCount.get());
    }
}
Also used : TDTable(com.treasuredata.client.model.TDTable) TDJobList(com.treasuredata.client.model.TDJobList) Test(org.junit.Test)

Example 2 with TDJobList

use of com.treasuredata.client.model.TDJobList in project td-client-java by treasure-data.

the class TestSSLProxyAccess method proxyApiAccess.

@Test
public void proxyApiAccess() {
    ProxyConfig.ProxyConfigBuilder proxy = new ProxyConfig.ProxyConfigBuilder();
    proxy.useSSL(true);
    proxy.setHost("localhost");
    proxy.setPort(proxyPort);
    proxy.setUser(PROXY_USER);
    proxy.setPassword(PROXY_PASS);
    TDClient client = TDClient.newBuilder().setProxy(proxy.createProxyConfig()).build();
    try {
        client.serverStatus();
        List<TDTable> tableList = client.listTables("sample_datasets");
        assertTrue(tableList.size() >= 2);
        TDJobList jobList = client.listJobs();
        assertTrue(jobList.getJobs().size() > 0);
    } finally {
        logger.debug("proxy access count: {}", proxyAccessCount);
        assertEquals(1, proxyAccessCount.get());
    }
}
Also used : TDTable(com.treasuredata.client.model.TDTable) TDJobList(com.treasuredata.client.model.TDJobList) Test(org.junit.Test)

Example 3 with TDJobList

use of com.treasuredata.client.model.TDJobList in project td-client-java by treasure-data.

the class TestTDClient method listJobs.

@Test
public void listJobs() throws Exception {
    TDJobList jobs = client.listJobs();
    logger.debug("job list: " + jobs);
    TDJobList jobsInAnIDRange = client.listJobs(34022478, 34022600);
    logger.debug("job list: " + jobsInAnIDRange);
    assertTrue(jobsInAnIDRange.getJobs().size() > 0);
    // Check getters
    Iterable<Method> getters = FluentIterable.from(TDJob.class.getDeclaredMethods()).filter(new Predicate<Method>() {

        @Override
        public boolean apply(Method input) {
            return test(input);
        }

        @Override
        public boolean test(Method input) {
            return input.getName().startsWith("get");
        }
    });
    // Call getters
    for (TDJob job : jobs.getJobs()) {
        for (Method m : getters) {
            m.invoke(job);
        }
    }
}
Also used : TDJob(com.treasuredata.client.model.TDJob) Method(java.lang.reflect.Method) TDJobList(com.treasuredata.client.model.TDJobList) Test(org.junit.Test)

Aggregations

TDJobList (com.treasuredata.client.model.TDJobList)3 Test (org.junit.Test)3 TDTable (com.treasuredata.client.model.TDTable)2 TDJob (com.treasuredata.client.model.TDJob)1 Method (java.lang.reflect.Method)1