@@ -49,8 +49,7 @@ public void testResolveJarCachePath_ExplicitJarCacheDir() throws IOException {
4949 .withValue (GobblinYarnConfigurationKeys .YARN_APPLICATION_LAUNCHER_START_TIME_KEY ,
5050 ConfigValueFactory .fromAnyRef (System .currentTimeMillis ()));
5151
52- JarCachePathResolver resolver = new JarCachePathResolver (config , mockFs );
53- Path result = resolver .resolveJarCachePath ();
52+ Path result = JarCachePathResolver .resolveJarCachePath (config , mockFs );
5453
5554 // Should use explicitly configured JAR_CACHE_DIR
5655 Assert .assertEquals (result .toString (), explicitCacheDir );
@@ -81,8 +80,7 @@ public Boolean answer(InvocationOnMock invocation) {
8180 .withValue (GobblinYarnConfigurationKeys .YARN_APPLICATION_LAUNCHER_START_TIME_KEY ,
8281 ConfigValueFactory .fromAnyRef (System .currentTimeMillis ()));
8382
84- JarCachePathResolver resolver = new JarCachePathResolver (config , mockFs );
85- Path result = resolver .resolveJarCachePath ();
83+ Path result = JarCachePathResolver .resolveJarCachePath (config , mockFs );
8684
8785 // Should resolve to root + suffix
8886 Assert .assertEquals (result .toString (), expectedFullPath );
@@ -114,8 +112,7 @@ public Boolean answer(InvocationOnMock invocation) {
114112 .withValue (GobblinYarnConfigurationKeys .YARN_APPLICATION_LAUNCHER_START_TIME_KEY ,
115113 ConfigValueFactory .fromAnyRef (System .currentTimeMillis ()));
116114
117- JarCachePathResolver resolver = new JarCachePathResolver (config , mockFs );
118- Path result = resolver .resolveJarCachePath ();
115+ Path result = JarCachePathResolver .resolveJarCachePath (config , mockFs );
119116
120117 // Should resolve to fallback root + suffix
121118 Assert .assertEquals (result .toString (), expectedFullPath );
@@ -140,9 +137,8 @@ public void testResolveJarCachePath_NeitherRootDirExists() throws IOException {
140137 .withValue (GobblinYarnConfigurationKeys .YARN_APPLICATION_LAUNCHER_START_TIME_KEY ,
141138 ConfigValueFactory .fromAnyRef (System .currentTimeMillis ()));
142139
143- JarCachePathResolver resolver = new JarCachePathResolver (config , mockFs );
144140 // Should throw IOException when no valid root directory found
145- resolver .resolveJarCachePath ();
141+ JarCachePathResolver .resolveJarCachePath (config , mockFs );
146142 }
147143
148144 @ Test
@@ -168,8 +164,7 @@ public Boolean answer(InvocationOnMock invocation) {
168164 .withValue (GobblinYarnConfigurationKeys .YARN_APPLICATION_LAUNCHER_START_TIME_KEY ,
169165 ConfigValueFactory .fromAnyRef (System .currentTimeMillis ()));
170166
171- JarCachePathResolver resolver = new JarCachePathResolver (config , mockFs );
172- Path result = resolver .resolveJarCachePath ();
167+ Path result = JarCachePathResolver .resolveJarCachePath (config , mockFs );
173168
174169 // Should resolve to fallback root + suffix
175170 Assert .assertEquals (result .toString (), expectedFullPath );
@@ -185,9 +180,67 @@ public void testResolveJarCachePath_NoRootDirsConfigured() throws IOException {
185180 .withValue (GobblinYarnConfigurationKeys .YARN_APPLICATION_LAUNCHER_START_TIME_KEY ,
186181 ConfigValueFactory .fromAnyRef (System .currentTimeMillis ()));
187182
188- JarCachePathResolver resolver = new JarCachePathResolver (config , mockFs );
189183 // Should throw IOException when no root directories are configured
190- resolver .resolveJarCachePath ();
184+ JarCachePathResolver .resolveJarCachePath (config , mockFs );
185+ }
186+
187+ @ Test
188+ public void testResolveJarCachePath_DefaultSuffix () throws IOException {
189+ FileSystem mockFs = Mockito .mock (FileSystem .class );
190+ String rootDir = "/user/testuser" ;
191+ // Note: Hadoop Path normalizes and removes trailing slashes
192+ String expectedFullPath = "/user/testuser/.gobblinCache/gobblin-temporal" ;
193+
194+ // Mock: Root directory exists
195+ Mockito .when (mockFs .exists (Mockito .any (Path .class ))).thenAnswer (new Answer <Boolean >() {
196+ @ Override
197+ public Boolean answer (InvocationOnMock invocation ) {
198+ Path path = invocation .getArgument (0 );
199+ return path .toString ().equals (rootDir );
200+ }
201+ });
202+
203+ // Config without JAR_CACHE_SUFFIX - should use default
204+ Config config = ConfigFactory .empty ()
205+ .withValue (GobblinYarnConfigurationKeys .JAR_CACHE_ROOT_DIR , ConfigValueFactory .fromAnyRef (rootDir ))
206+ .withValue (GobblinYarnConfigurationKeys .JAR_CACHE_ENABLED , ConfigValueFactory .fromAnyRef (true ))
207+ .withValue (GobblinYarnConfigurationKeys .YARN_APPLICATION_LAUNCHER_START_TIME_KEY ,
208+ ConfigValueFactory .fromAnyRef (System .currentTimeMillis ()));
209+
210+ Path result = JarCachePathResolver .resolveJarCachePath (config , mockFs );
211+
212+ // Should use default suffix
213+ Assert .assertEquals (result .toString (), expectedFullPath );
214+ }
215+
216+ @ Test
217+ public void testResolveJarCachePath_EmptySuffixUsesDefault () throws IOException {
218+ FileSystem mockFs = Mockito .mock (FileSystem .class );
219+ String rootDir = "/user/testuser" ;
220+ // Note: Hadoop Path normalizes and removes trailing slashes
221+ String expectedFullPath = "/user/testuser/.gobblinCache/gobblin-temporal" ;
222+
223+ // Mock: Root directory exists
224+ Mockito .when (mockFs .exists (Mockito .any (Path .class ))).thenAnswer (new Answer <Boolean >() {
225+ @ Override
226+ public Boolean answer (InvocationOnMock invocation ) {
227+ Path path = invocation .getArgument (0 );
228+ return path .toString ().equals (rootDir );
229+ }
230+ });
231+
232+ // Config with empty JAR_CACHE_SUFFIX - should use default
233+ Config config = ConfigFactory .empty ()
234+ .withValue (GobblinYarnConfigurationKeys .JAR_CACHE_ROOT_DIR , ConfigValueFactory .fromAnyRef (rootDir ))
235+ .withValue (GobblinYarnConfigurationKeys .JAR_CACHE_SUFFIX , ConfigValueFactory .fromAnyRef ("" ))
236+ .withValue (GobblinYarnConfigurationKeys .JAR_CACHE_ENABLED , ConfigValueFactory .fromAnyRef (true ))
237+ .withValue (GobblinYarnConfigurationKeys .YARN_APPLICATION_LAUNCHER_START_TIME_KEY ,
238+ ConfigValueFactory .fromAnyRef (System .currentTimeMillis ()));
239+
240+ Path result = JarCachePathResolver .resolveJarCachePath (config , mockFs );
241+
242+ // Should use default suffix when configured suffix is empty
243+ Assert .assertEquals (result .toString (), expectedFullPath );
191244 }
192245
193246 @ Test
@@ -213,8 +266,7 @@ public Boolean answer(InvocationOnMock invocation) {
213266 .withValue (GobblinYarnConfigurationKeys .YARN_APPLICATION_LAUNCHER_START_TIME_KEY ,
214267 ConfigValueFactory .fromAnyRef (System .currentTimeMillis ()));
215268
216- JarCachePathResolver resolver = new JarCachePathResolver (config , mockFs );
217- Path result = resolver .resolveJarCachePath ();
269+ Path result = JarCachePathResolver .resolveJarCachePath (config , mockFs );
218270
219271 // Should normalize suffix by stripping leading '/' to avoid absolute path issue
220272 Assert .assertEquals (result .toString (), expectedFullPath );
0 commit comments