Skip to content

Instantly share code, notes, and snippets.

public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
PrintWriter out = response.getWriter();
CharResponseWrapper wrapper = new CharResponseWrapper((HttpServletResponse) response);
chain.doFilter(request, wrapper);
out.write(wrapper.getData());
}
public ServletOutputStream getOutputStream()
throws IOException {
if (usingWriter)
throw new IllegalStateException
(sm.getString("coyoteResponse.getOutputStream.ise"));
usingOutputStream = true;
if (outputStream == null) {
outputStream = new CoyoteOutputStream(outputBuffer);
private UIComponent createComponentResource(FacesContext ctx, ResourceDependency dep) {
Expressions exprs = expressionsMap.get(dep);
Application app = ctx.getApplication();
String resname = exprs.getName(ctx);
UIComponent c = ctx.getApplication().createComponent("javax.faces.Output");
c.setRendererType(app.getResourceHandler().getRendererTypeForResourceName(resname));
Map<String,Object> attrs = c.getAttributes();
attrs.put("name", resname);
if (exprs.library != null) {
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 1997-2010 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
https://gist.github.com/1251704
package org.richfaces.demo;
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.Writer;
import java.util.LinkedHashSet;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public void processEvent(SystemEvent event) throws AbortProcessingException {
if (event instanceof PostRestoreStateEvent) {
FacesContext.getCurrentInstance().getApplication().subscribeToEvent(PreRenderViewEvent.class, this);
preDecode(getFacesContext());
}
if (event instanceof PreRenderViewEvent) {
FacesContext.getCurrentInstance().getApplication().unsubscribeFromEvent(PreRenderViewEvent.class, this);
preEncodeBegin(getFacesContext());
WebDriver client;
JSFServerSession server;
void testMethod() {
WebElement element = client.get...
element.click();
// test goes to server
FacesContext facesContext = server.getFacesContext();
@lfryc
lfryc / gist:1892612
Created February 23, 2012 12:19
Arquillian/GWT client API snippet
@RunWith(Arquillian.class)
public void TestCase {
@Deployment
...
@Drone
WebDriver driver;
@Test @RunAsClient
public void use_Selenium_and_GWT_dev_mode_to_test_WebStorage() {
@lfryc
lfryc / gist:1892743
Created February 23, 2012 13:18
Raw API proposal for Arquillian performance test
@RunWith(Arquillian.class)
public void PerformanceTestCase {
@Deployment
...
@Resource
HttpClient client;
@Client