Author: nbelaevski
Date: 2007-12-21 11:55:49 -0500 (Fri, 21 Dec 2007)
New Revision: 4956
Removed:
trunk/ui/columns/src/test/java/org/richfaces/facelet/mock/MockHttpServletRequest.java
trunk/ui/columns/src/test/java/org/richfaces/facelet/mock/MockHttpServletResponse.java
trunk/ui/columns/src/test/java/org/richfaces/facelet/mock/MockHttpSession.java
trunk/ui/columns/src/test/java/org/richfaces/facelet/mock/MockRequestDispatcher.java
trunk/ui/columns/src/test/java/org/richfaces/facelet/mock/MockResponseWriter.java
trunk/ui/columns/src/test/java/org/richfaces/facelet/mock/MockServletContext.java
trunk/ui/columns/src/test/java/org/richfaces/facelet/mock/MockServletInputStream.java
trunk/ui/columns/src/test/java/org/richfaces/facelet/mock/MockServletOutputStream.java
Modified:
trunk/ui/columns/src/test/java/org/richfaces/facelet/FaceletTagTestCase.java
trunk/ui/columns/src/test/java/org/richfaces/facelet/tag/ColumnsFaceletTagTest.java
Log:
columns test updated
Modified: trunk/ui/columns/src/test/java/org/richfaces/facelet/FaceletTagTestCase.java
===================================================================
---
trunk/ui/columns/src/test/java/org/richfaces/facelet/FaceletTagTestCase.java 2007-12-21
16:35:25 UTC (rev 4955)
+++
trunk/ui/columns/src/test/java/org/richfaces/facelet/FaceletTagTestCase.java 2007-12-21
16:55:49 UTC (rev 4956)
@@ -15,171 +15,40 @@
package org.richfaces.facelet;
-import java.io.FileNotFoundException;
-import java.io.OutputStream;
import java.io.StringWriter;
-import java.net.URI;
-import java.net.URL;
-import javax.faces.FacesException;
-import javax.faces.FactoryFinder;
-import javax.faces.application.ApplicationFactory;
-import javax.faces.context.FacesContext;
-import javax.faces.context.FacesContextFactory;
import javax.faces.context.ResponseWriter;
-import javax.faces.lifecycle.LifecycleFactory;
-import javax.servlet.ServletContext;
-import javax.servlet.ServletContextEvent;
-import javax.servlet.ServletContextListener;
-import junit.framework.TestCase;
+import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
-import org.richfaces.facelet.mock.MockHttpServletRequest;
-import org.richfaces.facelet.mock.MockHttpServletResponse;
-import org.richfaces.facelet.mock.MockServletContext;
-
import com.sun.facelets.FaceletFactory;
import com.sun.facelets.compiler.Compiler;
import com.sun.facelets.compiler.SAXCompiler;
import com.sun.facelets.impl.DefaultFaceletFactory;
import com.sun.facelets.impl.ResourceResolver;
-public abstract class FaceletTagTestCase extends TestCase implements ResourceResolver {
+public abstract class FaceletTagTestCase extends AbstractAjax4JsfTestCase implements
ResourceResolver {
-private final String filePath = this.getDirectory();
+ public FaceletTagTestCase(String name) {
+ super(name);
+ }
-private final URI base = this.getContext();
+ public void setUp() throws Exception {
+ super.setUp();
+ Compiler c = new SAXCompiler();
+ //c.setTrimmingWhitespace(true);
+ FaceletFactory factory = new DefaultFaceletFactory(c, this);
+ FaceletFactory.setInstance(factory);
-protected MockServletContext servletContext;
+ facesContext.setViewRoot(facesContext.getApplication().getViewHandler().createView(facesContext,
"/test"));
-protected MockHttpServletRequest servletRequest;
+ ResponseWriter rw = facesContext.getRenderKit().createResponseWriter(new
StringWriter(), null, null);
+ facesContext.setResponseWriter(rw);
+ }
-protected MockHttpServletResponse servletResponse;
+ public void tearDown() throws Exception {
+ super.tearDown();
+ this.servletContext = null;
+ }
-private ApplicationFactory factoryApplication;
-
-private FacesContextFactory factoryFacesContext;
-
-private LifecycleFactory factoryLifecycle;
-
-private boolean initialized = false;
-
-protected URI getContext() {
- try {
- ClassLoader cl = Thread.currentThread().getContextClassLoader();
- URL url = cl.getResource(this.filePath);
- System.out.println(new URI(url.toString()));
- if (url == null) {
- throw new FileNotFoundException(cl.getResource("").getFile()
- + this.filePath + " was not found");
- } else {
- return new URI(url.toString());
- }
- } catch (Exception e) {
- throw new RuntimeException("Error Initializing Context", e);
- }
}
-
-protected URL getLocalFile(String name) throws FileNotFoundException {
- ClassLoader cl = Thread.currentThread().getContextClassLoader();
- URL url = cl.getResource(this.filePath + "/" + name);
- if (url == null) {
- throw new FileNotFoundException(cl.getResource("").getFile() + name
- + " was not found");
- }
- return url;
-}
-
-private String getDirectory() {
- return this.getClass().getName().substring(0,
- this.getClass().getName().lastIndexOf('.')).replace('.',
'/') + "/";
-}
-
-protected void setUp() throws Exception {
- super.setUp();
- URI context = this.getContext();
- System.out.println(context.getPath());
- this.servletContext = new MockServletContext(context);
- this.servletRequest = new MockHttpServletRequest(this.servletContext,
- context);
- this.servletResponse = new MockHttpServletResponse();
-
- // initialize Faces
- this.initFaces();
-
- FacesContext faces = this.factoryFacesContext.getFacesContext(this.servletContext,
- this.servletRequest, this.servletResponse,
- this.factoryLifecycle
- .getLifecycle(LifecycleFactory.DEFAULT_LIFECYCLE));
-
-
- Compiler c = new SAXCompiler();
- //c.setTrimmingWhitespace(true);
- FaceletFactory factory = new DefaultFaceletFactory(c, this);
- FaceletFactory.setInstance(factory);
-
- faces.setViewRoot(faces.getApplication().getViewHandler().createView(faces,
"/test"));
-
- ResponseWriter rw = faces.getRenderKit().createResponseWriter(new StringWriter(),
null, null);
- faces.setResponseWriter(rw);
-}
-
-public void setRequest(String method, String path, OutputStream os) {
- this.servletRequest = new MockHttpServletRequest(this.servletContext, method, path);
- //this.servletResponse = new MockHttpServletResponse(os);
- this.factoryFacesContext.getFacesContext(this.servletContext,
- this.servletRequest, this.servletResponse,
- this.factoryLifecycle
- .getLifecycle(LifecycleFactory.DEFAULT_LIFECYCLE));
-}
-
-private void initFaces() throws Exception {
- if (!this.initialized) {
- this.initialized = true;
- this.initFacesListener(this.servletContext);
- this.factoryApplication = (ApplicationFactory) FactoryFinder
- .getFactory(FactoryFinder.APPLICATION_FACTORY);
- this.factoryFacesContext = (FacesContextFactory) FactoryFinder
- .getFactory(FactoryFinder.FACES_CONTEXT_FACTORY);
- this.factoryLifecycle = (LifecycleFactory) FactoryFinder
- .getFactory(FactoryFinder.LIFECYCLE_FACTORY);
-
- /*
- Application application = this.factoryApplication.getApplication();
- application.setViewHandler(new FaceletViewHandler(application
- .getViewHandler()));
- */
- }
-}
-
-protected void initFacesListener(ServletContext context) throws Exception {
- ServletContextListener listener;
- Class type;
- try {
- type = Class.forName("com.sun.faces.config.ConfigureListener");
- } catch (ClassNotFoundException e) {
- try {
- type = Class.forName("");
- } catch (ClassNotFoundException e2) {
- throw new FileNotFoundException(
- "Either JSF-RI or MyFaces needs to be on the classpath with
their supported Jars");
- }
- }
- listener = (ServletContextListener) type.newInstance();
- listener.contextInitialized(new ServletContextEvent(context));
-}
-
-protected void tearDown() throws Exception {
- super.tearDown();
- this.servletContext = null;
-}
-
-public URL resolveUrl(String path) {
- try {
- return new URL(this.getContext().toURL(), path.substring(1));
- } catch (Exception e) {
- throw new FacesException(e);
- }
-}
-
-}
Deleted:
trunk/ui/columns/src/test/java/org/richfaces/facelet/mock/MockHttpServletRequest.java
===================================================================
---
trunk/ui/columns/src/test/java/org/richfaces/facelet/mock/MockHttpServletRequest.java 2007-12-21
16:35:25 UTC (rev 4955)
+++
trunk/ui/columns/src/test/java/org/richfaces/facelet/mock/MockHttpServletRequest.java 2007-12-21
16:55:49 UTC (rev 4956)
@@ -1,397 +0,0 @@
-/**
- * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
- * Licensed under the Common Development and Distribution License,
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *
http://www.sun.com/cddl/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
-package org.richfaces.facelet.mock;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.Reader;
-import java.io.UnsupportedEncodingException;
-import java.net.URI;
-import java.security.Principal;
-import java.text.DateFormat;
-import java.text.ParseException;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.Enumeration;
-import java.util.Hashtable;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-import java.util.Properties;
-import java.util.Vector;
-
-import javax.servlet.RequestDispatcher;
-import javax.servlet.ServletContext;
-import javax.servlet.ServletInputStream;
-import javax.servlet.http.Cookie;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpSession;
-
-
-/**
- *
- * @author Jacob Hookom
- * @version $Id: MockHttpServletRequest.java,v 1.2 2005/12/21 05:51:05 jhook Exp $
- */
-public class MockHttpServletRequest implements HttpServletRequest {
-
- private final ServletContext servletContext;
-
- private final URI uri;
-
- private final String method;
-
- private Cookie[] cookies = new Cookie[0];
-
- private final Hashtable headers = new Hashtable();
-
- private String remoteUser;
-
- private String servletPath;
-
- private HttpSession session;
-
- private final Hashtable attributes = new Hashtable();
-
- private final Properties param = new Properties();
-
- private String characterEncoding = "ISO-8859-1";
-
- private String contentType = "text/html";
-
- private int contentLength = 0;
-
- private String protocol = "HTTP/1.1";
-
- private String localName = "localhost";
-
- private int localPort = 80;
-
- private String remoteAddr = "127.0.0.1";
-
- private String remoteHost = "localhost";
-
- private Locale locale = Locale.getDefault();
-
- private Vector locales = new Vector(Arrays.asList(Locale
- .getAvailableLocales()));
-
- private boolean secure = false;
-
- private int remotePort = 1024;
-
- private String localAddr = "127.0.0.1";
-
- private ServletInputStream inputStream = new MockServletInputStream();
-
- public MockHttpServletRequest(ServletContext servletContext, URI uri) {
- this(servletContext, "GET", uri);
- }
-
- public MockHttpServletRequest(ServletContext servletContext, String uri) {
- this(servletContext, "GET", uri);
- }
-
- public MockHttpServletRequest(ServletContext servletContext, String method,
- String uri) {
- this(servletContext, method, URI.create(uri));
- }
-
- public MockHttpServletRequest(ServletContext servletContext, String method,
- URI uri) {
- this.servletContext = servletContext;
- this.uri = uri;
- this.method = method;
-
- String q = this.uri.getRawQuery();
- if (q != null) {
- String[] p = q.split("(&|=)");
- for (int i = 0; i < p.length; i += 2) {
- this.param.put(p[i], p[i + 1]);
- }
- }
- }
-
- public String getAuthType() {
- return BASIC_AUTH;
- }
-
- public Cookie[] getCookies() {
- return this.cookies;
- }
-
- public long getDateHeader(String name) {
- String hdr = this.getHeader(name);
- if (hdr != null) {
- try {
- return DateFormat.getDateInstance(DateFormat.FULL).parse(hdr)
- .getTime();
- } catch (ParseException e) {
- throw new IllegalArgumentException("Header " + name + ":
"
- + hdr);
- }
- }
- return -1;
- }
-
- public String getHeader(String name) {
- Object obj = this.headers.get(name);
- if (obj instanceof List) {
- return ((List) obj).get(0).toString();
- } else if (obj instanceof String) {
- return (String) obj;
- }
- return null;
- }
-
- public Enumeration getHeaders(String name) {
- Object obj = this.headers.get(name);
- if (obj instanceof Vector) {
- return ((Vector) obj).elements();
- } else if (obj instanceof String) {
- Vector v = new Vector();
- v.add(obj);
- return v.elements();
- }
- return null;
- }
-
- public Enumeration getHeaderNames() {
- return this.headers.keys();
- }
-
- public int getIntHeader(String name) {
- String hdr = this.getHeader(name);
- if (hdr != null) {
- try {
- return Integer.parseInt(hdr);
- } catch (Exception e) {
- throw new IllegalArgumentException("Header " + name + ":
"
- + hdr);
- }
- }
- return -1;
- }
-
- public String getMethod() {
- return this.method;
- }
-
- public String getPathInfo() {
- return this.uri.getPath();
- }
-
- public String getPathTranslated() {
- return this.servletContext.getRealPath(this.uri.getPath());
- }
-
- public String getContextPath() {
- return this.uri.getPath();
- }
-
- public String getQueryString() {
- return this.uri.getQuery();
- }
-
- public String getRemoteUser() {
- return this.remoteUser;
- }
-
- public boolean isUserInRole(String role) {
- throw new UnsupportedOperationException();
- }
-
- public Principal getUserPrincipal() {
- throw new UnsupportedOperationException();
- }
-
- public String getRequestedSessionId() {
- return this.getParameter("jsessionid");
- }
-
- public String getRequestURI() {
- return this.uri.getPath();
- }
-
- public StringBuffer getRequestURL() {
- return new StringBuffer(this.uri.toString());
- }
-
- public String getServletPath() {
- return this.servletPath;
- }
-
- public HttpSession getSession(boolean create) {
- if (this.session == null && create) {
- this.session = new MockHttpSession(this.servletContext);
- }
- return this.session;
- }
-
- public HttpSession getSession() {
- return this.getSession(true);
- }
-
- public boolean isRequestedSessionIdValid() {
- throw new UnsupportedOperationException();
- }
-
- public boolean isRequestedSessionIdFromCookie() {
- throw new UnsupportedOperationException();
- }
-
- public boolean isRequestedSessionIdFromURL() {
- throw new UnsupportedOperationException();
- }
-
- public boolean isRequestedSessionIdFromUrl() {
- throw new UnsupportedOperationException();
- }
-
- public Object getAttribute(String name) {
- return this.attributes.get(name);
- }
-
- public Enumeration getAttributeNames() {
- return this.attributes.keys();
- }
-
- public String getCharacterEncoding() {
- return this.characterEncoding;
- }
-
- public void setCharacterEncoding(String characterEncoding)
- throws UnsupportedEncodingException {
- this.characterEncoding = characterEncoding;
- }
-
- public int getContentLength() {
- return this.contentLength;
- }
-
- public String getContentType() {
- return this.contentType;
- }
-
- public ServletInputStream getInputStream() throws IOException {
- return this.inputStream;
- }
-
- public String getParameter(String name) {
- return this.param.getProperty(name);
- }
-
- public Enumeration getParameterNames() {
- return this.param.keys();
- }
-
- public String[] getParameterValues(String name) {
- String p = this.param.getProperty(name);
- if (p != null) {
- return p.split(",");
- }
- return null;
- }
-
- public void setParameter(String name, String value) {
- this.param.put(name, value);
- }
-
- public Map getParameterMap() {
- return Collections.unmodifiableMap(this.param);
- }
-
- public String getProtocol() {
- return this.protocol;
- }
-
- public String getScheme() {
- return this.uri.getScheme();
- }
-
- public String getServerName() {
- return this.localName;
- }
-
- public int getServerPort() {
- return this.localPort;
- }
-
- public BufferedReader getReader() throws IOException {
- if (this.inputStream != null) {
- Reader sourceReader = (this.characterEncoding != null) ? new
InputStreamReader(
- this.inputStream, this.characterEncoding)
- : new InputStreamReader(this.inputStream);
- return new BufferedReader(sourceReader);
- } else {
- return null;
- }
- }
-
- public String getRemoteAddr() {
- return this.remoteAddr;
- }
-
- public String getRemoteHost() {
- return this.remoteHost;
- }
-
- public void setAttribute(String name, Object value) {
- this.attributes.put(name, value);
- }
-
- public void removeAttribute(String name) {
- this.attributes.remove(name);
- }
-
- public Locale getLocale() {
- return this.locale;
- }
-
- public Enumeration getLocales() {
- return this.locales.elements();
- }
-
- public boolean isSecure() {
- return this.secure;
- }
-
- public RequestDispatcher getRequestDispatcher(String path) {
- return this.servletContext.getRequestDispatcher(path);
- }
-
- public String getRealPath(String path) {
- return this.servletContext.getRealPath(path);
- }
-
- public int getRemotePort() {
- return this.remotePort;
- }
-
- public String getLocalName() {
- return this.localName;
- }
-
- public String getLocalAddr() {
- return this.localAddr;
- }
-
- public int getLocalPort() {
- return this.localPort;
- }
-
-}
Deleted:
trunk/ui/columns/src/test/java/org/richfaces/facelet/mock/MockHttpServletResponse.java
===================================================================
---
trunk/ui/columns/src/test/java/org/richfaces/facelet/mock/MockHttpServletResponse.java 2007-12-21
16:35:25 UTC (rev 4955)
+++
trunk/ui/columns/src/test/java/org/richfaces/facelet/mock/MockHttpServletResponse.java 2007-12-21
16:55:49 UTC (rev 4956)
@@ -1,193 +0,0 @@
-/**
- * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
- * Licensed under the Common Development and Distribution License,
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *
http://www.sun.com/cddl/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
-package org.richfaces.facelet.mock;
-
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.util.Hashtable;
-import java.util.Locale;
-
-import javax.servlet.ServletOutputStream;
-import javax.servlet.http.Cookie;
-import javax.servlet.http.HttpServletResponse;
-
-/**
- *
- * @author Jacob Hookom
- * @version $Id: MockHttpServletResponse.java,v 1.2 2005/07/19 00:49:01 jhook Exp $
- */
-public class MockHttpServletResponse implements HttpServletResponse {
-
- private boolean committed = false;
- private int status;
- private String message;
- private Hashtable headers = new Hashtable();
- private String characterEncoding = "ISO-8859-1";
- private String contentType = "text/html";
- private long contentLength = 0;
- private int bufferSize = 0;
- private Locale locale = Locale.getDefault();
-
- public MockHttpServletResponse() {
- super();
- }
-
- public void addCookie(Cookie cookie) {
- // TODO Auto-generated method stub
-
- }
-
- public boolean containsHeader(String name) {
- return this.headers.contains(name);
- }
-
- public String encodeURL(String url) {
- return url;
- }
-
- public String encodeRedirectURL(String url) {
- return url;
- }
-
- public String encodeUrl(String url) {
- return url;
- }
-
- public String encodeRedirectUrl(String url) {
- return this.encodeRedirectURL(url);
- }
-
- public void sendError(int status, String message) throws IOException {
- if (this.committed) {
- throw new IllegalStateException("Response is already committed");
- }
- this.status = status;
- this.message = message;
- this.committed = true;
- }
-
- public void sendError(int status) throws IOException {
- if (this.committed) {
- throw new IllegalStateException("Response is already committed");
- }
- this.status = status;
- this.committed = true;
- }
-
- public void sendRedirect(String path) throws IOException {
- if (this.committed) {
- throw new IllegalStateException("Response is already committed");
- }
- this.committed = true;
- }
-
- public void setDateHeader(String name, long date) {
- this.headers.put(name, ""+date);
- }
-
- public void addDateHeader(String name, long date) {
- this.headers.put(name, ""+date);
- }
-
- public void setHeader(String name, String value) {
- this.headers.put(name, value);
- }
-
- public void addHeader(String name, String value) {
- this.headers.put(name, value);
- }
-
- public void setIntHeader(String name, int value) {
- this.headers.put(name, ""+value);
- }
-
- public void addIntHeader(String name, int value) {
- this.headers.put(name, ""+value);
- }
-
- public void setStatus(int sc) {
- this.status = sc;
- }
-
- public void setStatus(int sc, String message) {
- this.status = sc;
- this.message = message;
- }
-
- public String getCharacterEncoding() {
- return this.characterEncoding;
- }
-
- public String getContentType() {
- return this.contentType;
- }
-
- public ServletOutputStream getOutputStream() throws IOException {
- // TODO Auto-generated method stub
- return null;
- }
-
- public PrintWriter getWriter() throws IOException {
- // TODO Auto-generated method stub
- return null;
- }
-
- public void setCharacterEncoding(String characterEncoding) {
- this.characterEncoding = characterEncoding;
- }
-
- public void setContentLength(int contentLength) {
- this.contentLength = contentLength;
- }
-
- public void setContentType(String contentType) {
- this.contentType = contentType;
- }
-
- public void setBufferSize(int sz) {
- this.bufferSize = sz;
- }
-
- public int getBufferSize() {
- return this.bufferSize;
- }
-
- public void flushBuffer() throws IOException {
-
- }
-
- public void resetBuffer() {
-
- }
-
- public boolean isCommitted() {
- return this.committed;
- }
-
- public void reset() {
- // TODO Auto-generated method stub
-
- }
-
- public void setLocale(Locale locale) {
- this.locale = locale;
- }
-
- public Locale getLocale() {
- return this.locale;
- }
-
-}
Deleted: trunk/ui/columns/src/test/java/org/richfaces/facelet/mock/MockHttpSession.java
===================================================================
---
trunk/ui/columns/src/test/java/org/richfaces/facelet/mock/MockHttpSession.java 2007-12-21
16:35:25 UTC (rev 4955)
+++
trunk/ui/columns/src/test/java/org/richfaces/facelet/mock/MockHttpSession.java 2007-12-21
16:55:49 UTC (rev 4956)
@@ -1,115 +0,0 @@
-/**
- * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
- * Licensed under the Common Development and Distribution License,
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *
http://www.sun.com/cddl/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
-package org.richfaces.facelet.mock;
-
-import java.util.Enumeration;
-import java.util.Hashtable;
-
-import javax.servlet.ServletContext;
-import javax.servlet.http.HttpSession;
-import javax.servlet.http.HttpSessionContext;
-
-/**
- *
- * @author Jacob Hookom
- * @version $Id: MockHttpSession.java,v 1.2 2005/07/19 00:49:02 jhook Exp $
- */
-public class MockHttpSession implements HttpSession {
-
- private final Hashtable attributes = new Hashtable();
- private final long creationTime;
- private String id;
- private long lastAccessedTime;
- private final ServletContext servletContext;
- private int maxInactiveInterval = 20;
-
- public MockHttpSession(ServletContext servletContext) {
- this.servletContext = servletContext;
- this.creationTime = System.currentTimeMillis();
- this.id = "" + this.creationTime;
- this.lastAccessedTime = this.creationTime;
- }
-
- public long getCreationTime() {
- return this.creationTime;
- }
-
- public String getId() {
- return this.id;
- }
-
- public long getLastAccessedTime() {
- return this.lastAccessedTime;
- }
-
- public ServletContext getServletContext() {
- return this.servletContext;
- }
-
- public void setMaxInactiveInterval(int interval) {
- this.maxInactiveInterval = interval;
- }
-
- public int getMaxInactiveInterval() {
- return this.maxInactiveInterval;
- }
-
- public HttpSessionContext getSessionContext() {
- throw new UnsupportedOperationException();
- }
-
- public Object getAttribute(String name) {
- return this.attributes.get(name);
- }
-
- public Object getValue(String name) {
- throw new UnsupportedOperationException();
- }
-
- public Enumeration getAttributeNames() {
- return this.attributes.keys();
- }
-
- public String[] getValueNames() {
- throw new UnsupportedOperationException();
- }
-
- public void setAttribute(String name, Object value) {
- this.attributes.put(name, value);
- }
-
- public void putValue(String arg0, Object arg1) {
- throw new UnsupportedOperationException();
-
- }
-
- public void removeAttribute(String name) {
- this.attributes.remove(name);
- }
-
- public void removeValue(String arg0) {
- throw new UnsupportedOperationException();
- }
-
- public void invalidate() {
-
- }
-
- public boolean isNew() {
- return false;
- }
-
-}
Deleted:
trunk/ui/columns/src/test/java/org/richfaces/facelet/mock/MockRequestDispatcher.java
===================================================================
---
trunk/ui/columns/src/test/java/org/richfaces/facelet/mock/MockRequestDispatcher.java 2007-12-21
16:35:25 UTC (rev 4955)
+++
trunk/ui/columns/src/test/java/org/richfaces/facelet/mock/MockRequestDispatcher.java 2007-12-21
16:55:49 UTC (rev 4956)
@@ -1,51 +0,0 @@
-/**
- * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
- * Licensed under the Common Development and Distribution License,
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *
http://www.sun.com/cddl/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
-package org.richfaces.facelet.mock;
-
-import java.io.IOException;
-import java.net.URL;
-
-import javax.servlet.RequestDispatcher;
-import javax.servlet.ServletException;
-import javax.servlet.ServletRequest;
-import javax.servlet.ServletResponse;
-
-/**
- *
- * @author Jacob Hookom
- * @version $Id: MockRequestDispatcher.java,v 1.1 2005/07/18 08:25:42 jhook Exp $
- */
-public class MockRequestDispatcher implements RequestDispatcher {
-
- protected final URL url;
-
- public MockRequestDispatcher(URL url) {
- this.url = url;
- }
-
- public void forward(ServletRequest request, ServletResponse response)
- throws ServletException, IOException {
- // TODO Auto-generated method stub
-
- }
-
- public void include(ServletRequest request, ServletResponse response)
- throws ServletException, IOException {
- // TODO Auto-generated method stub
-
- }
-
-}
Deleted:
trunk/ui/columns/src/test/java/org/richfaces/facelet/mock/MockResponseWriter.java
===================================================================
---
trunk/ui/columns/src/test/java/org/richfaces/facelet/mock/MockResponseWriter.java 2007-12-21
16:35:25 UTC (rev 4955)
+++
trunk/ui/columns/src/test/java/org/richfaces/facelet/mock/MockResponseWriter.java 2007-12-21
16:55:49 UTC (rev 4956)
@@ -1,178 +0,0 @@
-/**
- * Licensed under the Common Development and Distribution License,
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *
http://www.sun.com/cddl/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-package org.richfaces.facelet.mock;
-
-
-import java.io.IOException;
-import java.io.Writer;
-
-import javax.faces.component.UIComponent;
-import javax.faces.context.ResponseWriter;
-
-
-
-/**
- * @author Jacob Hookom
- *
- */
-public class MockResponseWriter extends ResponseWriter {
-
- private final Writer writer;
- private boolean startOpen;
-
- public MockResponseWriter(Writer writer) {
- this.writer = writer;
- }
-
- /* (non-Javadoc)
- * @see javax.faces.context.ResponseWriter#getContentType()
- */
- public String getContentType() {
- return "text/html";
- }
-
- /* (non-Javadoc)
- * @see javax.faces.context.ResponseWriter#getCharacterEncoding()
- */
- public String getCharacterEncoding() {
- return "UTF-8";
- }
-
- /* (non-Javadoc)
- * @see javax.faces.context.ResponseWriter#flush()
- */
- public void flush() throws IOException {
- // TODO Auto-generated method stub
-
- }
-
- /* (non-Javadoc)
- * @see javax.faces.context.ResponseWriter#startDocument()
- */
- public void startDocument() throws IOException {
- // TODO Auto-generated method stub
-
- }
-
- /* (non-Javadoc)
- * @see javax.faces.context.ResponseWriter#endDocument()
- */
- public void endDocument() throws IOException {
- // TODO Auto-generated method stub
-
- }
-
- private void closeStart() throws IOException {
- if (this.startOpen) {
- this.writer.write('>');
- }
- this.startOpen = false;
- }
-
- /* (non-Javadoc)
- * @see javax.faces.context.ResponseWriter#startElement(java.lang.String,
javax.faces.component.UIComponent)
- */
- public void startElement(String arg0, UIComponent arg1) throws IOException {
- this.closeStart();
- this.writer.write('<');
- this.writer.write(arg0);
- this.startOpen = true;
- }
-
- /* (non-Javadoc)
- * @see javax.faces.context.ResponseWriter#endElement(java.lang.String)
- */
- public void endElement(String arg0) throws IOException {
- if (this.startOpen) {
- this.writer.write("/>");
- this.startOpen = false;
- } else {
- this.writer.write("</");
- this.writer.write(arg0);
- this.writer.write('>');
- }
-
- }
-
- /* (non-Javadoc)
- * @see javax.faces.context.ResponseWriter#writeAttribute(java.lang.String,
java.lang.Object, java.lang.String)
- */
- public void writeAttribute(String arg0, Object arg1, String arg2)
- throws IOException {
- if (arg1 != null) {
- writer.write(' ');
- writer.write(arg0);
- writer.write("=\"");
- writer.write(arg1.toString());
- writer.write('"');
- }
- }
-
- /* (non-Javadoc)
- * @see javax.faces.context.ResponseWriter#writeURIAttribute(java.lang.String,
java.lang.Object, java.lang.String)
- */
- public void writeURIAttribute(String arg0, Object arg1, String arg2)
- throws IOException {
- this.writeAttribute(arg0, arg1, arg2);
- }
-
- /* (non-Javadoc)
- * @see javax.faces.context.ResponseWriter#writeComment(java.lang.Object)
- */
- public void writeComment(Object arg0) throws IOException {
- this.closeStart();
- this.writer.write("<!-- ");
- this.writer.write(arg0 != null ? arg0.toString() : "null");
- this.writer.write(" -->");
- }
-
- /* (non-Javadoc)
- * @see javax.faces.context.ResponseWriter#writeText(java.lang.Object,
java.lang.String)
- */
- public void writeText(Object arg0, String arg1) throws IOException {
- this.closeStart();
- this.writer.write(arg0 != null ? arg0.toString() : "null");
- }
-
- /* (non-Javadoc)
- * @see javax.faces.context.ResponseWriter#writeText(char[], int, int)
- */
- public void writeText(char[] arg0, int arg1, int arg2) throws IOException {
- this.closeStart();
- this.writer.write(arg0, arg1, arg2);
- }
-
- /* (non-Javadoc)
- * @see javax.faces.context.ResponseWriter#cloneWithWriter(java.io.Writer)
- */
- public ResponseWriter cloneWithWriter(Writer arg0) {
- return new MockResponseWriter(arg0);
- }
-
- /* (non-Javadoc)
- * @see java.io.Writer#write(char[], int, int)
- */
- public void write(char[] cbuf, int off, int len) throws IOException {
- this.writer.write(cbuf, off, len);
- }
-
- /* (non-Javadoc)
- * @see java.io.Writer#close()
- */
- public void close() throws IOException {
- // TODO Auto-generated method stub
-
- }
-
-}
Deleted:
trunk/ui/columns/src/test/java/org/richfaces/facelet/mock/MockServletContext.java
===================================================================
---
trunk/ui/columns/src/test/java/org/richfaces/facelet/mock/MockServletContext.java 2007-12-21
16:35:25 UTC (rev 4955)
+++
trunk/ui/columns/src/test/java/org/richfaces/facelet/mock/MockServletContext.java 2007-12-21
16:55:49 UTC (rev 4956)
@@ -1,240 +0,0 @@
-/**
- * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
- * Licensed under the Common Development and Distribution License,
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *
http://www.sun.com/cddl/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
-package org.richfaces.facelet.mock;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.MalformedURLException;
-import java.net.URI;
-import java.net.URL;
-import java.util.Collections;
-import java.util.Enumeration;
-import java.util.HashSet;
-import java.util.Hashtable;
-import java.util.Properties;
-import java.util.Set;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import javax.servlet.RequestDispatcher;
-import javax.servlet.Servlet;
-import javax.servlet.ServletContext;
-import javax.servlet.ServletException;
-
-/**
- *
- * @author Jacob Hookom
- * @version $Id: MockServletContext.java,v 1.1 2005/07/18 08:25:42 jhook Exp $
- */
-public class MockServletContext implements ServletContext {
-
- protected final Properties initParams = new Properties();
-
- protected final Logger log = Logger
- .getLogger("facelets.mock.ServletContext");
-
- protected final Hashtable attributes = new Hashtable();
-
- protected final URI base;
-
- public MockServletContext(URI base) {
- this.base = base;
- File f = new File(base);
- if (!f.exists()) {
- throw new IllegalArgumentException("File: " + base.getPath()
- + " doesn't exist");
- }
- }
-
- public ServletContext getContext(String name) {
- throw new UnsupportedOperationException();
- }
-
- public int getMajorVersion() {
- return 2;
- }
-
- public int getMinorVersion() {
- return 3;
- }
-
- public String getMimeType(String path) {
- throw new UnsupportedOperationException();
- }
-
- public Set getResourcePaths(String path) {
- URI uri = this.resolve(path);
- if (uri != null) {
- File f = new File(uri);
- if (f.exists() && f.isDirectory()) {
- File[] c = f.listFiles();
- Set s = new HashSet();
- int start = f.getAbsolutePath().length();
- for (int i = 0; i < c.length; i++) {
- s.add(c[i].getAbsolutePath().substring(start));
- }
- return s;
- }
- }
- return Collections.EMPTY_SET;
- }
-
- public URL getResource(String path) throws MalformedURLException {
- URI uri = this.resolve(path);
- if (uri != null) {
- File f = new File(uri);
- if (f.exists()) {
- return uri.toURL();
- }
- }
- return null;
- }
-
- public InputStream getResourceAsStream(String path) {
- URI uri = this.resolve(path);
- if (uri != null) {
- try {
- File f = new File(uri);
- if (f.exists()) {
- return uri.toURL().openStream();
- }
- } catch (MalformedURLException e) {
- this.log.severe(e.getMessage());
- return null;
- } catch (IOException e) {
- this.log.severe(e.getMessage());
- return null;
- }
- }
- return null;
- }
-
- public RequestDispatcher getRequestDispatcher(String path) {
- URI uri = this.resolve(path);
- if (uri != null) {
- File f = new File(uri);
- if (f.exists()) {
- try {
- return new MockRequestDispatcher(uri.toURL());
- } catch (MalformedURLException e) {
- this.log.severe(e.getMessage());
- return null;
- }
- }
-
- }
- return null;
- }
-
- public RequestDispatcher getNamedDispatcher(String fileName) {
- throw new UnsupportedOperationException();
- }
-
- public Servlet getServlet(String name) throws ServletException {
- throw new UnsupportedOperationException();
- }
-
- public Enumeration getServlets() {
- throw new UnsupportedOperationException();
- }
-
- public Enumeration getServletNames() {
- throw new UnsupportedOperationException();
- }
-
- public void log(String message) {
- this.log.info(message);
- }
-
- public void log(Exception error, String message) {
- this.log.log(Level.INFO, message, error);
-
- }
-
- public void log(String message, Throwable error) {
- this.log.log(Level.INFO, message, error);
- }
-
- public String getRealPath(String path) {
- URI uri = this.resolve(path);
- if (uri != null) {
- File f = new File(uri);
- if (f.exists()) {
- return f.getAbsolutePath();
- }
- }
- return null;
- }
-
- /* (non-Javadoc)
- * @see javax.servlet.ServletContext#getContextPath()
- */
- public String getContextPath() {
- // TODO Auto-generated method stub
- return null;
- }
-
- private final URI resolve(String path) {
- if (path == null) {
- throw new NullPointerException("Path cannot be null");
- }
- if (path.charAt(0) == '/') {
- if (path.length() > 1) {
- return this.base.resolve(path.substring(1));
- }
- return this.base;
- }
- return null;
- }
-
- public String getServerInfo() {
- return this.getClass().getName();
- }
-
- public String getInitParameter(String name) {
- return this.initParams.getProperty(name);
- }
-
- public Enumeration getInitParameterNames() {
- return this.initParams.keys();
- }
-
- public void setInitParameter(String name, String value) {
- this.initParams.setProperty(name, value);
- }
-
- public Object getAttribute(String name) {
- return this.attributes.get(name);
- }
-
- public Enumeration getAttributeNames() {
- return this.attributes.keys();
- }
-
- public void setAttribute(String name, Object value) {
- this.attributes.put(name, value);
- }
-
- public void removeAttribute(String name) {
- this.attributes.remove(name);
- }
-
- public String getServletContextName() {
- return this.getClass().getName();
- }
-
-}
Deleted:
trunk/ui/columns/src/test/java/org/richfaces/facelet/mock/MockServletInputStream.java
===================================================================
---
trunk/ui/columns/src/test/java/org/richfaces/facelet/mock/MockServletInputStream.java 2007-12-21
16:35:25 UTC (rev 4955)
+++
trunk/ui/columns/src/test/java/org/richfaces/facelet/mock/MockServletInputStream.java 2007-12-21
16:55:49 UTC (rev 4956)
@@ -1,45 +0,0 @@
-/**
- * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
- * Licensed under the Common Development and Distribution License,
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *
http://www.sun.com/cddl/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
-package org.richfaces.facelet.mock;
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-
-import javax.servlet.ServletInputStream;
-
-/**
- *
- * @author Jacob Hookom
- * @version $Id: MockServletInputStream.java,v 1.1 2005/07/18 08:25:42 jhook Exp $
- */
-public class MockServletInputStream extends ServletInputStream {
-
- private final InputStream source;
-
- public MockServletInputStream() {
- this.source = new ByteArrayInputStream(new byte[0]);
- }
-
- public MockServletInputStream(InputStream source) {
- this.source = source;
- }
-
- public int read() throws IOException {
- return this.source.read();
- }
-
-}
Deleted:
trunk/ui/columns/src/test/java/org/richfaces/facelet/mock/MockServletOutputStream.java
===================================================================
---
trunk/ui/columns/src/test/java/org/richfaces/facelet/mock/MockServletOutputStream.java 2007-12-21
16:35:25 UTC (rev 4955)
+++
trunk/ui/columns/src/test/java/org/richfaces/facelet/mock/MockServletOutputStream.java 2007-12-21
16:55:49 UTC (rev 4956)
@@ -1,44 +0,0 @@
-/**
- * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
- * Licensed under the Common Development and Distribution License,
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *
http://www.sun.com/cddl/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
-package org.richfaces.facelet.mock;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-
-import javax.servlet.ServletOutputStream;
-
-/**
- *
- * @author Jacob Hookom
- * @version $Id: MockServletOutputStream.java,v 1.1 2005/07/18 08:25:43 jhook Exp $
- */
-public class MockServletOutputStream extends ServletOutputStream {
-
- private final OutputStream dest;
-
- public MockServletOutputStream() {
- this.dest = new ByteArrayOutputStream();
- }
-
- public MockServletOutputStream(OutputStream dest) {
- this.dest = dest;
- }
-
- public void write(int b) throws IOException {
- this.dest.write(b);
- }
-}
Modified:
trunk/ui/columns/src/test/java/org/richfaces/facelet/tag/ColumnsFaceletTagTest.java
===================================================================
---
trunk/ui/columns/src/test/java/org/richfaces/facelet/tag/ColumnsFaceletTagTest.java 2007-12-21
16:35:25 UTC (rev 4955)
+++
trunk/ui/columns/src/test/java/org/richfaces/facelet/tag/ColumnsFaceletTagTest.java 2007-12-21
16:55:49 UTC (rev 4956)
@@ -5,6 +5,7 @@
*/
package org.richfaces.facelet.tag;
+import java.net.URL;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Map;
@@ -12,7 +13,6 @@
import javax.faces.component.UIComponent;
import javax.faces.component.UIOutput;
import javax.faces.component.UIViewRoot;
-import javax.faces.context.FacesContext;
import org.richfaces.component.UIColumn;
import org.richfaces.component.html.HtmlColumn;
@@ -31,72 +31,61 @@
*/
public class ColumnsFaceletTagTest extends FaceletTagTestCase {
-
+ public ColumnsFaceletTagTest(String name) {
+ super(name);
+ }
- /* (non-Javadoc)
- * @see org.ajax4jsf.tests.AbstractAjax4JsfTestCase#setUp()
- */
- @Override
- public void setUp() throws Exception {
- // TODO Auto-generated method stub
- super.setUp();
- }
-
-
- public void testFacelet() throws Exception {
- FacesContext faces = FacesContext.getCurrentInstance();
- Map session = faces.getExternalContext().getSessionMap();
- Collection c = new ArrayList();
- for (int i = 0; i < 10; i++) {
- c.add(i);
- }
- session.put("list", c);
-
-
- FaceletFactory f = FaceletFactory.getInstance();
- Facelet at = f.getFacelet("columns.xml");
-
- UIViewRoot root = faces.getViewRoot();
- at.apply(faces, root);
-
- int count = root.getChildCount();
- assertTrue(count == 1);
-
- UIComponent dataTable = root.getChildren().get(0);
- assertNotNull(dataTable);
-
- count = dataTable.getChildCount();
- assertTrue(count == 5);
-
- UIComponent component = dataTable.getChildren().get(0);
- assertTrue(component instanceof UIColumn);
-
- HtmlColumn column = (HtmlColumn) component;
- assertTrue("color: Red;".equals(column.getStyle()));
- assertTrue("100px;".equals(column.getWidth()));
-
- column = (HtmlColumn)dataTable.getChildren().get(4);
- UIComponent facet = column.getFacet("header");
- assertNotNull(facet);
- assertTrue(facet instanceof UIOutput);
- UIOutput output = (UIOutput)facet;
- Integer val = (Integer) output.getValue();
- assertTrue(val.equals(4));
-
- assertTrue(component.getChildCount() == 1 );
-
- output = (UIOutput)component.getChildren().get(0);
- String value = (String) output.getValue();
- assertTrue("1".equals(value));
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.tests.AbstractAjax4JsfTestCase#tearDown()
- */
- @Override
- public void tearDown() throws Exception {
- // TODO Auto-generated method stub
- super.tearDown();
- }
-
+
+ public void testFacelet() throws Exception {
+ Map session = facesContext.getExternalContext().getSessionMap();
+ Collection c = new ArrayList();
+ for (int i = 0; i < 10; i++) {
+ c.add(i);
+ }
+ session.put("list", c);
+
+
+ FaceletFactory f = FaceletFactory.getInstance();
+ Facelet at = f.getFacelet("/");
+
+ UIViewRoot root = facesContext.getViewRoot();
+ at.apply(facesContext, root);
+
+ int count = root.getChildCount();
+ assertTrue(count == 1);
+
+ UIComponent dataTable = root.getChildren().get(0);
+ assertNotNull(dataTable);
+
+ count = dataTable.getChildCount();
+ assertTrue(count == 5);
+
+ UIComponent component = dataTable.getChildren().get(0);
+ assertTrue(component instanceof UIColumn);
+
+ HtmlColumn column = (HtmlColumn) component;
+ assertTrue("color: Red;".equals(column.getStyle()));
+ assertTrue("100px;".equals(column.getWidth()));
+
+ column = (HtmlColumn)dataTable.getChildren().get(4);
+ UIComponent facet = column.getFacet("header");
+ assertNotNull(facet);
+ assertTrue(facet instanceof UIOutput);
+ UIOutput output = (UIOutput)facet;
+ Integer val = (Integer) output.getValue();
+ assertTrue(val.equals(4));
+
+ assertTrue(component.getChildCount() == 1 );
+
+ output = (UIOutput)component.getChildren().get(0);
+ String value = (String) output.getValue();
+ assertTrue("1".equals(value));
+ }
+
+
+ public URL resolveUrl(String string) {
+ URL url = getClass().getResource("columns.xml");
+ return url;
+ }
+
}