Skip to content

Commit

Permalink
[#117] Improved plugin test feature
Browse files Browse the repository at this point in the history
  • Loading branch information
lioolli committed Mar 6, 2015
1 parent ac60caa commit 6660a4a
Show file tree
Hide file tree
Showing 21 changed files with 1,303 additions and 531 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,6 @@ public enum MethodEditorProperty {
* If this property is set, exception will not be thrown even if the target method/constructor is not exist.
*/
IGNORE_IF_NOT_EXIST

// TODO 수정 도중 예외가 발생하더라도 무시하고 넘어갈 수 있는 옵션들 추가
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import java.io.PrintStream;
import java.lang.reflect.Method;
import java.util.List;

import com.navercorp.pinpoint.common.AnnotationKey;
import com.navercorp.pinpoint.common.ServiceType;
Expand All @@ -27,11 +28,17 @@
*
*/
public interface PluginTestVerifier {
public void verifyServerType(ServiceType serviceType);
public void verifySpanCount(int count);
public void verifyServerType(ServiceType expected);
public void verifyServerInfo(String expected);
public void verifyConnector(String protocol, int port);
public void verifyService(String context, List<String> libs);
public void verifySpanCount(int expected);
public void verifySpan(ServiceType serviceType, ExpectedAnnotation...annotations);
public void verifySpanEvent(ServiceType serviceType, ExpectedAnnotation...annotations);
public void verifyApi(ServiceType serviceType, Method method, Object... args);
public void verifySpan(ServiceType serviceType, Method method, String rpc, String endPoint, String remoteAddr, ExpectedAnnotation... annotations);
public void verifySpanEvent(ServiceType serviceType, Method method, String rpc, String endPoint, String destinationId, ExpectedAnnotation... annotations);
public void verifyApi(ServiceType serviceType, Method method, Object...args);
public void popSpan();
public void printSpans(PrintStream out);
public void printApis(PrintStream out);
public void initialize(boolean initializeTraceObject);
Expand All @@ -42,6 +49,16 @@ public static ExpectedAnnotation annotation(AnnotationKey key, Object value) {
return new ExpectedAnnotation(key.getCode(), value);
}

public static ExpectedAnnotation[] args(Object... args) {
ExpectedAnnotation[] annotations = new ExpectedAnnotation[args.length];

for (int i = 0; i < args.length; i++) {
annotations[i] = ExpectedAnnotation.annotation(AnnotationKey.getArgs(i), args[i]);
}

return annotations;
}

private final int key;
private final Object value;

Expand All @@ -62,5 +79,6 @@ public Object getValue() {
public String toString() {
return key + "=" + value;
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -201,9 +201,10 @@ public String getServerType() {
public int cacheApi(final MethodDescriptor methodDescriptor) {
final String fullName = methodDescriptor.getFullName();
final Result result = this.apiCache.put(fullName);
if (result.isNewValue()) {
methodDescriptor.setApiId(result.getId());

methodDescriptor.setApiId(result.getId());

if (result.isNewValue()) {
final TApiMetaData apiMetadata = new TApiMetaData();
apiMetadata.setAgentId(getAgentId());
apiMetadata.setAgentStartTime(getAgentStartTime());
Expand All @@ -213,7 +214,8 @@ public int cacheApi(final MethodDescriptor methodDescriptor) {
apiMetadata.setLine(methodDescriptor.getLineNumber());

this.priorityDataSender.request(apiMetadata);
}
}

return result.getId();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,12 @@ public JavassistMethodInfo(CtBehavior behavior) {
this.behavior = behavior;

String[] parameterVariableNames = JavaAssistUtils.getParameterVariableName(behavior);
this.descriptor = new DefaultMethodDescriptor(behavior.getDeclaringClass().getName(), behavior.getName(), getParameterTypes(), parameterVariableNames);
int lineNumber = JavaAssistUtils.getLineNumber(behavior);

DefaultMethodDescriptor descriptor = new DefaultMethodDescriptor(behavior.getDeclaringClass().getName(), behavior.getName(), getParameterTypes(), parameterVariableNames);
descriptor.setLineNumber(lineNumber);

this.descriptor = descriptor;
}

@Override
Expand Down
Loading

0 comments on commit 6660a4a

Please sign in to comment.