/**
   * This test can run multiple times, but due to static keyed lookup of the locators, 2nd and
   * subsequent calls will actuall get back same locator instance. This is not an issue really,
   * since the contained beanfactories will still be loaded and released.
   */
  @Test
  public void testGetInstance() {
    // Try with and without 'classpath*:' prefix, and with 'classpath:' prefix.
    BeanFactoryLocator facLoc =
        SingletonBeanFactoryLocator.getInstance(
            ClassUtils.addResourcePathToPackagePath(getClass(), "ref1.xml"));
    getInstanceTest1(facLoc);

    facLoc =
        SingletonBeanFactoryLocator.getInstance(
            "classpath*:/" + ClassUtils.addResourcePathToPackagePath(getClass(), "ref1.xml"));
    getInstanceTest2(facLoc);

    // This will actually get another locator instance, as the key is the resource name.
    facLoc =
        SingletonBeanFactoryLocator.getInstance(
            "classpath:" + ClassUtils.addResourcePathToPackagePath(getClass(), "ref1.xml"));
    getInstanceTest3(facLoc);
  }
 /** Worker method so subclass can use it too. */
 protected void basicFunctionalityTest(SingletonBeanFactoryLocator facLoc) {
   BeanFactoryReference bfr = facLoc.useBeanFactory("a.qualified.name.of.some.sort");
   BeanFactory fac = bfr.getFactory();
   BeanFactoryReference bfr2 = facLoc.useBeanFactory("another.qualified.name");
   fac = bfr2.getFactory();
   // verify that the same instance is returned
   TestBean tb = (TestBean) fac.getBean("beans1.bean1");
   assertTrue(tb.getName().equals("beans1.bean1"));
   tb.setName("was beans1.bean1");
   BeanFactoryReference bfr3 = facLoc.useBeanFactory("another.qualified.name");
   fac = bfr3.getFactory();
   tb = (TestBean) fac.getBean("beans1.bean1");
   assertTrue(tb.getName().equals("was beans1.bean1"));
   BeanFactoryReference bfr4 = facLoc.useBeanFactory("a.qualified.name.which.is.an.alias");
   fac = bfr4.getFactory();
   tb = (TestBean) fac.getBean("beans1.bean1");
   assertTrue(tb.getName().equals("was beans1.bean1"));
   // Now verify that we can call release in any order.
   // Unfortunately this doesn't validate complete release after the last one.
   bfr2.release();
   bfr3.release();
   bfr.release();
   bfr4.release();
 }