Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7004035
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T21:08:50+00:00 2026-05-27T21:08:50+00:00

i am using datasource in weblogic server and, using the datasource in Hibernate. With

  • 0

i am using datasource in weblogic server and, using the datasource in Hibernate.
With HibernateUtil class am getting the SessionFactory, now i want write test cases for my DAO layer by using JUnit.

  1. How to get the SessionFactory in my Test class.
  2. I am able to get the datasource by jndi lookup in setUp method in my Test Class

is there any better way of writing test classes in this environment?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T21:08:51+00:00Added an answer on May 27, 2026 at 9:08 pm

    You can get the datasource JNDI, using javax.naming.InitialContext. But I think wouldn’t be a good idea make the test dependent on container (weblogic).

    I had only 2 ideas:

    • You could use Mock, getting a fake conection to DB.
    • Or you could use a diferent hibernate configuration file for tests. This way, you can specify the connection directly, without JNDI.

    Loading this test-file-configuration can be done using reflection or a mock.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The Weblogic servers we are using have been configured to allow JNDI datasource names
I am using weblogic JDBC datasource and my DB is Oracle 10g, below is
I'm programming a web application using weblogic and oracle. the datasource is configured through
I want to write a generic helper method: def using(closeable: [B has close() method],
We're using Spring 2.5.4/Hibernate 3.2/Websphere Application Server 6.1.0.17. We've deployed the application on an
I can't create a datasource for MySQL and WebLogic server 10.3 due to this
I am using Weblogic web server. Please let me know, how can i create
I am using JPA with hibernate and trying to connect to the a datasource
In my J2ee web application I am using a datasource accessed stored in the
I am trying to do efficient paging with a gridview without using a datasource

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.