diff --git a/newrelic-agent/src/test/java/com/newrelic/agent/attributes/AgentAttributeSenderTest.java b/newrelic-agent/src/test/java/com/newrelic/agent/attributes/AgentAttributeSenderTest.java index c5485b84bd..d2e23f0b2a 100644 --- a/newrelic-agent/src/test/java/com/newrelic/agent/attributes/AgentAttributeSenderTest.java +++ b/newrelic-agent/src/test/java/com/newrelic/agent/attributes/AgentAttributeSenderTest.java @@ -19,9 +19,11 @@ import com.newrelic.agent.tracers.servlet.MockHttpRequest; import com.newrelic.agent.tracers.servlet.MockHttpResponse; import com.newrelic.api.agent.NewRelicApiImplementation; +import com.newrelic.test.marker.RequiresFork; import org.junit.Assert; import org.junit.Before; import org.junit.Test; +import org.junit.experimental.categories.Category; import java.math.BigDecimal; import java.math.BigInteger; @@ -33,6 +35,7 @@ import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicLong; +@Category(RequiresFork.class) public class AgentAttributeSenderTest { private static final String APP_NAME = "NAME"; diff --git a/newrelic-agent/src/test/java/com/newrelic/agent/profile/v2/TransactionProfileTest.java b/newrelic-agent/src/test/java/com/newrelic/agent/profile/v2/TransactionProfileTest.java index f3b2bbe75b..bcf309c3bd 100644 --- a/newrelic-agent/src/test/java/com/newrelic/agent/profile/v2/TransactionProfileTest.java +++ b/newrelic-agent/src/test/java/com/newrelic/agent/profile/v2/TransactionProfileTest.java @@ -13,8 +13,10 @@ import com.newrelic.agent.threads.ThreadNames; import com.newrelic.agent.tracers.ClassMethodSignature; import com.newrelic.agent.tracers.Tracer; +import com.newrelic.test.marker.RequiresFork; import org.junit.Assert; import org.junit.Test; +import org.junit.experimental.categories.Category; import org.mockito.Mockito; import java.io.IOException; @@ -22,6 +24,7 @@ import java.util.Arrays; import java.util.HashSet; +@Category(RequiresFork.class) public class TransactionProfileTest { TransactionProfile target; diff --git a/newrelic-agent/src/test/java/com/newrelic/agent/service/analytics/InsightsServiceImplTest.java b/newrelic-agent/src/test/java/com/newrelic/agent/service/analytics/InsightsServiceImplTest.java index e5bab9f25f..0a1d4e8d87 100644 --- a/newrelic-agent/src/test/java/com/newrelic/agent/service/analytics/InsightsServiceImplTest.java +++ b/newrelic-agent/src/test/java/com/newrelic/agent/service/analytics/InsightsServiceImplTest.java @@ -31,8 +31,10 @@ import com.newrelic.agent.stats.StatsEngine; import com.newrelic.agent.stats.StatsService; import com.newrelic.agent.tracing.DistributedTraceServiceImpl; +import com.newrelic.test.marker.RequiresFork; import org.junit.Assert; import org.junit.Test; +import org.junit.experimental.categories.Category; import org.mockito.Mockito; import java.io.ByteArrayInputStream; @@ -51,6 +53,7 @@ import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.spy; +@Category(RequiresFork.class) public class InsightsServiceImplTest { private static final String appName = "Dude"; diff --git a/newrelic-agent/src/test/java/com/newrelic/agent/service/async/AsyncTransactionServiceTest.java b/newrelic-agent/src/test/java/com/newrelic/agent/service/async/AsyncTransactionServiceTest.java index 7718af1aac..6be6627ee7 100644 --- a/newrelic-agent/src/test/java/com/newrelic/agent/service/async/AsyncTransactionServiceTest.java +++ b/newrelic-agent/src/test/java/com/newrelic/agent/service/async/AsyncTransactionServiceTest.java @@ -13,13 +13,16 @@ import com.newrelic.agent.config.AgentConfigImpl; import com.newrelic.agent.config.TransactionTracerConfigImpl; import com.newrelic.agent.service.ServiceFactory; +import com.newrelic.test.marker.RequiresFork; import org.junit.Test; +import org.junit.experimental.categories.Category; import java.util.HashMap; import java.util.Map; import static org.junit.Assert.*; +@Category(RequiresFork.class) // Token Timeout is stored as a static and will not get the new value from the test if this is not forked public class AsyncTransactionServiceTest { @Test(timeout = 90000) diff --git a/newrelic-agent/src/test/java/com/newrelic/agent/tracing/W3CTraceContextCrossAgentTest.java b/newrelic-agent/src/test/java/com/newrelic/agent/tracing/W3CTraceContextCrossAgentTest.java index e41a758337..ff89ebe788 100644 --- a/newrelic-agent/src/test/java/com/newrelic/agent/tracing/W3CTraceContextCrossAgentTest.java +++ b/newrelic-agent/src/test/java/com/newrelic/agent/tracing/W3CTraceContextCrossAgentTest.java @@ -33,6 +33,7 @@ import com.newrelic.agent.tracers.Tracer; import com.newrelic.agent.tracers.servlet.MockHttpRequest; import com.newrelic.agent.tracers.servlet.MockHttpResponse; +import com.newrelic.test.marker.RequiresFork; import org.json.simple.JSONArray; import org.json.simple.JSONObject; import org.json.simple.parser.JSONParser; @@ -40,6 +41,7 @@ import org.junit.After; import org.junit.Before; import org.junit.Test; +import org.junit.experimental.categories.Category; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import org.mockito.Mockito; @@ -54,6 +56,7 @@ import static org.junit.Assert.*; import static org.mockito.Mockito.when; +@Category(RequiresFork.class) @RunWith(Parameterized.class) public class W3CTraceContextCrossAgentTest { private MockServiceManager serviceManager; diff --git a/newrelic-agent/src/test/java/com/newrelic/agent/transaction/AsyncTransactionTest.java b/newrelic-agent/src/test/java/com/newrelic/agent/transaction/AsyncTransactionTest.java index cdc3c978a8..66c25ce0d9 100644 --- a/newrelic-agent/src/test/java/com/newrelic/agent/transaction/AsyncTransactionTest.java +++ b/newrelic-agent/src/test/java/com/newrelic/agent/transaction/AsyncTransactionTest.java @@ -20,17 +20,20 @@ import com.newrelic.agent.tracers.servlet.BasicRequestRootTracer; import com.newrelic.agent.tracers.servlet.MockHttpRequest; import com.newrelic.agent.tracers.servlet.MockHttpResponse; +import com.newrelic.test.marker.RequiresFork; import org.junit.After; import org.junit.Assert; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; +import org.junit.experimental.categories.Category; import org.objectweb.asm.Opcodes; import java.util.HashMap; import java.util.List; import java.util.Map; +@Category(RequiresFork.class) public class AsyncTransactionTest implements TransactionListener { private TransactionData data; diff --git a/newrelic-agent/src/test/java/com/newrelic/agent/transport/DataSenderImplTest.java b/newrelic-agent/src/test/java/com/newrelic/agent/transport/DataSenderImplTest.java index 49ae1b3576..ef55586c18 100644 --- a/newrelic-agent/src/test/java/com/newrelic/agent/transport/DataSenderImplTest.java +++ b/newrelic-agent/src/test/java/com/newrelic/agent/transport/DataSenderImplTest.java @@ -484,13 +484,15 @@ private void assertMetricWasRecorded(String expectedMetricName) { break; } String methodName = invocation.getMethod().getName(); - Object rawArgument = invocation.getRawArguments()[0]; - if (rawArgument instanceof IncrementCounter) { - String metricName = invocation.getArgument(0).getName(); - found = methodName.equals("doStatsWork") && metricName.equals(expectedMetricName); - } else if (rawArgument instanceof RecordDataUsageMetric) { - String metricName = invocation.getArgument(0).getName(); - found = methodName.equals("doStatsWork") && metricName.equals(expectedMetricName); + if (invocation.getRawArguments() != null && invocation.getRawArguments().length > 0) { + Object rawArgument = invocation.getRawArguments()[0]; + if (rawArgument instanceof IncrementCounter) { + String metricName = invocation.getArgument(0).getName(); + found = methodName.equals("doStatsWork") && metricName.equals(expectedMetricName); + } else if (rawArgument instanceof RecordDataUsageMetric) { + String metricName = invocation.getArgument(0).getName(); + found = methodName.equals("doStatsWork") && metricName.equals(expectedMetricName); + } } } assertTrue("Could not find metric: " + expectedMetricName, found);