Search in sources :

Example 1 with AbstractDispatcherCacheHeaderFilter

use of com.adobe.acs.commons.http.headers.impl.AbstractDispatcherCacheHeaderFilter in project acs-aem-commons by Adobe-Consulting-Services.

the class AbstractDispatcherCacheHeaderFilterTest method setup.

@Before
@SuppressWarnings("rawtypes")
public void setup() throws Exception {
    properties = new Hashtable<String, Object>();
    String[] patterns = new String[] { pattern };
    properties.put(AbstractDispatcherCacheHeaderFilter.PROP_FILTER_PATTERN, patterns);
    params = new HashMap();
    agents = new HashSet<String>();
    filter = new AbstractDispatcherCacheHeaderFilter() {

        @Override
        protected String getHeaderName() {
            return headerName;
        }

        @Override
        protected String getHeaderValue() {
            return headerValue;
        }

        @Override
        protected void doActivate(ComponentContext context) throws Exception {
        }
    };
    when(componentContext.getProperties()).thenReturn(properties);
    when(componentContext.getBundleContext()).thenReturn(bundleContext);
    when(bundleContext.registerService(anyString(), any(), (Dictionary) any())).thenReturn(serviceRegistration);
    when(request.getMethod()).thenReturn("GET");
    when(request.getParameterMap()).thenReturn(params);
    final Map<String, Object> attributes = new HashMap<>();
    doAnswer(i -> attributes.put(i.getArgumentAt(0, String.class), i.getArgumentAt(1, Object.class))).when(request).setAttribute(any(), any());
    when(request.getAttribute(any())).thenAnswer(i -> attributes.get(i.getArgumentAt(0, String.class)));
}
Also used : ComponentContext(org.osgi.service.component.ComponentContext) HashMap(java.util.HashMap) AbstractDispatcherCacheHeaderFilter(com.adobe.acs.commons.http.headers.impl.AbstractDispatcherCacheHeaderFilter) ConfigurationException(org.osgi.service.cm.ConfigurationException) Before(org.junit.Before)

Aggregations

AbstractDispatcherCacheHeaderFilter (com.adobe.acs.commons.http.headers.impl.AbstractDispatcherCacheHeaderFilter)1 HashMap (java.util.HashMap)1 Before (org.junit.Before)1 ConfigurationException (org.osgi.service.cm.ConfigurationException)1 ComponentContext (org.osgi.service.component.ComponentContext)1