@Test public void shouldReturnClassloaderFromContext() throws Exception { final Set<TraceeBackendProvider> contextClassloader = new HashSet<>(); contextClassloader.add(mock(TraceeBackendProvider.class)); BackendProviderResolver resolver = PowerMockito.spy(new BackendProviderResolver()); when(resolver, method(BackendProviderResolver.class, "loadProviders", ClassLoader.class)) .withArguments(BackendProviderResolver.GetClassLoader.fromContext()) .thenReturn(contextClassloader); assertThat(resolver.getBackendProviders(), is(equalTo(contextClassloader))); }
public Set<TraceeBackendProvider> getBackendProviders() { final Map<ClassLoader, Set<TraceeBackendProvider>> cacheCopy = providersPerClassloader; final Set<TraceeBackendProvider> providerFromContextClassLoader = getTraceeProviderFromClassloader(cacheCopy, GetClassLoader.fromContext()); if (!providerFromContextClassLoader.isEmpty()) { return providerFromContextClassLoader; } else { return getTraceeProviderFromClassloader(cacheCopy, GetClassLoader.fromClass(BackendProviderResolver.class)); } }
BackendProviderResolver { public Set<TraceeBackendProvider> getBackendProviders() { final Map<ClassLoader, Set<TraceeBackendProvider>> cacheCopy = providersPerClassloader; final Set<TraceeBackendProvider> providerFromContextClassLoader = getTraceeProviderFromClassloader(cacheCopy, GetClassLoader.fromContext()); if (!providerFromContextClassLoader.isEmpty()) { return providerFromContextClassLoader; } else { return getTraceeProviderFromClassloader(cacheCopy, GetClassLoader.fromClass(BackendProviderResolver.class)); } } }
BackendProviderResolver { public Set<TraceeBackendProvider> getBackendProviders() { final Map<ClassLoader, Set<TraceeBackendProvider>> cacheCopy = providersPerClassloader; final Set<TraceeBackendProvider> providerFromContextClassLoader = getTraceeProviderFromClassloader(cacheCopy, GetClassLoader.fromContext()); if (!providerFromContextClassLoader.isEmpty()) { return providerFromContextClassLoader; } else { return getTraceeProviderFromClassloader(cacheCopy, GetClassLoader.fromClass(BackendProviderResolver.class)); } }  }
BackendProviderResolver { public Set<TraceeBackendProvider> getBackendProviders() { final Map<ClassLoader, Set<TraceeBackendProvider>> cacheCopy = providersPerClassloader; final Set<TraceeBackendProvider> providerFromContextClassLoader = getTraceeProviderFromClassloader(cacheCopy, GetClassLoader.fromContext()); if (!providerFromContextClassLoader.isEmpty()) { return providerFromContextClassLoader; } else { return getTraceeProviderFromClassloader(cacheCopy, GetClassLoader.fromClass(BackendProviderResolver.class)); } }  Set<TraceeBackendProvider> getBackendProviders(); }
BackendProviderResolver { public Set<TraceeBackendProvider> getBackendProviders() { final Map<ClassLoader, Set<TraceeBackendProvider>> cacheCopy = providersPerClassloader; final Set<TraceeBackendProvider> providerFromContextClassLoader = getTraceeProviderFromClassloader(cacheCopy, GetClassLoader.fromContext()); if (!providerFromContextClassLoader.isEmpty()) { return providerFromContextClassLoader; } else { return getTraceeProviderFromClassloader(cacheCopy, GetClassLoader.fromClass(BackendProviderResolver.class)); } }  Set<TraceeBackendProvider> getBackendProviders();  }