LEFT | RIGHT |
(no file at all) | |
1 /* | 1 /* |
2 * Copyright (c) 2011 Google Inc. | 2 * Copyright (c) 2011 Google Inc. |
3 * | 3 * |
4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not u
se this file except | 4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not u
se this file except |
5 * in compliance with the License. You may obtain a copy of the License at | 5 * in compliance with the License. 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 distribut
ed under the License | 9 * Unless required by applicable law or agreed to in writing, software distribut
ed under the License |
10 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY K
IND, either express | 10 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY K
IND, either express |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 transport.createRequestFactory().buildGetRequest(HttpTesting.SIMPLE_GENE
RIC_URL); | 165 transport.createRequestFactory().buildGetRequest(HttpTesting.SIMPLE_GENE
RIC_URL); |
166 try { | 166 try { |
167 request.execute(); | 167 request.execute(); |
168 fail(); | 168 fail(); |
169 } catch (HttpResponseException e) { | 169 } catch (HttpResponseException e) { |
170 assertEquals( | 170 assertEquals( |
171 "404 Not Found" + StringUtils.LINE_SEPARATOR + "Unable to find resourc
e", e.getMessage()); | 171 "404 Not Found" + StringUtils.LINE_SEPARATOR + "Unable to find resourc
e", e.getMessage()); |
172 } | 172 } |
173 } | 173 } |
174 | 174 |
175 @SuppressWarnings("deprecation") | |
176 public void testSerialization() throws Exception { | 175 public void testSerialization() throws Exception { |
177 HttpTransport transport = new MockHttpTransport(); | 176 HttpTransport transport = new MockHttpTransport(); |
178 HttpRequest request = | 177 HttpRequest request = |
179 transport.createRequestFactory().buildGetRequest(HttpTesting.SIMPLE_GENE
RIC_URL); | 178 transport.createRequestFactory().buildGetRequest(HttpTesting.SIMPLE_GENE
RIC_URL); |
180 HttpResponse response = request.execute(); | 179 HttpResponse response = request.execute(); |
181 HttpResponseException e = new HttpResponseException(response); | 180 HttpResponseException e = new HttpResponseException(response); |
182 ByteArrayOutputStream out = new ByteArrayOutputStream(); | 181 ByteArrayOutputStream out = new ByteArrayOutputStream(); |
183 ObjectOutput s = new ObjectOutputStream(out); | 182 ObjectOutput s = new ObjectOutputStream(out); |
184 s.writeObject(e); | 183 s.writeObject(e); |
185 ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray()); | 184 ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray()); |
186 ObjectInputStream objectInput = new ObjectInputStream(in); | 185 ObjectInputStream objectInput = new ObjectInputStream(in); |
187 HttpResponseException e2 = (HttpResponseException) objectInput.readObject(); | 186 HttpResponseException e2 = (HttpResponseException) objectInput.readObject(); |
188 assertEquals(e.getMessage(), e2.getMessage()); | 187 assertEquals(e.getMessage(), e2.getMessage()); |
189 assertEquals(e.getStatusCode(), e2.getStatusCode()); | 188 assertEquals(e.getStatusCode(), e2.getStatusCode()); |
190 assertNull(e2.getResponse()); | |
191 assertNull(e2.getHeaders()); | 189 assertNull(e2.getHeaders()); |
192 } | 190 } |
193 } | 191 } |
LEFT | RIGHT |