Skip to content

Commit 7127b79

Browse files
author
Alexander Furer
committed
closes #93, gradle 4.10
1 parent db24208 commit 7127b79

File tree

17 files changed

+121
-92
lines changed

17 files changed

+121
-92
lines changed

gradle/wrapper/gradle-wrapper.jar

2.78 KB
Binary file not shown.
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
#Mon Mar 19 15:06:58 IST 2018
21
distributionBase=GRADLE_USER_HOME
32
distributionPath=wrapper/dists
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10-bin.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip

gradlew

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env bash
1+
#!/usr/bin/env sh
22

33
##############################################################################
44
##
@@ -33,11 +33,11 @@ DEFAULT_JVM_OPTS=""
3333
# Use the maximum available, or set MAX_FD != -1 to use that value.
3434
MAX_FD="maximum"
3535

36-
warn ( ) {
36+
warn () {
3737
echo "$*"
3838
}
3939

40-
die ( ) {
40+
die () {
4141
echo
4242
echo "$*"
4343
echo
@@ -154,11 +154,19 @@ if $cygwin ; then
154154
esac
155155
fi
156156

157-
# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
158-
function splitJvmOpts() {
159-
JVM_OPTS=("$@")
157+
# Escape application args
158+
save () {
159+
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
160+
echo " "
160161
}
161-
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
162-
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
162+
APP_ARGS=$(save "$@")
163163

164-
exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
164+
# Collect all arguments for the java command, following the shell quoting and substitution rules
165+
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
166+
167+
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
168+
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
169+
cd "$(dirname "$0")"
170+
fi
171+
172+
exec "$JAVACMD" "$@"

gradlew.bat

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ goto fail
4949
@rem Get command-line arguments, handling Windows variants
5050

5151
if not "%OS%" == "Windows_NT" goto win9xME_args
52-
if "%@eval[2+2]" == "4" goto 4NT_args
5352

5453
:win9xME_args
5554
@rem Slurp the command line arguments.
@@ -60,11 +59,6 @@ set _SKIP=2
6059
if "x%~1" == "x" goto execute
6160

6261
set CMD_LINE_ARGS=%*
63-
goto execute
64-
65-
:4NT_args
66-
@rem Get arguments from the 4NT Shell from JP Software
67-
set CMD_LINE_ARGS=%$
6862

6963
:execute
7064
@rem Setup the command line

grpc-spring-boot-starter-demo/src/main/protoGen/io/grpc/examples/CalculatorGrpc.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public static abstract class CalculatorImplBase implements io.grpc.BindableServi
7777
*/
7878
public void calculate(io.grpc.examples.CalculatorOuterClass.CalculatorRequest request,
7979
io.grpc.stub.StreamObserver<io.grpc.examples.CalculatorOuterClass.CalculatorResponse> responseObserver) {
80-
asyncUnimplementedUnaryCall(getCalculateMethod(), responseObserver);
80+
asyncUnimplementedUnaryCall(getCalculateMethod(), responseObserver);
8181
}
8282

8383
@java.lang.Override public final io.grpc.ServerServiceDefinition bindService() {

grpc-spring-boot-starter-demo/src/main/protoGen/io/grpc/examples/GreeterGrpc.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public static abstract class GreeterImplBase implements io.grpc.BindableService
8686
*/
8787
public void sayHello(io.grpc.examples.GreeterOuterClass.HelloRequest request,
8888
io.grpc.stub.StreamObserver<io.grpc.examples.GreeterOuterClass.HelloReply> responseObserver) {
89-
asyncUnimplementedUnaryCall(getSayHelloMethod(), responseObserver);
89+
asyncUnimplementedUnaryCall(getSayHelloMethod(), responseObserver);
9090
}
9191

9292
@java.lang.Override public final io.grpc.ServerServiceDefinition bindService() {
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package org.lognet.springboot.grpc;
2+
3+
import org.junit.Assert;
4+
import org.junit.runner.RunWith;
5+
import org.lognet.springboot.grpc.autoconfigure.GRpcServerProperties;
6+
import org.lognet.springboot.grpc.context.LocalRunningGrpcPort;
7+
import org.lognet.springboot.grpc.demo.DemoApp;
8+
import org.springframework.boot.test.context.SpringBootTest;
9+
import org.springframework.test.context.junit4.SpringRunner;
10+
11+
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.NONE;
12+
13+
@RunWith(SpringRunner.class)
14+
@SpringBootTest(classes = {DemoApp.class}, webEnvironment = NONE)
15+
public class DefaultGrpcPortTest extends GrpcServerTestBase {
16+
@LocalRunningGrpcPort
17+
int runningPort;
18+
19+
@Override
20+
protected int getPort() {
21+
return runningPort;
22+
}
23+
24+
@Override
25+
protected void beforeGreeting() {
26+
Assert.assertEquals(0, gRpcServerProperties.getPort());
27+
Assert.assertEquals(GRpcServerProperties.DEFAULT_GRPC_PORT, runningPort);
28+
}
29+
}

grpc-spring-boot-starter-demo/src/test/java/org/lognet/springboot/grpc/DemoAppTest.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,10 @@
4343
* Created by alexf on 28-Jan-16.
4444
*/
4545
@RunWith(SpringRunner.class)
46-
@SpringBootTest(classes = {DemoApp.class,TestConfig.class}, webEnvironment = RANDOM_PORT, properties = "grpc.enableReflection=true")
46+
@SpringBootTest(classes = {DemoApp.class, TestConfig.class}, webEnvironment = RANDOM_PORT
47+
, properties = {"grpc.enableReflection=true",
48+
"grpc.port=0"
49+
})
4750
public class DemoAppTest extends GrpcServerTestBase{
4851

4952
@Autowired

grpc-spring-boot-starter-demo/src/test/java/org/lognet/springboot/grpc/GrpcServerTestBase.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import org.junit.Before;
1010
import org.junit.Test;
1111
import org.lognet.springboot.grpc.autoconfigure.GRpcServerProperties;
12+
import org.lognet.springboot.grpc.context.LocalRunningGrpcPort;
1213
import org.springframework.beans.factory.annotation.Autowired;
1314
import org.springframework.beans.factory.annotation.Qualifier;
1415
import org.springframework.context.ApplicationContext;
@@ -34,6 +35,9 @@ public abstract class GrpcServerTestBase {
3435
protected ManagedChannel channel;
3536
protected ManagedChannel inProcChannel;
3637

38+
@LocalRunningGrpcPort
39+
int runningPort;
40+
3741
@Autowired
3842
protected ApplicationContext context;
3943

@@ -56,7 +60,7 @@ public final void setupChannels() {
5660
}
5761
}
5862
protected int getPort(){
59-
return gRpcServerProperties.getPort();
63+
return runningPort;
6064
}
6165

6266
protected ManagedChannelBuilder<?> onChannelBuild(ManagedChannelBuilder<?> channelBuilder){

grpc-spring-boot-starter-demo/src/test/java/org/lognet/springboot/grpc/OrderedInterceptorsTest.java

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
package org.lognet.springboot.grpc;
22

3-
import io.grpc.*;
3+
import io.grpc.Metadata;
4+
import io.grpc.ServerCall;
45
import io.grpc.ServerCall.Listener;
5-
import io.grpc.examples.GreeterGrpc;
6-
import io.grpc.examples.GreeterGrpc.GreeterBlockingStub;
7-
import io.grpc.examples.GreeterOuterClass;
8-
import org.junit.After;
6+
import io.grpc.ServerCallHandler;
7+
import io.grpc.ServerInterceptor;
8+
import org.junit.Assert;
99
import org.junit.Before;
10-
import org.junit.Test;
1110
import org.junit.runner.RunWith;
1211
import org.lognet.springboot.grpc.OrderedInterceptorsTest.TheConfiguration;
12+
import org.lognet.springboot.grpc.context.LocalRunningGrpcPort;
1313
import org.lognet.springboot.grpc.demo.DemoApp;
1414
import org.springframework.boot.test.context.SpringBootTest;
1515
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
@@ -33,6 +33,8 @@
3333
webEnvironment = WebEnvironment.NONE, properties = "grpc.port=7778")
3434
public class OrderedInterceptorsTest extends GrpcServerTestBase{
3535

36+
@LocalRunningGrpcPort
37+
int runningPort;
3638

3739
private static List<Integer> calledInterceptors = new ArrayList<>();
3840

@@ -43,6 +45,11 @@ public void setup() {
4345
calledInterceptors.clear();
4446
}
4547

48+
@Override
49+
protected void beforeGreeting() {
50+
Assert.assertEquals(7778, runningPort);
51+
Assert.assertEquals(getPort(), runningPort);
52+
}
4653

4754
@Override
4855
protected void afterGreeting() {

0 commit comments

Comments
 (0)