Junit test cases

hi friends,
I am new to junit, so please tell me how to write junit test cases for static as well as for the method which return void. and also give any sample example which return void and declaring as static.
please friends i need your help.
Thank you

Lekha28 wrote:
I am new to junit, so please tell me how to write junit test cases for static...Testing a static method is the same as testing a non-static method. You decide what you are going to test, you set up the appropriate conditions, call the method and assert that the results match your expectations.
as well as for the method which return void. See above. There must be something you can assert about the results of the method. If you can't, then you'll need to consider refactoring your class so that it is easier to test (or accept that there is nothing to test, and therefore no need for the method).
~

Similar Messages

  • 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

  • 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

  • Executing Junit test case in EM console

    Hi ,
    When i execute Junit test case in EM console, and against the tab test runs my assertion details gets failed and data in both column, expected value and actual value remains the same but in the expected value column the name space gets automitically populated. Am not able to include the namespace in Junit test case as it gets removed at the run time .
    Kindly suggest.

    Were you able to solve this issue ?

  • Setting bind variables for VO in JUnit test case

    Hi,
    I am using Jdeveloper 11.1.2.2
    I have a problem while writing the test case for VO in JUnit.
    For the Remove method in the Test case , I have passed variables into the VO by using a setWhereClause() .
    Like this :
            view.setWhereClause(null);
            String whereClause = "location_id = '" + newUpdatedLocationId  + "' AND organization_id = '" +newOrganizationId + "'" ;
            view.setWhereClause(whereClause);
            view.executeQuery();
            while (view.hasNext()) {
                view.next();
                view.removeCurrentRow();
            fixture1.getApplicationModule().getTransaction().commit();But it is showing a an error like the bind variables are not set.
    So how will I access Bind variables programmatically and set the values ?
    Thanks
    Nigel.

    setNamedWhereClauseParam() is used for setting bind variables

  • JUnit Test Case

    Hi
    I am very new for JUnit I have build my java class in eclipse. Pls tell me how I can make test cases for this method:
    public void deposit(float amt)
              s_balance += amt;
         }

    I know it is void so I dont need to put some value to compare them but problem is that when I remove but I still getting error so could you tell me how write a testcase for void method. pls tell mePresumably the void method does something. So, you call the method, then check that something happened. As to how to do that, it varies dependent upon what's being tested. I leave it as an exercise for the OP to determine how to test that something happened that doesn't involve trying to find out if "wrong" equals void. Hint: you'll probably want to check that the balance was increased by the amount deposited.
    ~

  • Writing to file in JUnit test case? Not working?

    I have a singleton class called InstantLogger that internally uses a PrintWriter to write to file. It is very basic, has startLogger(String filename), log(String msg), and stopLogger(). startLogger just creates file, log write to file, and stopLogger closes file.
    When I use this class outside of the JUnit test suite it works fine.
    As soon as I use it in a JUnit test it does not write to file. It creates the file (this happens in the TestSuite), but will not write anything to it (when log is called from TestCase). I put a System.out in the log function and I see that, but still nothing writing to file. And I will say it again, it does work in non TestCase scenarios so I know it works.
    Is there something that could be preventing me from writing to file in JUnit TestCase? Could this be a Singleton Issue?
    Thanks,

    avalanche333 wrote:
    I have a singleton class called InstantLogger Ouch.
    that internally uses a PrintWriter to write to file. It is very basic, has startLogger(String filename), log(String msg), and stopLogger(). startLogger just creates file, log write to file, and stopLogger closes file.
    When I use this class outside of the JUnit test suite it works fine.Oh, brother.
    >
    As soon as I use it in a JUnit test it does not write to file. It creates the file (this happens in the TestSuite), but will not write anything to it (when log is called from TestCase). I put a System.out in the log function and I see that, but still nothing writing to file. And I will say it again, it does work in non TestCase scenarios so I know it works.
    Is there something that could be preventing me from writing to file in JUnit TestCase? Could this be a Singleton Issue?Um, no.
    Your code is wrong. You're assuming something that isn't correct. You're also making the assumption that just because it "works" in another context that it's right in all contexts. The two aren't the same, be it configuration or something else.
    Singleton? That GoF pattern has been voted off the island. Didn't you hear?
    http://code.google.com/p/google-singleton-detector/
    %

  • Junit test cases -error in creating Application Module

    I am on JDeveloper 9i with OA Extension installed build 1550. I am trying to run Business Components Test Fixtures and getting the following error in setUp method of the fixture class at the following line
    _am = Configuration.createRootApplicationModule("mycompany.oracle.apps.xxsan.invoiceholds.server.InvoiceHoldsAM", "Development");
    The exception below..
    java.lang.NoSuchMethodError: oracle.xml.parser.v2.SAXParser.setContentHandler(Lorg/xml/sax/ContentHandler;)V
    at oracle.jdeveloper.cm.DefaultConnectionStore.read(DefaultConnectionStore.java:182)
    Anybody who have used Junit successfully to test their business components. Would appreciate any feedback.
    Thank you.
    Arun

    Well I guess i figured it out myself. I use the findApplicationModule before calling the createApplicationModule. Apparently, bc4j does not like creating multiple application modules...it should just reuse the existing one instead of throwing this obscure invalid name exception.

  • 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

  • Can I test (junit) default case of switch-case statement ?

    Hi,
    I have a class which has switch-case statements and I am trying to junit test with 100% coverage. My switch-case workes based on enum values.
    say my enum values are 1, 2.
    switch(getEnumValues) {
    case 1:
    return "some value";
    case 2:
    return "some value";
    default:
    throw new UnsupportedOperationException("No such enum value supported.");
    I have test case to test the case 1 and 2 but I am not able to test default case. Can anyone please let me know how can I right a junit test case for default case.
    Edited by: TUIJAVADEV on Nov 4, 2008 4:15 PM

    yawmark wrote:
    TUIJAVADEV wrote:
    I have test case to test the case 1 and 2 but I am not able to test default case. Can anyone please let me know how can I right a junit test case for default case.If your enum values are ONE and TWO, and you have cases for both, then there is no "default case". There is nothing to test.
    ~If I'm reading the OP correctly, they're 1 and 2, not ONE and TWO. That is, not values of a Java enum.
    If this is the case, then the easiest way to test the default case is to break the swtich out into a separate, package-accessible method that takes and arg and passes that onto the switch. (There may be variations on this, depending on how your code is structured.)
    However, in a similar vein to what the others are saying, if you already know that you'll only ever have 1 and 2 by the time you get to the switch (maybe because the value comes from an argument to the enclosing method, and you've already unit tested that it appropriately throws an IllegalArgumentException when other values are passed, then there's no need to test the default.
    Finally, though if it is ints 1 and 2, rather than a true enum, why not switch to an enum?

  • JUnit - Strange Test Case running problem

    Hi Everyone,
    I am very new to J Unit testing. Here's my problem. I have a project set up in Net Beans. Inside the project, there is a folder named "tests". This folder contains the following class:
    public class Bob
        public static void main(String[] args)
            System.out.println("Hello");
    }There are other classes inside of this folder that extend TestCase and TestSuite. They are functionally working according to J Unit testing (they prompt a JUnit Test Results panel in Net Beans with Pass or Fail).
    The problem that I am having upon running/executing the class "Bob", NetBeans treats it as a JUnit test case and brings up a Pass/Fail panel. I do not want this to happen. I just want this class to print "Hello" as if it was not a Test. Do you guys have any idea what the problem is? My "Bob" class has nothing imported.
    Also, I have another question. Is there a way that I can take INPUT from a user when running a Test Case (such as using the Scanner class)? My test cases seem to skip over the Scanner.nextLine() code for some reason.
    Thanks in advance.

    Hi BigDaddy,
    Thanks for the suggestion, however I am unsure of what you mean by injecting the scanner. Here is an example of what I would like to do:
    public class BenchmarkTestSuite extends TestSuite
        public static void main(String[] args)
            try
                Scanner scan = new Scanner(System.in);
                System.out.print("Enter the number of iterations for read: ");
                readIterations = scan.nextInt();
                .... etc
            catch(Exception ex)
                ex.printStackTrace();
        .... etc
    }Here, the prompted question for the user gets ignored for some odd reason. I would like for the tests to not start until the question has been answered by the user. NetBeans is strange. I commented all of the test methods to see if the question gets printed to the console, and it does not.
    Thanks.

  • Error in running juit test case for struts2 action class

    Hi,
    I am getting error when i am running my junit test case for struts2 action class. Here is the code.
    public class RoleMasterNewActionTest extends StrutsTestCase {
         public void setUp() throws Exception {
            super.setUp();
            ObjectFactory.setObjectFactory( new ObjectFactory() );
         public void testDoSomeThing()throws Exception {
              RoleMasterNewAction action = new RoleMasterNewAction();
              assertTrue(action.doSomeThing());
    }I am getting error at testDoSomeThing(). the error is
    2010-04-30 15:07:12,263 INFO [com.opensymphony.xwork2.config.providers.XmlConfigurationProvider] - Parsing configuration file [struts-default.xml]
    2010-04-30 15:07:12,325 INFO [com.opensymphony.xwork2.config.providers.XmlConfigurationProvider] - Parsing configuration file [struts-plugin.xml]
    2010-04-30 15:07:12,388 INFO [com.opensymphony.xwork2.config.providers.XmlConfigurationProvider] - Parsing configuration file [struts.xml]
    2010-04-30 15:07:12,388 WARN [org.apache.struts2.config.Settings] - Settings: Could not parse struts.locale setting, substituting default VM locale
    2010-04-30 15:07:12,388 INFO [org.apache.struts2.config.BeanSelectionProvider] - Loading global messages from ipl.comm.resources.comman-Lookup
    2010-04-30 15:07:12,388 INFO [org.apache.struts2.config.BeanSelectionProvider] - Loading global messages from ipl.comm.resources.comman-label
    2010-04-30 15:07:12,388 INFO [org.apache.struts2.config.BeanSelectionProvider] - Loading global messages from ipl.comm.resources.comman-headings
    2010-04-30 15:07:12,388 INFO [org.apache.struts2.config.BeanSelectionProvider] - Loading global messages from ipl.comm.resources.comman-messages
    2010-04-30 15:07:12,388 INFO [org.apache.struts2.config.BeanSelectionProvider] - Loading global messages from ipl.comm.resources.comman-setup
    2010-04-30 15:07:12,388 INFO [org.apache.struts2.config.BeanSelectionProvider] - Loading global messages from ipl.comm.resources.common-errors
    2010-04-30 15:07:12,388 INFO [org.apache.struts2.config.BeanSelectionProvider] - Loading global messages from ipl.admin.resources.admin-label
    2010-04-30 15:07:12,388 INFO [org.apache.struts2.config.BeanSelectionProvider] - Loading global messages from ipl.admin.resources.admin-lookup
    2010-04-30 15:07:12,388 INFO [org.apache.struts2.config.BeanSelectionProvider] - Loading global messages from ipl.admin.resources.admin-headings
    2010-04-30 15:07:12,388 INFO [org.apache.struts2.config.BeanSelectionProvider] - Loading global messages from ipl.admin.resources.admin-jndinames
    2010-04-30 15:07:12,388 INFO [org.apache.struts2.config.BeanSelectionProvider] - Loading global messages from ipl.birthCertificate.resources.birth-jndinames
    2010-04-30 15:07:12,388 INFO [org.apache.struts2.config.BeanSelectionProvider] - Loading global messages from ipl.birthCertificate.resources.birth-labels
    2010-04-30 15:07:12,388 INFO [org.apache.struts2.config.BeanSelectionProvider] - Loading global messages from ipl.birthCertificate.resources.birth-headings
    2010-04-30 15:07:12,388 INFO [org.apache.struts2.config.BeanSelectionProvider] - Loading global messages from ipl.admin.resources.admin-alert
    2010-04-30 15:07:12,388 INFO [org.apache.struts2.config.BeanSelectionProvider] - Loading global messages from ipl.comm.resources.form
    2010-04-30 15:07:12,419 INFO [org.apache.struts2.spring.StrutsSpringObjectFactory] - Initializing Struts-Spring integration...
    2010-04-30 15:07:12,419 FATAL [org.apache.struts2.spring.StrutsSpringObjectFactory] - ********** FATAL ERROR STARTING UP STRUTS-SPRING INTEGRATION **********
    Looks like the Spring listener was not configured for your web app!
    Nothing will work until WebApplicationContextUtils returns a valid ApplicationContext.
    You might need to add the following to web.xml:
        <listener>
            <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
        </listener>but already i have the listener configuration in my web.xml.
    Thanks in advance..

    I guess it wasn't reading the right web.xml file.
    You may prove it by deleting your web.xml file (don't forget to make a backup), and then run the test again to see whether the error is the same.

  • Error in juit test case for struts2 action class using StrutsSpringTestCase

    Hi
    I am getting some error when i am running my Struts2 Action class junit test case using StrutsSpringTestCase class (which is in struts2 junit plugin 2.1.8 version)
    Here is the code....
    package ipl.admin.action.test;
    import java.sql.Timestamp;
    import java.util.Date;
    import org.apache.struts2.StrutsSpringTestCase;
    import ipl.admin.action.RoleMasterNewAction;
    import ipl.admin.beans.RoleMasterNewBeanRemote;
    import com.opensymphony.xwork2.ObjectFactory;
    public class RoleMasterNewActionTest extends StrutsSpringTestCase {
         //XmlBeanFactory bf = new XmlBeanFactory(new ClassPathResource("applicationContext.xml", getClass()));
         RoleMasterNewAction action = new RoleMasterNewAction();
         RoleMasterNewBeanRemote roleMasterBeanNewRemote;
         public RoleMasterNewBeanRemote getRoleMasterBeanNewRemote() {
              return roleMasterBeanNewRemote;
         public void setRoleMasterBeanNewRemote(
                   RoleMasterNewBeanRemote roleMasterBeanNewRemote) {
              this.roleMasterBeanNewRemote = roleMasterBeanNewRemote;
         public void setUp() throws Exception {
              super.setUp();
              ObjectFactory.setObjectFactory(new ObjectFactory());
         public void testDoSomeThing() throws Exception {
              //System.out.println(bf.getBean("loginIntercepter"));
              assertTrue(action.doSomeThing());
    }I am getting error for this code. Below is the error details.
    2010-05-03 17:28:14,671 INFO [com.opensymphony.xwork2.config.providers.XmlConfigurationProvider] - Parsing configuration file [struts-default.xml]
    2010-05-03 17:28:14,859 INFO [com.opensymphony.xwork2.config.providers.XmlConfigurationProvider] - Parsing configuration file [struts-plugin.xml]
    2010-05-03 17:28:14,999 INFO [com.opensymphony.xwork2.config.providers.XmlConfigurationProvider] - Parsing configuration file [struts.xml]
    2010-05-03 17:28:15,015 WARN [org.apache.struts2.config.Settings] - Settings: Could not parse struts.locale setting, substituting default VM locale
    2010-05-03 17:28:15,015 INFO [org.apache.struts2.config.BeanSelectionProvider] - Loading global messages from ipl.comm.resources.comman-Lookup
    2010-05-03 17:28:15,015 INFO [org.apache.struts2.config.BeanSelectionProvider] - Loading global messages from ipl.comm.resources.comman-label
    2010-05-03 17:28:15,015 INFO [org.apache.struts2.config.BeanSelectionProvider] - Loading global messages from ipl.comm.resources.comman-headings
    2010-05-03 17:28:15,015 INFO [org.apache.struts2.config.BeanSelectionProvider] - Loading global messages from ipl.comm.resources.comman-messages
    2010-05-03 17:28:15,046 INFO [org.apache.struts2.config.BeanSelectionProvider] - Loading global messages from ipl.comm.resources.comman-setup
    2010-05-03 17:28:15,046 INFO [org.apache.struts2.config.BeanSelectionProvider] - Loading global messages from ipl.comm.resources.common-errors
    2010-05-03 17:28:15,046 INFO [org.apache.struts2.config.BeanSelectionProvider] - Loading global messages from ipl.admin.resources.admin-label
    2010-05-03 17:28:15,046 INFO [org.apache.struts2.config.BeanSelectionProvider] - Loading global messages from ipl.admin.resources.admin-lookup
    2010-05-03 17:28:15,046 INFO [org.apache.struts2.config.BeanSelectionProvider] - Loading global messages from ipl.admin.resources.admin-headings
    2010-05-03 17:28:15,046 INFO [org.apache.struts2.config.BeanSelectionProvider] - Loading global messages from ipl.admin.resources.admin-jndinames
    2010-05-03 17:28:15,046 INFO [org.apache.struts2.config.BeanSelectionProvider] - Loading global messages from ipl.birthCertificate.resources.birth-jndinames
    2010-05-03 17:28:15,046 INFO [org.apache.struts2.config.BeanSelectionProvider] - Loading global messages from ipl.birthCertificate.resources.birth-labels
    2010-05-03 17:28:15,046 INFO [org.apache.struts2.config.BeanSelectionProvider] - Loading global messages from ipl.birthCertificate.resources.birth-headings
    2010-05-03 17:28:15,046 INFO [org.apache.struts2.config.BeanSelectionProvider] - Loading global messages from ipl.admin.resources.admin-alert
    2010-05-03 17:28:15,046 INFO [org.apache.struts2.config.BeanSelectionProvider] - Loading global messages from ipl.comm.resources.form
    2010-05-03 17:28:15,140 INFO [org.apache.struts2.spring.StrutsSpringObjectFactory] - Initializing Struts-Spring integration...
    2010-05-03 17:28:15,171 FATAL [org.apache.struts2.spring.StrutsSpringObjectFactory] - ********** FATAL ERROR STARTING UP STRUTS-SPRING INTEGRATION **********
    Looks like the Spring listener was not configured for your web app!
    Nothing will work until WebApplicationContextUtils returns a valid ApplicationContext.
    You might need to add the following to web.xml:
        <listener>
            <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
        </listener> But already i have the listener configurations in my web.xml .
    Thanks in advance...

    I guess it wasn't reading the right web.xml file.
    You may prove it by deleting your web.xml file (don't forget to make a backup), and then run the test again to see whether the error is the same.

  • Re: Creating a seperate project for Junit Tests.

    Hello,
    I was wondering if its possible to have all the test cases form different projects in a single project(which would only contain all Junit test cases) and then fire these tests from that single project.
    So the idea is to have multiple projects but all the Junit tests would be compiled in a single project. Is there any way i can accomplish this.
    Thanks

    qwerty.123 wrote:
    Yes that is correct. But in order to do this i need my test class to be in the same package as my class which is tested. That's why one should use the same package structure in your test source directory as you do in your regular source directory.
    For example:
    myproject/src/main/java/some/package/MyClass.java
    myproject/src/test/java/some/package/MyClassTest.java
    Where myproject/src/main/java and myproject/src/test/java/ are both source folders in your project's build path.
    Is there any way i can run a test for a class which is in a different project/package altogether and my test class lying in a seperate Project/package.Sure; you just won't have access to "package-private" classes and members.
    ~

Maybe you are looking for