NinjaServletListener extends GuiceServletContextListener { public synchronized void setNinjaProperties(NinjaPropertiesImpl ninjaPropertiesImpl) { if (this.ninjaProperties != null) { throw new IllegalStateException("NinjaProperties already set."); } this.ninjaProperties = ninjaPropertiesImpl; }  synchronized void setNinjaProperties(NinjaPropertiesImpl ninjaPropertiesImpl); @Override void contextInitialized(ServletContextEvent servletContextEvent); @Override void contextDestroyed(ServletContextEvent servletContextEvent); Bootstrap getNinjaBootstrap(); @Override Injector getInjector();  }
@Test public void testThatSettingNinjaPropertiesTwiceDoesNotWork() { NinjaServletListener ninjaServletListener = new NinjaServletListener(); NinjaPropertiesImpl ninjaProperties = new NinjaPropertiesImpl(NinjaMode.test); ninjaServletListener.setNinjaProperties(ninjaProperties); boolean gotException = false; try { ninjaServletListener.setNinjaProperties(ninjaProperties); } catch (IllegalStateException illegalStateException) { gotException = true; } assertThat(gotException, equalTo(true)); }