@@ -454,6 +454,68 @@ int main(int argc, char **argv) {
454454 hdfsCloseFile (lfs , localFile );
455455 }
456456
457+
458+ {
459+ // HDFS Open File Builder tests
460+
461+ exists = hdfsExists (fs , readPath );
462+
463+ if (exists ) {
464+ fprintf (stderr , "Failed to validate existence of %s\n" , readPath );
465+ shutdown_and_exit (cl , -1 );
466+ }
467+
468+ hdfsOpenFileBuilder * builder ;
469+ builder = hdfsOpenFileBuilderAlloc (fs , readPath );
470+ hdfsOpenFileBuilderOpt (builder , "hello" , "world" );
471+
472+ hdfsOpenFileFuture * future ;
473+ future = hdfsOpenFileBuilderBuild (builder );
474+
475+ readFile = hdfsOpenFileFutureGet (future );
476+ if (!hdfsOpenFileFutureCancel (future , 0 )) {
477+ fprintf (stderr , "Cancel on a completed Future should return false" );
478+ shutdown_and_exit (cl , -1 );
479+ }
480+ hdfsOpenFileFutureFree (future );
481+
482+ memset (buffer , 0 , sizeof (buffer ));
483+ num_read_bytes = hdfsRead (fs , readFile , (void * ) buffer ,
484+ sizeof (buffer ));
485+ if (strncmp (fileContents , buffer , strlen (fileContents )) != 0 ) {
486+ fprintf (stderr ,
487+ "Failed to read. Expected %s but got %s (%d bytes)\n" ,
488+ fileContents , buffer , num_read_bytes );
489+ shutdown_and_exit (cl , -1 );
490+ }
491+ hdfsCloseFile (fs , readFile );
492+
493+ builder = hdfsOpenFileBuilderAlloc (fs , readPath );
494+ hdfsOpenFileBuilderOpt (builder , "hello" , "world" );
495+
496+ future = hdfsOpenFileBuilderBuild (builder );
497+
498+ readFile = hdfsOpenFileFutureGetWithTimeout (future , 1 , jDays );
499+ if (!hdfsOpenFileFutureCancel (future , 0 )) {
500+ fprintf (stderr , "Cancel on a completed Future should return "
501+ "false" );
502+ shutdown_and_exit (cl , -1 );
503+ }
504+ hdfsOpenFileFutureFree (future );
505+
506+ memset (buffer , 0 , sizeof (buffer ));
507+ num_read_bytes = hdfsRead (fs , readFile , (void * )buffer ,
508+ sizeof (buffer ));
509+ if (strncmp (fileContents , buffer , strlen (fileContents )) != 0 ) {
510+ fprintf (stderr , "Failed to read. Expected %s but got "
511+ "%s (%d bytes)\n" , fileContents , buffer ,
512+ num_read_bytes );
513+ shutdown_and_exit (cl , -1 );
514+ }
515+ memset (buffer , 0 , strlen (fileContents + 1 ));
516+ hdfsCloseFile (fs , readFile );
517+ }
518+
457519 totalResult = 0 ;
458520 result = 0 ;
459521 {
0 commit comments