|
|
Optimize with a SATA RAID Storage Solution
Range of capacities as low as $1250 per TB. Ideal if you currently rely on servers/disks/JBODs
Page 4 of 6
public class CarEjbTest extends TestCase {
private Context context;
private Car mockCar;
public final static String CAR_HOME = "ejb/car/Car";
protected void setUp() throws Exception {
super.setUp();
context = new InitialContext();
/*
* You have to write some file reader that reads
* the XML representing the car object
*/
String xml = SomeFileReader.getCarXML();
mockCar = (Car) (new XStrem()).fromXML(xml);
}
protected void tearDown() throws Exception {
super.tearDown();
}
public void testCar() throws Exception {
try {
/*
* Get the reference to home object
*/
Object objref = context.lookup(CAR_HOME);
CarReservationHome carReservationHome = (CarReservationHome)
PortableRemoteObject.narrow(objref,
CarReservationHome.class);
CarReservation carReservation = carReservationHome.create();
boolean ok = reservation.reserveCar(mockCar);
assertTrue(ok);
} catch (NamingException e) {
e.printStackTrace();
} catch (RemoteException e) {
e.printStackTrace();
}
}
}
Interestingly, the above test can be run both inside and outside an EJB container, with the following alternatives:
OpenEJB can be installed as either a standalone server or an embedded container:
c:\java\openejb.
move conf conf.bak.
conf, mkdir conf.
conf folder, create the following files:
openejb.conflogging.confmyapp.cmp.global-database.xmlmyapp.cmp.local-database.xmlmyapp.cmp.or-mapping.xmlopenejb.conf and make sure that it correctly references myapp.cmp.global-database.xml, myapp.cmp.local-database.xml, and myapp.cmp.or-mapping.xml. Note that the path is calculated from c:\java\openejb. For example, the path to myapp.cmp.global-database.xml would be conf/myapp.cmp.global-database.xml in openejb.conf. In all the above files, you must define various container-managed persistence and bean-managed persistence containers. Furthermore,
you must define connectors for various datasources.
openejb.conf, add a reference to your jar file. For example: <Deployments jar="C:\dev\myapp\deploy\myapp-ejb.jar"/>.
Deploy your application jar file only once to OpenEJB. OpenEJB will add a file called openejb-jar.xml to your jar file. The openejb-jar.xml file contains configuration information specific to OpenEJB. If you add or remove EJB beans, you must deploy again.
Here is the syntax for deploying a jar file:
openejb deploy -a -c C:\dev\myapp\deploy\myapp-ejb.jar
Now, you need to back up openejb-jar.xml. You will find it under the application jar file's META-INF folder. Simply go to the command prompt and run the following to extract the files:
Archived Discussions (Read only)