DO NOT MERGE ANYWHERE.
Revert "DO NOT MERGE ANYWHERE." This reverts commit b7c798f9b84c7c100aa37e6aa77e7f31460c7bd7, reversing changes made to 4e8ecc32db5d3a17ccec099681425c34b630d23b.
This commit is contained in:
@@ -26,15 +26,15 @@ LOCAL_MULTILIB := both
|
|||||||
|
|
||||||
LOCAL_JAVA_LIBRARIES := voip-common conscrypt
|
LOCAL_JAVA_LIBRARIES := voip-common conscrypt
|
||||||
|
|
||||||
LOCAL_JNI_SHARED_LIBRARIES := libcts_jni libnativedns_jni
|
LOCAL_JNI_SHARED_LIBRARIES := libnativedns_jni
|
||||||
|
|
||||||
# include CtsTestServer as a temporary hack to free net.cts from cts.stub.
|
# include CtsTestServer as a temporary hack to free net.cts from cts.stub.
|
||||||
LOCAL_SRC_FILES := $(call all-java-files-under, src)
|
LOCAL_SRC_FILES := $(call all-java-files-under, src)
|
||||||
|
|
||||||
LOCAL_PACKAGE_NAME := CtsNetTestCases
|
LOCAL_PACKAGE_NAME := CtsNetTestCases
|
||||||
|
|
||||||
LOCAL_STATIC_JAVA_LIBRARIES := core-tests-support ctsdeviceutil \
|
LOCAL_STATIC_JAVA_LIBRARIES := ctstestserver ctsdeviceutil ctstestrunner \
|
||||||
ctstestrunner ctstestserver mockwebserver
|
core-tests-support
|
||||||
|
|
||||||
# uncomment when b/13249961 is fixed
|
# uncomment when b/13249961 is fixed
|
||||||
#LOCAL_SDK_VERSION := current
|
#LOCAL_SDK_VERSION := current
|
||||||
|
|||||||
@@ -18,7 +18,6 @@
|
|||||||
#include <jni.h>
|
#include <jni.h>
|
||||||
#include <netdb.h>
|
#include <netdb.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
|
||||||
#include <utils/Log.h>
|
#include <utils/Log.h>
|
||||||
|
|
||||||
const char *GoogleDNSIpV4Address="8.8.8.8";
|
const char *GoogleDNSIpV4Address="8.8.8.8";
|
||||||
|
|||||||
@@ -126,8 +126,8 @@ public class LocalSocketTest extends AndroidTestCase{
|
|||||||
socket.setReceiveBufferSize(1999);
|
socket.setReceiveBufferSize(1999);
|
||||||
assertEquals(1999 << 1, socket.getReceiveBufferSize());
|
assertEquals(1999 << 1, socket.getReceiveBufferSize());
|
||||||
|
|
||||||
socket.setSendBufferSize(3998);
|
socket.setSendBufferSize(1998);
|
||||||
assertEquals(3998 << 1, socket.getSendBufferSize());
|
assertEquals(1998 << 1, socket.getSendBufferSize());
|
||||||
|
|
||||||
// Timeout is not support at present, so set is ignored
|
// Timeout is not support at present, so set is ignored
|
||||||
socket.setSoTimeout(1996);
|
socket.setSoTimeout(1996);
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ import javax.net.ssl.SSLPeerUnverifiedException;
|
|||||||
import android.net.SSLCertificateSocketFactory;
|
import android.net.SSLCertificateSocketFactory;
|
||||||
import android.test.AndroidTestCase;
|
import android.test.AndroidTestCase;
|
||||||
|
|
||||||
import libcore.javax.net.ssl.SSLConfigurationAsserts;
|
import libcore.javax.net.ssl.SSLDefaultConfigurationAsserts;
|
||||||
|
|
||||||
public class SSLCertificateSocketFactoryTest extends AndroidTestCase {
|
public class SSLCertificateSocketFactoryTest extends AndroidTestCase {
|
||||||
private SSLCertificateSocketFactory mFactory;
|
private SSLCertificateSocketFactory mFactory;
|
||||||
@@ -40,7 +40,7 @@ public class SSLCertificateSocketFactoryTest extends AndroidTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void testDefaultConfiguration() throws Exception {
|
public void testDefaultConfiguration() throws Exception {
|
||||||
SSLConfigurationAsserts.assertSSLSocketFactoryDefaultConfiguration(mFactory);
|
SSLDefaultConfigurationAsserts.assertSSLSocketFactory(mFactory);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testAccessProperties() throws Exception {
|
public void testAccessProperties() throws Exception {
|
||||||
|
|||||||
@@ -1,158 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2011 The Android Open Source Project
|
|
||||||
*
|
|
||||||
* 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 android.net.http.cts;
|
|
||||||
|
|
||||||
import com.google.mockwebserver.MockResponse;
|
|
||||||
import com.google.mockwebserver.MockWebServer;
|
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
|
||||||
|
|
||||||
import android.cts.util.FileUtils;
|
|
||||||
import android.net.http.HttpResponseCache;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.net.CacheRequest;
|
|
||||||
import java.net.CacheResponse;
|
|
||||||
import java.net.ResponseCache;
|
|
||||||
import java.net.URI;
|
|
||||||
import java.net.URLConnection;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
public final class HttpResponseCacheTest extends TestCase {
|
|
||||||
|
|
||||||
private File cacheDir;
|
|
||||||
private MockWebServer server = new MockWebServer();
|
|
||||||
|
|
||||||
@Override public void setUp() throws Exception {
|
|
||||||
super.setUp();
|
|
||||||
String tmp = System.getProperty("java.io.tmpdir");
|
|
||||||
cacheDir = new File(tmp, "HttpCache-" + UUID.randomUUID());
|
|
||||||
cacheDir.mkdirs();
|
|
||||||
// Make the cache directory read / writable.
|
|
||||||
FileUtils.setPermissions(cacheDir.getPath(), 0777);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override protected void tearDown() throws Exception {
|
|
||||||
ResponseCache.setDefault(null);
|
|
||||||
server.shutdown();
|
|
||||||
super.tearDown();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testInstall() throws Exception {
|
|
||||||
HttpResponseCache installed = HttpResponseCache.install(cacheDir, 10 * 1024 * 1024);
|
|
||||||
assertNotNull(installed);
|
|
||||||
assertSame(installed, ResponseCache.getDefault());
|
|
||||||
assertSame(installed, HttpResponseCache.getDefault());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testSecondEquivalentInstallDoesNothing() throws Exception {
|
|
||||||
HttpResponseCache first = HttpResponseCache.install(cacheDir, 10 * 1024 * 1024);
|
|
||||||
HttpResponseCache another = HttpResponseCache.install(cacheDir, 10 * 1024 * 1024);
|
|
||||||
assertSame(first, another);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testInstallClosesPreviouslyInstalled() throws Exception {
|
|
||||||
HttpResponseCache first = HttpResponseCache.install(cacheDir, 10 * 1024 * 1024);
|
|
||||||
initializeCache(first);
|
|
||||||
|
|
||||||
HttpResponseCache another = HttpResponseCache.install(cacheDir, 8 * 1024 * 1024);
|
|
||||||
initializeCache(first);
|
|
||||||
|
|
||||||
assertNotSame(first, another);
|
|
||||||
try {
|
|
||||||
first.flush();
|
|
||||||
fail();
|
|
||||||
} catch (IllegalStateException expected) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testGetInstalledWithWrongTypeInstalled() {
|
|
||||||
ResponseCache.setDefault(new ResponseCache() {
|
|
||||||
@Override public CacheResponse get(URI uri, String requestMethod,
|
|
||||||
Map<String, List<String>> requestHeaders) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
@Override public CacheRequest put(URI uri, URLConnection connection) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
assertNull(HttpResponseCache.getInstalled());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testCloseCloses() throws Exception {
|
|
||||||
HttpResponseCache cache = HttpResponseCache.install(cacheDir, 10 * 1024 * 1024);
|
|
||||||
initializeCache(cache);
|
|
||||||
|
|
||||||
cache.close();
|
|
||||||
try {
|
|
||||||
cache.flush();
|
|
||||||
fail();
|
|
||||||
} catch (IllegalStateException expected) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testCloseUninstalls() throws Exception {
|
|
||||||
HttpResponseCache cache = HttpResponseCache.install(cacheDir, 10 * 1024 * 1024);
|
|
||||||
cache.close();
|
|
||||||
assertNull(ResponseCache.getDefault());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testDeleteUninstalls() throws Exception {
|
|
||||||
HttpResponseCache cache = HttpResponseCache.install(cacheDir, 10 * 1024 * 1024);
|
|
||||||
cache.delete();
|
|
||||||
assertNull(ResponseCache.getDefault());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Make sure that statistics tracking are wired all the way through the
|
|
||||||
* wrapper class. http://code.google.com/p/android/issues/detail?id=25418
|
|
||||||
*/
|
|
||||||
public void testStatisticsTracking() throws Exception {
|
|
||||||
HttpResponseCache cache = HttpResponseCache.install(cacheDir, 10 * 1024 * 1024);
|
|
||||||
|
|
||||||
server.enqueue(new MockResponse()
|
|
||||||
.addHeader("Cache-Control: max-age=60")
|
|
||||||
.setBody("A"));
|
|
||||||
server.play();
|
|
||||||
|
|
||||||
URLConnection c1 = server.getUrl("/").openConnection();
|
|
||||||
InputStream inputStream1 = c1.getInputStream();
|
|
||||||
assertEquals('A', inputStream1.read());
|
|
||||||
inputStream1.close();
|
|
||||||
|
|
||||||
assertEquals(1, cache.getRequestCount());
|
|
||||||
assertEquals(1, cache.getNetworkCount());
|
|
||||||
assertEquals(0, cache.getHitCount());
|
|
||||||
|
|
||||||
URLConnection c2 = server.getUrl("/").openConnection();
|
|
||||||
assertEquals('A', c2.getInputStream().read());
|
|
||||||
|
|
||||||
URLConnection c3 = server.getUrl("/").openConnection();
|
|
||||||
assertEquals('A', c3.getInputStream().read());
|
|
||||||
assertEquals(3, cache.getRequestCount());
|
|
||||||
assertEquals(1, cache.getNetworkCount());
|
|
||||||
assertEquals(2, cache.getHitCount());
|
|
||||||
}
|
|
||||||
|
|
||||||
private void initializeCache(HttpResponseCache cache) {
|
|
||||||
// Ensure the cache is initialized, otherwise various methods are no-ops.
|
|
||||||
cache.size();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -372,6 +372,8 @@ public class NsdManagerTest extends AndroidTestCase {
|
|||||||
assertTrue(lastEvent != null);
|
assertTrue(lastEvent != null);
|
||||||
assertTrue(lastEvent.mInfo.getServiceName().equals(registeredName));
|
assertTrue(lastEvent.mInfo.getServiceName().equals(registeredName));
|
||||||
|
|
||||||
|
assertTrue(eventCacheSize() == 2);
|
||||||
|
|
||||||
// Register service again to see if we discover it
|
// Register service again to see if we discover it
|
||||||
checkForAdditionalEvents();
|
checkForAdditionalEvents();
|
||||||
clearEventCache();
|
clearEventCache();
|
||||||
@@ -403,6 +405,7 @@ public class NsdManagerTest extends AndroidTestCase {
|
|||||||
lastEvent.mInfo.getServiceName());
|
lastEvent.mInfo.getServiceName());
|
||||||
|
|
||||||
assertTrue(lastEvent.mInfo.getServiceName().equals(registeredName));
|
assertTrue(lastEvent.mInfo.getServiceName().equals(registeredName));
|
||||||
|
assertTrue(checkCacheSize(2));
|
||||||
|
|
||||||
checkForAdditionalEvents();
|
checkForAdditionalEvents();
|
||||||
clearEventCache();
|
clearEventCache();
|
||||||
|
|||||||
Reference in New Issue
Block a user