@Test public void testThatLoadSucceedsForServiceModule() throws IOException, LazyLoadingException, ClassNotFoundException { Mockito.when(mModulePathsNo1Mock.containsDexFile()).thenReturn(true); Mockito.when(mModulePathsNo1Mock.getDexFile()).thenReturn(mDexFileNo1Mock); Mockito.when(mModulePathsNo1Mock.getOptimizedDexFile()).thenReturn(mOptDexFileNo1Mock); ServiceLike returnedService = mObjectUnderTest.loadServiceModule(MODULE_NAME_NO1, ServiceModule.class.getName()); Assert.assertEquals(returnedService.getClass(), ServiceModule.class); Mockito.verify(mCustomClassLoaderMock) .addDex(Mockito.eq(mDexFileNo1Mock), Mockito.eq(mOptDexFileNo1Mock)); Mockito.verify(mLazyLoadListenerMock) .moduleLazilyLoaded(Mockito.eq(MODULE_NAME_NO1), Mockito.anyLong()); Mockito.verify(mClassLoaderMock).loadClass(ServiceModule.class.getName()); Mockito.verifyZeroInteractions(mNativeModuleLoaderMock); }
public synchronized ServiceLike loadServiceModule(String moduleName, String className) throws LazyLoadingException { try { Class lazyLoadedClass = mLoaderAlgorithm.loadModule(moduleName, className); Constructor c = lazyLoadedClass.getConstructor(Context.class); ServiceLike serviceLike = (ServiceLike) c.newInstance(mContext); return serviceLike; } catch (Throwable t) { throw new LazyLoadingException(t); } }
LazyModuleLoader { public synchronized ServiceLike loadServiceModule(String moduleName, String className) throws LazyLoadingException { try { Class lazyLoadedClass = mLoaderAlgorithm.loadModule(moduleName, className); Constructor c = lazyLoadedClass.getConstructor(Context.class); ServiceLike serviceLike = (ServiceLike) c.newInstance(mContext); return serviceLike; } catch (Throwable t) { throw new LazyLoadingException(t); } } }
LazyModuleLoader { public synchronized ServiceLike loadServiceModule(String moduleName, String className) throws LazyLoadingException { try { Class lazyLoadedClass = mLoaderAlgorithm.loadModule(moduleName, className); Constructor c = lazyLoadedClass.getConstructor(Context.class); ServiceLike serviceLike = (ServiceLike) c.newInstance(mContext); return serviceLike; } catch (Throwable t) { throw new LazyLoadingException(t); } } LazyModuleLoader(Context context, LoaderAlgorithm loaderAlgorithm); }
LazyModuleLoader { public synchronized ServiceLike loadServiceModule(String moduleName, String className) throws LazyLoadingException { try { Class lazyLoadedClass = mLoaderAlgorithm.loadModule(moduleName, className); Constructor c = lazyLoadedClass.getConstructor(Context.class); ServiceLike serviceLike = (ServiceLike) c.newInstance(mContext); return serviceLike; } catch (Throwable t) { throw new LazyLoadingException(t); } } LazyModuleLoader(Context context, LoaderAlgorithm loaderAlgorithm); synchronized ServiceLike loadServiceModule(String moduleName, String className); synchronized SupportFragmentLike loadSupportFragmentModule(
      Fragment hostingFragment, String moduleName, String className); synchronized FragmentLike loadFragmentModule(
      android.app.Fragment hostingFragment, String moduleName, String className); synchronized ActivityLike loadActivityModule(
      Activity activity, String moduleName, String className); synchronized Class loadModule(String moduleName, String className); synchronized void installModule(String moduleName); }
LazyModuleLoader { public synchronized ServiceLike loadServiceModule(String moduleName, String className) throws LazyLoadingException { try { Class lazyLoadedClass = mLoaderAlgorithm.loadModule(moduleName, className); Constructor c = lazyLoadedClass.getConstructor(Context.class); ServiceLike serviceLike = (ServiceLike) c.newInstance(mContext); return serviceLike; } catch (Throwable t) { throw new LazyLoadingException(t); } } LazyModuleLoader(Context context, LoaderAlgorithm loaderAlgorithm); synchronized ServiceLike loadServiceModule(String moduleName, String className); synchronized SupportFragmentLike loadSupportFragmentModule(
      Fragment hostingFragment, String moduleName, String className); synchronized FragmentLike loadFragmentModule(
      android.app.Fragment hostingFragment, String moduleName, String className); synchronized ActivityLike loadActivityModule(
      Activity activity, String moduleName, String className); synchronized Class loadModule(String moduleName, String className); synchronized void installModule(String moduleName);  }