From 4302006f904d6f8623062ea4f16d3a1822684f6d Mon Sep 17 00:00:00 2001 From: Paul Duffin Date: Tue, 7 Mar 2017 15:21:33 +0000 Subject: Update to 2.5 Updated using ./update_source.sh 2.5 Bug: 32912773 Test: Does not build yet; see following commit Change-Id: I88f6252c2b17ea6c69255e7a607678fc9fa541a5 --- tck-android/.settings/org.eclipse.jdt.core.prefs | 5 - tck-android/AndroidManifest.xml | 35 +-- tck-android/pom.xml | 249 ++++++++++++--------- .../org/objenesis/tck/android/ObjenesisTest.java | 92 ++++++++ .../objenesis/tck/android/TckInstrumentation.java | 21 +- 5 files changed, 272 insertions(+), 130 deletions(-) delete mode 100644 tck-android/.settings/org.eclipse.jdt.core.prefs create mode 100644 tck-android/src/main/java/org/objenesis/tck/android/ObjenesisTest.java (limited to 'tck-android') 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 @@ - + 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. +--> + intellij-specific + + + ${project.groupId} + objenesis + ${project.version} + + + + + 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 allCandidates, + Map 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); + + } +} -- cgit v1.2.3