Search in sources :

Example 1 with GenericXmlApplicationContext

use of org.springframework.context.support.GenericXmlApplicationContext in project pinpoint by naver.

the class AlarmJobTest method main.

public static void main(String[] args) throws Exception {
    GenericXmlApplicationContext applicationContext = new GenericXmlApplicationContext("/applicationContext-test.xml");
    JobLauncherTestUtils testLauncher = applicationContext.getBean(JobLauncherTestUtils.class);
    JobExecution jobExecution = testLauncher.launchJob(getParameters());
    BatchStatus status = jobExecution.getStatus();
    assertEquals(BatchStatus.COMPLETED, status);
    applicationContext.close();
}
Also used : JobExecution(org.springframework.batch.core.JobExecution) BatchStatus(org.springframework.batch.core.BatchStatus) JobLauncherTestUtils(org.springframework.batch.test.JobLauncherTestUtils) GenericXmlApplicationContext(org.springframework.context.support.GenericXmlApplicationContext)

Example 2 with GenericXmlApplicationContext

use of org.springframework.context.support.GenericXmlApplicationContext in project topjava10 by JavaWebinar.

the class SpringMain method main.

public static void main(String[] args) {
    // java 7 Automatic resource management
    try (GenericXmlApplicationContext appCtx = new GenericXmlApplicationContext()) {
        appCtx.getEnvironment().setActiveProfiles(Profiles.getActiveDbProfile(), Profiles.REPOSITORY_IMPLEMENTATION);
        appCtx.load("spring/spring-app.xml", "spring/mock.xml");
        appCtx.refresh();
        mockAuthorize(USER);
        System.out.println("Bean definition names: " + Arrays.toString(appCtx.getBeanDefinitionNames()));
        AdminRestController adminUserController = appCtx.getBean(AdminRestController.class);
        adminUserController.create(new User(null, "userName", "email", "password", 1500, Role.ROLE_ADMIN));
        System.out.println();
        MealRestController mealController = appCtx.getBean(MealRestController.class);
        List<MealWithExceed> filteredMealsWithExceeded = mealController.getBetween(LocalDate.of(2015, Month.MAY, 30), LocalTime.of(7, 0), LocalDate.of(2015, Month.MAY, 31), LocalTime.of(11, 0));
        filteredMealsWithExceeded.forEach(System.out::println);
    }
}
Also used : User(ru.javawebinar.topjava.model.User) MealRestController(ru.javawebinar.topjava.web.meal.MealRestController) AdminRestController(ru.javawebinar.topjava.web.user.AdminRestController) MealWithExceed(ru.javawebinar.topjava.to.MealWithExceed) GenericXmlApplicationContext(org.springframework.context.support.GenericXmlApplicationContext)

Example 3 with GenericXmlApplicationContext

use of org.springframework.context.support.GenericXmlApplicationContext in project spring-security-oauth by spring-projects.

the class AuthorizationServerInvalidParserTests method testCustomGrantRegistered.

@Test
public void testCustomGrantRegistered() {
    expected.expect(BeanDefinitionParsingException.class);
    expected.expectMessage("ClientDetailsService");
    context = new GenericXmlApplicationContext(getClass(), RESOURCE_NAME);
    TokenGranter granter = context.getBean(CompositeTokenGranter.class);
    assertNotNull(granter);
}
Also used : CompositeTokenGranter(org.springframework.security.oauth2.provider.CompositeTokenGranter) TokenGranter(org.springframework.security.oauth2.provider.TokenGranter) GenericXmlApplicationContext(org.springframework.context.support.GenericXmlApplicationContext) Test(org.junit.Test)

Example 4 with GenericXmlApplicationContext

use of org.springframework.context.support.GenericXmlApplicationContext in project spring-security-oauth by spring-projects.

the class InvalidResourceBeanDefinitionParserTests method loadContext.

private void loadContext(String attributes) {
    String config = HEADER + String.format(TEMPLATE, attributes) + FOOTER;
    context = new GenericXmlApplicationContext(new ByteArrayResource(config.getBytes()));
}
Also used : ByteArrayResource(org.springframework.core.io.ByteArrayResource) GenericXmlApplicationContext(org.springframework.context.support.GenericXmlApplicationContext)

Example 5 with GenericXmlApplicationContext

use of org.springframework.context.support.GenericXmlApplicationContext in project spring-security-oauth by spring-projects.

the class ResourceServerBeanDefinitionParserTests method testAuthenticationManager.

@Test
public void testAuthenticationManager() {
    GenericXmlApplicationContext context = new GenericXmlApplicationContext(getClass(), "resource-server-authmanager-context.xml");
    // System.err.println(Arrays.asList(context.getBeanDefinitionNames()));
    assertTrue(context.containsBeanDefinition("oauth2ProviderFilter"));
    OAuth2AuthenticationProcessingFilter filter = context.getBean(OAuth2AuthenticationProcessingFilter.class);
    assertEquals(context.getBean(AuthenticationManager.class), ReflectionTestUtils.getField(filter, "authenticationManager"));
    assertNotNull(ReflectionTestUtils.getField(filter, "tokenExtractor"));
    context.close();
}
Also used : AuthenticationManager(org.springframework.security.authentication.AuthenticationManager) OAuth2AuthenticationProcessingFilter(org.springframework.security.oauth2.provider.authentication.OAuth2AuthenticationProcessingFilter) GenericXmlApplicationContext(org.springframework.context.support.GenericXmlApplicationContext) Test(org.junit.Test)

Aggregations

GenericXmlApplicationContext (org.springframework.context.support.GenericXmlApplicationContext)61 Test (org.junit.Test)21 Test (org.junit.jupiter.api.Test)13 MBeanServer (javax.management.MBeanServer)5 ConfigurableApplicationContext (org.springframework.context.ConfigurableApplicationContext)5 Scanner (java.util.Scanner)4 ObjectName (javax.management.ObjectName)4 Resource (org.springframework.core.io.Resource)4 QueueChannel (org.springframework.integration.channel.QueueChannel)4 MessageChannel (org.springframework.messaging.MessageChannel)4 ApplicationContext (org.springframework.context.ApplicationContext)3 ByteArrayResource (org.springframework.core.io.ByteArrayResource)3 Message (org.springframework.messaging.Message)3 MBeanOperationInfo (javax.management.MBeanOperationInfo)2 Server (org.eclipse.jetty.server.Server)2 ServletContextHandler (org.eclipse.jetty.servlet.ServletContextHandler)2 ServletHolder (org.eclipse.jetty.servlet.ServletHolder)2 BatchStatus (org.springframework.batch.core.BatchStatus)2 BeanDefinitionParsingException (org.springframework.beans.factory.parsing.BeanDefinitionParsingException)2 CacheInterceptor (org.springframework.cache.interceptor.CacheInterceptor)2