root / extensions / gae / src / test / java / org / jclouds / gae / GaeHttpCommandExecutorServiceIntegrationTest.java @ 35e7942d
History | View | Annotate | Download (7.9 kB)
1 |
/**
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
|
4 |
*
|
5 |
* ====================================================================
|
6 |
* Licensed under the Apache License, Version 2.0 (the "License");
|
7 |
* you may not use this file except in compliance with the License.
|
8 |
* You may obtain a copy of the License at
|
9 |
*
|
10 |
* http://www.apache.org/licenses/LICENSE-2.0
|
11 |
*
|
12 |
* Unless required by applicable law or agreed to in writing, software
|
13 |
* distributed under the License is distributed on an "AS IS" BASIS,
|
14 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15 |
* See the License for the specific language governing permissions and
|
16 |
* limitations under the License.
|
17 |
* ====================================================================
|
18 |
*/
|
19 |
package org.jclouds.gae; |
20 |
|
21 |
import static org.testng.Assert.assertEquals; |
22 |
|
23 |
import java.io.File; |
24 |
import java.io.IOException; |
25 |
import java.net.MalformedURLException; |
26 |
import java.util.Map; |
27 |
import java.util.Properties; |
28 |
import java.util.concurrent.ExecutionException; |
29 |
import java.util.concurrent.TimeoutException; |
30 |
|
31 |
import org.jclouds.gae.config.GoogleAppEngineConfigurationModule; |
32 |
import org.jclouds.http.BaseHttpCommandExecutorServiceIntegrationTest; |
33 |
import org.testng.annotations.BeforeMethod; |
34 |
import org.testng.annotations.BeforeTest; |
35 |
import org.testng.annotations.Test; |
36 |
import org.testng.v6.Maps; |
37 |
|
38 |
import com.google.appengine.tools.development.ApiProxyLocalImpl; |
39 |
import com.google.apphosting.api.ApiProxy; |
40 |
import com.google.inject.Module; |
41 |
|
42 |
/**
|
43 |
*
|
44 |
* Integration test for the URLFetchService
|
45 |
*
|
46 |
* @author Adrian Cole
|
47 |
*/
|
48 |
@Test
|
49 |
public class GaeHttpCommandExecutorServiceIntegrationTest extends |
50 |
BaseHttpCommandExecutorServiceIntegrationTest { |
51 |
|
52 |
@Override
|
53 |
@Test(invocationCount = 50, timeOut = 3000) |
54 |
public void testKillRobotSlowly() throws MalformedURLException, ExecutionException, |
55 |
InterruptedException, TimeoutException { |
56 |
setupApiProxy(); |
57 |
super.testKillRobotSlowly();
|
58 |
} |
59 |
|
60 |
@Override
|
61 |
@Test(invocationCount = 50, timeOut = 3000) |
62 |
public void testPostAsInputStream() throws MalformedURLException, ExecutionException, |
63 |
InterruptedException, TimeoutException { |
64 |
setupApiProxy(); |
65 |
super.testPostAsInputStream();
|
66 |
} |
67 |
|
68 |
@Override
|
69 |
@Test(dependsOnMethods = "testPostAsInputStream") |
70 |
public void testPostResults() { |
71 |
// GAE converts everything to byte arrays and so failures are not gonna happen
|
72 |
assertEquals(postFailures.get(), 0);
|
73 |
} |
74 |
|
75 |
@Override
|
76 |
@Test(invocationCount = 50, timeOut = 3000) |
77 |
public void testPostBinder() throws MalformedURLException, ExecutionException, |
78 |
InterruptedException, TimeoutException { |
79 |
setupApiProxy(); |
80 |
super.testPostBinder();
|
81 |
} |
82 |
|
83 |
@BeforeTest
|
84 |
void validateExecutor() {
|
85 |
// ExecutorService executorService = injector.getInstance(ExecutorService.class);
|
86 |
// assert executorService.getClass().isAnnotationPresent(SingleThreadCompatible.class) :
|
87 |
// Arrays
|
88 |
// .asList(executorService.getClass().getAnnotations()).toString()
|
89 |
// + executorService.getClass().getName();
|
90 |
|
91 |
} |
92 |
|
93 |
@BeforeMethod
|
94 |
void setupApiProxy() {
|
95 |
ApiProxy.setEnvironmentForCurrentThread(new TestEnvironment());
|
96 |
ApiProxy.setDelegate(new ApiProxyLocalImpl(new File(".")) { |
97 |
}); |
98 |
} |
99 |
|
100 |
@Override
|
101 |
@Test(invocationCount = 50, timeOut = 3000) |
102 |
public void testGetAndParseSax() throws MalformedURLException, ExecutionException, |
103 |
InterruptedException, TimeoutException { |
104 |
setupApiProxy(); |
105 |
super.testGetAndParseSax();
|
106 |
} |
107 |
|
108 |
@Override
|
109 |
@Test(invocationCount = 50, timeOut = 3000) |
110 |
public void testGetString() throws MalformedURLException, ExecutionException, |
111 |
InterruptedException, TimeoutException { |
112 |
setupApiProxy(); |
113 |
super.testGetString();
|
114 |
} |
115 |
|
116 |
@Override
|
117 |
@Test(invocationCount = 50, timeOut = 3000, dataProvider = "gets") |
118 |
public void testGetStringSynch(String path) throws MalformedURLException, ExecutionException, |
119 |
InterruptedException, TimeoutException { |
120 |
setupApiProxy(); |
121 |
super.testGetStringSynch(path);
|
122 |
} |
123 |
|
124 |
@Override
|
125 |
@Test(invocationCount = 50, timeOut = 3000) |
126 |
public void testGetStringRedirect() throws MalformedURLException, ExecutionException, |
127 |
InterruptedException, TimeoutException { |
128 |
setupApiProxy(); |
129 |
super.testGetStringRedirect();
|
130 |
} |
131 |
|
132 |
@Override
|
133 |
@Test(invocationCount = 50, timeOut = 3000) |
134 |
public void testGetException() throws MalformedURLException, ExecutionException, |
135 |
InterruptedException, TimeoutException { |
136 |
setupApiProxy(); |
137 |
super.testGetException();
|
138 |
} |
139 |
|
140 |
@Override
|
141 |
@Test(invocationCount = 50, timeOut = 3000) |
142 |
public void testGetStringPermanentRedirect() throws MalformedURLException, ExecutionException, |
143 |
InterruptedException, TimeoutException { |
144 |
setupApiProxy(); |
145 |
super.testGetStringPermanentRedirect();
|
146 |
} |
147 |
|
148 |
@Override
|
149 |
@Test(invocationCount = 50, timeOut = 3000) |
150 |
public void testGetSynchException() throws MalformedURLException, ExecutionException, |
151 |
InterruptedException, TimeoutException { |
152 |
setupApiProxy(); |
153 |
super.testGetSynchException();
|
154 |
} |
155 |
|
156 |
@Override
|
157 |
@Test(invocationCount = 50, timeOut = 3000) |
158 |
public void testPost() throws MalformedURLException, ExecutionException, InterruptedException, |
159 |
TimeoutException {
|
160 |
setupApiProxy(); |
161 |
super.testPost();
|
162 |
} |
163 |
|
164 |
@Override
|
165 |
@Test(invocationCount = 50, timeOut = 3000) |
166 |
public void testPut() throws MalformedURLException, ExecutionException, InterruptedException, |
167 |
TimeoutException {
|
168 |
setupApiProxy(); |
169 |
super.testPut();
|
170 |
} |
171 |
|
172 |
@Override
|
173 |
@Test(invocationCount = 50, timeOut = 3000) |
174 |
public void testPutRedirect() throws MalformedURLException, ExecutionException, |
175 |
InterruptedException, TimeoutException { |
176 |
setupApiProxy(); |
177 |
super.testPutRedirect();
|
178 |
} |
179 |
|
180 |
@Override
|
181 |
@Test(enabled = false) |
182 |
public void testGetStringWithHeader() throws MalformedURLException, ExecutionException, |
183 |
InterruptedException, TimeoutException { |
184 |
// GAE does not support sending headers in their test stub as of version
|
185 |
// 1.2.0
|
186 |
} |
187 |
|
188 |
@Override
|
189 |
@Test(invocationCount = 50, timeOut = 3000) |
190 |
public void testHead() throws MalformedURLException, ExecutionException, InterruptedException, |
191 |
TimeoutException {
|
192 |
setupApiProxy(); |
193 |
super.testHead();
|
194 |
} |
195 |
|
196 |
@Test(enabled = false) |
197 |
public void testRequestFilter() throws MalformedURLException, ExecutionException, |
198 |
InterruptedException, TimeoutException { |
199 |
// GAE does not support sending headers in their test stub as of version
|
200 |
// 1.2.0
|
201 |
} |
202 |
|
203 |
class TestEnvironment implements ApiProxy.Environment { |
204 |
public String getAppId() { |
205 |
return "Unit Tests"; |
206 |
} |
207 |
|
208 |
public String getVersionId() { |
209 |
return "1.0"; |
210 |
} |
211 |
|
212 |
public void setDefaultNamespace(String s) { |
213 |
} |
214 |
|
215 |
public String getRequestNamespace() { |
216 |
return null; |
217 |
} |
218 |
|
219 |
public String getDefaultNamespace() { |
220 |
return null; |
221 |
} |
222 |
|
223 |
public String getAuthDomain() { |
224 |
return null; |
225 |
} |
226 |
|
227 |
public boolean isLoggedIn() { |
228 |
return false; |
229 |
} |
230 |
|
231 |
public String getEmail() { |
232 |
return null; |
233 |
} |
234 |
|
235 |
public boolean isAdmin() { |
236 |
return false; |
237 |
} |
238 |
|
239 |
public Map<String, Object> getAttributes() { |
240 |
return Maps.newHashMap();
|
241 |
} |
242 |
} |
243 |
|
244 |
protected Module createConnectionModule() {
|
245 |
return new GoogleAppEngineConfigurationModule(); |
246 |
} |
247 |
|
248 |
@Override
|
249 |
protected void addConnectionProperties(Properties props) { |
250 |
} |
251 |
|
252 |
@Override
|
253 |
@Test(enabled = false) |
254 |
public void testGetBigFile() throws MalformedURLException, ExecutionException, |
255 |
InterruptedException, TimeoutException { |
256 |
// disabled since test data is too big
|
257 |
} |
258 |
|
259 |
@Override
|
260 |
@Test(enabled = false) |
261 |
public void testUploadBigFile() throws IOException { |
262 |
// disabled since test data is too big
|
263 |
} |
264 |
|
265 |
} |