public class WrapRestProxyIntegrationTest {
@Test
public void serviceCanBeCalledToCreateAccessToken() throws Exception {
// Arrange
Configuration config = Configuration.getInstance();
overrideWithEnv(config, ServiceBusConfiguration.URI);
overrideWithEnv(config, ServiceBusConfiguration.WRAP_URI);
overrideWithEnv(config, ServiceBusConfiguration.WRAP_NAME);
overrideWithEnv(config, ServiceBusConfiguration.WRAP_PASSWORD);
WrapContract contract = new WrapRestProxy(config.create(Client.class),
new UserAgentFilter());
// Act
String serviceBusUri = (String) config
.getProperty(ServiceBusConfiguration.URI);
String uri = (String) config
.getProperty(ServiceBusConfiguration.WRAP_URI);
String name = (String) config
.getProperty(ServiceBusConfiguration.WRAP_NAME);
String password = (String) config
.getProperty(ServiceBusConfiguration.WRAP_PASSWORD);
String scope = new URI("http", new URI(serviceBusUri).getAuthority(),
new URI(serviceBusUri).getPath(), null, null).toString();
WrapAccessTokenResult result = contract.wrapAccessToken(uri, name,
password, scope);