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