Skip to content

Commit

Permalink
[#9932] Fix testcase failure
Browse files Browse the repository at this point in the history
  • Loading branch information
emeroad committed May 24, 2023
1 parent 470becc commit d643842
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 16 deletions.
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

0 comments on commit d643842

Please sign in to comment.