@@ -19,8 +19,8 @@ public static String getUri() {
1919 try {
2020 return ConfigProvider .getConfig ().getValue ("test.url" , String .class );
2121 } catch (IllegalStateException e ) {
22- //massive hack for dev mode tests, dev mode has not started yet
23- //so we don't have any way to load this correctly from config
22+ // massive hack for dev mode tests, dev mode has not started yet
23+ // so we don't have any way to load this correctly from config
2424 return "http://localhost:8080" ;
2525 }
2626 }
@@ -29,8 +29,8 @@ public static String getManagementUri() {
2929 try {
3030 return ConfigProvider .getConfig ().getValue ("test.management.url" , String .class );
3131 } catch (IllegalStateException e ) {
32- //massive hack for dev mode tests, dev mode has not started yet
33- //so we don't have any way to load this correctly from config
32+ // massive hack for dev mode tests, dev mode has not started yet
33+ // so we don't have any way to load this correctly from config
3434 return "http://localhost:9000" ;
3535 }
3636 }
@@ -59,29 +59,42 @@ public static void inject(Object testCase, List<Function<Class<?>, String>> endp
5959 Map <Class <?>, TestHTTPResourceProvider <?>> providers = getProviders ();
6060 Class <?> c = testCase .getClass ();
6161 while (c != Object .class ) {
62+ TestHTTPEndpoint classEndpointAnnotation = c .getAnnotation (TestHTTPEndpoint .class );
6263 for (Field f : c .getDeclaredFields ()) {
6364 TestHTTPResource resource = f .getAnnotation (TestHTTPResource .class );
64- if (resource != null ) {
65+ TestHTTPEndpoint fieldEndpointAnnotation = f .getAnnotation (TestHTTPEndpoint .class );
66+ if (resource != null || classEndpointAnnotation != null || fieldEndpointAnnotation != null ) {
6567 TestHTTPResourceProvider <?> provider = providers .get (f .getType ());
6668 if (provider == null ) {
6769 throw new RuntimeException (
6870 "Unable to inject TestHTTPResource field " + f + " as no provider exists for the type" );
6971 }
70- String path = resource .value ();
72+ String path = resource != null ? resource .value () : "" ;
7173 String endpointPath = null ;
72- boolean management = resource .management ();
73- TestHTTPEndpoint endpointAnnotation = f .getAnnotation (TestHTTPEndpoint .class );
74- if (endpointAnnotation != null ) {
74+ boolean management = resource != null && resource .management ();
75+ if (fieldEndpointAnnotation != null ) {
7576 for (Function <Class <?>, String > func : endpointProviders ) {
76- endpointPath = func .apply (endpointAnnotation .value ());
77+ endpointPath = func .apply (fieldEndpointAnnotation .value ());
7778 if (endpointPath != null ) {
7879 break ;
7980 }
8081 }
8182 if (endpointPath == null ) {
8283 throw new RuntimeException (
83- "Could not determine the endpoint path for " + endpointAnnotation .value () + " to inject "
84- + f );
84+ "Could not determine the endpoint path for " + fieldEndpointAnnotation .value ()
85+ + " to inject " + f );
86+ }
87+ } else if (classEndpointAnnotation != null ) {
88+ for (Function <Class <?>, String > func : endpointProviders ) {
89+ endpointPath = func .apply (classEndpointAnnotation .value ());
90+ if (endpointPath != null ) {
91+ break ;
92+ }
93+ }
94+ if (endpointPath == null ) {
95+ throw new RuntimeException (
96+ "Could not determine the endpoint path for " + classEndpointAnnotation .value ()
97+ + " to inject " + f );
8598 }
8699 }
87100 if (!path .isEmpty () && endpointPath != null ) {
@@ -94,7 +107,7 @@ public static void inject(Object testCase, List<Function<Class<?>, String>> endp
94107 path = endpointPath ;
95108 }
96109 String val ;
97- if (resource .ssl () || resource .tls ()) {
110+ if (resource != null && ( resource .ssl () || resource .tls () )) {
98111 if (management ) {
99112 if (path .startsWith ("/" )) {
100113 val = getManagementSslUri () + path ;
0 commit comments