OAuthAuthenticator implements WebappAuthenticator { public void init() { this.tokenValidator = Utils.initAuthenticators(this.properties); }  void init(); boolean canHandle(org.apache.catalina.connector.Request request); AuthenticationInfo authenticate(org.apache.catalina.connector.Request request, Response response); String getName(); String getProperty(String name); Properties getProperties(); void setProperties(Properties properties);  }
@Test(description = "This method tests the successful execution of init method") public void testInit() throws NoSuchFieldException, IllegalAccessException { properties = new Properties(); properties.setProperty("TokenValidationEndpointUrl", "test"); properties.setProperty("Username", "admin"); properties.setProperty("Password", "admin"); properties.setProperty("IsRemote", "true"); properties.setProperty("MaxConnectionsPerHost", "100"); properties.setProperty("MaxTotalConnections", "1000"); Assert.assertNull(oAuthAuthenticator.getProperty("test"), "OAuth authenticator is returning the properties that were never set"); oAuthAuthenticator.setProperties(properties); oAuthAuthenticator.init(); Field tokenValidator = OAuthAuthenticator.class.getDeclaredField("tokenValidator"); tokenValidator.setAccessible(true); Assert.assertNotNull(tokenValidator.get(oAuthAuthenticator), "OauthAuthenticator initialization failed"); Assert.assertEquals(oAuthAuthenticator.getName(), "OAuth", "Name of the OauthAuthenticator does not match"); }