Exemplo n.º 1
0
  @Test
  public void test() {
    final TestSvc test = (TestSvc) context.getBean("testSvc");

    // *AssignCache assignments are not very dynamic by their very nature.
    // Take care to invalidate the caches before each of the *AssignCache tests
    test.invalidateL2AssignIndia(System.currentTimeMillis());

    // Set the first cached datum
    final String orig = test.getL2AssignGolf(999L, RandomStringUtils.randomAlphabetic(4) + "-");

    // Make sure the value is definitely in there
    for (int ix = 0; ix < 3; ix++) {
      assertEquals(
          orig,
          test.getL2AssignGolf(1000L + ix, RandomStringUtils.randomAlphanumeric(4 + ix) + "-"));
    }

    // Force the update to happen.
    final String renew =
        test.getL2AssignHotel(
            System.currentTimeMillis(), RandomStringUtils.randomAlphanumeric(8) + "-");
    assertFalse(orig.equals(renew));

    // Make sure the NEW value is definitely in there
    for (int ix = 0; ix < 3; ix++) {
      assertEquals(
          renew,
          test.getL2AssignGolf(1000L + ix, RandomStringUtils.randomAlphanumeric(8 + ix) + "-"));
    }
  }
Exemplo n.º 2
0
 public static ApplicationContext getApplicationContext(String selector, String factoryKey) {
   if (selector == null) selector = "configurations/default-spring-context.xml";
   if (factoryKey == null) factoryKey = "spring-context.xml";
   BeanFactoryReference reference =
       ContextSingletonBeanFactoryLocator.getInstance(
               System.getProperty("spring.configuration", selector))
           .useBeanFactory(factoryKey);
   BeanFactory beanFactory = reference.getFactory();
   return (ApplicationContext) beanFactory;
 }
Exemplo n.º 3
0
 public static Object getBean(String selector, String factoryKey, String name, Class type) {
   if (selector == null) selector = "configurations/default-spring-context.xml";
   if (factoryKey == null) factoryKey = "spring-context.xml";
   BeanFactoryReference reference =
       ContextSingletonBeanFactoryLocator.getInstance(
               System.getProperty("spring.configuration", selector))
           .useBeanFactory(factoryKey);
   BeanFactory beanFactory = reference.getFactory();
   return beanFactory.getBean(name, type);
 }