diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/auth/wrap/Exports.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/auth/wrap/Exports.java deleted file mode 100644 index 5acaa03325cae..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/auth/wrap/Exports.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.microsoft.windowsazure.auth.wrap; - -import com.microsoft.windowsazure.auth.wrap.contract.WrapContract; -import com.microsoft.windowsazure.auth.wrap.contract.WrapContractImpl; -import com.microsoft.windowsazure.configuration.builder.Builder.Registry; - -public class Exports implements - com.microsoft.windowsazure.configuration.builder.Builder.Exports { - - public void register(Registry registry) { - registry.add(WrapContract.class, WrapContractImpl.class); - registry.add(WrapClient.class); - registry.add(WrapFilter.class); - } - -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/auth/wrap/contract/WrapContract.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/auth/wrap/contract/WrapContract.java deleted file mode 100644 index 7b583d7ef63ae..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/auth/wrap/contract/WrapContract.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.microsoft.windowsazure.auth.wrap.contract; - -import com.microsoft.windowsazure.ServiceException; - -public interface WrapContract { - WrapResponse post(String uri, String name, String password, String scope) throws ServiceException; -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusContract.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusContract.java index e1ddae8f9b8a4..9a48c4becb217 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusContract.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusContract.java @@ -1,7 +1,7 @@ package com.microsoft.windowsazure.services.serviceBus; import com.microsoft.windowsazure.ServiceException; -import com.microsoft.windowsazure.http.ServiceFilter; +import com.microsoft.windowsazure.http.FilterableService; import com.microsoft.windowsazure.services.serviceBus.models.CreateQueueResult; import com.microsoft.windowsazure.services.serviceBus.models.CreateRuleResult; import com.microsoft.windowsazure.services.serviceBus.models.CreateSubscriptionResult; @@ -23,8 +23,7 @@ import com.microsoft.windowsazure.services.serviceBus.models.Subscription; import com.microsoft.windowsazure.services.serviceBus.models.Topic; -public interface ServiceBusContract { - ServiceBusContract withFilter(ServiceFilter filter); +public interface ServiceBusContract extends FilterableService { void sendQueueMessage(String queueName, Message message) throws ServiceException; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/Exports.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/Exports.java new file mode 100644 index 0000000000000..0143c7d644580 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/Exports.java @@ -0,0 +1,13 @@ +package com.microsoft.windowsazure.services.serviceBus.implementation; + +import com.microsoft.windowsazure.configuration.builder.Builder; + +public class Exports implements Builder.Exports { + + public void register(Builder.Registry registry) { + registry.add(WrapContract.class, WrapRestProxy.class); + registry.add(WrapTokenManager.class); + registry.add(WrapFilter.class); + } + +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java index f4c11d9f2b53a..270532b332dd1 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java @@ -12,7 +12,6 @@ import org.apache.commons.logging.LogFactory; import com.microsoft.windowsazure.ServiceException; -import com.microsoft.windowsazure.auth.wrap.WrapFilter; import com.microsoft.windowsazure.http.ClientFilterAdapter; import com.microsoft.windowsazure.http.ServiceFilter; import com.microsoft.windowsazure.services.serviceBus.ServiceBusContract; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/auth/wrap/contract/WrapResponse.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapAccessTokenResult.java similarity index 85% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/auth/wrap/contract/WrapResponse.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapAccessTokenResult.java index ab06407f92f1d..da241b3ad9cfb 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/auth/wrap/contract/WrapResponse.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapAccessTokenResult.java @@ -1,6 +1,6 @@ -package com.microsoft.windowsazure.auth.wrap.contract; +package com.microsoft.windowsazure.services.serviceBus.implementation; -public class WrapResponse { +public class WrapAccessTokenResult { String accessToken; long expiresIn; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapContract.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapContract.java new file mode 100644 index 0000000000000..c3939e2dce139 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapContract.java @@ -0,0 +1,7 @@ +package com.microsoft.windowsazure.services.serviceBus.implementation; + +import com.microsoft.windowsazure.ServiceException; + +public interface WrapContract { + WrapAccessTokenResult wrapAccessToken(String uri, String name, String password, String scope) throws ServiceException; +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/auth/wrap/WrapFilter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapFilter.java similarity index 74% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/auth/wrap/WrapFilter.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapFilter.java index dd322619984e1..ea836739c1781 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/auth/wrap/WrapFilter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapFilter.java @@ -1,4 +1,4 @@ -package com.microsoft.windowsazure.auth.wrap; +package com.microsoft.windowsazure.services.serviceBus.implementation; import com.microsoft.windowsazure.ServiceException; import com.sun.jersey.api.client.ClientHandlerException; @@ -7,10 +7,10 @@ import com.sun.jersey.api.client.filter.ClientFilter; public class WrapFilter extends ClientFilter { - private WrapClient client; + private WrapTokenManager tokenManager; - public WrapFilter(WrapClient client) { - this.client = client; + public WrapFilter(WrapTokenManager tokenManager) { + this.tokenManager = tokenManager; } @Override @@ -19,7 +19,7 @@ public ClientResponse handle(ClientRequest cr) String accessToken; try { - accessToken = client.getAccessToken(); + accessToken = tokenManager.getAccessToken(); } catch (ServiceException e) { // must wrap exception because of base class signature diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/auth/wrap/contract/WrapContractImpl.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapRestProxy.java similarity index 72% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/auth/wrap/contract/WrapContractImpl.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapRestProxy.java index 313d490a9be2c..dca9b912540a4 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/auth/wrap/contract/WrapContractImpl.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapRestProxy.java @@ -1,4 +1,4 @@ -package com.microsoft.windowsazure.auth.wrap.contract; +package com.microsoft.windowsazure.services.serviceBus.implementation; import javax.inject.Inject; import javax.ws.rs.core.MediaType; @@ -12,17 +12,17 @@ import com.sun.jersey.api.client.UniformInterfaceException; import com.sun.jersey.api.representation.Form; -public class WrapContractImpl implements WrapContract { +public class WrapRestProxy implements WrapContract { Client channel; static Log log = LogFactory.getLog(WrapContract.class); @Inject - public WrapContractImpl(Client channel) { + public WrapRestProxy(Client channel) { this.channel = channel; } - public WrapResponse post(String uri, String name, String password, String scope) throws ServiceException { + public WrapAccessTokenResult wrapAccessToken(String uri, String name, String password, String scope) throws ServiceException { Form requestForm = new Form(); requestForm.add("wrap_name", name); requestForm.add("wrap_password", password); @@ -30,9 +30,7 @@ public WrapResponse post(String uri, String name, String password, String scope) Form responseForm; try { - responseForm = channel.resource(uri) - .accept(MediaType.APPLICATION_FORM_URLENCODED) - .type(MediaType.APPLICATION_FORM_URLENCODED) + responseForm = channel.resource(uri).accept(MediaType.APPLICATION_FORM_URLENCODED).type(MediaType.APPLICATION_FORM_URLENCODED) .post(Form.class, requestForm); } catch (UniformInterfaceException e) { @@ -40,7 +38,7 @@ public WrapResponse post(String uri, String name, String password, String scope) throw ServiceExceptionFactory.process("WRAP", new ServiceException("WRAP server returned error acquiring access_token", e)); } - WrapResponse response = new WrapResponse(); + WrapAccessTokenResult response = new WrapAccessTokenResult(); response.setAccessToken(responseForm.getFirst("wrap_access_token")); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/auth/wrap/WrapClient.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapTokenManager.java similarity index 70% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/auth/wrap/WrapClient.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapTokenManager.java index 36bf0683b870d..fd97fd6a50f11 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/auth/wrap/WrapClient.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapTokenManager.java @@ -1,4 +1,4 @@ -package com.microsoft.windowsazure.auth.wrap; +package com.microsoft.windowsazure.services.serviceBus.implementation; import java.util.Date; @@ -7,29 +7,22 @@ import javax.management.timer.Timer; import com.microsoft.windowsazure.ServiceException; -import com.microsoft.windowsazure.auth.wrap.contract.WrapContract; -import com.microsoft.windowsazure.auth.wrap.contract.WrapResponse; import com.microsoft.windowsazure.utils.DateFactory; -public class WrapClient { +public class WrapTokenManager { WrapContract contract; - private DateFactory dateFactory; - private String uri; - private String name; - private String password; - private String scope; + private final DateFactory dateFactory; + private final String uri; + private final String name; + private final String password; + private final String scope; private ActiveToken activeToken; @Inject - public WrapClient( - WrapContract contract, - DateFactory dateFactory, - @Named("wrap.uri") String uri, - @Named("wrap.scope") String scope, - @Named("wrap.name") String name, - @Named("wrap.password") String password) { + public WrapTokenManager(WrapContract contract, DateFactory dateFactory, @Named("wrap.uri") String uri, @Named("wrap.scope") String scope, + @Named("wrap.name") String name, @Named("wrap.password") String password) { this.contract = contract; this.dateFactory = dateFactory; this.uri = uri; @@ -61,7 +54,7 @@ public String getAccessToken() throws ServiceException { return active.getWrapResponse().getAccessToken(); } - WrapResponse wrapResponse = getContract().post(uri, name, password, scope); + WrapAccessTokenResult wrapResponse = getContract().wrapAccessToken(uri, name, password, scope); Date expiresUtc = new Date(now.getTime() + wrapResponse.getExpiresIn() * Timer.ONE_SECOND / 2); ActiveToken acquired = new ActiveToken(); @@ -74,7 +67,7 @@ public String getAccessToken() throws ServiceException { class ActiveToken { Date expiresUtc; - WrapResponse wrapResponse; + WrapAccessTokenResult wrapResponse; /** * @return the expiresUtc @@ -94,7 +87,7 @@ public void setExpiresUtc(Date expiresUtc) { /** * @return the wrapResponse */ - public WrapResponse getWrapResponse() { + public WrapAccessTokenResult getWrapResponse() { return wrapResponse; } @@ -102,7 +95,7 @@ public WrapResponse getWrapResponse() { * @param wrapResponse * the wrapResponse to set */ - public void setWrapResponse(WrapResponse wrapResponse) { + public void setWrapResponse(WrapAccessTokenResult wrapResponse) { this.wrapResponse = wrapResponse; } } diff --git a/microsoft-azure-api/src/main/resources/META-INF/services/com.microsoft.windowsazure.configuration.builder.Builder$Exports b/microsoft-azure-api/src/main/resources/META-INF/services/com.microsoft.windowsazure.configuration.builder.Builder$Exports index ce9f1f862db41..0e2672c708145 100644 --- a/microsoft-azure-api/src/main/resources/META-INF/services/com.microsoft.windowsazure.configuration.builder.Builder$Exports +++ b/microsoft-azure-api/src/main/resources/META-INF/services/com.microsoft.windowsazure.configuration.builder.Builder$Exports @@ -1,6 +1,6 @@ -com.microsoft.windowsazure.auth.wrap.Exports com.microsoft.windowsazure.configuration.jersey.Exports com.microsoft.windowsazure.services.blob.Exports com.microsoft.windowsazure.services.queue.Exports com.microsoft.windowsazure.services.serviceBus.Exports +com.microsoft.windowsazure.services.serviceBus.implementation.Exports com.microsoft.windowsazure.utils.Exports diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/auth/wrap/contract/WrapContractIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/auth/wrap/contract/WrapContractIntegrationTest.java deleted file mode 100644 index 46650236ed02a..0000000000000 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/auth/wrap/contract/WrapContractIntegrationTest.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.microsoft.windowsazure.auth.wrap.contract; - -import org.junit.Test; - -import com.microsoft.windowsazure.auth.wrap.contract.WrapContract; -import com.microsoft.windowsazure.auth.wrap.contract.WrapContractImpl; -import com.microsoft.windowsazure.configuration.Configuration; -import com.sun.jersey.api.client.Client; - -public class WrapContractIntegrationTest { - @Test - public void yaaaaargh() throws Exception { - Configuration config = new Configuration(); - - WrapContract contract = new WrapContractImpl(config.create(Client.class)); - - contract.post( - "https://lodejard-sb.accesscontrol.windows.net/WRAPv0.9", - "owner", - "Zo3QCZ5jLlJofibEiifZyz7B3x6a5Suv2YoS1JAWopA=", - "http://lodejard.servicebus.windows.net"); - } -} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapRestProxyIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapRestProxyIntegrationTest.java new file mode 100644 index 0000000000000..5bafb7df76e91 --- /dev/null +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapRestProxyIntegrationTest.java @@ -0,0 +1,25 @@ +package com.microsoft.windowsazure.services.serviceBus.implementation; + +import static org.junit.Assert.*; + +import org.junit.Test; + +import com.microsoft.windowsazure.configuration.Configuration; +import com.sun.jersey.api.client.Client; + +public class WrapRestProxyIntegrationTest { + @Test + public void serviceCanBeCalledToCreateAccessToken() throws Exception { + // Arrange + Configuration config = new Configuration(); + WrapContract contract = new WrapRestProxy(config.create(Client.class)); + + // Act + WrapAccessTokenResult result = contract.wrapAccessToken("https://lodejard-sb.accesscontrol.windows.net/WRAPv0.9", "owner", + "Zo3QCZ5jLlJofibEiifZyz7B3x6a5Suv2YoS1JAWopA=", "http://lodejard.servicebus.windows.net"); + + // Assert + assertNotNull(result); + assertNotNull(result.getAccessToken()); + } +} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/auth/wrap/WrapClientIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapTokenManagerIntegrationTest.java similarity index 76% rename from microsoft-azure-api/src/test/java/com/microsoft/windowsazure/auth/wrap/WrapClientIntegrationTest.java rename to microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapTokenManagerIntegrationTest.java index 665d3152297fa..361287d7ef09e 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/auth/wrap/WrapClientIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapTokenManagerIntegrationTest.java @@ -1,13 +1,13 @@ -package com.microsoft.windowsazure.auth.wrap; +package com.microsoft.windowsazure.services.serviceBus.implementation; import junit.framework.Assert; import org.junit.Test; -import com.microsoft.windowsazure.auth.wrap.WrapClient; import com.microsoft.windowsazure.configuration.Configuration; +import com.microsoft.windowsazure.services.serviceBus.implementation.WrapTokenManager; -public class WrapClientIntegrationTest { +public class WrapTokenManagerIntegrationTest { private Configuration createConfiguration() { Configuration config = new Configuration(); config.setProperty("wrapClient.uri", "https://lodejard-sb.accesscontrol.windows.net/WRAPv0.9"); @@ -21,7 +21,7 @@ private Configuration createConfiguration() { public void wrapClientWillAcquireAccessToken() throws Exception { // Arrange Configuration config = createConfiguration(); - WrapClient client = config.create(WrapClient.class); + WrapTokenManager client = config.create(WrapTokenManager.class); // Act String accessToken = client.getAccessToken(); diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/auth/wrap/WrapClientTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapTokenManagerTest.java similarity index 67% rename from microsoft-azure-api/src/test/java/com/microsoft/windowsazure/auth/wrap/WrapClientTest.java rename to microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapTokenManagerTest.java index 6dc11fd627667..2cae1fad35bbd 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/auth/wrap/WrapClientTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapTokenManagerTest.java @@ -1,4 +1,4 @@ -package com.microsoft.windowsazure.auth.wrap; +package com.microsoft.windowsazure.services.serviceBus.implementation; import static org.junit.Assert.*; import static org.mockito.Mockito.*; @@ -13,14 +13,11 @@ import org.mockito.stubbing.Answer; import com.microsoft.windowsazure.ServiceException; -import com.microsoft.windowsazure.auth.wrap.WrapClient; -import com.microsoft.windowsazure.auth.wrap.contract.WrapContract; -import com.microsoft.windowsazure.auth.wrap.contract.WrapResponse; import com.microsoft.windowsazure.utils.DateFactory; -public class WrapClientTest { +public class WrapTokenManagerTest { private WrapContract contract; - private WrapClient client; + private WrapTokenManager client; private DateFactory dateFactory; private Calendar calendar; @@ -30,13 +27,7 @@ public void init() { dateFactory = mock(DateFactory.class); contract = mock(WrapContract.class); - client = new WrapClient( - contract, - dateFactory, - "testurl", - "testscope", - "testname", - "testpassword"); + client = new WrapTokenManager(contract, dateFactory, "testurl", "testscope", "testname", "testpassword"); when(dateFactory.getDate()).thenAnswer(new Answer() { public Date answer(InvocationOnMock invocation) throws Throwable { @@ -49,11 +40,11 @@ public Date answer(InvocationOnMock invocation) throws Throwable { @Test public void clientUsesContractToGetToken() throws ServiceException { // Arrange - WrapResponse wrapResponse = new WrapResponse(); + WrapAccessTokenResult wrapResponse = new WrapAccessTokenResult(); wrapResponse.setAccessToken("testaccesstoken"); wrapResponse.setExpiresIn(83); - when(contract.post("testurl", "testname", "testpassword", "testscope")).thenReturn(wrapResponse); + when(contract.wrapAccessToken("testurl", "testname", "testpassword", "testscope")).thenReturn(wrapResponse); // Act String accessToken = client.getAccessToken(); @@ -66,11 +57,11 @@ public void clientUsesContractToGetToken() throws ServiceException { @Test public void clientWillNotCallMultipleTimesWhileAccessTokenIsValid() throws ServiceException { // Arrange - WrapResponse wrapResponse = new WrapResponse(); + WrapAccessTokenResult wrapResponse = new WrapAccessTokenResult(); wrapResponse.setAccessToken("testaccesstoken"); wrapResponse.setExpiresIn(83); - when(contract.post("testurl", "testname", "testpassword", "testscope")).thenReturn(wrapResponse); + when(contract.wrapAccessToken("testurl", "testname", "testpassword", "testscope")).thenReturn(wrapResponse); // Act String accessToken1 = client.getAccessToken(); @@ -83,23 +74,23 @@ public void clientWillNotCallMultipleTimesWhileAccessTokenIsValid() throws Servi assertEquals("testaccesstoken", accessToken2); assertEquals("testaccesstoken", accessToken3); - verify(contract, times(1)).post("testurl", "testname", "testpassword", "testscope"); + verify(contract, times(1)).wrapAccessToken("testurl", "testname", "testpassword", "testscope"); } @Test public void clientWillBeCalledWhenTokenIsHalfwayToExpiring() throws ServiceException { // Arrange - doAnswer(new Answer() { + doAnswer(new Answer() { int count = 0; - public WrapResponse answer(InvocationOnMock invocation) throws Throwable { + public WrapAccessTokenResult answer(InvocationOnMock invocation) throws Throwable { ++count; - WrapResponse wrapResponse = new WrapResponse(); + WrapAccessTokenResult wrapResponse = new WrapAccessTokenResult(); wrapResponse.setAccessToken("testaccesstoken" + count); wrapResponse.setExpiresIn(83); return wrapResponse; } - }).when(contract).post("testurl", "testname", "testpassword", "testscope"); + }).when(contract).wrapAccessToken("testurl", "testname", "testpassword", "testscope"); // Act String accessToken1 = client.getAccessToken(); @@ -112,7 +103,7 @@ public WrapResponse answer(InvocationOnMock invocation) throws Throwable { assertEquals("testaccesstoken1", accessToken2); assertEquals("testaccesstoken2", accessToken3); - verify(contract, times(2)).post("testurl", "testname", "testpassword", "testscope"); + verify(contract, times(2)).wrapAccessToken("testurl", "testname", "testpassword", "testscope"); } }