Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions cdc-service/src/main/java/com/xtrmetl/cdc/CdcApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,20 @@
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.kafka.annotation.EnableKafka;

/**
* Starts the standalone mightyETL CDC service with service discovery and Kafka support during CDC bootstrap.
*/
@SpringBootApplication
@EnableDiscoveryClient
@EnableKafka
@org.springframework.boot.context.properties.EnableConfigurationProperties(com.xtrmetl.cdc.config.XtrmetlProperties.class)
public class CdcApplication {

/**
* Launches the CDC service through Spring Boot.
*
* @param args command-line arguments passed to Spring Boot
*/
public static void main(String[] args) {
SpringApplication.run(CdcApplication.class, args);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package com.xtrmetl.cdc;

import org.junit.jupiter.api.Test;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.kafka.annotation.EnableKafka;

import java.io.IOException;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;

import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;

/**
* Verifies the standalone CDC bootstrap contract and its beginner-readable public documentation.
*/
class CdcApplicationContractTest {

@Test
void bootstrapClassKeepsTheRequiredCdcAnnotations() {
assertNotNull(CdcApplication.class.getAnnotation(SpringBootApplication.class));
assertNotNull(CdcApplication.class.getAnnotation(EnableDiscoveryClient.class));
assertNotNull(CdcApplication.class.getAnnotation(EnableKafka.class));
}

@Test
void mainEntryPointRemainsPublicStatic() throws NoSuchMethodException {
Method main = CdcApplication.class.getDeclaredMethod("main", String[].class);

assertTrue(Modifier.isPublic(main.getModifiers()));
assertTrue(Modifier.isStatic(main.getModifiers()));
}

@Test
void publicBootstrapApiHasBeginnerReadableJavadoc() throws IOException {
String source = Files.readString(
Path.of("src/main/java/com/xtrmetl/cdc/CdcApplication.java"),
StandardCharsets.UTF_8
);

assertTrue(source.contains("Starts the standalone mightyETL CDC service"));
assertTrue(source.contains("service discovery and Kafka support during CDC bootstrap"));
assertTrue(source.contains("Launches the CDC service through Spring Boot"));
assertTrue(source.contains("@param args command-line arguments passed to Spring Boot"));
}
}
Loading