Skip to content

Commit

Permalink
test debug
Browse files Browse the repository at this point in the history
Signed-off-by: Ankit Singh <ankit2.singh@samsung.com>
  • Loading branch information
asingh2295 committed Jul 21, 2023
1 parent e8140ce commit d708432
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,6 @@ public class QuarkusUtils {
private QuarkusUtils() {}

public static String extractPort(Properties properties, String defaultValue) {
// final Optional<String> activeProfile = getActiveProfile(javaProject);
// if (activeProfile.isPresent()) {
// final String profilePort = properties.getProperty(String.format("%%%s.%s", activeProfile.get(), QUARKUS_HTTP_PORT));
// if (StringUtils.isNotBlank(profilePort)) {
// return profilePort;
// }
// }
return properties.getProperty(QUARKUS_HTTP_PORT, defaultValue);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,8 @@ private Probe discoverQuarkusHealthCheck(int initialDelay, Function<JavaProject,
return new ProbeBuilder()
.withNewHttpGet()
.withNewPort(asInteger(extractPort(getQuarkusConfiguration(getContext().getProject()),getConfig(Config.PORT))))
//.withNewPort(asInteger(getConfig(Config.PORT)))
.withPath(resolveHealthPath(pathResolver.apply(getContext().getProject())))
.withScheme(getConfig(Config.SCHEME))
.withPath(resolveHealthPath(pathResolver.apply(getContext().getProject())))
.withScheme(getConfig(Config.SCHEME))
.endHttpGet()
.withFailureThreshold(asInteger(getConfig(Config.FAILURE_THRESHOLD)))
.withSuccessThreshold(asInteger(getConfig(Config.SUCCESS_THRESHOLD)))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,47 +54,24 @@ void setUp() throws IOException {
}

@Test
void extractPort_noProfileAndNoPort_shouldReturnDefault() {
// When
final String result = extractPort(new Properties(), "80");
// Then
assertThat(result).isEqualTo("80");
}

@Test
void extractPort_noProfileAndPort_shouldReturnPort() {
void extractPort_whenServerPortPropertyPresent_thenReturnPort() {
// Given
final Properties properties = new Properties();
properties.put("quarkus.http.port", "1337");
// When
final String result = extractPort(properties, "80");
// Then
assertThat(result).isEqualTo("1337");
}

@Test
void extractPort_inactiveProfileAndPort_shouldReturnPort() {
// Given
final Properties properties = new Properties();
properties.put("quarkus.http.port", "1337");
properties.put("%dev.quarkus.http.port", "31337");
Properties properties = new Properties();
properties.put("quarkus.http.port", "8888");
// When
final String result = extractPort(properties, "80");
String result = QuarkusUtils.extractPort(properties, "8080");
// Then
assertThat(result).isEqualTo("1337");
assertThat(result).isEqualTo("8888");
}

@Test
void extractPort_activeProfileAndPort_shouldReturnProfilePort() {
void extractPort_whenServerPortPropertyAbsent_thenReturnDefaultPort() {
// Given
final Properties properties = new Properties();
properties.put("quarkus.http.port", "1337");
properties.put("%dev.quarkus.http.port", "31337");
javaProject.getProperties().put("quarkus.profile", "dev");
Properties properties = new Properties();
// When
final String result = extractPort(properties, "80");
String result = QuarkusUtils.extractPort(properties, "8080");
// Then
assertThat(result).isEqualTo("31337");
assertThat(result).isEqualTo("8080");
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ void withApplicationPropertiesAndProfile_shouldAddConfiguredProfile() throws IOE
.extracting(ImageConfiguration::getBuildConfiguration)
.extracting(BuildConfiguration::getPorts)
.asList()
.containsExactly("31337", "8778", "9779");
.containsExactly("1337", "8778", "9779");
}

private void withNativeBinaryInTarget() throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,4 @@
# Red Hat, Inc. - initial API and implementation
#

%dev.quarkus.http.port=9080
quarkus.http.port=9080
%dev.quarkus.http.port=9080

0 comments on commit d708432

Please sign in to comment.