use of org.eclipse.scout.rt.platform.BeanMetaData in project scout.rt by eclipse.
the class HttpServletControlTest method runTestSetResponseHeader.
protected void runTestSetResponseHeader(boolean mshtml, boolean cspEnabled, String method, boolean expectCspHeader) {
CspEnabledProperty cspProperty = Mockito.mock(CspEnabledProperty.class);
Mockito.when(cspProperty.getValue(ArgumentMatchers.<String>any())).thenReturn(cspEnabled);
s_beans.add(TestingUtility.registerBean(new BeanMetaData(CspEnabledProperty.class, cspProperty)));
HttpClientInfo httpClientInfo = Mockito.mock(HttpClientInfo.class);
Mockito.when(httpClientInfo.isMshtml()).thenReturn(mshtml);
HttpServletControl httpServletControl = new HttpServletControl();
httpServletControl.setCspToken(TEST_CSP_TOKEN);
HttpServlet servlet = Mockito.mock(HttpServlet.class);
HttpSession session = Mockito.mock(HttpSession.class);
HttpServletRequest req = Mockito.mock(HttpServletRequest.class);
HttpServletResponse resp = Mockito.mock(HttpServletResponse.class);
Mockito.when(req.getMethod()).thenReturn(method);
Mockito.when(req.getSession(false)).thenReturn(session);
Mockito.when(session.getAttribute(HttpClientInfo.HTTP_CLIENT_INFO_ATTRIBUTE_NAME)).thenReturn(httpClientInfo);
httpServletControl.setResponseHeaders(servlet, req, resp);
Mockito.verifyZeroInteractions(servlet);
if (expectCspHeader) {
Mockito.verify(resp).setHeader(HttpServletControl.HTTP_HEADER_X_FRAME_OPTIONS, HttpServletControl.SAMEORIGIN);
Mockito.verify(resp).setHeader(HttpServletControl.HTTP_HEADER_X_XSS_PROTECTION, HttpServletControl.XSS_MODE_BLOCK);
if (mshtml) {
Mockito.verify(resp).setHeader(HttpServletControl.HTTP_HEADER_CSP_LEGACY, TEST_CSP_TOKEN);
} else {
Mockito.verify(resp).setHeader(HttpServletControl.HTTP_HEADER_CSP, TEST_CSP_TOKEN);
}
}
}
use of org.eclipse.scout.rt.platform.BeanMetaData in project scout.rt by eclipse.
the class InvocationContextTest method before.
@Before
public void before() {
m_port = mock(TestPort.class);
when(m_port.getRequestContext()).thenReturn(new HashMap<String, Object>());
m_commitListener = mock(ICommitListener.class);
m_rollbackListener = mock(IRollbackListener.class);
m_implementorSpecifics = mock(JaxWsImplementorSpecifics.class);
when(m_commitListener.onCommitPhase1()).thenReturn(true);
m_beans = TestingUtility.registerBeans(new BeanMetaData(BEANS.get(JaxWsImplementorSpecifics.class).getClass(), m_implementorSpecifics).withReplace(true));
}
use of org.eclipse.scout.rt.platform.BeanMetaData in project scout.rt by eclipse.
the class JaxWsPlatformListener method installImplementorSpecifics.
protected void installImplementorSpecifics(final IBeanManager beanManager) {
final String jaxwsImplementor = CONFIG.getPropertyValue(JaxWsImplementorProperty.class);
if (jaxwsImplementor == null) {
return;
}
try {
final Class<?> jaxwsImplementorClazz = Class.forName(jaxwsImplementor);
Assertions.assertTrue(JaxWsImplementorSpecifics.class.isAssignableFrom(jaxwsImplementorClazz), "Implementor class must be of type '{}'.", JaxWsImplementorSpecifics.class.getName());
// Unregister the Bean first, so it can be registered with @Replace annotation anew.
beanManager.unregisterClass(jaxwsImplementorClazz);
beanManager.registerBean(new BeanMetaData(jaxwsImplementorClazz).withReplace(true));
LOG.info("JAX-WS implementor specific class installed: {}", jaxwsImplementorClazz.getName());
} catch (final ClassNotFoundException e) {
throw new PlatformException("Configured JAX-WS implementor specific class", e);
}
}
Aggregations