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.

Similar Messages

  • Tried to add JUnit Test in Eclipse -- "Test type does not exist" error

    Hi guys,
    I'm developing an assignment whose details I won't bother going into -- it's enough to say that we were introduced to JUnit testing a couple of weeks ago in university tutorials, and I've stupidly tried to add one to my project without fully understanding it all. This is in eclipse 3.1.1.
    Basically, I followed eclipse's built-in tutorial called "Writing and running JUnit tests ".
    1) Created class "TestFailure" with method "testFailure".
    public void testFailure() throws Exception {
        fail();
    } 2) This then appeared as a .java file in my project (as well as on my UML diagram, courtesy of Omondo's UML plugin).
    3) I decided it was too risky mucking around with this stuff in a "live" project, so went ahead and deleted the TestFailure icon on my class diagram.
    4) I closed down eclipse.
    5) I went ahead and deleted TestFailure.java and TestFailure.class from my project folders.
    6) I opened my project again, and tried to execute...
    ... and now I keep getting a Test type does not exist error when I try and run it.
    How on earth do I get rid of this?
    Any advice/guidance is greatly appriciated -- oh, how I wish I'd not started messing with JUnit testing!!! :)

    Um, okay -- I fully hold my hands up and admit that I don't know what I'm doing with JUnit testing (we only had a half hour intro to it) but figured I may as well learn by using the official tutorials. It's always a good place to start! Although obviously using a current assignment isn't the best idea ;)
    I was executing my main class (obviously with my main method in there) to execute the program after I'd deleted test case classes, but strangely I've just shut down my machine and restarted and it's working fine. I'm not sure what the deal is here -- lesson learnt though, study new topics on a dummy project! :)
    Anyway, if I waited until I understood the software and code I'm producing to its fullest, I think hell'd freeze over before I executed any code! :) Using a tutorial to learn a new aspect of software I'm already familiar with wasn't a bad move, IMHO. Just using it on this particular project was... Needless stress and all that.

  • How to test servlet using Junit test????

    Hello everybody
    Does anybody know how to test an servlet class using Junit without using Cactus test . Is it possible to test a servlet using Junit without cactus test.Plz tell me the process how to test a servlet using Junit test .
    Regards
    srikant

    1) Do yoiu mean how to "run" your servlet code with sample parameter? This call manual testing with a sample run of you code. You need a web server(eg Tomcat), create a webapp with your servlet then deploy it there in order to run it.
    2) httpunit and junit are framework to write test case code that can be automated and repeatable. Plz read their doc.
    3) Your sample code me a very wrong way to retrieve and convert servlet parameters.
    Get a java toturial and servlet tutorial book and read it over the weekend. You need to get at least the basic.

  • 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.

  • 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.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Cannot get to debugger when Debug As - Junit Test in OEPE

    In Oracle Enterprise Pack for Eclipse, I created a JUnit (3 or 4) test case. When I attempted to Debug As -> Junit Test, I would get NullPointerException and cannot get to the debugger at all. However, there is no such problem in Ganymede (not OEPE). Is this a known problem for OEPE?
    The stack trace is:
    junit.framework.AssertionFailedError: Exception in constructor: testMapCustomer (org.apache.commons.logging.LogConfigurationException: org.apache.commons.logging.LogConfigurationException: java.lang.NullPointerException (Caused by java.lang.NullPointerException) (Caused by org.apache.commons.logging.LogConfigurationException: java.lang.NullPointerException (Caused by java.lang.NullPointerException))
         at org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryImpl.java:543)
         at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:235)
         at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:209)
         at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:351)
         at org.springframework.test.ConditionalTestCase.<init>(ConditionalTestCase.java:50)
         at org.springframework.test.AbstractSpringContextTests.<init>(AbstractSpringContextTests.java:73)
         at org.springframework.test.AbstractSingleSpringContextTests.<init>(AbstractSingleSpringContextTests.java:80)
         at org.springframework.test.AbstractDependencyInjectionSpringContextTests.<init>(AbstractDependencyInjectionSpringContextTests.java:98)
         at com.cibc.wmfxr.pricing.processor.test.Junit38SybaseDaoTest.<init>(Junit38SybaseDaoTest.java:6)
         at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
         at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
         at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
         at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
         at junit.framework.TestSuite.createTest(TestSuite.java:54)
         at junit.framework.TestSuite.addTestMethod(TestSuite.java:280)
         at junit.framework.TestSuite.<init>(TestSuite.java:140)
         at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestLoader.getTest(JUnit3TestLoader.java:102)
         at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestLoader.loadTests(JUnit3TestLoader.java:59)
         at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:445)
         at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
         at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
         at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
    Caused by: org.apache.commons.logging.LogConfigurationException: java.lang.NullPointerException (Caused by java.lang.NullPointerException)
         at org.apache.commons.logging.impl.LogFactoryImpl.getLogConstructor(LogFactoryImpl.java:397)
         at org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryImpl.java:529)
         ... 21 more
    Caused by: java.lang.NullPointerException
         at org.apache.commons.logging.impl.LogFactoryImpl.getLogConstructor(LogFactoryImpl.java:374)
         at org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryImpl.java:529)
         at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:235)
         at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:209)
         at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:351)
         at org.springframework.test.ConditionalTestCase.<init>(ConditionalTestCase.java:50)
         at org.springframework.test.AbstractSpringContextTests.<init>(AbstractSpringContextTests.java:74)
         at org.springframework.test.AbstractSingleSpringContextTests.<init>(AbstractSingleSpringContextTests.java:80)
         at org.springframework.test.AbstractDependencyInjectionSpringContextTests.<init>(AbstractDependencyInjectionSpringContextTests.java:98)
         at com.cibc.wmfxr.pricing.processor.test.Junit38SybaseDaoTest.<init>(Junit38SybaseDaoTest.java:6)
         at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
         at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
         at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
         at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
         at junit.framework.TestSuite.createTest(TestSuite.java:54)
         at junit.framework.TestSuite.addTestMethod(TestSuite.java:280)
         at junit.framework.TestSuite.<init>(TestSuite.java:140)
         at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestLoader.getTest(JUnit3TestLoader.java:102)
         at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestLoader.loadTests(JUnit3TestLoader.java:59)
         at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:445)
         at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:674)
         ... 2 more
         at junit.framework.Assert.fail(Assert.java:47)
         at junit.framework.TestSuite$1.runTest(TestSuite.java:90)
         at junit.framework.TestCase.runBare(TestCase.java:130)
         at junit.framework.TestResult$1.protect(TestResult.java:106)
         at junit.framework.TestResult.runProtected(TestResult.java:124)
         at junit.framework.TestResult.run(TestResult.java:109)
         at junit.framework.TestCase.run(TestCase.java:120)
         at junit.framework.TestSuite.runTest(TestSuite.java:230)
         at junit.framework.TestSuite.run(TestSuite.java:225)
         at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
         at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
         at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
         at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
         at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
         at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)

    Thanks. I tried it with the downloaded junit-4.6.jar and got the following stack trace. Now I wonder I should try it with the Junit bundle in the SpringSource Enterprise Bundle Repository since OEPE integrates the Spring OSGi Bundle. If this is the right idea, could you let me know how to install the Junit bundle in OEPE? Do I just add it to bundles.info? There are already a few lines for org.junit in bundles.info. What should I do with them? Thanks a lot.
    java.lang.ExceptionInInitializerError
         at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
         at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
         at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
         at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
         at org.junit.internal.builders.AnnotatedBuilder.buildRunner(AnnotatedBuilder.java:31)
         at org.junit.internal.builders.AnnotatedBuilder.runnerForClass(AnnotatedBuilder.java:24)
         at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:57)
         at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:29)
         at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:57)
         at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:24)
         at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.<init>(JUnit4TestReference.java:28)
         at org.eclipse.jdt.internal.junit4.runner.JUnit4TestClassReference.<init>(JUnit4TestClassReference.java:24)
         at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.createTest(JUnit4TestLoader.java:40)
         at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.loadTests(JUnit4TestLoader.java:30)
         at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:445)
         at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
         at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
         at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
    Caused by: org.apache.commons.logging.LogConfigurationException: org.apache.commons.logging.LogConfigurationException: java.lang.NullPointerException (Caused by java.lang.NullPointerException) (Caused by org.apache.commons.logging.LogConfigurationException: java.lang.NullPointerException (Caused by java.lang.NullPointerException))
         at org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryImpl.java:543)
         at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:235)
         at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:209)
         at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:351)
         at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.<clinit>(SpringJUnit4ClassRunner.java:63)
         ... 18 more
    Caused by: org.apache.commons.logging.LogConfigurationException: java.lang.NullPointerException (Caused by java.lang.NullPointerException)
         at org.apache.commons.logging.impl.LogFactoryImpl.getLogConstructor(LogFactoryImpl.java:397)
         at org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryImpl.java:529)
         ... 22 more
    Caused by: java.lang.NullPointerException
         at org.apache.commons.logging.impl.LogFactoryImpl.getLogConstructor(LogFactoryImpl.java:374)
         ... 23 more

  • Getting error while writing JUnit test case for RestFul Services

    Hi All,
    I have written Restful services in Netbean 6.8.
    It's running well...no issues.
    {color:#0000ff}While writing JUnit test cases for them, I am getting following error:
    {color}{color:#993300}Testcase: testGetAuthenticated(com.ct.services.LoginServicesTest): Caused an ERROR
    Implementing class{color}
    java.lang.IncompatibleClassChangeError: Implementing class
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:616)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
    at java.net.URLClassLoader.access$000(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:303)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
    at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:316)
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:616)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
    at java.net.URLClassLoader.access$000(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:303)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
    at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:316)
    at org.eclipse.persistence.jpa.PersistenceProvider.createEntityManagerFactory(PersistenceProvider.java:160)
    at org.eclipse.persistence.jpa.PersistenceProvider.createEntityManagerFactory(PersistenceProvider.java:65)
    at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:52)
    at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:34)
    at com.ct.services.LoginServices.getAuthenticated(LoginServices.java:205)
    at com.ct.services.LoginServicesTest.testGetAuthenticated(LoginServicesTest.java:84)
    Test com.ct.services.LoginServicesTest FAILED
    F:\NetbeanProjectsWorkspace\DemoProject\nbproject\build-impl.xml:972: Some tests failed; see details above.
    BUILD FAILED (total time: 11 seconds)
    {color:#0000ff}Strange thing is that when I am commenting below lines and its related calls:
    {color}
    {color:#ff0000}EntityManagerFactory mEmf = Persistence.createEntityManagerFactory("AnyName");
    EntityManager mEm = mEmf.createEntityManager();
    {color}
    {color:#0000ff}from my code, JUnit test cases are working fine.
    {color}Anybody having any idea about this ?
    Thanks
    Avi
    Edited by: Avi007 on Aug 28, 2010 5:17 AM

    Hi All,
    [http://stackoverflow.com/questions/2778295/test-driven-development-problem]
    Please refer the above link for the solution
    Thanks
    Avi
    Edited by: Avi007 on Aug 30, 2010 12:33 AM

  • Exception while running a test file as JUNIT test case

    Hi,
    I am trying to build a code using Eclipse to generate an "ear" file that can be used for deployment. The ear file is generated successfully but the build is not successful as the following exception is thrown while debugging a junit test case:
    javax.naming.CommunicationException: tdk.dk:389 [Root exception is java.net.SocketTimeoutException: connect timed out]
         at com.sun.jndi.ldap.Connection.<init>(Connection.java:197)
         at com.sun.jndi.ldap.LdapClient.<init>(LdapClient.java:118)
         at com.sun.jndi.ldap.LdapClient.getInstance(LdapClient.java:1580)
         at com.sun.jndi.ldap.LdapCtx.connect(LdapCtx.java:2616)
         at com.sun.jndi.ldap.LdapCtx.<init>(LdapCtx.java:287)
         at com.sun.jndi.ldap.LdapCtxFactory.getUsingURL(LdapCtxFactory.java:175)
         at com.sun.jndi.ldap.LdapCtxFactory.getUsingURLs(LdapCtxFactory.java:193)
         at com.sun.jndi.ldap.LdapCtxFactory.getLdapCtxInstance(LdapCtxFactory.java:136)
         at com.sun.jndi.ldap.LdapCtxFactory.getInitialContext(LdapCtxFactory.java:66)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:597)
         at junit.framework.TestCase.runTest(TestCase.java:154)
         at junit.framework.TestCase.runBare(TestCase.java:127)
         at junit.framework.TestResult$1.protect(TestResult.java:106)
         at junit.framework.TestResult.runProtected(TestResult.java:124)
         at junit.framework.TestResult.run(TestResult.java:109)
         at junit.framework.TestCase.run(TestCase.java:118)
         at junit.framework.TestSuite.runTest(TestSuite.java:208)
         at junit.framework.TestSuite.run(TestSuite.java:203)
         at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
         at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
         at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
         at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
         at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
         at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
    Kindly suggest a solution.
    P.S. : All test cases are running fine except for one test case, whose error details are given.

    No it is not. The Oracle JDeveloper and ADF forum is for development questions around development with Oracle JDeveloper and ADF.
    If you use Eclipse through OEPE, you could post the question here
    Enterprise Pack for Eclipse
    If you don't use OEPE but Eclipse, then this forum may be a great source of help: http://stackoverflow.com/
    Frank

  • Exceptions trying to run Junit test thro Jdev. Test uses Application module

    Hi,
    my junit test works through the OraTst frame work. But I want to debug the code and If I try to run the same test through Jdev I am running into a following exception. Can somebody tell me how to fix this issue.
    I am a consumer of the Application module, I have not created it. I am using it by referencing it through the jar file provided by the owner.
    oracle.jbo.DMLException: JBO-27200: JNDI failure. Unable to lookup Data Source at context jdbc/EMReposDS
    at oracle.jbo.server.DBTransactionImpl.lookupDataSource(DBTransactionImpl.java:1414)
    at oracle.jbo.server.DBTransactionImpl2.connectToDataSource(DBTransactionImpl2.java:309)
    at oracle.jbo.common.ampool.DefaultConnectionStrategy.connect(DefaultConnectionStrategy.java:203)
    at oracle.jbo.server.ApplicationPoolMessageHandler.doPoolConnect(ApplicationPoolMessageHandler.java:553)
    at oracle.jbo.server.ApplicationPoolMessageHandler.doPoolMessage(ApplicationPoolMessageHandler.java:409)
    at oracle.jbo.server.ApplicationModuleImpl.doPoolMessage(ApplicationModuleImpl.java:8534)
    at oracle.jbo.common.ampool.ApplicationPoolImpl.sendPoolMessage(ApplicationPoolImpl.java:4392)
    at oracle.jbo.common.ampool.ApplicationPoolImpl.prepareApplicationModule(ApplicationPoolImpl.java:2388)
    at oracle.jbo.common.ampool.ApplicationPoolImpl.prepareResource(ApplicationPoolImpl.java:3621)
    at oracle.jbo.pool.ResourcePool.useResource(ResourcePool.java:344)
    at oracle.jbo.common.ampool.ApplicationPoolImpl.doCheckout(ApplicationPoolImpl.java:2200)
    at oracle.jbo.common.ampool.ApplicationPoolImpl.useApplicationModule(ApplicationPoolImpl.java:3088)
    at oracle.jbo.common.ampool.SessionCookieImpl.useApplicationModule(SessionCookieImpl.java:460)
    at oracle.jbo.common.ampool.SessionCookieImpl.useApplicationModule(SessionCookieImpl.java:431)
    at oracle.jbo.common.ampool.SessionCookieImpl.useApplicationModule(SessionCookieImpl.java:426)
    at oracle.jbo.client.Configuration.getApplicationModule(Configuration.java:1494)
    at oracle.jbo.client.Configuration.createRootApplicationModule(Configuration.java:1399)
    at oracle.jbo.client.Configuration.createRootApplicationModule(Configuration.java:1370)
    -Sidd

    Sidd,
    No idea what OraTst is, but based upon the name of your data source, I'd guess you are an Oracle employee using an internal framework. I understand that there are some internal Oracle forums that you can use.
    John

  • Creating junit test cases using the reflection API

    In order to use the reflection API to get information about a *.java file's class name and methods, I need to compile the *.java file first, and then get info through the *.class file. Am I right?
    Eclipse, the Java IDE, can create junit test cases for java files the user selects right after the *.java files have been created, and even before the *.java files have been compiled by the user. I guess Eclipse internally compiles the java files before creating JUnit test cases for them. Does anyone know about it? Thanks.

    Let me explain my problem in more details.
    Given any java source tree, my program is supposed to create junit test cases for each class using java reflection. My approach is to scan through the source tree to keep the list of classes available, then compile all the java files in the given source tree, then do Class.forName() to load them to get their methods... Obviously I don't know what classes I will have at compilation time. I create a temp_classes directory as the output directory for the given source tree java files, and I add temp_classes to my classpath when I strart up my own program. However, that won't work..
    D:\eclipse\workspace\cmpe271_hw4\classes>java -classpath ..\classes;..\temp_classes Test
    javac -classpath .\temp_classes; -d .\temp_classes @temp_classes\javalist.txt
    java.lang.ClassNotFoundException: Factory
    java.lang.ClassNotFoundException: InvalidDateFormatException
    java.lang.ClassNotFoundException: MyUtility
    java.lang.ClassNotFoundException: Storage

  • Question about writing Junit test for SQLj application

    Just inherite a SQLj application without unit test. After making few enchancement I plan to add unit test about it to make it more solid. What I plan to do is invoke SQLj translator dynamically to generate java source, then compile and invoke the result class dynamically at Junit test. Does anyone how to call SQLj translator as an API call ??

    I guess I might add that the error I am getting is
    java.lang.nullPointerException
    i've got this now:
         public E top() throws EmptyStackException {
              if (numItems == 0)
                   throw new EmptyStackException("Stack is empty");
              return S[numItems--];
         }With the same test, as it would throw an emptystackexception not a full..
    But the test still doesn't pass.

  • Accessing Jar resource issue (in Junit test)

    Hi,
    I have a package called my.test.example containing one class called Example1.class and a property file called MyProp.properties. I am trying to load the content of MyProp.properties with the following:
    static {
        Properties Configuration = new Properties();
        try {
           URL url = Example1.class.getResource("/MyProp.properties");
           Configuration.load(url.openStream());
        } catch (IOException ex) {
            LOG.severe("Cannot load MyProp.properties :\n" + ex.toString());
    }The url is systematically null. I have tried including the package name, to use '/' instead of '.', but it does not work. How should I proceed? I am looking for a solution that works wherever the .jar is installed. Is this possible?
    Thanks.
    P.S.: I am working under Vista and the static code is invoked in a Junit test. I don't know whether this has an impact on the issue (but I don't think so).

    OK. Solved the issue with:
    Configuration.load(Example1.class.getResourceAsStream("MyProp.properties"));I had to solve another 'hidden' bug in the code.

  • Check if an exception is thrown during my JUnit test

    Hi all,
    I've been writing unit tests for the application I'm writing.
    I'm trying to write one very generic test which will simply open up the application, press some buttons, and close it back down, and confirm that no exceptions were thrown at any time during the test.
    Unfortunately, while I figured I could just wrap the whole thing in a try/catch block, it seems that I have an exception that is being thown in the AWT-EventQueue which isn't being caught. The test passes fine, but I want it to fail.
    What is the best way to go about checking for this? Should I be running the test in the event queue? Or should I have my own error handler to catch the exceptions?
    Thanks!
    Tim

    jschell wrote:
    TimQuinn wrote:
    I'm not trying to fix the bug. I'm trying to make my JUnit tests catch the exception. I think we're going around in circles here.Yep. Because the problem was stated incorrectly.
    Exceptions are returned up the call stack within the thread of execution.
    You have two threads. The one that the test runs in A, and another B.
    You can't catch or even see an exception in A that originated in B as an exception (you can't catch it.)
    So you need to find some other way, some other place, to put a catch, in thread B and then create data which indicates whether it worked or not. Or find some other existing data that changes state because of that.Well, the question that I asked in my original post was exactly that: how do I find out about an exception that is thrown in another thread? If something got stated incorrectly, maybe it was in the later posts?
    It can't be impossible: I can think of one very simple solution to my question, but it isn't very good. I can simply replace the Standard Error writer with one that sets a"fail" flag every time it is called. Then my test can fail every time Standard Error is written to, no matter which thread it's in. Obviously, this isn't a great solution, because, while it would fail the test every time an exception was printed, it would fail other times as well.
    So with a bit more work I could parse what's written to stderr myself, to check if it's a real exception. But this really seems like re-inventing the wheel. Is there no standard pattern for creating a test that confirms that you can run something without generating exceptions?

  • Using TimesTen for JUnit tests

    I want to switch from using HSQL (in memory) to TimesTen in my Unit tests. Is there a simple setup for TimesTen when used for this purpose?
    For example, for HSQL, all I have to do is include the hsql.jar as a dependency in my project, then include the following line in my JUnit test:
    DataSource dataSource = new DriverManagerDataSource("org.hsqldb.jdbcDriver",
    "jdbc:hsqldb:target/test-classes/com/project/path/test/schema", user, pw);
    schema is a reference to the schema.script that includes the DDL for all the tables that I need to create in memory.
    Can anyone help me out? Thanks.

    From what little I know about it TimesTen is not an in-memory database, it is a caching architecture. Therefore I would expect the set-up to be different - the TimesTen stuff should be set up once ever[], like the schema of a regular database, rather than everytime you run your unit tests.
    I think you need to sit down with the TimesTen documentation and figure out how you are going to use the product. If you are just looking for a quick DB to use in unit tests I think you may well want to keep using HSQL.
    Cheers, APC

  • 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.

Maybe you are looking for

  • Slow printing in Acrobat 7/9 on G5

    Here's a really odd problem: I have a G5 with 10.4.11. When I print a PDF which is all B/W images (scans) it takes a long time to queue the job and then there's a significant pause at the printer between each page. It's being printed to a copier conn

  • Using Sharepoint as an archival and document management

    Hello,  I was asked by my manager to look for possible solutions to convert our archive paper file cabinets that are full of student records into digital format. We do not utilize sharepoint yet at the school but I was researching and found that shar

  • How to make dual mono output from one mono track

    Please forgive my complete ignorance of music mixing/sound board terminology: I'm only using Logic Pro X because Apple deliberately made it impossible to use Soundtrack Pro as part of a roundtrip with FCPx. Soundtrack Pro is what I've always used for

  • Converting audio to xml form

    hi i need to know how to convert audio to xml form.. can any one help me on this...

  • Help creating browse sequences that work and deleting sync TOC

    Hi, I'm using the latest version of the TCS with RH 9.0. I'm trying to create WebHelp Pro output for a book produced originally in Framemaker. I've been following Rick's Skinny on skins guide to tailor the look and feel, but am having real problems g