@Test public void shouldConsumeEventsWithNoSnapshot() throws SQLException, InterruptedException { Testing.Files.delete(DB_HISTORY_PATH);
@Override public void start() throws Exception { // Kafka setup for the example File dataDir = Testing.Files.createTestingDirectory("cluster"); dataDir.deleteOnExit(); kafkaCluster = new KafkaCluster() .usingDirectory(dataDir) .withPorts(2181, 9092) .addBrokers(1) .deleteDataPriorToStartup(true) .startup(); // Deploy the dashboard JsonObject consumerConfig = new JsonObject((Map) kafkaCluster.useTo() .getConsumerProperties("the_group", "the_client", OffsetResetStrategy.LATEST)); vertx.deployVerticle( DashboardVerticle.class.getName(), new DeploymentOptions().setConfig(consumerConfig) ); // Deploy the metrics collector : 3 times JsonObject producerConfig = new JsonObject((Map) kafkaCluster.useTo() .getProducerProperties("the_producer")); vertx.deployVerticle( MetricsVerticle.class.getName(), new DeploymentOptions().setConfig(producerConfig).setInstances(3) ); }
/** * Read the contents of the supplied {@link InputStream}, replace all variables found in the content, and write the * result to a temporary file. * * @param stream the input stream containing zero or more {@link Strings#replaceVariables(String, java.util.function.Function) * variable expressions} * @param variables the variables * @return the temporary file that exists in the data directory * @throws IOException if there is a problem reading the input stream or writing to the temporary file */ protected static File replaceVariables(InputStream stream, AvailableVariables variables) throws IOException { File tmpFile = Testing.Files.createTestingFile(); try (OutputStream ostream = new FileOutputStream(tmpFile)) { IoUtil.readLines(stream, (line) -> { String newLine = Strings.replaceVariables(line, variables::variableForName); try { ostream.write(newLine.getBytes(StandardCharsets.UTF_8)); } catch (IOException e) { throw new RuntimeException("Error writing to file '" + tmpFile + "'", e); } }, StandardCharsets.UTF_8); } return tmpFile; } }
File dataDir = Testing.Files.createTestingDirectory("cluster"); dataDir.deleteOnExit(); KafkaCluster kafkaCluster;
Path dir = Testing.Files.createTestingPath("simple/gen-expected").toAbsolutePath(); Testing.Files.delete(dir);
/** * Read the contents of the supplied {@link InputStream}, replace all variables found in the content, and write the * result to a temporary file. * * @param stream the input stream containing zero or more {@link Strings#replaceVariables(String, java.util.function.Function) * variable expressions} * @param variables the variables * @return the temporary file that exists in the data directory * @throws IOException if there is a problem reading the input stream or writing to the temporary file */ protected static File replaceVariables(InputStream stream, AvailableVariables variables) throws IOException { File tmpFile = Testing.Files.createTestingFile(); try (OutputStream ostream = new FileOutputStream(tmpFile)) { IoUtil.readLines(stream, (line) -> { String newLine = Strings.replaceVariables(line, variables::variableForName); try { ostream.write(newLine.getBytes(StandardCharsets.UTF_8)); } catch (IOException e) { throw new RuntimeException("Error writing to file '" + tmpFile + "'", e); } }, StandardCharsets.UTF_8); } return tmpFile; } }
protected void writeConfigurationFile(Path configFilePath, Properties props) throws IOException { File configFile = Testing.Files.createTestingFile(configFilePath); try (OutputStream ostream = new FileOutputStream(configFile)) { props.store(ostream, "MockConnector configuration"); } }
protected static KafkaCluster kafkaCluster() { if (kafkaCluster != null) { throw new IllegalStateException(); } dataDir = Testing.Files.createTestingDirectory("cluster"); kafkaCluster = new KafkaCluster().usingDirectory(dataDir).withPorts(2181, 9092); return kafkaCluster; }
@Before public void beforeEach() { stopConnector(); DATABASE.createAndInitialize(); initializeConnectorTestFramework(); Testing.Files.delete(DB_HISTORY_PATH); }
@After public void afterEach() { try { stopConnector(); } finally { Testing.Files.delete(DB_HISTORY_PATH); } }
protected Properties readConfiguration(Path configFilePath) throws IOException { File configFile = Testing.Files.createTestingFile(configFilePath); Properties props = new Properties(); try (InputStream ostream = new FileInputStream(configFile)) { props.load(ostream); } return props; }
@Before public void beforeEach() { stopConnector(); databaseDifferences = databaseGeoDifferences(MySQLConnection.forTestDatabase("emptydb").getMySqlVersion()); DATABASE = new UniqueDatabase("geometryit", databaseDifferences.geometryDatabaseName()) .withDbHistoryPath(DB_HISTORY_PATH); DATABASE.createAndInitialize(); initializeConnectorTestFramework(); Testing.Files.delete(DB_HISTORY_PATH); }
@Before public void beforeEach() { Testing.Files.delete(DB_HISTORY_PATH); DATABASE.createAndInitialize(); this.store = KeyValueStore.createForTopicsBeginningWith(DATABASE.getServerName() + "."); this.schemaChanges = new SchemaChangeHistory(DATABASE.getServerName()); }
@Before public void beforeEach() { stopConnector(); DATABASE.createAndInitialize(); initializeConnectorTestFramework(); Testing.Files.delete(DB_HISTORY_PATH); }
@Before public void beforeEach() { stopConnector(); DATABASE.createAndInitialize(Collections.singletonMap("sessionVariables", "sql_mode=''")); initializeConnectorTestFramework(); Testing.Files.delete(DB_HISTORY_PATH); }
@After public void afterEach() { if (context != null) { try { context.shutdown(); } finally { context = null; Testing.Files.delete(DB_HISTORY_PATH); } } }
@Before public void beforeEach() { Testing.Files.delete(DB_HISTORY_PATH); DATABASE.createAndInitialize(); OTHER_DATABASE.createAndInitialize(); completed = new CountDownLatch(1); }
@After public void afterEach() { try { stopConnector(); } finally { Testing.Files.delete(DB_HISTORY_PATH); } }
@Before public void beforeEach() throws Exception { nextConsumedLineNumber = 1; linesAdded = 0; Testing.Files.delete(TEST_FILE_PATH); inputFile = Testing.Files.createTestingFile(TEST_FILE_PATH); // Basic connector configuration; the remaining engine configuration props are set in base class in startup connectorConfig = Configuration.create() .with(FileStreamSourceConnector.FILE_CONFIG, TEST_FILE_PATH) .with(FileStreamSourceConnector.TOPIC_CONFIG, "topicX") .build(); }