-
-
Notifications
You must be signed in to change notification settings - Fork 199
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix avaje module #3426
Merged
Merged
Fix avaje module #3426
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
c9c81fd
reproduce ClassCastException issue
kliushnichenko 9b91406
fix ClassCastException issue
kliushnichenko a503150
remove Config (it is already in registry)
kliushnichenko d99b26c
test for @Named
kliushnichenko ebc79c3
polish
kliushnichenko File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
modules/jooby-avaje-inject/src/test/java/io/jooby/avaje/inject/AvajeInjectModuleTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package io.jooby.avaje.inject; | ||
|
||
import io.jooby.avaje.inject.app.TestApp; | ||
import io.jooby.test.JoobyTest; | ||
import okhttp3.OkHttpClient; | ||
import okhttp3.Request; | ||
import okhttp3.Response; | ||
|
||
import java.io.IOException; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
public class AvajeInjectModuleTest { | ||
|
||
static OkHttpClient client = new OkHttpClient(); | ||
|
||
@JoobyTest(TestApp.class) | ||
public void shouldPropagateJoobyServicesToAvajeBeanScope(String serverPath) throws IOException { | ||
Request request = new Request.Builder().url(serverPath + "ping").build(); | ||
|
||
try (Response response = client.newCall(request).execute()) { | ||
assertEquals("test", response.body().string()); | ||
} | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
modules/jooby-avaje-inject/src/test/java/io/jooby/avaje/inject/app/Controller.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package io.jooby.avaje.inject.app; | ||
|
||
import com.fasterxml.jackson.databind.json.JsonMapper; | ||
import com.typesafe.config.Config; | ||
import io.avaje.inject.InjectModule; | ||
import io.jooby.annotation.GET; | ||
import io.jooby.annotation.Path; | ||
import jakarta.inject.Inject; | ||
import jakarta.inject.Named; | ||
import jakarta.inject.Singleton; | ||
|
||
@Singleton | ||
@Path("") | ||
@InjectModule(requires = {JsonMapper.class, Config.class, String.class}) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. never use Avaje Inject. Why do we need this line? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
from https://jooby.io/#dependency-injection-avaje-inject-mvc-routes :) |
||
public class Controller { | ||
|
||
private final JsonMapper jsonMapper; | ||
private final Config config; | ||
private final String env; | ||
|
||
@Inject | ||
public Controller(JsonMapper jsonMapper, Config config, @Named("application.env") String env) { | ||
this.jsonMapper = jsonMapper; | ||
this.config = config; | ||
this.env = env; | ||
} | ||
|
||
@GET | ||
@Path("/ping") | ||
public String ping() { | ||
jsonMapper.version(); | ||
config.isEmpty(); | ||
|
||
return this.env; | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
modules/jooby-avaje-inject/src/test/java/io/jooby/avaje/inject/app/TestApp.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package io.jooby.avaje.inject.app; | ||
|
||
import com.fasterxml.jackson.databind.json.JsonMapper; | ||
import com.typesafe.config.Config; | ||
import io.jooby.Jooby; | ||
import io.jooby.avaje.inject.AvajeInjectModule; | ||
import io.jooby.jackson.JacksonModule; | ||
|
||
public class TestApp extends Jooby { | ||
|
||
{ | ||
install(new JacksonModule()); | ||
install(AvajeInjectModule.of()); | ||
|
||
mvc(Controller.class); | ||
|
||
onStarted(() -> { | ||
JsonMapper jsonMapper = require(JsonMapper.class); | ||
Config config = require(Config.class); | ||
jsonMapper.version(); | ||
config.isEmpty(); | ||
}); | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks