diff --git a/components/org.wso2.carbon.identity.oauth/src/test/java/org/wso2/carbon/identity/oauth2/responsemode/provider/FragmentResponseModeProviderTest.java b/components/org.wso2.carbon.identity.oauth/src/test/java/org/wso2/carbon/identity/oauth2/responsemode/provider/FragmentResponseModeProviderTest.java
deleted file mode 100644
index 9d39d97e75b..00000000000
--- a/components/org.wso2.carbon.identity.oauth/src/test/java/org/wso2/carbon/identity/oauth2/responsemode/provider/FragmentResponseModeProviderTest.java
+++ /dev/null
@@ -1,49 +0,0 @@
-package org.wso2.carbon.identity.oauth2.responsemode.provider;
-
-import org.testng.Assert;
-import org.testng.annotations.Test;
-import org.testng.annotations.DataProvider;
-import org.wso2.carbon.identity.oauth2.responsemode.provider.impl.FragmentResponseModeProvider;
-
-public class FragmentResponseModeProviderTest {
-
- @DataProvider(name = "authorizationResponseDTOProvider")
- private Object[][] authorizationResponseDTOProvider() {
-
- return new Object[][] {
- // AuthorizationResponseDTO, expected redirect url
- {getAuthResponseDTO("https://www.google.com/redirects/redirect1", "code1"),
- "https://www.google.com/redirects/redirect1#code=code1"},
- {getAuthResponseDTO("https://www.google.com/redirects/redirect2?param1=abc¶m2=xyz",
- "code2"), "https://www.google.com/redirects/redirect2?param1=abc¶m2=xyz#code=code2"},
-
- };
- }
-
- @Test(dataProvider = "authorizationResponseDTOProvider", description = "Test whether the redirect url generated by " +
- "the ResponseModeProvider is correct.")
- public void testRedirectUrl(AuthorizationResponseDTO authorizationResponseDTO, String expectedRedirectUrl){
-
- String redirectUrl = new FragmentResponseModeProvider().getAuthResponseRedirectUrl(authorizationResponseDTO);
-
- Assert.assertTrue(redirectUrl.contains(authorizationResponseDTO.getRedirectUrl()), "Redirect url does not " +
- "contain the callback url provided in the AuthorizationResponseDTO.");
- Assert.assertTrue(redirectUrl.contains("#"), "Redirect url does not contain a fragment part.");
- Assert.assertTrue(redirectUrl.contains("code="), "Redirect url does not contain the authorization code.");
- Assert.assertEquals(redirectUrl, expectedRedirectUrl, "Redirect url is not as expected.");
- }
-
- /**
- * This method creates and returns dummy AuthorizationResponseDTO instance.
- * @return AuthorizationResponseDTO DTO
- */
- private AuthorizationResponseDTO getAuthResponseDTO(String redirectURI, String code){
-
- AuthorizationResponseDTO authorizationResponseDTO = new AuthorizationResponseDTO();
- authorizationResponseDTO.setRedirectUrl(redirectURI);
-
- authorizationResponseDTO.getSuccessResponseDTO().setAuthorizationCode(code);
-
- return authorizationResponseDTO;
- }
-}
diff --git a/components/org.wso2.carbon.identity.oauth/src/test/java/org/wso2/carbon/identity/oauth2/responsemode/provider/ResponseModeProviderTest.java b/components/org.wso2.carbon.identity.oauth/src/test/java/org/wso2/carbon/identity/oauth2/responsemode/provider/ResponseModeProviderTest.java
new file mode 100644
index 00000000000..20887d0ab35
--- /dev/null
+++ b/components/org.wso2.carbon.identity.oauth/src/test/java/org/wso2/carbon/identity/oauth2/responsemode/provider/ResponseModeProviderTest.java
@@ -0,0 +1,90 @@
+package org.wso2.carbon.identity.oauth2.responsemode.provider;
+
+import org.testng.Assert;
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
+import org.wso2.carbon.identity.oauth2.responsemode.provider.impl.FragmentResponseModeProvider;
+import org.wso2.carbon.identity.oauth2.responsemode.provider.impl.QueryResponseModeProvider;
+
+import java.util.Arrays;
+import java.util.HashSet;
+
+public class ResponseModeProviderTest {
+
+ @DataProvider(name = "fragmentDataProvider")
+ private Object[][] fragmentDataProvider() {
+
+ return new Object[][] {
+ // AuthorizationResponseDTO, provided callback url, expected redirect url
+ {getAuthResponseDTO("https://www.google.com/redirects/redirect1", "code1"),
+ "https://www.google.com/redirects/redirect1",
+ "https://www.google.com/redirects/redirect1#code=code1&scope=openid"},
+ {getAuthResponseDTO("https://www.google.com/redirects/redirect2?param1=abc¶m2=xyz",
+ "code2"),
+ "https://www.google.com/redirects/redirect2?param1=abc¶m2=xyz",
+ "https://www.google.com/redirects/redirect2?param1=abc¶m2=xyz#code=code2&scope=openid"},
+
+ };
+ }
+
+ @Test(dataProvider = "fragmentDataProvider", description = "Test whether the redirect url generated " +
+ "by the FragmentResponseModeProvider is correct.")
+ public void testFragmentRedirectUrl(AuthorizationResponseDTO authorizationResponseDTO, String callbackUrl,
+ String expectedRedirectUrl) {
+
+ FragmentResponseModeProvider fragmentResponseModeProvider = new FragmentResponseModeProvider();
+ String redirectUrl = fragmentResponseModeProvider.getAuthResponseRedirectUrl(authorizationResponseDTO);
+
+ Assert.assertTrue(redirectUrl.contains(callbackUrl), "Redirect url does not " +
+ "contain the callback url provided.");
+ Assert.assertTrue(redirectUrl.contains("#"), "Redirect url does not contain a fragment part.");
+ Assert.assertTrue(redirectUrl.contains("code="), "Redirect url does not contain the authorization code.");
+ Assert.assertEquals(redirectUrl, expectedRedirectUrl, "Redirect url is not as expected.");
+ }
+
+ @DataProvider(name = "queryDataProvider")
+ private Object[][] queryDataProvider() {
+
+ return new Object[][] {
+ // AuthorizationResponseDTO, provided callback url, expected redirect url
+ {getAuthResponseDTO("https://www.google.com/redirects/redirect1", "code1"),
+ "https://www.google.com/redirects/redirect1",
+ "https://www.google.com/redirects/redirect1?code=code1&scope=openid"},
+ {getAuthResponseDTO("https://www.google.com/redirects/redirect2?param1=abc¶m2=xyz",
+ "code2"),
+ "https://www.google.com/redirects/redirect2?param1=abc¶m2=xyz",
+ "https://www.google.com/redirects/redirect2?param1=abc¶m2=xyz&code=code2&scope=openid"},
+
+ };
+ }
+
+ @Test(dataProvider = "queryDataProvider", description = "Test whether the redirect url generated " +
+ "by the QueryResponseModeProvider is correct.")
+ public void testQueryRedirectUrl(AuthorizationResponseDTO authorizationResponseDTO, String callbackUrl,
+ String expectedRedirectUrl) {
+
+ QueryResponseModeProvider queryResponseModeProvider = new QueryResponseModeProvider();
+ String redirectUrl = queryResponseModeProvider.getAuthResponseRedirectUrl(authorizationResponseDTO);
+
+ Assert.assertTrue(redirectUrl.contains(callbackUrl), "Redirect url does not " +
+ "contain the callback url provided.");
+ Assert.assertTrue(redirectUrl.contains("?"), "Redirect url does not contain a query part.");
+ Assert.assertTrue(redirectUrl.contains("code="), "Redirect url does not contain the authorization code.");
+ Assert.assertEquals(redirectUrl, expectedRedirectUrl, "Redirect url is not as expected.");
+ }
+
+ /**
+ * This method creates and returns dummy AuthorizationResponseDTO instance.
+ * @return AuthorizationResponseDTO DTO
+ */
+ private AuthorizationResponseDTO getAuthResponseDTO(String redirectURI, String code) {
+
+ AuthorizationResponseDTO authorizationResponseDTO = new AuthorizationResponseDTO();
+ authorizationResponseDTO.setRedirectUrl(redirectURI);
+
+ authorizationResponseDTO.getSuccessResponseDTO().setAuthorizationCode(code);
+ authorizationResponseDTO.getSuccessResponseDTO().setScope(new HashSet<>(Arrays.asList("openid")));
+
+ return authorizationResponseDTO;
+ }
+}
diff --git a/components/org.wso2.carbon.identity.oauth/src/test/resources/testng.xml b/components/org.wso2.carbon.identity.oauth/src/test/resources/testng.xml
index 17d967b2712..49fa3415b4e 100644
--- a/components/org.wso2.carbon.identity.oauth/src/test/resources/testng.xml
+++ b/components/org.wso2.carbon.identity.oauth/src/test/resources/testng.xml
@@ -113,6 +113,7 @@
+