Uploaded image for project: 'Android Client'
  1. Android Client
  2. AC-635

Unit tests cannot run because of a deprecated library

    XMLWordPrintable

Details

    • Medium

    Description

      When running any unit test that extends ACUnitTestBase, it fails during initialization part. Error:

      java.lang.IllegalStateException: Failed to transform class with name com.activeandroid.Cache. Reason: cannot find android.support.v4.util.LruCache
      
      	at org.powermock.core.classloader.javassist.JavassistMockClassLoader.defineAndTransformClass(JavassistMockClassLoader.java:119)
      	at org.powermock.core.classloader.MockClassLoader.loadMockClass(MockClassLoader.java:174)
      	at org.powermock.core.classloader.MockClassLoader.loadClassByThisClassLoader(MockClassLoader.java:102)
      	at org.powermock.core.classloader.DeferSupportingClassLoader.loadClass1(DeferSupportingClassLoader.java:147)
      	at org.powermock.core.classloader.DeferSupportingClassLoader.loadClass(DeferSupportingClassLoader.java:98)
      	at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
      	at java.lang.Class.forName0(Native Method)
      	at java.lang.Class.forName(Class.java:348)
      	at sun.reflect.generics.factory.CoreReflectionFactory.makeNamedType(CoreReflectionFactory.java:114)
      	at sun.reflect.generics.visitor.Reifier.visitClassTypeSignature(Reifier.java:125)
      	at sun.reflect.generics.tree.ClassTypeSignature.accept(ClassTypeSignature.java:49)
      	at sun.reflect.annotation.AnnotationParser.parseSig(AnnotationParser.java:439)
      	at sun.reflect.annotation.AnnotationParser.parseClassValue(AnnotationParser.java:420)
      	at sun.reflect.annotation.AnnotationParser.parseClassArray(AnnotationParser.java:724)
      	at sun.reflect.annotation.AnnotationParser.parseArray(AnnotationParser.java:531)
      	at sun.reflect.annotation.AnnotationParser.parseMemberValue(AnnotationParser.java:355)
      	at sun.reflect.annotation.AnnotationParser.parseAnnotation2(AnnotationParser.java:286)
      	at sun.reflect.annotation.AnnotationParser.parseAnnotations2(AnnotationParser.java:120)
      	at sun.reflect.annotation.AnnotationParser.parseAnnotations(AnnotationParser.java:72)
      	at java.lang.Class.createAnnotationData(Class.java:3521)
      	at java.lang.Class.annotationData(Class.java:3510)
      	at java.lang.Class.createAnnotationData(Class.java:3526)
      	at java.lang.Class.annotationData(Class.java:3510)
      	at java.lang.Class.createAnnotationData(Class.java:3526)
      	at java.lang.Class.annotationData(Class.java:3510)
      	at java.lang.Class.getAnnotation(Class.java:3415)
      	at org.junit.internal.MethodSorter.getDeclaredMethods(MethodSorter.java:52)
      	at org.junit.internal.runners.TestClass.getAnnotatedMethods(TestClass.java:45)
      	at org.junit.internal.runners.MethodValidator.validateTestMethods(MethodValidator.java:71)
      	at org.junit.internal.runners.MethodValidator.validateStaticMethods(MethodValidator.java:44)
      	at org.junit.internal.runners.MethodValidator.validateMethodsForDefaultRunner(MethodValidator.java:50)
      	at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl.validate(PowerMockJUnit44RunnerDelegateImpl.java:124)
      	at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl.<init>(PowerMockJUnit44RunnerDelegateImpl.java:86)
      	at org.powermock.modules.junit4.internal.impl.PowerMockJUnit47RunnerDelegateImpl.<init>(PowerMockJUnit47RunnerDelegateImpl.java:42)
      	at org.powermock.modules.junit4.internal.impl.PowerMockJUnit49RunnerDelegateImpl.<init>(PowerMockJUnit49RunnerDelegateImpl.java:25)
      	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
      	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
      	at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
      	at org.powermock.modules.junit4.common.internal.impl.JUnit4TestSuiteChunkerImpl.createDelegatorFromClassloader(JUnit4TestSuiteChunkerImpl.java:165)
      	at org.powermock.modules.junit4.common.internal.impl.JUnit4TestSuiteChunkerImpl.createDelegatorFromClassloader(JUnit4TestSuiteChunkerImpl.java:47)
      	at org.powermock.tests.utils.impl.AbstractTestSuiteChunkerImpl.createTestDelegators(AbstractTestSuiteChunkerImpl.java:107)
      	at org.powermock.modules.junit4.common.internal.impl.JUnit4TestSuiteChunkerImpl.<init>(JUnit4TestSuiteChunkerImpl.java:69)
      	at org.powermock.modules.junit4.common.internal.impl.AbstractCommonPowerMockRunner.<init>(AbstractCommonPowerMockRunner.java:36)
      	at org.powermock.modules.junit4.PowerMockRunner.<init>(PowerMockRunner.java:34)
      	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
      	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
      	at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
      	at org.junit.internal.builders.AnnotatedBuilder.buildRunner(AnnotatedBuilder.java:104)
      	at org.junit.internal.builders.AnnotatedBuilder.runnerForClass(AnnotatedBuilder.java:86)
      	at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
      	at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:26)
      	at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
      	at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:33)
      	at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:49)
      	at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
      	at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
      	at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
      Caused by: javassist.CannotCompileException: cannot find android.support.v4.util.LruCache
      	at javassist.expr.NewExpr.replace(NewExpr.java:236)
      	at org.powermock.core.transformers.javassist.support.PowerMockExpressionEditor.edit(PowerMockExpressionEditor.java:73)
      	at javassist.expr.ExprEditor.loopBody(ExprEditor.java:217)
      	at javassist.expr.ExprEditor.doit(ExprEditor.java:96)
      	at javassist.CtClassType.instrument(CtClassType.java:1541)
      	at org.powermock.core.transformers.javassist.InstrumentMockTransformer.transform(InstrumentMockTransformer.java:41)
      	at org.powermock.core.transformers.javassist.AbstractJavaAssistMockTransformer.transform(AbstractJavaAssistMockTransformer.java:40)
      	at org.powermock.core.transformers.support.DefaultMockTransformerChain.transform(DefaultMockTransformerChain.java:43)
      	at org.powermock.core.classloader.MockClassLoader.transformClass(MockClassLoader.java:184)
      	at org.powermock.core.classloader.javassist.JavassistMockClassLoader.defineAndTransformClass(JavassistMockClassLoader.java:102)
      	... 58 more
      Caused by: javassist.NotFoundException: android.support.v4.util.LruCache
      	at javassist.ClassPool.get(ClassPool.java:422)
      	at javassist.expr.NewExpr.replace(NewExpr.java:210)
      	... 67 more
      

      Steps to reproduce
      1. Clone the latest master branch version
      2. Run a unit test (e.g. LoginPresenterTest)
      3. Observe the initialization error like above

      Expected Outcome

      We can run a unit test without encountering this initialization problem.

      References

      Gliffy Diagrams

        Attachments

          Activity

            People

              ishaanndas Ishaan Das
              f4ww4z Fawwaz Yusran
              Fawwaz Yusran Fawwaz Yusran
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - 3 days
                  3d
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 3 days
                  3d