@@ -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,65 @@ 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+ String expectedFullPath = "/user/testuser/.gobblinCache/gobblin-temporal/" ;
192+
193+ // Mock: Root directory exists
194+ Mockito .when (mockFs .exists (Mockito .any (Path .class ))).thenAnswer (new Answer <Boolean >() {
195+ @ Override
196+ public Boolean answer (InvocationOnMock invocation ) {
197+ Path path = invocation .getArgument (0 );
198+ return path .toString ().equals (rootDir );
199+ }
200+ });
201+
202+ // Config without JAR_CACHE_SUFFIX - should use default
203+ Config config = ConfigFactory .empty ()
204+ .withValue (GobblinYarnConfigurationKeys .JAR_CACHE_ROOT_DIR , ConfigValueFactory .fromAnyRef (rootDir ))
205+ .withValue (GobblinYarnConfigurationKeys .JAR_CACHE_ENABLED , ConfigValueFactory .fromAnyRef (true ))
206+ .withValue (GobblinYarnConfigurationKeys .YARN_APPLICATION_LAUNCHER_START_TIME_KEY ,
207+ ConfigValueFactory .fromAnyRef (System .currentTimeMillis ()));
208+
209+ Path result = JarCachePathResolver .resolveJarCachePath (config , mockFs );
210+
211+ // Should use default suffix
212+ Assert .assertEquals (result .toString (), expectedFullPath );
213+ }
214+
215+ @ Test
216+ public void testResolveJarCachePath_EmptySuffixUsesDefault () throws IOException {
217+ FileSystem mockFs = Mockito .mock (FileSystem .class );
218+ String rootDir = "/user/testuser" ;
219+ String expectedFullPath = "/user/testuser/.gobblinCache/gobblin-temporal/" ;
220+
221+ // Mock: Root directory exists
222+ Mockito .when (mockFs .exists (Mockito .any (Path .class ))).thenAnswer (new Answer <Boolean >() {
223+ @ Override
224+ public Boolean answer (InvocationOnMock invocation ) {
225+ Path path = invocation .getArgument (0 );
226+ return path .toString ().equals (rootDir );
227+ }
228+ });
229+
230+ // Config with empty JAR_CACHE_SUFFIX - should use default
231+ Config config = ConfigFactory .empty ()
232+ .withValue (GobblinYarnConfigurationKeys .JAR_CACHE_ROOT_DIR , ConfigValueFactory .fromAnyRef (rootDir ))
233+ .withValue (GobblinYarnConfigurationKeys .JAR_CACHE_SUFFIX , ConfigValueFactory .fromAnyRef ("" ))
234+ .withValue (GobblinYarnConfigurationKeys .JAR_CACHE_ENABLED , ConfigValueFactory .fromAnyRef (true ))
235+ .withValue (GobblinYarnConfigurationKeys .YARN_APPLICATION_LAUNCHER_START_TIME_KEY ,
236+ ConfigValueFactory .fromAnyRef (System .currentTimeMillis ()));
237+
238+ Path result = JarCachePathResolver .resolveJarCachePath (config , mockFs );
239+
240+ // Should use default suffix when configured suffix is empty
241+ Assert .assertEquals (result .toString (), expectedFullPath );
191242 }
192243
193244 @ Test
@@ -213,8 +264,7 @@ public Boolean answer(InvocationOnMock invocation) {
213264 .withValue (GobblinYarnConfigurationKeys .YARN_APPLICATION_LAUNCHER_START_TIME_KEY ,
214265 ConfigValueFactory .fromAnyRef (System .currentTimeMillis ()));
215266
216- JarCachePathResolver resolver = new JarCachePathResolver (config , mockFs );
217- Path result = resolver .resolveJarCachePath ();
267+ Path result = JarCachePathResolver .resolveJarCachePath (config , mockFs );
218268
219269 // Should normalize suffix by stripping leading '/' to avoid absolute path issue
220270 Assert .assertEquals (result .toString (), expectedFullPath );
0 commit comments