Skip to content

Commit

Permalink
Merge pull request #41934 from gsmet/3.12.3-backports-1
Browse files Browse the repository at this point in the history
[3.12] 3.12.3 backports 1
  • Loading branch information
gsmet authored Jul 17, 2024
2 parents 5c7542e + d4b869b commit 35a1b3a
Show file tree
Hide file tree
Showing 36 changed files with 884 additions and 130 deletions.
2 changes: 1 addition & 1 deletion .mvn/extensions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<extension>
<groupId>com.gradle</groupId>
<artifactId>quarkus-build-caching-extension</artifactId>
<version>1.2</version>
<version>1.6</version>
</extension>
<extension>
<groupId>io.quarkus.develocity</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -788,6 +788,7 @@ public NativeImageInvokerInfo build() {
* control its actual inclusion which will depend on the usual analysis.
*/
nativeImageArgs.add("-J--add-exports=java.security.jgss/sun.security.krb5=ALL-UNNAMED");
nativeImageArgs.add("-J--add-exports=java.security.jgss/sun.security.jgss=ALL-UNNAMED");

//address https://github.com/quarkusio/quarkus-quickstarts/issues/993
nativeImageArgs.add("-J--add-opens=java.base/java.text=ALL-UNNAMED");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,7 @@ private void queueConditionalDependency(ExtensionDependency<?> extension, Depend
private Configuration createConditionalDependenciesConfiguration(Project project, Dependency conditionalDep) {
// previously we used a detached configuration here but apparently extendsFrom(enforcedPlatforms)
// wouldn't actually enforce platforms on a detached configuration
final String name = conditionalDep.getGroup() + ":" + conditionalDep.getName() + ":" + conditionalDep.getVersion()
+ "Configuration";
var name = getConditionalConfigurationName(conditionalDep);
var config = project.getConfigurations().findByName(name);
if (config == null) {
project.getConfigurations().register(name, configuration -> {
Expand All @@ -184,6 +183,31 @@ private Configuration createConditionalDependenciesConfiguration(Project project
return config;
}

private static String getConditionalConfigurationName(Dependency conditionalDep) {
var name = new StringBuilder().append("quarkusConditional");
appendCapitalized(name, conditionalDep.getGroup());
appendCapitalized(name, conditionalDep.getName());
appendCapitalized(name, conditionalDep.getVersion());
return name.append("Configuration").toString();
}

private static void appendCapitalized(StringBuilder sb, String part) {
if (part != null && !part.isEmpty()) {
boolean toUpperCase = true;
for (int i = 0; i < part.length(); ++i) {
var c = part.charAt(i);
if (toUpperCase) {
sb.append(Character.toUpperCase(c));
toUpperCase = false;
} else if (c == '.' || c == '-') {
toUpperCase = true;
} else {
sb.append(c);
}
}
}
}

private void enableConditionalDependency(ModuleVersionIdentifier dependency) {
final Set<ExtensionDependency<?>> extensions = featureVariants.remove(getFeatureKey(dependency));
if (extensions == null) {
Expand Down
5 changes: 3 additions & 2 deletions docs/src/main/asciidoc/rest.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -1420,10 +1420,11 @@ public class Person {
@SecureField(rolesAllowed = "${role:admin}") <1>
private String address;
public Person(Long id, String first, String last) {
public Person(Long id, String first, String last, String address) {
this.id = id;
this.first = first;
this.last = last;
this.address = address;
}
public Long getId() {
Expand Down Expand Up @@ -1466,7 +1467,7 @@ import jakarta.ws.rs.Produces;
import jakarta.ws.rs.core.Response;
@Path("person")
public class Person {
public class PersonResource {
@Path("{id}")
@GET
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -363,8 +363,7 @@ import io.quarkus.runtime.StartupEvent;
import io.smallrye.mutiny.Uni;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.enterprise.event.Observes;
import jakarta.i
nject.Inject;
import jakarta.inject.Inject;
@ApplicationScoped
public class OidcClientCreator {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package io.quarkus.amazon.lambda.deployment.testing;

import java.util.ArrayList;
import java.util.List;

import com.amazonaws.services.lambda.runtime.Context;
import com.amazonaws.services.lambda.runtime.RequestHandler;

import io.quarkus.amazon.lambda.deployment.testing.model.InputPerson;
import io.quarkus.amazon.lambda.deployment.testing.model.OutputPerson;

public abstract class AbstractInputCollectionOutputCollection implements RequestHandler<List<InputPerson>, List<OutputPerson>> {

@Override
public List<OutputPerson> handleRequest(List<InputPerson> inputPeronList, Context context) {
List<OutputPerson> personList = new ArrayList<>();
inputPeronList.forEach(person -> personList.add(new OutputPerson(person.getName())));
return personList;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package io.quarkus.amazon.lambda.deployment.testing;

public class AbstractInputCollectionOutputCollectionLambdaImpl extends AbstractInputCollectionOutputCollection {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package io.quarkus.amazon.lambda.deployment.testing;

import static io.restassured.RestAssured.given;
import static org.hamcrest.CoreMatchers.hasItem;
import static org.hamcrest.CoreMatchers.not;
import static org.hamcrest.Matchers.hasEntry;

import java.util.ArrayList;
import java.util.List;

import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;

import io.quarkus.amazon.lambda.deployment.testing.model.InputPerson;
import io.quarkus.amazon.lambda.deployment.testing.model.OutputPerson;
import io.quarkus.test.QuarkusUnitTest;

public class AbstractInputCollectionOutputCollectionLambdaImplTest {

@RegisterExtension
static final QuarkusUnitTest test = new QuarkusUnitTest().setArchiveProducer(() -> ShrinkWrap
.create(JavaArchive.class)
.addClasses(AbstractInputCollectionOutputCollectionLambdaImpl.class, AbstractInputCollectionOutputCollection.class,
InputPerson.class, OutputPerson.class));

@Test
void abstractRequestHandler_InputCollectionInputPerson_OutputCollectionOutputPerson() {

List<InputPerson> personList = new ArrayList<>();
personList.add(new InputPerson("Chris"));
personList.add(new InputPerson("Fred"));

given()
.body(personList)
.when()
.post()
.then()
.statusCode(200)
.body("", hasItem(hasEntry("outputname", "Chris"))) // OutputPerson serializes name with key outputname
.body("", hasItem(hasEntry("outputname", "Fred")))
.body("", not(hasItem(hasEntry("name", "Chris")))) // make sure that there is no key name
.body("", not(hasItem(hasEntry("name", "Fred"))));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
import com.amazonaws.services.lambda.runtime.Context;
import com.amazonaws.services.lambda.runtime.RequestHandler;

public class GreetingLambda implements RequestHandler<Person, String> {
import io.quarkus.amazon.lambda.deployment.testing.model.InputPerson;

public class GreetingLambda implements RequestHandler<InputPerson, String> {

@Override
public String handleRequest(Person input, Context context) {
public String handleRequest(InputPerson input, Context context) {
return "Hey " + input.getName();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package io.quarkus.amazon.lambda.deployment.testing;

import static io.restassured.RestAssured.given;
import static org.hamcrest.CoreMatchers.containsString;

import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;

import io.quarkus.amazon.lambda.deployment.testing.model.InputPerson;
import io.quarkus.test.QuarkusUnitTest;

class GreetingLambdaTest {

@RegisterExtension
static final QuarkusUnitTest test = new QuarkusUnitTest().setArchiveProducer(() -> ShrinkWrap
.create(JavaArchive.class)
.addClasses(GreetingLambda.class, InputPerson.class));

@Test
public void requestHandler_InputPerson_OutputString() throws Exception {
// you test your lambdas by invoking on http://localhost:8081
// this works in dev mode too

InputPerson in = new InputPerson("Stu");
given()
.contentType("application/json")
.accept("application/json")
.body(in)
.when()
.post()
.then()
.statusCode(200)
.body(containsString("Hey Stu"));
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package io.quarkus.amazon.lambda.deployment.testing;

import java.util.ArrayList;
import java.util.List;

import com.amazonaws.services.lambda.runtime.Context;
import com.amazonaws.services.lambda.runtime.RequestHandler;

import io.quarkus.amazon.lambda.deployment.testing.model.InputPerson;
import io.quarkus.amazon.lambda.deployment.testing.model.OutputPerson;

public class InputCollectionOutputCollectionLambda implements RequestHandler<List<InputPerson>, List<OutputPerson>> {

@Override
public List<OutputPerson> handleRequest(List<InputPerson> people, Context context) {

List<OutputPerson> outputPeople = new ArrayList<>();
people.forEach((person) -> {
outputPeople.add(new OutputPerson(person.getName()));
});

return outputPeople;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package io.quarkus.amazon.lambda.deployment.testing;

import static io.restassured.RestAssured.given;
import static org.hamcrest.CoreMatchers.hasItem;
import static org.hamcrest.CoreMatchers.not;
import static org.hamcrest.Matchers.hasEntry;

import java.util.ArrayList;
import java.util.List;

import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;

import io.quarkus.amazon.lambda.deployment.testing.model.InputPerson;
import io.quarkus.amazon.lambda.deployment.testing.model.OutputPerson;
import io.quarkus.test.QuarkusUnitTest;

public class InputCollectionOutputCollectionLambdaTest {

@RegisterExtension
static final QuarkusUnitTest test = new QuarkusUnitTest().setArchiveProducer(() -> ShrinkWrap
.create(JavaArchive.class)
.addClasses(InputCollectionOutputCollectionLambda.class, InputPerson.class, OutputPerson.class));

@Test
void requestHandler_InputCollectionInputPerson_OutputCollectionOutputPerson() {

List<InputPerson> personList = new ArrayList<>();
personList.add(new InputPerson("Chris"));
personList.add(new InputPerson("Fred"));

given()
.body(personList)
.when()
.post()
.then()
.statusCode(200)
.body("", hasItem(hasEntry("outputname", "Chris"))) // OutputPerson serializes name with key outputname
.body("", hasItem(hasEntry("outputname", "Fred")))
.body("", not(hasItem(hasEntry("name", "Chris")))) // make sure that there is no key name
.body("", not(hasItem(hasEntry("name", "Fred"))));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
import org.junit.jupiter.api.RepeatedTest;
import org.junit.jupiter.api.extension.RegisterExtension;

import io.quarkus.amazon.lambda.deployment.testing.model.InputPerson;
import io.quarkus.amazon.lambda.deployment.testing.model.OutputPerson;
import io.quarkus.test.ContinuousTestingTestUtils;
import io.quarkus.test.QuarkusDevModeTest;

Expand All @@ -21,7 +23,7 @@ public class LambdaDevServicesContinuousTestingTestCase {
@Override
public JavaArchive get() {
return ShrinkWrap.create(JavaArchive.class)
.addClasses(GreetingLambda.class, Person.class)
.addClasses(GreetingLambda.class, InputPerson.class, OutputPerson.class)
.addAsResource(
new StringAsset(ContinuousTestingTestUtils.appProperties(
"quarkus.log.category.\"io.quarkus.amazon.lambda.runtime\".level=DEBUG")),
Expand All @@ -30,7 +32,7 @@ public JavaArchive get() {
}).setTestArchiveProducer(new Supplier<>() {
@Override
public JavaArchive get() {
return ShrinkWrap.create(JavaArchive.class).addClass(LambdaHandlerET.class);
return ShrinkWrap.create(JavaArchive.class).addClass(GreetingLambdaTest.class);
}
});

Expand All @@ -45,7 +47,7 @@ public void testLambda() throws Exception {
result = utils.waitForNextCompletion();
Assertions.assertEquals(0, result.getTotalTestsPassed());
Assertions.assertEquals(1, result.getTotalTestsFailed());
test.modifyTestSourceFile(LambdaHandlerET.class, s -> s.replace("Hey", "Yo"));
test.modifyTestSourceFile(GreetingLambdaTest.class, s -> s.replace("Hey", "Yo"));
result = utils.waitForNextCompletion();
Assertions.assertEquals(1, result.getTotalTestsPassed());
Assertions.assertEquals(0, result.getTotalTestsFailed());
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package io.quarkus.amazon.lambda.deployment.testing.model;

public class InputPerson {

public InputPerson() {
}

public InputPerson(String name) {
this.name = name;
}

private String name;

public String getName() {
return name;
}

public InputPerson setName(String name) {
this.name = name;
return this;
}
}
Loading

0 comments on commit 35a1b3a

Please sign in to comment.