Android Open Source - klarna-on-demand-android Context Test






From Project

Back to project page klarna-on-demand-android.

License

The source code is released under:

Apache License

If you think the Android project klarna-on-demand-android listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.klarna.ondemand;
//w  ww.  ja  v  a2s  .c o m
import junit.framework.TestCase;
import java.lang.RuntimeException;

public class ContextTest extends TestCase {

    @Override
    protected void setUp() throws java.lang.Exception {
        Context.setApiKey(null);
    }

    public void testSetApiKey(){
        String apiKey = "my_key";
        Context.setApiKey(apiKey);

        assertEquals(Context.getApiKey(), apiKey);
    }

    public void testGetApiKeyShouldThrowExceptionWhenThereIsNoApiKey() {
        try {
            Context.getApiKey();
            fail("Exception not thrown");
        }
        catch(RuntimeException e) {
            assertEquals(e.getMessage(), "You must set the API key first.");
        }
    }
}




Java Source Code List

com.klarna.example.ApplicationTest.java
com.klarna.example.MainActivity.java
com.klarna.ondemand.ContextTest.java
com.klarna.ondemand.Context.java
com.klarna.ondemand.RegistrationActivity.java
com.klarna.ondemand.UrlHelperTest.java
com.klarna.ondemand.UrlHelper.java
com.klarna.ondemand.WebViewActivity.java
com.klarna.ondemand.package-info.java