use of co.cask.cdap.client.ApplicationClient in project cdap by caskdata.
the class GenerateClientUsageExample method applicationClient.
public void applicationClient() throws Exception {
// Construct the client used to interact with CDAP
ApplicationClient appClient = new ApplicationClient(clientConfig);
// Fetch the list of applications
List<ApplicationRecord> apps = appClient.list(NamespaceId.DEFAULT);
// Deploy an application
File appJarFile = new File("your-app.jar");
appClient.deploy(NamespaceId.DEFAULT, appJarFile);
// Delete an application
appClient.delete(NamespaceId.DEFAULT.app("Purchase"));
// List programs belonging to an application
appClient.listPrograms(NamespaceId.DEFAULT.app("Purchase"));
}
use of co.cask.cdap.client.ApplicationClient in project cdap by caskdata.
the class IntegrationTestBaseTest method testDeployApplicationInNamespace.
@Test
public void testDeployApplicationInNamespace() throws Exception {
NamespaceId namespace = new NamespaceId("Test1");
NamespaceMeta namespaceMeta = new NamespaceMeta.Builder().setName(namespace).build();
getNamespaceClient().create(namespaceMeta);
ClientConfig clientConfig = new ClientConfig.Builder(getClientConfig()).build();
deployApplication(namespace, TestApplication.class);
// Check the default namespaces applications to see whether the application wasn't made in the default namespace
ClientConfig defaultClientConfig = new ClientConfig.Builder(getClientConfig()).build();
Assert.assertEquals(0, new ApplicationClient(defaultClientConfig).list(NamespaceId.DEFAULT).size());
ApplicationClient applicationClient = new ApplicationClient(clientConfig);
Assert.assertEquals(TestApplication.NAME, applicationClient.list(namespace).get(0).getName());
applicationClient.delete(namespace.app(TestApplication.NAME));
Assert.assertEquals(0, new ApplicationClient(clientConfig).list(namespace).size());
}
use of co.cask.cdap.client.ApplicationClient in project cdap by caskdata.
the class IntegrationTestBase method assertNoApps.
private void assertNoApps(NamespaceId namespace) throws Exception {
ApplicationClient applicationClient = getApplicationClient();
List<ApplicationRecord> applicationRecords = applicationClient.list(namespace);
List<String> applicationIds = Lists.newArrayList();
for (ApplicationRecord applicationRecord : applicationRecords) {
applicationIds.add(applicationRecord.getName());
}
Assert.assertTrue("Must have no deployed apps, but found the following apps: " + Joiner.on(", ").join(applicationIds), applicationRecords.isEmpty());
}
Aggregations