// Path: google-cloud-core-grpc/src/main/java/com/google/cloud/grpc/GrpcTransportOptions.java
// @InternalApi
// public static class DefaultExecutorFactory implements ExecutorFactory<ScheduledExecutorService> {
// 
//   private static final DefaultExecutorFactory INSTANCE = new DefaultExecutorFactory();
// 
//   @Override
//   public ScheduledExecutorService get() {
//     return SharedResourceHolder.get(EXECUTOR);
//   }
// 
//   @Override
//   public synchronized void release(ScheduledExecutorService executor) {
//     SharedResourceHolder.release(EXECUTOR, executor);
//   }
// }
// 
// Path: google-cloud-core-grpc/src/main/java/com/google/cloud/grpc/GrpcTransportOptions.java
// public interface ExecutorFactory<T extends ExecutorService> {
// 
//   /** Gets an executor service instance. */
//   T get();
// 
//   /** Releases resources used by the executor and possibly shuts it down. */
//   void release(T executor);
// }


import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
import com.google.cloud.grpc.GrpcTransportOptions.DefaultExecutorFactory;
import com.google.cloud.grpc.GrpcTransportOptions.ExecutorFactory;
import java.util.concurrent.ScheduledExecutorService;
import org.easymock.EasyMock;
import org.junit.Test;
/*
 * Copyright 2016 Google LLC
 *
 * 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 com.google.cloud.grpc;



public class GrpcTransportOptionsTest {

  private static final ExecutorFactory MOCK_EXECUTOR_FACTORY =
      EasyMock.createMock(ExecutorFactory.class);
  private static final GrpcTransportOptions OPTIONS =
      GrpcTransportOptions.newBuilder().setExecutorFactory(MOCK_EXECUTOR_FACTORY).build();
  private static final GrpcTransportOptions DEFAULT_OPTIONS =
      GrpcTransportOptions.newBuilder().build();
  private static final GrpcTransportOptions OPTIONS_COPY = OPTIONS.toBuilder().build();

  @Test
  public void testBuilder() {
    assertSame(MOCK_EXECUTOR_FACTORY, OPTIONS.getExecutorFactory());
// Path: google-cloud-core-grpc/src/main/java/com/google/cloud/grpc/GrpcTransportOptions.java
// @InternalApi
// public static class DefaultExecutorFactory implements ExecutorFactory<ScheduledExecutorService> {
// 
//   private static final DefaultExecutorFactory INSTANCE = new DefaultExecutorFactory();
// 
//   @Override
//   public ScheduledExecutorService get() {
//     return SharedResourceHolder.get(EXECUTOR);
//   }
// 
//   @Override
//   public synchronized void release(ScheduledExecutorService executor) {
//     SharedResourceHolder.release(EXECUTOR, executor);
//   }
// }
// 
// Path: google-cloud-core-grpc/src/main/java/com/google/cloud/grpc/GrpcTransportOptions.java
// public interface ExecutorFactory<T extends ExecutorService> {
// 
//   /** Gets an executor service instance. */
//   T get();
// 
//   /** Releases resources used by the executor and possibly shuts it down. */
//   void release(T executor);
// }


// Path: google-cloud-core-grpc/src/test/java/com/google/cloud/grpc/GrpcTransportOptionsTest.java
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
import com.google.cloud.grpc.GrpcTransportOptions.DefaultExecutorFactory;
import com.google.cloud.grpc.GrpcTransportOptions.ExecutorFactory;
import java.util.concurrent.ScheduledExecutorService;
import org.easymock.EasyMock;
import org.junit.Test;

/*
 * Copyright 2016 Google LLC
 *
 * 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 com.google.cloud.grpc;



public class GrpcTransportOptionsTest {

  private static final ExecutorFactory MOCK_EXECUTOR_FACTORY =
      EasyMock.createMock(ExecutorFactory.class);
  private static final GrpcTransportOptions OPTIONS =
      GrpcTransportOptions.newBuilder().setExecutorFactory(MOCK_EXECUTOR_FACTORY).build();
  private static final GrpcTransportOptions DEFAULT_OPTIONS =
      GrpcTransportOptions.newBuilder().build();
  private static final GrpcTransportOptions OPTIONS_COPY = OPTIONS.toBuilder().build();

  @Test
  public void testBuilder() {
    assertSame(MOCK_EXECUTOR_FACTORY, OPTIONS.getExecutorFactory());
    assertTrue(DEFAULT_OPTIONS.getExecutorFactory() instanceof DefaultExecutorFactory);