1414import java .util .Iterator ;
1515import java .util .List ;
1616
17- import static org .junit .Assert .*;
17+ import static org .junit .Assert .assertEquals ;
18+ import static org .junit .Assert .assertNotNull ;
1819
1920/**
2021 * @author Jerry Lee (oldratlee at gmail dot com)
@@ -39,11 +40,9 @@ public void setUp() throws Exception {
3940 System .out .println ("Prepared output file: " + outputFilePath );
4041
4142 setAgentFilePath ();
42- assertNotNull (agentFilePath );
43- System .out .println ("Found agent file: " + agentFilePath );
4443 }
4544
46- public void setAgentFilePath () throws Exception {
45+ private void setAgentFilePath () throws Exception {
4746 // find agent jar file from dcm lib project
4847 File dcmLibProjectDir = new File ("library" );
4948 if (!dcmLibProjectDir .exists ()) {
@@ -63,7 +62,6 @@ public void setAgentFilePath() throws Exception {
6362 final File next = fileIterator .next ();
6463 final String fileName = next .getName ();
6564 final String agentJarPath = next .getCanonicalPath ();
66- System .out .println ("List Agent jar from target: " + agentJarPath );
6765
6866 if (fileName .startsWith ("dns-cache-manipulator" )) {
6967 final String replaced = fileName .replace ("dns-cache-manipulator-" , "" ).replace ("-SNAPSHOT" , "" );
@@ -94,12 +92,14 @@ public void setAgentFilePath() throws Exception {
9492 }
9593 }
9694
97- assertTrue (list .size () > 0 );
98- Collections .sort (list );
99-
100- System .out .println ("List Agent jar from .m2: " + list );
101- agentFilePath = list .get (list .size () - 1 );
95+ if (!list .isEmpty ()) {
96+ Collections .sort (list );
97+ agentFilePath = list .get (list .size () - 1 );
98+ }
10299 }
100+
101+ assertNotNull ("Not found agent file" , agentFilePath );
102+ System .out .println ("Found agent file: " + agentFilePath );
103103 }
104104
105105 @ Test
0 commit comments