@@ -209,4 +209,207 @@ public void test_parseProjectProperties_threadSafety() throws InterruptedExcepti
209209 assertTrue ("All threads should see the property set" , result );
210210 }
211211 }
212+
213+ public void test_constructor_initialization () {
214+ // Given & When
215+ CustomSystemHelper helper = new CustomSystemHelper ();
216+
217+ // Then
218+ assertNotNull ("Helper instance should not be null" , helper );
219+ assertTrue ("Helper should be instance of SystemHelper" , helper instanceof org .codelibs .fess .helper .SystemHelper );
220+ assertTrue ("Helper should be instance of CustomSystemHelper" , helper instanceof CustomSystemHelper );
221+ }
222+
223+ public void test_parseProjectProperties_overwritesExistingProperty () {
224+ // Given
225+ CustomSystemHelper helper = new CustomSystemHelper ();
226+ System .setProperty ("fess.webapp.plugin" , "false" );
227+ assertEquals ("false" , System .getProperty ("fess.webapp.plugin" ));
228+
229+ // When
230+ helper .parseProjectProperties (null );
231+
232+ // Then
233+ assertEquals ("Property should be overwritten to true" , "true" , System .getProperty ("fess.webapp.plugin" ));
234+ }
235+
236+ public void test_parseProjectProperties_withAbsolutePath () {
237+ // Given
238+ CustomSystemHelper helper = new CustomSystemHelper ();
239+ Path absolutePath = Paths .get ("/tmp/test/project.properties" ).toAbsolutePath ();
240+
241+ // When
242+ helper .parseProjectProperties (absolutePath );
243+
244+ // Then
245+ assertEquals ("true" , System .getProperty ("fess.webapp.plugin" ));
246+ }
247+
248+ public void test_parseProjectProperties_withRelativePath () {
249+ // Given
250+ CustomSystemHelper helper = new CustomSystemHelper ();
251+ Path relativePath = Paths .get ("./project.properties" );
252+
253+ // When
254+ helper .parseProjectProperties (relativePath );
255+
256+ // Then
257+ assertEquals ("true" , System .getProperty ("fess.webapp.plugin" ));
258+ }
259+
260+ public void test_parseProjectProperties_withSpecialCharactersInPath () {
261+ // Given
262+ CustomSystemHelper helper = new CustomSystemHelper ();
263+ Path pathWithSpaces = Paths .get ("path with spaces/project.properties" );
264+ Path pathWithUnicode = Paths .get ("パス/project.properties" );
265+
266+ // When
267+ helper .parseProjectProperties (pathWithSpaces );
268+ String resultAfterSpaces = System .getProperty ("fess.webapp.plugin" );
269+
270+ helper .parseProjectProperties (pathWithUnicode );
271+ String resultAfterUnicode = System .getProperty ("fess.webapp.plugin" );
272+
273+ // Then
274+ assertEquals ("true" , resultAfterSpaces );
275+ assertEquals ("true" , resultAfterUnicode );
276+ }
277+
278+ public void test_multipleInstances_independence () {
279+ // Given
280+ CustomSystemHelper helper1 = new CustomSystemHelper ();
281+ CustomSystemHelper helper2 = new CustomSystemHelper ();
282+ CustomSystemHelper helper3 = new CustomSystemHelper ();
283+
284+ // When
285+ helper1 .parseProjectProperties (Paths .get ("path1" ));
286+ helper2 .parseProjectProperties (Paths .get ("path2" ));
287+ helper3 .parseProjectProperties (null );
288+
289+ // Then
290+ assertEquals ("true" , System .getProperty ("fess.webapp.plugin" ));
291+ assertNotSame ("Instances should be different objects" , helper1 , helper2 );
292+ assertNotSame ("Instances should be different objects" , helper2 , helper3 );
293+ }
294+
295+ public void test_parseProjectProperties_consistencyAcrossInstances () {
296+ // Given
297+ System .clearProperty ("fess.webapp.plugin" );
298+ CustomSystemHelper helper1 = new CustomSystemHelper ();
299+ CustomSystemHelper helper2 = new CustomSystemHelper ();
300+
301+ // When
302+ helper1 .parseProjectProperties (Paths .get ("test1" ));
303+ String valueAfterHelper1 = System .getProperty ("fess.webapp.plugin" );
304+
305+ helper2 .parseProjectProperties (Paths .get ("test2" ));
306+ String valueAfterHelper2 = System .getProperty ("fess.webapp.plugin" );
307+
308+ // Then
309+ assertEquals ("true" , valueAfterHelper1 );
310+ assertEquals ("true" , valueAfterHelper2 );
311+ assertEquals ("Values should be consistent" , valueAfterHelper1 , valueAfterHelper2 );
312+ }
313+
314+ public void test_parseProjectProperties_withDifferentPathTypes () {
315+ // Given
316+ CustomSystemHelper helper = new CustomSystemHelper ();
317+ Path [] testPaths = {
318+ null ,
319+ Paths .get ("" ),
320+ Paths .get ("relative/path" ),
321+ Paths .get ("/absolute/path" ),
322+ Paths .get ("../parent/path" ),
323+ Paths .get ("./current/path" )
324+ };
325+
326+ // When & Then
327+ for (Path testPath : testPaths ) {
328+ System .clearProperty ("fess.webapp.plugin" );
329+ helper .parseProjectProperties (testPath );
330+ assertEquals ("Property should be set for all path types" , "true" , System .getProperty ("fess.webapp.plugin" ));
331+ }
332+ }
333+
334+ public void test_parseProjectProperties_propertyValueIsExactlyTrue () {
335+ // Given
336+ CustomSystemHelper helper = new CustomSystemHelper ();
337+ System .clearProperty ("fess.webapp.plugin" );
338+
339+ // When
340+ helper .parseProjectProperties (null );
341+ String propertyValue = System .getProperty ("fess.webapp.plugin" );
342+
343+ // Then
344+ assertNotNull ("Property value should not be null" , propertyValue );
345+ assertEquals ("Property value should be exactly 'true'" , "true" , propertyValue );
346+ assertTrue ("Property value should equal 'true' using equals" , "true" .equals (propertyValue ));
347+ assertFalse ("Property value should not be 'false'" , "false" .equals (propertyValue ));
348+ assertFalse ("Property value should not be empty" , propertyValue .isEmpty ());
349+ }
350+
351+ public void test_parseProjectProperties_idempotency () {
352+ // Given
353+ CustomSystemHelper helper = new CustomSystemHelper ();
354+ System .clearProperty ("fess.webapp.plugin" );
355+
356+ // When
357+ helper .parseProjectProperties (null );
358+ String firstValue = System .getProperty ("fess.webapp.plugin" );
359+
360+ helper .parseProjectProperties (null );
361+ String secondValue = System .getProperty ("fess.webapp.plugin" );
362+
363+ helper .parseProjectProperties (Paths .get ("different/path" ));
364+ String thirdValue = System .getProperty ("fess.webapp.plugin" );
365+
366+ // Then
367+ assertEquals ("true" , firstValue );
368+ assertEquals ("true" , secondValue );
369+ assertEquals ("true" , thirdValue );
370+ assertEquals ("Multiple calls should produce same result (idempotent)" , firstValue , secondValue );
371+ assertEquals ("Multiple calls should produce same result (idempotent)" , secondValue , thirdValue );
372+ }
373+
374+ public void test_parseProjectProperties_doesNotThrowException () {
375+ // Given
376+ CustomSystemHelper helper = new CustomSystemHelper ();
377+ Path [] problematicPaths = {
378+ null ,
379+ Paths .get ("" ),
380+ Paths .get ("/" ),
381+ Paths .get ("non/existent/path" ),
382+ Paths .get ("\\ invalid\\ path" ),
383+ Paths .get ("special!@#$%/path" )
384+ };
385+
386+ // When & Then
387+ for (Path testPath : problematicPaths ) {
388+ try {
389+ helper .parseProjectProperties (testPath );
390+ // No exception should be thrown
391+ assertTrue ("Method should complete without exception" , true );
392+ } catch (Exception e ) {
393+ fail ("Should not throw exception for path: " + testPath + ", but got: " + e .getMessage ());
394+ }
395+ }
396+ }
397+
398+ public void test_parseProjectProperties_stressTest () {
399+ // Given
400+ CustomSystemHelper helper = new CustomSystemHelper ();
401+ final int iterations = 100 ;
402+
403+ // When
404+ long startTime = System .currentTimeMillis ();
405+ for (int i = 0 ; i < iterations ; i ++) {
406+ helper .parseProjectProperties (Paths .get ("test/path/" + i ));
407+ }
408+ long endTime = System .currentTimeMillis ();
409+
410+ // Then
411+ assertEquals ("Property should still be set after stress test" , "true" , System .getProperty ("fess.webapp.plugin" ));
412+ long duration = endTime - startTime ;
413+ assertTrue ("Stress test should complete in reasonable time (< 5 seconds)" , duration < 5000 );
414+ }
212415}
0 commit comments