Package facebook4j.conf

Examples of facebook4j.conf.ConfigurationBuilder


    protected MockFacebook facebook;

    @Before
    public void setUp() throws Exception {
        Configuration conf = new ConfigurationBuilder().setJSONStoreEnabled(true).build();
        facebook = MockFacebookFactory.create(conf);
        facebook.setOAuthAppId("mock", "json");
        facebook.setOAuthAccessToken(new AccessToken("required"));
    }
View Full Code Here


    // cached FaceBook instance, is created in getFacebook by endpoint producers and consumers
    private Facebook facebook;

    public Configuration getConfiguration() {
        final ConfigurationBuilder builder = new ConfigurationBuilder();
        // apply builder settings

        if (oAuthAccessToken != null) {
            builder.setOAuthAccessToken(oAuthAccessToken);
        }
        if (oAuthAccessTokenURL != null) {
            builder.setOAuthAccessTokenURL(oAuthAccessTokenURL);
        }
        if (oAuthAppId != null) {
            builder.setOAuthAppId(oAuthAppId);
        }
        if (oAuthAppSecret != null) {
            builder.setOAuthAppSecret(oAuthAppSecret);
        }
        if (oAuthAuthorizationURL != null) {
            builder.setOAuthAuthorizationURL(oAuthAuthorizationURL);
        }
        if (oAuthPermissions != null) {
            builder.setOAuthPermissions(oAuthPermissions);
        }

        if (clientURL != null) {
            builder.setClientURL(clientURL);
        }
        if (clientVersion != null) {
            builder.setClientVersion(clientVersion);
        }
        if (debugEnabled != null) {
            builder.setDebugEnabled(debugEnabled);
        }
        if (gzipEnabled != null) {
            builder.setGZIPEnabled(gzipEnabled);
        }
        if (httpConnectionTimeout != null) {
            builder.setHttpConnectionTimeout(httpConnectionTimeout);
        }
        if (httpDefaultMaxPerRoute != null) {
            builder.setHttpDefaultMaxPerRoute(httpDefaultMaxPerRoute);
        }
        if (httpMaxTotalConnections != null) {
            builder.setHttpMaxTotalConnections(httpMaxTotalConnections);
        }
        if (httpProxyHost != null) {
            builder.setHttpProxyHost(httpProxyHost);
        }
        if (httpProxyPassword != null) {
            builder.setHttpProxyPassword(httpProxyPassword);
        }
        if (httpProxyPort != null) {
            builder.setHttpProxyPort(httpProxyPort);
        }
        if (httpProxyUser != null) {
            builder.setHttpProxyUser(httpProxyUser);
        }
        if (httpReadTimeout != null) {
            builder.setHttpReadTimeout(httpReadTimeout);
        }
        if (httpRetryCount != null) {
            builder.setHttpRetryCount(httpRetryCount);
        }
        if (httpRetryIntervalSeconds != null) {
            builder.setHttpRetryIntervalSeconds(httpRetryIntervalSeconds);
        }
        if (httpStreamingReadTimeout != null) {
            builder.setHttpStreamingReadTimeout(httpStreamingReadTimeout);
        }
        if (jsonStoreEnabled != null) {
            builder.setJSONStoreEnabled(jsonStoreEnabled);
        }
        if (mbeanEnabled != null) {
            builder.setMBeanEnabled(mbeanEnabled);
        }
        if (prettyDebugEnabled != null) {
            builder.setPrettyDebugEnabled(prettyDebugEnabled);
        }
        if (restBaseURL != null) {
            builder.setRestBaseURL(restBaseURL);
        }
        if (useSSL != null) {
            builder.setUseSSL(useSSL);
        }
        if (videoBaseURL != null) {
            builder.setVideoBaseURL(videoBaseURL);
        }

        return builder.build();
    }
View Full Code Here

    }

    @Category(RealAPITests.class)
    @Test
    public void OAuth() throws Exception {
        ConfigurationBuilder build = new ConfigurationBuilder();
        String oAuthAccessToken = p.getProperty("oauth.accessToken");
        String oAuthAppId = p.getProperty("oauth.appId");
        String oAuthAppSecret = p.getProperty("oauth.appSecret");
        build.setOAuthAccessToken(oAuthAccessToken);
        build.setOAuthAppId(oAuthAppId);
        build.setOAuthAppSecret(oAuthAppSecret);
        OAuthAuthorization auth = new OAuthAuthorization(build.build());
        Facebook fb = new FacebookFactory().getInstance(auth);
        fb.getId();
    }
