Example #1
0
  /*
   * @see TestCase#setUp()
   */
  protected void setUp() throws Exception {
    super.setUp();

    company = new CompanyImpl();

    companyValidator = CoreObjectFactory.getCompanyValidator();
  }
Example #2
0
  /** Test que l'inject dependencies renvoit bien l'object envoyé. si celui-ci est déjé advised */
  public void testInjectDependenciesWithAnAdvised() {

    Project basicProject1 = CoreObjectFactory.getProject();

    Project basicProject2 = basicProjectProxyUtil.injectDependencies(basicProject1);

    assertSame(basicProject1, basicProject2);
  }
Example #3
0
  /**
   * Validation de l'object m�tier User.<br>
   * Les r�gles sont les suivantes:
   *
   * <ul>
   *   <li>le login est obligatoire
   *   <li>le login est unique
   *   <li>le mot de passse est obligatoire
   *   <li>le nom est obligatoire
   *   <li>le pr�nom est obligatoire
   *   <li>l'email est obligatoire
   *   <li>Le login doit avoir entre 5 et 10 carat�res.
   *   <li>Le mot de passe doit avoir entre 5 et 10 caract�res.
   *   <li>Le format de l'adresse email doit �tre valide
   * </ul>
   *
   * @param object user � valider
   */
  public Errors validate(final Object object) {

    User user = (User) object;

    Errors errors = CoreObjectFactory.getErrors();

    if (user.getLogin() == null || user.getLogin().trim() == "") {

      errors.rejectValue("login", "user.loginMandatory");

    } else if (user.getLogin().length() < 5 || user.getLogin().length() > 10) {

      // le login doit avoir entre 5 et 10 caract�res
      errors.rejectValue("login", "user.loginIncorrectSize");

    } else if (user.getPersistanceId() == 0
        && userRepository.findUserByLogin(user.getLogin()) != null) {

      // le login doit �tre unique
      errors.rejectValue("login", "user.loginAlreadyExists");
    }

    if (user.getPassword() == null || user.getPassword().trim() == "") {

      errors.rejectValue("password", "user.passwordMandatory");

    } else if (user.getPassword().length() < 5 || user.getPassword().length() > 10) {

      // le password doit avoir entre 5 et 10 caract�res
      errors.rejectValue("password", "user.passwordIncorrectSize");
    }

    if (user.getLastName() == null || user.getLastName().trim() == "") {

      errors.rejectValue("lastName", "user.lastNameMandatory");
    }

    if (user.getFirstName() == null || user.getFirstName().trim() == "") {

      errors.rejectValue("firstName", "user.firstNameMandatory");
    }

    if (user.getEmail() == null || user.getEmail().trim() == "") {

      errors.rejectValue("email", "user.emailMandatory");

    } else if (!EmailValidator.getInstance().isValid(user.getEmail())) {

      // Le format de l'adresse email doit �tre valide

      errors.rejectValue("email", "user.incorrectEmail");
    }

    return errors;
  }
Example #4
0
  /** test the construction of the object in the ApplicationContext */
  public final void testObjectConstruction() {

    // get a member from the application context
    Address address = CoreObjectFactory.getAddress();

    assertEquals("City", null, address.getCity());
    assertEquals("Country", null, address.getCountry());
    assertEquals("PostalCode", null, address.getPostalCode());
    assertEquals("StreetName", null, address.getStreetName());
    assertEquals("StreetNumber", null, address.getStreetNumber());
  }
Example #5
0
  /** Test que le getTarget renvoit bien la target du proxy quand on envoit un proxy */
  public void testGetTargetWithAnAdvised() {

    Project basicProject = CoreObjectFactory.getProject();

    Project basicProjectTargetReturned = basicProjectProxyUtil.getTarget(basicProject);

    // Project est un proxy, il faut r�cup�rer la target
    TargetSource targetSource = ((Advised) basicProject).getTargetSource();
    Object target = ((SingletonTargetSource) targetSource).getTarget();

    assertEquals(basicProjectTargetReturned, target);
  }
Example #6
0
  /** test if object is a singleton. */
  public final void testSingleton() {

    assertTrue("singleton", CoreObjectFactory.isSingleton("projectProxyUtil"));
  }
Example #7
0
  /** test if object is not a singleton */
  public final void testSingleton() {

    assertFalse("not singleton", CoreObjectFactory.isSingleton("address"));
  }
Example #8
0
  /*
   * @see TestCase#setUp()
   */
  protected void setUp() throws Exception {
    super.setUp();

    address = CoreObjectFactory.getAddress();
  }