Skip to content

Commit

Permalink
Keep tests for channelz and binlog implementations, as they are kept …
Browse files Browse the repository at this point in the history
…in-place.
  • Loading branch information
voidzcy committed Apr 14, 2021
1 parent 15fb5fc commit 851628c
Show file tree
Hide file tree
Showing 9 changed files with 3,553 additions and 2 deletions.
2 changes: 1 addition & 1 deletion services/src/main/java/io/grpc/services/BinlogHelper.java
Expand Up @@ -19,7 +19,7 @@
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Preconditions.checkState;
import static io.grpc.protobuf.services.BinaryLogProvider.BYTEARRAY_MARSHALLER;
import static io.grpc.services.BinaryLogProvider.BYTEARRAY_MARSHALLER;

import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Charsets;
Expand Down
Expand Up @@ -91,4 +91,4 @@ private static String hextetsToIPv6String(int[] hextets) {
}
return buf.toString();
}
}
}
@@ -0,0 +1,57 @@
/*
* Copyright 2018 The gRPC Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package io.grpc.services;

import static org.junit.Assert.assertNull;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;

import io.grpc.CallOptions;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;

/** Tests for {@link BinaryLogProviderImpl}. */
@SuppressWarnings("deprecation")
@RunWith(JUnit4.class)
public class BinaryLogProviderImplTest {
@Test
public void configStrNullTest() throws Exception {
BinaryLogSink sink = mock(BinaryLogSink.class);
BinaryLogProviderImpl binlog = new BinaryLogProviderImpl(sink, /*configStr=*/ null);
assertNull(binlog.getServerInterceptor("package.service/method"));
assertNull(binlog.getClientInterceptor("package.service/method", CallOptions.DEFAULT));
}

@Test
public void configStrEmptyTest() throws Exception {
BinaryLogSink sink = mock(BinaryLogSink.class);
BinaryLogProviderImpl binlog = new BinaryLogProviderImpl(sink, "");
assertNull(binlog.getServerInterceptor("package.service/method"));
assertNull(binlog.getClientInterceptor("package.service/method", CallOptions.DEFAULT));
}

@Test
public void closeTest() throws Exception {
BinaryLogSink sink = mock(BinaryLogSink.class);
BinaryLogProviderImpl log = new BinaryLogProviderImpl(sink, "*");
verify(sink, never()).close();
log.close();
verify(sink).close();
}
}

0 comments on commit 851628c

Please sign in to comment.