Package org.auraframework.util

Examples of org.auraframework.util.ServiceLoader


    @Override
    public void setUp() throws Exception {
       super.setUp();
       mci = Mockito.mock(ConfigAdapter.class);
       Mockito.when(mci.isPrivilegedNamespace((String)Mockito.any())).thenReturn(true);
       ServiceLoader msl = ServiceLocatorMocker.mockServiceLocator();
       Mockito.when(msl.get(ConfigAdapter.class)).thenReturn(mci);      
    }
View Full Code Here


        public final FakeRegistry reg;
        public final Lock rLock;
        public final Lock wLock;

        public LockTestInfo() {
            ServiceLoader sl = ServiceLocatorMocker.spyOnServiceLocator();
            this.rLock = Mockito.mock(Lock.class, "rLock");
            this.wLock = Mockito.mock(Lock.class, "wLock");
            CachingService acs = Mockito.spy(sl.get(CachingService.class));
            Mockito.stub(sl.get(CachingService.class)).toReturn(acs);
            Mockito.stub(acs.getReadLock()).toReturn(rLock);
            Mockito.stub(acs.getWriteLock()).toReturn(wLock);
            this.reg = new FakeRegistry(rLock, wLock);
            this.mdr = new MasterDefRegistryImpl(reg);
        }
View Full Code Here

     */
    public static ServiceLoader mockServiceLocator() {
        try {
            ThreadLocal<ServiceLoader> alternateServiceLocator = AuraPrivateAccessor.get(ServiceLocator.class,
                    "alternateServiceLocator");
            ServiceLoader mockedProviderFactory = Mockito.mock(ServiceLoader.class);
            alternateServiceLocator.set(mockedProviderFactory);
            return mockedProviderFactory;
        } catch (Exception exception) {
            throw new RuntimeException("Exception mocking ServiceLocator", exception);
        }
View Full Code Here

     */
    public static ServiceLoader spyOnServiceLocator() {
        try {
            ThreadLocal<ServiceLoader> alternateServiceLocator = AuraPrivateAccessor.get(ServiceLocator.class,
                    "alternateServiceLocator");
            ServiceLoader instance = AuraPrivateAccessor.get(ServiceLocator.class,
                    "instance");
            ServiceLoader previous = alternateServiceLocator.get();
            if (previous != null) {
                throw new RuntimeException("trying to spy on a mock");
            }
            ServiceLoader mockedProviderFactory = Mockito.spy(instance);
            alternateServiceLocator.set(mockedProviderFactory);
            return mockedProviderFactory;
        } catch (Exception exception) {
            throw new RuntimeException("Exception mocking ServiceLocator", exception);
        }
View Full Code Here

     */
    public static ServiceLoader unmockServiceLocator() {
        try {
            ThreadLocal<ServiceLoader> currentMock = AuraPrivateAccessor.get(ServiceLocator.class,
                    "alternateServiceLocator");
            ServiceLoader mock = currentMock.get();
            currentMock.set(null);
            return mock;
        } catch (Exception exception) {
            throw new RuntimeException("Exception unmocking ServiceLocator", exception);
        }
View Full Code Here

TOP

Related Classes of org.auraframework.util.ServiceLoader

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.