@@ -628,15 +628,17 @@ protected PrivilegedOperationExecutor getPrivilegedOperationExecutor() {
628
628
when (context .getEnvironment ()).thenReturn (env );
629
629
Path workDir = new Path ("/tmp" );
630
630
631
+ LocalizerStartContext lsc = new LocalizerStartContext .Builder ()
632
+ .setNmPrivateContainerTokens (nmPrivateCTokensPath )
633
+ .setNmAddr (address )
634
+ .setUser (appSubmitter )
635
+ .setAppId (appId .toString ())
636
+ .setLocId ("12345" )
637
+ .setDirsHandler (dirService )
638
+ .build ();
639
+
631
640
try {
632
- lce .startLocalizer (new LocalizerStartContext .Builder ()
633
- .setNmPrivateContainerTokens (nmPrivateCTokensPath )
634
- .setNmAddr (address )
635
- .setUser (appSubmitter )
636
- .setAppId (appId .toString ())
637
- .setLocId ("12345" )
638
- .setDirsHandler (dirService )
639
- .build ());
641
+ lce .startLocalizer (lsc );
640
642
Assert .fail ("startLocalizer should have thrown an exception" );
641
643
} catch (IOException e ) {
642
644
assertTrue ("Unexpected exception " + e ,
@@ -648,30 +650,23 @@ protected PrivilegedOperationExecutor getPrivilegedOperationExecutor() {
648
650
LinuxContainerExecutor .ExitCode .INVALID_CONFIG_FILE .getExitCode (),
649
651
};
650
652
651
- for (int i = 0 ; i < exitCodesToThrow .length ; i ++) {
652
- int exitCode = exitCodesToThrow [i ];
653
+ for (int exitCode : exitCodesToThrow ) {
653
654
doThrow (new PrivilegedOperationException ("invalid config" , exitCode , null , null ))
654
655
.when (spyPrivilegedExecutor ).executePrivilegedOperation (
655
656
any (), any (PrivilegedOperation .class ),
656
657
any (), any (), anyBoolean (), anyBoolean ());
657
658
658
659
try {
659
- lce .startLocalizer (new LocalizerStartContext .Builder ()
660
- .setNmPrivateContainerTokens (nmPrivateCTokensPath )
661
- .setNmAddr (address )
662
- .setUser (appSubmitter )
663
- .setAppId (appId .toString ())
664
- .setLocId ("12345" )
665
- .setDirsHandler (dirService )
666
- .build ());
660
+ lce .startLocalizer (lsc );
667
661
Assert .fail ("startLocalizer should have thrown a ConfigurationException" );
668
662
} catch (ConfigurationException e ) {
669
663
assertTrue ("Unexpected exception " + e ,
670
664
e .getMessage ().contains ("exitCode=" + exitCode ));
671
665
}
672
666
}
673
667
674
- // Assert that we do catch an IOException thrown by the ProcessBuilder.start method as a misconfiguration
668
+ // Assert that we do catch an IOException thrown by the ProcessBuilder.start
669
+ // method as a misconfiguration
675
670
String containerExecutorPath = lce .getContainerExecutorExecutablePath (conf );
676
671
doThrow (new PrivilegedOperationException ("IO error" ,
677
672
new IOException ("Cannot run program \" " + containerExecutorPath + "\" " )))
@@ -680,14 +675,7 @@ protected PrivilegedOperationExecutor getPrivilegedOperationExecutor() {
680
675
any (), any (), anyBoolean (), anyBoolean ());
681
676
682
677
try {
683
- lce .startLocalizer (new LocalizerStartContext .Builder ()
684
- .setNmPrivateContainerTokens (nmPrivateCTokensPath )
685
- .setNmAddr (address )
686
- .setUser (appSubmitter )
687
- .setAppId (appId .toString ())
688
- .setLocId ("12345" )
689
- .setDirsHandler (dirService )
690
- .build ());
678
+ lce .startLocalizer (lsc );
691
679
Assert .fail ("startLocalizer should have thrown an ConfigurationException" );
692
680
} catch (ConfigurationException e ) {
693
681
assertTrue ("Unexpected exception " + e ,
@@ -702,14 +690,7 @@ protected PrivilegedOperationExecutor getPrivilegedOperationExecutor() {
702
690
any (), any (), anyBoolean (), anyBoolean ());
703
691
704
692
try {
705
- lce .startLocalizer (new LocalizerStartContext .Builder ()
706
- .setNmPrivateContainerTokens (nmPrivateCTokensPath )
707
- .setNmAddr (address )
708
- .setUser (appSubmitter )
709
- .setAppId (appId .toString ())
710
- .setLocId ("12345" )
711
- .setDirsHandler (dirService )
712
- .build ());
693
+ lce .startLocalizer (lsc );
713
694
Assert .fail ("startLocalizer should have thrown an IOException" );
714
695
} catch (ConfigurationException e ) {
715
696
Assert .fail ("startLocalizer should not have thrown a ConfigurationException" );
0 commit comments