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

Similar Messages

  • 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

  • Want to run multiple Test Cases by ant ?

    Hi all,
    I have a class called Book.java and two test cases called BookTest1.java and BookTest2.java . I want to test both this test cases by ant. I have to set this ant task unix cron job so, that this test is done automatically each day.
    I have wrote the build file with batchtest option but it is building the application suucessfully without checking the Test Cases individually.
    I am successfully the same task with JUnit Test suite.
    Thanks and Regards
    Taton Banerjee
    Book.java
    package src;
    public class Book {
        private String title;
        private double price;
        public Book(String title,double price) {
            this.title = title;
            this.price = price;
    public static void main(String args[])
         System.out.println("Inside Book class");
        public boolean equals(Object object) {
            if (object instanceof Book) {
                Book book = (Book) object;
                return getTitle().equals(book.getTitle())
                        && getPrice() == book.getPrice();
            return false;
        public double getPrice() {
            return price;
        public void setPrice(double price) {
            this.price = price;
        public String getTitle() {
            return title;
        public void setTitle(String title) {
            this.title = title;
    BookTest1.java
    package src;
    import junit.framework.Test;
    import junit.framework.TestCase;
    import junit.framework.TestSuite;
    //import de.laliluna.tutorial.junitexample.Book;
    * @author http://www.laliluna.de
    public class BookTest1 extends TestCase {
        private Book book1;
        private Book book2;
        @SuppressWarnings("unused")
         private Book book3;
         * setUp() method that initializes common objects
        protected void setUp() throws Exception {
            super.setUp();
            book1 = new Book("ES", 12.99);
            book2 = new Book("The Gate", 11.99);
            book3 = new Book("ES", 12.99);
         * tearDown() method that cleanup the common objects
        protected void tearDown() throws Exception {
            super.tearDown();
            book1 = null;
            book2 = null;
            book3 = null;
         * Constructor for BookTest1.
         * @param name
        public BookTest1(String name) {
            super(name);
         * testEquals method to test the equals(..) method
         * of the class Book
        public void testEquals(){
            assertFalse(book2.equals(book1));
            assertTrue(book1.equals(book3));
        public static Test suite(){
            TestSuite suite = new TestSuite();
            suite.addTest(new BookTest1("testEquals"));
            return suite;
    BookTest2.java
    package src;
    import junit.framework.Test;
    import junit.framework.TestCase;
    import junit.framework.TestSuite;
    //import de.laliluna.tutorial.junitexample.Book;
    public class BookTest2 extends TestCase {
        private Book book3;
        private Book book4;
        private Book book5;
         * setUp() method that initializes common objects
        protected void setUp() throws Exception {
            super.setUp();
            book3 = new Book("ES", 12.99);
            book4 = new Book("The Gate", 11.99);
            book5 = new Book("ES", 12.99);
         * tearDown() method that cleanup the common objects
        protected void tearDown() throws Exception {
            super.tearDown();
            book3 = null;
            book4 = null;
            book5 = null;
         * Constructor for BookTest.
         * @param name
        public BookTest2(String name) {
            super(name);
         * testEquals method to test the equals(..) method
         * of the class Book
        public void testEquals(){
            assertFalse(book4.equals(book3));
            assertTrue(book3.equals(book5));
        public static Test suite(){
            TestSuite suite = new TestSuite();
            suite.addTest(new BookTest2("testEquals"));
            return suite;
    Test Suite(Not neccessary when running with ant)
    package src;
    import junit.framework.Test;
    import junit.framework.TestSuite;
    public class AllJUnitTests {
         /*public AllJUnitTests(String name)
         super(name);
         public static Test suite() {
              TestSuite suite = new TestSuite("Test for src");
              //$JUnit-BEGIN$
              suite.addTest(BookTest2.suite());
              suite.addTest(BookTest1.suite());
              //$JUnit-END$
              return suite;
         * Runs the test suite using the textual runner.
        public static void main(String[] args) {
            junit.textui.TestRunner.run(suite());
    build.xml
    <?xml version="1.0"?>
         <project default="deploy">
         <!-- set global properties for this build -->
              <property name="src" value="src" />
              <property name="build" value="build" />
              <property name="dist" value="dist" />
              <target name="JUNIT">
                   <!-- Create the time stamp -->
                   <tstamp/>
                   <!-- Create the build directory structure used by compile -->
                   <mkdir dir="${build}/src" />
              </target>
              <target name="compile" depends="JUNIT">
                   <mkdir dir="${dist}/lib" />
                   <!-- Compile the java code from ${src} into ${build} -->
                   <javac srcdir="${src}" destdir="${build}/src" >
                   <classpath>
                        <!--<pathelement location="dist/lib/HellowithAnt.jar" />-->
                        <pathelement path="E:/junit4.4/junit-4.4.jar" />
                        <!--<pathelement path="/lib/commons-net-1.4.1.jar" />
                        <pathelement path="/lib/jakarta-oro-2.0.8.jar" />-->
                   <!--<pathelement path="E:/apache-ant-1.7/lib" />-->
                   </classpath>
                   </javac>
                   <junit printsummary="yes" fork="yes"
                           errorProperty="batchtest.failed"
                           failureProperty="batchtest.failed"
                           haltonfailure="yes">
                           <formatter type="xml"/>
                           <classpath path=".">
                             <pathelement path="E:/junit4.4/junit-4.4.jar" />
                             <pathelement path="/build/src/BookTest1.class"/>
                             <pathelement path="/build/src/BookTest2.class"/>
                                <pathelement path="/build/src/AllJUnitTests.class"/>                                   
                             </classpath>     
                             <!--<test todir="${build}/src"/>-->
                             <batchtest todir="${build}/src">
                             <!--<fileset dir="${build}/src" includes="src.AllJUnitTests.class"/>-->
                             <fileset dir="${build}/src">     
                        <filename name ="src.BookTest1.class"/>
                             <filename name ="src.BookTest2.class"/>
                             <filename name ="src.AllJUnitTests.class"/>     
                             </fileset>     
                             </batchtest>
                        <!--<batchtest todir="build.src">
                             <fileset dir="build.src">
                             <filename name ="src.BookTest1.class"/>
                             <filename name ="src.BookTest2.class"/>
                             </fileset>     
                        </batchtest>-->
                             <!--<test todir="${build}/src" name="src.BookTest"/>-->
                        </junit>
                             <fail message="Tests failed!" if="batchtest.failed"/>                              
                            <junitreport todir="${build}/src">
                                <!--<batchtest todir="${build}/src">
                            <fileset dir="${build}/src">
                             <include name="*.xml"/>
                             </fileset>
                             </batchtest>-->
                        <report format="frames" todir="${build}/lib"/>
                             </junitreport>
                    </target>
                    <target name="dist" depends="compile">
                     <!-- Create the ${dist}/lib directory -->
                     <!-- Put everything in ${build} into the HelloTest.jar file -->
                     <jar jarfile="${dist}/lib/HellowithAnt.jar" basedir="${build}/src" >
                          <!--<fileset dir="${dist}/lib">
                                                   <filename name="BookTest1.class"/>
                                                   <filename name="BookTest2.class"/>
                                               <filename name="Book.class"/>
                                               <filename name="dist.lib.HelloTestwith.jar"/>
                          </fileset>-->
                          <manifest>
                           <attribute name="Main-Class" value="src.Book"/>
                           </manifest>
                          </jar>
                    </target>
                    <target name="runtests" depends="dist" >
                     <java jar="${dist}/lib/HellowithAnt.jar"
                          fork="yes" 
                          classpath=".;D:/Java/jdk1.5.0_01/bin;E:/apache-ant-1.7.0/lib/junit-4.4.jar;C:/Documents and Settings/kaushikb/workspace/HelloTestwithAnt/dist/lib/HellowithAnt.jar;C:/Documents and Settings/kaushikb/workspace/HelloTestwithAnt/src/AllJUnitTests;C:/Documents and Settings/kaushikb/workspace/HelloTestwithAnt/src/BookTest1;C:/Documents and Settings/kaushikb/workspace/HelloTestwithAnt/src/BookTest2">
                        <!--<fileset todir="${build}/src">
                             <filename name="src.BookTest1.class"/>
                             <filename name="src.BookTest2.class"/>
                             </fileset>-->
                        <arg value="src.AllJUnitTests"/>
                     </java>
                    </target>
                     <target name="deploy" depends="runtests">
                   </target>
               </project>/*---------------------------------------------------------------------------
    Command prompt output :
    c:/Documents and Settings/kaushikb/workspace/HelloTestwithAnt> ant
    Buildfile: build.xml
    JUNIT:
    compile:
    [javac] Compiling 4 source files to C:\Documents and Settings\kaushikb\wor
    pace\HelloTestwithAnt\build\src
    [junitreport] Processing C:\Documents and Settings\kaushikb\workspace\HelloTes
    ithAnt\build\src\TESTS-TestSuites.xml to C:\DOCUME~1\kaushikb\LOCALS~1\Temp\nu
    1759201173
    [junitreport] Loading stylesheet jar:file:/E:/apache-ant-1.7.0/lib/ant-junit.j
    !/org/apache/tools/ant/taskdefs/optional/junit/xsl/junit-frames.xsl
    [junitreport] Transform time: 1153ms
    [junitreport] Deleting: C:\DOCUME~1\kaushikb\LOCALS~1\Temp\null1759201173
    dist:
    [jar] Building jar: C:\Documents and Settings\kaushikb\workspace\HelloTe
    withAnt\dist\lib\HellowithAnt.jar
    runtests:
    [java] Inside Book class
    deploy:
    BUILD SUCCESSFUL
    Total time: 5 seconds
    ---------------------------------------------------------------------------

    Haven't looked too carefully because you weren't very specific, but here's how I would do it:
    public class Book { }
    public class TestBook1 extends TestCase {}
    public class TestBook2 extends TestCase {} //don't define any suite() method
    public class TestBookSuite extends TestCase {
       public static Test suite() {
          TestSuite suite = new TestSuite();
          suite.add(TestBook1.class);
          suite.add(TestBook2.class);
          return suite;
    //================ant:===========
    <target name="runtests" depends="dist" >
       <java classpath="." classname="junit.textui.TestRunner">
         <arg value="path.to.TestBookSuite"/>
       </java>
    </target>Of course filling in classpath information and the like where it's appropriate for your situation.

  • 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

  • Error encountered while running a test case using MTM

    Hello,
    Has anyone encountered this error while running a test case using MTM 2013? 
    When I click on OK, the message is again shown until that time wherein the popup error is no longer shown.
    When I try to continue to the next pages wherein a modal is being open and I need to enter some data on a text field, the IE would stop working and seems to crash.
    Thanks!

    Hi Kiyaruh,
    Base on the error message, the error is threw by internet explorer.
    Does it have the same issue when access that web site/page in IE directly or it just occurs when run tests through MTM?
    What’s the version of your browser? You may try it with other browser and check whether it has same issue.
    Regards
    Starain
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • 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

  • 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

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

  • Macro command to delete an test run or a test case from QC

    I want to know the VB script command to delete an test run or a test case from QC. i can now able to access all the parameters of an test run, like status, execution data, etc. but stuck up while trying to delete it. please someone reply with the exact command

    My J2SE version was wrongly set to 1.3 instead of 1.5.
    Now it works.

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

  • How to compile Java files using Ant in Eclipse

    Hi All ,
    I would like to compile all Java files using Ant in Eclipse.Since am very new to Ant and Eclipse can someone help me to create a build.xml file and let me know how to compile all the java files.
    For ex , I have placed my java files inside the path C:\HEC\Terab.Initially the Terab folder holds 7 jar files which i had decompiled using JD compiler and placed the unzipped 7 folders (which contains the java files ).Now i have imported the HEC project into Eclipse using New ->Project ->Java Project.after importig it throwed me an error saying missing jar files.again i copied the jar files and placed inside Terab folder with other 7 folder.
    Now How i can compile the java files and convert in to class files.Then after compiling the files i will again need to jar all the 7 folder.
    Please tell me the steps i need to follow.How to write an build.xml file ? where i should keep it ? only one build.xml file is enough or should i write 7 build.xml file for each folder ? Please help me out...
    Thanks & Regards
    Kar1983

    put it another way, what I am trying to do is to compile David Brackeen's ch 18 code from his book. The java sourse files can be downloaded here:
    http://www.brackeen.com/javagamebook/
    my question is that how would I complie all of these file so that I can get the program in ch18src\src\com\brackeen\javagamebook\test\ to run?

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

  • 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/
    %

  • "Error running javac.exe compiler" when using ant to compile Eclipse plugin

    Hi
    I encounter an error "Error running C:\jdk1.5.0_06\bin\javac.exe compiler" when building my project using ant1.7.
    My project has 10 eclipse plugins, and each plugin is compiled by invoking following ant target
    <!-- ===================================================================
    Compile specified plugin
         target parameters:
              param.plugin.dir: the plugin directory
              param.plugin.targetJarFile: the name of jar file for the given plugin
              param.plugin.src.dir: the folder name of source codes. Note: it is relative path name
              param.fork: indicate if another process is forked to run javac
    =================================================================== -->
    <target name="compilePlugin">
         <!-- Prepare compile environment -->
         <!-- Delete obsolete build folder -->
         <delete dir="${param.plugin.dir}/${build.dir}" quiet="true"/>
         <!-- Delete obsolete jar file -->
         <delete file="${param.plugin.dir}/${param.plugin.targetJarFile}" quiet="true"/>
         <mkdir dir="${param.plugin.dir}/${build.dir}"/>
         <!-- Compile source codes -->
         <javac      srcdir="${param.plugin.dir}/${param.plugin.src.dir}"
                   destdir="${param.plugin.dir}/${build.dir}"
                   failonerror="${javacFailOnError}"
                   verbose="${javacVerbose}"
                   debug="${javacDebugInfo}"
                   deprecation="${javacDeprecation}"
              optimize="${javacOptimize}"
                   source="${javacSource}"
                   target="${javacTarget}"     
                   fork="${param.fork}" memoryInitialSize="256m" memoryMaximumSize="512m">
              <classpath refid="compile.classpath" />
         </javac>
         <!-- Create plugin jar file -->
         <copy todir="${param.plugin.dir}/${build.dir}" failonerror="true">
              <fileset dir="${param.plugin.dir}/${param.plugin.src.dir}" excludes="**/*.java, **/package.htm*" />
         </copy>
         <jar jarfile="${param.plugin.dir}/${param.plugin.targetJarFile}" basedir="${param.plugin.dir}/${build.dir}"/>
         <delete dir="${param.plugin.dir}/${build.dir}" quiet="true"/>
    </target>
    Since each of first 9 plugins contains less than 500 java source files, we always set "param.fork" to false when invoking this ant target.
    For the 10th plugin, it has about 1000 source files. If we set "param.fork" to false, we will get the error "Error running javac.exe compiler". So we have to set "param.fork" to true when compiling it. This week, this plugin contains about 1250 files and we get the same error again when compiling it. I tried to increase the "memoryMaximumSize" to "768", but still couldn't get through it.
    BTW, There are about 150 jar files in our classpath for compiling plugins. Do many jar files cause this problem?
    Any help is highly appreciated.
    Many thanks
    Oceanman

    I encountered a very similar error and I was able to resolve it by removing the following parameters from the javac task:
    fork="${param.fork}"
    memoryInitialSize="256m"
    memoryMaximumSize="512m"My values were not the same as yours, before I removed them, the values were set to:
    fork="true"
    memoryInitialSize="256m"
    memoryMaximumSize="256m" Not sure why this fixed my problem but it did. I was using Ant 1.7 and Java 1.6_07 hope this helps.

Maybe you are looking for

  • Windows 7 Ultimate 64bit upgrade to Windows 8 Pro RTM 64bit hangs

    I am trying to upgrade Windows 7 Ultimate 64bit on a Dell Alienware Aurora R3 desktop PC via DVD to Windows 8 Pro 64bit (RTM) and it freezes on the Windows Splash Screen after the installation and then after the restart. It looks like it has put the

  • Problem with Reinstallation of Xcelsius Present application

    Hi, I purchased Xcelsius Present application online in March 2009.  As my system is going through an upgradation process, would like to know possibility of re-installation of the application in my new  desktop. Would like to get the expertise to rein

  • How to send the output of a script to a txt or rpt file using T-sql?

    Hi! I have some code which we use to record info about a database when we decommission it. I normally click Query > Results to File and then run it to produce a file.  I need to do this via t-sql so I can automate it. Any idea what code I need to mak

  • After upgrading to 5, I can no longer sync my phone!

    I somehow got my apps to transfer, but the only way my music shows up is if I'm picking it up on cloud.  When I leave my WIFI, I lose all of my music.  When I sync, it says it can't be synced because I do not have the privilege to make changes.  Any

  • HCM = FI: Posting an IDOC via Workflow

    Hello, I hope I'm right here in this part of the forum. In addition I hope my explanations will be good enough to understand. Every month the HCM-System send IDOCs (payment of salary) to the FI-System. Everything works well (in partner profile (WE20)