If you are doing an end to end test that involves setting up an in process
server as you are doing with GrpcServerRule, I would recommend just
creating the context normally (most likely based on the initial metadata).
If you want to unit test the server handler in isolation, then you probably
don't want to use GrpcServerRule and instead want to call your handler
directly with the context attached.

On Fri, May 18, 2018 at 11:39 PM <[email protected]> wrote:

> I have a gRPC service that reads values from the context.  While unit
> testing how do I set the value of the context being used in java?
>
> My current setup that does not work is using
> GrpcServerRule().directExecutor().  In the @Before method I update the
> context via
> Context.current().withValue("key", "value")).apply();
>
> The server returned doesnt seems to be using this context because I guess
> this inst the correct thread scope to attach it to.  Any tips?
>
> Thanks in advance.
>
> --
> 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/b82e88f4-b36d-4b02-aa2c-ab9c85dffe06%40googlegroups.com
> <https://groups.google.com/d/msgid/grpc-io/b82e88f4-b36d-4b02-aa2c-ab9c85dffe06%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>


-- 
Spencer Fang

-- 
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/CAK%3D-x_4ifJEqDFOwmWqZQGYPiS8Ut5cXqtWZq4_vdh_cx97Ptg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to