Unable to run ADFBC JUNIT Test Classes with JDEV11G 11.1.1.6

Dear All,
I upgraded my project to the latest release JDEV 11G 11.1.1.6
Previously we are on JDEV 11G 11.1.1.5
I have a JUNIT class that I am running which test my ADFBC components.
public class MyTestClass {
  @Test
  public void testVOAccess()
    //assertions
}Unfortunately, I am hitting an error like this from the messages.
Mar 9, 2012 1:28:07 PM oracle.adf.share.ADFContext getCurrent
WARNING: Automatically initializing a DefaultContext for getCurrent.
Caller should ensure that a DefaultContext is proper for this use.
Memory leaks and/or unexpected behaviour may occur if the automatic initialization is performed improperly.
This message may be avoided by performing initADFContext before using getCurrent().
For more information please enable logging for oracle.adf.share.ADFContext at FINEST level.
Mar 9, 2012 1:28:08 PM oracle.security.jps.internal.config.xml.XmlConfigurationFactory initDefaultConfiguration
SEVERE: org.xml.sax.SAXParseException: Invalid encoding name "Cp1252".
Mar 9, 2012 1:28:10 PM oracle.mds
NOTIFICATION: PManager instance is created without multitenancy support as JVM flag "oracle.multitenant.enabled" is not set to enable multitenancy support.
Mar 9, 2012 1:28:12 PM oracle.security.jps.internal.config.xml.XmlConfigurationFactory initDefaultConfiguration
SEVERE: org.xml.sax.SAXParseException: Invalid encoding name "Cp1252".
Mar 9, 2012 1:28:12 PM oracle.adf.share.jndi.ReferenceStoreHelper getReferencesMapEx
WARNING: Incomplete connection reference object for connection:MYDATASOURCEAt the JUNIT Test Runner, I see this.
java.lang.ExceptionInInitializerError: null
     java.lang.reflect.Constructor.newInstance(Constructor.java:513)
     org.junit.runners.BlockJUnit4ClassRunner.createTest(BlockJUnit4ClassRunner.java:171)
     org.junit.runners.BlockJUnit4ClassRunner$1.runReflectiveCall(BlockJUnit4ClassRunner.java:216)
Caused by: oracle.jbo.DMLException: JBO-26061: Error while opening JDBC connection.
     oracle.jbo.server.ConnectionPool.createConnection(ConnectionPool.java:207)
     oracle.jbo.server.ConnectionPool.instantiateResource(ConnectionPool.java:166)To validate the issue, I tried to run my same project using the older release which is JDEV 11G 11.1.1.5
and I see that I am not hitting any error. All my test classes runs fine.
Has anybody replicated this?
Thanks

Didier Laurent wrote:
I logged the following bug for this issue:
bug 14030895 - REGR: JDEVELOPER 11.1.1.6.0 JUNIT JBO-26061 ERROR WHILE OPENING JDBC CONNECTION
Regards,
Didier.So its really a bug..
I abandon this already since I cannot find any solution to look up for this.
On the other hand, I am maintaining two jdeveloper version just to get around this problem.
When testing ADFBC, I used the 11.1.1.5 while for non-junit test I used the 11.1.1.6
Hopefully this gets fixed on the next release as I am having a hard time swithcing between two JDev version.
Thanks
Edited by: Neliel on May 3, 2012 11:42 PM

