20
20
21
21
import java .io .File ;
22
22
import java .io .IOException ;
23
+ import java .nio .file .Files ;
23
24
import java .text .SimpleDateFormat ;
24
25
import java .util .Calendar ;
25
26
import java .util .Date ;
26
27
import java .util .Locale ;
27
28
28
- import org .apache .maven .shared .utils .io .FileUtils ;
29
29
import org .apache .maven .shared .verifier .VerificationException ;
30
30
import org .apache .maven .shared .verifier .util .ResourceExtractor ;
31
+ import org .codehaus .plexus .util .FileUtils ;
31
32
import org .junit .jupiter .api .BeforeEach ;
32
33
import org .junit .jupiter .api .Disabled ;
33
34
import org .junit .jupiter .api .Test ;
@@ -69,7 +70,7 @@ protected void setUp() throws Exception {
69
70
repository ,
70
71
"org/apache/maven/maven-core-it-support/1.0-SNAPSHOT/maven-core-it-support-1.0-SNAPSHOT.jar" );
71
72
artifact .getParentFile ().mkdirs ();
72
- FileUtils . fileWrite (artifact .getAbsolutePath (), "originalArtifact" );
73
+ Files . writeString (artifact .getAbsoluteFile (). toPath (), "originalArtifact" );
73
74
74
75
verifier .verifyArtifactNotPresent ("org.apache.maven" , "maven-core-it-support" , "1.0-SNAPSHOT" , "jar" );
75
76
}
@@ -86,7 +87,7 @@ public void testSnapshotUpdated() throws Exception {
86
87
// set in the past to ensure it is downloaded
87
88
localRepoFile .setLastModified (System .currentTimeMillis () - TIME_OFFSET );
88
89
89
- FileUtils . fileWrite (artifact .getAbsolutePath (), "updatedArtifact" );
90
+ Files . writeString (artifact .getAbsoluteFile (). toPath (), "updatedArtifact" );
90
91
91
92
verifier .addCliArgument ("package" );
92
93
verifier .execute ();
@@ -99,8 +100,9 @@ public void testSnapshotUpdated() throws Exception {
99
100
@ Test
100
101
public void testSnapshotUpdatedWithMetadata () throws Exception {
101
102
File metadata = new File (repository , "org/apache/maven/maven-core-it-support/1.0-SNAPSHOT/maven-metadata.xml" );
102
- FileUtils .fileWrite (
103
- metadata .getAbsolutePath (), constructMetadata ("1" , System .currentTimeMillis () - TIME_OFFSET , true ));
103
+ Files .writeString (
104
+ metadata .getAbsoluteFile ().toPath (),
105
+ constructMetadata ("1" , System .currentTimeMillis () - TIME_OFFSET , true ));
104
106
105
107
verifier .addCliArgument ("package" );
106
108
verifier .execute ();
@@ -109,9 +111,10 @@ public void testSnapshotUpdatedWithMetadata() throws Exception {
109
111
110
112
verifyArtifactContent ("originalArtifact" );
111
113
112
- FileUtils . fileWrite (artifact .getAbsolutePath (), "updatedArtifact" );
114
+ Files . writeString (artifact .getAbsoluteFile (). toPath (), "updatedArtifact" );
113
115
metadata = new File (repository , "org/apache/maven/maven-core-it-support/1.0-SNAPSHOT/maven-metadata.xml" );
114
- FileUtils .fileWrite (metadata .getAbsolutePath (), constructMetadata ("2" , System .currentTimeMillis (), true ));
116
+ Files .writeString (
117
+ metadata .getAbsoluteFile ().toPath (), constructMetadata ("2" , System .currentTimeMillis (), true ));
115
118
116
119
verifier .addCliArgument ("package" );
117
120
verifier .execute ();
@@ -130,8 +133,9 @@ public void testSnapshotUpdatedWithLocalMetadata() throws Exception {
130
133
localMetadata .getParentFile ().mkdirs ();
131
134
132
135
File metadata = new File (repository , "org/apache/maven/maven-core-it-support/1.0-SNAPSHOT/maven-metadata.xml" );
133
- FileUtils .fileWrite (
134
- metadata .getAbsolutePath (), constructMetadata ("1" , System .currentTimeMillis () - TIME_OFFSET , true ));
136
+ Files .writeString (
137
+ metadata .getAbsoluteFile ().toPath (),
138
+ constructMetadata ("1" , System .currentTimeMillis () - TIME_OFFSET , true ));
135
139
136
140
verifier .addCliArgument ("package" );
137
141
verifier .execute ();
@@ -141,9 +145,9 @@ public void testSnapshotUpdatedWithLocalMetadata() throws Exception {
141
145
verifyArtifactContent ("originalArtifact" );
142
146
assertFalse (localMetadata .exists ());
143
147
144
- FileUtils . fileWrite (localRepoFile .getAbsolutePath (), "localArtifact" );
145
- FileUtils . fileWrite (
146
- localMetadata .getAbsolutePath (),
148
+ Files . writeString (localRepoFile .getAbsoluteFile (). toPath (), "localArtifact" );
149
+ Files . writeString (
150
+ localMetadata .getAbsoluteFile (). toPath (),
147
151
constructLocalMetadata ("org.apache.maven" , "maven-core-it-support" , System .currentTimeMillis (), true ));
148
152
// update the remote file, but we shouldn't be looking
149
153
artifact .setLastModified (System .currentTimeMillis ());
@@ -157,11 +161,11 @@ public void testSnapshotUpdatedWithLocalMetadata() throws Exception {
157
161
158
162
Calendar cal = Calendar .getInstance ();
159
163
cal .add (Calendar .YEAR , -1 );
160
- FileUtils . fileWrite (
161
- localMetadata .getAbsolutePath (),
164
+ Files . writeString (
165
+ localMetadata .getAbsoluteFile (). toPath (),
162
166
constructLocalMetadata ("org.apache.maven" , "maven-core-it-support" , cal .getTimeInMillis (), true ));
163
- FileUtils . fileWrite (
164
- metadata .getAbsolutePath (), constructMetadata ("2" , System .currentTimeMillis () - 2000 , true ));
167
+ Files . writeString (
168
+ metadata .getAbsoluteFile (). toPath (), constructMetadata ("2" , System .currentTimeMillis () - 2000 , true ));
165
169
artifact .setLastModified (System .currentTimeMillis ());
166
170
167
171
verifier .addCliArgument ("package" );
@@ -175,8 +179,9 @@ public void testSnapshotUpdatedWithLocalMetadata() throws Exception {
175
179
@ Test
176
180
public void testSnapshotUpdatedWithMetadataUsingFileTimestamp () throws Exception {
177
181
File metadata = new File (repository , "org/apache/maven/maven-core-it-support/1.0-SNAPSHOT/maven-metadata.xml" );
178
- FileUtils .fileWrite (
179
- metadata .getAbsolutePath (), constructMetadata ("1" , System .currentTimeMillis () - TIME_OFFSET , false ));
182
+ Files .writeString (
183
+ metadata .getAbsoluteFile ().toPath (),
184
+ constructMetadata ("1" , System .currentTimeMillis () - TIME_OFFSET , false ));
180
185
metadata .setLastModified (System .currentTimeMillis () - TIME_OFFSET );
181
186
182
187
verifier .addCliArgument ("package" );
@@ -186,9 +191,10 @@ public void testSnapshotUpdatedWithMetadataUsingFileTimestamp() throws Exception
186
191
187
192
verifyArtifactContent ("originalArtifact" );
188
193
189
- FileUtils . fileWrite (artifact .getAbsolutePath (), "updatedArtifact" );
194
+ Files . writeString (artifact .getAbsoluteFile (). toPath (), "updatedArtifact" );
190
195
metadata = new File (repository , "org/apache/maven/maven-core-it-support/1.0-SNAPSHOT/maven-metadata.xml" );
191
- FileUtils .fileWrite (metadata .getAbsolutePath (), constructMetadata ("2" , System .currentTimeMillis (), false ));
196
+ Files .writeString (
197
+ metadata .getAbsoluteFile ().toPath (), constructMetadata ("2" , System .currentTimeMillis (), false ));
192
198
193
199
verifier .addCliArgument ("package" );
194
200
verifier .execute ();
0 commit comments