- Add Safari 6 to the supported matrix.

This commit is contained in:
Paulo Gustavo Veiga 2012-09-16 20:47:13 -03:00
parent 46f3ec96c5
commit 7b1574150a
4 changed files with 25 additions and 24 deletions

View File

@ -41,14 +41,14 @@ public class BrowserSupportInterceptor extends HandlerInterceptorAdapter {
final HttpSession session = request.getSession(false);
// Try to loaded from the request ...
WiseUserAgent userAgent = null;
SupportedUserAgent userAgent = null;
if (session != null) {
userAgent = (WiseUserAgent) session.getAttribute(USER_AGENT);
userAgent = (SupportedUserAgent) session.getAttribute(USER_AGENT);
}
// I could not loaded. I will create a new one...
if (userAgent == null) {
userAgent = WiseUserAgent.create(request);
userAgent = SupportedUserAgent.create(request);
if (session != null) {
session.setAttribute(USER_AGENT, userAgent);
}

View File

@ -24,17 +24,17 @@ import org.jetbrains.annotations.NotNull;
import javax.servlet.http.HttpServletRequest;
import java.io.Serializable;
public class WiseUserAgent implements Serializable {
public class SupportedUserAgent implements Serializable {
public static final String USER_AGENT_HEADER = "User-Agent";
transient private UserAgent userAgent;
private String header;
private WiseUserAgent(@NotNull final String header) {
private SupportedUserAgent(@NotNull final String header) {
this.header = header;
}
public static WiseUserAgent create(@NotNull final HttpServletRequest request) {
return new WiseUserAgent(request.getHeader(USER_AGENT_HEADER));
public static SupportedUserAgent create(@NotNull final HttpServletRequest request) {
return new SupportedUserAgent(request.getHeader(USER_AGENT_HEADER));
}
public boolean isBrowserSupported() {
@ -50,6 +50,7 @@ public class WiseUserAgent implements Serializable {
result = result || browser == Browser.OPERA && Integer.parseInt(version.getMajorVersion()) >= 11;
result = result || browser == Browser.CHROME && Integer.parseInt(version.getMajorVersion()) >= 18;
result = result || browser == Browser.SAFARI5;
result = result || browser == Browser.SAFARI && Integer.parseInt(version.getMajorVersion()) >= 5;
result = result || browser == Browser.MOBILE_SAFARI && Integer.parseInt(version.getMajorVersion()) >= 5;
result = result || os.isMobileDevice() && (os == OperatingSystem.ANDROID || os == OperatingSystem.iOS4_IPHONE);
result = result || browser.getBrowserType() == BrowserType.ROBOT;
@ -76,8 +77,8 @@ public class WiseUserAgent implements Serializable {
return browser == Browser.IE && Integer.parseInt(version.getMajorVersion()) >= 8 && os == OperatingSystem.WINDOWS && header.contains("chromeframe");
}
public static WiseUserAgent create(@NotNull final String userAgent) {
return new WiseUserAgent(userAgent);
public static SupportedUserAgent create(@NotNull final String userAgent) {
return new SupportedUserAgent(userAgent);
}

View File

@ -18,7 +18,7 @@
package com.wisemapping.mail;
import com.wisemapping.filter.WiseUserAgent;
import com.wisemapping.filter.SupportedUserAgent;
import com.wisemapping.model.Collaboration;
import com.wisemapping.model.Mindmap;
import com.wisemapping.model.User;
@ -175,7 +175,7 @@ final public class NotificationService {
final String userEmail = user != null ? user.getEmail() : "'anonymous'";
model.put("email", userEmail);
model.put("userAgent", request.getHeader(WiseUserAgent.USER_AGENT_HEADER));
model.put("userAgent", request.getHeader(SupportedUserAgent.USER_AGENT_HEADER));
model.put("server", request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort());
model.put("requestURI", request.getRequestURI());
model.put("method", request.getMethod());

View File

@ -1,6 +1,6 @@
package com.wisemapping.test.model;
import com.wisemapping.filter.WiseUserAgent;
import com.wisemapping.filter.SupportedUserAgent;
import org.testng.Assert;
import org.testng.annotations.Test;
@ -10,40 +10,40 @@ public class UserAgentTest {
@Test
public void validations() {
final WiseUserAgent firefox15 = WiseUserAgent.create("Mozilla/5.0 (Windows NT 6.1; rv:15.0) Gecko/20120716 Firefox/15");
final SupportedUserAgent firefox15 = SupportedUserAgent.create("Mozilla/5.0 (Windows NT 6.1; rv:15.0) Gecko/20120716 Firefox/15");
Assert.assertEquals(firefox15.isBrowserSupported(), true);
final WiseUserAgent firefox9 = WiseUserAgent.create("Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:9.0a2) Gecko/20111101 Firefox/9.0a2");
final SupportedUserAgent firefox9 = SupportedUserAgent.create("Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:9.0a2) Gecko/20111101 Firefox/9.0a2");
Assert.assertEquals(firefox9.isBrowserSupported(), false);
final WiseUserAgent chrome18 = WiseUserAgent.create("Mozilla/5.0 (Windows NT 6.1) AppleWebKit/535.2 (KHTML, like Gecko) Chrome/18.6.872.0 Safari/535.2 UNTRUSTED/1.0 3gpp-gba UNTRUSTED/1.0");
final SupportedUserAgent chrome18 = SupportedUserAgent.create("Mozilla/5.0 (Windows NT 6.1) AppleWebKit/535.2 (KHTML, like Gecko) Chrome/18.6.872.0 Safari/535.2 UNTRUSTED/1.0 3gpp-gba UNTRUSTED/1.0");
Assert.assertEquals(chrome18.isBrowserSupported(), true);
final WiseUserAgent chrome21 = WiseUserAgent.create("Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/22.0.1207.1 Safari/537.1");
final SupportedUserAgent chrome21 = SupportedUserAgent.create("Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/22.0.1207.1 Safari/537.1");
Assert.assertEquals(chrome21.isBrowserSupported(), true);
final WiseUserAgent ie10 = WiseUserAgent.create("Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; Trident/4.0; InfoPath.2; SV1; .NET CLR 2.0.50727; WOW64)");
final SupportedUserAgent ie10 = SupportedUserAgent.create("Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; Trident/4.0; InfoPath.2; SV1; .NET CLR 2.0.50727; WOW64)");
Assert.assertEquals(ie10.isBrowserSupported(), true);
final WiseUserAgent ie10_6 = WiseUserAgent.create("Mozilla/5.0 (compatible; MSIE 10.6; Windows NT 6.1; Trident/5.0; InfoPath.2; SLCC1; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET CLR 2.0.50727) 3gpp-gba UNTRUSTED/1.0");
final SupportedUserAgent ie10_6 = SupportedUserAgent.create("Mozilla/5.0 (compatible; MSIE 10.6; Windows NT 6.1; Trident/5.0; InfoPath.2; SLCC1; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET CLR 2.0.50727) 3gpp-gba UNTRUSTED/1.0");
Assert.assertEquals(ie10_6.isBrowserSupported(), true);
final WiseUserAgent ie9 = WiseUserAgent.create("Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.2; .NET CLR 1.1.4322; .NET4.0C; Tablet PC 2.0)");
final SupportedUserAgent ie9 = SupportedUserAgent.create("Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.2; .NET CLR 1.1.4322; .NET4.0C; Tablet PC 2.0)");
Assert.assertEquals(ie9.isBrowserSupported(), true);
final WiseUserAgent safari = WiseUserAgent.create("Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_7; da-dk) AppleWebKit/533.21.1 (KHTML, like Gecko) Version/5.0.5 Safari/533.21.1");
final SupportedUserAgent safari = SupportedUserAgent.create("Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_7; da-dk) AppleWebKit/533.21.1 (KHTML, like Gecko) Version/5.0.5 Safari/533.21.1");
Assert.assertEquals(safari.isBrowserSupported(), true);
final WiseUserAgent safari6 = WiseUserAgent.create("Mozilla/5.0 (iPad; CPU OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A5355d Safari/8536.25");
final SupportedUserAgent safari6 = SupportedUserAgent.create("Mozilla/5.0 (iPad; CPU OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A5355d Safari/8536.25");
Assert.assertEquals(safari6.isBrowserSupported(), true);
final WiseUserAgent safariIpad = WiseUserAgent.create("Mozilla/5.0 (iPad; CPU OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A5355d Safari/8536.25");
final SupportedUserAgent safariIpad = SupportedUserAgent.create("Mozilla/5.0 (iPad; CPU OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A5355d Safari/8536.25");
Assert.assertEquals(safariIpad.isBrowserSupported(), true);
final WiseUserAgent googlebot = WiseUserAgent.create("Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)");
final SupportedUserAgent googlebot = SupportedUserAgent.create("Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)");
Assert.assertEquals(googlebot.isBrowserSupported(), true);
final WiseUserAgent mediapartners = WiseUserAgent.create("Mediapartners-Google/2.1");
final SupportedUserAgent mediapartners = SupportedUserAgent.create("Mediapartners-Google/2.1");
Assert.assertEquals(mediapartners.isBrowserSupported(), true);
}