* </p>
*
* @throws Exception if an error occurs while running the test.
*/
public void testCreateTokenProvider() throws Exception {
WSTrustServiceFactory factory = WSTrustServiceFactory.getInstance();
SecurityTokenProvider provider = factory.createTokenProvider(
"org.picketlink.test.identity.federation.core.wstrust.SpecialTokenProvider", null);
assertNotNull("Unexpected null token provider", provider);
assertTrue("Unexpected token provider type", provider instanceof SpecialTokenProvider);
provider = factory.createTokenProvider(
"org.picketlink.identity.federation.core.wstrust.plugins.saml.SAML20TokenProvider",
new HashMap<String, String>());
assertNotNull("Unexpected null token provider", provider);
assertTrue("Unexpected token provider type", provider instanceof SAML20TokenProvider);
// try to create an invalid token provider.
try {
factory.createTokenProvider("InvalidTokenProvider", null);
fail("An exception should have been raised");
} catch (RuntimeException re) {
String msg = re.getCause().getMessage();
assertTrue(msg.contains("Cannot create instance"));
}