gpt4 book ai didi

org.cloudfoundry.identity.uaa.impl.config.YamlServletProfileInitializer.initialize()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-16 16:49:31 26 4
gpt4 key购买 nike

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

YamlServletProfileInitializer.initialize介绍

暂无

代码示例

代码示例来源:origin: cloudfoundry/uaa

@Test
public void testLog4jConfigurationFromYaml() throws Exception {
  Mockito.when(context.getResource(ArgumentMatchers.anyString())).thenReturn(
    new ByteArrayResource("logging:\n  config: bar".getBytes()));
  initializer.initialize(context);
}

代码示例来源:origin: cloudfoundry/uaa

@Test
public void testLog4jPathFromYaml() throws Exception {
  Mockito.when(context.getResource(ArgumentMatchers.anyString())).thenReturn(
          new ByteArrayResource("logging:\n  path: /tmp/log/bar".getBytes()));
  initializer.initialize(context);
  assertEquals("/tmp/log/bar", System.getProperty("LOG_PATH"));
}

代码示例来源:origin: cloudfoundry/uaa

@Test
public void testLog4jFileFromYaml() throws Exception {
  Mockito.when(context.getResource(ArgumentMatchers.anyString())).thenReturn(
          new ByteArrayResource("logging:\n  file: /tmp/bar.log".getBytes()));
  initializer.initialize(context);
  assertEquals("/tmp/bar.log", System.getProperty("LOG_FILE"));
}

代码示例来源:origin: cloudfoundry/uaa

@Test
public void testLoadSessionEventPublisher() throws Exception {
  Mockito.when(context.getResource(ArgumentMatchers.contains("${APPLICATION_CONFIG_URL}"))).thenReturn(
    new ByteArrayResource("foo: bar\nspam:\n  foo: baz".getBytes()));
  initializer.initialize(context);
  ArgumentCaptor<HttpSessionEventPublisher> httpSessionEventPublisherArgumentCaptor = ArgumentCaptor.forClass(HttpSessionEventPublisher.class);
  verify(servletContext, atLeastOnce()).addListener(httpSessionEventPublisherArgumentCaptor.capture());
  assertNotNull(httpSessionEventPublisherArgumentCaptor.getValue());
}

代码示例来源:origin: cloudfoundry/uaa

@Test
public void testActiveProfiles() throws Exception {
  System.setProperty("spring.profiles.active", "foo");
  Mockito.when(context.getResource(ArgumentMatchers.anyString())).thenReturn(
    new ByteArrayResource("spring_profiles: bar".getBytes()));
  initializer.initialize(context);
  assertEquals("bar", environment.getActiveProfiles()[0]);
}

代码示例来源:origin: cloudfoundry/uaa

@Test
public void testActiveProfilesFromYaml() throws Exception {
  Mockito.when(context.getResource(ArgumentMatchers.anyString())).thenReturn(
          new ByteArrayResource("spring_profiles: bar".getBytes()));
  initializer.initialize(context);
  assertEquals("bar", environment.getActiveProfiles()[0]);
}

代码示例来源:origin: cloudfoundry/uaa

@Test
public void testLoadServletConfiguredResource() throws Exception {
  Mockito.when(servletConfig.getInitParameter("environmentConfigLocations")).thenReturn("foo.yml");
  Mockito.when(context.getResource(ArgumentMatchers.eq("foo.yml"))).thenReturn(
          new ByteArrayResource("foo: bar\nspam:\n  foo: baz".getBytes()));
  initializer.initialize(context);
  assertEquals("bar", environment.getProperty("foo"));
  assertEquals("baz", environment.getProperty("spam.foo"));
}

代码示例来源:origin: cloudfoundry/uaa

@Test
public void testLoadServletConfiguredFilename() throws Exception {
  Mockito.when(servletConfig.getInitParameter("APPLICATION_CONFIG_FILE")).thenReturn("/config/path/foo.yml");
  Mockito.when(context.getResource(ArgumentMatchers.eq("file:/config/path/foo.yml"))).thenReturn(
          new ByteArrayResource("foo: bar\nspam:\n  foo: baz".getBytes()));
  initializer.initialize(context);
  assertEquals("bar", environment.getProperty("foo"));
  assertEquals("baz", environment.getProperty("spam.foo"));
}

代码示例来源:origin: cloudfoundry/uaa

@Test
public void testLoadContextConfiguredResource() throws Exception {
  Mockito.when(servletContext.getInitParameter("environmentConfigLocations")).thenReturn("foo.yml");
  Mockito.when(context.getResource(ArgumentMatchers.eq("foo.yml"))).thenReturn(
          new ByteArrayResource("foo: bar\nspam:\n  foo: baz".getBytes()));
  initializer.initialize(context);
  assertEquals("bar", environment.getProperty("foo"));
  assertEquals("baz", environment.getProperty("spam.foo"));
}

