@Test public void customizeTargetTestClasses() { Context standardContext = mock(Context.class); StandardRoot webResourceRoot = new StandardRoot(standardContext); Mockito.when(standardContext.getResources()).thenReturn(webResourceRoot); Mockito.when(standardContext.getAddWebinfClassesResources()).thenReturn(Boolean.FALSE); String absolutePath = new File("").getAbsolutePath(); String internalPath = METAINF_RESOURCES; String targetTestClassesBase = absolutePath + "/" + "build/resources/test"; File testClassesResources = new File(targetTestClassesBase + internalPath); if (!testClassesResources.mkdirs()) { throw new RuntimeException("Could not create dir: " + testClassesResources.toString()); } JsfTomcatContextCustomizer jsfTomcatContextCustomizer = new JsfTomcatContextCustomizer(); jsfTomcatContextCustomizer.customize(standardContext); JsfTomcatApplicationListener jsfTomcatApplicationListener = new JsfTomcatApplicationListener(jsfTomcatContextCustomizer.getContext()); jsfTomcatApplicationListener.onApplicationEvent(mock(ApplicationReadyEvent.class)); if (!testClassesResources.delete()) { throw new RuntimeException("Could not delete dir: " + testClassesResources.toString()); } assertThat(webResourceRoot.getPostResources().length) .isGreaterThanOrEqualTo(10); }
@Test public void customize() { Context standardContext = mock(Context.class); StandardRoot webResourceRoot = new StandardRoot(standardContext); Mockito.when(standardContext.getResources()).thenReturn(webResourceRoot); Mockito.when(standardContext.getAddWebinfClassesResources()).thenReturn(Boolean.FALSE); JsfTomcatContextCustomizer jsfTomcatContextCustomizer = new JsfTomcatContextCustomizer(); jsfTomcatContextCustomizer.customize(standardContext); JsfTomcatApplicationListener jsfTomcatApplicationListener = new JsfTomcatApplicationListener(jsfTomcatContextCustomizer.getContext()); jsfTomcatApplicationListener.onApplicationEvent(mock(ApplicationReadyEvent.class)); assertThat(webResourceRoot.getPostResources().length) .isGreaterThanOrEqualTo(9); }
@Test public void customizeTargetTestClasses() throws LifecycleException { Context standardContext = Mockito.mock(Context.class); StandardRoot webResourceRoot = new StandardRoot(standardContext); Mockito.when(standardContext.getResources()).thenReturn(webResourceRoot); Mockito.when(standardContext.getAddWebinfClassesResources()).thenReturn(Boolean.FALSE); String absolutePath = new File("").getAbsolutePath(); String internalPath = METAINF_RESOURCES; String targetTestClassesBase = absolutePath + "/" + "target/test-classes"; File testClassesResources = new File(targetTestClassesBase + internalPath); if (!testClassesResources.mkdirs()) { throw new RuntimeException("Could not create dir: " + testClassesResources.toString()); } JsfTomcatContextCustomizer jsfTomcatContextCustomizer = new JsfTomcatContextCustomizer(); jsfTomcatContextCustomizer.customize(standardContext); JsfTomcatApplicationListener jsfTomcatApplicationListener = JsfTomcatApplicationListener .builder().context(jsfTomcatContextCustomizer.getContext()).build(); jsfTomcatApplicationListener.onApplicationEvent(null); if (!testClassesResources.delete()) { throw new RuntimeException("Could not delete dir: " + testClassesResources.toString()); } assertThat(webResourceRoot.getPostResources().length) .isEqualTo(10); }
@Test public void customizeTargetTestClasses() throws LifecycleException { Context standardContext = Mockito.mock(Context.class); StandardRoot webResourceRoot = new StandardRoot(standardContext); Mockito.when(standardContext.getResources()).thenReturn(webResourceRoot); Mockito.when(standardContext.getAddWebinfClassesResources()).thenReturn(Boolean.FALSE); String absolutePath = new File("").getAbsolutePath(); String internalPath = METAINF_RESOURCES; String targetTestClassesBase = absolutePath + "/" + "target/test-classes"; File testClassesResources = new File(targetTestClassesBase + internalPath); if (!testClassesResources.mkdirs()) { throw new RuntimeException("Could not create dir: " + testClassesResources.toString()); } JsfTomcatContextCustomizer jsfTomcatContextCustomizer = new JsfTomcatContextCustomizer(); jsfTomcatContextCustomizer.customize(standardContext); JsfTomcatApplicationListener jsfTomcatApplicationListener = JsfTomcatApplicationListener .builder().context(jsfTomcatContextCustomizer.getContext()).build(); jsfTomcatApplicationListener.onApplicationEvent(null); if (!testClassesResources.delete()) { throw new RuntimeException("Could not delete dir: " + testClassesResources.toString()); } assertThat(webResourceRoot.getPostResources().length) .isEqualTo(3); }
@Test public void customize() throws LifecycleException { Context standardContext = Mockito.mock(Context.class); StandardRoot webResourceRoot = new StandardRoot(standardContext); Mockito.when(standardContext.getResources()).thenReturn(webResourceRoot); Mockito.when(standardContext.getAddWebinfClassesResources()).thenReturn(Boolean.FALSE); JsfTomcatContextCustomizer jsfTomcatContextCustomizer = new JsfTomcatContextCustomizer(); jsfTomcatContextCustomizer.customize(standardContext); JsfTomcatApplicationListener jsfTomcatApplicationListener = JsfTomcatApplicationListener .builder().context(jsfTomcatContextCustomizer.getContext()).build(); jsfTomcatApplicationListener.onApplicationEvent(null); assertThat(webResourceRoot.getPostResources().length) .isEqualTo(2); }
@Test public void customize() throws LifecycleException { Context standardContext = Mockito.mock(Context.class); StandardRoot webResourceRoot = new StandardRoot(standardContext); Mockito.when(standardContext.getResources()).thenReturn(webResourceRoot); Mockito.when(standardContext.getAddWebinfClassesResources()).thenReturn(Boolean.FALSE); JsfTomcatContextCustomizer jsfTomcatContextCustomizer = new JsfTomcatContextCustomizer(); jsfTomcatContextCustomizer.customize(standardContext); JsfTomcatApplicationListener jsfTomcatApplicationListener = JsfTomcatApplicationListener .builder().context(jsfTomcatContextCustomizer.getContext()).build(); jsfTomcatApplicationListener.onApplicationEvent(null); assertThat(webResourceRoot.getPostResources().length) .isEqualTo(9); }