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
90f1566a
Commit
90f1566a
authored
Feb 16, 2017
by
Dave Kantor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ATLAS-1539 Address coverity scan issues
parent
20fb5894
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
52 additions
and
10 deletions
+52
-10
ApplicationPropertiesTest.java
...test/java/org/apache/atlas/ApplicationPropertiesTest.java
+52
-10
No files found.
common/src/test/java/org/apache/atlas/ApplicationPropertiesTest.java
View file @
90f1566a
...
...
@@ -32,23 +32,52 @@ public class ApplicationPropertiesTest {
@Test
public
void
testGetFileAsInputStream
()
throws
Exception
{
Configuration
props
=
ApplicationProperties
.
get
(
"test.properties"
);
InputStream
inStr
=
null
;
// configured file as class loader resource
InputStream
inStr
=
ApplicationProperties
.
getFileAsInputStream
(
props
,
"jaas.properties.file"
,
null
);
assertNotNull
(
inStr
);
try
{
inStr
=
ApplicationProperties
.
getFileAsInputStream
(
props
,
"jaas.properties.file"
,
null
);
assertNotNull
(
inStr
);
}
finally
{
if
(
inStr
!=
null
)
{
inStr
.
close
();
}
}
// configured file from file system path
props
.
setProperty
(
"jaas.properties.file"
,
"src/test/resources/atlas-jaas.properties"
);
inStr
=
ApplicationProperties
.
getFileAsInputStream
(
props
,
"jaas.properties.file"
,
null
);
assertNotNull
(
inStr
);
try
{
inStr
=
ApplicationProperties
.
getFileAsInputStream
(
props
,
"jaas.properties.file"
,
null
);
assertNotNull
(
inStr
);
}
finally
{
if
(
inStr
!=
null
)
{
inStr
.
close
();
}
}
// default file as class loader resource
inStr
=
ApplicationProperties
.
getFileAsInputStream
(
props
,
"property.not.specified.in.config"
,
"atlas-jaas.properties"
);
assertNotNull
(
inStr
);
try
{
inStr
=
ApplicationProperties
.
getFileAsInputStream
(
props
,
"property.not.specified.in.config"
,
"atlas-jaas.properties"
);
assertNotNull
(
inStr
);
}
finally
{
if
(
inStr
!=
null
)
{
inStr
.
close
();
}
}
// default file relative to working directory
inStr
=
ApplicationProperties
.
getFileAsInputStream
(
props
,
"property.not.specified.in.config"
,
"src/test/resources/atlas-jaas.properties"
);
assertNotNull
(
inStr
);
try
{
inStr
=
ApplicationProperties
.
getFileAsInputStream
(
props
,
"property.not.specified.in.config"
,
"src/test/resources/atlas-jaas.properties"
);
assertNotNull
(
inStr
);
}
finally
{
if
(
inStr
!=
null
)
{
inStr
.
close
();
}
}
// default file relative to atlas configuration directory
String
originalConfDirSetting
=
System
.
setProperty
(
ApplicationProperties
.
ATLAS_CONFIGURATION_DIRECTORY_PROPERTY
,
"src/test/resources"
);
...
...
@@ -57,6 +86,9 @@ public class ApplicationPropertiesTest {
assertNotNull
(
inStr
);
}
finally
{
if
(
inStr
!=
null
)
{
inStr
.
close
();
}
if
(
originalConfDirSetting
!=
null
)
{
System
.
setProperty
(
ApplicationProperties
.
ATLAS_CONFIGURATION_DIRECTORY_PROPERTY
,
originalConfDirSetting
);
}
...
...
@@ -67,21 +99,31 @@ public class ApplicationPropertiesTest {
// non-existent property and no default file
try
{
ApplicationProperties
.
getFileAsInputStream
(
props
,
"property.not.specified.in.config"
,
null
);
inStr
=
ApplicationProperties
.
getFileAsInputStream
(
props
,
"property.not.specified.in.config"
,
null
);
fail
(
"Expected "
+
AtlasException
.
class
.
getSimpleName
()
+
" but none thrown"
);
}
catch
(
AtlasException
e
)
{
// good
}
finally
{
if
(
inStr
!=
null
)
{
inStr
.
close
();
}
}
// configured file not found in file system or classpath
props
.
setProperty
(
"jaas.properties.file"
,
"does_not_exist.txt"
);
try
{
ApplicationProperties
.
getFileAsInputStream
(
props
,
"jaas.properties.file"
,
null
);
inStr
=
ApplicationProperties
.
getFileAsInputStream
(
props
,
"jaas.properties.file"
,
null
);
fail
(
"Expected "
+
AtlasException
.
class
.
getSimpleName
()
+
" but none thrown"
);
}
catch
(
AtlasException
e
)
{
// good
}
finally
{
if
(
inStr
!=
null
)
{
inStr
.
close
();
}
}
}
}
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