DefaultWebApplicationExtensionContext implements WebApplicationExtensionContext { @Override public void add(Class<? extends WebApplicationExtension> extension) { try { WebApplicationExtension instance = extension.getDeclaredConstructor().newInstance(); instance.extend(this); extensions.add(instance); extensionClasses.add(extension); } catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException ex) { ex.printStackTrace(); } } DefaultWebApplicationExtensionContext(); @Override void add(Class<? extends WebApplicationExtension> extension); @Override void add(WebApplicationExtension extension); void configure(WebApplication webApplication); @Override void remove(Class<? extends WebApplicationExtension> extension);  }
@Test void testAdd() { DefaultWebApplicationExtensionContext context = new DefaultWebApplicationExtensionContext(); DefaultWebApplication webApplication = new DefaultWebApplication(); context.add(TestExtension.class); context.configure(webApplication); webApplication.initialize(); assertNotNull(webApplication.getAttribute(TestInitializer.class.getName())); }