Example usage for com.liferay.portal.kernel.test ReflectionTestUtil setFieldValue

List of usage examples for com.liferay.portal.kernel.test ReflectionTestUtil setFieldValue

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.test ReflectionTestUtil setFieldValue.

Prototype

public static void setFieldValue(Object instance, String fieldName, Object value) 

Source Link

Usage

From source file:com.liferay.adaptive.media.image.internal.configuration.AdaptiveMediaImageConfigurationEntryParserTest.java

License:Open Source License

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);

    when(_http.encodeURL(Mockito.eq("desc"))).thenReturn("desc");

    when(_http.decodeURL(Mockito.eq("desc"))).thenReturn("desc");

    when(_http.encodeURL(Mockito.eq("test"))).thenReturn("test");

    when(_http.decodeURL(Mockito.eq("test"))).thenReturn("test");

    ReflectionTestUtil.setFieldValue(_configurationEntryParser, "_http", _http);
}

From source file:com.liferay.adaptive.media.web.internal.processor.DefaultAdaptiveMediaURIResolverTest.java

License:Open Source License

@Before
public void setUp() {
    PortalUtil portalUtil = new PortalUtil();

    portalUtil.setPortal(_portal);/* w  ww. j  a v  a 2s  .  com*/

    ReflectionTestUtil.setFieldValue(_uriResolver, "_portal", _portal);
}

From source file:com.liferay.adaptive.media.web.internal.processor.DefaultAMURIResolverTest.java

License:Open Source License

@Before
public void setUp() {
    PortalUtil portalUtil = new PortalUtil();

    portalUtil.setPortal(_portal);//  w  w  w.  j a  va2  s.c  o  m

    ReflectionTestUtil.setFieldValue(_amURIResolver, "_portal", _portal);
}

From source file:com.liferay.blogs.internal.util.PingbackMethodImplTest.java

License:Open Source License

protected PingbackMethodImpl getPingbackMethodImpl() {
    PingbackMethodImpl pingbackMethodImpl = new PingbackMethodImpl();

    ReflectionTestUtil.setFieldValue(pingbackMethodImpl, "_commentManager", _commentManager);

    pingbackMethodImpl.setBlogsEntryLocalService(_blogsEntryLocalService);
    pingbackMethodImpl.setPortletLocalService(_portletLocalService);
    pingbackMethodImpl.setUserLocalService(_userLocalService);

    return pingbackMethodImpl;
}

From source file:com.liferay.blogs.linkback.LinkbackConsumerTest.java

License:Open Source License

@Before
public void setUp() throws Exception {
    MockitoAnnotations.initMocks(this);

    RegistryUtil.setRegistry(new BasicRegistryImpl());

    setUpBlogsUtil();/*from   ww w. j a  va 2s .c  o m*/

    _linkbackConsumer = new LinkbackConsumer();

    ReflectionTestUtil.setFieldValue(_linkbackConsumer, "_commentManager", _commentManager);

    ReflectionTestUtil.setFieldValue(_linkbackConsumer, "_http", _http);
}

From source file:com.liferay.calendar.service.test.CalendarBookingLocalServiceTest.java

License:Open Source License

protected void setUpCheckBookingMessageListener() {
    Bundle bundle = FrameworkUtil.getBundle(CalendarBookingLocalServiceTest.class);

    BundleContext bundleContext = bundle.getBundleContext();

    ServiceReference<?> serviceReference = bundleContext.getServiceReference(
            "com.liferay.calendar.web.internal.messaging." + "CheckBookingsMessageListener");

    _checkBookingMessageListener = bundleContext.getService(serviceReference);

    ReflectionTestUtil.setFieldValue(_checkBookingMessageListener, "_calendarBookingLocalService",
            ProxyUtil.newProxyInstance(CalendarBookingLocalService.class.getClassLoader(),
                    new Class<?>[] { CalendarBookingLocalService.class }, new InvocationHandler() {

                        @Override
                        public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {

                            if ("checkCalendarBookings".equals(method.getName())) {
                                return null;
                            }/*from  ww  w  .j a v a2  s  .  c o m*/

                            return method.invoke(CalendarBookingLocalServiceUtil.getService(), args);
                        }

                    }));
}

From source file:com.liferay.calendar.service.test.CalendarBookingLocalServiceTest.java

License:Open Source License

protected void tearDownCheckBookingMessageListener() {
    ReflectionTestUtil.setFieldValue(_checkBookingMessageListener, "_calendarBookingLocalService",
            CalendarBookingLocalServiceUtil.getService());
}

From source file:com.liferay.calendar.test.util.CheckBookingsMessageListenerTestUtil.java

License:Open Source License

public static void setUp() {
    Bundle bundle = FrameworkUtil.getBundle(CalendarBookingLocalServiceTest.class);

    BundleContext bundleContext = bundle.getBundleContext();

    ServiceReference<?> serviceReference = bundleContext.getServiceReference(
            "com.liferay.calendar.web.internal.messaging." + "CheckBookingsMessageListener");

    _checkBookingMessageListener = bundleContext.getService(serviceReference);

    ReflectionTestUtil.setFieldValue(_checkBookingMessageListener, "_calendarBookingLocalService",
            ProxyUtil.newProxyInstance(CalendarBookingLocalService.class.getClassLoader(),
                    new Class<?>[] { CalendarBookingLocalService.class }, new InvocationHandler() {

                        @Override
                        public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {

                            if (Objects.equals("checkCalendarBookings", method.getName())) {

                                return null;
                            }/*from   w  ww  .  j  a  va2 s . c  o  m*/

                            return method.invoke(CalendarBookingLocalServiceUtil.getService(), args);
                        }

                    }));
}

From source file:com.liferay.calendar.test.util.CheckBookingsMessageListenerTestUtil.java

License:Open Source License

public static void tearDown() {
    ReflectionTestUtil.setFieldValue(_checkBookingMessageListener, "_calendarBookingLocalService",
            CalendarBookingLocalServiceUtil.getService());
}

From source file:com.liferay.calendar.upgrade.v1_0_6.test.UpgradeSchemaTest.java

License:Open Source License

@Before
public void setUp() throws Exception {
    _group = GroupTestUtil.addGroup();/*  w  ww .  j  a  va2s .co m*/

    _user = UserTestUtil.addUser();

    Bundle bundle = FrameworkUtil.getBundle(UpgradeSchemaTest.class);

    BundleContext bundleContext = bundle.getBundleContext();

    ServiceReference<?> serviceReference = bundleContext.getServiceReference(
            "com.liferay.calendar.web.internal.messaging." + "CheckBookingsMessageListener");

    _checkBookingMessageListener = bundleContext.getService(serviceReference);

    ReflectionTestUtil.setFieldValue(_checkBookingMessageListener, "_calendarBookingLocalService",
            ProxyUtil.newProxyInstance(CalendarBookingLocalService.class.getClassLoader(),
                    new Class<?>[] { CalendarBookingLocalService.class }, new InvocationHandler() {

                        @Override
                        public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {

                            if ("checkCalendarBookings".equals(method.getName())) {
                                return null;
                            }

                            return method.invoke(CalendarBookingLocalServiceUtil.getService(), args);
                        }

                    }));
}