Skip to content

Provide ApplicationContext instead of Config classes #3

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

Merged
merged 3 commits into from
Jan 17, 2017

Conversation

joeyvmason
Copy link
Contributor

Added ability to provide custom ApplicationContext. For Spring testing, made objects that can potentially be shared by multiple tests classes and methods beans.

…g, made objects that can potentially be shared by multiple tests classes and methods beans.
@sapessi
Copy link
Contributor

sapessi commented Jan 16, 2017

In the latest commit I've added the ability to initialize the library with an implementation of WebApplicationContext, would that work?

…ationContext. Added the ability to specify whether or not applicationContext should be refreshed during initialization. This is necessary because if you are using the application context that is automatically generated when running Spring tests, calling refresh() on the application context is not allowed.
@joeyvmason
Copy link
Contributor Author

It's a little more complicated than just adding this. The main issue is that if you are using an applicationContext generated by Spring when running tests, making a call to refresh() will cause the test to fail because refresh() can only be called once.

The other fix here is that the tests were not using the Spring test framework, which I think is important because that's how Spring developers are going to be using this library. By adding that, I was able to catch the refresh issue above. I also made the SpringLambdaContainerHandler a bean because this object needs to be shared by multiple test classes. If you try to initialize two instances of it, it will fail because both instances will try to update the shared applicationContext.

@sapessi
Copy link
Contributor

sapessi commented Jan 17, 2017

I see, makes sense. The only change I would suggest from your last commit is that we don't use the refreshContext boolean as a constructor parameter, instead we create a setter for it. This way, the constructor remains clean and simple with a single parameter and you can call the setter only from your unit tests - the default value for refreshContext is true. What do you think?

Also, can you change the scope of the spring-test dependency to test?

…ApplicationInitializer and SpringLambdacontainerHandler. Added setter for refreshContext. Added Spring test dependencies to test scope
@joeyvmason
Copy link
Contributor Author

Sure makes sense. Just pushed changes for this.

@sapessi sapessi merged commit ef2f145 into aws:spring-support Jan 17, 2017
sapessi pushed a commit that referenced this pull request Mar 2, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants