Skip to content

Commit

Permalink
quakrus test
Browse files Browse the repository at this point in the history
  • Loading branch information
asingh2295 committed Jul 17, 2023
1 parent b016b35 commit e8140ce
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,14 @@ public class QuarkusUtils {

private QuarkusUtils() {}

public static String extractPort(JavaProject javaProject, 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;
}
}
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 @@ -29,6 +29,8 @@

import static org.eclipse.jkube.kit.common.Configs.asInteger;
import static org.eclipse.jkube.quarkus.QuarkusUtils.QUARKUS_GROUP_ID;
import static org.eclipse.jkube.quarkus.QuarkusUtils.extractPort;
import static org.eclipse.jkube.quarkus.QuarkusUtils.getQuarkusConfiguration;
import static org.eclipse.jkube.quarkus.QuarkusUtils.concatPath;
import static org.eclipse.jkube.quarkus.QuarkusUtils.isStartupEndpointSupported;
import static org.eclipse.jkube.quarkus.QuarkusUtils.resolveCompleteQuarkusHealthRootPath;
Expand Down Expand Up @@ -87,7 +89,8 @@ private Probe discoverQuarkusHealthCheck(int initialDelay, Function<JavaProject,
}
return new ProbeBuilder()
.withNewHttpGet()
.withNewPort(asInteger(getConfig(Config.PORT)))
.withNewPort(asInteger(extractPort(getQuarkusConfiguration(getContext().getProject()),getConfig(Config.PORT))))
//.withNewPort(asInteger(getConfig(Config.PORT)))
.withPath(resolveHealthPath(pathResolver.apply(getContext().getProject())))
.withScheme(getConfig(Config.SCHEME))
.endHttpGet()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public boolean isApplicable(List<ImageConfiguration> configs) {

@Override
protected String getDefaultWebPort() {
return extractPort(getProject(), getQuarkusConfiguration(getProject()), super.getDefaultWebPort());
return extractPort(getQuarkusConfiguration(getProject()), super.getDefaultWebPort());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ void setUp() throws IOException {
@Test
void extractPort_noProfileAndNoPort_shouldReturnDefault() {
// When
final String result = extractPort(javaProject, new Properties(), "80");
final String result = extractPort(new Properties(), "80");
// Then
assertThat(result).isEqualTo("80");
}
Expand All @@ -67,7 +67,7 @@ void extractPort_noProfileAndPort_shouldReturnPort() {
final Properties properties = new Properties();
properties.put("quarkus.http.port", "1337");
// When
final String result = extractPort(javaProject, properties, "80");
final String result = extractPort(properties, "80");
// Then
assertThat(result).isEqualTo("1337");
}
Expand All @@ -79,7 +79,7 @@ void extractPort_inactiveProfileAndPort_shouldReturnPort() {
properties.put("quarkus.http.port", "1337");
properties.put("%dev.quarkus.http.port", "31337");
// When
final String result = extractPort(javaProject, properties, "80");
final String result = extractPort(properties, "80");
// Then
assertThat(result).isEqualTo("1337");
}
Expand All @@ -92,7 +92,7 @@ void extractPort_activeProfileAndPort_shouldReturnProfilePort() {
properties.put("%dev.quarkus.http.port", "31337");
javaProject.getProperties().put("quarkus.profile", "dev");
// When
final String result = extractPort(javaProject, properties, "80");
final String result = extractPort(properties, "80");
// Then
assertThat(result).isEqualTo("31337");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@
# Red Hat, Inc. - initial API and implementation
#

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

0 comments on commit e8140ce

Please sign in to comment.