//Custom deployment with bad class export will be disabled.
final File tmpBad = VoltProjectBuilder.writeStringToTempFile(withBadCustomExport);
DeploymentType bad_deployment = CatalogUtil.getDeployment(new FileInputStream(tmpBad));
VoltCompiler compiler = new VoltCompiler();
String x[] = {tmpDdl.getAbsolutePath()};
Catalog cat = compiler.compileCatalogFromDDL(x);
long crc = CatalogUtil.compileDeployment(cat, bad_deployment, true, false);
assertTrue("Deployment file failed to parse", crc != -1);
Database db = cat.getClusters().get("cluster").getDatabases().get("database");
org.voltdb.catalog.Connector catconn = db.getConnectors().get("0");
assertNotNull(catconn);
assertFalse(bad_deployment.getExport().isEnabled());
//This is a good deployment with custom class that can be found
final File tmpGood = VoltProjectBuilder.writeStringToTempFile(withGoodCustomExport);
DeploymentType good_deployment = CatalogUtil.getDeployment(new FileInputStream(tmpGood));
Catalog cat2 = compiler.compileCatalogFromDDL(x);
crc = CatalogUtil.compileDeployment(cat2, good_deployment, true, false);
assertTrue("Deployment file failed to parse", crc != -1);
db = cat2.getClusters().get("cluster").getDatabases().get("database");
catconn = db.getConnectors().get("0");
assertNotNull(catconn);
assertTrue(good_deployment.getExport().isEnabled());
assertEquals(good_deployment.getExport().getTarget(), ServerExportEnum.CUSTOM);
assertEquals(good_deployment.getExport().getExportconnectorclass(),
"org.voltdb.exportclient.NoOpTestExportClient");
ConnectorProperty prop = catconn.getConfig().get(ExportDataProcessor.EXPORT_TO_TYPE);
assertEquals(prop.getValue(), "org.voltdb.exportclient.NoOpTestExportClient");
// This is to test previous deployment with builtin export functionality.
final File tmpBuiltin = VoltProjectBuilder.writeStringToTempFile(withBuiltinFileExport);
DeploymentType builtin_deployment = CatalogUtil.getDeployment(new FileInputStream(tmpBuiltin));
Catalog cat3 = compiler.compileCatalogFromDDL(x);
crc = CatalogUtil.compileDeployment(cat3, builtin_deployment, true, false);
assertTrue("Deployment file failed to parse", crc != -1);
db = cat3.getClusters().get("cluster").getDatabases().get("database");
catconn = db.getConnectors().get("0");
assertNotNull(catconn);
assertTrue(builtin_deployment.getExport().isEnabled());
assertEquals(builtin_deployment.getExport().getTarget(), ServerExportEnum.FILE);
prop = catconn.getConfig().get(ExportDataProcessor.EXPORT_TO_TYPE);
assertEquals(prop.getValue(), "org.voltdb.exportclient.ExportToFileClient");
//Check kafka option.
final File tmpKafkaBuiltin = VoltProjectBuilder.writeStringToTempFile(withBuiltinKafkaExport);
DeploymentType builtin_kafkadeployment = CatalogUtil.getDeployment(new FileInputStream(tmpKafkaBuiltin));
Catalog cat4 = compiler.compileCatalogFromDDL(x);
crc = CatalogUtil.compileDeployment(cat4, builtin_kafkadeployment, true, false);
assertTrue("Deployment file failed to parse", crc != -1);
db = cat4.getClusters().get("cluster").getDatabases().get("database");
catconn = db.getConnectors().get("0");
assertNotNull(catconn);
assertTrue(builtin_kafkadeployment.getExport().isEnabled());
assertEquals(builtin_kafkadeployment.getExport().getTarget(), ServerExportEnum.KAFKA);
prop = catconn.getConfig().get(ExportDataProcessor.EXPORT_TO_TYPE);
assertEquals(prop.getValue(), "org.voltdb.exportclient.KafkaExportClient");
// Check RabbitMQ option
final File tmpRabbitMQBuiltin = VoltProjectBuilder.writeStringToTempFile(withBuiltinRabbitMQExport);
DeploymentType builtin_rabbitmqdeployment = CatalogUtil.getDeployment(new FileInputStream(tmpRabbitMQBuiltin));
Catalog cat5 = compiler.compileCatalogFromDDL(x);
crc = CatalogUtil.compileDeployment(cat5, builtin_rabbitmqdeployment, true, false);
assertTrue("Deployment file failed to parse", crc != -1);
db = cat5.getClusters().get("cluster").getDatabases().get("database");
catconn = db.getConnectors().get("0");
assertNotNull(catconn);