Github user sjcorbett commented on a diff in the pull request:
https://github.com/apache/incubator-brooklyn/pull/156#discussion_r17308329
--- Diff:
usage/rest-server/src/test/java/brooklyn/rest/testing/BrooklynRestApiTest.java
---
@@ -81,30 +91,78 @@ public LocationRegistry getLocationRegistry() {
return new
BrooklynRestResourceUtils(getManagementContext()).getLocationRegistry();
}
- @Override
+ private JerseyTest jerseyTest;
+ protected DefaultResourceConfig config = new DefaultResourceConfig();
+
protected final void addResource(Object resource) {
+ Preconditions.checkNotNull(config, "Must run before setUpJersey");
+
+ if (resource instanceof Class)
+ config.getClasses().add((Class<?>)resource);
+ else
+ config.getSingletons().add(resource);
+
+ if (resource instanceof ManagementContextInjectable) {
+
((ManagementContextInjectable)resource).injectManagementContext(getManagementContext());
+ }
+ }
+
+ protected final void addProvider(Class<?> provider) {
+ Preconditions.checkNotNull(config, "Must run before setUpJersey");
+
+ config.getClasses().add(provider);
+ }
+
+ protected void addDefaultResources() {
// seems we have to provide our own injector because the jersey
test framework
// doesn't inject ServletConfig and it all blows up
- addProvider(NullServletConfigProvider.class);
+// addProvider(NullServletConfigProvider.class);
--- End diff --
Delete or explain why it is commented out.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---