Spring Framework GenericXmlApplicationContext - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Spring Framework GenericXmlApplicationContext class.

This code example shows how to use the following methods:load, getBean, refresh, setParent
This code example shows how to use the following methods:close, containsBeanDefinition
 */ 
public class ResourceServerBeanDefinitionParserTests { 
 
	@Test
	public void testDefaults() { 
		GenericXmlApplicationContext context = new GenericXmlApplicationContext(
				getClass(), "resource-server-context.xml");
		assertTrue(context.containsBeanDefinition("oauth2ProviderFilter"));
		assertTrue(context.containsBeanDefinition("anotherProviderFilter"));
		assertTrue(context.containsBeanDefinition("thirdProviderFilter"));
		context.close();
	} 
 
	@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);
8
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:close, getBean
	@Test
	public void testChannelAdapterDemo() throws InterruptedException {
 
		System.setProperty("spring.profiles.active", "testCase");
 
		final GenericXmlApplicationContext applicationContext = new GenericXmlApplicationContext(configFilesChannelAdapterDemo);
 
		final MessageChannel stdinToJmsoutChannel = applicationContext.getBean("stdinToJmsoutChannel", MessageChannel.class);
 
		stdinToJmsoutChannel.send(MessageBuilder.withPayload("jms test").build());
 
		final QueueChannel queueChannel = applicationContext.getBean("queueChannel", QueueChannel.class);
 
		@SuppressWarnings("unchecked") 
		Message<String> reply = (Message<String>) queueChannel.receive(20000);
		Assert.assertNotNull(reply);
		String out = reply.getPayload();
		Assert.assertEquals("jms test", out);
 
		applicationContext.close();

7
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getBean
 
	private GenericXmlApplicationContext context;
 
	@Test
	public void testJavaBean() { 
		context = new GenericXmlApplicationContext(getClass(), getClass().getSimpleName()+"-java-context.xml");
		TestService bean = context.getBean("javaBean", TestService.class);
		LogUserAdvice logAdvice = context.getBean(LogUserAdvice.class);
 
		assertEquals(0, logAdvice.getCountThrows());
		try { 
			bean.sayHello();
			fail("Expected exception"); 
		} 
		catch (RuntimeException ex) {
			assertEquals("TestServiceImpl", ex.getMessage());
		} 
		assertEquals(1, logAdvice.getCountThrows());
 
	} 
7
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:load, getEnvironment, refresh, setClassLoader
	 * @param targetClass the class who's classloader we will use to laod the context file 
	 * @param profile a profile name 
	 * @return the spring context 
	 */ 
	public static AbstractApplicationContext loadProfileContext(String path, Class<?> targetClass, String profile) {
		GenericXmlApplicationContext ctx = new GenericXmlApplicationContext();
		ctx.getEnvironment().setActiveProfiles(profile);
		ctx.setClassLoader(targetClass.getClassLoader());
		ctx.load(path);
		ctx.refresh();
		return ctx;
	} 
 
} 
7
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:close, getBean
		ForkUtil.sendSignal(); 
	} 
 
	@Test
	public void testContainerSetup() throws Exception {
		GenericXmlApplicationContext applicationContext = new GenericXmlApplicationContext(
			"/org/springframework/data/gemfire/listener/container.xml"); 
 
		try { 
			ContinuousQueryListenerContainer container = applicationContext.getBean(
				ContinuousQueryListenerContainer.class); 
 
			assertNotNull(container);
			assertTrue(container.isRunning());
 
			// test getting container listener by bean ID 
			ContinuousQueryListenerContainer container2 = applicationContext.getBean("testContainerId",
				ContinuousQueryListenerContainer.class); 
 
			assertSame(container, container2);

7
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:close, getBean
	@Test
	public void testGatewayDemo() throws InterruptedException {
 
		System.setProperty("spring.profiles.active", "testCase");
 
		final GenericXmlApplicationContext applicationContext = new GenericXmlApplicationContext(configFilesGatewayDemo);
 
		final MessageChannel stdinToJmsoutChannel = applicationContext.getBean("stdinToJmsoutChannel", MessageChannel.class);
 
		stdinToJmsoutChannel.send(MessageBuilder.withPayload("jms test").build());
 
		final QueueChannel queueChannel = applicationContext.getBean("queueChannel", QueueChannel.class);
 
		@SuppressWarnings("unchecked") 
		Message<String> reply = (Message<String>) queueChannel.receive(20000);
		Assert.assertNotNull(reply);
		String out = reply.getPayload();
 
		Assert.assertEquals("JMS response: JMS TEST", out);
 

7
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:load, refresh, setParent
    } 
 
    @Test
    public void methodExpressionHandlerInParentContextLoads() { 
        parent = new GenericXmlApplicationContext("org/springframework/security/config/method/sec2499/parent.xml");
        child = new GenericXmlApplicationContext();
        child.load("org/springframework/security/config/method/sec2499/child.xml");
        child.setParent(parent);
        child.refresh();
    } 
} 
7
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:load, getEnvironment, refresh, registerShutdownHook
		System.exit(0);
 
	} 
 
	public static GenericXmlApplicationContext setupContext() {
		final GenericXmlApplicationContext context = new GenericXmlApplicationContext();
 
		System.out.print("Detect open server socket...");
		int availableServerSocket = SocketUtils.findAvailableServerSocket(5678);
 
		final Map<String, Object> sockets = new HashMap<String, Object>();
		sockets.put("availableServerSocket", availableServerSocket);
 
		final MapPropertySource propertySource = new MapPropertySource("sockets", sockets);
 
		context.getEnvironment().getPropertySources().addLast(propertySource);
 
		System.out.println("using port " + context.getEnvironment().getProperty("availableServerSocket"));
 
		context.load("classpath:META-INF/spring/integration/tcpClientServerDemo-context.xml");

7
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:load, getBeanDefinitionNames, getEnvironment, refresh
 
public class ActiveMQTest { 
 
	@Test
	public void testJmsConnectionFactory() { 
		GenericXmlApplicationContext applicationContext = new GenericXmlApplicationContext();
		applicationContext.getEnvironment().setActiveProfiles("test");
		applicationContext.load("/jmsContext.xml");
		applicationContext.refresh();
		String[] profiles = applicationContext.getEnvironment().getActiveProfiles();
		Assert.assertTrue(ArrayUtils.contains(profiles, "test"));
		String[] beanNames = applicationContext.getBeanDefinitionNames();
		Assert.assertTrue(ArrayUtils.contains(beanNames, "jmsConnectionFactory"));
	} 
 
} 
7
CodeRank
Experience pair programming with AI  Get Codota for Java
See Code Examples for Spring Framework GenericXmlApplicationContext Methods: