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 7719155
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T03:20:39+00:00 2026-06-01T03:20:39+00:00

I am creating Junit test cases in Spring. private static BeanFactory servicefactory = null;

  • 0

I am creating Junit test cases in Spring.

private static BeanFactory servicefactory = null;
private static BookingProcessService bookingProcessService;
@BeforeClass
public static void setUpBeforeClass() throws Exception{
    try{
        String[] configFiles = {"applicationcontext-Service.xml","applicationcontext-Hibernate.xml","applicationContext-dao.xml"};
        ClassPathXmlApplicationContext appContext = new ClassPathXmlApplicationContext(configFiles);
        servicefactory = (BeanFactory) appContext;
        bookingProcessService = (BookingProcessService) servicefactory.getBean("bookingProcessService");            
    }catch (Exception e){
        e.printStackTrace();
    }
}

Here BookingProcessService is an interface and its implementation class is BookingProcessServiceImpl.java.
In spring configuration files, there is no bean id defined for that.
Is there any way I can use the ‘bookingProcessService’ for invoking the actual method definition written in BookingProcessImp.java in my test methods?

  • 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-06-01T03:20:40+00:00Added an answer on June 1, 2026 at 3:20 am

    If u are configuring this test I recommend to use Annotations, will be more clear.

    Usually in your “applicationcontext-Service.xml” must have the bean defined with the Implementation, and is the classes where you would use the Interface of this class.

    With that you would not coupling code with implementation.

    In this example, simple must do the next:

     @Autowired
     private BookingProcessService bookingProcessService;
    

    The annotation @Autowired from Spring will do the IOC from your xml configuration “applicationcontext-Service.xml”.

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

Sidebar

Related Questions

I am creating a custom test runner for JUnit test cases using JUnitCore's run(junit.framework.Test
I'm often creating custom assertion methods for my JUnit tests. eg: public void assertArrays(String[]
I'm currently creating some test cases with Selenium and I've come across a problem.
Creating Traversals for Binary Search Tree with Recursion. void inOrder(void (*inOrderPtr)(T&)) { if(this->left !=
I'm creating a TemporaryFolder using the @Rule annotation in JUnit 4.7. I've tried to
I am creating a web application using zkoss 5.0.4, Spring 3.0.3, Hibernate 3, and
when I run my junit test I can get right result and the data
i have a service method addAgent defined as @Override @Transactional(readOnly=false) public void addAgent(Agent agent,
I tried creating a test project with maven and the unit testing worked fine.
I am trying to debug a junit test in eclipse but my breakpoints are

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.