This repository was archived by the owner on Nov 15, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +64
-5
lines changed
test-utils/utils-ng/src/main/java/org/glassfish/tests/utils
tests/admin/src/test/java/org/glassfish/nucleus/admin/progress Expand file tree Collapse file tree 3 files changed +64
-5
lines changed Original file line number Diff line number Diff line change 11/*
22 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
33 *
4- * Copyright (c) 2012-2013 Oracle and/or its affiliates. All rights reserved.
4+ * Copyright (c) 2012-2017 Oracle and/or its affiliates. All rights reserved.
55 *
66 * The contents of this file are subject to the terms of either the GNU
77 * General Public License Version 2 only ("GPL") or the Common Development
@@ -335,4 +335,58 @@ public static class NadminReturn {
335335 public String outAndErr ;
336336 }
337337
338+ public static void deleteDirectoryContents (final File dir ) {
339+ if (dir == null || !dir .exists ()) {
340+ return ;
341+ }
342+ System .out .println ("Deleting contents of directory : " + dir );
343+ File [] files = dir .listFiles ();
344+ if (files !=null ) {
345+ for (File f : files ) {
346+ if (f .isDirectory ()) {
347+ deleteDirectory (f );
348+ }else {
349+ f .delete ();
350+ }
351+ }
352+ }
353+ }
354+
355+ public static void deleteDirectory (final File dir ) {
356+ if (dir == null || !dir .exists ()) {
357+ return ;
358+ }
359+ File [] files = dir .listFiles ();
360+ if (files !=null ) {
361+ for (File f : files ) {
362+ if (f .isDirectory ()) {
363+ deleteDirectory (f );
364+ }else {
365+ f .delete ();
366+ }
367+ }
368+ }
369+ dir .delete ();
370+ }
371+
372+ public static void touchDirectory (final File dir ) {
373+ if (dir == null || !dir .exists ()) {
374+ return ;
375+ }
376+ long timestamp ;
377+ File [] files = dir .listFiles ();
378+ if (files !=null ) {
379+ for (File f : files ) {
380+ if (f .isDirectory ()) {
381+ touchDirectory (f );
382+ }else {
383+ timestamp = System .currentTimeMillis ();
384+ f .setLastModified (timestamp );
385+ }
386+ }
387+ }
388+ timestamp = System .currentTimeMillis ();
389+ dir .setLastModified (timestamp );
390+ System .out .println ("Touched contents of directory : " + dir );
391+ }
338392}
Original file line number Diff line number Diff line change 11/*
22 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
33 *
4- * Copyright (c) 2012 Oracle and/or its affiliates. All rights reserved.
4+ * Copyright (c) 2012-2017 Oracle and/or its affiliates. All rights reserved.
55 *
66 * The contents of this file are subject to the terms of either the GNU
77 * General Public License Version 2 only ("GPL") or the Common Development
4444import java .util .HashSet ;
4545import java .util .List ;
4646import java .util .Set ;
47+ import java .io .File ;
4748import java .util .StringTokenizer ;
4849import java .util .concurrent .Callable ;
4950import java .util .concurrent .ExecutionException ;
6263 */
6364@ Test (testName ="DetachAttachTest" )
6465public class DetachAttachTest {
65-
66+ private static File nucleusRoot = getNucleusRoot ();
67+
6668 @ AfterTest
6769 public void cleanUp () throws Exception {
6870 nadmin ("stop-domain" );
6971 JobManagerTest .deleteJobsFile ();
72+ //osgi-cache workaround
73+ touchDirectory (nucleusRoot );
7074 nadmin ("start-domain" );
7175 }
7276
Original file line number Diff line number Diff line change 11/*
22 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
33 *
4- * Copyright (c) 2012 Oracle and/or its affiliates. All rights reserved.
4+ * Copyright (c) 2012-2017 Oracle and/or its affiliates. All rights reserved.
55 *
66 * The contents of this file are subject to the terms of either the GNU
77 * General Public License Version 2 only ("GPL") or the Common Development
@@ -65,7 +65,8 @@ public void setUp() throws Exception {
6565 nadmin ("stop-domain" );
6666 //delete jobs.xml incase there were other jobs run
6767 deleteJobsFile ();
68-
68+ //osgi-cache workaround
69+ touchDirectory (nucleusRoot );
6970 nadmin ("start-domain" );
7071
7172
You can’t perform that action at this time.
0 commit comments