public ContextMock() { this.standardContext = Mockito.mock(Context.class); this.webResourceRoot = Mockito.mock(WebResourceRoot.class); LifecycleState state = LifecycleState.NEW; Mockito.when(this.webResourceRoot.getContext()) .thenReturn(this.standardContext); Mockito.when(this.webResourceRoot.getState()) .thenReturn(state); Mockito.when(this.standardContext.getResources()) .thenReturn(this.webResourceRoot); Mockito.when(this.standardContext.getAddWebinfClassesResources()) .thenReturn(Boolean.FALSE); }
public ContextMock() { this.standardContext = Mockito.mock(Context.class); this.webResourceRoot = Mockito.mock(WebResourceRoot.class); LifecycleState state = LifecycleState.NEW; Mockito.when(this.webResourceRoot.getContext()) .thenReturn(this.standardContext); Mockito.when(this.webResourceRoot.getState()) .thenReturn(state); Mockito.when(this.standardContext.getResources()) .thenReturn(this.webResourceRoot); Mockito.when(this.standardContext.getAddWebinfClassesResources()) .thenReturn(Boolean.FALSE); }
public ContextMock() { this.standardContext = Mockito.mock(Context.class); this.webResourceRoot = new MockWebResourceRoot(); Mockito.when(this.standardContext.getResources()) .thenReturn(this.webResourceRoot); Mockito.when(this.standardContext.getAddWebinfClassesResources()) .thenReturn(Boolean.FALSE); this.webResourceRoot.setContext(this.standardContext); }
@Test public void resourcesNull() { Context standardContext = mock(Context.class); Mockito.when(standardContext.getResources()).thenReturn(null); 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(jsfTomcatApplicationListener) .isNotNull(); }
setBase(base); if (root.getContext().getAddWebinfClassesResources()) { File f = new File(base, internalPath); f = new File(f, "/WEB-INF/classes/META-INF/resources");
@Test public void jarResourcesNull() { Context standardContext = mock(Context.class); WebResourceRoot webResourceRoot = mock(WebResourceRoot.class); Mockito.when(standardContext.getResources()).thenReturn(webResourceRoot); Mockito.when(standardContext.getAddWebinfClassesResources()).thenReturn(Boolean.FALSE); Mockito.when(webResourceRoot.getJarResources()).thenReturn(null); JsfTomcatContextCustomizer jsfTomcatContextCustomizer = new JsfTomcatContextCustomizer(); jsfTomcatContextCustomizer.customize(standardContext); JsfTomcatApplicationListener jsfTomcatApplicationListener = new JsfTomcatApplicationListener(jsfTomcatContextCustomizer.getContext()); jsfTomcatApplicationListener.onApplicationEvent(mock(ApplicationReadyEvent.class)); assertThat(jsfTomcatApplicationListener) .isNotNull(); }
setBase(base); if (root.getContext().getAddWebinfClassesResources()) { File f = new File(base, internalPath); f = new File(f, "/WEB-INF/classes/META-INF/resources");
setBase(base); if (root.getContext().getAddWebinfClassesResources()) { File f = new File(base, internalPath); f = new File(f, "/WEB-INF/classes/META-INF/resources");
@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 jarResourcesNull() throws LifecycleException { Context standardContext = Mockito.mock(Context.class); WebResourceRoot webResourceRoot = Mockito.mock(WebResourceRoot.class); Mockito.when(standardContext.getResources()).thenReturn(webResourceRoot); Mockito.when(standardContext.getAddWebinfClassesResources()).thenReturn(Boolean.FALSE); Mockito.when(webResourceRoot.getJarResources()).thenReturn(null); JsfTomcatContextCustomizer jsfTomcatContextCustomizer = new JsfTomcatContextCustomizer(); jsfTomcatContextCustomizer.customize(standardContext); JsfTomcatApplicationListener jsfTomcatApplicationListener = JsfTomcatApplicationListener .builder().context(jsfTomcatContextCustomizer.getContext()).build(); jsfTomcatApplicationListener.onApplicationEvent(null); assertThat(jsfTomcatApplicationListener) .isNotNull(); }
@Test public void jarResourcesNull() throws LifecycleException { Context standardContext = Mockito.mock(Context.class); WebResourceRoot webResourceRoot = Mockito.mock(WebResourceRoot.class); Mockito.when(standardContext.getResources()).thenReturn(webResourceRoot); Mockito.when(standardContext.getAddWebinfClassesResources()).thenReturn(Boolean.FALSE); Mockito.when(webResourceRoot.getJarResources()).thenReturn(null); JsfTomcatContextCustomizer jsfTomcatContextCustomizer = new JsfTomcatContextCustomizer(); jsfTomcatContextCustomizer.customize(standardContext); JsfTomcatApplicationListener jsfTomcatApplicationListener = JsfTomcatApplicationListener .builder().context(jsfTomcatContextCustomizer.getContext()).build(); jsfTomcatApplicationListener.onApplicationEvent(null); assertThat(jsfTomcatApplicationListener) .isNotNull(); }
@Test public void resourcesNull() throws LifecycleException { Context standardContext = Mockito.mock(Context.class); Mockito.when(standardContext.getResources()).thenReturn(null); 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(jsfTomcatApplicationListener) .isNotNull(); }
@Test public void resourcesNull() throws LifecycleException { Context standardContext = Mockito.mock(Context.class); Mockito.when(standardContext.getResources()).thenReturn(null); 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(jsfTomcatApplicationListener) .isNotNull(); }
@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); }