Skip to content

Commit

Permalink
Fixing copyrights, spot-bugs and test
Browse files Browse the repository at this point in the history
  • Loading branch information
thegridman committed Dec 8, 2023
1 parent 3e00de3 commit 21a8004
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 8 deletions.
3 changes: 3 additions & 0 deletions grpc/client/src/main/java/module-info.java
Expand Up @@ -20,6 +20,9 @@
module io.helidon.grpc.client {
exports io.helidon.grpc.client;

requires io.grpc.netty;
requires io.netty.handler;

requires transitive io.helidon.grpc.core;

requires io.helidon.tracing;
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019, 2022 Oracle and/or its affiliates.
* Copyright (c) 2019, 2023 Oracle and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -33,6 +33,8 @@
import io.helidon.grpc.server.GrpcServerConfiguration;
import io.grpc.EquivalentAddressGroup;
import io.grpc.NameResolver;
import io.grpc.NameResolverProvider;
import io.grpc.NameResolverRegistry;
import io.grpc.StatusRuntimeException;

import io.netty.handler.codec.DecoderException;
Expand Down Expand Up @@ -209,12 +211,11 @@ public void shouldConnectWithCaCertAndClientCertAndClientKeyTo2WaySslServer() th

@Test
public void shouldUseTarget() throws Exception {
FakeNameResolverFactory factory = new FakeNameResolverFactory(portNoSsl);
NameResolverRegistry.getDefaultRegistry().register(new FakeNameResolverProvider("foo", portNoSsl));
String channelKey = "ChannelKey";
GrpcChannelDescriptor.Builder builder = GrpcChannelDescriptor
.builder()
.target("foo://bar.com")
.nameResolverFactory(factory);
.target("foo://bar.com");

GrpcChannelsProvider provider = GrpcChannelsProvider.builder()
.channel(channelKey, builder.build())
Expand Down Expand Up @@ -304,6 +305,39 @@ public NameResolver.Args getArgs() {
}
}

private static class FakeNameResolverProvider extends NameResolverProvider {
private final String scheme;
private final int port;
private URI targetUri;
private NameResolver.Args args;

public FakeNameResolverProvider(String scheme, int port) {
this.scheme = scheme;
this.port = port;
}

@Override
protected boolean isAvailable() {
return true;
}

@Override
protected int priority() {
return 0;
}

@Override
public NameResolver newNameResolver(URI targetUri, NameResolver.Args args) {
this.targetUri = targetUri;
this.args = args;
return new FakeNameResolver(port);
}

@Override
public String getDefaultScheme() {
return scheme;
}
}

private static class FakeNameResolver extends NameResolver {
private final int port;
Expand Down
4 changes: 4 additions & 0 deletions grpc/io.grpc/pom.xml
Expand Up @@ -32,6 +32,10 @@
<name>Helidon grpc-java Bundle</name>
<description>Bundle of grpc dependencies provided for backwards compatibility</description>

<properties>
<spotbugs.skip>true</spotbugs.skip>
</properties>

<dependencies>
<dependency>
<groupId>io.grpc</groupId>
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019, 2022 Oracle and/or its affiliates.
* Copyright (c) 2019, 2023 Oracle and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019, 2022 Oracle and/or its affiliates.
* Copyright (c) 2019, 2023 Oracle and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019, 2021 Oracle and/or its affiliates.
* Copyright (c) 2019, 2023 Oracle and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019, 2022 Oracle and/or its affiliates.
* Copyright (c) 2019, 2023 Oracle and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down

0 comments on commit 21a8004

Please sign in to comment.