Bind to PasswordCredentialAuth
[netconf.git] / netconf / aaa-authn-odl-plugin / src / test / java / org / opendaylight / netconf / authprovider / CredentialServiceAuthProviderTest.java
index 11d16fff1129e66e003ef5143da79f24770a69a6..a2ebe91c9d9dc255e957427567d04d8f1357615d 100644 (file)
@@ -14,36 +14,22 @@ import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.doThrow;
 import static org.mockito.Mockito.mock;
 
-import org.junit.Before;
 import org.junit.Test;
+import org.junit.runner.RunWith;
 import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.mockito.invocation.InvocationOnMock;
-import org.mockito.stubbing.Answer;
+import org.mockito.junit.MockitoJUnitRunner;
 import org.opendaylight.aaa.api.AuthenticationException;
 import org.opendaylight.aaa.api.Claim;
-import org.opendaylight.aaa.api.CredentialAuth;
+import org.opendaylight.aaa.api.PasswordCredentialAuth;
 import org.opendaylight.aaa.api.PasswordCredentials;
-import org.osgi.framework.ServiceListener;
-import org.osgi.framework.ServiceReference;
 
+@RunWith(MockitoJUnitRunner.StrictStubs.class)
 public class CredentialServiceAuthProviderTest {
-
     @Mock
-    private CredentialAuth<PasswordCredentials> credAuth;
-
-    @Before
-    public void setUp() throws Exception {
-        MockitoAnnotations.initMocks(this);
-    }
-
+    private PasswordCredentialAuth credAuth;
 
     @Test
     public void testAuthenticatedTrue() throws Exception {
-        ServiceReference serviceRef = mock(ServiceReference.class);
-
-        ServiceListenerAnswer answer = new ServiceListenerAnswer();
-
         Claim claim = mock(Claim.class);
         doReturn("domain").when(claim).domain();
         doReturn(claim).when(credAuth).authenticate(any(PasswordCredentials.class));
@@ -58,15 +44,4 @@ public class CredentialServiceAuthProviderTest {
         CredentialServiceAuthProvider credentialServiceAuthProvider = new CredentialServiceAuthProvider(credAuth);
         assertFalse(credentialServiceAuthProvider.authenticated("user", "pwd"));
     }
-
-    private static class ServiceListenerAnswer implements Answer {
-
-        ServiceListener serviceListener;
-
-        @Override
-        public Object answer(final InvocationOnMock invocationOnMock) throws Throwable {
-            serviceListener = (ServiceListener) invocationOnMock.getArguments()[0];
-            return null;
-        }
-    }
 }