use of dalvik.annotation.AndroidOnly in project robovm by robovm.
the class HandshakeCompletedEventTest method testClientAuth.
/**
* Implements the actual test case. Launches a server and a client, requires
* client authentication and checks the certificates afterwards (not in the
* usual sense, we just make sure that we got the expected certificates,
* because our self-signed test certificates are not valid.)
*/
@AndroidOnly("Uses bks key store. Change useBKS to false to run on the RI")
public void testClientAuth() throws Exception {
boolean useBKS = true;
listener = new MyHandshakeListener();
String serverKeys = (useBKS ? SERVER_KEYS_BKS : SERVER_KEYS_JKS);
String clientKeys = (useBKS ? CLIENT_KEYS_BKS : CLIENT_KEYS_JKS);
TestServer server = new TestServer(true, TestServer.CLIENT_AUTH_WANTED, serverKeys);
TestClient client = new TestClient(true, clientKeys);
Thread serverThread = new Thread(server);
Thread clientThread = new Thread(client);
serverThread.start();
Thread.currentThread().sleep(3000);
clientThread.start();
serverThread.join();
clientThread.join();
// The server must have completed without an exception.
Exception e = server.getException();
if (e != null) {
e.printStackTrace();
}
// The client must have completed without an exception.
e = client.getException();
if (e != null) {
e.printStackTrace();
}
assertNull(e);
assertTrue(listener.completeDone);
}
use of dalvik.annotation.AndroidOnly in project robovm by robovm.
the class CertificateTest method testVerifyMD2.
@AndroidOnly("MD2 is not supported by Android")
public void testVerifyMD2() throws Exception {
Provider[] providers = Security.getProviders("CertificateFactory.X509");
for (Provider provider : providers) {
CertificateFactory certificateFactory = CertificateFactory.getInstance("X509", provider);
Certificate certificate = certificateFactory.generateCertificate(new ByteArrayInputStream(selfSignedCertMD2.getBytes()));
try {
certificate.verify(certificate.getPublicKey());
fail("MD2 should not be allowed");
} catch (NoSuchAlgorithmException e) {
// expected
} catch (Throwable e) {
throw new AssertionError(provider.getName(), e);
}
}
}
use of dalvik.annotation.AndroidOnly in project robovm by robovm.
the class MessageDigestTestMD2 method testMessageDigest2.
@AndroidOnly("Android allows usage of MD2 in third party providers")
public void testMessageDigest2() throws Exception {
Provider provider = new MyProvider();
Security.addProvider(provider);
try {
MessageDigest digest = MessageDigest.getInstance("MD2");
digest = MessageDigest.getInstance("1.2.840.113549.2.2");
} finally {
Security.removeProvider(provider.getName());
}
}
use of dalvik.annotation.AndroidOnly in project robovm by robovm.
the class SignatureTestMD2withRSA method testSignature2.
@AndroidOnly("Android allows usage of MD2withRSA in third party providers")
public void testSignature2() throws Exception {
Provider provider = new MyProvider();
Security.addProvider(provider);
Signature signature = Signature.getInstance("MD2withRSA");
signature = Signature.getInstance("MD2WithRSA");
signature = Signature.getInstance("MD2WITHRSA");
signature = Signature.getInstance("MD2withRSAEncryption");
signature = Signature.getInstance("MD2WithRSAEncryption");
signature = Signature.getInstance("MD2WITHRSAENCRYPTION");
signature = Signature.getInstance("MD2/RSA");
signature = Signature.getInstance("1.2.840.113549.1.1.2");
Security.removeProvider(provider.getName());
}
use of dalvik.annotation.AndroidOnly in project robovm by robovm.
the class OldTimeZoneTest method test_getDisplayNameZILjava_util_Locale.
@AndroidOnly("fail on RI. See comment below")
public void test_getDisplayNameZILjava_util_Locale() {
TimeZone tz = TimeZone.getTimeZone("America/Los_Angeles");
assertEquals("PST", tz.getDisplayName(false, 0, Locale.US));
assertEquals("Pacific Daylight Time", tz.getDisplayName(true, 1, Locale.US));
assertEquals("Pacific Standard Time", tz.getDisplayName(false, 1, Locale.UK));
// RI always returns short time zone name as "PST"
// ICU zone/root.txt patched to allow metazone names.
assertEquals("PST", tz.getDisplayName(false, 0, Locale.FRANCE));
assertEquals("heure avancée du Pacifique", tz.getDisplayName(true, 1, Locale.FRANCE));
assertEquals("heure normale du Pacifique", tz.getDisplayName(false, 1, Locale.FRANCE));
}
Aggregations