Skip to content

Commit

Permalink
test: add config as test dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
EddeCCC committed Oct 15, 2024
1 parent dc948e1 commit ea49226
Show file tree
Hide file tree
Showing 18 changed files with 30 additions and 27 deletions.
1 change: 1 addition & 0 deletions inspectit-gepard-agent/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ dependencies {
annotationProcessor deps.autoservice

// All dependencies below are only for tests
testImplementation("rocks.inspectit.gepard:inspectit-gepard-config:${version}")
testImplementation("org.mockito:mockito-core:5.12.0")
testImplementation("org.mockito:mockito-junit-jupiter:5.12.0")
testImplementation("org.awaitility:awaitility:4.2.1")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ public class InspectitAgentExtension implements AgentExtension {
public AgentBuilder extend(AgentBuilder agentBuilder, ConfigProperties config) {
log.info("Starting inspectIT Gepard agent extension ...");



// Append the bootstrap classloader with inspectIT interfaces
BootstrapManager bootstrapManager = BootstrapManager.create();
bootstrapManager.appendToBootstrapClassLoader();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
import org.apache.hc.core5.concurrent.FutureCallback;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import rocks.inspectit.gepard.config.model.InspectitConfiguration;
import rocks.inspectit.gepard.agent.internal.configuration.observer.ConfigurationReceivedSubject;
import rocks.inspectit.gepard.agent.internal.configuration.util.ConfigurationMapper;
import rocks.inspectit.gepard.config.model.InspectitConfiguration;

/** Callback for configuration requests to the configuration server. */
public class HttpConfigurationCallback implements FutureCallback<SimpleHttpResponse> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
import org.slf4j.LoggerFactory;
import rocks.inspectit.gepard.agent.configuration.persistence.file.ConfigurationFileReader;
import rocks.inspectit.gepard.agent.configuration.persistence.file.ConfigurationFileWriter;
import rocks.inspectit.gepard.config.model.InspectitConfiguration;
import rocks.inspectit.gepard.agent.internal.configuration.observer.ConfigurationReceivedEvent;
import rocks.inspectit.gepard.agent.internal.configuration.observer.ConfigurationReceivedObserver;
import rocks.inspectit.gepard.agent.internal.configuration.observer.ConfigurationReceivedSubject;
import rocks.inspectit.gepard.config.model.InspectitConfiguration;

/**
* Responsible for accessing the persisted agent configuration as well as keeping the configuration
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
import java.io.IOException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import rocks.inspectit.gepard.config.model.InspectitConfiguration;
import rocks.inspectit.gepard.agent.internal.configuration.util.ConfigurationMapper;
import rocks.inspectit.gepard.agent.internal.file.FileAccessor;
import rocks.inspectit.gepard.config.model.InspectitConfiguration;

/** Reads the agent configuration persistence file. */
public class ConfigurationFileReader {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
import java.io.IOException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import rocks.inspectit.gepard.config.model.InspectitConfiguration;
import rocks.inspectit.gepard.agent.internal.configuration.util.ConfigurationMapper;
import rocks.inspectit.gepard.agent.internal.file.FileAccessor;
import rocks.inspectit.gepard.config.model.InspectitConfiguration;

/**
* Writes into the agent configuration persistence file. After every configuration update, the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.matcher.ElementMatcher;
import rocks.inspectit.gepard.agent.instrumentation.state.configuration.scope.ScopeResolver;
import rocks.inspectit.gepard.config.model.instrumentation.InstrumentationConfiguration;
import rocks.inspectit.gepard.agent.internal.instrumentation.InstrumentedType;
import rocks.inspectit.gepard.agent.internal.instrumentation.model.ClassInstrumentationConfiguration;
import rocks.inspectit.gepard.agent.internal.instrumentation.model.InstrumentationScope;
import rocks.inspectit.gepard.config.model.instrumentation.InstrumentationConfiguration;

/**
* Utility class to resolve the {@link InstrumentationConfiguration} and determine whether class
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import rocks.inspectit.gepard.config.model.InspectitConfiguration;
import rocks.inspectit.gepard.agent.internal.configuration.observer.ConfigurationReceivedEvent;
import rocks.inspectit.gepard.agent.internal.configuration.observer.ConfigurationReceivedObserver;
import rocks.inspectit.gepard.config.model.InspectitConfiguration;

/**
* When the agent receives a new configuration, it will notify this holder about the new
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
import rocks.inspectit.gepard.agent.instrumentation.state.configuration.InspectitConfigurationHolder;
import rocks.inspectit.gepard.agent.instrumentation.state.configuration.matcher.CustomElementMatchers;
import rocks.inspectit.gepard.agent.instrumentation.state.configuration.matcher.MatcherChainBuilder;
import rocks.inspectit.gepard.agent.internal.instrumentation.model.InstrumentationScope;
import rocks.inspectit.gepard.config.model.instrumentation.InstrumentationConfiguration;
import rocks.inspectit.gepard.config.model.instrumentation.ScopeConfiguration;
import rocks.inspectit.gepard.agent.internal.instrumentation.model.InstrumentationScope;

/**
* This class is used to resolve the {@link ScopeConfiguration} based on the {@link ScopeConfiguration} List, contained in the
* {@link InstrumentationConfiguration}.
* This class is used to resolve the {@link ScopeConfiguration} based on the {@link
* ScopeConfiguration} List, contained in the {@link InstrumentationConfiguration}.
*/
public class ScopeResolver {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
import org.mockito.junit.jupiter.MockitoExtension;
import rocks.inspectit.gepard.agent.configuration.persistence.file.ConfigurationFileReader;
import rocks.inspectit.gepard.agent.configuration.persistence.file.ConfigurationFileWriter;
import rocks.inspectit.gepard.config.model.InspectitConfiguration;
import rocks.inspectit.gepard.config.model.instrumentation.InstrumentationConfiguration;
import rocks.inspectit.gepard.config.model.instrumentation.ScopeConfiguration;
import rocks.inspectit.gepard.agent.internal.configuration.observer.ConfigurationReceivedEvent;
import rocks.inspectit.gepard.agent.internal.configuration.observer.ConfigurationReceivedObserver;
import rocks.inspectit.gepard.agent.internal.configuration.observer.ConfigurationReceivedSubject;
import rocks.inspectit.gepard.config.model.InspectitConfiguration;
import rocks.inspectit.gepard.config.model.instrumentation.InstrumentationConfiguration;
import rocks.inspectit.gepard.config.model.instrumentation.ScopeConfiguration;

@ExtendWith(MockitoExtension.class)
public class ConfigurationPersistenceTest {
Expand Down Expand Up @@ -82,7 +82,8 @@ void newConfigurationNotifiesObservers() {
}

private static InspectitConfiguration createConfiguration() {
ScopeConfiguration scope = new ScopeConfiguration(true, "com.example.Application", Collections.emptyList());
ScopeConfiguration scope =
new ScopeConfiguration(true, "com.example.Application", Collections.emptyList());
InstrumentationConfiguration instrumentationConfiguration =
new InstrumentationConfiguration(List.of(scope));
return new InspectitConfiguration(instrumentationConfiguration);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
import rocks.inspectit.gepard.agent.internal.file.FileAccessor;
import rocks.inspectit.gepard.config.model.InspectitConfiguration;
import rocks.inspectit.gepard.config.model.instrumentation.ScopeConfiguration;
import rocks.inspectit.gepard.agent.internal.file.FileAccessor;

@ExtendWith(MockitoExtension.class)
public class ConfigurationFileReaderTest {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
import rocks.inspectit.gepard.agent.internal.file.FileAccessor;
import rocks.inspectit.gepard.config.model.InspectitConfiguration;
import rocks.inspectit.gepard.config.model.instrumentation.InstrumentationConfiguration;
import rocks.inspectit.gepard.config.model.instrumentation.ScopeConfiguration;
import rocks.inspectit.gepard.agent.internal.file.FileAccessor;

@ExtendWith(MockitoExtension.class)
public class ConfigurationFileWriterTest {
Expand Down Expand Up @@ -49,7 +49,8 @@ void nullIsNotWrittenToFile() throws IOException {
}

private static InspectitConfiguration createConfiguration() {
ScopeConfiguration scope = new ScopeConfiguration(true, "com.example.Application", Collections.emptyList());
ScopeConfiguration scope =
new ScopeConfiguration(true, "com.example.Application", Collections.emptyList());
InstrumentationConfiguration instrumentationConfiguration =
new InstrumentationConfiguration(List.of(scope));
return new InspectitConfiguration(instrumentationConfiguration);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
import rocks.inspectit.gepard.agent.instrumentation.cache.PendingClassesCache;
import rocks.inspectit.gepard.config.model.InspectitConfiguration;
import rocks.inspectit.gepard.agent.internal.configuration.observer.ConfigurationReceivedEvent;
import rocks.inspectit.gepard.config.model.InspectitConfiguration;

@ExtendWith(MockitoExtension.class)
class ConfigurationReceiverTest {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
import rocks.inspectit.gepard.config.model.InspectitConfiguration;
import rocks.inspectit.gepard.config.model.instrumentation.ScopeConfiguration;
import rocks.inspectit.gepard.agent.internal.instrumentation.InstrumentedType;
import rocks.inspectit.gepard.agent.internal.instrumentation.model.ClassInstrumentationConfiguration;
import rocks.inspectit.gepard.config.model.InspectitConfiguration;
import rocks.inspectit.gepard.config.model.instrumentation.ScopeConfiguration;

@ExtendWith(MockitoExtension.class)
class ConfigurationResolverTest {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
import java.util.Collections;
import java.util.List;
import org.junit.jupiter.api.Test;
import rocks.inspectit.gepard.agent.internal.configuration.observer.ConfigurationReceivedEvent;
import rocks.inspectit.gepard.config.model.InspectitConfiguration;
import rocks.inspectit.gepard.config.model.instrumentation.InstrumentationConfiguration;
import rocks.inspectit.gepard.config.model.instrumentation.ScopeConfiguration;
import rocks.inspectit.gepard.agent.internal.configuration.observer.ConfigurationReceivedEvent;

class InspectitConfigurationHolderTest {

Expand All @@ -35,7 +35,8 @@ void configurationIsUpdated() {
}

private InspectitConfiguration createConfiguration() {
ScopeConfiguration scope = new ScopeConfiguration(true, "com.example.Application", Collections.emptyList());
ScopeConfiguration scope =
new ScopeConfiguration(true, "com.example.Application", Collections.emptyList());
InstrumentationConfiguration instrumentationConfiguration =
new InstrumentationConfiguration(List.of(scope));
return new InspectitConfiguration(instrumentationConfiguration);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
import rocks.inspectit.gepard.agent.instrumentation.state.configuration.InspectitConfigurationHolder;
import rocks.inspectit.gepard.agent.internal.instrumentation.model.InstrumentationScope;
import rocks.inspectit.gepard.config.model.InspectitConfiguration;
import rocks.inspectit.gepard.config.model.instrumentation.ScopeConfiguration;
import rocks.inspectit.gepard.agent.internal.instrumentation.model.InstrumentationScope;

@ExtendWith(MockitoExtension.class)
class ScopeResolverTest {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ private static String expectedString() {
}

private static InspectitConfiguration expectedConfig() {
ScopeConfiguration scope = new ScopeConfiguration(true, "com.example.Application", Collections.emptyList());
ScopeConfiguration scope =
new ScopeConfiguration(true, "com.example.Application", Collections.emptyList());
InstrumentationConfiguration instrumentationConfiguration =
new InstrumentationConfiguration(List.of(scope));
return new InspectitConfiguration(instrumentationConfiguration);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import rocks.inspectit.gepard.config.model.InspectitConfiguration;
import rocks.inspectit.gepard.config.model.instrumentation.InstrumentationConfiguration;
import rocks.inspectit.gepard.config.model.instrumentation.ScopeConfiguration;
import rocks.inspectit.gepard.config.model.instrumentation.ScopeConfiguration;

public class InspectitConfigurationUtil {

Expand All @@ -27,7 +26,8 @@ public static InspectitConfiguration createConfiguration(List<ScopeConfiguration
* @param methodNames the method names to be instrumented
* @return the scope with the current class as fqn
*/
public static ScopeConfiguration createScope(boolean enabled, String name, List<String> methodNames) {
public static ScopeConfiguration createScope(
boolean enabled, String name, List<String> methodNames) {
return new ScopeConfiguration(enabled, name, methodNames);
}

Expand Down

0 comments on commit ea49226

Please sign in to comment.