コード例 #1
0
 private Set<Class<?>> findEndpointClasses(Collection<MvcEndpoint> existing) {
   Set<Class<?>> types = new HashSet<Class<?>>();
   for (MvcEndpoint endpoint : existing) {
     Class<?> type = endpoint.getEndpointType();
     if (type != null) {
       types.add(type);
     }
   }
   return types;
 }
 @Test
 public void endpointsAllListed() throws Exception {
   for (MvcEndpoint endpoint : this.mvcEndpoints.getEndpoints()) {
     String path = endpoint.getPath();
     if ("/actuator".equals(path)) {
       continue;
     }
     path = path.startsWith("/") ? path.substring(1) : path;
     this.mockMvc
         .perform(get("/actuator").accept(MediaType.APPLICATION_JSON))
         .andExpect(status().isOk())
         .andExpect(jsonPath("$._links.%s.href", path).exists());
   }
 }
 @Test
 public void endpointsDoNotHaveLinks() throws Exception {
   for (MvcEndpoint endpoint : this.mvcEndpoints.getEndpoints()) {
     String path = endpoint.getPath();
     if ("/actuator".equals(path)) {
       continue;
     }
     path = path.length() > 0 ? path : "/";
     this.mockMvc
         .perform(get(path).accept(MediaType.APPLICATION_JSON))
         .andExpect(status().isOk())
         .andExpect(jsonPath("$._links").doesNotExist());
   }
 }
 @Test
 public void endpointsEachHaveSelf() throws Exception {
   Set<String> collections = new HashSet<String>(Arrays.asList("/trace", "/beans", "/dump"));
   for (MvcEndpoint endpoint : this.mvcEndpoints.getEndpoints()) {
     String path = endpoint.getPath();
     if (collections.contains(path)) {
       continue;
     }
     path = path.length() > 0 ? path : "/";
     this.mockMvc
         .perform(get(path).accept(MediaType.APPLICATION_JSON))
         .andExpect(status().isOk())
         .andExpect(jsonPath("$._links.self.href").value("http://localhost" + endpoint.getPath()));
   }
 }
コード例 #5
0
 /**
  * Return the path that should be used to map the given {@link MvcEndpoint}.
  *
  * @param endpoint the endpoint to map
  * @return the path to use for the endpoint or {@code null} if no mapping is required
  */
 protected String getPath(MvcEndpoint endpoint) {
   return endpoint.getPath();
 }