Skip to content

Commit 5a824b8

Browse files
authored
Merge pull request #88 from salesforce/bugfix/jprotoc-filename
Fix invalid character handling in proto file names
2 parents 32c2081 + 9a0eab3 commit 5a824b8

File tree

12 files changed

+203
-6
lines changed

12 files changed

+203
-6
lines changed

jprotoc-test/src/test/java/com/salesforce/jprotoc/CompletableFutureEndToEndTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
import java.util.concurrent.TimeUnit;
2222
import java.util.concurrent.TimeoutException;
2323

24+
import com.salesforce.jprotoc.HelloWorldProto.*;
25+
2426
import static org.awaitility.Awaitility.await;
2527

2628
@SuppressWarnings("ALL")

jprotoc-test/src/test/java/com/salesforce/jprotoc/Jdk8GeneratorStructureTest.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
import java.lang.reflect.Method;
1515
import java.lang.reflect.Modifier;
1616

17+
import com.salesforce.jprotoc.HelloWorldProto.*;
18+
1719
import static org.junit.Assert.*;
1820

1921
/**
@@ -63,7 +65,7 @@ public void GeneratedStubClassDerivesFromAbstractStub() throws Exception {
6365
public void GeneratedStubSubclassHasExpectedMethods() throws Exception {
6466
Class<?> clazz = Class.forName("com.salesforce.jprotoc.GreeterGrpc8$GreeterCompletableFutureStub");
6567

66-
Method method = clazz.getMethod("sayHello", com.salesforce.jprotoc.HelloRequest.class);
68+
Method method = clazz.getMethod("sayHello", HelloRequest.class);
6769
assertNotNull(method);
6870
assertTrue(Modifier.isPublic(method.getModifiers()));
6971
assertEquals("CompletableFuture", method.getReturnType().getSimpleName());
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
package com.salesforce.jprotoc;
2+
3+
import com.example.v2.FrontendGrpc8;
4+
import my.someparameters.SomeParameterOuterClass;
5+
import nested.NestedGrpc8;
6+
import nested.NestedOuterClass;
7+
import org.junit.Test;
8+
9+
import static org.assertj.core.api.Assertions.assertThat;
10+
11+
/**
12+
* This test verifies the existence of generated proto stubs. If generation is successful, the classes will be
13+
* present to compile against.
14+
*/
15+
public class ProtoGenerationPresenceTest {
16+
@Test
17+
public void greeterGrpc8Exists() {
18+
assertThat(GreeterGrpc8.class).isNotNull();
19+
}
20+
21+
@Test
22+
public void someParameterExists() {
23+
assertThat(SomeParameterOuterClass.SomeParameter.class).isNotNull();
24+
}
25+
26+
@Test
27+
public void frontendGrpc8Exists() {
28+
assertThat(FrontendGrpc8.class).isNotNull();
29+
}
30+
31+
@Test
32+
public void nestedGrpc8Exists() {
33+
assertThat(NestedGrpc8.class).isNotNull();
34+
assertThat(NestedOuterClass.Outer.MiddleAA.Inner.class).isNotNull();
35+
assertThat(NestedOuterClass.Outer.MiddleBB.Inner.class).isNotNull();
36+
}
37+
38+
@Test
39+
public void currentTimeGrpc8Exists() {
40+
assertThat(com.salesforce.invalid.dollar.CurrentTimeGrpc8.class).isNotNull();
41+
assertThat(com.salesforce.invalid.plus.CurrentTimeGrpc8.class).isNotNull();
42+
assertThat(com.salesforce.invalid.dot.CurrentTimeGrpc8.class).isNotNull();
43+
assertThat(com.salesforce.invalid.number.CurrentTimeGrpc8.class).isNotNull();
44+
assertThat(com.salesforce.invalid.dash.CurrentTimeGrpc8.class).isNotNull();
45+
assertThat(com.salesforce.invalid.underscore.CurrentTimeGrpc8.class).isNotNull();
46+
assertThat(com.salesforce.invalid.enye.CurrentTimeGrpc8.class).isNotNull();
47+
}
48+
}

jprotoc-test/src/test/proto/helloworld.proto

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import "google/protobuf/empty.proto";
66
import "google/protobuf/timestamp.proto";
77
import "some_parameter.proto";
88

9-
option java_multiple_files = true;
109
option java_package = "com.salesforce.jprotoc";
1110
option java_outer_classname = "HelloWorldProto";
1211

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
syntax = "proto3";
2+
3+
package com.salesforce.invalid.dollar;
4+
5+
import "google/protobuf/empty.proto";
6+
import "google/protobuf/timestamp.proto";
7+
8+
// The time - as a service.
9+
service CurrentTime {
10+
// Sends the current time
11+
rpc SayTime (google.protobuf.Empty) returns (TimeResponse) {}
12+
}
13+
14+
// The response message containing the time
15+
message TimeResponse {
16+
google.protobuf.Timestamp time = 1;
17+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
syntax = "proto3";
2+
3+
package com.salesforce.invalid.plus;
4+
5+
import "google/protobuf/empty.proto";
6+
import "google/protobuf/timestamp.proto";
7+
8+
// The time - as a service.
9+
service CurrentTime {
10+
// Sends the current time
11+
rpc SayTime (google.protobuf.Empty) returns (TimeResponse) {}
12+
}
13+
14+
// The response message containing the time
15+
message TimeResponse {
16+
google.protobuf.Timestamp time = 1;
17+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
syntax = "proto3";
2+
3+
package com.salesforce.invalid.dash;
4+
5+
import "google/protobuf/empty.proto";
6+
import "google/protobuf/timestamp.proto";
7+
8+
// The time - as a service.
9+
service CurrentTime {
10+
// Sends the current time
11+
rpc SayTime (google.protobuf.Empty) returns (TimeResponse) {}
12+
}
13+
14+
// The response message containing the time
15+
message TimeResponse {
16+
google.protobuf.Timestamp time = 1;
17+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
syntax = "proto3";
2+
3+
package com.salesforce.invalid.dot;
4+
5+
import "google/protobuf/empty.proto";
6+
import "google/protobuf/timestamp.proto";
7+
8+
// The time - as a service.
9+
service CurrentTime {
10+
// Sends the current time
11+
rpc SayTime (google.protobuf.Empty) returns (TimeResponse) {}
12+
}
13+
14+
// The response message containing the time
15+
message TimeResponse {
16+
google.protobuf.Timestamp time = 1;
17+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
syntax = "proto3";
2+
3+
package com.salesforce.invalid.number;
4+
5+
import "google/protobuf/empty.proto";
6+
import "google/protobuf/timestamp.proto";
7+
8+
// The time - as a service.
9+
service CurrentTime {
10+
// Sends the current time
11+
rpc SayTime (google.protobuf.Empty) returns (TimeResponse) {}
12+
}
13+
14+
// The response message containing the time
15+
message TimeResponse {
16+
google.protobuf.Timestamp time = 1;
17+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
syntax = "proto3";
2+
3+
package com.salesforce.invalid.underscore;
4+
5+
import "google/protobuf/empty.proto";
6+
import "google/protobuf/timestamp.proto";
7+
8+
// The time - as a service.
9+
service CurrentTime {
10+
// Sends the current time
11+
rpc SayTime (google.protobuf.Empty) returns (TimeResponse) {}
12+
}
13+
14+
// The response message containing the time
15+
message TimeResponse {
16+
google.protobuf.Timestamp time = 1;
17+
}

0 commit comments

Comments
 (0)