Package org.springframework.ide.eclipse.beans.core.model

Examples of org.springframework.ide.eclipse.beans.core.model.IBean


  public void testExistingInitAndDestroyMethodsWithWrongParameterCount() throws Exception {
    String[] errorMessages = new String[] {
        "Destroy-method 'initWithParameters' not found in bean class 'org.springframework.Base'",
        "Init-method 'initWithParameters' not found in bean class 'org.springframework.Base'" };

    IBean bean = BeansModelUtils.getBean("incorrectWithParameters", beansConfig);
    assertNotNull(bean);
    int severity = MarkerUtils.getHighestSeverityFromMarkersInRange(resource, bean
        .getElementStartLine(), bean.getElementEndLine());
    assertTrue(severity == IMarker.SEVERITY_ERROR);

    Set<IMarker> markers = MarkerUtils.getAllMarkersInRange(resource, bean
        .getElementStartLine(), bean.getElementEndLine());
    assertTrue(markers.size() == 2);
    for (IMarker marker : markers) {
      String msg = (String) marker.getAttribute(IMarker.MESSAGE);
      assertTrue("Error message not expected '" + msg + "'", Arrays.asList(errorMessages)
          .contains(msg));
View Full Code Here


    StsTestUtil.waitForResource(resource);
  }

  @Test
  public void testRequiredAnnotationConfiguration() throws Exception {
    IBean bean = BeansModelUtils.getBean("abstractFoo", beansConfig);
    assertNotNull(bean);
    int severity = MarkerUtils.getHighestSeverityFromMarkersInRange(resource, bean
        .getElementStartLine(), bean.getElementEndLine());
    assertEquals("Abstract beans are not required to be configured", -1, severity);

    bean = BeansModelUtils.getBean("goodFoo", beansConfig);
    severity = MarkerUtils.getHighestSeverityFromMarkersInRange(resource, bean
        .getElementStartLine(), bean.getElementEndLine());
    assertEquals("Satisfying configuration given; no error expected", -1, severity);

    bean = BeansModelUtils.getBean("wrongFoo", beansConfig);
    severity = MarkerUtils.getHighestSeverityFromMarkersInRange(resource, bean
        .getElementStartLine(), bean.getElementEndLine());
    assertEquals("Missing required configuration; error expected", IMarker.SEVERITY_WARNING,
        severity);
    Set<IMarker> markers = MarkerUtils.getAllMarkersInRange(resource, bean
        .getElementStartLine(), bean.getElementEndLine());
    assertEquals(1, markers.size());
    for (IMarker marker : markers) {
      String msg = (String) marker.getAttribute(IMarker.MESSAGE);
      assertEquals("Error message not expected '" + msg + "'",
          "Property 'bar' is required for bean 'wrongFoo'", msg);
View Full Code Here

  }
 
  @Test
  public void testAutowireEmpty() throws Exception {
    String[] errorMessages = new String[] { "No constructor with 0 arguments defined in class 'org.springframework.Factory'" };
    IBean bean = BeansModelUtils.getBean("autowireEmpty", beansConfig);
    assertNotNull(bean);
   
    int severity = MarkerUtils.getHighestSeverityFromMarkersInRange(resource, bean
        .getElementStartLine(), bean.getElementEndLine());
    assertEquals(IMarker.SEVERITY_ERROR, severity);

    Set<IMarker> markers = MarkerUtils.getAllMarkersInRange(resource, bean
        .getElementStartLine(), bean.getElementEndLine());
    assertEquals(1, markers.size());
    for (IMarker marker : markers) {
      String msg = (String) marker.getAttribute(IMarker.MESSAGE);
      assertTrue("Error message not expected '" + msg + "'", Arrays.asList(errorMessages)
          .contains(msg));
View Full Code Here

   * @param context the validation context
   * @return true if given element is supported by this rule implementation
   * @see #supportsModelElementForNonInfrastructureBean(IModelElement, IBeansValidationContext)
   */
  public final boolean supports(IModelElement element, IValidationContext context) {
    IBean bean = resolveBeanFromModelElement(element);
    return context instanceof IBeansValidationContext
        && (bean == null || (bean != null && !bean.isInfrastructure()))
        && supportsModelElementForNonInfrastructureBean(element, (IBeansValidationContext) context);
  }
View Full Code Here

  }
 
  @Test
  public void testAutowireDefault() throws Exception {
    String[] errorMessages = new String[] { "No constructor with 0 arguments defined in class 'org.springframework.Factory'" };
    IBean bean = BeansModelUtils.getBean("autowireDefault", beansConfig);
    assertNotNull(bean);

    int severity = MarkerUtils.getHighestSeverityFromMarkersInRange(resource, bean
        .getElementStartLine(), bean.getElementEndLine());
    assertEquals(IMarker.SEVERITY_ERROR, severity);

    Set<IMarker> markers = MarkerUtils.getAllMarkersInRange(resource, bean
        .getElementStartLine(), bean.getElementEndLine());
    assertEquals(1, markers.size());
    for (IMarker marker : markers) {
      String msg = (String) marker.getAttribute(IMarker.MESSAGE);
      assertTrue("Error message not expected '" + msg + "'", Arrays.asList(errorMessages)
          .contains(msg));
View Full Code Here

    }
  }

  @Test
  public void testAutowireConstructor() throws Exception {
    IBean bean = BeansModelUtils.getBean("autowireConstructor", beansConfig);
    assertNotNull(bean);
    int severity = MarkerUtils.getHighestSeverityFromMarkersInRange(resource, bean
        .getElementStartLine(), bean.getElementEndLine());
    assertTrue("No error expected for bean", severity != IMarker.SEVERITY_ERROR
        && severity != IMarker.SEVERITY_WARNING);
  }
View Full Code Here

  }

  @Test
  public void testAutowireEmptyParentDefault() throws Exception {
    String[] errorMessages = new String[] { "No constructor with 0 arguments defined in class 'org.springframework.Factory'" };
    IBean bean = BeansModelUtils.getBean("autowireEmptyParentDefault", beansConfig);
    assertNotNull(bean);
    int severity = MarkerUtils.getHighestSeverityFromMarkersInRange(resource, bean
        .getElementStartLine(), bean.getElementEndLine());
    assertEquals(IMarker.SEVERITY_ERROR, severity);

    Set<IMarker> markers = MarkerUtils.getAllMarkersInRange(resource, bean
        .getElementStartLine(), bean.getElementEndLine());
    assertEquals(1, markers.size());
    for (IMarker marker : markers) {
      String msg = (String) marker.getAttribute(IMarker.MESSAGE);
      assertTrue("Error message not expected '" + msg + "'", Arrays.asList(errorMessages)
          .contains(msg));
View Full Code Here

  }
 
  @Test
  public void testAutowireDefaultParentDefault() throws Exception {
    String[] errorMessages = new String[] { "No constructor with 0 arguments defined in class 'org.springframework.Factory'" };
    IBean bean = BeansModelUtils.getBean("autowireDefaultParentDefault", beansConfig);
    assertNotNull(bean);
   
    int severity = MarkerUtils.getHighestSeverityFromMarkersInRange(resource, bean
        .getElementStartLine(), bean.getElementEndLine());
    assertEquals(IMarker.SEVERITY_ERROR, severity);

    Set<IMarker> markers = MarkerUtils.getAllMarkersInRange(resource, bean
        .getElementStartLine(), bean.getElementEndLine());
    assertEquals(1, markers.size());
    for (IMarker marker : markers) {
      String msg = (String) marker.getAttribute(IMarker.MESSAGE);
      assertTrue("Error message not expected '" + msg + "'", Arrays.asList(errorMessages)
          .contains(msg));
View Full Code Here

    }
  }
 
  @Test
  public void testAutowireConstructorParentDefault() throws Exception {
    IBean bean = BeansModelUtils.getBean("autowireConstructorParentDefault", beansConfig);
    assertNotNull(bean);
    int severity = MarkerUtils.getHighestSeverityFromMarkersInRange(resource, bean
        .getElementStartLine(), bean.getElementEndLine());
    assertTrue("No error expected for bean", severity != IMarker.SEVERITY_ERROR
        && severity != IMarker.SEVERITY_WARNING);
  }
View Full Code Here

        && severity != IMarker.SEVERITY_WARNING);
  }

  @Test
  public void testAutowireEmptyParentConstructor() throws Exception {
    IBean bean = BeansModelUtils.getBean("autowireEmptyParentConstructor", beansConfig);
    assertNotNull(bean);
    int severity = MarkerUtils.getHighestSeverityFromMarkersInRange(resource, bean
        .getElementStartLine(), bean.getElementEndLine());
    assertTrue("No error expected for bean", severity != IMarker.SEVERITY_ERROR
        && severity != IMarker.SEVERITY_WARNING);
  }
View Full Code Here

TOP

Related Classes of org.springframework.ide.eclipse.beans.core.model.IBean

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.