@@ -157,6 +157,41 @@ protected AbstractBackgroundInitializerTestImpl getBackgroundInitializerTestImpl
157157 return new MethodBackgroundInitializerTestImpl (exec );
158158 }
159159
160+ @ Test
161+ void testBuilder () throws ConcurrentException {
162+ // @formatter:off
163+ final BackgroundInitializer <Object > backgroundInitializer = BackgroundInitializer .builder ()
164+ .setCloser (null )
165+ .setExternalExecutor (null )
166+ .setInitializer (null )
167+ .get ();
168+ // @formatter:on
169+ assertNull (backgroundInitializer .getExternalExecutor ());
170+ assertFalse (backgroundInitializer .isInitialized ());
171+ assertFalse (backgroundInitializer .isStarted ());
172+ assertThrows (IllegalStateException .class , backgroundInitializer ::getFuture );
173+ }
174+
175+ @ Test
176+ void testBuilderThenGetFailures () throws ConcurrentException {
177+ // @formatter:off
178+ final BackgroundInitializer <Object > backgroundInitializer = BackgroundInitializer .builder ()
179+ .setCloser (null )
180+ .setExternalExecutor (null )
181+ .setInitializer (() -> {
182+ throw new IllegalStateException ("test" );
183+ })
184+ .get ();
185+ // @formatter:on
186+ assertNull (backgroundInitializer .getExternalExecutor ());
187+ assertFalse (backgroundInitializer .isInitialized ());
188+ assertFalse (backgroundInitializer .isStarted ());
189+ assertThrows (IllegalStateException .class , backgroundInitializer ::getFuture );
190+ // start
191+ backgroundInitializer .start ();
192+ assertEquals ("test" , assertThrows (IllegalStateException .class , backgroundInitializer ::get ).getMessage ());
193+ }
194+
160195 /**
161196 * Tries to obtain the executor before start(). It should not have been
162197 * initialized yet.
@@ -174,8 +209,7 @@ void testGetActiveExecutorBeforeStart() {
174209 void testGetActiveExecutorExternal () throws InterruptedException , ConcurrentException {
175210 final ExecutorService exec = Executors .newSingleThreadExecutor ();
176211 try {
177- final AbstractBackgroundInitializerTestImpl init = getBackgroundInitializerTestImpl (
178- exec );
212+ final AbstractBackgroundInitializerTestImpl init = getBackgroundInitializerTestImpl (exec );
179213 init .start ();
180214 assertSame (exec , init .getActiveExecutor (), "Wrong executor" );
181215 checkInitialize (init );
0 commit comments