use of org.springframework.mock.jndi.SimpleNamingContextBuilder in project Activiti by Activiti.
the class JndiEmailTest method setUp.
@BeforeClass
public void setUp() {
Properties props = new Properties();
props.put("mail.transport.protocol", "smtp");
props.put("mail.smtp.provider.class", MockEmailTransport.class.getName());
props.put("mail.smtp.class", MockEmailTransport.class.getName());
props.put("mail.smtp.provider.vendor", "test");
props.put("mail.smtp.provider.version", "0.0.0");
Provider provider = new Provider(Type.TRANSPORT, "smtp", MockEmailTransport.class.getName(), "test", "1.0");
Session mailSession = Session.getDefaultInstance(props);
SimpleNamingContextBuilder builder = null;
try {
mailSession.setProvider(provider);
builder = SimpleNamingContextBuilder.emptyActivatedContextBuilder();
builder.bind("java:comp/env/Session", mailSession);
} catch (NamingException e) {
logger.error("Naming error in email setup", e);
} catch (NoSuchProviderException e) {
logger.error("provider error in email setup", e);
}
}
use of org.springframework.mock.jndi.SimpleNamingContextBuilder in project midpoint by Evolveum.
the class JNDIMock method setObjects.
public void setObjects(Map<String, Object> objects) throws NamingException {
LOGGER.info("Loading fake JNDI context.");
if (SimpleNamingContextBuilder.getCurrentContextBuilder() != null) {
SimpleNamingContextBuilder.getCurrentContextBuilder().deactivate();
}
SimpleNamingContextBuilder builder = new SimpleNamingContextBuilder();
if (objects != null) {
for (Map.Entry<String, Object> entry : objects.entrySet()) {
LOGGER.info("Registering '{}' with value '{}'", new Object[] { entry.getKey(), entry.getValue() });
builder.bind(entry.getKey(), entry.getValue());
}
}
builder.activate();
}
use of org.springframework.mock.jndi.SimpleNamingContextBuilder in project logging-log4j2 by apache.
the class JndiRule method apply.
@Override
public Statement apply(final Statement base, final Description description) {
return new Statement() {
@Override
public void evaluate() throws Throwable {
final SimpleNamingContextBuilder builder = SimpleNamingContextBuilder.emptyActivatedContextBuilder();
for (final Map.Entry<String, Object> entry : initialBindings.entrySet()) {
builder.bind(entry.getKey(), entry.getValue());
}
base.evaluate();
}
};
}
use of org.springframework.mock.jndi.SimpleNamingContextBuilder in project ocvn by devgateway.
the class DatabaseConfiguration method jndiBuilder.
/**
* This bean creates the JNDI tree and registers the
* {@link javax.sql.DataSource} to this tree. This allows Pentaho Classic
* Engine to use a {@link javax.sql.DataSource} ,in our case backed by a
* connection pool instead of always opening up JDBC connections. Should
* significantly improve performance of all classic reports. In PRD use
* connection type=JNDI and name toolkitDS. To use it in PRD you need to add
* the configuration to the local PRD. Edit
* ~/.pentaho/simple-jndi/default.properties and add the following:
* toolkitDS/type=javax.sql.DataSource
* toolkitDS/driver=org.apache.derby.jdbc.ClientDriver toolkitDS/user=app
* toolkitDS/password=app
* toolkitDS/url=jdbc:derby://localhost//derby/toolkit
*
* @return
*/
@Bean
public SimpleNamingContextBuilder jndiBuilder() {
SimpleNamingContextBuilder builder = new SimpleNamingContextBuilder();
builder.bind(datasourceJndiName, dataSource());
try {
builder.activate();
} catch (IllegalStateException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (NamingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return builder;
}
Aggregations