代码示例来源:origin: cloudfoundry/uaa

@Test
public void testLoadReplacedResourceFromFileLocation() throws Exception {
  System.setProperty("APPLICATION_CONFIG_FILE", "foo/uaa.yml");
  Mockito.when(context.getResource(ArgumentMatchers.eq("file:foo/uaa.yml"))).thenReturn(
          new ByteArrayResource("foo: bar\nspam:\n  foo: baz".getBytes()));
  initializer.initialize(context);
  assertEquals("bar", environment.getProperty("foo"));
  assertEquals("baz", environment.getProperty("spam.foo"));
}

代码示例来源:origin: cloudfoundry/uaa

@Test
public void testLoadReplacedResource() throws Exception {
  System.setProperty("APPLICATION_CONFIG_URL", "file:foo/uaa.yml");
  Mockito.when(context.getResource(ArgumentMatchers.eq("file:foo/uaa.yml"))).thenReturn(
          new ByteArrayResource("foo: bar\nspam:\n  foo: baz".getBytes()));
  initializer.initialize(context);
  assertEquals("bar", environment.getProperty("foo"));
  assertEquals("baz", environment.getProperty("spam.foo"));
}

代码示例来源:origin: cloudfoundry/uaa

@Test
public void testLoggingConfigVariableWorks() throws Exception {
  System.setProperty("APPLICATION_CONFIG_FILE", "foo/uaa.yml");
  Mockito.when(context.getResource(ArgumentMatchers.eq("file:foo/uaa.yml"))).thenReturn(
    new ByteArrayResource("logging:\n  config: /some/path".getBytes()));
  initializer.initialize(context);
  assertEquals("/some/path", environment.getProperty("logging.config"));
  assertNull(environment.getProperty("smtp.host"));
  assertNull(environment.getProperty("smtp.port"));
}

代码示例来源:origin: cloudfoundry/uaa

initializer.initialize(context);
assertEquals("-Djava.util.logging.config=/some/path/logging.properties", environment.getProperty("logging.config"));
Mockito.verify(servletContext,atLeastOnce()).log(servletLogCaptor.capture());

代码示例来源:origin: cloudfoundry/uaa

@Test
public void testLoadDefaultResource() throws Exception {
  Mockito.when(context.getResource(ArgumentMatchers.contains("${APPLICATION_CONFIG_URL}"))).thenReturn(
    new ByteArrayResource("foo: bar\nspam:\n  foo: baz".getBytes()));
  initializer.initialize(context);
  assertEquals("bar", environment.getProperty("foo"));
  assertEquals("baz", environment.getProperty("spam.foo"));
}

代码示例来源:origin: cloudfoundry/uaa

public void initializeContext(ConfigurableWebApplicationContext context, String yamlPath) {
    MockServletContext servletContext = new MockServletContext() {
      @Override
      public <Type extends EventListener> void addListener(Type t) {
        //no op
      }
    };
    MockServletConfig servletConfig = new MockServletConfig(servletContext);
    servletConfig.addInitParameter("environmentConfigDefaults", yamlPath);
    context.setServletContext(servletContext);
    context.setServletConfig(servletConfig);
    new YamlServletProfileInitializer().initialize(context);
  }
}

代码示例来源:origin: cloudfoundry/uaa

initializer.initialize(context);

代码示例来源:origin: cloudfoundry/uaa

public void testReadingYamlFromEnvironment(String variableName) throws Exception {
  if (hasText(variableName)) {
    initializer.setYamlEnvironmentVariableName(variableName);
  }
  SystemEnvironmentAccessor env = new SystemEnvironmentAccessor() {
    @Override
    public String getEnvironmentVariable(String name) {
      return name.equals(initializer.getYamlEnvironmentVariableName()) ?
        "uaa.url: http://uaa.test.url/\n" +
        "login.url: http://login.test.url/\n" +
        "smtp:\n" +
        "  host: mail.server.host\n" +
        "  port: 3535\n" :
        null;
    }
  };
  initializer.setEnvironmentAccessor(env);
  initializer.initialize(context);
  assertEquals("mail.server.host", environment.getProperty("smtp.host"));
  assertEquals("3535", environment.getProperty("smtp.port"));
  assertEquals("http://uaa.test.url/", environment.getProperty("uaa.url"));
  assertEquals("http://login.test.url/", environment.getProperty("login.url"));
}

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com