@@ -12,15 +12,38 @@ public class ArtifactoryRepositoryTests extends GroovyTestCase {
1212 File propFile = new File (" ." + " /src/test/resources/unitTest.properties" )
1313 def map = Utilities . mapProperties(propFile)
1414
15- // Utility function to get temporary directory...
15+ /**
16+ * Utility function for getting tmpDir
17+ */
1618 File getTmpDir () {
17- return new File ((map. get(" tmpDir" ) != null ) ? map. get(" tmpDir" ) : System . getProperty(" java.io.tmpdir" ))
19+ if (runUnitTestsOnly()) {
20+ return new File (System . getProperty(" java.io.tmpdir" ))
21+ } else {
22+ return new File ((map. get(" tmpDir" ) != null ) ? map. get(" tmpDir" ) : System . getProperty(" java.io.tmpdir" ))
23+ }
24+ }
25+
26+ /**
27+ * Utility function for seeing if need to just run unit-tests
28+ */
29+ boolean runUnitTestsOnly () {
30+ if (System . getenv(" DEVOPS_FRAMEWORK_UNITTESTS" )!= null ) {
31+ return true ;
32+ }
33+ String unitTests = map. get(" unit_tests_only" )
34+ if (unitTests != null && ! unitTests. isEmpty()) {
35+ return (unitTests. contains(" true" ))
36+ }
37+ return false
1838 }
1939
2040 /**
2141 * Push file to Artifactory repo
2242 */
2343 void testPushFileToArtifactory () {
44+ if (runUnitTestsOnly()) {
45+ return ;
46+ }
2447 File srcFile = new File (propFile. getAbsolutePath())
2548 URI targetRepo = new URI (map. get(" artifactory_repoURI" )+ " /unitTest/" )
2649
@@ -40,6 +63,9 @@ public class ArtifactoryRepositoryTests extends GroovyTestCase {
4063 * Pull file from Artifactory repo
4164 */
4265 void testPullFileFromArtifactory () {
66+ if (runUnitTestsOnly()) {
67+ return ;
68+ }
4369 Random rand = new Random ()
4470 Long uid = rand. nextLong()
4571
@@ -76,6 +102,9 @@ public class ArtifactoryRepositoryTests extends GroovyTestCase {
76102 * Push file to Artifactory repo
77103 */
78104 void testPushFileToArtifactoryStr () {
105+ if (runUnitTestsOnly()) {
106+ return ;
107+ }
79108 File srcFile = new File (propFile. getAbsolutePath())
80109 URI targetRepo = new URI (map. get(" artifactory_repoURI" )+ " /unitTest/" )
81110
@@ -97,6 +126,9 @@ public class ArtifactoryRepositoryTests extends GroovyTestCase {
97126 * Pull file from Artifactory repo
98127 */
99128 void testPullFileFromArtifactoryStr () {
129+ if (runUnitTestsOnly()) {
130+ return ;
131+ }
100132 Random rand = new Random ()
101133 Long uid = rand. nextLong()
102134
@@ -134,6 +166,9 @@ public class ArtifactoryRepositoryTests extends GroovyTestCase {
134166 * Pull directory from Artifactory repo failure test
135167 */
136168 void testPullFileFromArtifactoryStrFailDir () {
169+ if (runUnitTestsOnly()) {
170+ return ;
171+ }
137172 Random rand = new Random ()
138173 Long uid = rand. nextLong()
139174
@@ -173,6 +208,9 @@ public class ArtifactoryRepositoryTests extends GroovyTestCase {
173208 * Push file to Artifactory repo failure test
174209 */
175210 void testPushFileToArtifactoryStrFail () {
211+ if (runUnitTestsOnly()) {
212+ return ;
213+ }
176214 File srcFile = new File (propFile. getAbsolutePath())
177215 URI targetRepo = new URI (" http://localhost:25/someStupidURIThatDoesNotExist" )
178216
@@ -195,6 +233,9 @@ public class ArtifactoryRepositoryTests extends GroovyTestCase {
195233 * Pull file from Artifactory repo failure test
196234 */
197235 void testPullFileFromArtifactoryStrFail () {
236+ if (runUnitTestsOnly()) {
237+ return ;
238+ }
198239 Random rand = new Random ()
199240 Long uid = rand. nextLong()
200241
@@ -229,6 +270,9 @@ public class ArtifactoryRepositoryTests extends GroovyTestCase {
229270 * Pull file from Artifactory repo failure test
230271 */
231272 void testPullFileFromArtifactoryStrFailURL () {
273+ if (runUnitTestsOnly()) {
274+ return ;
275+ }
232276 Random rand = new Random ()
233277 Long uid = rand. nextLong()
234278
@@ -263,6 +307,9 @@ public class ArtifactoryRepositoryTests extends GroovyTestCase {
263307 * Pull non-existing file from Artifactory repo
264308 */
265309 void testPullInvalidFileFromArtifactoryStr () {
310+ if (runUnitTestsOnly()) {
311+ return ;
312+ }
266313 Random rand = new Random ()
267314 Long uid = rand. nextLong()
268315
@@ -304,6 +351,9 @@ public class ArtifactoryRepositoryTests extends GroovyTestCase {
304351 * Authent error pull
305352 */
306353 void testPullAuthErrFromArtifactoryStr () {
354+ if (runUnitTestsOnly()) {
355+ return ;
356+ }
307357 Random rand = new Random ()
308358 Long uid = rand. nextLong()
309359
@@ -344,6 +394,9 @@ public class ArtifactoryRepositoryTests extends GroovyTestCase {
344394 * Authent error push
345395 */
346396 void testPushAuthErrFromArtifactoryStr () {
397+ if (runUnitTestsOnly()) {
398+ return ;
399+ }
347400 Random rand = new Random ()
348401 Long uid = rand. nextLong()
349402
0 commit comments