use of co.cask.cdap.ToyApp in project cdap by caskdata.
the class LocalApplicationManagerTest method testGoodPipeline.
/**
* Good pipeline with good tests.
*/
@Test
public void testGoodPipeline() throws Exception {
Location deployedJar = AppJarHelper.createDeploymentJar(lf, ToyApp.class);
ArtifactId artifactId = new ArtifactId("toyapp", new ArtifactVersion("1.0.0-SNAPSHOT"), ArtifactScope.USER);
ArtifactDescriptor artifactDescriptor = new ArtifactDescriptor(artifactId, deployedJar);
AppDeploymentInfo info = new AppDeploymentInfo(artifactDescriptor, NamespaceId.DEFAULT, ToyApp.class.getName(), null, null, null);
ApplicationWithPrograms input = AppFabricTestHelper.getLocalManager().deploy(info).get();
Assert.assertEquals(input.getPrograms().iterator().next().getProgramId().getType(), ProgramType.FLOW);
Assert.assertEquals(input.getPrograms().iterator().next().getProgramId().getProgram(), "ToyFlow");
}
use of co.cask.cdap.ToyApp in project cdap by caskdata.
the class ProgramGenerationStageTest method testProgramGenerationForToyApp.
@Test
public void testProgramGenerationForToyApp() throws Exception {
cConf.set(Constants.AppFabric.OUTPUT_DIR, "programs");
LocationFactory lf = new LocalLocationFactory(TEMP_FOLDER.newFolder());
// have to do this since we are not going through the route of create namespace -> deploy application
// in real scenarios, the namespace directory would already be created
Location namespaceLocation = lf.create(DefaultId.APPLICATION.getNamespace());
Locations.mkdirsIfNotExists(namespaceLocation);
LocationFactory jarLf = new LocalLocationFactory(TEMP_FOLDER.newFolder());
Location appArchive = AppJarHelper.createDeploymentJar(jarLf, ToyApp.class);
ApplicationSpecification appSpec = Specifications.from(new ToyApp());
ApplicationSpecificationAdapter adapter = ApplicationSpecificationAdapter.create(new ReflectionSchemaGenerator());
ApplicationSpecification newSpec = adapter.fromJson(adapter.toJson(appSpec));
ProgramGenerationStage pgmStage = new ProgramGenerationStage();
// Can do better here - fixed right now to run the test.
pgmStage.process(new StageContext(Object.class));
pgmStage.process(new ApplicationDeployable(NamespaceId.DEFAULT.artifact("ToyApp", "1.0"), appArchive, DefaultId.APPLICATION, newSpec, null, ApplicationDeployScope.USER));
Assert.assertTrue(true);
}
use of co.cask.cdap.ToyApp in project cdap by caskdata.
the class SimpleQueueSpecificationGeneratorTest method testQueueSpecificationGenWithToyApp.
@Test
public void testQueueSpecificationGenWithToyApp() throws Exception {
ApplicationSpecification appSpec = Specifications.from(new ToyApp());
ApplicationSpecificationAdapter adapter = ApplicationSpecificationAdapter.create(new ReflectionSchemaGenerator());
ApplicationSpecification newSpec = adapter.fromJson(adapter.toJson(appSpec));
QueueSpecificationGenerator generator = new SimpleQueueSpecificationGenerator(NamespaceId.DEFAULT.app(newSpec.getName()));
table = generator.create(newSpec.getFlows().values().iterator().next());
dumpConnectionQueue(table);
// Stream X
Assert.assertTrue(containsQueue(get(FlowletConnection.Type.STREAM, "X", "A"), String.format("stream:///%s/X", TEST_NAMESPACE_ID)));
Assert.assertTrue(containsQueue(get(FlowletConnection.Type.STREAM, "Y", "B"), String.format("stream:///%s/Y", TEST_NAMESPACE_ID)));
// Node A
Assert.assertTrue(containsQueue(get(FlowletConnection.Type.FLOWLET, "A", "E"), String.format("queue:///%s/ToyApp/ToyFlow/A/out1", Id.Namespace.DEFAULT.getId())));
Assert.assertTrue(containsQueue(get(FlowletConnection.Type.FLOWLET, "A", "C"), String.format("queue:///%s/ToyApp/ToyFlow/A/queue", Id.Namespace.DEFAULT.getId())));
// Node B
Assert.assertTrue(containsQueue(get(FlowletConnection.Type.FLOWLET, "B", "E"), String.format("queue:///%s/ToyApp/ToyFlow/B/queue", Id.Namespace.DEFAULT.getId())));
// Node C
Assert.assertTrue(containsQueue(get(FlowletConnection.Type.FLOWLET, "C", "D"), String.format("queue:///%s/ToyApp/ToyFlow/C/c1", Id.Namespace.DEFAULT.getId())));
Assert.assertTrue(containsQueue(get(FlowletConnection.Type.FLOWLET, "C", "F"), String.format("queue:///%s/ToyApp/ToyFlow/C/c2", Id.Namespace.DEFAULT.getId())));
// Node D
Assert.assertTrue(containsQueue(get(FlowletConnection.Type.FLOWLET, "D", "G"), String.format("queue:///%s/ToyApp/ToyFlow/D/d1", Id.Namespace.DEFAULT.getId())));
// Node E
Assert.assertTrue(containsQueue(get(FlowletConnection.Type.FLOWLET, "E", "G"), String.format("queue:///%s/ToyApp/ToyFlow/E/queue", Id.Namespace.DEFAULT.getId())));
// Node F
Assert.assertTrue(containsQueue(get(FlowletConnection.Type.FLOWLET, "F", "G"), String.format("queue:///%s/ToyApp/ToyFlow/F/f1", Id.Namespace.DEFAULT.getId())));
}
use of co.cask.cdap.ToyApp in project cdap by caskdata.
the class DefaultStoreTest method testLoadingProgram.
@Test
public void testLoadingProgram() throws Exception {
ApplicationSpecification appSpec = Specifications.from(new ToyApp());
ApplicationId appId = NamespaceId.DEFAULT.app(appSpec.getName());
store.addApplication(appId, appSpec);
ProgramDescriptor descriptor = store.loadProgram(appId.flow("ToyFlow"));
Assert.assertNotNull(descriptor);
FlowSpecification flowSpec = descriptor.getSpecification();
Assert.assertEquals("ToyFlow", flowSpec.getName());
}
Aggregations