Merge "Remove Google compile testing from Room compiler" into androidx-main
diff --git a/room/compiler-processing-testing/src/main/java/androidx/room/compiler/processing/util/CompilationResultSubject.kt b/room/compiler-processing-testing/src/main/java/androidx/room/compiler/processing/util/CompilationResultSubject.kt
index abec687..3a7b940 100644
--- a/room/compiler-processing-testing/src/main/java/androidx/room/compiler/processing/util/CompilationResultSubject.kt
+++ b/room/compiler-processing-testing/src/main/java/androidx/room/compiler/processing/util/CompilationResultSubject.kt
@@ -27,7 +27,6 @@
 import com.google.common.truth.Subject.Factory
 import com.google.common.truth.Truth
 import com.google.testing.compile.Compilation
-import com.google.testing.compile.CompileTester
 import com.tschuchort.compiletesting.KotlinCompilation
 import java.io.File
 import javax.tools.Diagnostic
@@ -90,7 +89,7 @@
  * see: [XTestInvocation.assertCompilationResult]
  */
 @ExperimentalProcessingApi
-class CompilationResultSubject(
+class CompilationResultSubject internal constructor(
     failureMetadata: FailureMetadata,
     val compilationResult: CompilationResult,
 ) : Subject<CompilationResultSubject, CompilationResult>(
@@ -107,14 +106,14 @@
      *
      * @see hasError
      */
-    fun compilationDidFail() = chain {
+    fun compilationDidFail() = apply {
         shouldSucceed = false
     }
 
     /**
      * Asserts free form output from the compilation output.
      */
-    fun hasRawOutputContaining(expected: String) = chain {
+    fun hasRawOutputContaining(expected: String) = apply {
         val found = compilationResult.rawOutput().contains(expected)
         if (!found) {
             failWithActual(
@@ -138,7 +137,7 @@
      */
     fun hasWarningCount(expected: Int) = hasDiagnosticCount(Diagnostic.Kind.WARNING, expected)
 
-    private fun hasDiagnosticCount(kind: Diagnostic.Kind, expected: Int) = chain {
+    private fun hasDiagnosticCount(kind: Diagnostic.Kind, expected: Int) = apply {
         val actual = compilationResult.diagnosticsOfKind(kind).size
         if (actual != expected) {
             failWithActual(
@@ -152,7 +151,7 @@
      * @see hasError
      * @see hasNote
      */
-    fun hasWarning(expected: String) = chain {
+    fun hasWarning(expected: String) = apply {
         hasDiagnosticWithMessage(
             kind = Diagnostic.Kind.WARNING,
             expected = expected,
@@ -168,7 +167,7 @@
      * @see hasErrorContaining
      * @see hasNoteContaining
      */
-    fun hasWarningContaining(expected: String) = chain {
+    fun hasWarningContaining(expected: String) = apply {
         hasDiagnosticWithMessage(
             kind = Diagnostic.Kind.WARNING,
             expected = expected,
@@ -184,7 +183,7 @@
      * @see hasError
      * @see hasWarning
      */
-    fun hasNote(expected: String) = chain {
+    fun hasNote(expected: String) = apply {
         hasDiagnosticWithMessage(
             kind = Diagnostic.Kind.NOTE,
             expected = expected,
@@ -200,7 +199,7 @@
      * @see hasErrorContaining
      * @see hasWarningContaining
      */
-    fun hasNoteContaining(expected: String) = chain {
+    fun hasNoteContaining(expected: String) = apply {
         hasDiagnosticWithMessage(
             kind = Diagnostic.Kind.NOTE,
             expected = expected,
@@ -216,7 +215,7 @@
      * @see hasWarning
      * @see hasNote
      */
-    fun hasError(expected: String) = chain {
+    fun hasError(expected: String) = apply {
         shouldSucceed = false
         hasDiagnosticWithMessage(
             kind = Diagnostic.Kind.ERROR,
@@ -233,7 +232,7 @@
      * @see hasWarningContaining
      * @see hasNoteContaining
      */
-    fun hasErrorContaining(expected: String) = chain {
+    fun hasErrorContaining(expected: String) = apply {
         shouldSucceed = false
         hasDiagnosticWithMessage(
             kind = Diagnostic.Kind.ERROR,
@@ -250,9 +249,9 @@
      * @see compilationDidFail
      * @see hasWarning
      */
-    fun hasError() = chain {
+    fun hasError() = apply {
         shouldSucceed = false
-        if (actual().diagnosticsOfKind(Diagnostic.Kind.ERROR).isEmpty()) {
+        if (compilationResult.diagnosticsOfKind(Diagnostic.Kind.ERROR).isEmpty()) {
             failWithActual(
                 simpleFact("expected at least one failure message")
             )
@@ -264,8 +263,8 @@
      *
      * @see generatedSource
      */
-    fun generatedSourceFileWithPath(relativePath: String) = chain {
-        val match = actual().generatedSources.firstOrNull {
+    fun generatedSourceFileWithPath(relativePath: String) = apply {
+        val match = compilationResult.generatedSources.firstOrNull {
             it.relativePath == relativePath
         }
         if (match == null) {
@@ -282,15 +281,15 @@
      *
      * @see generatedSourceFileWithPath
      */
-    fun generatedSource(source: Source) = chain {
-        val match = actual().generatedSources.firstOrNull {
+    fun generatedSource(source: Source) = apply {
+        val match = compilationResult.generatedSources.firstOrNull {
             it.relativePath == source.relativePath
         }
         if (match == null) {
             failWithActual(
                 simpleFact("Didn't generate $source")
             )
-            return@chain
+            return@apply
         }
         val mismatch = source.findMismatch(match)
         if (mismatch != null) {
@@ -358,15 +357,6 @@
         failWithActual(simpleFact(buildErrorMessage()))
     }
 
-    private fun chain(
-        block: () -> Unit
-    ): CompileTester.ChainingClause<CompilationResultSubject> {
-        block()
-        return CompileTester.ChainingClause<CompilationResultSubject> {
-            this
-        }
-    }
-
     /**
      * Helper method to create an exception that does not include the stack trace from the test
      * infra, instead, it just reports the stack trace of the actual error with added log.
@@ -395,6 +385,7 @@
         }
     }
 }
+
 @ExperimentalProcessingApi
 internal class JavaCompileTestingCompilationResult(
     testRunner: CompilationTestRunner,
diff --git a/room/compiler-processing/src/test/java/androidx/room/compiler/processing/XProcessingEnvTest.kt b/room/compiler-processing/src/test/java/androidx/room/compiler/processing/XProcessingEnvTest.kt
index 828b0c9..1ae77d5 100644
--- a/room/compiler-processing/src/test/java/androidx/room/compiler/processing/XProcessingEnvTest.kt
+++ b/room/compiler-processing/src/test/java/androidx/room/compiler/processing/XProcessingEnvTest.kt
@@ -231,8 +231,7 @@
             )
             it.assertCompilationResult {
                 compilationDidFail()
-                    .and()
-                    .hasError("intentional failure")
+                hasError("intentional failure")
             }
         }
     }
diff --git a/room/compiler/build.gradle b/room/compiler/build.gradle
index f31a895..2e448a4 100644
--- a/room/compiler/build.gradle
+++ b/room/compiler/build.gradle
@@ -113,7 +113,8 @@
     implementation(KOTLIN_METADATA_JVM)
     implementation(APACHE_COMMONS_CODEC)
     implementation(INTELLIJ_ANNOTATIONS)
-    testImplementation(GOOGLE_COMPILE_TESTING)
+    testImplementation(TRUTH)
+    testImplementation(AUTO_VALUE) // to access the processor in tests
     testImplementation(projectOrArtifact(":paging:paging-common"))
     testImplementation(project(":room:room-compiler-processing-testing"))
     testImplementation(JUNIT)
diff --git a/room/compiler/src/test/kotlin/androidx/room/processor/BaseDaoTest.kt b/room/compiler/src/test/kotlin/androidx/room/processor/BaseDaoTest.kt
index 6761321..148e40d 100644
--- a/room/compiler/src/test/kotlin/androidx/room/processor/BaseDaoTest.kt
+++ b/room/compiler/src/test/kotlin/androidx/room/processor/BaseDaoTest.kt
@@ -196,7 +196,7 @@
             """
         )
         runProcessorTest(
-            sources = listOf(baseClass, extension, Source.fromJavaFileObject(COMMON.USER), fakeDb)
+            sources = listOf(baseClass, extension, COMMON.USER, fakeDb)
         ) { invocation ->
             val daoElm = invocation.processingEnv.requireTypeElement("foo.bar.MyDao")
             val dbElm = invocation.context.processingEnv
diff --git a/room/compiler/src/test/kotlin/androidx/room/processor/DaoProcessorTest.kt b/room/compiler/src/test/kotlin/androidx/room/processor/DaoProcessorTest.kt
index 24bcb0e..3a35d15 100644
--- a/room/compiler/src/test/kotlin/androidx/room/processor/DaoProcessorTest.kt
+++ b/room/compiler/src/test/kotlin/androidx/room/processor/DaoProcessorTest.kt
@@ -421,7 +421,7 @@
                     "foo.bar.MyDao",
                     DAO_PREFIX + inputs.joinToString("\n")
                 ),
-                Source.fromJavaFileObject(COMMON.USER)
+                COMMON.USER
             ),
             classpath = classpathFiles
         ) { invocation: XTestInvocation ->
diff --git a/room/compiler/src/test/kotlin/androidx/room/processor/DatabaseProcessorTest.kt b/room/compiler/src/test/kotlin/androidx/room/processor/DatabaseProcessorTest.kt
index 7a755fd..700eb3c 100644
--- a/room/compiler/src/test/kotlin/androidx/room/processor/DatabaseProcessorTest.kt
+++ b/room/compiler/src/test/kotlin/androidx/room/processor/DatabaseProcessorTest.kt
@@ -571,7 +571,7 @@
                 public abstract class MyDb extends RoomDatabase {
                 }
                 """,
-            entity1, Source.fromJavaFileObject(COMMON.USER)
+            entity1, COMMON.USER
         ) { _, invocation ->
             invocation.assertCompilationResult {
                 hasErrorContaining(
@@ -607,7 +607,7 @@
                 public abstract class MyDb extends RoomDatabase {
                 }
                 """,
-            entity1, Source.fromJavaFileObject(COMMON.USER)
+            entity1, COMMON.USER
         ) { _, invocation ->
             invocation.assertCompilationResult {
                 hasErrorContaining(
diff --git a/room/compiler/src/test/kotlin/androidx/room/processor/InsertionMethodProcessorTest.kt b/room/compiler/src/test/kotlin/androidx/room/processor/InsertionMethodProcessorTest.kt
index e22402f..daafffd 100644
--- a/room/compiler/src/test/kotlin/androidx/room/processor/InsertionMethodProcessorTest.kt
+++ b/room/compiler/src/test/kotlin/androidx/room/processor/InsertionMethodProcessorTest.kt
@@ -41,7 +41,6 @@
 import org.junit.Test
 import org.junit.runner.RunWith
 import org.junit.runners.JUnit4
-import toSources
 
 @Suppress("PLATFORM_CLASS_MAPPED_TO_KOTLIN")
 @RunWith(JUnit4::class)
@@ -934,7 +933,7 @@
             COMMON.USER, COMMON.BOOK, COMMON.NOT_AN_ENTITY, COMMON.RX2_COMPLETABLE,
             COMMON.RX2_MAYBE, COMMON.RX2_SINGLE, COMMON.RX3_COMPLETABLE,
             COMMON.RX3_MAYBE, COMMON.RX3_SINGLE
-        ).toSources()
+        )
 
         runProcessorTest(
             sources = commonSources + additionalSources + inputSource
diff --git a/room/compiler/src/test/kotlin/androidx/room/processor/PojoProcessorTest.kt b/room/compiler/src/test/kotlin/androidx/room/processor/PojoProcessorTest.kt
index 5a8e06e..497d707 100644
--- a/room/compiler/src/test/kotlin/androidx/room/processor/PojoProcessorTest.kt
+++ b/room/compiler/src/test/kotlin/androidx/room/processor/PojoProcessorTest.kt
@@ -176,7 +176,7 @@
                 @Relation(parentColumn = "id", entityColumn = "uid")
                 public transient List<User> user;
                 """,
-            Source.fromJavaFileObject(COMMON.USER),
+            COMMON.USER,
         ) { pojo, invocation ->
             assertThat(pojo.relations.size, `is`(1))
             assertThat(pojo.relations.first().entityField.name, `is`("uid"))
@@ -419,7 +419,7 @@
                 @Relation(parentColumn = "id", entityColumn = "uid")
                 public List<UserSummary> user;
                 """,
-            Source.fromJavaFileObject(COMMON.USER_SUMMARY)
+            COMMON.USER_SUMMARY
         ) { _, _ ->
         }
     }
@@ -432,7 +432,7 @@
                 @Relation(parentColumn = "id", entityColumn = "uid")
                 public User user;
                 """,
-            Source.fromJavaFileObject(COMMON.USER)
+            COMMON.USER
         ) { _, _ ->
         }
     }
@@ -446,7 +446,7 @@
                 @Relation(parentColumn = "id", entityColumn = "uid")
                 public List<User> user;
                 """,
-            Source.fromJavaFileObject(COMMON.USER)
+            COMMON.USER
         ) { _, invocation ->
             invocation.assertCompilationResult {
                 hasErrorContaining(ProcessorErrors.CANNOT_USE_MORE_THAN_ONE_POJO_FIELD_ANNOTATION)
@@ -462,7 +462,7 @@
                 @Relation(parentColumn = "id", entityColumn = "uid")
                 public List<NotAnEntity> user;
                 """,
-            Source.fromJavaFileObject(COMMON.NOT_AN_ENTITY)
+            COMMON.NOT_AN_ENTITY
         ) { _, invocation ->
             invocation.assertCompilationResult {
                 hasErrorContaining(ProcessorErrors.NOT_ENTITY_OR_VIEW)
@@ -507,7 +507,7 @@
                 @Relation(parentColumn = "idk", entityColumn = "uid")
                 public List<User> user;
                 """,
-            Source.fromJavaFileObject(COMMON.USER)
+            COMMON.USER
         ) { _, invocation ->
             invocation.assertCompilationResult {
                 hasErrorContaining(
@@ -525,7 +525,7 @@
                 @Relation(parentColumn = "id", entityColumn = "idk")
                 public List<User> user;
                 """,
-            Source.fromJavaFileObject(COMMON.USER)
+            COMMON.USER
         ) { _, invocation ->
             invocation.assertCompilationResult {
                 hasErrorContaining(
@@ -575,7 +575,7 @@
                 @Relation(parentColumn = "foo", entityColumn = "uid")
                 public List<User> user;
                 """,
-            Source.fromJavaFileObject(COMMON.USER)
+            COMMON.USER
         ) { pojo, _ ->
             assertThat(pojo.relations.first().parentField.columnName, `is`("foo"))
         }
@@ -595,7 +595,7 @@
                 @Relation(parentColumn = "id", entityColumn = "uid", entity = User.class)
                 public List<UserWithNested> user;
                 """,
-            Source.fromJavaFileObject(COMMON.USER)
+            COMMON.USER
         ) { pojo, invocation ->
             assertThat(pojo.relations.first().parentField.name, `is`("id"))
             invocation.assertCompilationResult {
@@ -612,7 +612,7 @@
                 @Relation(parentColumn = "id", entityColumn = "uid")
                 public List<User> user;
                 """,
-            Source.fromJavaFileObject(COMMON.USER)
+            COMMON.USER
         ) { pojo, invocation ->
             // trigger assignment evaluation
             RelationCollector.createCollectors(invocation.context, pojo.relations)
@@ -640,7 +640,7 @@
                 @Relation(parentColumn = "id", entityColumn = "uid")
                 public List<User> user;
                 """,
-            Source.fromJavaFileObject(COMMON.USER)
+            COMMON.USER
         ) { pojo, invocation ->
             assertThat(pojo.relations.size, `is`(1))
             assertThat(pojo.relations.first().entityField.name, `is`("uid"))
@@ -659,7 +659,7 @@
                 @Relation(parentColumn = "id", entityColumn = "uid", projection={"i_dont_exist"})
                 public List<User> user;
                 """,
-            Source.fromJavaFileObject(COMMON.USER)
+            COMMON.USER
         ) { _, invocation ->
             invocation.assertCompilationResult {
                 hasErrorContaining(
@@ -682,7 +682,7 @@
                 public void setUser(List<User> user){ this.user = user;}
                 public User getUser(){return null;}
                 """,
-            Source.fromJavaFileObject(COMMON.USER)
+            COMMON.USER
         ) { _, invocation ->
             invocation.assertCompilationResult {
                 hasErrorContaining(CANNOT_FIND_GETTER_FOR_FIELD)
@@ -699,7 +699,7 @@
                         entity = User.class)
                 public List<Integer> userIds;
                 """,
-            Source.fromJavaFileObject(COMMON.USER)
+            COMMON.USER
         ) { pojo, _ ->
             assertThat(pojo.relations.size, `is`(1))
             val rel = pojo.relations.first()
@@ -717,7 +717,7 @@
                         entity = User.class)
                 public List<String> userNames;
                 """,
-            Source.fromJavaFileObject(COMMON.USER)
+            COMMON.USER
         ) { pojo, _ ->
             assertThat(pojo.relations.size, `is`(1))
             val rel = pojo.relations.first()
@@ -734,7 +734,7 @@
                 @Relation(parentColumn = "id", entityColumn = "uid")
                 public List<? extends User> user;
                 """,
-            Source.fromJavaFileObject(COMMON.USER)
+            COMMON.USER
         ) { pojo, invocation ->
             assertThat(pojo.relations.size, `is`(1))
             assertThat(pojo.relations.first().entityField.name, `is`("uid"))
@@ -787,7 +787,7 @@
                 )
                 public List<User> user;
                 """,
-            Source.fromJavaFileObject(COMMON.USER), junctionEntity
+            COMMON.USER, junctionEntity
         ) { pojo, invocation ->
             assertThat(pojo.relations.size, `is`(1))
             assertThat(pojo.relations.first().junction, notNullValue())
@@ -832,7 +832,7 @@
                 )
                 public List<User> user;
                 """,
-            Source.fromJavaFileObject(COMMON.USER), junctionEntity
+            COMMON.USER, junctionEntity
         ) { _, invocation ->
             invocation.assertCompilationResult {
                 hasNoWarnings()
@@ -880,7 +880,7 @@
                     associateBy = @Junction(UserFriendsXRef.class))
                 public List<User> user;
                 """,
-            Source.fromJavaFileObject(COMMON.USER), junctionEntity
+            COMMON.USER, junctionEntity
         ) { _, invocation ->
             invocation.assertCompilationResult {
                 hasNoWarnings()
@@ -913,7 +913,7 @@
                 )
                 public List<User> user;
                 """,
-            Source.fromJavaFileObject(COMMON.USER), junctionEntity
+            COMMON.USER, junctionEntity
         ) { _, invocation ->
             invocation.assertCompilationResult {
                 hasErrorContaining(
@@ -950,7 +950,7 @@
                 )
                 public List<User> user;
                 """,
-            Source.fromJavaFileObject(COMMON.USER), junctionEntity
+            COMMON.USER, junctionEntity
         ) { _, invocation ->
             invocation.assertCompilationResult {
                 hasErrorContaining(
@@ -989,7 +989,7 @@
                 )
                 public List<User> user;
                 """,
-            Source.fromJavaFileObject(COMMON.USER), junctionEntity
+            COMMON.USER, junctionEntity
         ) { _, invocation ->
             invocation.assertCompilationResult {
                 hasErrorContaining(
@@ -1028,7 +1028,7 @@
                 )
                 public List<User> user;
                 """,
-            Source.fromJavaFileObject(COMMON.USER), junctionEntity
+            COMMON.USER, junctionEntity
         ) { _, invocation ->
             invocation.assertCompilationResult {
                 hasErrorContaining(
@@ -1064,7 +1064,7 @@
                     associateBy = @Junction(UserFriendsXRef.class))
                 public List<User> user;
                 """,
-            Source.fromJavaFileObject(COMMON.USER), junctionEntity
+            COMMON.USER, junctionEntity
         ) { _, invocation ->
             invocation.assertCompilationResult {
                 hasWarningCount(2)
@@ -1390,7 +1390,7 @@
             public MyPojo(String uid, List<String> items) {
             }
             """,
-            Source.fromJavaFileObject(COMMON.USER)
+            COMMON.USER
         ) { _, _ ->
         }
     }
diff --git a/room/compiler/src/test/kotlin/androidx/room/processor/QueryMethodProcessorTest.kt b/room/compiler/src/test/kotlin/androidx/room/processor/QueryMethodProcessorTest.kt
index d2fdfe6..8f573d5 100644
--- a/room/compiler/src/test/kotlin/androidx/room/processor/QueryMethodProcessorTest.kt
+++ b/room/compiler/src/test/kotlin/androidx/room/processor/QueryMethodProcessorTest.kt
@@ -63,7 +63,6 @@
 import org.junit.runner.RunWith
 import org.junit.runners.Parameterized
 import org.mockito.Mockito
-import toSources
 
 @Suppress("PLATFORM_CLASS_MAPPED_TO_KOTLIN")
 @RunWith(Parameterized::class)
@@ -684,7 +683,7 @@
                 @Query("select * from user")
                 abstract ${KotlinTypeNames.CHANNEL}<User> getUsersChannel();
                 """,
-            additionalSources = listOf(COMMON.CHANNEL).toSources()
+            additionalSources = listOf(COMMON.CHANNEL)
         ) { _, invocation ->
             invocation.assertCompilationResult {
                 hasErrorContaining(
@@ -703,7 +702,7 @@
                 @Query("select * from user")
                 abstract ${KotlinTypeNames.SEND_CHANNEL}<User> getUsersChannel();
                 """,
-            additionalSources = listOf(COMMON.SEND_CHANNEL).toSources()
+            additionalSources = listOf(COMMON.SEND_CHANNEL)
         ) { _, invocation ->
             invocation.assertCompilationResult {
                 hasErrorContaining(
@@ -722,7 +721,7 @@
                 @Query("select * from user")
                 abstract ${KotlinTypeNames.RECEIVE_CHANNEL}<User> getUsersChannel();
                 """,
-            additionalSources = listOf(COMMON.RECEIVE_CHANNEL).toSources()
+            additionalSources = listOf(COMMON.RECEIVE_CHANNEL)
         ) { _, invocation ->
             invocation.assertCompilationResult {
                 hasErrorContaining(
@@ -1230,7 +1229,7 @@
         val commonSources = listOf(
             COMMON.LIVE_DATA, COMMON.COMPUTABLE_LIVE_DATA, COMMON.USER, COMMON.BOOK,
             COMMON.NOT_AN_ENTITY
-        ).toSources()
+        )
         runProcessorTest(
             sources = additionalSources + commonSources + inputSource,
             options = options
diff --git a/room/compiler/src/test/kotlin/androidx/room/processor/RawQueryMethodProcessorTest.kt b/room/compiler/src/test/kotlin/androidx/room/processor/RawQueryMethodProcessorTest.kt
index 001e186..7145423 100644
--- a/room/compiler/src/test/kotlin/androidx/room/processor/RawQueryMethodProcessorTest.kt
+++ b/room/compiler/src/test/kotlin/androidx/room/processor/RawQueryMethodProcessorTest.kt
@@ -35,7 +35,6 @@
 import org.hamcrest.CoreMatchers.`is`
 import org.hamcrest.MatcherAssert.assertThat
 import org.junit.Test
-import toSources
 
 class RawQueryMethodProcessorTest {
     @Test
@@ -353,7 +352,7 @@
             COMMON.LIVE_DATA, COMMON.COMPUTABLE_LIVE_DATA, COMMON.USER,
             COMMON.DATA_SOURCE_FACTORY, COMMON.POSITIONAL_DATA_SOURCE,
             COMMON.NOT_AN_ENTITY
-        ).toSources()
+        )
         runProcessorTest(
             sources = commonSources + inputSource
         ) { invocation ->
diff --git a/room/compiler/src/test/kotlin/androidx/room/processor/RemoveUnusedColumnsTest.kt b/room/compiler/src/test/kotlin/androidx/room/processor/RemoveUnusedColumnsTest.kt
index 76bcdd6..c58bc62 100644
--- a/room/compiler/src/test/kotlin/androidx/room/processor/RemoveUnusedColumnsTest.kt
+++ b/room/compiler/src/test/kotlin/androidx/room/processor/RemoveUnusedColumnsTest.kt
@@ -110,7 +110,7 @@
             annotateDao = annotateDao,
             annotateDb = annotateDb,
             annotateMethod = annotateMethod
-        ) + Source.fromJavaFileObject(COMMON.USER)
+        ) + COMMON.USER
 
         runProcessorTest(
             sources = sources,
diff --git a/room/compiler/src/test/kotlin/androidx/room/processor/ShortcutMethodProcessorTest.kt b/room/compiler/src/test/kotlin/androidx/room/processor/ShortcutMethodProcessorTest.kt
index a105248..f62ec6d 100644
--- a/room/compiler/src/test/kotlin/androidx/room/processor/ShortcutMethodProcessorTest.kt
+++ b/room/compiler/src/test/kotlin/androidx/room/processor/ShortcutMethodProcessorTest.kt
@@ -37,7 +37,6 @@
 import org.hamcrest.CoreMatchers.`is`
 import org.hamcrest.MatcherAssert.assertThat
 import org.junit.Test
-import toSources
 import kotlin.reflect.KClass
 
 /**
@@ -599,7 +598,7 @@
             COMMON.RX2_MAYBE, COMMON.RX2_SINGLE, COMMON.RX3_COMPLETABLE,
             COMMON.RX3_MAYBE, COMMON.RX3_SINGLE, COMMON.LISTENABLE_FUTURE,
             COMMON.GUAVA_ROOM
-        ).toSources()
+        )
         runProcessorTest(
             sources = commonSources + additionalSources + inputSource
         ) { invocation ->
diff --git a/room/compiler/src/test/kotlin/androidx/room/processor/TableEntityProcessorTest.kt b/room/compiler/src/test/kotlin/androidx/room/processor/TableEntityProcessorTest.kt
index f695759..4b2c808 100644
--- a/room/compiler/src/test/kotlin/androidx/room/processor/TableEntityProcessorTest.kt
+++ b/room/compiler/src/test/kotlin/androidx/room/processor/TableEntityProcessorTest.kt
@@ -39,7 +39,6 @@
 import org.junit.Test
 import org.junit.runner.RunWith
 import org.junit.runners.JUnit4
-import toSources
 
 @RunWith(JUnit4::class)
 class TableEntityProcessorTest : BaseEntityParserTest() {
@@ -1930,7 +1929,7 @@
                 @Relation(parentColumn = "id", entityColumn = "uid")
                 java.util.List<User> users;
                 """,
-            sources = listOf(COMMON.USER).toSources()
+            sources = listOf(COMMON.USER)
         ) { _, invocation ->
             invocation.assertCompilationResult {
                 hasError(RELATION_IN_ENTITY)
@@ -1955,7 +1954,7 @@
                 int id;
                 String name;
                 """,
-            attributes = annotation, sources = listOf(COMMON.USER).toSources()
+            attributes = annotation, sources = listOf(COMMON.USER)
         ) { _, invocation ->
             invocation.assertCompilationResult {
                 hasError(ProcessorErrors.INVALID_FOREIGN_KEY_ACTION)
@@ -1979,7 +1978,7 @@
                 int id;
                 String name;
                 """,
-            attributes = annotation, sources = listOf(COMMON.USER).toSources()
+            attributes = annotation, sources = listOf(COMMON.USER)
         ) { _, invocation ->
             invocation.assertCompilationResult {
                 compilationDidFail()
@@ -2004,7 +2003,7 @@
                 int id;
                 String name;
                 """,
-            attributes = annotation, sources = listOf(COMMON.NOT_AN_ENTITY).toSources()
+            attributes = annotation, sources = listOf(COMMON.NOT_AN_ENTITY)
         ) { _, invocation ->
             invocation.assertCompilationResult {
                 hasError(
@@ -2032,7 +2031,7 @@
                 int id;
                 String name;
                 """,
-            attributes = annotation, sources = listOf(COMMON.USER).toSources()
+            attributes = annotation, sources = listOf(COMMON.USER)
         ) { _, invocation ->
             invocation.assertCompilationResult {
                 hasError(
@@ -2060,7 +2059,7 @@
                 int id;
                 String name;
                 """,
-            attributes = annotation, sources = listOf(COMMON.USER).toSources()
+            attributes = annotation, sources = listOf(COMMON.USER)
         ) { _, invocation ->
             invocation.assertCompilationResult {
                 hasError(
@@ -2088,7 +2087,7 @@
                 int id;
                 String name;
                 """,
-            attributes = annotation, sources = listOf(COMMON.USER).toSources()
+            attributes = annotation, sources = listOf(COMMON.USER)
         ) { _, invocation ->
             invocation.assertCompilationResult {
                 hasError(ProcessorErrors.FOREIGN_KEY_EMPTY_CHILD_COLUMN_LIST)
@@ -2112,7 +2111,7 @@
                 int id;
                 String name;
                 """,
-            attributes = annotation, sources = listOf(COMMON.USER).toSources()
+            attributes = annotation, sources = listOf(COMMON.USER)
         ) { _, invocation ->
             invocation.assertCompilationResult {
                 hasError(ProcessorErrors.FOREIGN_KEY_EMPTY_PARENT_COLUMN_LIST)
@@ -2139,7 +2138,7 @@
                 int id;
                 String name;
                 """,
-            attributes = annotation, sources = listOf(COMMON.USER).toSources()
+            attributes = annotation, sources = listOf(COMMON.USER)
         ) { entity, _ ->
             assertThat(entity.foreignKeys.size, `is`(1))
             val fKey = entity.foreignKeys.first()
@@ -2172,7 +2171,7 @@
                 int id;
                 String name;
                 """,
-            attributes = annotation, sources = listOf(COMMON.USER).toSources()
+            attributes = annotation, sources = listOf(COMMON.USER)
         ) { _, invocation ->
             invocation.assertCompilationResult {
                 hasNoWarnings()
@@ -2201,7 +2200,7 @@
                 String name;
                 String lName;
                 """,
-            attributes = annotation, sources = listOf(COMMON.USER).toSources()
+            attributes = annotation, sources = listOf(COMMON.USER)
         ) { entity, invocation ->
             assertThat(entity.indices.size, `is`(1))
             invocation.assertCompilationResult {
@@ -2231,7 +2230,7 @@
                 String name;
                 String lName;
                 """,
-            attributes = annotation, sources = listOf(COMMON.USER).toSources()
+            attributes = annotation, sources = listOf(COMMON.USER)
         ) { entity, invocation ->
             assertThat(entity.indices.size, `is`(1))
             invocation.assertCompilationResult {
@@ -2259,7 +2258,7 @@
                 int id;
                 String name;
                 """,
-            attributes = annotation, sources = listOf(COMMON.USER).toSources()
+            attributes = annotation, sources = listOf(COMMON.USER)
         ) { entity, invocation ->
             assertThat(entity.indices, `is`(emptyList()))
             invocation.assertCompilationResult {
@@ -2285,7 +2284,7 @@
                 String name;
                 String lName;
                 """,
-            attributes = annotation, sources = listOf(COMMON.USER).toSources()
+            attributes = annotation, sources = listOf(COMMON.USER)
         ) { entity, invocation ->
             assertThat(entity.indices, `is`(emptyList()))
             invocation.assertCompilationResult {
@@ -2320,7 +2319,7 @@
                 int id;
                 String name;
                 """,
-            attributes = annotation, sources = listOf(COMMON.USER).toSources()
+            attributes = annotation, sources = listOf(COMMON.USER)
         ) { entity, invocation ->
             assertThat(entity.indices, `is`(emptyList()))
             invocation.assertCompilationResult {
@@ -2428,7 +2427,7 @@
                 int id;
                 String name;
                 """,
-            attributes = annotation, sources = listOf(COMMON.USER).toSources()
+            attributes = annotation, sources = listOf(COMMON.USER)
         ) { entity, _ ->
             assertThat(entity.tableName).isEqualTo("foo bar")
         }
@@ -2443,7 +2442,7 @@
                 int id;
                 String name;
                 """,
-            attributes = annotation, sources = listOf(COMMON.USER).toSources()
+            attributes = annotation, sources = listOf(COMMON.USER)
         ) { _, invocation ->
             invocation.assertCompilationResult {
                 hasError(ProcessorErrors.INVALID_TABLE_NAME)
@@ -2460,7 +2459,7 @@
                 @ColumnInfo(name = "\"foo bar\"")
                 String name;
                 """,
-            sources = listOf(COMMON.USER).toSources()
+            sources = listOf(COMMON.USER)
         ) { _, invocation ->
             invocation.assertCompilationResult {
                 hasError(ProcessorErrors.INVALID_COLUMN_NAME)
diff --git a/room/compiler/src/test/kotlin/androidx/room/processor/TransactionMethodProcessorTest.kt b/room/compiler/src/test/kotlin/androidx/room/processor/TransactionMethodProcessorTest.kt
index 88cc9ab..20a4398 100644
--- a/room/compiler/src/test/kotlin/androidx/room/processor/TransactionMethodProcessorTest.kt
+++ b/room/compiler/src/test/kotlin/androidx/room/processor/TransactionMethodProcessorTest.kt
@@ -30,7 +30,6 @@
 import org.junit.Test
 import org.junit.runner.RunWith
 import org.junit.runners.JUnit4
-import toSources
 
 @Suppress("PLATFORM_CLASS_MAPPED_TO_KOTLIN")
 @RunWith(JUnit4::class)
@@ -268,7 +267,7 @@
             COMMON.LIVE_DATA, COMMON.RX2_FLOWABLE, COMMON.PUBLISHER, COMMON.RX2_COMPLETABLE,
             COMMON.RX2_SINGLE, COMMON.RX3_FLOWABLE, COMMON.RX3_COMPLETABLE,
             COMMON.RX3_SINGLE, COMMON.LISTENABLE_FUTURE
-        ).toSources()
+        )
         runProcessorTest(
             sources = inputSource + otherSources
         ) { invocation ->
diff --git a/room/compiler/src/test/kotlin/androidx/room/solver/TypeAdapterStoreTest.kt b/room/compiler/src/test/kotlin/androidx/room/solver/TypeAdapterStoreTest.kt
index e6feb02..4e2dcb4 100644
--- a/room/compiler/src/test/kotlin/androidx/room/solver/TypeAdapterStoreTest.kt
+++ b/room/compiler/src/test/kotlin/androidx/room/solver/TypeAdapterStoreTest.kt
@@ -63,7 +63,6 @@
 import org.junit.runner.RunWith
 import org.junit.runners.JUnit4
 import testCodeGenScope
-import toSources
 
 @Suppress("PLATFORM_CLASS_MAPPED_TO_KOTLIN")
 @RunWith(JUnit4::class)
@@ -499,7 +498,7 @@
     fun testMissingRx2Room() {
         @Suppress("CHANGING_ARGUMENTS_EXECUTION_ORDER_FOR_NAMED_VARARGS")
         runProcessorTest(
-            sources = listOf(COMMON.PUBLISHER, COMMON.RX2_FLOWABLE).toSources()
+            sources = listOf(COMMON.PUBLISHER, COMMON.RX2_FLOWABLE)
         ) { invocation ->
             val publisherElement = invocation.processingEnv
                 .requireTypeElement(ReactiveStreamsTypeNames.PUBLISHER)
@@ -520,7 +519,7 @@
     fun testMissingRx3Room() {
         @Suppress("CHANGING_ARGUMENTS_EXECUTION_ORDER_FOR_NAMED_VARARGS")
         runProcessorTest(
-            sources = listOf(COMMON.PUBLISHER, COMMON.RX3_FLOWABLE).toSources()
+            sources = listOf(COMMON.PUBLISHER, COMMON.RX3_FLOWABLE)
         ) { invocation ->
             val publisherElement = invocation.processingEnv
                 .requireTypeElement(ReactiveStreamsTypeNames.PUBLISHER)
@@ -545,7 +544,7 @@
         ).forEach { (rxTypeSrc, rxRoomSrc) ->
             @Suppress("CHANGING_ARGUMENTS_EXECUTION_ORDER_FOR_NAMED_VARARGS")
             runProcessorTest(
-                sources = listOf(COMMON.PUBLISHER, rxTypeSrc, rxRoomSrc).toSources()
+                sources = listOf(COMMON.PUBLISHER, rxTypeSrc, rxRoomSrc)
             ) { invocation ->
                 val publisher = invocation.processingEnv
                     .requireTypeElement(ReactiveStreamsTypeNames.PUBLISHER)
@@ -568,7 +567,7 @@
         ).forEach { (rxTypeSrc, rxRoomSrc, rxTypeClassName) ->
             @Suppress("CHANGING_ARGUMENTS_EXECUTION_ORDER_FOR_NAMED_VARARGS")
             runProcessorTest(
-                sources = listOf(COMMON.PUBLISHER, rxTypeSrc, rxRoomSrc).toSources()
+                sources = listOf(COMMON.PUBLISHER, rxTypeSrc, rxRoomSrc)
             ) { invocation ->
                 val flowable = invocation.processingEnv.requireTypeElement(rxTypeClassName)
                 assertThat(
@@ -589,7 +588,7 @@
         ).forEach { (rxTypeSrc, rxRoomSrc, rxTypeClassName) ->
             @Suppress("CHANGING_ARGUMENTS_EXECUTION_ORDER_FOR_NAMED_VARARGS")
             runProcessorTest(
-                sources = listOf(rxTypeSrc, rxRoomSrc).toSources()
+                sources = listOf(rxTypeSrc, rxRoomSrc)
             ) { invocation ->
                 val observable = invocation.processingEnv.requireTypeElement(rxTypeClassName)
                 assertThat(observable, notNullValue())
@@ -610,7 +609,7 @@
             Triple(COMMON.RX3_SINGLE, COMMON.RX3_ROOM, RxJava3TypeNames.SINGLE)
         ).forEach { (rxTypeSrc, _, rxTypeClassName) ->
             @Suppress("CHANGING_ARGUMENTS_EXECUTION_ORDER_FOR_NAMED_VARARGS")
-            runProcessorTest(sources = listOf(rxTypeSrc).toSources()) { invocation ->
+            runProcessorTest(sources = listOf(rxTypeSrc)) { invocation ->
                 val single = invocation.processingEnv.requireTypeElement(rxTypeClassName)
                 assertThat(single, notNullValue())
                 assertThat(
@@ -629,7 +628,7 @@
             Triple(COMMON.RX2_MAYBE, COMMON.RX2_ROOM, RxJava2TypeNames.MAYBE),
             Triple(COMMON.RX3_MAYBE, COMMON.RX3_ROOM, RxJava3TypeNames.MAYBE)
         ).forEach { (rxTypeSrc, _, rxTypeClassName) ->
-            runProcessorTest(sources = listOf(rxTypeSrc).toSources()) { invocation ->
+            runProcessorTest(sources = listOf(rxTypeSrc)) { invocation ->
                 val maybe = invocation.processingEnv.requireTypeElement(rxTypeClassName)
                 assertThat(
                     RxCallableInsertMethodBinderProvider.getAll(invocation.context).any {
@@ -647,7 +646,7 @@
             Triple(COMMON.RX2_COMPLETABLE, COMMON.RX2_ROOM, RxJava2TypeNames.COMPLETABLE),
             Triple(COMMON.RX3_COMPLETABLE, COMMON.RX3_ROOM, RxJava3TypeNames.COMPLETABLE)
         ).forEach { (rxTypeSrc, _, rxTypeClassName) ->
-            runProcessorTest(sources = listOf(rxTypeSrc).toSources()) { invocation ->
+            runProcessorTest(sources = listOf(rxTypeSrc)) { invocation ->
                 val completable = invocation.processingEnv.requireTypeElement(rxTypeClassName)
                 assertThat(
                     RxCallableInsertMethodBinderProvider.getAll(invocation.context).any {
@@ -661,7 +660,7 @@
 
     @Test
     fun testFindInsertListenableFuture() {
-        runProcessorTest(sources = listOf(COMMON.LISTENABLE_FUTURE).toSources()) {
+        runProcessorTest(sources = listOf(COMMON.LISTENABLE_FUTURE)) {
             invocation ->
             val future = invocation.processingEnv
                 .requireTypeElement(GuavaUtilConcurrentTypeNames.LISTENABLE_FUTURE)
@@ -676,7 +675,7 @@
 
     @Test
     fun testFindDeleteOrUpdateSingle() {
-        runProcessorTest(sources = listOf(COMMON.RX2_SINGLE).toSources()) { invocation ->
+        runProcessorTest(sources = listOf(COMMON.RX2_SINGLE)) { invocation ->
             val single = invocation.processingEnv.requireTypeElement(RxJava2TypeNames.SINGLE)
             assertThat(single, notNullValue())
             assertThat(
@@ -690,7 +689,7 @@
 
     @Test
     fun testFindDeleteOrUpdateMaybe() {
-        runProcessorTest(sources = listOf(COMMON.RX2_MAYBE).toSources()) {
+        runProcessorTest(sources = listOf(COMMON.RX2_MAYBE)) {
             invocation ->
             val maybe = invocation.processingEnv.requireTypeElement(RxJava2TypeNames.MAYBE)
             assertThat(maybe, notNullValue())
@@ -705,7 +704,7 @@
 
     @Test
     fun testFindDeleteOrUpdateCompletable() {
-        runProcessorTest(sources = listOf(COMMON.RX2_COMPLETABLE).toSources()) {
+        runProcessorTest(sources = listOf(COMMON.RX2_COMPLETABLE)) {
             invocation ->
             val completable = invocation.processingEnv
                 .requireTypeElement(RxJava2TypeNames.COMPLETABLE)
@@ -722,7 +721,7 @@
     @Test
     fun testFindDeleteOrUpdateListenableFuture() {
         runProcessorTest(
-            sources = listOf(COMMON.LISTENABLE_FUTURE).toSources()
+            sources = listOf(COMMON.LISTENABLE_FUTURE)
         ) { invocation ->
             val future = invocation.processingEnv
                 .requireTypeElement(GuavaUtilConcurrentTypeNames.LISTENABLE_FUTURE)
@@ -738,7 +737,7 @@
     @Test
     fun testFindLiveData() {
         runProcessorTest(
-            sources = listOf(COMMON.COMPUTABLE_LIVE_DATA, COMMON.LIVE_DATA).toSources()
+            sources = listOf(COMMON.COMPUTABLE_LIVE_DATA, COMMON.LIVE_DATA)
         ) { invocation ->
             val liveData = invocation.processingEnv
                 .requireTypeElement(LifecyclesTypeNames.LIVE_DATA)
@@ -828,7 +827,7 @@
 
     @Test
     fun findDataSourceFactory() {
-        runProcessorTest(sources = listOf(COMMON.DATA_SOURCE_FACTORY).toSources()) {
+        runProcessorTest(sources = listOf(COMMON.DATA_SOURCE_FACTORY)) {
             invocation ->
             val pagedListProvider = invocation.processingEnv
                 .requireTypeElement(PagingTypeNames.DATA_SOURCE_FACTORY)
diff --git a/room/compiler/src/test/kotlin/androidx/room/testing/test_util.kt b/room/compiler/src/test/kotlin/androidx/room/testing/test_util.kt
index f75c9b6..4a0e2a3 100644
--- a/room/compiler/src/test/kotlin/androidx/room/testing/test_util.kt
+++ b/room/compiler/src/test/kotlin/androidx/room/testing/test_util.kt
@@ -38,12 +38,10 @@
 import androidx.room.testing.context
 import androidx.room.verifier.DatabaseVerifier
 import androidx.room.writer.ClassWriter
-import com.google.testing.compile.JavaFileObjects
 import com.squareup.javapoet.ClassName
 import org.mockito.Mockito.doReturn
 import org.mockito.Mockito.mock
 import java.io.File
-import javax.tools.JavaFileObject
 
 object COMMON {
     val USER by lazy {
@@ -218,9 +216,9 @@
     return CodeGenScope(mock(ClassWriter::class.java))
 }
 
-fun loadJavaCode(fileName: String, qName: String): JavaFileObject {
+fun loadJavaCode(fileName: String, qName: String): Source {
     val contents = File("src/test/data/$fileName").readText(Charsets.UTF_8)
-    return JavaFileObjects.forSourceString(qName, contents)
+    return Source.java(qName, contents)
 }
 
 fun loadTestSource(fileName: String, qName: String): Source {
@@ -262,7 +260,3 @@
     doReturn(type).`when`(element).type
     return element to type
 }
-
-fun String.toJFO(qName: String): JavaFileObject = JavaFileObjects.forSourceLines(qName, this)
-
-fun Collection<JavaFileObject>.toSources() = map(Source::fromJavaFileObject)
diff --git a/room/compiler/src/test/kotlin/androidx/room/writer/DaoWriterTest.kt b/room/compiler/src/test/kotlin/androidx/room/writer/DaoWriterTest.kt
index cb808ad..101138c 100644
--- a/room/compiler/src/test/kotlin/androidx/room/writer/DaoWriterTest.kt
+++ b/room/compiler/src/test/kotlin/androidx/room/writer/DaoWriterTest.kt
@@ -29,7 +29,6 @@
 import org.junit.Test
 import org.junit.runner.RunWith
 import org.junit.runners.JUnit4
-import toSources
 import java.util.Locale
 
 @RunWith(JUnit4::class)
@@ -135,7 +134,7 @@
             COMMON.RX2_MAYBE, COMMON.RX2_COMPLETABLE, COMMON.USER_SUMMARY,
             COMMON.RX2_ROOM, COMMON.PARENT, COMMON.CHILD1, COMMON.CHILD2,
             COMMON.INFO, COMMON.LISTENABLE_FUTURE, COMMON.GUAVA_ROOM
-        ).toSources() + inputs
+        ) + inputs
         runProcessorTest(
             sources = sources
         ) { invocation ->
diff --git a/room/compiler/src/test/kotlin/androidx/room/writer/DatabaseWriterTest.kt b/room/compiler/src/test/kotlin/androidx/room/writer/DatabaseWriterTest.kt
index cfad1fb..20772ab 100644
--- a/room/compiler/src/test/kotlin/androidx/room/writer/DatabaseWriterTest.kt
+++ b/room/compiler/src/test/kotlin/androidx/room/writer/DatabaseWriterTest.kt
@@ -27,7 +27,6 @@
 import org.junit.experimental.runners.Enclosed
 import org.junit.runner.RunWith
 import org.junit.runners.Parameterized
-import toSources
 
 @RunWith(Enclosed::class)
 class DatabaseWriterTest {
@@ -145,7 +144,7 @@
         COMMON.USER, COMMON.USER_SUMMARY, COMMON.LIVE_DATA, COMMON.COMPUTABLE_LIVE_DATA,
         COMMON.PARENT, COMMON.CHILD1, COMMON.CHILD2, COMMON.INFO, COMMON.GUAVA_ROOM,
         COMMON.LISTENABLE_FUTURE
-    ).toSources() + inputs
+    ) + inputs
     runProcessorTest(
         sources = sources,
         handler = DatabaseProcessingStep().asTestInvocationHandler(handler)