master
Juergen Hoeller 8 years ago
parent e4976a2c6d
commit 37de0e45f6
  1. 5
      spring-webmvc/src/main/java/org/springframework/web/servlet/i18n/AcceptHeaderLocaleResolver.java
  2. 5
      spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/condition/AbstractMediaTypeExpression.java
  3. 8
      spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/condition/ProducesRequestConditionTests.java

@ -70,7 +70,7 @@ public class AcceptHeaderLocaleResolver implements LocaleResolver {
/** /**
* Configure a fixed default locale to fall back on if the request does not * Configure a fixed default locale to fall back on if the request does not
* have an "Accept-Language" header. * have an "Accept-Language" header.
* <p>By default this is not set in which case when there is "Accept-Lanaguage" * <p>By default this is not set in which case when there is "Accept-Language"
* header, the default locale for the server is used as defined in * header, the default locale for the server is used as defined in
* {@link HttpServletRequest#getLocale()}. * {@link HttpServletRequest#getLocale()}.
* @param defaultLocale the default locale to use * @param defaultLocale the default locale to use
@ -81,7 +81,8 @@ public class AcceptHeaderLocaleResolver implements LocaleResolver {
} }
/** /**
* The configured default locale. * The configured default locale, if any.
* @since 4.3
*/ */
public Locale getDefaultLocale() { public Locale getDefaultLocale() {
return this.defaultLocale; return this.defaultLocale;

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2015 the original author or authors. * Copyright 2002-2016 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -30,7 +30,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
* @author Rossen Stoyanchev * @author Rossen Stoyanchev
* @since 3.1 * @since 3.1
*/ */
abstract class AbstractMediaTypeExpression implements Comparable<AbstractMediaTypeExpression>, MediaTypeExpression { abstract class AbstractMediaTypeExpression implements MediaTypeExpression, Comparable<AbstractMediaTypeExpression> {
protected final Log logger = LogFactory.getLog(getClass()); protected final Log logger = LogFactory.getLog(getClass());
@ -66,6 +66,7 @@ abstract class AbstractMediaTypeExpression implements Comparable<AbstractMediaTy
return this.isNegated; return this.isNegated;
} }
@Override @Override
public int compareTo(AbstractMediaTypeExpression other) { public int compareTo(AbstractMediaTypeExpression other) {
return MediaType.SPECIFICITY_COMPARATOR.compare(this.getMediaType(), other.getMediaType()); return MediaType.SPECIFICITY_COMPARATOR.compare(this.getMediaType(), other.getMediaType());

@ -24,14 +24,11 @@ import org.junit.Test;
import org.springframework.mock.web.test.MockHttpServletRequest; import org.springframework.mock.web.test.MockHttpServletRequest;
import org.springframework.web.servlet.mvc.condition.ProducesRequestCondition.ProduceMediaTypeExpression; import org.springframework.web.servlet.mvc.condition.ProducesRequestCondition.ProduceMediaTypeExpression;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.*;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
/** /**
* Unit tests for {@link ProducesRequestCondition}. * Unit tests for {@link ProducesRequestCondition}.
*
* @author Arjen Poutsma * @author Arjen Poutsma
* @author Rossen Stoyanchev * @author Rossen Stoyanchev
*/ */
@ -330,6 +327,7 @@ public class ProducesRequestConditionTests {
assertNull(result); assertNull(result);
} }
private void assertConditions(ProducesRequestCondition condition, String... expected) { private void assertConditions(ProducesRequestCondition condition, String... expected) {
Collection<ProduceMediaTypeExpression> expressions = condition.getContent(); Collection<ProduceMediaTypeExpression> expressions = condition.getContent();
assertEquals("Invalid number of conditions", expressions.size(), expected.length); assertEquals("Invalid number of conditions", expressions.size(), expected.length);

Loading…
Cancel
Save