Home | History | Annotate | Download | only in integration
      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)
     35   public void unknownStringThrowsException() {
     36     fromString("does_not_exist_1234");
     37   }
     38 
     39   @Test
     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       "server_streaming",
     51       "server_compressed_streaming",
     52       "ping_pong",
     53       "empty_stream",
     54       "compute_engine_creds",
     55       "service_account_creds",
     56       "jwt_token_creds",
     57       "oauth2_auth_token",
     58       "per_rpc_creds",
     59       "custom_metadata",
     60       "status_code_and_message",
     61       "special_status_message",
     62       "unimplemented_method",
     63       "unimplemented_service",
     64       "cancel_after_begin",
     65       "cancel_after_first_response",
     66       "timeout_on_sleeping_server"
     67     };
     68 
     69     // additional test cases
     70     String[] additionalTestCases = {
     71       "client_compressed_unary_noprobe",
     72       "client_compressed_streaming_noprobe",
     73       "very_large_request"
     74     };
     75 
     76     assertEquals(testCases.length + additionalTestCases.length, TestCases.values().length);
     77 
     78     Set<TestCases> testCaseSet = new HashSet<TestCases>(testCases.length);
     79     for (String testCase : testCases) {
     80       testCaseSet.add(TestCases.fromString(testCase));
     81     }
     82     for (String testCase : additionalTestCases) {
     83       testCaseSet.add(TestCases.fromString(testCase));
     84     }
     85 
     86     assertEquals(TestCases.values().length, testCaseSet.size());
     87   }
     88 }
     89