Skip to content

Commit

Permalink
Merge pull request #493 from pascalgrimaud/fix-existing-eol
Browse files Browse the repository at this point in the history
Fix eol in MainApp
  • Loading branch information
pascalgrimaud authored Jan 6, 2022
2 parents bdf7d17 + 5d7460a commit fa928bb
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 24 deletions.
15 changes: 8 additions & 7 deletions src/main/java/tech/jhipster/lite/JHLiteApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public class JHLiteApp {
private static final Logger log = LoggerFactory.getLogger(JHLiteApp.class);

private static final String SEPARATOR = "----------------------------------------------------------";
protected static final String LF = "\n";

public static void main(String[] args) {
SpringApplication app = new SpringApplication(JHLiteApp.class);
Expand All @@ -31,9 +32,9 @@ private static void logApplicationStartup(Environment env) {
String hostAddress = getHostAddress();

String welcomeMessage = new StringBuilder()
.append("\n")
.append(LF)
.append(SEPARATOR)
.append("\n")
.append(LF)
.append(applicationRunning(env.getProperty("spring.application.name")))
.append(accessUrlLocal(protocol, serverPort, contextPath))
.append(accessUrlExternal(protocol, hostAddress, serverPort, contextPath))
Expand All @@ -46,32 +47,32 @@ private static void logApplicationStartup(Environment env) {
}

public static String applicationRunning(String value) {
return String.format(" Application '%s' is running!", value) + "\n";
return String.format(" Application '%s' is running!", value) + LF;
}

public static String accessUrlLocal(String protocol, String serverPort, String contextPath) {
if (StringUtils.isBlank(serverPort)) {
return "";
}
return String.format(" Local: \t%s://localhost:%s%sswagger-ui.html", protocol, serverPort, contextPath) + "\n";
return String.format(" Local: \t%s://localhost:%s%sswagger-ui.html", protocol, serverPort, contextPath) + LF;
}

public static String accessUrlExternal(String protocol, String hostAddress, String serverPort, String contextPath) {
if (StringUtils.isBlank(serverPort)) {
return "";
}
return String.format(" External: \t%s://%s:%s%sswagger-ui.html", protocol, hostAddress, serverPort, contextPath) + "\n";
return String.format(" External: \t%s://%s:%s%sswagger-ui.html", protocol, hostAddress, serverPort, contextPath) + LF;
}

public static String profile(String profiles) {
return String.format(" Profile(s): \t%s", profiles) + "\n";
return String.format(" Profile(s): \t%s", profiles) + LF;
}

public static String configServer(String configServerStatus) {
if (StringUtils.isBlank(configServerStatus)) {
return "";
}
return "\n" + String.format(" Config Server: %s", configServerStatus) + "\n" + SEPARATOR + "\n";
return LF + String.format(" Config Server: %s", configServerStatus) + LF + SEPARATOR + LF;
}

public static String getProtocol(String value) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public class {{mainClass}}App {
private static final Logger log = LoggerFactory.getLogger({{mainClass}}App.class);

private static final String SEPARATOR = "----------------------------------------------------------";
protected static final String LF = "\n";

public static void main(String[] args) {
SpringApplication app = new SpringApplication({{mainClass}}App.class);
Expand All @@ -31,9 +32,9 @@ public class {{mainClass}}App {
String hostAddress = getHostAddress();
String welcomeMessage = new StringBuilder()
.append("\n")
.append(LF)
.append(SEPARATOR)
.append("\n")
.append(LF)
.append(applicationRunning(env.getProperty("spring.application.name")))
.append(accessUrlLocal(protocol, serverPort, contextPath))
.append(accessUrlExternal(protocol, hostAddress, serverPort, contextPath))
Expand All @@ -46,32 +47,32 @@ public class {{mainClass}}App {
}

public static String applicationRunning(String value) {
return String.format(" Application '%s' is running!", value) + "\n";
return String.format(" Application '%s' is running!", value) + LF;
}

public static String accessUrlLocal(String protocol, String serverPort, String contextPath) {
if (StringUtils.isBlank(serverPort)) {
return "";
}
return String.format(" Local: \t%s://localhost:%s%s", protocol, serverPort, contextPath) + "\n";
return String.format(" Local: \t%s://localhost:%s%s", protocol, serverPort, contextPath) + LF;
}

public static String accessUrlExternal(String protocol, String hostAddress, String serverPort, String contextPath) {
if (StringUtils.isBlank(serverPort)) {
return "";
}
return String.format(" External: \t%s://%s:%s%s", protocol, hostAddress, serverPort, contextPath) + "\n";
return String.format(" External: \t%s://%s:%s%s", protocol, hostAddress, serverPort, contextPath) + LF;
}

public static String profile(String profiles) {
return String.format(" Profile(s): \t%s", profiles) + "\n";
return String.format(" Profile(s): \t%s", profiles) + LF;
}

public static String configServer(String configServerStatus) {
if (StringUtils.isBlank(configServerStatus)) {
return "";
}
return "\n" + String.format(" Config Server: %s", configServerStatus) + "\n" + SEPARATOR + "\n";
return LF + String.format(" Config Server: %s", configServerStatus) + LF + SEPARATOR + LF;
}

public static String getProtocol(String value) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package {{packageName}};

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatCode;
import static {{packageName}}.{{mainClass}}App.LF;

import java.net.InetAddress;
import java.net.UnknownHostException;
Expand All @@ -20,7 +21,7 @@ class {{mainClass}}AppIT {
@Test
void shouldApplicationRunning() {
String result = {{mainClass}}App.applicationRunning("jhlite");
assertThat(result).isEqualTo(" Application 'jhlite' is running!\n");
assertThat(result).isEqualTo(" Application 'jhlite' is running!" + LF);
}

@Test
Expand All @@ -32,13 +33,13 @@ class {{mainClass}}AppIT {
@Test
void shouldAccessUrlLocalWithoutContextPath() {
String result = {{mainClass}}App.accessUrlLocal("http", "8080", "/");
assertThat(result).isEqualTo(" Local: \thttp://localhost:8080/\n");
assertThat(result).isEqualTo(" Local: \thttp://localhost:8080/" + LF);
}

@Test
void shouldAccessUrlLocalWithContextPath() {
String result = {{mainClass}}App.accessUrlLocal("http", "8080", "/lite/");
assertThat(result).isEqualTo(" Local: \thttp://localhost:8080/lite/\n");
assertThat(result).isEqualTo(" Local: \thttp://localhost:8080/lite/" + LF);
}

@Test
Expand All @@ -50,13 +51,13 @@ class {{mainClass}}AppIT {
@Test
void shouldAccessUrlExternalWithoutContextPath() {
String result = {{mainClass}}App.accessUrlExternal("http", "127.0.1.1", "8080", "/");
assertThat(result).isEqualTo(" External: \thttp://127.0.1.1:8080/\n");
assertThat(result).isEqualTo(" External: \thttp://127.0.1.1:8080/" + LF);
}

@Test
void shouldAccessUrlExternalWithContextPath() {
String result = {{mainClass}}App.accessUrlExternal("http", "127.0.1.1", "8080", "/lite/");
assertThat(result).isEqualTo(" External: \thttp://127.0.1.1:8080/lite/\n");
assertThat(result).isEqualTo(" External: \thttp://127.0.1.1:8080/lite/" + LF);
}

@Test
Expand Down
11 changes: 6 additions & 5 deletions src/test/java/tech/jhipster/lite/JHLiteAppIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatCode;
import static tech.jhipster.lite.JHLiteApp.LF;

import java.net.InetAddress;
import java.net.UnknownHostException;
Expand All @@ -20,7 +21,7 @@ void shouldMain() {
@Test
void shouldApplicationRunning() {
String result = JHLiteApp.applicationRunning("jhlite");
assertThat(result).isEqualTo(" Application 'jhlite' is running!\n");
assertThat(result).isEqualTo(" Application 'jhlite' is running!" + LF);
}

@Test
Expand All @@ -32,13 +33,13 @@ void shouldAccessUrlLocalWithoutServerPort() {
@Test
void shouldAccessUrlLocalWithoutContextPath() {
String result = JHLiteApp.accessUrlLocal("http", "8080", "/");
assertThat(result).isEqualTo(" Local: \thttp://localhost:8080/swagger-ui.html\n");
assertThat(result).isEqualTo(" Local: \thttp://localhost:8080/swagger-ui.html" + LF);
}

@Test
void shouldAccessUrlLocalWithContextPath() {
String result = JHLiteApp.accessUrlLocal("http", "8080", "/lite/");
assertThat(result).isEqualTo(" Local: \thttp://localhost:8080/lite/swagger-ui.html\n");
assertThat(result).isEqualTo(" Local: \thttp://localhost:8080/lite/swagger-ui.html" + LF);
}

@Test
Expand All @@ -50,13 +51,13 @@ void shouldAccessUrlExternalWithoutServerPort() {
@Test
void shouldAccessUrlExternalWithoutContextPath() {
String result = JHLiteApp.accessUrlExternal("http", "127.0.1.1", "8080", "/");
assertThat(result).isEqualTo(" External: \thttp://127.0.1.1:8080/swagger-ui.html\n");
assertThat(result).isEqualTo(" External: \thttp://127.0.1.1:8080/swagger-ui.html" + LF);
}

@Test
void shouldAccessUrlExternalWithContextPath() {
String result = JHLiteApp.accessUrlExternal("http", "127.0.1.1", "8080", "/lite/");
assertThat(result).isEqualTo(" External: \thttp://127.0.1.1:8080/lite/swagger-ui.html\n");
assertThat(result).isEqualTo(" External: \thttp://127.0.1.1:8080/lite/swagger-ui.html" + LF);
}

@Test
Expand Down

0 comments on commit fa928bb

Please sign in to comment.