How to mock ResultSetMetaData?


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4

Thread: How to mock ResultSetMetaData?

Hybrid View

  1. #1
    Join Date
    Nov 2007
    Posts
    2

    Post How to mock ResultSetMetaData?

    Hi all,
    I need to mock ResultSetMetaData for testing my JUnit test cases. We need to mock the methods ResultSetMetaData.getColumnCount() and ResultSetMetaData.getColumnName(i). Please help me if any of you have come across such requirement.

    Thanks and regards,
    Abhisek.

  2. #2
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,666
    Welcome to DevX

    By "mock" I assume you mean run in a test environment, correct?

    Don't you have a test web server set up in your shop? This, typically, is how we test pages prior to moving them to our production web server.
    I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
    Please use [Code]your code goes in here[/Code] tags when posting code.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    Modifications Required For VB6 Apps To Work On Vista

  3. #3
    Join Date
    Nov 2007
    Posts
    2
    Thanx for the quick reply. Ya. It is a test environment. I wanna test the method using JUnit. Please correct me if I am wrong, but as far as i know, we do not need a server (web/app) to be running while executing the JUnit test cases. I would like to quote here that the method to be tested is a factory method, not a web page. e.g.
    Code:
    class Factory extends SuperClass{
    runTest(ResultSet) {
    callOtherMethod(ResultSet);
    }
    }
    
    class SuperClass {
    callOtherMethod(ResultSet) {
    ResultSetMetaData rsMeta = ResultSet.getMetaData();
    rsMeta.getColumnCount();
    rsMeta.getColumnName(i);
    }
    }
    I have already mocked the ResultSet successfully. But how to mock ResultSetMetaData is the primary issue now. I hope I am more clear now.

  4. #4
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,666
    See Post #3 in this thread. One of those methods may be useful for you.
    I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
    Please use [Code]your code goes in here[/Code] tags when posting code.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    Modifications Required For VB6 Apps To Work On Vista

Similar Threads

  1. Reg. Mock Exam designers for JavaBeat
    By kks_krishna in forum Careers
    Replies: 0
    Last Post: 10-05-2007, 10:09 PM
  2. A mock Auction tool in Access 97
    By cervantes008 in forum Database
    Replies: 0
    Last Post: 07-21-2006, 11:49 AM
  3. Replies: 6
    Last Post: 09-15-2005, 02:49 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center