use of javax.net.ssl.TrustManagerFactory in project robovm by robovm.
the class myTrustManagerFactory method test_ConstructorLjavax_net_ssl_TrustManagerFactorySpiLjava_security_ProviderLjava_lang_String.
public void test_ConstructorLjavax_net_ssl_TrustManagerFactorySpiLjava_security_ProviderLjava_lang_String() throws NoSuchAlgorithmException {
TrustManagerFactorySpi spi = new MyTrustManagerFactorySpi();
TrustManagerFactory tmF = new myTrustManagerFactory(spi, getDefaultProvider(), getDefaultAlgorithm());
assertTrue("Not CertStore object", tmF instanceof TrustManagerFactory);
assertEquals("Incorrect algorithm", tmF.getAlgorithm(), getDefaultAlgorithm());
assertEquals("Incorrect provider", tmF.getProvider(), getDefaultProvider());
assertNull("Incorrect result", tmF.getTrustManagers());
tmF = new myTrustManagerFactory(null, null, null);
assertTrue("Not CertStore object", tmF instanceof TrustManagerFactory);
assertNull("Provider must be null", tmF.getProvider());
assertNull("Algorithm must be null", tmF.getAlgorithm());
try {
tmF.getTrustManagers();
fail("NullPointerException must be thrown");
} catch (NullPointerException e) {
}
}
use of javax.net.ssl.TrustManagerFactory in project robovm by robovm.
the class myTrustManagerFactory method test_getInstanceLjava_lang_StringLjava_lang_String04.
/**
* Test for <code>getInstance(String algorithm, String provider)</code>
* method
* Assertion: returns instance of TrustManagerFactory
*/
public void test_getInstanceLjava_lang_StringLjava_lang_String04() throws Exception {
for (String validValue : getValidValues()) {
TrustManagerFactory trustMF = TrustManagerFactory.getInstance(validValue, getDefaultProviderName());
assertTrue("Not TrustManagerFactory object", trustMF instanceof TrustManagerFactory);
assertEquals("Invalid algorithm", trustMF.getAlgorithm(), validValue);
assertEquals("Invalid provider", trustMF.getProvider(), getDefaultProvider());
}
}
use of javax.net.ssl.TrustManagerFactory in project robovm by robovm.
the class myTrustManagerFactory method test_getTrustManagers.
/**
* Test for <code>geTrustManagers()</code>
* @throws KeyStoreException
* @throws IOException
* @throws CertificateException
* @throws NoSuchAlgorithmException
*/
public void test_getTrustManagers() {
try {
TrustManagerFactory trustMF = TrustManagerFactory.getInstance(getDefaultAlgorithm());
KeyStore ks = KeyStore.getInstance(KeyStore.getDefaultType());
ks.load(null, null);
trustMF.init(ks);
TrustManager[] tm = trustMF.getTrustManagers();
assertNotNull("Result has not be null", tm);
assertTrue("Length of result TrustManager array should not be 0", (tm.length > 0));
} catch (Exception ex) {
fail("Unexpected exception " + ex.toString());
}
}
use of javax.net.ssl.TrustManagerFactory in project robovm by robovm.
the class TrustManagerFactory2Test method testLjava_lang_StringLjava_security_Provider.
/**
* Test for <code>getInstance(String algorithm, Provider provider)</code>
* method
* Assertions:
* throws NullPointerException when algorithm is null;
* throws NoSuchAlgorithmException when algorithm is not correct;
* throws IllegalArgumentException when provider is null;
* returns TrustManagerFactory object
*/
public void testLjava_lang_StringLjava_security_Provider() throws Exception {
try {
TrustManagerFactory.getInstance(null, mProv);
fail("NoSuchAlgorithmException or NullPointerException should be thrown (algorithm is null");
} catch (NoSuchAlgorithmException e) {
} catch (NullPointerException e) {
}
for (int i = 0; i < invalidValues.length; i++) {
try {
TrustManagerFactory.getInstance(invalidValues[i], mProv);
fail("NoSuchAlgorithmException must be thrown (algorithm: ".concat(invalidValues[i]).concat(")"));
} catch (NoSuchAlgorithmException e) {
}
}
Provider prov = null;
for (int i = 0; i < validValues.length; i++) {
try {
TrustManagerFactory.getInstance(validValues[i], prov);
fail("IllegalArgumentException must be thrown when provider is null (algorithm: ".concat(invalidValues[i]).concat(")"));
} catch (IllegalArgumentException e) {
}
}
TrustManagerFactory tmf;
for (int i = 0; i < validValues.length; i++) {
tmf = TrustManagerFactory.getInstance(validValues[i], mProv);
assertTrue("Not instanceof TrustManagerFactory object", tmf instanceof TrustManagerFactory);
assertEquals("Incorrect algorithm", tmf.getAlgorithm(), validValues[i]);
assertEquals("Incorrect provider", tmf.getProvider(), mProv);
checkResult(tmf);
}
}
use of javax.net.ssl.TrustManagerFactory in project robovm by robovm.
the class TrustManagerFactory2Test method test_getInstanceLjava_lang_String.
/**
* Test for <code>getInstance(String algorithm)</code> method
* Assertions:
* throws NullPointerException when algorithm is null;
* throws NoSuchAlgorithmException when algorithm is not correct;
* returns TrustManagerFactory object
*/
public void test_getInstanceLjava_lang_String() throws Exception {
try {
TrustManagerFactory.getInstance(null);
fail("NoSuchAlgorithmException or NullPointerException should be thrown (algorithm is null");
} catch (NoSuchAlgorithmException e) {
} catch (NullPointerException e) {
}
for (int i = 0; i < invalidValues.length; i++) {
try {
TrustManagerFactory.getInstance(invalidValues[i]);
fail("NoSuchAlgorithmException must be thrown (algorithm: ".concat(invalidValues[i]).concat(")"));
} catch (NoSuchAlgorithmException e) {
}
}
TrustManagerFactory tmf;
for (int i = 0; i < validValues.length; i++) {
tmf = TrustManagerFactory.getInstance(validValues[i]);
assertTrue("Not instanceof TrustManagerFactory object", tmf instanceof TrustManagerFactory);
assertEquals("Incorrect algorithm", tmf.getAlgorithm(), validValues[i]);
assertEquals("Incorrect provider", tmf.getProvider(), mProv);
checkResult(tmf);
}
}
Aggregations