Similar Messages

  • How to create test classes with JUnit?

    Hello,
    I need to test my classes with JUnit. My editor is BlueJ.
    This is my class:
    package model;
    import java.util.*;
    public class Category
        private String name;
        private List<Appointment> appointments;
        private List<ToDo> toDos;
        public Category(String name)
            this.name = name;
            appointments = new ArrayList<Appointment>();
            toDos = new ArrayList<ToDo>();
        public String getName()
            return this.name;
        public void setName(String newName)
            this.name = newName;
        public void addAppointment(Appointment a)
            appointments.add(a);
        public void removeAppointment(Appointment a)
            appointments.remove(a);
        public void addToDo(ToDo t)
            toDos.add(t);
        public void removeToDo(ToDo t)
            toDos.remove(t);
        public List<Appointment> getAppointments()
            return appointments;
        public List<ToDo> getToDos()
            return toDos;
    }This is my JUnit test class code so far:
    package model;
    import java.util.*;
    * The test class CategoryTest.
    * @author  (your name)
    * @version (a version number or a date)
    public class CategoryTest extends junit.framework.TestCase
       private Category cat;
        protected void setUp()
            cat = new Category("Kategori");
        public void testGetAndSetName()
            assertTrue(cat.getName().equals("Kategori"));
            cat.setName("Kategori 2");
            assertTrue(cat.getName().equals("Kategori 2"));
            assertFalse(cat.getName().equals("Kategori"));
    }Any hint would be appreicted.
    Best regards,
    Turtle

    jonasse wrote:
    Hehe:)
    This is my code:
       private Category cate;
    protected void setUp() {
    text = new Appointment("Aftale",TimeStampGenerator.generate(1, 1, 2009), TimeStampGenerator.generate(1, 2, 2009));
    cate = new Category("Aftaler");
    public void testSetAndGetText() {
    assertTrue(text.getText().equals("Aftale"));
    text.setText("Andre aftaler");
    assertTrue(text.getText().equals("Andre aftaler"));
    public void testSetAndGetCategory()
    assertTrue(text.getText().equals("Aftale"));
    text.setText("Andre Aftaler");
    assertFalse(text.getText().equals("Aftale"));
         public void testGetAndSetStartTime() {
             assertTrue(text.getStartTime().equals(TimeStampGenerator.generate(1,2,2009)));
             text.setStartTime(TimeStampGenerator.generate(1,2,2008));
             assertTrue(text.getStartTime().equals(TimeStampGenerator.generate(1,2,2008)));
             assertFalse(text.getStartTime().equals(TimeStampGenerator.generate(1,2,2009)));
    }The last method compiles, but I get a failure when I run the test. Says no exception message???
    Thanks in advance,
    JonasSo this is where TDD kicks in. Your mission - should you choose to become test-infected - is to write tests that fail, preferably even don't compile, and then write the code that makes them pass. Compilation is no guarantee the thing will work. In all honesty, that test is probably too busy. Ideally, each test case has exactly one assert in it. That way, you can know instantly what's gone wrong. If you reply "but my code can't be tested like that" it's probably time to refactor it so that it can

  • Exception Description: Unable to process XML tag [driver-class] with value

    Hi
    I'm newbie with TopLink. I try to write a litle application with TopLink:
    - First, I create a session.xml file:
    <?xml version="1.0" encoding="UTF-8"?>
    <toplink-sessions version="11g Technology Preview 3 (11.1.1.0.0)" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <session xsi:type="database-session">
    <name>dbsession</name>
    <event-listener-classes/>
    <logging xsi:type="toplink-log"/>
    <primary-project xsi:type="xml">META-INF/tlMap.xml</primary-project>
    <login xsi:type="database-login">
    <platform-class>oracle.toplink.platform.database.oracle.Oracle10Platform</platform-class>
    <user-name>dev</user-name>
    <password>F6A3DA7BA187330D4E11A713C42FF833</password>
    <sequencing>
    <default-sequence xsi:type="table-sequence">
    <name>Default</name>
    </default-sequence>
    </sequencing>
    <driver-class>oracle.jdbc.OracleDriver</driver-class>
    <connection-url>jdbc:oracle:thin:@//10.10.10.31:1521/devdb1</connection-url>
    <bind-all-parameters>false</bind-all-parameters>
    <struct-converters/>
    </login>
    </session>
    </toplink-sessions>
    - Second, I create a Java Application ( Application1.java):
    package project2;
    import java.sql.ResultSet;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    import java.util.Vector;
    import oracle.toplink.queryframework.DataModifyQuery;
    import oracle.toplink.queryframework.SQLCall;
    import oracle.toplink.queryframework.StoredProcedureCall;
    import oracle.toplink.sessions.DatabaseSession;
    import oracle.toplink.sessions.Session;
    import oracle.toplink.tools.sessionconfiguration.XMLSessionConfigLoader;
    import oracle.toplink.tools.sessionmanagement.SessionManager;
    import oracle.toplink.util.SessionFactory;
    public class Application1 {
    public Application1() {
    public static void main(String[] args) {
    // new Application1();
    String statement = "SELECT motdepasse,login FROM bou_courtier";
    SessionManager sessionmanager = SessionManager.getManager();
    System.out.println("test");
    // SessionFactory sessionfactory = new SessionFactory("META-INF/sessions.xml","dbsession");
    DatabaseSession session = (DatabaseSession)sessionmanager.getSession(new XMLSessionConfigLoader(),"dbsession",Thread.currentThread().getContextClassLoader());
    // Session session = sessionfactory.acquireSession();
    System.out.println("test");
    SQLCall sqlcall = new SQLCall(statement);
    session.executeNonSelectingCall(sqlcall);
    ResultSet rs = sqlcall.getResult();
    try {
    while(rs.next()){
    String strPass = rs.getString(1);
    String strLogin = rs.getString(2);
    System.out.println("Password :"+strPass+"---"+"Login :"+strLogin);
    } catch (SQLException e) {
    // TODO
    - Third, I build and run Application1.java in Jdevelopper 11g preview 3. Sadly, the result is a error:
    Exception in thread "main" Local Exception Stack:
    Exception [TOPLINK-9003] (Oracle TopLink - 11g Technology Preview 3 (11.1.1.0.0) (Build 071207)): oracle.toplink.exceptions.SessionLoaderException
    Exception Description: Unable to process XML tag [driver-class] with value [oracle.jdbc.OracleDriver].
    Internal Exception: java.lang.ClassNotFoundException: oracle.jdbc.OracleDriver
         at oracle.toplink.exceptions.SessionLoaderException.failedToLoadTag(SessionLoaderException.java:83)
         at oracle.toplink.tools.sessionconfiguration.TopLinkSessionsFactory.buildDatabaseLoginConfig(TopLinkSessionsFactory.java:408)
         at oracle.toplink.tools.sessionconfiguration.TopLinkSessionsFactory.buildLogin(TopLinkSessionsFactory.java:336)
         at oracle.toplink.tools.sessionconfiguration.TopLinkSessionsFactory.buildDatabaseSessionConfig(TopLinkSessionsFactory.java:182)
         at oracle.toplink.tools.sessionconfiguration.TopLinkSessionsFactory.buildSession(TopLinkSessionsFactory.java:168)
         at oracle.toplink.tools.sessionconfiguration.TopLinkSessionsFactory.buildTopLinkSessions(TopLinkSessionsFactory.java:117)
         at oracle.toplink.tools.sessionconfiguration.XMLSessionConfigLoader.load(XMLSessionConfigLoader.java:239)
         at oracle.toplink.tools.sessionmanagement.SessionManager.getSession(SessionManager.java:448)
         at oracle.toplink.tools.sessionmanagement.SessionManager.getSession(SessionManager.java:311)
         at project2.Application1.main(Application1.java:33)
    Caused by: java.lang.ClassNotFoundException: oracle.jdbc.OracleDriver
         at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
         at java.security.AccessController.doPrivileged(Native Method)
         at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
         at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
         at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
         at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
         at oracle.toplink.tools.sessionconfiguration.TopLinkSessionsFactory.buildDatabaseLoginConfig(TopLinkSessionsFactory.java:405)
         ... 8 more
    Process exited with exit code 1.
    Can you help me to debug this error. Many thanks
    user615555

    The internal error: "java.lang.ClassNotFoundException: oracle.jdbc.OracleDriver"
    is stating it can't find your driver jar file on the classpath. You'll need to check that you've included your Database driver in the list of libraries on your classpath.
    Best Regards,
    Chris

  • How to run a junit test?

    Hi,
    i have compliled a junit test class (MsgQueueTest extends TestCase). When i try to run it, i get:
    kostas@home:~/programming/java/SwarmTests/src$ java MsgQueueTest
    Exception in thread "main" java.lang.NoClassDefFoundError: junit/framework/TestCase
            at java.lang.ClassLoader.defineClass1(Native Method)
            at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
            at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
            at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
            at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
            at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
            at java.security.AccessController.doPrivileged(Native Method)
            at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
            at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
            at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
            at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
            at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)I have tried some parameters, but no luck so far. Any ideas?

    Append junit.jar to your CLASSPATH.

  • Unable to run Mozilla demo site Problem with Bananabread

    I am using firefox 13.01 on a Mac OS and when I go to Mozilla web site
    "https://developer.mozilla.org/media/uploads/demos/a/z/azakai/3baf4ad7e600cbda06ec46efec5ec3b8/bananabread_1348775105_demo_package/index.html"
    When I click on the levels I get a message OOPs there was a problem starting Banabread" I have cleared my cache and cookies with no change. The demo says it will run on any modern 2012 browser. but I cna hear the sound in the background. Can anyone tell me why a Mozilla product is unable to run its own demo?

    No answers as to why Firefox 13.01 does not run on Mozilla's own web site even though Mozilla says any version this year should work.
    Mozilla web site "https://developer.mozilla.org/media/uploads/demos/a/z/azakai/3baf4ad7e600cbda06ec46efec5ec3b8/bananabread_1348775105_demo_package/index.html"

  • Error while running simple JAXB test class

    I am new to JAXB and trying to run simple tutorial code.
    I created Java project and added required jar files in a classpath.
    But I get error as
    "com.jaxbtest" doesnt contain ObjectFactory.class or jaxb.index
    I am using Eclipse and I have added these external jars in build path as well as in "Open Run Dialog" classpath.
    Thank you in advance.
    YB

    Hi Timo,
    Im using JDev version 11.1.1.6.0.
    I checked the class path on the jdev console. All the library references are mentioned in the manifest.mf classpath of the test project like below:
    Manifest-Version: 1.0
    Class-Path: lib/identitystore.jar
    lib/adfm.jar
    lib/groovy-all-1.6.3.jar
    lib/adftransactionsdt.jar
    lib/adf-dt-at-rt.jar
    lib/adfdt_common.jar
    lib/adflibrary.jar
    lib/xmlparserv2.jar
    lib/db-ca.jar
    lib/jdev-cm.jar
    lib/ojmisc.jar
    lib/commons-el.jar
    lib/jsp-el-api.jar
    etc...
    So I expect the library references should be resolved looking at the manifest file.
    Another set of entries that I see in the jdev classpath are related to the Model project which is under test.
    -classpath
    D:\CurrentProject_1\16_7_2013_3pm\11_7_2013\.adf;
    D:\CurrentProject_1\16_7_2013_3pm\11_7_2013\Model\classes;
    How do I put these entries into my class path? Will it be sufficient if I add the Model.jar into my test project classpath?
    Thanks,
    Sapna

  • Unable to run simple empty jsp page with weblogic 10.3.6.0.

    Dears,
    I have a simple war with simple empty welcome jsp page, when i deploy my project on AdminServer domain, jsp displays correctly, but if i deploy it on other domain i got this exception :
    java.lang.ClassCastException: org.apache.jasper.runtime.JspWriterImpl cannot be cast to weblogic.servlet.jsp.ByteWriter
         at jsp_servlet.__index._jspService(__index.java:63)
         at weblogic.servlet.jsp.JspBase.service(JspBase.java:34)
         at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
         at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
         at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:301)
         at weblogic.servlet.internal.ServletStubImpl.onAddToMapException(ServletStubImpl.java:416)
         at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:327)
         at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at oracle.security.jps.ee.http.JpsAbsFilter$1.run(JpsAbsFilter.java:119)
         at java.security.AccessController.doPrivileged(Native Method)
         at oracle.security.jps.util.JpsSubject.doAsPrivileged(JpsSubject.java:315)
         at oracle.security.jps.ee.util.JpsPlatformUtil.runJaasMode(JpsPlatformUtil.java:442)
         at oracle.security.jps.ee.http.JpsAbsFilter.runJaasMode(JpsAbsFilter.java:103)
         at oracle.security.jps.ee.http.JpsAbsFilter.doFilter(JpsAbsFilter.java:171)
         at oracle.security.jps.ee.http.JpsFilter.doFilter(JpsFilter.java:71)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at oracle.dms.servlet.DMSServletFilter.doFilter(DMSServletFilter.java:139)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3730)
         at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3696)
         at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
         at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
         at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2273)
         at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2179)
         at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1490)
         at weblogic.work.ExecuteThread.execute(ExecuteThread.java:256)
         at weblogic.work.ExecuteThread.run(ExecuteThread.java:221)
    I'm using weblogic 10.3.6, any help will be appreciated.
    regards.

    dunnsoftinc wrote:
    During the initial pass, I decided to leave this password null in both places, which is documented within the peopletools 8.53.00 installation guide. Maybe, it's time to further test. Thank you Nicolas.To be honest I've never tried to leave it blank in previous releases, thought that was mandatory (it was not prompted in psadmin menu as it is with PT8.53).
    I don't have a PTools 8.53 instance in hands right now, but after a quick test over here on PT8.51, I have the same issue as yours.
    Let me also remind you that there are two separate scenarios that may be received via the sign-on page:
    1.) "The application server is down" status message without the "bea.jolt.ServiceException: TPESVCERR - server error while handling request" error.
    2.) "The application server is down" status message including the "bea.jolt.ServiceException: TPESVCERR - server error while handling request" error.As I said earlier, you should get more clue in the webserver logfiles.
    Nicolas.

  • Unable to run Mega PC 865 Pro with 6600 GEFORCE?

    Really hoping someone can help here.
    I have a MEGA PC 865 PRO, and in it I have a Hauppauge 150 MCE Capture Card, a 160Gig HDD, DVD drive, 512MB RAM and a Pentium 4 2.6 Prescott.
    This was running great, but action sports looked very blurry in the background.  I decided that this was due to the on board graphics card not coping with the refresh rates required.
    SO - I purchased the XFX GEFORCE 6600 DDR 128MB with Dual DVI Output.
    After installing it initally worked fine (first 10 minutes) - and looked like I was home and hosed.  BUT - It freezes radomly.  Usually after 5 or so minutes of the PC being booted up.  Someitmes quicker after the initial.
    I am trying to find the cause.
    I have removed the Hauppauge 150 MCE card to see if this helps both temperature (more space) and power usage (less devices). I have also disconnected the DVD drive to assist with the power.
    BUT - It still freezes up.  Locks up and the only way to fix is to reboot - but the problem happens again.
    Anyone know what the issue is here?
    The power supply is as follows:
    MAX DC Output 250W
    (+3.3V & +5V = 120W MAX)(+3.3V & +5V & +12V = 200W MAX)
    It should be noted that other people have run the 6600 in their Mega PC without power issues.
    If anyone can help decipher the problem please do let me know.  My inkling is it is either power or temperature related - but hopefully there is another fix!
    Thanks all!
    JD34.

    is it only one game in particular, or does it happen with any 3D application?
    do you get problems when just using 2D graphics in Windows?
    which Nvidia drivers are you using? you can get the latest from www.nvidia.com
    also make sure you have the latest Intel chipset drivers from downloadfinder.intel.com

  • Running a JUnit test case using Ant in Eclipse

    If I have a "JUnit", how can I run it using "Ant" in Eclipse?
    Thanks.

    Right-click on the ant build script and select "Run as ant build". But why bother? Eclipse has its own JUnit runners

  • JUNIT test failure-Configuration file bc4j.xcfg not found in the classpath

    Hi All,
    As part of an ESS project,Im having a model project containing a VO(parameters VO).This VO is configured to have Read-only access through SQL query and have only one transient attribute each.For the model projects containing the VO for pre merge checker compliance I had to create JUNIT Test projects containing new AMs for testing the parametersVO. While running the JUNIT tests I got an exception like
    “oracle.jbo.JboException: JBO-29000: Unexpected exception caught: oracle.jbo.ConfigException, msg=JBO-33001: Configuration file /oracle/apps/hcm/goals/core/dataMigration/publicEssModel/test/applicationModule/common/bc4j.xcfg is not found in the classpath.”.—even though this file is contained in both the src/classes folder of the project.
    When i try to run the TestAM I'm getting an exception like 'configuration tester.xcfg not found in the calsspath.
    While debugging this error, we found that we are able to successfully run the JUNIT tests if we make some changes in the adf-config.xml file of the Application. The change required is to comment out the mdsC:adf-mds-config tag in the xml file.
    After doing this change Im also able to run my AM without any exception.
    Is this a known issue?.
    Since modifying the adf-config.xml is not a recommended practice is there any workaround that we can get rid of this exception.
    Regards,
    Ajin.

    Just checked but could only find this thread Unable to run ADFBC JUNIT Test Classes with JDEV11G 11.1.1.6
    As it's also dealing with junit and 11.1.1.6.0 you might want to read it.
    Timo

  • Use JUnit test EJB bean class

    I'm using Junit test EJB 3.0 session bean class by initialize :
    SessionBeanClass sbc = new SessionBeanClass()
    so the object I got is just a normal object, it's not remote or local interface.
    however, when I start JUnit within Jdeveloper, looks like the embed OC4J start.
    this behivor is strange to me, I thought I 'm not calling EJB in this case,why the OC4J start?
    this is different than running JUnit outside of JDeveloper?

    Yes, this is the way JDev works -- JDeveloper notices that this class happens to be a Session bean, and when you 'run' it, it assumes you want to 'run' it in the embedded OC4J server -- though clearly it is not what you want in this case.
    One way you can override this behavior is by creating a wrapper (POJO) class to be your JUnit test class, and have that class instantiate your Session bean.

  • Writing JUnit test app to test a method which uses AppResources

    Recently I was given a requirement to write a JUnit class( with main) to test a method in a Processor class which is running in weblogic. But this method in processor class makes use of AppResources like this: AppResources appResources = new AppResources("ApplicationResources"); String ruleFileName = appResources.getResourceString("rule.file.irlfile"); But when I try to run my JUnit test (stand alone app with main class) I am getting "java.util.MissingResourceException: Can't find bundle for base name ApplicationResources" exception. The appResources is null... Any ideas how to work around this problem?

    It doesn't sound like the Process class was designed for testability outside of its J2EE server container, probably. So writing a unit test for it, under its current design, may be an exercise in futility. You might want to look into "Cactus" tests (search for JUnit Cactus on the web), to test it in its container. Or, redesign the class for testability, separating its business logic better (that's a lot of work to do though) so that it can be instantiated and exercised independently of its environment.

  • Re: junit test for entity beans ... ejb 3.0

    I'm confused. I'm trying to test my entity bean.
    I have:
    - an entity bean
    - a stateless session bean for accessing the entity bean (facade)
    - an interface for accessing the the stateless bean
    And I'm trying to write a JUnit test class to test this bean. However, I am uncertain as to how to test this (I'm new to EJB 3.0, JBoss and Eclipse).
    What would the JUnit test look like? I'm confused as to whether or not I should be injecting the interface/bean/what???
    I've tried several variations. I either get "NameNotFound" - not bound exceptions or Null pointer exceptions.
    What would the @EJB syntax look like or how would I do it through the context?
    For Example:
    @EJB private TestFacade myTest; //interface to stateless bean ?
    OR
    InitialContext ctx = new InitialContext();
    TestResultFacadeBean myTest = (TestResultFacadeBean) ctx.lookup("localTest");
    I'm confused at to which method I should be using and what object I should be accessing. If I could get either one to work, I'd be happy. :)
    How do I ensure my bean is deployed to the container? What do I need to do?
    If anyone has a simple example or explanation as to which method I should use and how to use it, I'd be very grateful.
    Thanks very much,
    LisaD

    OK, you need to have several layers of testing.
    Layer 0. Test the entity beans are deployable (more on this later). Basically, you need to know that all your annotations work. Things to watch out for are multiple @Id fields in one class or @EmbeddedID or @IdClass in conjuction with @ManyToOne, @ManyToMany, @OneToMany, @OneToOne and fun with @JoinTable, @JoinColumn and @JoinColumns. Once you know how these are supposed to work with the spec, it's not too bad to write it correctly each time. But there are some gotchas that will break things later on.
    Layer 1. Do the functions in the classes that don't depend on annotations work as expected. Typically, this is just going to be the getters and setters in your entity classes. Of course JUnit best practice says we don't bother testing functions that look like:
    public T getX() {
    return this.x;
    or
    public void setX(T x) {
    this.x = x;
    as there is nothing that can go wrong with them. So in that case, your level 1 tests will just be initial values specified from constructors and verifying that the non-get/set pairs work, and that the getters you have tagged @Transient work (because you've likely put some logic in them)
    Layer 2. Test the session bean methods that don't require injection to work.
    Layer 3. Test the session bean methods that require injection (Mock Objects). Simulate the injection for yourself, injecting Mock Objects for the entity manager. Then you can confirm that the correct methods are being called in the correct sequences, etc.
    [Note this may require some skill in designing the mock.  I'm working on developing my own entitymanager mock, and if it looks usefull I'll release it to the world.
    Layer 4. Test the session bean methods that require injection (Real entity manager) (See Layer 0)
    For this you will need an out of container persistence implementation.  Currently Hibernate and Glassfish provide beta versions.  You will need a different persistence.xml file that lists all the entities.  You will have to use reflection to inject the entity manager(s) that you create from an entity manager factory unless you provide a constructor that takes an EntityManager as a parameter.  You may need to use reflection to call any @PostConstruct method if you made it private.
    Layer 5. Navigate the relationships in the objects returned from Layer 4 using a database that has been loaded with test data.
    I am currently using Layers 0, 1, 2 & 4 to test my session beans and entity beans.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Best practice for @EJB injection in junit test (out-of-container) ?

    Hi all,
    I'd like to run a JUnit test for a Stateless bean A which has another bean B injected via the @EJB annotation. Both beans are pure EJB 3 POJOs.
    The JUnit test should run out-of-container and is not meant to be an EJB client, either.
    What is the easiest/suggested way of getting this injection happening without explicitely having to instantiate the bean B in my test setup ?

    you can deal with EntityBeans without having the Container managed senario , you can obtain instance of EntityManager using the "EntityManagerFactory" and providing the "persistence.xml" file and provide the "provider" (toplink,hibernate ,...), then you can use entities as plain un managed classes

  • JUnit Tests (How To) - Websphere/Eclipse

    I'm about to start looking into using JUnit to test some db resultset timings. As I haven't really dived into this before, I'm looking for some guidance.
    Can someone post an example of how I would use JUnit to test the timing of a resultset or the timing of a procedure.
    I could just do a simple timed test, but I want to start using JUnit.
    Where:
    <start timing>
    do a bunch of really wild stuff
    <end timing>
    Thanks.

    JUnit isn't meant for performance timing. There's nothing to stop you from doing it, of course.
    JUnit might be pertinent if you had a metric that would define success or failure of your "really wild stuff".
    But timing would be more the province of JMeter or another performance measurement tool.
    With that said, Eclipse handles JUnit tests easily. Just have the JUnit JAR in your project's build path. Open the debug view and you can run any JUnit test in your project.
    I have an Ant build.xml that runs all the tests in my projects automatically and generates reports for viewing in a Web browser. That's a great way to go, IMO.

Maybe you are looking for

  • Trusted devices for 2 step verification

    I have set up 2 step verification with 2 trusted devices - my iphone and my partner's iphone.  The problem is that they both have the last 6 digits of the phone number the same.  So when I get the option for which phone to receive the code I get a li

  • Airport Extreme keeps dropping the connection

    Hi, I have this model: http://www.apple.com/airportextreme/ It is connected to the main router which is for TalkTalk, router is just a standard Broadband Wireless N ADSl2+ Router. My settings in my AE are: Internet Connect Using: DHCP IPv4 Address: 1

  • WPC Migration to 7.3 - Navigation

    Hi Everyone,      We are in the process of migrating WPC content originally created in version 7.0 to 7.3.      After connecting the Area to the Role I haven't been able to set the top level entry points correctly. I need to define the content below

  • Use of Convert to Formula Option

    Hi All Where do we use Convert to formula option and give me some scenarios. Regards Naga

  • Issues with Adobe Reader XI -- lost "submit" button option

    When I updated to Adobe Reader XI, the "submit" button that was located in the fillable form (in the purple bar) disappeared. When I downgraded to Adobe Reader X, the "Submit" button reappeared. Why is the option no longer available in XI?