View Full Code Here

    @Test
    public void accessToken_res() throws Exception {
        String appId = p.getProperty("oauth.appId");
        String appSecret = p.getProperty("oauth.appSecret");

        ConfigurationBuilder build = new ConfigurationBuilder();
        build.setOAuthAppId(appId);
        build.setOAuthAppSecret(appSecret);
        Configuration configuration = build.build();
        HttpClientWrapper http = new HttpClientWrapper(configuration);
        HttpResponse res = http.get(configuration.getOAuthAccessTokenURL() +
                "?client_id=" + appId +
                "&client_secret=" + appSecret +
                "&grant_type=client_credentials");
View Full Code Here

public class OAuthAuthorizationTest {

    public static class AppSecretProof {
        @Test
        public void defaultCacheSize() throws Exception {
            Configuration conf = new ConfigurationBuilder()
                    .setAppSecretProofEnabled(true)
                    .setOAuthAppSecret("1234567890123456")
                    .build();
            OAuthAuthorization auth = new OAuthAuthorization(conf);
            auth.setOAuthAccessToken(new AccessToken("access_token1"));
View Full Code Here

            assertThat(reComputedProof2, is(not(proof2)));   // re-computed
        }

        @Test
        public void customCacheSize() throws Exception {
            Configuration conf = new ConfigurationBuilder()
                    .setAppSecretProofEnabled(true)
                    .setOAuthAppSecret("1234567890123456")
                    .setAppSecretProofCacheSize(3)
                    .build();
            OAuthAuthorization auth = new OAuthAuthorization(conf);
View Full Code Here

        public void get() throws Exception {
            RequestMethod method = RequestMethod.GET;
            String url = "https://graph.facebook.com/foo/bar";
            HttpParameter[] parameters = new HttpParameter[1];
            parameters[0] = new HttpParameter("hoge", "1");
            ConfigurationBuilder cb = new ConfigurationBuilder().setOAuthAccessToken("access_token");
            OAuthAuthorization authorization = new OAuthAuthorization(cb.build());
            Map<String, String> requestHeaders = new HashMap<String, String>();

            HttpRequest actual = new HttpRequest(method, url, parameters, authorization, requestHeaders);
            assertThat(new URL(actual.getURL()), is(pathOf("/foo/bar")));
            assertThat(new URL(actual.getURL()), hasParameter("access_token", "access_token"));
View Full Code Here

        public void post() throws Exception {
            RequestMethod method = RequestMethod.POST;
            String url = "https://graph.facebook.com/foo/bar";
            HttpParameter[] parameters = new HttpParameter[1];
            parameters[0] = new HttpParameter("hoge", "1");
            ConfigurationBuilder cb = new ConfigurationBuilder().setOAuthAccessToken("access_token");
            OAuthAuthorization authorization = new OAuthAuthorization(cb.build());
            Map<String, String> requestHeaders = new HashMap<String, String>();

            HttpRequest actual = new HttpRequest(method, url, parameters, authorization, requestHeaders);
            assertThat(actual.getURL(), is("https://graph.facebook.com/foo/bar"));
            assertThat(actual.getParameters().length, is(2));
View Full Code Here

        public void get() throws Exception {
            RequestMethod method = RequestMethod.GET;
            String url = "https://graph.facebook.com/foo/bar";
            HttpParameter[] parameters = new HttpParameter[1];
            parameters[0] = new HttpParameter("hoge", "1");
            ConfigurationBuilder cb = new ConfigurationBuilder()
                                        .setAppSecretProofEnabled(true)
                                        .setOAuthAppSecret("1234567890123456")
                                        .setOAuthAccessToken("access_token");
            OAuthAuthorization authorization = new OAuthAuthorization(cb.build());
            Map<String, String> requestHeaders = new HashMap<String, String>();

            HttpRequest actual = new HttpRequest(method, url, parameters, authorization, requestHeaders);
            assertThat(new URL(actual.getURL()), is(pathOf("/foo/bar")));
            assertThat(new URL(actual.getURL()), hasParameter("access_token", "access_token"));
View Full Code Here

        public void post() throws Exception {
            RequestMethod method = RequestMethod.POST;
            String url = "https://graph.facebook.com/foo/bar";
            HttpParameter[] parameters = new HttpParameter[1];
            parameters[0] = new HttpParameter("hoge", "1");
            ConfigurationBuilder cb = new ConfigurationBuilder()
                                        .setAppSecretProofEnabled(true)
                                        .setOAuthAppSecret("1234567890123456")
                                        .setOAuthAccessToken("access_token");
            OAuthAuthorization authorization = new OAuthAuthorization(cb.build());
            Map<String, String> requestHeaders = new HashMap<String, String>();

            HttpRequest actual = new HttpRequest(method, url, parameters, authorization, requestHeaders);
            assertThat(actual.getURL(), is("https://graph.facebook.com/foo/bar"));
            assertThat(actual.getParameters().length, is(3));
View Full Code Here

TOP

Related Classes of facebook4j.conf.ConfigurationBuilder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.