Skip to content

Commit

Permalink
Check, that dev-mode is omitted on projects with pom packaging
Browse files Browse the repository at this point in the history
Required for QUARKUS-2757
  • Loading branch information
fedinskiy committed Jan 24, 2023
1 parent b8a56a0 commit 4fd38c7
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,19 @@
import static io.quarkus.test.utils.AwaitilityUtils.untilAsserted;
import static io.quarkus.ts.quarkus.cli.QuarkusCliUtils.defaultWithFixedStream;
import static org.hamcrest.Matchers.is;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.time.Duration;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
Expand All @@ -27,6 +31,7 @@
import org.apache.http.HttpStatus;
import org.apache.maven.model.Model;
import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
import org.awaitility.core.ConditionTimeoutException;
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Tag;
Expand Down Expand Up @@ -264,6 +269,27 @@ public void verifyRestEasyReactiveAndClassicResteasyCollisionUserMsg() {
assertBuildError(buildResult, "io.quarkus:quarkus-resteasy");
}

@Test
public void devModeIgnoresPomPackaging() throws IOException {
QuarkusCliRestService app = cliClient.createApplication("pomApp", defaultWithFixedStream());
{//set packaging to POM
Path pom = getFileFromApplication(app, ROOT_FOLDER, "pom.xml").toPath();
List<String> content = Files.readAllLines(pom);
for (int i = 0; i < content.size(); i++) {
String line = content.get(i);
if (line.endsWith("<artifactId>pomApp</artifactId>")) {
content.set(i, line + "<packaging>pom</packaging>");
break;
}
}
Files.write(pom, content);
}
// Start using DEV mode
assertEquals(Duration.ofSeconds(2), app.getConfiguration().getAsDuration("startup.timeout", null));
assertThrows(ConditionTimeoutException.class, app::start, "That application shouldn't start!");
app.logs().assertContains("Type of the artifact is POM, skipping dev goal");
}

private void assertBuildError(Result result, String expectedError) {
assertTrue(result.getOutput().contains(expectedError), "Unexpected build error message");
}
Expand Down Expand Up @@ -300,7 +326,6 @@ private void assertDockerJavaVersion(File dockerFile, String expectedVersion) {

Assertions.assertTrue(line.contains("openjdk-" + expectedVersion),
DOCKERFILE_JVM + " doesn't contains expected version " + expectedVersion);

} catch (FileNotFoundException e) {
fail(e.getMessage());
}
Expand Down
3 changes: 3 additions & 0 deletions quarkus-cli/src/test/resources/test.properties
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
ts.global.generated-service.enabled=false
#this app is not expected to start, so let's fail right after
ts.pomApp.startup.timeout=PT2s
ts.pomApp.startup.check-poll-interval=PT1s

0 comments on commit 4fd38c7

Please sign in to comment.