/** * Starts the container. * <p> * May be called once, only. * <p> * One of the init methods must be called, first. */ public final void start() { checkState(initialized, "handler has not been initialized"); checkState(!started, "container has already been started"); container.onStartup(); started = true; }
@Test public void onStartup_ShouldStartAppHandler() { container.onStartup(); verify(appHandler, times(1)).onStartup(container); }
@Test public void start_Initialized_ShouldDelegateStartToContainer() { @SuppressWarnings("unchecked") JRestlessHandlerContainer<JRestlessContainerRequest> customContainer = mock(JRestlessHandlerContainer.class); SimpleRequestHandlerImpl customHandler = new SimpleRequestHandlerImpl(); customHandler.init(customContainer); customHandler.start(); verify(customContainer).onStartup(); }
@BeforeEach public void setup() { testService = mock(ArticleService.class); Binder binder = new InstanceBinder.Builder().addInstance(testService, ArticleService.class).build(); container = new JRestlessHandlerContainer<JRestlessContainerRequest>( new ResourceConfig().register(TestResource.class).register(binder).register(RolesAllowedDynamicFeature.class)); container.onStartup(); }