1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.apache.myfaces.tobago.context;
21
22
23 import org.apache.myfaces.tobago.util.Parameterized;
24 import org.junit.Assert;
25 import org.junit.Test;
26 import org.junit.runner.RunWith;
27
28 import java.util.Arrays;
29 import java.util.List;
30
31 @RunWith(Parameterized.class)
32 public class UserAgentUnitTest {
33
34 private UserAgent agent;
35 private String headerString;
36
37 public UserAgentUnitTest(String title, UserAgent agent, String headerString) {
38 this.agent = agent;
39 this.headerString = headerString;
40 }
41
42 @Test
43 public void test() {
44 Assert.assertEquals(agent, UserAgent.getInstance(headerString));
45 }
46
47 @Parameterized.Parameters
48 public static List<Object[]> data() {
49 return Arrays.asList(new Object[][]{
50
51 {"Internet Explorer 6 - Windows 2000",
52 UserAgent.MSIE_6_0,
53 "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0"},
54
55 {"Internet Explorer 6 - Windows XP",
56 UserAgent.MSIE_6_0,
57 "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)'"},
58
59 {"Internet Explorer 7 - Windows XP",
60 UserAgent.MSIE_7_0,
61 "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)"},
62
63 {"Internet Explorer 8 - Windows XP",
64 UserAgent.MSIE_8_0,
65 "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 2.0.50727;"
66 + " .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)"},
67
68 {"Internet Explorer 8 - Compatibility Mode - Windows XP",
69 UserAgent.MSIE_7_0_COMPAT,
70 "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0)"},
71
72 {"Internet Explorer 9 preview - Windows 7",
73 UserAgent.MSIE_9_0,
74 "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)"},
75
76 {"Internet Explorer 9 - Windows 7",
77 UserAgent.MSIE_9_0,
78 "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Win64; x64; Trident/5.0)"},
79
80 {"Internet Explorer 9 - Compatibility Mode - Windows 7",
81 UserAgent.MSIE_7_0_COMPAT,
82 "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; Win64; x64; Trident/5.0; "
83 + ".NET CLR 2.0.50727; SLCC2; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C)"},
84
85 {"Internet Explorer 10 - Windows 8 - Developer Preview",
86 UserAgent.MSIE_10_0,
87 "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; WOW64; Trident/6.0)"},
88
89 {"Internet Explorer 10 - Compatibility Mode - Windows 8 - Developer Preview",
90 UserAgent.MSIE_7_0_COMPAT,
91 "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.2; WOW64; Trident/6.0; .NET4.0E; .NET4.0C)"},
92
93 {"Firefox 3.6 - Ubuntu 10.4",
94 UserAgent.GECKO_1_9,
95 "Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2) Gecko/20100308 Ubuntu/10.04 (lucid) Firefox/3.6"},
96
97 {"Firefox 3.6 - Ubuntu 9.10",
98 UserAgent.GECKO_1_9,
99 "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.3pre) Gecko/20100328 Ubuntu/9.10 (karmic) "
100 + "Namoroka/3.6.3pre"},
101
102 {"Firefox 5.0 - Mac OS X Snow Leopard",
103 UserAgent.GECKO_5_0,
104 "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:5.0) Gecko/20100101 Firefox/5.0"},
105
106 {"Firefox 4.0 beta 2 - Mac OS X Snow Leopard",
107 UserAgent.GECKO_2_0,
108 "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:2.0b2) Gecko/20100720 Firefox/4.0b2"},
109
110 {"Firefox 3.6 - Mac OS X Snow Leopard",
111 UserAgent.GECKO_1_9,
112 "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; de; rv:1.9.2.8) Gecko/20100722 Firefox/3.6.8"},
113
114 {"Firefox 3.5 - Mac OS X Snow Leopard",
115 UserAgent.GECKO_1_9,
116 "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; de; rv:1.9.1.9) Gecko/20100315 Firefox/3.5.9"},
117
118 {"Firefox 3.0 - Mac OS X Snow Leopard",
119 UserAgent.GECKO_1_9,
120 "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; de; rv:1.9.0.19) Gecko/2010031218 Firefox/3.0.19"},
121
122 {"Firefox 2.0 - Mac OS X Snow Leopard",
123 UserAgent.GECKO_1_8,
124 "Mozilla/5.0 (Macintosh; U; Intel Mac OS X; de; rv:1.8.1.20) Gecko/20081217 Firefox/2.0.0.20"},
125
126 {"Opera 10.61 - Windows 7",
127 UserAgent.PRESTO,
128 "Opera/9.80 (Windows NT 6.1; U; de) Presto/2.6.30 Version/10.61"},
129
130 {"Opera 10.10 - Mac OS X Snow Leopard",
131 UserAgent.PRESTO,
132 "Opera/9.80 (Macintosh; Intel Mac OS X; U; de) Presto/2.2.15 Version/10.10"},
133
134 {"Opera 10.51 - Ubuntu 9.10",
135 UserAgent.PRESTO,
136 "Opera/9.80 (X11; Linux i686; U; en) Presto/2.5.22 Version/10.51"},
137
138 {"Chrome 4.1 - Windows 7",
139 UserAgent.WEBKIT,
140 "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/532.5 (KHTML, like Gecko)"
141 + " Chrome/4.1.249.1042 Safari/532.5"},
142
143 {"Chrome 5 - Mac OS X Snow Leopard",
144 UserAgent.WEBKIT,
145 "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_4; en-US) AppleWebKit/533.4 (KHTML, like Gecko)"
146 + " Chrome/5.0.375.127 Safari/533.4"},
147
148 {"Chrome 5 - Ubuntu 9.10",
149 UserAgent.WEBKIT,
150 "Mozilla/5.0 (X11; U; Linux i686; en-US) AppleWebKit/533.3 (KHTML, like Gecko)"
151 + " Chrome/5.0.360.0 Safari/533.3"},
152
153 {"Chromium 5 - Ubuntu 9.10",
154 UserAgent.WEBKIT,
155 "Mozilla/5.0 (X11; U; Linux i686; en-US) AppleWebKit/533.3 (KHTML, like Gecko)"
156 + " Chrome/5.0.365.0 Safari/533.3"},
157
158 {"Safari 5 - Mac OS X Snow Leopard",
159 UserAgent.WEBKIT,
160 "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_4; de-de) AppleWebKit/533.17.8 (KHTML, like Gecko) "
161 + "Version/5.0.1 Safari/533.17.8"},
162
163 {"Safari 4 - Mac OS X Snow Leopard",
164 UserAgent.WEBKIT,
165 "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_2; de-de) AppleWebKit/531.22.7 (KHTML, like Gecko) "
166 + "Version/4.0.5 Safari/531.22.7"},
167
168 {"Safari 4 - iPad",
169 UserAgent.WEBKIT,
170 "Mozilla/5.0 (iPad; U; CPU OS 3_2_1 like Mac OS X; de-de) AppleWebKit/531.21.10 (KHTML, like Gecko) "
171 + "Version/4.0.4 Mobile/7B405 Safari/531.21.10"},
172
173 {"Web-Browser for S60 - Symbian - Nokia E51",
174 UserAgent.WEBKIT,
175 "Mozilla/5.0 "
176 + "(SymbianOS/9.2; U; Series60/3.1 NokiaE51-1/300.34.56; Profile/MIDP-2.0 Configuration/CLDC-1.1 ) "
177 + "AppleWebKit/413 (KHTML, like Gecko) Safari/413"},
178 });
179 }
180 }