Skip to content

Commit

Permalink
Adjust assertion
Browse files Browse the repository at this point in the history
  • Loading branch information
mcruzdev committed Sep 29, 2024
1 parent 90c2a2a commit f8ac776
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.function.Consumer;

import io.quarkus.bootstrap.app.QuarkusBootstrap;
import io.quarkus.builder.BuildChainBuilder;
import io.quarkus.maven.dependency.ArtifactKey;
import io.quarkus.paths.PathCollection;
import io.quarkus.paths.PathList;
Expand Down Expand Up @@ -66,6 +68,7 @@ public class DevModeContext implements Serializable {

private Set<File> processorPaths;
private List<String> processors;
private List<Consumer<BuildChainBuilder>> customizers;

public boolean isLocalProjectDiscovery() {
return localProjectDiscovery;
Expand Down Expand Up @@ -258,6 +261,14 @@ public List<String> getAnnotationProcessors() {
return processors;
}

public List<Consumer<BuildChainBuilder>> getCustomizers() {
return customizers;
}

public void setCustomizers(List<Consumer<BuildChainBuilder>> customizers) {
this.customizers = customizers;
}

public static class ModuleInfo implements Serializable {

private static final long serialVersionUID = -1376678003747618410L;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import java.util.Map;
import java.util.Properties;

import io.quarkus.runner.bootstrap.AugmentActionImpl;
import org.apache.commons.lang3.SystemUtils;
import org.jboss.logging.Logger;

Expand Down Expand Up @@ -128,6 +129,7 @@ public void start() throws Exception {
map.put(DevModeContext.class.getName(), context);
map.put(DevModeType.class.getName(), DevModeType.LOCAL);
curatedApplication = bootstrapBuilder.setTest(context.isTest()).build().bootstrap();

realCloseable = (Closeable) curatedApplication.runInAugmentClassLoader(
context.getAlternateEntryPoint() == null ? IsolatedDevModeMain.class.getName()
: context.getAlternateEntryPoint(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ void shouldConfigureClientNameCorrectly() {
@Test
void shouldConfigureFromRedisClientNameAnnotation() {
Response executed = fromAnnotation.execute(Command.CLIENT, "GETNAME");
Assertions.assertThat(executed).isNull();
Assertions.assertThat(executed).isNotNull();
Assertions.assertThat(executed.toString()).isEqualTo("from-annotation");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
import java.util.logging.LogRecord;
import java.util.stream.Stream;

import io.quarkus.bootstrap.model.PathsCollection;
import io.quarkus.builder.BuildChainBuilder;
import org.jboss.logmanager.Logger;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.exporter.ExplodedExporter;
Expand Down Expand Up @@ -56,6 +58,7 @@
import io.quarkus.test.common.TestConfigUtil;
import io.quarkus.test.common.TestResourceManager;
import io.quarkus.test.common.http.TestHTTPResourceManager;
import org.slf4j.LoggerFactory;

/**
* A test extension for <strong>black-box</strong> testing of Quarkus development mode in extensions.
Expand Down Expand Up @@ -84,6 +87,7 @@ public class QuarkusDevModeTest
private static final Logger rootLogger;
public static final OpenOption[] OPEN_OPTIONS = { StandardOpenOption.SYNC, StandardOpenOption.CREATE,
StandardOpenOption.TRUNCATE_EXISTING, StandardOpenOption.WRITE };
private static final org.slf4j.Logger log = LoggerFactory.getLogger(QuarkusDevModeTest.class);
private Handler[] originalRootLoggerHandlers;

static {
Expand Down Expand Up @@ -118,6 +122,7 @@ public class QuarkusDevModeTest
private final Map<String, String> oldSystemProps = new HashMap<>();
private final Map<String, String> buildSystemProperties = new HashMap<>();
private boolean allowFailedStart = false;
private List<Consumer<BuildChainBuilder>> buildChainCustomizers = new ArrayList<>();

private static final List<CompilationProvider> compilationProviders;

Expand All @@ -129,6 +134,7 @@ public class QuarkusDevModeTest
compilationProviders = Collections.unmodifiableList(providers);
}


public Supplier<JavaArchive> getArchiveProducer() {
return archiveProducer;
}
Expand Down Expand Up @@ -280,6 +286,8 @@ public void close() throws Throwable {
deploymentDir = Files.createTempDirectory("quarkus-dev-mode-test");
testLocation = PathTestHelper.getTestClassesLocation(testClass);

ArrayList<Consumer<BuildChainBuilder>> customizers = new ArrayList<>(buildChainCustomizers);

//TODO: this is a huge hack, at the moment this just guesses the source location
//this can be improved, but as this is for testing extensions it is probably fine for now
String sourcePath = System.getProperty("quarkus.test.source-path");
Expand All @@ -300,6 +308,7 @@ public void close() throws Throwable {
context.getBuildSystemProperties().put("quarkus.banner.enabled", "false");
context.getBuildSystemProperties().put("quarkus.console.disable-input", "true"); //surefire communicates via stdin, we don't want the test to be reading input
context.getBuildSystemProperties().putAll(buildSystemProperties);
context.setCustomizers(customizers);
devModeMain = new DevModeMain(context);
devModeMain.start();
ApplicationStateNotification.waitForApplicationStart();
Expand Down Expand Up @@ -788,6 +797,11 @@ public QuarkusDevModeTest setAllowFailedStart(boolean allowFailedStart) {
return this;
}

public QuarkusDevModeTest addBuildChainCustomizer(Consumer<BuildChainBuilder> customizer) {
this.buildChainCustomizers.add(customizer);
return this;
}

static class ChangeSet {
final String name;
final Function<String, String> mutator;
Expand Down

0 comments on commit f8ac776

Please sign in to comment.