Skip to content

Commit

Permalink
Extend default ctor generation to suitable impls of JAX-RS interfaces
Browse files Browse the repository at this point in the history
Relates to: quarkusio#10430
  • Loading branch information
geoand authored and oztimpower committed Jul 4, 2020
1 parent 2f19d07 commit ad7547c
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,10 @@ public void build(
String className = implementor.name().toString();
reflectiveClass.produce(new ReflectiveClassBuildItem(true, true, className));
scannedResources.putIfAbsent(implementor.name(), implementor);

if (!implementor.hasNoArgsConstructor()) {
withoutDefaultCtor.put(implementor.name(), implementor);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package io.quarkus.resteasy.test;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

@Path("/inter")
public interface InterfaceResource {

@Path("/hello")
@GET
@Produces(MediaType.TEXT_PLAIN)
String hello();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package io.quarkus.resteasy.test;

public class InterfaceResourceImpl implements InterfaceResource {

private Service service;

public InterfaceResourceImpl(Service service) {
this.service = service;
}

@Override
public String hello() {
return "hello from impl";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ public class RestEasyDevModeTestCase {
.setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class)
.addClass(PostResource.class)
.addClass(GreetingResource.class)
.addClass(InterfaceResource.class)
.addClass(InterfaceResourceImpl.class)
.addClass(Service.class)
.addAsResource("config-test.properties", "application.properties"));

@Test
Expand Down Expand Up @@ -54,4 +57,11 @@ public void testConfigHotReplacement() {
.statusCode(200)
.body(is("hi from dev mode"));
}

@Test
public void testInterfaceImplementation() {
RestAssured.when().get("/inter/hello").then()
.statusCode(200)
.body(is("hello from impl"));
}
}

0 comments on commit ad7547c

Please sign in to comment.