Package org.springframework.web.servlet.mvc.condition

Examples of org.springframework.web.servlet.mvc.condition.RequestMethodsRequestCondition


  @Test
  public void compareTwoHttpMethodsOneParam() {
    RequestMappingInfo none = new RequestMappingInfo(null, null, null, null, null, null, null);
    RequestMappingInfo oneMethod =
      new RequestMappingInfo(null,
          new RequestMethodsRequestCondition(RequestMethod.GET), null, null, null, null, null);
    RequestMappingInfo oneMethodOneParam =
        new RequestMappingInfo(null,
            new RequestMethodsRequestCondition(RequestMethod.GET),
            new ParamsRequestCondition("foo"), null, null, null, null);

    Comparator<RequestMappingInfo> comparator = new Comparator<RequestMappingInfo>() {
      @Override
      public int compare(RequestMappingInfo info, RequestMappingInfo otherInfo) {
View Full Code Here


  @Test
  public void equals() {
    RequestMappingInfo info1 = new RequestMappingInfo(
        new PatternsRequestCondition("/foo"),
        new RequestMethodsRequestCondition(RequestMethod.GET),
        new ParamsRequestCondition("foo=bar"),
        new HeadersRequestCondition("foo=bar"),
        new ConsumesRequestCondition("text/plain"),
        new ProducesRequestCondition("text/plain"),
        new ParamsRequestCondition("customFoo=customBar"));

    RequestMappingInfo info2 = new RequestMappingInfo(
        new PatternsRequestCondition("/foo"),
        new RequestMethodsRequestCondition(RequestMethod.GET),
        new ParamsRequestCondition("foo=bar"),
        new HeadersRequestCondition("foo=bar"),
        new ConsumesRequestCondition("text/plain"),
        new ProducesRequestCondition("text/plain"),
        new ParamsRequestCondition("customFoo=customBar"));

    assertEquals(info1, info2);
    assertEquals(info1.hashCode(), info2.hashCode());

    info2 = new RequestMappingInfo(
        new PatternsRequestCondition("/foo", "/NOOOOOO"),
        new RequestMethodsRequestCondition(RequestMethod.GET),
        new ParamsRequestCondition("foo=bar"),
        new HeadersRequestCondition("foo=bar"),
        new ConsumesRequestCondition("text/plain"),
        new ProducesRequestCondition("text/plain"),
        new ParamsRequestCondition("customFoo=customBar"));

    assertFalse(info1.equals(info2));
    assertNotEquals(info1.hashCode(), info2.hashCode());

    info2 = new RequestMappingInfo(
        new PatternsRequestCondition("/foo"),
        new RequestMethodsRequestCondition(RequestMethod.GET, RequestMethod.POST),
        new ParamsRequestCondition("foo=bar"),
        new HeadersRequestCondition("foo=bar"),
        new ConsumesRequestCondition("text/plain"),
        new ProducesRequestCondition("text/plain"),
        new ParamsRequestCondition("customFoo=customBar"));

    assertFalse(info1.equals(info2));
    assertNotEquals(info1.hashCode(), info2.hashCode());

    info2 = new RequestMappingInfo(
        new PatternsRequestCondition("/foo"),
        new RequestMethodsRequestCondition(RequestMethod.GET),
        new ParamsRequestCondition("/NOOOOOO"),
        new HeadersRequestCondition("foo=bar"),
        new ConsumesRequestCondition("text/plain"),
        new ProducesRequestCondition("text/plain"),
        new ParamsRequestCondition("customFoo=customBar"));

    assertFalse(info1.equals(info2));
    assertNotEquals(info1.hashCode(), info2.hashCode());

    info2 = new RequestMappingInfo(
        new PatternsRequestCondition("/foo"),
        new RequestMethodsRequestCondition(RequestMethod.GET),
        new ParamsRequestCondition("foo=bar"),
        new HeadersRequestCondition("/NOOOOOO"),
        new ConsumesRequestCondition("text/plain"),
        new ProducesRequestCondition("text/plain"),
        new ParamsRequestCondition("customFoo=customBar"));

    assertFalse(info1.equals(info2));
    assertNotEquals(info1.hashCode(), info2.hashCode());

    info2 = new RequestMappingInfo(
        new PatternsRequestCondition("/foo"),
        new RequestMethodsRequestCondition(RequestMethod.GET),
        new ParamsRequestCondition("foo=bar"),
        new HeadersRequestCondition("foo=bar"),
        new ConsumesRequestCondition("text/NOOOOOO"),
        new ProducesRequestCondition("text/plain"),
        new ParamsRequestCondition("customFoo=customBar"));

    assertFalse(info1.equals(info2));
    assertNotEquals(info1.hashCode(), info2.hashCode());

    info2 = new RequestMappingInfo(
        new PatternsRequestCondition("/foo"),
        new RequestMethodsRequestCondition(RequestMethod.GET),
        new ParamsRequestCondition("foo=bar"),
        new HeadersRequestCondition("foo=bar"),
        new ConsumesRequestCondition("text/plain"),
        new ProducesRequestCondition("text/NOOOOOO"),
        new ParamsRequestCondition("customFoo=customBar"));

    assertFalse(info1.equals(info2));
    assertNotEquals(info1.hashCode(), info2.hashCode());

    info2 = new RequestMappingInfo(
        new PatternsRequestCondition("/foo"),
        new RequestMethodsRequestCondition(RequestMethod.GET),
        new ParamsRequestCondition("foo=bar"),
        new HeadersRequestCondition("foo=bar"),
        new ConsumesRequestCondition("text/plain"),
        new ProducesRequestCondition("text/plain"),
        new ParamsRequestCondition("customFoo=NOOOOOO"));
View Full Code Here

    protected RequestMappingInfo getMappingForMethod(Method method, Class<?> handlerType) {
      RequestMapping annotation = AnnotationUtils.findAnnotation(method, RequestMapping.class);
      if (annotation != null) {
        return new RequestMappingInfo(
          new PatternsRequestCondition(annotation.value(), getUrlPathHelper(), getPathMatcher(), true, true),
          new RequestMethodsRequestCondition(annotation.method()),
          new ParamsRequestCondition(annotation.params()),
          new HeadersRequestCondition(annotation.headers()),
          new ConsumesRequestCondition(annotation.consumes(), annotation.headers()),
          new ProducesRequestCondition(annotation.produces(), annotation.headers()), null);
      }
View Full Code Here

TOP

Related Classes of org.springframework.web.servlet.mvc.condition.RequestMethodsRequestCondition

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.