Home | History | Annotate | Download | only in net
      1 /* Licensed to the Apache Software Foundation (ASF) under one or more
      2  * contributor license agreements.  See the NOTICE file distributed with
      3  * this work for additional information regarding copyright ownership.
      4  * The ASF licenses this file to You under the Apache License, Version 2.0
      5  * (the "License"); you may not use this file except in compliance with
      6  * the License.  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 org.apache.harmony.luni.tests.java.net;
     18 
     19 import java.io.IOException;
     20 import java.net.CacheRequest;
     21 import java.net.CacheResponse;
     22 import java.net.NetPermission;
     23 import java.net.ResponseCache;
     24 import java.net.URI;
     25 import java.net.URLConnection;
     26 import java.security.Permission;
     27 import java.util.Map;
     28 
     29 import junit.framework.TestCase;
     30 
     31 public class ResponseCacheTest extends TestCase {
     32 
     33 	/**
     34 	 * @tests java.net.ResponseCache#getDefault()
     35 	 */
     36 	public void test_GetDefault() throws Exception {
     37 		assertNull(ResponseCache.getDefault());
     38 	}
     39 
     40 	/**
     41 	 * @tests java.net.ResponseCache#setDefault(ResponseCache)
     42 	 */
     43 	public void test_SetDefaultLjava_net_ResponseCache_Normal()
     44 			throws Exception {
     45 		ResponseCache rc1 = new MockResponseCache();
     46 		ResponseCache rc2 = new MockResponseCache();
     47 		ResponseCache.setDefault(rc1);
     48 		assertSame(ResponseCache.getDefault(), rc1);
     49 		ResponseCache.setDefault(rc2);
     50 		assertSame(ResponseCache.getDefault(), rc2);
     51 		ResponseCache.setDefault(null);
     52 		assertNull(ResponseCache.getDefault());
     53 	}
     54 
     55 	/*
     56 	 * MockResponseCache for testSetDefault(ResponseCache)
     57 	 */
     58 	class MockResponseCache extends ResponseCache {
     59 
     60 		public CacheResponse get(URI arg0, String arg1, Map arg2)
     61 				throws IOException {
     62 			return null;
     63 		}
     64 
     65 		public CacheRequest put(URI arg0, URLConnection arg1)
     66 				throws IOException {
     67 			return null;
     68 		}
     69 	}
     70 }
     71