diff options
author | Paul Duffin <paulduffin@google.com> | 2017-03-07 15:21:33 +0000 |
---|---|---|
committer | Paul Duffin <paulduffin@google.com> | 2017-03-08 11:00:52 +0000 |
commit | 4302006f904d6f8623062ea4f16d3a1822684f6d (patch) | |
tree | 08808d233d15de485ef9b1033ee6f7c80dcff951 /tck-android | |
parent | 3c95c88031b5e7d709598fe86a036704c12e121a (diff) | |
download | objenesis-4302006f904d6f8623062ea4f16d3a1822684f6d.tar.gz |
Update to 2.5
Updated using ./update_source.sh 2.5
Bug: 32912773
Test: Does not build yet; see following commit
Change-Id: I88f6252c2b17ea6c69255e7a607678fc9fa541a5
Diffstat (limited to 'tck-android')
-rw-r--r-- | tck-android/.settings/org.eclipse.jdt.core.prefs | 5 | ||||
-rw-r--r-- | tck-android/AndroidManifest.xml | 35 | ||||
-rw-r--r-- | tck-android/pom.xml | 249 | ||||
-rw-r--r-- | tck-android/src/main/java/org/objenesis/tck/android/ObjenesisTest.java | 92 | ||||
-rw-r--r-- | tck-android/src/main/java/org/objenesis/tck/android/TckInstrumentation.java | 21 |
5 files changed, 272 insertions, 130 deletions
diff --git a/tck-android/.settings/org.eclipse.jdt.core.prefs b/tck-android/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index abec6ca..0000000 --- a/tck-android/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,5 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 -org.eclipse.jdt.core.compiler.compliance=1.5 -org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning -org.eclipse.jdt.core.compiler.source=1.5 diff --git a/tck-android/AndroidManifest.xml b/tck-android/AndroidManifest.xml index b17fbbc..61ef6af 100644 --- a/tck-android/AndroidManifest.xml +++ b/tck-android/AndroidManifest.xml @@ -1,21 +1,21 @@ <?xml version="1.0" encoding="utf-8"?> - <!-- -Copyright 2006-2013 the original author or authors. -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at + Copyright 2006-2017 the original author or authors. - http://www.apache.org/licenses/LICENSE-2.0 + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. ---> + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> <!-- Describes an Android application with a single Instrumentation, which runs the Objenesis TCK. @@ -30,7 +30,7 @@ limitations under the License. <uses-sdk android:minSdkVersion="1" - android:targetSdkVersion="17" /> + android:targetSdkVersion="25" /> <application android:allowBackup="false"> <uses-library android:name="android.test.runner" /> @@ -38,6 +38,9 @@ limitations under the License. <instrumentation android:name=".TckInstrumentation" - android:targetPackage="org.objenesis.tck.android"> - </instrumentation> -</manifest>
\ No newline at end of file + android:targetPackage="org.objenesis.tck.android" /> + + <instrumentation android:name="android.test.InstrumentationTestRunner" + android:targetPackage="org.objenesis.tck.android" + android:label="Objenesis Android TCK."/> +</manifest> diff --git a/tck-android/pom.xml b/tck-android/pom.xml index abb64a1..46369e7 100644 --- a/tck-android/pom.xml +++ b/tck-android/pom.xml @@ -1,103 +1,146 @@ -<?xml version="1.0" encoding="ISO-8859-1"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.objenesis</groupId>
- <artifactId>objenesis-parent</artifactId>
- <version>2.0-SNAPSHOT</version>
- </parent>
- <artifactId>objenesis-tck-android</artifactId>
- <name>Objenesis Android TCK</name>
- <description>Objenesis' TCK built for Android devices</description>
- <packaging>apk</packaging>
-
- <dependencies>
- <dependency>
- <groupId>org.objenesis</groupId>
- <artifactId>objenesis-tck</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>com.google.android</groupId>
- <artifactId>android</artifactId>
- <version>1.5_r3</version>
- <scope>provided</scope>
- </dependency>
- </dependencies>
- <build>
- <sourceDirectory>src</sourceDirectory>
-
- <pluginManagement>
- <plugins>
- <plugin>
- <groupId>com.jayway.maven.plugins.android.generation2</groupId>
- <artifactId>android-maven-plugin</artifactId>
- <version>3.5.0</version>
- <extensions>true</extensions>
- </plugin>
- </plugins>
- </pluginManagement>
- <plugins>
- <plugin>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <source>1.5</source>
- <target>1.5</target>
- </configuration>
- </plugin>
-
- <plugin>
- <groupId>com.jayway.maven.plugins.android.generation2</groupId>
- <artifactId>android-maven-plugin</artifactId>
- <configuration>
- <sdk>
- <platform>17</platform>
- </sdk>
- </configuration>
- <extensions>true</extensions>
- </plugin>
-
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>exec-maven-plugin</artifactId>
- <version>1.2.1</version>
- <inherited>false</inherited>
- <executions>
- <execution>
- <id>install</id>
- <phase>integration-test</phase>
- <goals>
- <goal>exec</goal>
- </goals>
- <configuration>
- <executable>adb</executable>
- <arguments>
- <argument>install</argument>
- <argument>-r</argument>
- <argument>${project.build.directory}\${project.build.finalName}.apk</argument>
- </arguments>
- </configuration>
- </execution>
- <execution>
- <id>execute</id>
- <phase>integration-test</phase>
- <goals>
- <goal>exec</goal>
- </goals>
- <configuration>
- <executable>adb</executable>
- <arguments>
- <argument>shell</argument>
- <argument>am</argument>
- <argument>instrument</argument>
- <argument>-w</argument>
- <argument>org.objenesis.tck.android/.TckInstrumentation</argument>
- </arguments>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
-
-</project>
+<?xml version="1.0" encoding="ISO-8859-1"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.objenesis</groupId> + <artifactId>objenesis-parent</artifactId> + <version>2.5</version> + </parent> + <artifactId>objenesis-tck-android</artifactId> + <name>Objenesis Android TCK</name> + <description>Objenesis' TCK built for Android devices</description> + <packaging>apk</packaging> + + <properties> + <android.home>${env.ANDROID_HOME}</android.home> + </properties> + + <dependencies> + <dependency> + <groupId>org.objenesis</groupId> + <artifactId>objenesis</artifactId> + <version>${project.version}</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>${project.groupId}</groupId> + <artifactId>objenesis-tck</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>com.google.android</groupId> + <artifactId>android</artifactId> + <version>4.1.1.4</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>com.google.android</groupId> + <artifactId>android-test</artifactId> + <version>4.1.1.4</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <exclusions> + <exclusion> + <groupId>org.hamcrest</groupId> + <artifactId>hamcrest-core</artifactId> + </exclusion> + </exclusions> + </dependency> + </dependencies> + <build> + <pluginManagement> + <plugins> + <plugin> + <groupId>com.simpligility.maven.plugins</groupId> + <artifactId>android-maven-plugin</artifactId> + <version>4.4.3</version> + <extensions>true</extensions> + <configuration> + <testFailSafe>false</testFailSafe> + <test> + <instrumentationPackage>org.objenesis.tck.android</instrumentationPackage> + <instrumentationRunner>android.test.InstrumentationTestRunner</instrumentationRunner> + </test> + </configuration> + </plugin> + </plugins> + </pluginManagement> + + <plugins> + <plugin> + <artifactId>maven-compiler-plugin</artifactId> + <configuration> + <source>1.5</source> + <target>1.5</target> + </configuration> + </plugin> + + <plugin> + <groupId>com.keyboardsamurais.maven</groupId> + <artifactId>maven-timestamp-plugin</artifactId> + </plugin> + <plugin> + <groupId>com.mycila.maven-license-plugin</groupId> + <artifactId>maven-license-plugin</artifactId> + </plugin> + <plugin> + <artifactId>maven-remote-resources-plugin</artifactId> + </plugin> + + <plugin> + <groupId>com.simpligility.maven.plugins</groupId> + <artifactId>android-maven-plugin</artifactId> + <configuration> + <sdk> + <platform>25</platform> + </sdk> + </configuration> + <extensions>true</extensions> + </plugin> + + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>exec-maven-plugin</artifactId> + <inherited>false</inherited> + <executions> + <execution> + <id>execute</id> + <phase>integration-test</phase> + <goals> + <goal>exec</goal> + </goals> + <configuration> + <executable>${android.home}/platform-tools/adb</executable> + <arguments> + <argument>shell</argument> + <argument>am</argument> + <argument>instrument</argument> + <argument>-w</argument> + <argument>org.objenesis.tck.android/.TckInstrumentation</argument> + </arguments> + </configuration> + </execution> + </executions> + </plugin> + </plugins> + + </build> + + <profiles> + <profile> + <!-- To activate in IntelliJ. This will allow compilation because it seems IntelliJ can't retrieve + the objenesis classes shaded in the objenesis-tck jar --> + <id>intellij-specific</id> + <dependencies> + <dependency> + <groupId>${project.groupId}</groupId> + <artifactId>objenesis</artifactId> + <version>${project.version}</version> + </dependency> + </dependencies> + </profile> + </profiles> +</project> diff --git a/tck-android/src/main/java/org/objenesis/tck/android/ObjenesisTest.java b/tck-android/src/main/java/org/objenesis/tck/android/ObjenesisTest.java new file mode 100644 index 0000000..76d6d0d --- /dev/null +++ b/tck-android/src/main/java/org/objenesis/tck/android/ObjenesisTest.java @@ -0,0 +1,92 @@ +/** + * Copyright 2006-2017 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.objenesis.tck.android; + +import java.io.ByteArrayOutputStream; +import java.io.PrintStream; +import java.util.Map; + +import org.objenesis.ObjenesisSerializer; +import org.objenesis.ObjenesisStd; +import org.objenesis.tck.Main; +import org.objenesis.tck.Reporter; + +import android.test.AndroidTestCase; +import android.test.suitebuilder.annotation.SmallTest; + +/** + * Test case running the entire tck on android. + * + * @author Henri Tremblay + */ +public class ObjenesisTest extends AndroidTestCase { + + public static class JUnitReporter implements Reporter { + + private String currentObjenesis; + + private String currentCandidate; + + public void startTests(String platformDescription, Map<String, Object> allCandidates, + Map<String, Object> allInstantiators) { + } + + public void startTest(String candidateDescription, String objenesisDescription) { + currentCandidate = candidateDescription; + currentObjenesis = objenesisDescription; + } + + public void endObjenesis(String description) { + } + + public void endTests() { + } + + public void exception(Exception exception) { + ByteArrayOutputStream buffer = new ByteArrayOutputStream(); + PrintStream out = new PrintStream(buffer); + out.println("Exception when instantiating " + currentCandidate + " with " + + currentObjenesis + ": "); + exception.printStackTrace(out); + fail(buffer.toString()); + } + + public void result(boolean instantiatedObject) { + assertTrue("Instantiating " + currentCandidate + " with " + currentObjenesis + " failed", + instantiatedObject); + } + + public void endTest() { + } + } + + @SmallTest + public void testObjenesisStd() throws Exception { + Main.runStandardTest(new ObjenesisStd(), new JUnitReporter()); + } + + @SmallTest + public void testObjenesisSerializer() throws Exception { + Main.runSerializerTest(new ObjenesisSerializer(), new JUnitReporter()); + } + + @SmallTest + public void testObjenesisSerializerParentConstructorCalled() throws Exception { + boolean result = Main.runParentConstructorTest(new ObjenesisSerializer()); + assertTrue(result); + } + +}
\ No newline at end of file diff --git a/tck-android/src/main/java/org/objenesis/tck/android/TckInstrumentation.java b/tck-android/src/main/java/org/objenesis/tck/android/TckInstrumentation.java index 23ee5cf..575b671 100644 --- a/tck-android/src/main/java/org/objenesis/tck/android/TckInstrumentation.java +++ b/tck-android/src/main/java/org/objenesis/tck/android/TckInstrumentation.java @@ -1,5 +1,5 @@ /** - * Copyright 2006-2013 the original author or authors. + * Copyright 2006-2017 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,14 +13,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.objenesis.tck.android; import android.app.Activity; import android.app.Instrumentation; import android.os.Bundle; - import org.objenesis.tck.Main; +import org.objenesis.tck.TextReporter; import java.io.ByteArrayOutputStream; import java.io.IOException; @@ -33,21 +32,31 @@ import java.io.PrintStream; */ public class TckInstrumentation extends Instrumentation { + @Override public void onCreate(Bundle arguments) { ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); PrintStream printStream = new PrintStream(outputStream); System.setOut(printStream); + System.setErr(printStream); try { - Main.main(new String[0]); + launch(); } catch (IOException e) { e.printStackTrace(); } - + Bundle bundle = new Bundle(); String fromStdout = outputStream.toString(); bundle.putString(Instrumentation.REPORT_KEY_STREAMRESULT, fromStdout); finish(Activity.RESULT_OK, bundle); } -} + private void launch() throws IOException { + TextReporter reporter = new TextReporter(System.out, System.err); + + boolean parentConstructorTestSuccessful = Main.run(reporter); + + reporter.printResult(parentConstructorTestSuccessful); + + } +} |