Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#9932] Fix testcase failure #9985

Merged
merged 1 commit into from
May 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.navercorp.pinpoint.common.profiler.message;

public class DefaultResultResponse implements ResultResponse {
private final boolean success;
private final String message;

public DefaultResultResponse(boolean success, String message) {
this.success = success;
this.message = message;
}

@Override
public boolean isSuccess() {
return success;
}

@Override
public String getMessage() {
return message;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@
*/
public class TestClassList {

private List<String> testClassList = new ArrayList<>();
private final List<String> testClassList = new ArrayList<>();

public TestClassList() {
add("com.navercorp.pinpoint.bootstrap.");
add("com.navercorp.pinpoint.common.");
add("com.navercorp.pinpoint.thrift.");

add("com.navercorp.pinpoint.profiler.context.");

add("com.navercorp.pinpoint.test.MockApplicationContext");
Expand All @@ -42,7 +42,7 @@ public TestClassList() {
add("com.navercorp.pinpoint.test.junit4.TestContext");

add("com.navercorp.pinpoint.test.junit4.IsRootSpan");
add("org.apache.thrift.TBase");

add("junit.");
add("org.hamcrest.");
add("org.assertj.");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.navercorp.pinpoint.test.rpc;

import com.google.inject.Inject;
import com.navercorp.pinpoint.common.profiler.message.DefaultResultResponse;
import com.navercorp.pinpoint.common.profiler.message.MessageConverter;
import com.navercorp.pinpoint.common.profiler.message.ResultResponse;

public class MockMessageConverter implements MessageConverter<Object, ResultResponse> {

@Inject
public MockMessageConverter() {
}

@Override
public ResultResponse toMessage(Object message) {
return new DefaultResultResponse(true, "success by mocking");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import com.navercorp.pinpoint.common.profiler.message.ResultResponse;
import com.navercorp.pinpoint.io.ResponseMessage;
import com.navercorp.pinpoint.profiler.context.SpanType;
import com.navercorp.pinpoint.profiler.context.grpc.GrpcMessageToResultConverterProvider;
import com.navercorp.pinpoint.profiler.context.module.AgentDataSender;
import com.navercorp.pinpoint.profiler.context.module.MetadataDataSender;
import com.navercorp.pinpoint.profiler.context.module.ModuleLifeCycle;
Expand Down Expand Up @@ -88,7 +87,7 @@ protected void configure() {

TypeLiteral<MessageConverter<Object, ResultResponse>> resultMessageConverter = new TypeLiteral<MessageConverter<Object, ResultResponse>>() {};
Key<MessageConverter<Object, ResultResponse>> resultMessageConverterKey = Key.get(resultMessageConverter, ResultConverter.class);
bind(resultMessageConverterKey).toProvider(GrpcMessageToResultConverterProvider.class).in(Scopes.SINGLETON);
bind(resultMessageConverterKey).to(MockMessageConverter.class).in(Scopes.SINGLETON);
expose(resultMessageConverterKey);


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package com.navercorp.pinpoint.profiler.context.grpc;

import com.google.protobuf.InvalidProtocolBufferException;
import com.navercorp.pinpoint.common.profiler.message.DefaultResultResponse;
import com.navercorp.pinpoint.common.profiler.message.MessageConverter;
import com.navercorp.pinpoint.common.profiler.message.ResultResponse;
import com.navercorp.pinpoint.grpc.trace.PResult;
Expand All @@ -33,17 +34,7 @@ public ResultResponse toMessage(Object object) {
final byte[] byteMessage = responseMessage.getMessage();
try {
final PResult pResult = PResult.parseFrom(byteMessage);
return new ResultResponse() {
@Override
public boolean isSuccess() {
return pResult.getSuccess();
}

@Override
public String getMessage() {
return pResult.getMessage();
}
};
return new DefaultResultResponse(pResult.getSuccess(), pResult.getMessage());
} catch (InvalidProtocolBufferException e) {
throw new IllegalArgumentException("invalid message data. response message=" + responseMessage, e);
}
Expand Down