Commit 1c3dcc07 by apoorvnaik

ATLAS-1834: TestNG asserts over JUnit for consistency

parent e75984c4
......@@ -41,15 +41,15 @@ import java.net.URISyntaxException;
import java.util.Arrays;
import java.util.List;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertNull;
import static org.testng.Assert.assertTrue;
import static org.testng.Assert.fail;
public class AtlasClientTest {
......
......@@ -28,9 +28,9 @@ import org.testng.annotations.BeforeClass;
import org.testng.annotations.Guice;
import org.testng.annotations.Test;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertTrue;
@Guice(modules = TestOnlyModule.class)
public class EntityDiscoveryServiceTest {
......
......@@ -16,15 +16,14 @@
*/
package org.apache.atlas.web.filters;
import java.io.IOException;
import org.mockito.Mockito;
import org.testng.annotations.Test;
import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.junit.Test;
import org.mockito.Mockito;
import java.io.IOException;
import static org.mockito.Mockito.atLeastOnce;
import static org.mockito.Mockito.verify;
......
......@@ -22,7 +22,6 @@ import org.apache.atlas.ApplicationProperties;
import org.apache.atlas.web.TestUtils;
import org.apache.commons.configuration.PropertiesConfiguration;
import org.apache.commons.io.FileUtils;
import org.junit.Assert;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.slf4j.Logger;
......@@ -42,6 +41,8 @@ import java.io.File;
import java.util.Collection;
import static org.mockito.Mockito.when;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;
public class FileAuthenticationTest {
......@@ -118,7 +119,7 @@ public class FileAuthenticationTest {
Authentication auth = authProvider.authenticate(authentication);
LOG.debug(" {}", auth);
Assert.assertTrue(auth.isAuthenticated());
assertTrue(auth.isAuthenticated());
}
@Test
......@@ -131,7 +132,7 @@ public class FileAuthenticationTest {
Authentication auth = authProvider.authenticate(authentication);
LOG.debug(" {}", auth);
} catch (BadCredentialsException bcExp) {
Assert.assertEquals("Wrong password", bcExp.getMessage());
assertEquals("Wrong password", bcExp.getMessage());
}
}
......@@ -144,7 +145,7 @@ public class FileAuthenticationTest {
Authentication auth = authProvider.authenticate(authentication);
LOG.debug(" {}", auth);
} catch (UsernameNotFoundException uExp) {
Assert.assertTrue(uExp.getMessage().contains("Username not found."));
assertTrue(uExp.getMessage().contains("Username not found."));
}
}
......@@ -157,7 +158,7 @@ public class FileAuthenticationTest {
Authentication auth = authProvider.authenticate(authentication);
LOG.debug(" {}", auth);
} catch (AtlasAuthenticationException uExp) {
Assert.assertTrue(uExp.getMessage().startsWith("User role credentials is not set properly for"));
assertTrue(uExp.getMessage().startsWith("User role credentials is not set properly for"));
}
}
......@@ -171,7 +172,7 @@ public class FileAuthenticationTest {
Authentication auth = authProvider.authenticate(authentication);
LOG.debug(" {}", auth);
} catch (UsernameNotFoundException uExp) {
Assert.assertTrue(uExp.getMessage().startsWith("Username not found"));
assertTrue(uExp.getMessage().startsWith("Username not found"));
}
}
......@@ -184,7 +185,7 @@ public class FileAuthenticationTest {
Authentication auth = authProvider.authenticate(authentication);
LOG.debug(" {}", auth);
Assert.assertTrue(auth.isAuthenticated());
assertTrue(auth.isAuthenticated());
Collection<? extends GrantedAuthority> authorities = auth.getAuthorities();
......@@ -192,7 +193,7 @@ public class FileAuthenticationTest {
for (GrantedAuthority gauth : authorities) {
role = gauth.getAuthority();
}
Assert.assertTrue("ADMIN".equals(role));
assertTrue("ADMIN".equals(role));
}
......
......@@ -16,15 +16,17 @@
*/
package org.apache.atlas.web.security;
import java.util.Collection;
import java.util.Properties;
import org.apache.atlas.web.dao.UserDao;
import org.apache.atlas.web.model.User;
import org.junit.Assert;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.testng.annotations.Test;
import java.util.Collection;
import java.util.Properties;
import static org.testng.Assert.assertTrue;
public class UserDaoTest {
@Test
......@@ -36,14 +38,14 @@ public class UserDaoTest {
UserDao user = new UserDao();
user.setUserLogins(userLogins);
User userBean = user.loadUserByUsername("admin");
Assert.assertTrue(userBean.getPassword().equals("admin123"));
assertTrue(userBean.getPassword().equals("admin123"));
Collection<? extends GrantedAuthority> authorities = userBean.getAuthorities();
String role = "";
for (GrantedAuthority gauth : authorities) {
role = gauth.getAuthority();
}
Assert.assertTrue("ADMIN".equals(role));
assertTrue("ADMIN".equals(role));
}
@Test
......@@ -60,7 +62,7 @@ public class UserDaoTest {
} catch (UsernameNotFoundException uex) {
hadException = true;
}
Assert.assertTrue(hadException);
assertTrue(hadException);
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment