PageRenderTime 30ms CodeModel.GetById 20ms app.highlight 7ms RepoModel.GetById 1ms app.codeStats 0ms

/sitebricks-acceptance-tests/src/test/java/com/google/sitebricks/acceptance/SpiRestfuWebServiceWithSubpaths2AcceptanceTest.java

http://github.com/dhanji/sitebricks
Java | 52 lines | 42 code | 7 blank | 3 comment | 0 complexity | 79aa97c78773d8cdba11558af13422be MD5 | raw file
 1package com.google.sitebricks.acceptance;
 2
 3import com.google.common.collect.ImmutableSet;
 4import com.google.inject.AbstractModule;
 5import com.google.inject.Guice;
 6import com.google.inject.Injector;
 7import com.google.sitebricks.acceptance.util.AcceptanceTest;
 8import com.google.sitebricks.client.Web;
 9import com.google.sitebricks.client.WebResponse;
10import com.google.sitebricks.client.transport.Json;
11import com.google.sitebricks.conversion.Converter;
12import com.google.sitebricks.conversion.ConverterRegistry;
13import com.google.sitebricks.conversion.StandardTypeConverter;
14import org.testng.annotations.Test;
15
16/**
17 * @author Dhanji R. Prasanna (dhanji@gmail.com)
18 */
19@Test(suiteName = AcceptanceTest.SUITE)
20public class SpiRestfuWebServiceWithSubpaths2AcceptanceTest {
21
22  public void shouldServiceTopLevelDynamicPath() {
23    WebResponse response = createInjector()
24        .getInstance(Web.class)
25        .clientOf(AcceptanceTest.baseUrl() + "/spi/test")
26        .transports(String.class)
27        .over(Json.class)
28        .get();
29
30    assert "get:top".equals(response.toString());
31  }
32
33  public void shouldServiceFirstLevelStaticPath() {
34    WebResponse response = createInjector()
35        .getInstance(Web.class)
36        .clientOf(AcceptanceTest.baseUrl() + "/spi/test")
37        .transports(String.class)
38        .over(Json.class)
39        .post("");
40
41    assert "post:junk_subpath1".equals(response.toString()) : response.toString();
42  }
43
44	private Injector createInjector() {
45		return Guice.createInjector(new AbstractModule() {
46	      protected void configure() {
47	        bind(ConverterRegistry.class).toInstance(new StandardTypeConverter(
48              ImmutableSet.<Converter>of()));
49	      }
50	    });
51	}
52}