org.springframework.tests.mock.jndi.SimpleNamingContext Java Examples

The following examples show how to use org.springframework.tests.mock.jndi.SimpleNamingContext. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JndiPropertySourceTests.java    From spring-analysis-note with MIT License 6 votes vote down vote up
@Test
public void nameBoundWithoutPrefix() {
	final SimpleNamingContext context = new SimpleNamingContext();
	context.bind("p1", "v1");

	JndiTemplate jndiTemplate = new JndiTemplate() {
		@Override
		protected Context createInitialContext() throws NamingException {
			return context;
		}
	};
	JndiLocatorDelegate jndiLocator = new JndiLocatorDelegate();
	jndiLocator.setResourceRef(true);
	jndiLocator.setJndiTemplate(jndiTemplate);

	JndiPropertySource ps = new JndiPropertySource("jndiProperties", jndiLocator);
	assertThat(ps.getProperty("p1"), equalTo("v1"));
}
 
Example #2
Source File: JndiPropertySourceTests.java    From spring-analysis-note with MIT License 6 votes vote down vote up
@Test
public void nameBoundWithPrefix() {
	final SimpleNamingContext context = new SimpleNamingContext();
	context.bind("java:comp/env/p1", "v1");

	JndiTemplate jndiTemplate = new JndiTemplate() {
		@Override
		protected Context createInitialContext() throws NamingException {
			return context;
		}
	};
	JndiLocatorDelegate jndiLocator = new JndiLocatorDelegate();
	jndiLocator.setResourceRef(true);
	jndiLocator.setJndiTemplate(jndiTemplate);

	JndiPropertySource ps = new JndiPropertySource("jndiProperties", jndiLocator);
	assertThat(ps.getProperty("p1"), equalTo("v1"));
}
 
Example #3
Source File: JndiPropertySourceTests.java    From java-technology-stack with MIT License 6 votes vote down vote up
@Test
public void nameBoundWithoutPrefix() {
	final SimpleNamingContext context = new SimpleNamingContext();
	context.bind("p1", "v1");

	JndiTemplate jndiTemplate = new JndiTemplate() {
		@Override
		protected Context createInitialContext() throws NamingException {
			return context;
		}
	};
	JndiLocatorDelegate jndiLocator = new JndiLocatorDelegate();
	jndiLocator.setResourceRef(true);
	jndiLocator.setJndiTemplate(jndiTemplate);

	JndiPropertySource ps = new JndiPropertySource("jndiProperties", jndiLocator);
	assertThat(ps.getProperty("p1"), equalTo("v1"));
}
 
Example #4
Source File: JndiPropertySourceTests.java    From java-technology-stack with MIT License 6 votes vote down vote up
@Test
public void nameBoundWithPrefix() {
	final SimpleNamingContext context = new SimpleNamingContext();
	context.bind("java:comp/env/p1", "v1");

	JndiTemplate jndiTemplate = new JndiTemplate() {
		@Override
		protected Context createInitialContext() throws NamingException {
			return context;
		}
	};
	JndiLocatorDelegate jndiLocator = new JndiLocatorDelegate();
	jndiLocator.setResourceRef(true);
	jndiLocator.setJndiTemplate(jndiTemplate);

	JndiPropertySource ps = new JndiPropertySource("jndiProperties", jndiLocator);
	assertThat(ps.getProperty("p1"), equalTo("v1"));
}
 
Example #5
Source File: JndiPropertySourceTests.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
@Test
public void nameBoundWithoutPrefix() {
	final SimpleNamingContext context = new SimpleNamingContext();
	context.bind("p1", "v1");

	JndiTemplate jndiTemplate = new JndiTemplate() {
		@Override
		protected Context createInitialContext() throws NamingException {
			return context;
		}
	};
	JndiLocatorDelegate jndiLocator = new JndiLocatorDelegate();
	jndiLocator.setResourceRef(true);
	jndiLocator.setJndiTemplate(jndiTemplate);

	JndiPropertySource ps = new JndiPropertySource("jndiProperties", jndiLocator);
	assertThat((String)ps.getProperty("p1"), equalTo("v1"));
}
 
Example #6
Source File: JndiPropertySourceTests.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
@Test
public void nameBoundWithPrefix() {
	final SimpleNamingContext context = new SimpleNamingContext();
	context.bind("java:comp/env/p1", "v1");

	JndiTemplate jndiTemplate = new JndiTemplate() {
		@Override
		protected Context createInitialContext() throws NamingException {
			return context;
		}
	};
	JndiLocatorDelegate jndiLocator = new JndiLocatorDelegate();
	jndiLocator.setResourceRef(true);
	jndiLocator.setJndiTemplate(jndiTemplate);

	JndiPropertySource ps = new JndiPropertySource("jndiProperties", jndiLocator);
	assertThat((String)ps.getProperty("p1"), equalTo("v1"));
}