本文整理汇总了Java中javax.ejb.embeddable.EJBContainer类的典型用法代码示例。如果您正苦于以下问题:Java EJBContainer类的具体用法?Java EJBContainer怎么用?Java EJBContainer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
EJBContainer类属于javax.ejb.embeddable包,在下文中一共展示了EJBContainer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initContainer
import javax.ejb.embeddable.EJBContainer; //导入依赖的package包/类
@Before
public void initContainer() throws Exception {
/*
This will start an embedded container, which we ll save us
from having to start it as an external process and deploy
our WAR on it.
However, embedded containers only provide reduced functionalities,
see page 231 in Chapter 7 and
http://arquillian.org/blog/2012/04/13/the-danger-of-embedded-containers/
In generate, better to avoid the embedded containers,
although I will use them in some simple examples just to
simplify the execution of the tests
*/
Map<String, Object> properties = new HashMap<>();
properties.put(EJBContainer.MODULES, new File("target/classes"));
ec = EJBContainer.createEJBContainer(properties);
ctx = ec.getContext();
}
开发者ID:arcuri82,项目名称:testing_security_development_enterprise_systems,代码行数:23,代码来源:UserBeanInEmbeddedContainerTest.java
示例2: EjbFactory
import javax.ejb.embeddable.EJBContainer; //导入依赖的package包/类
private EjbFactory() {
if (container == null) {
Properties properties = new Properties();
properties.put("myTransactionManager", "new://TransactionManager?type=TransactionManager");
properties.put("myTransactionManager.defaultTransactionTimeout", "3hr"); //hour
properties.put("jdbc/bankWorkTestResource", "new://Resource?type=DataSource");
properties.put("jdbc/bankWorkTestResource.JdbcDriver", "com.mysql.jdbc.Driver");
properties.put("jdbc/bankWorkTestResource.JdbcUrl", databaseUrl);
properties.put("jdbc/bankWorkTestResource.UserName", databaseUser);
properties.put("jdbc/bankWorkTestResource.Password", databasePass);
container = EJBContainer.createEJBContainer(properties);
}
}
示例3: withBeforeClasses
import javax.ejb.embeddable.EJBContainer; //导入依赖的package包/类
@Override
protected Statement withBeforeClasses(Statement statement) {
Properties p = new Properties();
// set the initial context factory
p.put("java.naming.factory.initial ",
"org.apache.openejb.client.LocalInitialContextFactory");
// create some resources
p.put("jdbc/StudentsDS", "new://Resource?type=DataSource");
p.put("jdbc/StudentsDS.JdbcDriver", "org.apache.derby.jdbc.EmbeddedDriver");
p.put("jdbc/StudentsDS.JdbcUrl", "jdbc:derby:memory:studentDB;create=true");
// set some openejb flags
p.put("openejb.jndiname.format", "{ejbName}/{interfaceClass}");
p.put("openejb.descriptors.output", "true");
p.put("openejb.validation.output.level", "verbose");
p.put("JEE6DemoPersistence.eclipselink.target-database", "DERBY");
p.put("JEE6DemoPersistence.eclipselink.logging.level", "INFO");
p.put("JEE6DemoPersistence.eclipselink.ddl-generation", "create-tables");
ejbContainer = EJBContainer.createEJBContainer(p);
return super.withBeforeClasses(statement);
}
示例4: test
import javax.ejb.embeddable.EJBContainer; //导入依赖的package包/类
@Test @Ignore("no provider found!")
public void test() throws Exception {
final Properties p = new Properties();
p.put("TicketManorDataSource", "new://Resource?type=DataSource");
p.put("TicketManorDataSource.JdbcDriver", "org.hsqldb.jdbcDriver");
p.put("TicketManorDataSource.JdbcUrl", "jdbc:hsqldb:mem:TicketManorDataSource");
final Context context = EJBContainer.createEJBContainer(p).getContext();
EventsEjb events = (EventsEjb) context.lookup("java:global/injection-of-entitymanager/EventsBean");
LocalDateTime today = LocalDateTime.now();
events.addEvent(new Event(new Movie("Quentin Tarantino", "Reservoir Dogs", 1992), today, null));
events.addEvent(new Event(new Movie("Joel Coen", "Fargo", 1996), today, null));
events.addEvent(new Event(new Movie("Joel Coen", "The Big Lebowski", 1998), today, null));
List<Event> list = events.getAllEvents();
assertEquals("List.size()", 3, list.size());
for (Event event : list) {
events.deleteEvent(event);
}
}
示例5: classpath
import javax.ejb.embeddable.EJBContainer; //导入依赖的package包/类
@Test
public void classpath() throws Exception {
final Properties p = new Properties();
p.setProperty(EJBContainer.PROVIDER, EmbeddedTomEEContainer.class.getName());
p.setProperty(DeploymentsResolver.CLASSPATH_INCLUDE, ".*tomee-embedded.*");
p.setProperty(EmbeddedTomEEContainer.TOMEE_EJBCONTAINER_HTTP_PORT, "-1");
EJBContainer container = null;
try {
container = EJBContainer.createEJBContainer(p);
assertNotNull(container);
assertNotNull(container.getContext());
final ABean bean = ABean.class.cast(container.getContext().lookup("java:global/tomee-embedded/ABean"));
assertNotNull(bean);
assertEquals("ok", bean.embedded());
} finally {
if (container != null) {
container.close();
}
}
}
示例6: start
import javax.ejb.embeddable.EJBContainer; //导入依赖的package包/类
@BeforeClass
public static void start() throws IOException {
// get a random unused port to use for http requests
ServerSocket server = new ServerSocket(0);
port = server.getLocalPort();
server.close();
webApp = createWebApp();
Properties p = new Properties();
p.setProperty(EJBContainer.APP_NAME, "moviefun");
p.setProperty(EJBContainer.PROVIDER, "tomee-embedded"); // need web feature
p.setProperty(EJBContainer.MODULES, webApp.getAbsolutePath());
p.setProperty(EmbeddedTomEEContainer.TOMEE_EJBCONTAINER_HTTP_PORT, String.valueOf(port));
container = EJBContainer.createEJBContainer(p);
}
示例7: test
import javax.ejb.embeddable.EJBContainer; //导入依赖的package包/类
public void test() throws Exception {
EJBContainer.createEJBContainer().getContext().bind("inject", this);
Date date = DateFormat.getDateInstance(DateFormat.MEDIUM, Locale.US).parse("Mar 1, 1962");
assertEquals("Strat.getDateCreated()", date, strat.getDateCreated());
List<Pickup> pickups = asList(Pickup.SINGLE_COIL, Pickup.SINGLE_COIL, Pickup.SINGLE_COIL);
assertEquals("Strat.getPickups()", pickups, strat.getPickups());
assertEquals("Strat.getStyle()", Style.VINTAGE, strat.getStyle());
assertEquals("Strat.getStringGuage(\"E1\")", 0.052F, strat.getStringGuage("E1"), 1e-15);
assertEquals("Strat.getStringGuage(\"A\")", 0.042F, strat.getStringGuage("A"), 1e-15);
assertEquals("Strat.getStringGuage(\"D\")", 0.030F, strat.getStringGuage("D"), 1e-15);
assertEquals("Strat.getStringGuage(\"G\")", 0.017F, strat.getStringGuage("G"), 1e-15);
assertEquals("Strat.getStringGuage(\"B\")", 0.013F, strat.getStringGuage("B"), 1e-15);
assertEquals("Strat.getStringGuage(\"E\")", 0.010F, strat.getStringGuage("E"), 1e-15);
File file = new File("/tmp/strat-certificate.txt");
assertEquals("Strat.getCertificateOfAuthenticity()", file, strat.getCertificateOfAuthenticity());
}
示例8: accessDatasourceWithMyImplementation
import javax.ejb.embeddable.EJBContainer; //导入依赖的package包/类
@Test
public void accessDatasourceWithMyImplementation() throws Exception {
// define the datasource
Properties properties = new Properties();
properties.setProperty("ProtectedDatasource", "new://Resource?type=DataSource");
properties.setProperty("ProtectedDatasource.JdbcDriver", "org.hsqldb.jdbcDriver");
properties.setProperty("ProtectedDatasource.JdbcUrl", "jdbc:hsqldb:mem:protected");
properties.setProperty("ProtectedDatasource.UserName", USER);
properties.setProperty("ProtectedDatasource.Password", "3MdniFr3v3NLLuoY");
properties.setProperty("ProtectedDatasource.PasswordCipher", "reverse");
properties.setProperty("ProtectedDatasource.JtaManaged", "true");
// start the context and makes junit test injections
EJBContainer container = EJBContainer.createEJBContainer(properties);
Context context = container.getContext();
context.bind("inject", this);
// test the datasource
assertNotNull(dataSource);
assertNotNull(dataSource.getConnection());
// closing the context
container.close();
}
示例9: test
import javax.ejb.embeddable.EJBContainer; //导入依赖的package包/类
public void test() throws Exception {
System.setProperty("hsqldb.reconfig_logging", "false");
final Properties p = new Properties();
p.put("movieDatabase", "new://Resource?type=DataSource");
p.put("movieDatabase.JdbcDriver", "org.hsqldb.jdbcDriver");
p.put("movieDatabase.JdbcUrl", "jdbc:hsqldb:mem:moviedb");
final Context context = EJBContainer.createEJBContainer(p).getContext();
Movies movies = (Movies) context.lookup("java:global/jpa-hibernate/Movies");
movies.addMovie(new Movie("Quentin Tarantino", "Reservoir Dogs", 1992));
movies.addMovie(new Movie("Joel Coen", "Fargo", 1996));
movies.addMovie(new Movie("Joel Coen", "The Big Lebowski", 1998));
List<Movie> list = movies.getMovies();
assertEquals("List.size()", 3, list.size());
for (Movie movie : list) {
movies.deleteMovie(movie);
}
assertEquals("Movies.getMovies()", 0, movies.getMovies().size());
}
示例10: test
import javax.ejb.embeddable.EJBContainer; //导入依赖的package包/类
public void test() throws Exception {
final Map<String, Object> map = new HashMap<String, Object>();
map.put(EJBContainer.MODULES, new SingletonBean(Orange.class));
EJBContainer.createEJBContainer(map).getContext().bind("inject", this);
userTransaction.begin();
orange.exceptionRollback();
try {
userTransaction.commit();
fail("transaction should have been rolled back");
} catch (final RollbackException e) {
final Throwable throwable = e.getCause();
assertTrue(throwable instanceof UserException);
}
}
示例11: noRestart
import javax.ejb.embeddable.EJBContainer; //导入依赖的package包/类
@Test
public void noRestart() throws Exception {
final EJBContainer container1 = EJBContainer.createEJBContainer(new Properties() {{
put(EJBContainer.MODULES, new EjbJar());
put(OpenEjbContainer.OPENEJB_EJBCONTAINER_CLOSE, OpenEjbContainer.OPENEJB_EJBCONTAINER_CLOSE_SINGLE);
}});
container1.close();
final EJBContainer container2 = EJBContainer.createEJBContainer(new Properties() {{
put(EJBContainer.MODULES, new EjbJar());
}});
container2.close();
assertTrue(SystemInstance.isInitialized());
assertSame(container1, container2);
Reflections.invokeByReflection(container2, "doClose", new Class<?>[0], null);
assertFalse(SystemInstance.isInitialized());
}
示例12: start
import javax.ejb.embeddable.EJBContainer; //导入依赖的package包/类
@BeforeClass
public static void start() throws Exception {
final Properties p = new Properties();
p.setProperty("openejb.deployments.classpath.include", "spring-data-proxy");
p.setProperty("openejb.exclude-include.order", "exclude-include");
p.setProperty("jdbc/DynamicUserDaoTest", "new://Resource?type=DataSource");
p.setProperty("jdbc/DynamicUserDaoTest", "new://Resource?type=DataSource");
p.setProperty("jdbc/DynamicUserDaoTest.JdbcDriver", "org.hsqldb.jdbcDriver");
p.setProperty("jdbc/DynamicUserDaoTest.JdbcUrl", "jdbc:hsqldb:mem:moviedb");
p.setProperty("jdbc/DynamicUserDaoTest.UserName", "sa");
p.setProperty("jdbc/DynamicUserDaoTest.Password", "");
container = EJBContainer.createEJBContainer(p);
}
示例13: play
import javax.ejb.embeddable.EJBContainer; //导入依赖的package包/类
@Test
public void play() throws Exception {
Properties properties = new Properties();
properties.setProperty(LocalMBeanServer.OPENEJB_JMX_ACTIVE, Boolean.TRUE.toString());
EJBContainer container = EJBContainer.createEJBContainer(properties);
MBeanServer server = ManagementFactory.getPlatformMBeanServer();
ObjectName objectName = new ObjectName(OBJECT_NAME);
assertEquals(0, server.getAttribute(objectName, "value"));
server.setAttribute(objectName, new Attribute("value", 3));
assertEquals(3, server.getAttribute(objectName, "value"));
assertEquals("winner", server.invoke(objectName, "tryValue", new Object[]{3}, null));
assertEquals("not the correct value, please have another try", server.invoke(objectName, "tryValue", new Object[]{2}, null));
container.close();
}
示例14: test
import javax.ejb.embeddable.EJBContainer; //导入依赖的package包/类
public void test() throws Exception {
Properties p = new Properties();
p.put("movieDatabase", "new://Resource?type=DataSource");
p.put("movieDatabase.JdbcDriver", "org.hsqldb.jdbcDriver");
p.put("movieDatabase.JdbcUrl", "jdbc:hsqldb:mem:moviedb");
Context context = EJBContainer.createEJBContainer(p).getContext();
Movies movies = (Movies) context.lookup("java:global/injection-of-datasource/Movies");
movies.addMovie(new Movie("Quentin Tarantino", "Reservoir Dogs", 1992));
movies.addMovie(new Movie("Joel Coen", "Fargo", 1996));
movies.addMovie(new Movie("Joel Coen", "The Big Lebowski", 1998));
List<Movie> list = movies.getMovies();
assertEquals("List.size()", 3, list.size());
for (Movie movie : list) {
movies.deleteMovie(movie);
}
assertEquals("Movies.getMovies()", 0, movies.getMovies().size());
}
示例15: test
import javax.ejb.embeddable.EJBContainer; //导入依赖的package包/类
public void test() throws Exception {
Properties p = new Properties();
p.put("movieDatabase", "new://Resource?type=DataSource");
p.put("movieDatabase.JdbcDriver", "org.hsqldb.jdbcDriver");
p.put("movieDatabase.JdbcUrl", "jdbc:hsqldb:mem:moviedb");
final Context context = EJBContainer.createEJBContainer(p).getContext();
Movies movies = (Movies) context.lookup("java:global/jpa-eclipselink/Movies");
movies.addMovie(new Movie("Quentin Tarantino", "Reservoir Dogs", 1992));
movies.addMovie(new Movie("Joel Coen", "Fargo", 1996));
movies.addMovie(new Movie("Joel Coen", "The Big Lebowski", 1998));
List<Movie> list = movies.getMovies();
assertEquals("List.size()", 3, list.size());
for (Movie movie : list) {
movies.deleteMovie(movie);
}
assertEquals("Movies.getMovies()", 0, movies.getMovies().size());
}