LEFT | RIGHT |
1 // Copyright 2012 Google Inc. All Rights Reserved. | 1 // Copyright 2012 Google Inc. All Rights Reserved. |
2 // | 2 // |
3 // Licensed under the Apache License, Version 2.0 (the "License"); | 3 // Licensed under the Apache License, Version 2.0 (the "License"); |
4 // you may not use this file except in compliance with the License. | 4 // you may not use this file except in compliance with the License. |
5 // You may obtain a copy of the License at | 5 // You may obtain a copy of the License at |
6 // | 6 // |
7 // http://www.apache.org/licenses/LICENSE-2.0 | 7 // http://www.apache.org/licenses/LICENSE-2.0 |
8 // | 8 // |
9 // Unless required by applicable law or agreed to in writing, software | 9 // Unless required by applicable law or agreed to in writing, software |
10 // distributed under the License is distributed on an "AS IS" BASIS, | 10 // distributed under the License is distributed on an "AS IS" BASIS, |
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
12 // See the License for the specific language governing permissions and | 12 // See the License for the specific language governing permissions and |
13 // limitations under the License. | 13 // limitations under the License. |
14 | 14 |
15 package com.google.enterprise.adaptor; | 15 package com.google.enterprise.adaptor; |
16 | 16 |
17 import static org.junit.Assert.assertEquals; | 17 import static org.junit.Assert.assertEquals; |
18 | 18 |
19 import com.sun.net.httpserver.HttpExchange; | 19 import com.sun.net.httpserver.HttpExchange; |
20 import com.sun.net.httpserver.HttpHandler; | 20 import com.sun.net.httpserver.HttpHandler; |
21 import com.sun.net.httpserver.HttpServer; | 21 import com.sun.net.httpserver.HttpServer; |
22 import com.sun.net.httpserver.HttpsConfigurator; | 22 import com.sun.net.httpserver.HttpsConfigurator; |
23 import com.sun.net.httpserver.HttpsServer; | 23 import com.sun.net.httpserver.HttpsServer; |
24 | |
25 import org.junit.After; | |
26 import org.junit.Before; | |
27 import org.junit.Rule; | |
28 import org.junit.Test; | |
29 import org.junit.rules.ExpectedException; | |
30 | |
31 import java.io.ByteArrayInputStream; | 24 import java.io.ByteArrayInputStream; |
32 import java.io.IOException; | 25 import java.io.IOException; |
33 import java.io.InputStream; | 26 import java.io.InputStream; |
34 import java.net.InetSocketAddress; | 27 import java.net.InetSocketAddress; |
35 import java.net.URI; | 28 import java.net.URI; |
36 import java.net.URL; | 29 import java.net.URL; |
37 import java.nio.charset.Charset; | 30 import java.nio.charset.Charset; |
38 import java.util.zip.GZIPInputStream; | 31 import java.util.zip.GZIPInputStream; |
39 | |
40 import javax.net.ssl.SSLContext; | 32 import javax.net.ssl.SSLContext; |
| 33 import org.junit.After; |
| 34 import org.junit.Before; |
| 35 import org.junit.Rule; |
| 36 import org.junit.Test; |
| 37 import org.junit.rules.ExpectedException; |
41 | 38 |
42 /** | 39 /** |
43 * Test cases for {@link GsaFeedFileSender}. | 40 * Test cases for {@link GsaFeedFileSender}. |
44 */ | 41 */ |
45 public class GsaFeedFileSenderTest { | 42 public class GsaFeedFileSenderTest { |
46 @Rule | 43 @Rule |
47 public ExpectedException thrown = ExpectedException.none(); | 44 public ExpectedException thrown = ExpectedException.none(); |
48 | 45 |
49 private Charset charset = Charset.forName("UTF-8"); | 46 private Charset charset = Charset.forName("UTF-8"); |
50 private HttpServer server; | 47 private HttpServer server; |
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
312 assertEquals(URI.create("/xmlgroups"), handler.getRequestUri()); | 309 assertEquals(URI.create("/xmlgroups"), handler.getRequestUri()); |
313 assertEquals("multipart/form-data; boundary=<<", | 310 assertEquals("multipart/form-data; boundary=<<", |
314 handler.getRequestHeaders().getFirst("Content-Type")); | 311 handler.getRequestHeaders().getFirst("Content-Type")); |
315 assertEquals(goldenResponse, | 312 assertEquals(goldenResponse, |
316 new String(handler.getRequestBytes(), charset)); | 313 new String(handler.getRequestBytes(), charset)); |
317 } | 314 } |
318 | 315 |
319 @Test | 316 @Test |
320 public void testGroupsInvalidGroupSource() throws Exception { | 317 public void testGroupsInvalidGroupSource() throws Exception { |
321 thrown.expect(IllegalArgumentException.class); | 318 thrown.expect(IllegalArgumentException.class); |
322 sender.sendGroups("bad#source", "<payload/>", false,false); | 319 sender.sendGroups("bad#source", "<payload/>", false, false); |
323 } | 320 } |
324 } | 321 } |
LEFT | RIGHT |