diff --git a/bootstrap-core/src/main/java/com/navercorp/pinpoint/bootstrap/plugin/test/Expectations.java b/bootstrap-core/src/main/java/com/navercorp/pinpoint/bootstrap/plugin/test/Expectations.java index 3c784c7f40a8..f3705389f15d 100644 --- a/bootstrap-core/src/main/java/com/navercorp/pinpoint/bootstrap/plugin/test/Expectations.java +++ b/bootstrap-core/src/main/java/com/navercorp/pinpoint/bootstrap/plugin/test/Expectations.java @@ -25,7 +25,6 @@ public final class Expectations { private static final Object ANY_ANNOTATION_VALUE = new Object(); - private Expectations() { } @@ -34,55 +33,131 @@ public static Object anyAnnotationValue() { } public static ExpectedTrace root(String serviceType, Member method, String rpc, String endPoint, String remoteAddr, ExpectedAnnotation... annotations) { - return new ExpectedTrace(TraceType.ROOT, serviceType, method, null, null, rpc, endPoint, remoteAddr, null, annotations, null); + ExpectedTrace.Builder rootBuilder = ExpectedTrace.createRootBuilder(serviceType); + rootBuilder.setMethod(method); + rootBuilder.setRpc(rpc); + rootBuilder.setEndPoint(endPoint); + rootBuilder.setRemoteAddr(remoteAddr); + rootBuilder.setAnnotations(annotations); + return rootBuilder.build(); } public static ExpectedTrace root(String serviceType, Member method, Exception exception, String rpc, String endPoint, String remoteAddr, ExpectedAnnotation... annotations) { - return new ExpectedTrace(TraceType.ROOT, serviceType, method, null, exception, rpc, endPoint, remoteAddr, null, annotations, null); + ExpectedTrace.Builder rootBuilder = ExpectedTrace.createRootBuilder(serviceType); + rootBuilder.setMethod(method); + rootBuilder.setException(exception); + rootBuilder.setRpc(rpc); + rootBuilder.setEndPoint(endPoint); + rootBuilder.setRemoteAddr(remoteAddr); + rootBuilder.setAnnotations(annotations); + return rootBuilder.build(); } public static ExpectedTrace root(String serviceType, String methodDescriptor, String rpc, String endPoint, String remoteAddr, ExpectedAnnotation... annotations) { - return new ExpectedTrace(TraceType.ROOT, serviceType, null, methodDescriptor, null, rpc, endPoint, remoteAddr, null, annotations, null); + ExpectedTrace.Builder rootBuilder = ExpectedTrace.createRootBuilder(serviceType); + rootBuilder.setMethodSignature(methodDescriptor); + rootBuilder.setRpc(rpc); + rootBuilder.setEndPoint(endPoint); + rootBuilder.setRemoteAddr(remoteAddr); + rootBuilder.setAnnotations(annotations); + return rootBuilder.build(); } public static ExpectedTrace root(String serviceType, String methodDescriptor, Exception exception, String rpc, String endPoint, String remoteAddr, ExpectedAnnotation... annotations) { - return new ExpectedTrace(TraceType.ROOT, serviceType, null, methodDescriptor, exception, rpc, endPoint, remoteAddr, null, annotations, null); + ExpectedTrace.Builder rootBuilder = ExpectedTrace.createRootBuilder(serviceType); + rootBuilder.setMethodSignature(methodDescriptor); + rootBuilder.setException(exception); + rootBuilder.setRpc(rpc); + rootBuilder.setEndPoint(endPoint); + rootBuilder.setRemoteAddr(remoteAddr); + rootBuilder.setAnnotations(annotations); + return rootBuilder.build(); } public static ExpectedTrace event(String serviceType, Member method, String rpc, String endPoint, String destinationId, ExpectedAnnotation... annotations) { - return new ExpectedTrace(TraceType.EVENT, serviceType, method, null, null, rpc, endPoint, null, destinationId, annotations, null); + ExpectedTrace.Builder eventBuilder = ExpectedTrace.createEventBuilder(serviceType); + eventBuilder.setMethod(method); + eventBuilder.setRpc(rpc); + eventBuilder.setEndPoint(endPoint); + eventBuilder.setDestinationId(destinationId); + eventBuilder.setAnnotations(annotations); + return eventBuilder.build(); } public static ExpectedTrace event(String serviceType, Member method, Exception exception, String rpc, String endPoint, String destinationId, ExpectedAnnotation... annotations) { - return new ExpectedTrace(TraceType.EVENT, serviceType, method, null, exception, rpc, endPoint, null, destinationId, annotations, null); + ExpectedTrace.Builder eventBuilder = ExpectedTrace.createEventBuilder(serviceType); + eventBuilder.setMethod(method); + eventBuilder.setException(exception); + eventBuilder.setRpc(rpc); + eventBuilder.setEndPoint(endPoint); + eventBuilder.setDestinationId(destinationId); + eventBuilder.setAnnotations(annotations); + return eventBuilder.build(); } public static ExpectedTrace event(String serviceType, Member method, ExpectedAnnotation... annotations) { - return new ExpectedTrace(TraceType.EVENT, serviceType, method, null, null, null, null, null, null, annotations, null); + ExpectedTrace.Builder eventBuilder = ExpectedTrace.createEventBuilder(serviceType); + eventBuilder.setMethod(method); + eventBuilder.setAnnotations(annotations); + return eventBuilder.build(); } public static ExpectedTrace event(String serviceType, Member method, Exception exception, ExpectedAnnotation... annotations) { - return new ExpectedTrace(TraceType.EVENT, serviceType, method, null, exception, null, null, null, null, annotations, null); + ExpectedTrace.Builder eventBuilder = ExpectedTrace.createEventBuilder(serviceType); + eventBuilder.setMethod(method); + eventBuilder.setException(exception); + eventBuilder.setAnnotations(annotations); + return eventBuilder.build(); } public static ExpectedTrace event(String serviceType, String methodDescriptor, ExpectedAnnotation... annotations) { - return new ExpectedTrace(TraceType.EVENT, serviceType, null, methodDescriptor, null, null, null, null, null, annotations, null); + ExpectedTrace.Builder eventBuilder = ExpectedTrace.createEventBuilder(serviceType); + eventBuilder.setMethodSignature(methodDescriptor); + eventBuilder.setAnnotations(annotations); + return eventBuilder.build(); } public static ExpectedTrace event(String serviceType, String methodDescriptor, Exception exception, ExpectedAnnotation... annotations) { - return new ExpectedTrace(TraceType.EVENT, serviceType, null, methodDescriptor, exception, null, null, null, null, annotations, null); + ExpectedTrace.Builder eventBuilder = ExpectedTrace.createEventBuilder(serviceType); + eventBuilder.setMethodSignature(methodDescriptor); + eventBuilder.setException(exception); + eventBuilder.setAnnotations(annotations); + return eventBuilder.build(); } public static ExpectedTrace event(String serviceType, String methodDescriptor, String rpc, String endPoint, String destinationId, ExpectedAnnotation... annotations) { - return new ExpectedTrace(TraceType.EVENT, serviceType, null, methodDescriptor, null, rpc, endPoint, null, destinationId, annotations, null); + ExpectedTrace.Builder eventBuilder = ExpectedTrace.createEventBuilder(serviceType); + eventBuilder.setMethodSignature(methodDescriptor); + eventBuilder.setRpc(rpc); + eventBuilder.setEndPoint(endPoint); + eventBuilder.setDestinationId(destinationId); + eventBuilder.setAnnotations(annotations); + return eventBuilder.build(); } public static ExpectedTrace event(String serviceType, String methodDescriptor, Exception exception, String rpc, String endPoint, String destinationId, ExpectedAnnotation... annotations) { - return new ExpectedTrace(TraceType.EVENT, serviceType, null, methodDescriptor, exception, rpc, endPoint, null, destinationId, annotations, null); + ExpectedTrace.Builder eventBuilder = ExpectedTrace.createEventBuilder(serviceType); + eventBuilder.setMethodSignature(methodDescriptor); + eventBuilder.setException(exception); + eventBuilder.setRpc(rpc); + eventBuilder.setEndPoint(endPoint); + eventBuilder.setDestinationId(destinationId); + eventBuilder.setAnnotations(annotations); + return eventBuilder.build(); } public static ExpectedTrace async(ExpectedTrace initiator, ExpectedTrace... asyncTraces) { - return new ExpectedTrace(initiator.getType(), initiator.getServiceType(), initiator.getMethod(), initiator.getMethodSignature(), initiator.getException(), initiator.getRpc(), initiator.getEndPoint(), initiator.getRemoteAddr(), initiator.getDestinationId(), initiator.getAnnotations(), asyncTraces); + ExpectedTrace.Builder eventBuilder = ExpectedTrace.createBuilder(initiator.getType(), initiator.getServiceType()); + eventBuilder.setMethod(initiator.getMethod()); + eventBuilder.setMethodSignature(initiator.getMethodSignature()); + eventBuilder.setException(initiator.getException()); + eventBuilder.setRpc(initiator.getRpc()); + eventBuilder.setEndPoint(initiator.getEndPoint()); + eventBuilder.setRemoteAddr(initiator.getRemoteAddr()); + eventBuilder.setDestinationId(initiator.getDestinationId()); + eventBuilder.setAnnotations(initiator.getAnnotations()); + eventBuilder.setAsyncTraces(asyncTraces); + return eventBuilder.build(); } public static ExpectedAnnotation[] annotations(ExpectedAnnotation... annotations) { diff --git a/bootstrap-core/src/main/java/com/navercorp/pinpoint/bootstrap/plugin/test/ExpectedTrace.java b/bootstrap-core/src/main/java/com/navercorp/pinpoint/bootstrap/plugin/test/ExpectedTrace.java index ae6f1dc3f0f9..57670eb0a0c5 100644 --- a/bootstrap-core/src/main/java/com/navercorp/pinpoint/bootstrap/plugin/test/ExpectedTrace.java +++ b/bootstrap-core/src/main/java/com/navercorp/pinpoint/bootstrap/plugin/test/ExpectedTrace.java @@ -3,9 +3,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -18,7 +18,6 @@ /** * @author Jongho Moon - * */ public class ExpectedTrace { private final TraceType type; @@ -26,25 +25,25 @@ public class ExpectedTrace { private final Member method; private final String methodSignature; private final Exception exception; - private final String rpc; - private final String endPoint; - private final String remoteAddr; - private final String destinationId; + private final ExpectedTraceField rpc; + private final ExpectedTraceField endPoint; + private final ExpectedTraceField remoteAddr; + private final ExpectedTraceField destinationId; private final ExpectedAnnotation[] annotations; private final ExpectedTrace[] asyncTraces; - - public ExpectedTrace(TraceType type, String serviceType, Member method, String methodSignature, Exception exception, String rpc, String endPoint, String remoteAddr, String destinationId, ExpectedAnnotation[] annotations, ExpectedTrace[] asyncTraces) { - this.type = type; - this.serviceType = serviceType; - this.method = method; - this.methodSignature = methodSignature; - this.exception = exception; - this.rpc = rpc; - this.endPoint = endPoint; - this.remoteAddr = remoteAddr; - this.destinationId = destinationId; - this.annotations = annotations; - this.asyncTraces = asyncTraces; + + private ExpectedTrace(Builder builder) { + this.type = builder.type; + this.serviceType = builder.serviceType; + this.method = builder.method; + this.methodSignature = builder.methodSignature; + this.exception = builder.exception; + this.rpc = builder.rpc; + this.endPoint = builder.endPoint; + this.remoteAddr = builder.remoteAddr; + this.destinationId = builder.destinationId; + this.annotations = builder.annotations; + this.asyncTraces = builder.asyncTraces; } public TraceType getType() { @@ -67,19 +66,19 @@ public Exception getException() { return exception; } - public String getRpc() { + public ExpectedTraceField getRpc() { return rpc; } - public String getEndPoint() { + public ExpectedTraceField getEndPoint() { return endPoint; } - public String getRemoteAddr() { + public ExpectedTraceField getRemoteAddr() { return remoteAddr; } - public String getDestinationId() { + public ExpectedTraceField getDestinationId() { return destinationId; } @@ -90,4 +89,114 @@ public ExpectedAnnotation[] getAnnotations() { public ExpectedTrace[] getAsyncTraces() { return asyncTraces; } + + + public static Builder createBuilder(TraceType traceType, String serviceType) { + return new Builder(traceType, serviceType); + } + + public static Builder createRootBuilder(String serviceType) { + return new Builder(TraceType.ROOT, serviceType); + } + + public static Builder createEventBuilder(String serviceType) { + return new Builder(TraceType.EVENT, serviceType); + } + + public static class Builder { + + private final TraceType type; + private final String serviceType; + + private Member method; + private String methodSignature; + private Exception exception; + private ExpectedTraceField rpc = ExpectedTraceField.ALWAYS_TRUE; + private ExpectedTraceField endPoint = ExpectedTraceField.ALWAYS_TRUE; + private ExpectedTraceField remoteAddr = ExpectedTraceField.ALWAYS_TRUE; + private ExpectedTraceField destinationId = ExpectedTraceField.ALWAYS_TRUE; + private ExpectedAnnotation[] annotations; + private ExpectedTrace[] asyncTraces; + + public Builder(TraceType type, String serviceType) { + if (type == null) { + throw new NullPointerException("type must not be null"); + } + if (serviceType == null) { + throw new NullPointerException("serviceType must not be null"); + } + this.type = type; + this.serviceType = serviceType; + } + + public void setMethod(Member method) { + this.method = method; + } + + public void setMethodSignature(String methodSignature) { + this.methodSignature = methodSignature; + } + + public void setException(Exception exception) { + this.exception = exception; + } + + public void setRpc(String rpc) { + setRpc(ExpectedTraceField.create(rpc)); + } + + public void setRpc(ExpectedTraceField rpc) { + if (rpc == null) { + throw new NullPointerException("rpc must not be null"); + } + this.rpc = rpc; + } + + public void setEndPoint(String endPoint) { + setEndPoint(ExpectedTraceField.create(endPoint)); + } + + public void setEndPoint(ExpectedTraceField endPoint) { + if (endPoint == null) { + throw new NullPointerException("endPoint must not be null"); + } + this.endPoint = endPoint; + } + + public void setRemoteAddr(String remoteAddr) { + setRemoteAddr(ExpectedTraceField.create(remoteAddr)); + } + + public void setRemoteAddr(ExpectedTraceField remoteAddr) { + if (remoteAddr == null) { + throw new NullPointerException("remoteAddr must not be null"); + } + this.remoteAddr = remoteAddr; + } + + public void setDestinationId(String destinationId) { + setDestinationId(ExpectedTraceField.create(destinationId)); + } + + public void setDestinationId(ExpectedTraceField destinationId) { + if (destinationId == null) { + throw new NullPointerException("destinationId must not be null"); + } + this.destinationId = destinationId; + } + + public void setAnnotations(ExpectedAnnotation... annotations) { + this.annotations = annotations; + } + + public void setAsyncTraces(ExpectedTrace[] asyncTraces) { + this.asyncTraces = asyncTraces; + } + + public ExpectedTrace build() { + return new ExpectedTrace(this); + } + + } + } diff --git a/bootstrap-core/src/main/java/com/navercorp/pinpoint/bootstrap/plugin/test/ExpectedTraceField.java b/bootstrap-core/src/main/java/com/navercorp/pinpoint/bootstrap/plugin/test/ExpectedTraceField.java new file mode 100644 index 000000000000..49f94ea76fda --- /dev/null +++ b/bootstrap-core/src/main/java/com/navercorp/pinpoint/bootstrap/plugin/test/ExpectedTraceField.java @@ -0,0 +1,86 @@ +/* + * Copyright 2018 NAVER Corp. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.navercorp.pinpoint.bootstrap.plugin.test; + +/** + * @author Taejin Koo + */ +public class ExpectedTraceField { + + public static ExpectedTraceField ALWAYS_TRUE = new ExpectedTraceField(ExpectedTraceFieldType.ALWAYS_TRUE); + public static ExpectedTraceField EMPTY = new ExpectedTraceField(ExpectedTraceFieldType.EMPTY); + public static ExpectedTraceField NOT_EMPTY = new ExpectedTraceField(ExpectedTraceFieldType.NOT_EMPTY); + + private final String expected; + private final ExpectedTraceFieldType expectedType; + + public ExpectedTraceField(ExpectedTraceFieldType expectedType) { + this(null, expectedType); + } + + public ExpectedTraceField(String expected, ExpectedTraceFieldType expectedType) { + if (expectedType == null) { + throw new NullPointerException("expectedType must not be null"); + } + this.expected = expected; + this.expectedType = expectedType; + } + + public static ExpectedTraceField create(String value) { + if (value == null) { + return createAlwaysTrue(); + } else { + return createEquals(value); + } + } + + public static ExpectedTraceField createEquals(String value) { + return new ExpectedTraceField(value, ExpectedTraceFieldType.EQUALS); + } + + public static ExpectedTraceField createAlwaysTrue() { + return ALWAYS_TRUE; + } + + public static ExpectedTraceField createNotEmpty() { + return NOT_EMPTY; + } + + public static ExpectedTraceField createEmpty() { + return EMPTY; + } + + public static ExpectedTraceField createStartWith(String value) { + return new ExpectedTraceField(value, ExpectedTraceFieldType.START_WITH); + } + + public static ExpectedTraceField createContains(String value) { + return new ExpectedTraceField(value, ExpectedTraceFieldType.CONTAINS); + } + + public boolean isEquals(String value) { + return expectedType.isEquals(expected, value); + } + + @Override + public String toString() { + return "ExpectedTraceField{" + + "expectedType=" + expectedType + + ", expected='" + expected + '\'' + + '}'; + } +} diff --git a/bootstrap-core/src/main/java/com/navercorp/pinpoint/bootstrap/plugin/test/ExpectedTraceFieldType.java b/bootstrap-core/src/main/java/com/navercorp/pinpoint/bootstrap/plugin/test/ExpectedTraceFieldType.java new file mode 100644 index 000000000000..31084b3c45a0 --- /dev/null +++ b/bootstrap-core/src/main/java/com/navercorp/pinpoint/bootstrap/plugin/test/ExpectedTraceFieldType.java @@ -0,0 +1,99 @@ +/* + * Copyright 2018 NAVER Corp. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.navercorp.pinpoint.bootstrap.plugin.test; + +/** + * @author Taejin Koo + */ +public enum ExpectedTraceFieldType { + + EQUALS { + @Override + public boolean isEquals(String expected, String actual) { + if (expected == null && actual == null) { + return true; + } + if (expected == null) { + return false; + } + return expected.equals(actual); + } + }, + + ALWAYS_TRUE { + @Override + public boolean isEquals(String expected, String actual) { + return true; + } + }, + + NOT_EMPTY { + @Override + public boolean isEquals(String expected, String actual) { + if (actual == null || actual.length() == 0) { + return false; + } + return true; + } + }, + + EMPTY { + @Override + public boolean isEquals(String expected, String actual) { + if (actual == null || actual.length() == 0) { + return true; + } + return false; + } + }, + + START_WITH { + @Override + public boolean isEquals(String expected, String actual) { + if (expected == null && actual == null) { + return true; + } + if (expected == null) { + return true; + } + if (actual != null) { + return actual.startsWith(expected); + } + return false; + } + + }, + + CONTAINS { + @Override + public boolean isEquals(String expected, String actual) { + if (expected == null && actual == null) { + return true; + } + if (expected == null) { + return true; + } + if (actual != null) { + return actual.contains(expected); + } + return false; + } + }; + + public abstract boolean isEquals(String expected, String actual); + +} diff --git a/bootstrap-core/src/test/java/com/navercorp/pinpoint/bootstrap/plugin/test/ExpectedTraceFieldTest.java b/bootstrap-core/src/test/java/com/navercorp/pinpoint/bootstrap/plugin/test/ExpectedTraceFieldTest.java new file mode 100644 index 000000000000..60cff2ac1104 --- /dev/null +++ b/bootstrap-core/src/test/java/com/navercorp/pinpoint/bootstrap/plugin/test/ExpectedTraceFieldTest.java @@ -0,0 +1,92 @@ +/* + * Copyright 2018 NAVER Corp. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.navercorp.pinpoint.bootstrap.plugin.test; + +import org.junit.Assert; +import org.junit.Test; + +/** + * @author Taejin Koo + */ +public class ExpectedTraceFieldTest { + + private final String message = "message"; + private final String message1 = "message1"; + private final String message2 = "message2"; + private final String failMessage = "fail"; + private final String emptyMessage = ""; + private final String nullMessage = null; + + @Test + public void alwaysTrueTest() { + ExpectedTraceField expectedTraceField = ExpectedTraceField.create(null); + assertField(expectedTraceField, true, true, true, true, true, true); + } + + @Test + public void alwaysTrueTest2() { + ExpectedTraceField expectedTraceField = ExpectedTraceField.createAlwaysTrue(); + assertField(expectedTraceField, true, true, true, true, true, true); + } + + @Test + public void equalsTest() { + ExpectedTraceField expectedTraceField = ExpectedTraceField.create(message); + assertField(expectedTraceField, true, false, false, false, false, false); + } + + @Test + public void equalsTest2() { + ExpectedTraceField expectedTraceField = ExpectedTraceField.createEquals(message); + assertField(expectedTraceField, true, false, false, false, false, false); + } + + @Test + public void containsTest() { + ExpectedTraceField expectedTraceField = ExpectedTraceField.createContains(message); + assertField(expectedTraceField, true, true, true, false, false, false); + } + + @Test + public void emptyTest() { + ExpectedTraceField expectedTraceField = ExpectedTraceField.createEmpty(); + assertField(expectedTraceField, false, false, false, false, true, true); + } + + @Test + public void notEmptyTest() { + ExpectedTraceField expectedTraceField = ExpectedTraceField.createNotEmpty(); + assertField(expectedTraceField, true, true, true, true, false, false); + } + + @Test + public void startWithTest() { + ExpectedTraceField expectedTraceField = ExpectedTraceField.createStartWith(message); + assertField(expectedTraceField, true, true, true, false, false, false); + } + + + private void assertField(ExpectedTraceField expectedTraceField, boolean boolean1, boolean boolean2, boolean boolean3, boolean boolean4, boolean boolean5, boolean boolean6) { + Assert.assertEquals(boolean1, expectedTraceField.isEquals(message)); + Assert.assertEquals(boolean2, expectedTraceField.isEquals(message1)); + Assert.assertEquals(boolean3, expectedTraceField.isEquals(message2)); + Assert.assertEquals(boolean4, expectedTraceField.isEquals(failMessage)); + Assert.assertEquals(boolean5, expectedTraceField.isEquals(emptyMessage)); + Assert.assertEquals(boolean6, expectedTraceField.isEquals(nullMessage)); + } + +} diff --git a/profiler-test/src/main/java/com/navercorp/pinpoint/test/PluginVerifierExternalAdaptor.java b/profiler-test/src/main/java/com/navercorp/pinpoint/test/PluginVerifierExternalAdaptor.java index a229b2e2e459..02e18a81d73c 100644 --- a/profiler-test/src/main/java/com/navercorp/pinpoint/test/PluginVerifierExternalAdaptor.java +++ b/profiler-test/src/main/java/com/navercorp/pinpoint/test/PluginVerifierExternalAdaptor.java @@ -27,6 +27,7 @@ import com.navercorp.pinpoint.bootstrap.plugin.test.ExpectedAnnotation; import com.navercorp.pinpoint.bootstrap.plugin.test.ExpectedSql; import com.navercorp.pinpoint.bootstrap.plugin.test.ExpectedTrace; +import com.navercorp.pinpoint.bootstrap.plugin.test.ExpectedTraceField; import com.navercorp.pinpoint.bootstrap.plugin.test.PluginTestVerifier; import com.navercorp.pinpoint.bootstrap.plugin.test.TraceType; import com.navercorp.pinpoint.common.service.AnnotationKeyRegistryService; @@ -543,13 +544,13 @@ private static final class ResolvedExpectedTrace { private final LocalAsyncId localAsyncId; private final Integer apiId; private final Exception exception; - private final String rpc; - private final String endPoint; - private final String remoteAddr; - private final String destinationId; + private final ExpectedTraceField rpc; + private final ExpectedTraceField endPoint; + private final ExpectedTraceField remoteAddr; + private final ExpectedTraceField destinationId; private final ExpectedAnnotation[] annotations; - public ResolvedExpectedTrace(Class type, ServiceType serviceType, Integer apiId, Exception exception, String rpc, String endPoint, String remoteAddr, String destinationId, ExpectedAnnotation[] annotations, Integer asyncId) { + public ResolvedExpectedTrace(Class type, ServiceType serviceType, Integer apiId, Exception exception, ExpectedTraceField rpc, ExpectedTraceField endPoint, ExpectedTraceField remoteAddr, ExpectedTraceField destinationId, ExpectedAnnotation[] annotations, Integer asyncId) { this.type = type; this.serviceType = serviceType; this.apiId = apiId; @@ -615,6 +616,15 @@ private static boolean equals(Object expected, Object actual) { return expected == null || (expected.equals(actual)); } + private static boolean equals(Object expected, String actual) { + if (expected instanceof ExpectedTraceField) { + return ((ExpectedTraceField) expected).isEquals(actual); + } + + // if expected is null, no need to compare. + return expected == null || (expected.equals(actual)); + } + private void verifySpan(ResolvedExpectedTrace expected, ActualTrace actual) { if (!expected.type.equals(actual.getType())) { throw new AssertionError("Expected an instance of " + expected.type.getSimpleName() + " but was " + actual.getType().getName() + ". expected: " + expected + ", was: " + actual);