Skip to content

Commit d30eb24

Browse files
committed
move some tests from blocked Facebook to vk.com to simplify release testing
1 parent f8f9587 commit d30eb24

File tree

5 files changed

+24
-22
lines changed

5 files changed

+24
-22
lines changed

scribejava-apis/src/test/java/com/github/scribejava/apis/examples/FacebookAsyncApacheExample.java renamed to scribejava-apis/src/test/java/com/github/scribejava/apis/examples/VkontakteAsyncApacheExample.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import java.util.Random;
44
import java.util.Scanner;
55
import java.util.concurrent.ExecutionException;
6-
import com.github.scribejava.apis.FacebookApi;
6+
import com.github.scribejava.apis.VkontakteApi;
77
import com.github.scribejava.core.builder.ServiceBuilder;
88
import com.github.scribejava.core.model.OAuth2AccessToken;
99
import com.github.scribejava.core.model.OAuthRequest;
@@ -13,12 +13,13 @@
1313
import com.github.scribejava.httpclient.apache.ApacheHttpClientConfig;
1414
import java.io.IOException;
1515

16-
public class FacebookAsyncApacheExample {
16+
public class VkontakteAsyncApacheExample {
1717

18-
private static final String NETWORK_NAME = "Facebook";
19-
private static final String PROTECTED_RESOURCE_URL = "https://graph.facebook.com/v3.2/me";
18+
private static final String NETWORK_NAME = "vk.com";
19+
private static final String PROTECTED_RESOURCE_URL = "https://api.vk.com/method/users.get?v="
20+
+ VkontakteApi.VERSION;
2021

21-
private FacebookAsyncApacheExample() {
22+
private VkontakteAsyncApacheExample() {
2223
}
2324

2425
@SuppressWarnings("PMD.SystemPrintln")
@@ -28,11 +29,11 @@ public static void main(String... args) throws InterruptedException, ExecutionEx
2829
final String clientSecret = "your client secret";
2930
final String secretState = "secret" + new Random().nextInt(999_999);
3031

31-
try (OAuth20Service service = new ServiceBuilder(clientId)
32+
try ( OAuth20Service service = new ServiceBuilder(clientId)
3233
.apiSecret(clientSecret)
3334
.callback("http://www.example.com/oauth_callback/")
3435
.httpClientConfig(ApacheHttpClientConfig.defaultConfig())
35-
.build(FacebookApi.instance())) {
36+
.build(VkontakteApi.instance())) {
3637
final Scanner in = new Scanner(System.in, "UTF-8");
3738

3839
System.out.println("=== " + NETWORK_NAME + "'s Async OAuth Workflow ===");
@@ -73,7 +74,7 @@ public static void main(String... args) throws InterruptedException, ExecutionEx
7374
System.out.println("Now we're going to access a protected resource...");
7475
final OAuthRequest request = new OAuthRequest(Verb.GET, PROTECTED_RESOURCE_URL);
7576
service.signRequest(accessToken, request);
76-
try (Response response = service.execute(request)) {
77+
try ( Response response = service.execute(request)) {
7778
System.out.println("Got it! Lets see what we found...");
7879
System.out.println();
7980
System.out.println(response.getCode());

scribejava-apis/src/test/java/com/github/scribejava/apis/examples/FacebookAsyncNingExample.java renamed to scribejava-apis/src/test/java/com/github/scribejava/apis/examples/VkontakteAsyncNingExample.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import java.util.Random;
66
import java.util.Scanner;
77
import java.util.concurrent.ExecutionException;
8-
import com.github.scribejava.apis.FacebookApi;
8+
import com.github.scribejava.apis.VkontakteApi;
99
import com.github.scribejava.core.builder.ServiceBuilder;
1010
import com.github.scribejava.core.model.OAuth2AccessToken;
1111
import com.github.scribejava.core.model.OAuthRequest;
@@ -14,12 +14,13 @@
1414
import com.github.scribejava.core.oauth.OAuth20Service;
1515
import java.io.IOException;
1616

17-
public class FacebookAsyncNingExample {
17+
public class VkontakteAsyncNingExample {
1818

19-
private static final String NETWORK_NAME = "Facebook";
20-
private static final String PROTECTED_RESOURCE_URL = "https://graph.facebook.com/v3.2/me";
19+
private static final String NETWORK_NAME = "vk.com";
20+
private static final String PROTECTED_RESOURCE_URL = "https://api.vk.com/method/users.get?v="
21+
+ VkontakteApi.VERSION;
2122

22-
private FacebookAsyncNingExample() {
23+
private VkontakteAsyncNingExample() {
2324
}
2425

2526
@SuppressWarnings("PMD.SystemPrintln")
@@ -36,11 +37,11 @@ public static void main(String... args) throws InterruptedException, ExecutionEx
3637
.setReadTimeout(1_000)
3738
.build());
3839

39-
try (OAuth20Service service = new ServiceBuilder(clientId)
40+
try ( OAuth20Service service = new ServiceBuilder(clientId)
4041
.apiSecret(clientSecret)
4142
.callback("http://www.example.com/oauth_callback/")
4243
.httpClientConfig(clientConfig)
43-
.build(FacebookApi.instance())) {
44+
.build(VkontakteApi.instance())) {
4445
final Scanner in = new Scanner(System.in, "UTF-8");
4546

4647
System.out.println("=== " + NETWORK_NAME + "'s Async OAuth Workflow ===");
@@ -81,7 +82,7 @@ public static void main(String... args) throws InterruptedException, ExecutionEx
8182
System.out.println("Now we're going to access a protected resource...");
8283
final OAuthRequest request = new OAuthRequest(Verb.GET, PROTECTED_RESOURCE_URL);
8384
service.signRequest(accessToken, request);
84-
try (Response response = service.execute(request)) {
85+
try ( Response response = service.execute(request)) {
8586
System.out.println("Got it! Lets see what we found...");
8687
System.out.println();
8788
System.out.println(response.getCode());

scribejava-apis/src/test/java/com/github/scribejava/apis/examples/VkontakteClientCredentialsGrantExample.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
public class VkontakteClientCredentialsGrantExample {
1111

12-
private static final String NETWORK_NAME = "Vkontakte.ru";
12+
private static final String NETWORK_NAME = "vk.com>";
1313

1414
private VkontakteClientCredentialsGrantExample() {
1515
}

scribejava-apis/src/test/java/com/github/scribejava/apis/examples/VkontakteExample.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
public class VkontakteExample {
1717

18-
private static final String NETWORK_NAME = "Vkontakte.ru";
18+
private static final String NETWORK_NAME = "vk.com";
1919
private static final String PROTECTED_RESOURCE_URL = "https://api.vk.com/method/users.get?v="
2020
+ VkontakteApi.VERSION;
2121

@@ -66,7 +66,7 @@ public static void main(String... args) throws IOException, InterruptedException
6666
System.out.println("Now we're going to access a protected resource...");
6767
final OAuthRequest request = new OAuthRequest(Verb.GET, PROTECTED_RESOURCE_URL);
6868
service.signRequest(accessToken, request);
69-
try (Response response = service.execute(request)) {
69+
try ( Response response = service.execute(request)) {
7070
System.out.println("Got it! Lets see what we found...");
7171
System.out.println();
7272
System.out.println(response.getCode());

scribejava-apis/src/test/java/com/github/scribejava/apis/examples/VkontakteExternalHttpExample.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
public class VkontakteExternalHttpExample {
1818

19-
private static final String NETWORK_NAME = "Vkontakte.ru";
19+
private static final String NETWORK_NAME = "vk.com";
2020
private static final String PROTECTED_RESOURCE_URL = "https://api.vk.com/method/users.get?v="
2121
+ VkontakteApi.VERSION;
2222

@@ -37,7 +37,7 @@ public static void main(String... args) throws IOException, InterruptedException
3737
.setReadTimeout(1_000)
3838
.build();
3939
//wrap it
40-
try (DefaultAsyncHttpClient ahcHttpClient = new DefaultAsyncHttpClient(httpClientConfig)) {
40+
try ( DefaultAsyncHttpClient ahcHttpClient = new DefaultAsyncHttpClient(httpClientConfig)) {
4141
//wrap it
4242
final AhcHttpClient wrappedAHCHttpClient = new AhcHttpClient(ahcHttpClient);
4343

@@ -74,7 +74,7 @@ public static void main(String... args) throws IOException, InterruptedException
7474
System.out.println("Now we're going to access a protected resource...");
7575
final OAuthRequest request = new OAuthRequest(Verb.GET, PROTECTED_RESOURCE_URL);
7676
service.signRequest(accessToken, request);
77-
try (Response response = service.execute(request)) {
77+
try ( Response response = service.execute(request)) {
7878
System.out.println("Got it! Lets see what we found...");
7979
System.out.println();
8080
System.out.println(response.getCode());

0 commit comments

Comments
 (0)