use of android.test.suitebuilder.annotation.Suppress in project android_frameworks_base by crdroidandroid.
the class SSLTest method testCertificate.
//This test relies on network resources.
@Suppress
public void testCertificate() throws Exception {
// test www.fortify.net/sslcheck.html
Socket ssl = SSLCertificateSocketFactory.getDefault().createSocket("www.fortify.net", 443);
assertNotNull(ssl);
OutputStream out = ssl.getOutputStream();
assertNotNull(out);
InputStream in = ssl.getInputStream();
assertNotNull(in);
String get = "GET /sslcheck.html HTTP/1.1\r\nHost: 68.178.217.222\r\n\r\n";
// System.out.println("going for write...");
out.write(get.getBytes());
byte[] b = new byte[1024];
// System.out.println("going for read...");
int ret = in.read(b);
// System.out.println(new String(b));
}
use of android.test.suitebuilder.annotation.Suppress in project android_frameworks_base by crdroidandroid.
the class NetworkStatsHistoryTest method testFuzzing.
@Suppress
public void testFuzzing() throws Exception {
try {
// fuzzing with random events, looking for crashes
final NetworkStats.Entry entry = new NetworkStats.Entry();
final Random r = new Random();
for (int i = 0; i < 500; i++) {
stats = new NetworkStatsHistory(r.nextLong());
for (int j = 0; j < 10000; j++) {
if (r.nextBoolean()) {
// add range
final long start = r.nextLong();
final long end = start + r.nextInt();
entry.rxBytes = nextPositiveLong(r);
entry.rxPackets = nextPositiveLong(r);
entry.txBytes = nextPositiveLong(r);
entry.txPackets = nextPositiveLong(r);
entry.operations = nextPositiveLong(r);
stats.recordData(start, end, entry);
} else {
// trim something
stats.removeBucketsBefore(r.nextLong());
}
}
assertConsistent(stats);
}
} catch (Throwable e) {
Log.e(TAG, String.valueOf(stats));
throw new RuntimeException(e);
}
}
use of android.test.suitebuilder.annotation.Suppress in project android_frameworks_base by crdroidandroid.
the class NetworkPolicyManagerServiceTest method testNetworkPolicyAppliedCycleLastMonth.
@Suppress
public void testNetworkPolicyAppliedCycleLastMonth() throws Exception {
NetworkState[] state = null;
NetworkStats stats = null;
Future<Void> future;
final long TIME_FEB_15 = 1171497600000L;
final long TIME_MAR_10 = 1173484800000L;
final int CYCLE_DAY = 15;
setCurrentTimeMillis(TIME_MAR_10);
// first, pretend that wifi network comes online. no policy active,
// which means we shouldn't push limit to interface.
state = new NetworkState[] { buildWifi() };
expect(mConnManager.getAllNetworkState()).andReturn(state).atLeastOnce();
expectCurrentTime();
expectClearNotifications();
expectAdvisePersistThreshold();
future = expectMeteredIfacesChanged();
replay();
mServiceContext.sendBroadcast(new Intent(CONNECTIVITY_ACTION));
future.get();
verifyAndReset();
// now change cycle to be on 15th, and test in early march, to verify we
// pick cycle day in previous month.
expect(mConnManager.getAllNetworkState()).andReturn(state).atLeastOnce();
expectCurrentTime();
// pretend that 512 bytes total have happened
stats = new NetworkStats(getElapsedRealtime(), 1).addIfaceValues(TEST_IFACE, 256L, 2L, 256L, 2L);
expect(mStatsService.getNetworkTotalBytes(sTemplateWifi, TIME_FEB_15, TIME_MAR_10)).andReturn(stats.getTotalBytes()).atLeastOnce();
expectPolicyDataEnable(TYPE_WIFI, true);
// TODO: consider making strongly ordered mock
expectRemoveInterfaceQuota(TEST_IFACE);
expectSetInterfaceQuota(TEST_IFACE, (2 * MB_IN_BYTES) - 512);
expectClearNotifications();
expectAdvisePersistThreshold();
future = expectMeteredIfacesChanged(TEST_IFACE);
replay();
setNetworkPolicies(new NetworkPolicy(sTemplateWifi, CYCLE_DAY, TIMEZONE_UTC, 1 * MB_IN_BYTES, 2 * MB_IN_BYTES, false));
future.get();
verifyAndReset();
}
use of android.test.suitebuilder.annotation.Suppress in project android_frameworks_base by AOSPA.
the class NetworkStatsHistoryTest method testFuzzing.
@Suppress
public void testFuzzing() throws Exception {
try {
// fuzzing with random events, looking for crashes
final NetworkStats.Entry entry = new NetworkStats.Entry();
final Random r = new Random();
for (int i = 0; i < 500; i++) {
stats = new NetworkStatsHistory(r.nextLong());
for (int j = 0; j < 10000; j++) {
if (r.nextBoolean()) {
// add range
final long start = r.nextLong();
final long end = start + r.nextInt();
entry.rxBytes = nextPositiveLong(r);
entry.rxPackets = nextPositiveLong(r);
entry.txBytes = nextPositiveLong(r);
entry.txPackets = nextPositiveLong(r);
entry.operations = nextPositiveLong(r);
stats.recordData(start, end, entry);
} else {
// trim something
stats.removeBucketsBefore(r.nextLong());
}
}
assertConsistent(stats);
}
} catch (Throwable e) {
Log.e(TAG, String.valueOf(stats));
throw new RuntimeException(e);
}
}
use of android.test.suitebuilder.annotation.Suppress in project android_frameworks_base by AOSPA.
the class DatabaseCursorTest method testCursorWindowFailureWhenTooManyCursorWindowsLeftOpen.
/**
* sometimes CursorWindow creation fails due to non-availability of memory create
* another CursorWindow object. One of the scenarios of its occurrence is when
* there are too many CursorWindow objects already opened by the process.
* This test is for that scenario.
*/
@LargeTest
// Failing.
@Suppress
public void testCursorWindowFailureWhenTooManyCursorWindowsLeftOpen() {
mDatabase.execSQL("CREATE TABLE test (_id INTEGER PRIMARY KEY, data TEXT);");
mDatabase.execSQL("INSERT INTO test values(1, 'test');");
int N = 1024;
ArrayList<Cursor> cursorList = new ArrayList<Cursor>();
// open many cursors until a failure occurs
for (int i = 0; i < N; i++) {
try {
Cursor cursor = mDatabase.rawQuery("select * from test", null);
cursor.getCount();
cursorList.add(cursor);
} catch (CursorWindowAllocationException e) {
// got the exception we wanted
break;
} catch (Exception e) {
fail("unexpected exception: " + e.getMessage());
e.printStackTrace();
break;
}
}
for (Cursor c : cursorList) {
c.close();
}
}
Aggregations