diff --git a/circle.yml b/circle.yml index 4db5d9b..a3d6fff 100644 --- a/circle.yml +++ b/circle.yml @@ -16,5 +16,5 @@ test: # copy the build outputs to artifacts - cp -r lib/build/outputs $CIRCLE_ARTIFACTS # copy the test results to the test results directory. - #- cp -r lib/build/outputs/androidTest-results/* $CIRCLE_TEST_REPORTS + - cp -r lib/build/test-results/* $CIRCLE_TEST_REPORTS diff --git a/lib/build.gradle b/lib/build.gradle index a101cd4..8372fef 100644 --- a/lib/build.gradle +++ b/lib/build.gradle @@ -1,12 +1,13 @@ apply plugin: 'com.android.library' android { - compileSdkVersion 22 + compileSdkVersion 21 buildToolsVersion "21.1.2" defaultConfig { minSdkVersion 8 - targetSdkVersion 22 + targetSdkVersion 21 + versionName "1.8" } buildTypes { diff --git a/lib/src/main/java/jp/mixi/android/sdk/Constants.java b/lib/src/main/java/jp/mixi/android/sdk/Constants.java index 2eca87c..1391199 100644 --- a/lib/src/main/java/jp/mixi/android/sdk/Constants.java +++ b/lib/src/main/java/jp/mixi/android/sdk/Constants.java @@ -33,7 +33,7 @@ class Constants { /** android2.2のSDKバージョン番号 */ static final int SUPPORTED_SDK_VERSION = 8; /** mixiAndroidSDKのバージョン番号 */ - static final String VERSION = "1.8"; + static final String VERSION = BuildConfig.VERSION_NAME; /** SDKからアクセスする際のユーザーエージェント */ static final String USER_AGENT = System.getProperties().getProperty("http.agent") + " mixi-Android-SDK/" + VERSION; diff --git a/lib/src/test/java/jp/mixi/android/sdk/ConfigTest.java b/lib/src/test/java/jp/mixi/android/sdk/ConfigTest.java new file mode 100644 index 0000000..3cd7a47 --- /dev/null +++ b/lib/src/test/java/jp/mixi/android/sdk/ConfigTest.java @@ -0,0 +1,30 @@ +package jp.mixi.android.sdk; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.robolectric.RobolectricGradleTestRunner; + +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.CoreMatchers.nullValue; +import static org.junit.Assert.assertThat; + +/** + * Created by Hideyuki.Kikuma on 15/08/25. + */ +@RunWith(RobolectricGradleTestRunner.class) +@org.robolectric.annotation.Config(constants = BuildConfig.class) +public class ConfigTest { + + private static final int DEFAULT_CONNECTION_TIMEOUT = 20000; + private static final int DEFAULT_SOCKET_TIMEOUT = 20000; + + @Test + public void defaultConfig() { + Config config = new Config(); + assertThat(config.selector, is(Config.APPLICATION)); + assertThat(config.clientId, is(nullValue())); + assertThat(config.connectionTimeout, is(DEFAULT_CONNECTION_TIMEOUT)); + assertThat(config.socketTimeout, is(DEFAULT_SOCKET_TIMEOUT)); + assertThat(config.version, is(BuildConfig.VERSION_NAME)); + } +} \ No newline at end of file diff --git a/lib/src/test/java/jp/mixi/android/sdk/ConstantsTest.java b/lib/src/test/java/jp/mixi/android/sdk/ConstantsTest.java new file mode 100644 index 0000000..1634e3f --- /dev/null +++ b/lib/src/test/java/jp/mixi/android/sdk/ConstantsTest.java @@ -0,0 +1,56 @@ +package jp.mixi.android.sdk; + +import android.os.Build; + +import org.junit.After; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.robolectric.RobolectricGradleTestRunner; +import org.robolectric.annotation.Config; + +import static org.hamcrest.CoreMatchers.is; +import static org.junit.Assert.assertThat; + +/** + * Created by Hideyuki.Kikuma on 15/08/25. + */ +@RunWith(RobolectricGradleTestRunner.class) +@Config(constants = BuildConfig.class) +public class ConstantsTest { + private static final String AGENT_PROPERTY_NAME = "http.agent"; + private static final String AGENT_PROPERTY_VALUE = "testAgent"; + + @BeforeClass + public static void testSetUp() { + System.getProperties().setProperty(AGENT_PROPERTY_NAME, AGENT_PROPERTY_VALUE); + } + + @Before + public void setUp() throws Exception { + + } + + @After + public void tearDown() throws Exception { + + } + + @Test + public void testSUPPORTED_SDK_VERSION() throws Exception { + assertThat(Constants.SUPPORTED_SDK_VERSION, is(Build.VERSION_CODES.FROYO)); + } + + @Test + public void testVERSION() throws Exception { + assertThat(Constants.VERSION, is(BuildConfig.VERSION_NAME)); + } + + @Test + public void testUSER_AGENT() throws Exception { + assertThat(Constants.USER_AGENT, is(AGENT_PROPERTY_VALUE + " mixi-Android-SDK/" + BuildConfig.VERSION_NAME)); + + } + +}