• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2016 The gRPC Authors
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package io.grpc.testing.integration;
18 
19 import static io.grpc.testing.integration.TestCases.fromString;
20 import static org.junit.Assert.assertEquals;
21 
22 import java.util.HashSet;
23 import java.util.Set;
24 import org.junit.Test;
25 import org.junit.runner.RunWith;
26 import org.junit.runners.JUnit4;
27 
28 /**
29  * Unit tests for {@link TestCases}.
30  */
31 @RunWith(JUnit4.class)
32 public class TestCasesTest {
33 
34   @Test(expected = IllegalArgumentException.class)
unknownStringThrowsException()35   public void unknownStringThrowsException() {
36     fromString("does_not_exist_1234");
37   }
38 
39   @Test
testCaseNamesShouldMapToEnums()40   public void testCaseNamesShouldMapToEnums() {
41     // names of testcases as defined in the interop spec
42     String[] testCases = {
43       "empty_unary",
44       "cacheable_unary",
45       "large_unary",
46       "client_compressed_unary",
47       "server_compressed_unary",
48       "client_streaming",
49       "client_compressed_streaming",
50       "compute_engine_channel_credentials",
51       "server_streaming",
52       "server_compressed_streaming",
53       "ping_pong",
54       "empty_stream",
55       "compute_engine_creds",
56       "service_account_creds",
57       "jwt_token_creds",
58       "oauth2_auth_token",
59       "per_rpc_creds",
60       "google_default_credentials",
61       "custom_metadata",
62       "status_code_and_message",
63       "special_status_message",
64       "unimplemented_method",
65       "unimplemented_service",
66       "cancel_after_begin",
67       "cancel_after_first_response",
68       "timeout_on_sleeping_server",
69       "orca_per_rpc",
70       "orca_oob"
71     };
72 
73     // additional test cases
74     String[] additionalTestCases = {
75       "client_compressed_unary_noprobe",
76       "client_compressed_streaming_noprobe",
77       "very_large_request",
78       "pick_first_unary",
79       "channel_soak",
80       "rpc_soak"
81     };
82 
83     assertEquals(testCases.length + additionalTestCases.length, TestCases.values().length);
84 
85     Set<TestCases> testCaseSet = new HashSet<>(testCases.length);
86     for (String testCase : testCases) {
87       testCaseSet.add(TestCases.fromString(testCase));
88     }
89     for (String testCase : additionalTestCases) {
90       testCaseSet.add(TestCases.fromString(testCase));
91     }
92 
93     assertEquals(TestCases.values().length, testCaseSet.size());
94   }
95 }
96