@@ -0,0 +1,3170 @@
+/*%0A  Copyright 2012 - 2014 Jerome Leleu%0A%0A   Licensed under the Apache License, Version 2.0 (the %22License%22);%0A   you may not use this file except in compliance with the License.%0A   You may obtain a copy of the License at%0A%0A       http://www.apache.org/licenses/LICENSE-2.0%0A%0A   Unless required by applicable law or agreed to in writing, software%0A   distributed under the License is distributed on an %22AS IS%22 BASIS,%0A   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A   See the License for the specific language governing permissions and%0A   limitations under the License.%0A */%0Apackage org.pac4j.oauth.client;%0A%0Aimport com.esotericsoftware.kryo.Kryo;%0Aimport com.gargoylesoftware.htmlunit.WebClient;%0Aimport com.gargoylesoftware.htmlunit.html.HtmlButton;%0Aimport com.gargoylesoftware.htmlunit.html.HtmlForm;%0Aimport com.gargoylesoftware.htmlunit.html.HtmlPage;%0Aimport com.gargoylesoftware.htmlunit.html.HtmlPasswordInput;%0Aimport com.gargoylesoftware.htmlunit.html.HtmlTextInput;%0Aimport static junit.framework.Assert.assertEquals;%0Aimport org.pac4j.core.client.Client;%0Aimport org.pac4j.core.profile.UserProfile;%0Aimport org.pac4j.oauth.profile.bitbucket.BitbucketProfile;%0A%0A/**%0A * This class tests the %7B@link BitbucketClient%7D class by simulating a complete %0A * authentication.%0A *%0A * @author Sebastian Sdorra%0A * @since 1.5.1%0A */%0Apublic class TestBitbucketClient extends TestOAuthClient %7B%0A%0A    @Override%0A    protected Client getClient() %7B%0A        BitbucketClient client = new BitbucketClient();%0A        client.setKey(%22bjEt8BMpLwFDqZUvp6%22);%0A        client.setSecret(%22NN6fVXRTcV2qYVejVLZqxBRqHgn3ygD4%22);%0A        client.setCallbackUrl(PAC4J_BASE_URL);%0A        return client;%0A    %7D%0A%0A    @Override%0A    protected String getCallbackUrl(WebClient webClient, HtmlPage authorizationPage) throws Exception %7B%0A        HtmlForm form = authorizationPage.getHtmlElementById(%22login-form%22);%0A        HtmlTextInput username = form.getInputByName(%22username%22);%0A        username.setValueAttribute(%22testscribeup%22);%0A        HtmlPasswordInput password = form.getInputByName(%22password%22);%0A        password.setValueAttribute(%22testpwdscribeup78%22);%0A        HtmlButton submit = form.getButtonByName(%22submit%22);%0A        HtmlPage callbackPage = submit.click();%0A        final String callbackUrl = callbackPage.getUrl().toString();%0A        logger.debug(%22callbackUrl : %7B%7D%22, callbackUrl);%0A        return callbackUrl;%0A    %7D%0A%0A    @Override%0A    protected void verifyProfile(UserProfile userProfile) %7B%0A        BitbucketProfile profile = (BitbucketProfile) userProfile;%0A        assertEquals(%22testscribeup%22, profile.getUsername());%0A        assertEquals(%22Test%22, profile.getFirstName());%0A        assertEquals(%22Scribeup%22, profile.getFamilyName());%0A        assertEquals(%22Test Scribeup%22, profile.getDisplayName());%0A        assertFalse(profile.isTeam());%0A        assertEquals(%22https://bitbucket-assetroot.s3.amazonaws.com/c/photos/2014/Apr/29/testscribeup-avatar-2548548378-2_avatar.png%22, profile.getPictureUrl());%0A        assertEquals(%22/1.0/users/testscribeup%22, profile.getProfileUrl());%0A    %7D%0A%0A    @Override%0A    protected void registerForKryo(Kryo kryo) %7B%0A        kryo.register(BitbucketProfile.class);%0A    %7D%0A%0A%7D%0A

implement unit test for bitbucket client