1 / 14

Build, deploy, and test EJB components in just a few seconds

Build, deploy, and test EJB components in just a few seconds. Nader Aeinehchi, Chief Architect – September 2005. Challenge. Build, deploy and test cycle very time-consuming In average between few minutes to half an hour Often requires cleaning the cache or restart of the server.

aderyn
Download Presentation

Build, deploy, and test EJB components in just a few seconds

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Build, deploy, and test EJB components in just a few seconds Nader Aeinehchi, Chief Architect – September 2005

  2. Challenge • Build, deploy and test cycle very time-consuming • In average between few minutes to half an hour • Often requires cleaning the cache or restart of the server

  3. Mock frameworks • Speed up the development process • But • Many frameworks to choose from • Mock frameworks do not provide a complete solution • Mock frameworks need to be integrated with each other • Requires the developer to learn the framework • Requires often special adjustments to the tests

  4. EJB container EJB container Application Application Test Test Traditional testing of EJB components 1. 2. remote

  5. Instead of running your code inside a container,Run the container inside your code

  6. 2. EJB container EJB container Test EJB container Application Application Application Test Test remote 3. Testing with embedded container 1. 1.

  7. OpenEJB as embedded EJB container • Designed to be embedded • Takes few seconds to boot and run • Zero administration • Default EJB container for Apache Geronimo and supported by IBM

  8. Test EJB container Application 3. Running OpenEJB in embedded mode • Provide JVM arguments: -Djava.naming.factory.initial=org.openejb.client.LocalInitialContextFactory -Djava.naming.provider.url=ormi://localhost:4201 -Dopenejb.home=c:\java\openejb\openejb-0.9.2 -Dopenejb.configuration=c:\java\openejb\openejb-0.9.2\conf\openejb.conf -Dopenejb.loader=embed -Dopenejb.localcopy=true

  9. Run the test and OpenEJB from Eclipse

  10. 2. EJB container Application Test remote Run unit tests with Oracle OC4J • Deploy the application to OC4J • Provide JVM arguments: -Djava.naming.factory.initial=com.evermind.server.ApplicationClientInitialContextFactory -Djava.naming.provider.url=ormi://localhost:23791/myapplication -Djava.naming.security.principal=admin -Djava.naming.security.credentials=password

  11. Run the test with remote OC4J from Eclipse

  12. Automate input for the tests • Hard-coded Java • time-consuming • pollutes the test • Database • requires a machinery • XML • Appropriate • Many XML – Java mapping frameworks • Xstream • Fast • Simple • Complex Object Hierarchy • Snapshot and persist to file: • XStream xstream = new XStream(); • String xml = xstream.toXML(foo)); • FooWriter.write("foo.xml", xml); • Convert from XML to Java • String xml = FooReader.read("foo.xml"); • Foo foo = xstream.fromXML(xml);

  13. References • JavaWorld: • "Build, deploy, and test EJB components in just a few seconds, OpenEJB simplifies Enterprise JavaBeans development", by Nader Aeinehchi • http://www.javaworld.com/javaworld/jw-06-2005/jw-0613-ejb.html • OpenEJB: • http://www.openejb.org • JUnit: • http://www.junit.org • XStream: • http://xstream.codehaus.org/ • Eclipse: • http://www.eclipse.org • Oracle OC4J: • http://www.oracle.com/technology/tech/java/oc4j/index.html • "Container Driven Testing: Advanced EJB Testing with OpenEJB," N. Alex Rupp (TheServerSide.com, June 2004): • http://www.theserverside.com/articles/article.tss?l=ContainerDrivenTestingSeries • Getting Started with OpenEJB: • http://blog.ideoplex.com/software/2004/01/29.html#a768 • A Simple Entity Bean with OpenEJB: • http://blog.ideoplex.com/software/2004/03/31.html#a828 • Chapter 2, Java Naming and Directory Interface, from the Oracle9iAS Containers for J2EE Services Guide: • http://www.di.unipi.it/~ghelli/bdl/A97329_03/web.902/a95879/jndi.htm • For more articles on testing, browse the Testing section of JavaWorld's Topical Index: • http://www.javaworld.com/channel_content/jw-testing-index.shtml • For more articles on EJB, browse the Enterprise JavaBeans (EJB) section of JavaWorld's Topical Index: • http://www.javaworld.com/channel_content/jw-ejbs-index.shtml?

  14. Demo • POJO development • EJB development

More Related