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
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,18 @@
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;

/**
* Starts the standalone mightyETL gateway with service discovery during gateway bootstrap.
*/
@SpringBootApplication
@EnableDiscoveryClient
public class ZuulGatewayApplication {

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

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

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 gateway bootstrap contract and its beginner-readable public documentation.
*/
class ZuulGatewayApplicationContractTest {

@Test
void bootstrapClassKeepsTheRequiredGatewayAnnotations() {
assertNotNull(ZuulGatewayApplication.class.getAnnotation(SpringBootApplication.class));
assertNotNull(ZuulGatewayApplication.class.getAnnotation(EnableDiscoveryClient.class));
}

@Test
void mainEntryPointRemainsPublicStatic() throws NoSuchMethodException {
Method main = ZuulGatewayApplication.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/gateway/ZuulGatewayApplication.java"),
StandardCharsets.UTF_8
);

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