Ejemplo n.º 1
0
  /**
   * Attempts to load all Spring application context XML files to verify proper wiring.
   *
   * @throws Exception On test failure.
   */
  @Test(groups = {"passtest"})
  public void testSpringWiring() throws Exception {
    final ClassPathXmlApplicationContext context =
        new ClassPathXmlApplicationContext(
            new String[] {
              "/spring-context.xml",
            });
    AssertJUnit.assertTrue(context.getBeanDefinitionCount() > 0);

    final PasswordValidator validator =
        new PasswordValidator(new ArrayList<Rule>(context.getBeansOfType(Rule.class).values()));
    final PasswordData pd = new PasswordData(new Password("springtest"));
    pd.setUsername("springuser");

    final RuleResult result = validator.validate(pd);
    AssertJUnit.assertNotNull(result);
  }
Ejemplo n.º 2
0
  public static void main(String[] args) {
    log.info("weibo task starting...");

    final ClassPathXmlApplicationContext context =
        new ClassPathXmlApplicationContext("classpath*:spring-*.xml");

    JobTimer timer = new JobTimer();
    SpringMonitorTask mTask = new SpringMonitorTask(timer, context);
    timer.addTask(mTask);

    for (Task t : context.getBeansOfType(Task.class).values()) {
      timer.addTask(t);
    }

    File lock = new File(SpringMonitorTask.PID_FILE);
    while (lock.exists()) {
      try {
        Thread.sleep(2000L);
      } catch (InterruptedException e) {
      }
    }
  }