Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
atlas
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
dataplatform
atlas
Commits
1c3dcc07
Commit
1c3dcc07
authored
May 26, 2017
by
apoorvnaik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ATLAS-1834: TestNG asserts over JUnit for consistency
parent
e75984c4
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
25 additions
and
22 deletions
+25
-22
AtlasClientTest.java
client/src/test/java/org/apache/atlas/AtlasClientTest.java
+2
-2
EntityDiscoveryServiceTest.java
...org/apache/atlas/services/EntityDiscoveryServiceTest.java
+2
-2
AtlasCSRFPreventionFilterTest.java
...ache/atlas/web/filters/AtlasCSRFPreventionFilterTest.java
+3
-4
FileAuthenticationTest.java
...org/apache/atlas/web/security/FileAuthenticationTest.java
+9
-8
UserDaoTest.java
.../test/java/org/apache/atlas/web/security/UserDaoTest.java
+9
-6
No files found.
client/src/test/java/org/apache/atlas/AtlasClientTest.java
View file @
1c3dcc07
...
...
@@ -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
{
...
...
repository/src/test/java/org/apache/atlas/services/EntityDiscoveryServiceTest.java
View file @
1c3dcc07
...
...
@@ -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
{
...
...
webapp/src/test/java/org/apache/atlas/web/filters/AtlasCSRFPreventionFilterTest.java
View file @
1c3dcc07
...
...
@@ -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
;
...
...
webapp/src/test/java/org/apache/atlas/web/security/FileAuthenticationTest.java
View file @
1c3dcc07
...
...
@@ -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
));
}
...
...
webapp/src/test/java/org/apache/atlas/web/security/UserDaoTest.java
View file @
1c3dcc07
...
...
@@ -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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment