never mind.

It looks like the only real culprit is MethodDescriptor class which has now 
been marked final. But mock can be replaced with a builder:

        MethodDescriptor<Object, Object> methodDescriptor = 
MethodDescriptor.newBuilder()

            .setFullMethodName(fullMethodName)

            .setType(MethodType.UNARY)

            .setRequestMarshaller(marshaller)

            .setResponseMarshaller(marshaller)

            .build();

The @DoNotMock annotation on ServiceCall does not seem to do anything.

Eugene


On Monday, September 25, 2017 at 3:51:45 PM UTC-7, Eugene Strulyov wrote:
>
> Hi,
>
> I'm trying to upgrade to 1.6.1 but I ran into this problem. Currently have 
> the following code:
>
>         requestHeaders = new Metadata();
>
>         attributes = Attributes.newBuilder()
>
>             .set(Grpc.TRANSPORT_ATTR_SSL_SESSION, sslSession)
>
>             .build();
>
>         when(call.getAttributes()).thenReturn(attributes);
>
>         when(call.getMethodDescriptor()).thenReturn(methodDescriptor);
>
>         when(sslSession.getPeerPrincipal()).thenReturn(peerPrincipal);
>
>         validator = new CertAuthInterceptor(true, AUTH_MAP);
>
> ...
>
>
>         when(peerPrincipal.getName()).thenReturn("my peer principal");
>
>         when(methodDescriptor.getFullMethodName()).thenReturn("my 
> method...");
>
>         validator.interceptCall(call, requestHeaders, next);
>
>
> This doesn't work any more because MethodDescriptor has been marked final 
> and ServerCall has @DoNotMock annotation. How do I do this now? The 
> annotation suggests using InProcessTransport, but it seems that Attributes 
> are hard-coded in it, so I cannot provide sslSession. I also don't 
> understand why I now have to jump through hoops to do such a simple test.
>
>
> (CertAuthInterceptor is a ServerInterceptor that allows/denies a method 
> call depending on the client certificate and AUTH_MAP).
>
>
> thanks,
>
>
> Eugene
>
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"grpc.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/grpc-io.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/grpc-io/87bc0114-756a-42a5-b242-1cba708262a3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to