18bced3e769d315a0a81b89de7a5282f1a85acbf7Neil Fuller/*
28bced3e769d315a0a81b89de7a5282f1a85acbf7Neil Fuller *  Licensed to the Apache Software Foundation (ASF) under one or more
38bced3e769d315a0a81b89de7a5282f1a85acbf7Neil Fuller *  contributor license agreements.  See the NOTICE file distributed with
48bced3e769d315a0a81b89de7a5282f1a85acbf7Neil Fuller *  this work for additional information regarding copyright ownership.
58bced3e769d315a0a81b89de7a5282f1a85acbf7Neil Fuller *  The ASF licenses this file to You under the Apache License, Version 2.0
68bced3e769d315a0a81b89de7a5282f1a85acbf7Neil Fuller *  (the "License"); you may not use this file except in compliance with
78bced3e769d315a0a81b89de7a5282f1a85acbf7Neil Fuller *  the License.  You may obtain a copy of the License at
88bced3e769d315a0a81b89de7a5282f1a85acbf7Neil Fuller *
98bced3e769d315a0a81b89de7a5282f1a85acbf7Neil Fuller *     http://www.apache.org/licenses/LICENSE-2.0
108bced3e769d315a0a81b89de7a5282f1a85acbf7Neil Fuller *
118bced3e769d315a0a81b89de7a5282f1a85acbf7Neil Fuller *  Unless required by applicable law or agreed to in writing, software
128bced3e769d315a0a81b89de7a5282f1a85acbf7Neil Fuller *  distributed under the License is distributed on an "AS IS" BASIS,
138bced3e769d315a0a81b89de7a5282f1a85acbf7Neil Fuller *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
148bced3e769d315a0a81b89de7a5282f1a85acbf7Neil Fuller *  See the License for the specific language governing permissions and
158bced3e769d315a0a81b89de7a5282f1a85acbf7Neil Fuller *  limitations under the License.
168bced3e769d315a0a81b89de7a5282f1a85acbf7Neil Fuller */
178bced3e769d315a0a81b89de7a5282f1a85acbf7Neil Fuller
188bced3e769d315a0a81b89de7a5282f1a85acbf7Neil Fullerpackage com.squareup.okhttp;
198bced3e769d315a0a81b89de7a5282f1a85acbf7Neil Fuller
208bced3e769d315a0a81b89de7a5282f1a85acbf7Neil Fullerimport org.junit.Before;
218bced3e769d315a0a81b89de7a5282f1a85acbf7Neil Fullerimport org.junit.Test;
228bced3e769d315a0a81b89de7a5282f1a85acbf7Neil Fuller
238bced3e769d315a0a81b89de7a5282f1a85acbf7Neil Fullerimport libcore.net.event.NetworkEventDispatcher;
248bced3e769d315a0a81b89de7a5282f1a85acbf7Neil Fuller
258bced3e769d315a0a81b89de7a5282f1a85acbf7Neil Fullerimport static org.junit.Assert.assertNotSame;
268bced3e769d315a0a81b89de7a5282f1a85acbf7Neil Fullerimport static org.junit.Assert.assertSame;
278bced3e769d315a0a81b89de7a5282f1a85acbf7Neil Fuller
288bced3e769d315a0a81b89de7a5282f1a85acbf7Neil Fuller/**
298bced3e769d315a0a81b89de7a5282f1a85acbf7Neil Fuller * Tests for {@link ConfigAwareConnectionPool}.
308bced3e769d315a0a81b89de7a5282f1a85acbf7Neil Fuller */
318bced3e769d315a0a81b89de7a5282f1a85acbf7Neil Fullerpublic class ConfigAwareConnectionPoolTest {
328bced3e769d315a0a81b89de7a5282f1a85acbf7Neil Fuller
338bced3e769d315a0a81b89de7a5282f1a85acbf7Neil Fuller  @Test
348bced3e769d315a0a81b89de7a5282f1a85acbf7Neil Fuller  public void getInstance() {
358bced3e769d315a0a81b89de7a5282f1a85acbf7Neil Fuller    assertSame(ConfigAwareConnectionPool.getInstance(), ConfigAwareConnectionPool.getInstance());
368bced3e769d315a0a81b89de7a5282f1a85acbf7Neil Fuller  }
378bced3e769d315a0a81b89de7a5282f1a85acbf7Neil Fuller
388bced3e769d315a0a81b89de7a5282f1a85acbf7Neil Fuller  @Test
398bced3e769d315a0a81b89de7a5282f1a85acbf7Neil Fuller  public void get() throws Exception {
408bced3e769d315a0a81b89de7a5282f1a85acbf7Neil Fuller    NetworkEventDispatcher networkEventDispatcher = new NetworkEventDispatcher() {};
418bced3e769d315a0a81b89de7a5282f1a85acbf7Neil Fuller    ConfigAwareConnectionPool instance = new ConfigAwareConnectionPool(networkEventDispatcher) {};
428bced3e769d315a0a81b89de7a5282f1a85acbf7Neil Fuller    assertSame(instance.get(), instance.get());
438bced3e769d315a0a81b89de7a5282f1a85acbf7Neil Fuller
448bced3e769d315a0a81b89de7a5282f1a85acbf7Neil Fuller    ConnectionPool beforeEventInstance = instance.get();
458bced3e769d315a0a81b89de7a5282f1a85acbf7Neil Fuller    networkEventDispatcher.onNetworkConfigurationChanged();
468bced3e769d315a0a81b89de7a5282f1a85acbf7Neil Fuller
478bced3e769d315a0a81b89de7a5282f1a85acbf7Neil Fuller    assertNotSame(beforeEventInstance, instance.get());
488bced3e769d315a0a81b89de7a5282f1a85acbf7Neil Fuller  }
498bced3e769d315a0a81b89de7a5282f1a85acbf7Neil Fuller}
50