org.apache.catalina.Context.getAddWebinfClassesResources()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(13.5k)|赞(0)|评价(0)|浏览(98)

本文整理了Java中org.apache.catalina.Context.getAddWebinfClassesResources()方法的一些代码示例,展示了Context.getAddWebinfClassesResources()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Context.getAddWebinfClassesResources()方法的具体详情如下:
包路径:org.apache.catalina.Context
类名称:Context
方法名:getAddWebinfClassesResources

Context.getAddWebinfClassesResources介绍

[英]Gets the flag that indicates if /WEB-INF/classes should be treated like an exploded JAR and JAR resources made available as if they were in a JAR.
[中]获取标志,该标志指示是否应将/WEB-INF/类视为已分解的JAR,并将JAR资源视为在JAR中可用。

代码示例

代码示例来源:origin: org.joinfaces/jsf-tomcat-spring-boot-autoconfigure

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);
}

代码示例来源:origin: org.joinfaces/jsf-spring-boot-autoconfigure

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);
}

代码示例来源:origin: joinfaces/joinfaces

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);
}

代码示例来源:origin: joinfaces/joinfaces

@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();
}

代码示例来源:origin: org.apache.tomcat/tomcat-catalina

setBase(base);
if (root.getContext().getAddWebinfClassesResources()) {
  File f = new File(base, internalPath);
  f = new File(f, "/WEB-INF/classes/META-INF/resources");

代码示例来源:origin: joinfaces/joinfaces

@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();
}

代码示例来源:origin: codefollower/Tomcat-Research

setBase(base);
if (root.getContext().getAddWebinfClassesResources()) {
  File f = new File(base, internalPath);
  f = new File(f, "/WEB-INF/classes/META-INF/resources");

代码示例来源:origin: org.ops4j.pax.tipi/org.ops4j.pax.tipi.tomcat-embed-core

setBase(base);
if (root.getContext().getAddWebinfClassesResources()) {
  File f = new File(base, internalPath);
  f = new File(f, "/WEB-INF/classes/META-INF/resources");

代码示例来源:origin: joinfaces/joinfaces

@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);
}

代码示例来源:origin: org.joinfaces/jsf-tomcat-spring-boot-autoconfigure

@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();
}

代码示例来源:origin: org.joinfaces/jsf-spring-boot-autoconfigure

@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();
}

代码示例来源:origin: org.joinfaces/jsf-spring-boot-autoconfigure

@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();
}

代码示例来源:origin: org.joinfaces/jsf-tomcat-spring-boot-autoconfigure

@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();
}

代码示例来源:origin: joinfaces/joinfaces

@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);
}

代码示例来源:origin: org.joinfaces/jsf-spring-boot-autoconfigure

@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);
}

代码示例来源:origin: org.joinfaces/jsf-tomcat-spring-boot-autoconfigure

@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);
}

代码示例来源:origin: org.joinfaces/jsf-tomcat-spring-boot-autoconfigure

@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);
}

代码示例来源:origin: org.joinfaces/jsf-spring-boot-autoconfigure

@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);
}

相关文章

微信公众号

最新文章

更多

Context类方法