hlship      2005/08/10 07:00:48

  Modified:    .        status.xml
               framework/src/java/org/apache/tapestry/test
                        ScriptStrings.properties ScriptMessages.java
  Added:       framework/src/test/org/apache/tapestry/test/mock
                        AttributeHolder.java InitParameterHolder.java
                        MockServletConfig.java MockResponse.java
                        MockSession.java MockRequestDispatcher.java
                        MockContext.java MockRequest.java
                        MockServletInputStream.java
  Removed:     framework/src/test/org/apache/tapestry/test
                        TestScriptParser.java TestRequestDescriptor.java
                        TestScriptDescriptor.java TestAssertOutput.java
                        TestAssertRegexp.java TestParameterList.java
               framework/src/java/org/apache/tapestry/test
                        ScriptDescriptor.java ParameterList.java
                        RequestDescriptor.java ServletDescriptor.java
                        ScriptRunner.java ScriptedTestSession.java
                        ResponseAssertion.java
                        IntegrationTestScriptParser.java
                        ScriptParser.properties
               framework/src/java/org/apache/tapestry/test/mock
                        InitParameterHolder.java MockRequest.java
                        AttributeHolder.java MockServletConfig.java
                        MockSession.java MockServletInputStream.java
                        MockResponse.java MockContext.java
                        MockRequestDispatcher.java
               framework/src/java/org/apache/tapestry/test/assertions
                        AssertOutput.java AssertRegexp.java
                        RegexpMatch.java
  Log:
  Remove incomplete and unused integration test code
  
  Revision  Changes    Path
  1.199     +1 -0      jakarta-tapestry/status.xml
  
  Index: status.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/status.xml,v
  retrieving revision 1.198
  retrieving revision 1.199
  diff -u -r1.198 -r1.199
  --- status.xml        10 Aug 2005 06:02:50 -0000      1.198
  +++ status.xml        10 Aug 2005 14:00:47 -0000      1.199
  @@ -83,6 +83,7 @@
         <action type="update" dev="PF">Checkbox component is now 
validatable.</action>
         <action type="update" dev="PF">Required validator additionally detects 
empty strings and empty collections.</action>
         <action type="fix" dev="PF" 
fixes-bug="TAPESTRY-531">contrib:MultiplePropertySelection isn't setting it's 
own name before rendering</action>
  +      <action type="update" dev="HLS">Remove incomplete and unused 
integration test code</action>
       </release>
       <release version="4.0-beta-3" date="Jul 22 2005">
         <action type="fix" dev="HLS" fixes-bug="TAPESTRY-398" due-to="Jonas 
Maurus">HiveMind configuration error breaks the useage of the state: binding 
prefix</action>
  
  
  
  1.1                  
jakarta-tapestry/framework/src/test/org/apache/tapestry/test/mock/AttributeHolder.java
  
  Index: AttributeHolder.java
  ===================================================================
  // Copyright 2004, 2005 The Apache Software Foundation
  //
  // Licensed under the Apache License, Version 2.0 (the "License");
  // you may not use this file except in compliance with the License.
  // You may obtain a copy of the License at
  //
  //     http://www.apache.org/licenses/LICENSE-2.0
  //
  // 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.apache.tapestry.test.mock;
  
  import java.io.ByteArrayInputStream;
  import java.io.ByteArrayOutputStream;
  import java.io.IOException;
  import java.io.ObjectInputStream;
  import java.io.ObjectOutputStream;
  import java.util.Collections;
  import java.util.Enumeration;
  import java.util.HashMap;
  import java.util.Map;
  import java.util.Set;
  
  import org.apache.hivemind.ApplicationRuntimeException;
  
  /**
   *  
   * Base class for holders of named attributes such as
   * [EMAIL PROTECTED] javax.servlet.http.HttpSession}, 
   * [EMAIL PROTECTED] javax.servlet.http.HttpServletRequest}
   * and [EMAIL PROTECTED] javax.servlet.ServletContext}.
   *
   *
   * @author Howard Lewis Ship
   * @since 4.0
   */
  
  public class AttributeHolder
  {
      private Map _attributes = new HashMap();
  
      public Object getAttribute(String name)
      {
          return _attributes.get(name);
      }
  
      public Enumeration getAttributeNames()
      {
          return getEnumeration(_attributes);
      }
  
      protected Enumeration getEnumeration(Map map)
      {
          return Collections.enumeration(map.keySet());
      }
  
      public String[] getAttributeNamesArray()
      {
          Set keys = _attributes.keySet();
          int count = keys.size();
  
          String[] array = new String[count];
  
          return (String[]) keys.toArray(array);
      }
  
      public void setAttribute(String name, Object value)
      {
          _attributes.put(name, value);
      }
  
      public void removeAttribute(String name)
      {
          _attributes.remove(name);
      }
  
      /**
       *  Serializes and then deserializes the [EMAIL PROTECTED] Map}
       *  containing all attributes.
       * 
       **/
  
      public void simulateFailover()
      {
          byte[] serialized = serializeAttributes();
  
          _attributes = null;
  
          Map restoredAttributes = deserializeAttributes(serialized);
  
          _attributes = restoredAttributes;
      }
  
      private byte[] serializeAttributes()
      {
          try
          {
              ByteArrayOutputStream bos = new ByteArrayOutputStream();
              ObjectOutputStream oos = new ObjectOutputStream(bos);
  
              oos.writeObject(_attributes);
  
              oos.close();
  
              return bos.toByteArray();
          }
          catch (IOException ex)
          {
              throw new ApplicationRuntimeException("Unable to serialize 
attributes.", ex);
          }
      }
  
      private Map deserializeAttributes(byte[] serialized)
      {
          try
          {
              ByteArrayInputStream bis = new ByteArrayInputStream(serialized);
              ObjectInputStream ois = new ObjectInputStream(bis);
  
              Map result = (Map) ois.readObject();
  
              return result;
          }
          catch (Exception ex)
          {
              throw new ApplicationRuntimeException("Unable to deserialize 
attributes.", ex);
          }
      }
  }
  
  
  
  1.1                  
jakarta-tapestry/framework/src/test/org/apache/tapestry/test/mock/InitParameterHolder.java
  
  Index: InitParameterHolder.java
  ===================================================================
  // Copyright 2004, 2005 The Apache Software Foundation
  //
  // Licensed under the Apache License, Version 2.0 (the "License");
  // you may not use this file except in compliance with the License.
  // You may obtain a copy of the License at
  //
  //     http://www.apache.org/licenses/LICENSE-2.0
  //
  // 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.apache.tapestry.test.mock;
  
  import java.util.Enumeration;
  
  /**
   *  Common interface for several mock objects that can contain
   *  initial parameters.
   *
   *
   *  @author Howard Lewis Ship
   *  @since 4.0
   * 
   */
  
  public interface InitParameterHolder
  {
      public String getInitParameter(String name);
  
      public Enumeration getInitParameterNames();
      
      /**
       *  Allows Mock objects to have initial parameters set.
       * 
       **/
      
      public void setInitParameter(String name, String value);
  }
  
  
  
  1.1                  
jakarta-tapestry/framework/src/test/org/apache/tapestry/test/mock/MockServletConfig.java
  
  Index: MockServletConfig.java
  ===================================================================
  // Copyright 2004, 2005 The Apache Software Foundation
  //
  // Licensed under the Apache License, Version 2.0 (the "License");
  // you may not use this file except in compliance with the License.
  // You may obtain a copy of the License at
  //
  //     http://www.apache.org/licenses/LICENSE-2.0
  //
  // 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.apache.tapestry.test.mock;
  
  import java.util.Collections;
  import java.util.Enumeration;
  import java.util.HashMap;
  import java.util.Map;
  
  import javax.servlet.ServletConfig;
  import javax.servlet.ServletContext;
  
  /**
   * An implementation of [EMAIL PROTECTED] javax.servlet.ServletConfig} used
   * for Mock testing. 
   *
   * @author Howard Lewis Ship
   * @since 4.0
   */
  
  public class MockServletConfig implements ServletConfig, InitParameterHolder
  {
      private String _name;
      private ServletContext _context;
      private Map _initParameters = new HashMap();
  
      public MockServletConfig(String name, ServletContext context)
      {
          _name = name;
          _context = context;
      }
  
      public String getInitParameter(String name)
      {
          return (String) _initParameters.get(name);
      }
  
      public Enumeration getInitParameterNames()
      {
          return Collections.enumeration(_initParameters.keySet());
      }
  
      public ServletContext getServletContext()
      {
          return _context;
      }
  
      public String getServletName()
      {
          return _name;
      }
  
      public void setInitParameter(String name, String value)
      {
          _initParameters.put(name, value);
      }
  
  }
  
  
  
  1.1                  
jakarta-tapestry/framework/src/test/org/apache/tapestry/test/mock/MockResponse.java
  
  Index: MockResponse.java
  ===================================================================
  // Copyright 2004, 2005 The Apache Software Foundation
  //
  // Licensed under the Apache License, Version 2.0 (the "License");
  // you may not use this file except in compliance with the License.
  // You may obtain a copy of the License at
  //
  //     http://www.apache.org/licenses/LICENSE-2.0
  //
  // 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.apache.tapestry.test.mock;
  
  import java.io.BufferedWriter;
  import java.io.ByteArrayOutputStream;
  import java.io.IOException;
  import java.io.OutputStreamWriter;
  import java.io.PrintWriter;
  import java.io.UnsupportedEncodingException;
  import java.util.*;
  
  import javax.servlet.ServletOutputStream;
  import javax.servlet.http.Cookie;
  import javax.servlet.http.HttpServletResponse;
  
  import org.apache.tapestry.util.ContentType;
  
  /**
   * Mock implementation of [EMAIL PROTECTED] 
javax.servlet.http.HttpServletResponse}.
   * 
   * @author Howard Lewis Ship
   * @since 4.0
   */
  
  public class MockResponse implements HttpServletResponse
  {
      private MockRequest _request;
  
      private boolean _commited = false;
  
      private ByteArrayOutputStream _outputByteStream;
  
      private ServletOutputStream _outputStream;
  
      private String _outputString;
  
      private List _cookies = new ArrayList();
  
      private String _redirectLocation;
  
      private String _contentType = "text/html;charset=utf-8";
  
      private class ServletOutputStreamImpl extends ServletOutputStream
      {
          private ServletOutputStreamImpl()
          {
          }
  
          public void close() throws IOException
          {
              super.close();
  
              if (_outputByteStream != null)
                  _outputByteStream.close();
          }
  
          public void write(byte[] b, int off, int len) throws IOException
          {
              commit();
  
              _outputByteStream.write(b, off, len);
          }
  
          public void write(byte[] b) throws IOException
          {
              commit();
  
              _outputByteStream.write(b);
          }
  
          public void write(int b) throws IOException
          {
              commit();
  
              _outputByteStream.write(b);
          }
  
          private void commit()
          {
              if (!_commited)
              {
                  _commited = true;
                  _outputByteStream = new ByteArrayOutputStream();
              }
          }
      }
  
      public MockResponse(MockRequest request)
      {
          _request = request;
      }
  
      public void addCookie(Cookie cookie)
      {
          _cookies.add(cookie);
      }
  
      public boolean containsHeader(String arg0)
      {
          return false;
      }
  
      public String encodeURL(String path)
      {
          return path;
      }
  
      public String encodeRedirectURL(String path)
      {
          return path;
      }
  
      public String encodeUrl(String path)
      {
          return encodeURL(path);
      }
  
      public String encodeRedirectUrl(String path)
      {
          return encodeRedirectURL(path);
      }
  
      public void sendError(int code, String message) throws IOException
      {
          if (_commited)
              throw new IllegalStateException("sendError() when committed.");
      }
  
      public void sendError(int code) throws IOException
      {
          sendError(code, null);
      }
  
      public void sendRedirect(String location) throws IOException
      {
          if (_commited)
              throw new IllegalStateException("sendRedirect() when committed.");
  
          if (location.endsWith("/FAIL_IO"))
              throw new IOException("Forced IOException in 
MockResponse.sendRedirect().");
  
          _redirectLocation = location;
  
          _commited = true;
  
      }
  
      public String getRedirectLocation()
      {
          return _redirectLocation;
      }
  
      public void setDateHeader(String name, long value)
      {
      }
  
      public void addDateHeader(String name, long value)
      {
      }
  
      public void setHeader(String name, String value)
      {
      }
  
      public void addHeader(String name, String value)
      {
      }
  
      public void setIntHeader(String name, int value)
      {
      }
  
      public void addIntHeader(String name, int value)
      {
      }
  
      public void setStatus(int name)
      {
      }
  
      public void setStatus(int name, String arg1)
      {
      }
  
      public String getCharacterEncoding()
      {
          return null;
      }
  
      public ServletOutputStream getOutputStream() throws IOException
      {
          if (_outputStream != null)
              throw new IllegalStateException("getOutputStream() invoked more 
than once.");
  
          _outputStream = new ServletOutputStreamImpl();
  
          return _outputStream;
      }
  
      public PrintWriter getWriter() throws IOException
      {
          ContentType ct = new ContentType(_contentType);
  
          String encoding = ct.getParameter("charset");
  
          return new PrintWriter(new BufferedWriter(new 
OutputStreamWriter(getOutputStream(),
                  encoding)));
      }
  
      public void setContentLength(int arg0)
      {
      }
  
      public void setContentType(String contentType)
      {
          _contentType = contentType;
      }
  
      public void setBufferSize(int arg0)
      {
      }
  
      public int getBufferSize()
      {
          return 0;
      }
  
      public void flushBuffer() throws IOException
      {
      }
  
      public void resetBuffer()
      {
      }
  
      public boolean isCommitted()
      {
          return _commited;
      }
  
      public void reset()
      {
          _outputStream = null;
      }
  
      public void setLocale(Locale arg0)
      {
      }
  
      public Locale getLocale()
      {
          return null;
      }
  
      /**
       * Invoked by [EMAIL PROTECTED] 
org.apache.tapestry.junit.mock.MockTester}after the test is complete, to
       * close and otherwise finish up.
       */
  
      public void end() throws IOException
      {
          // For redirects, we may never open an output stream.
  
          if (_outputStream != null)
              _outputStream.close();
      }
  
      /**
       * Converts the binary output stream back into a String.
       */
  
      public String getOutputString()
      {
          if (_outputString != null)
              return _outputString;
  
          if (_outputByteStream == null)
              return null;
  
          try
          {
              String encoding = _request.getCharacterEncoding();
  
              if (encoding != null)
                  _outputString = new String(_outputByteStream.toByteArray(), 
encoding);
          }
          catch (UnsupportedEncodingException e)
          {
          }
  
          if (_outputString == null)
              _outputString = _outputByteStream.toString();
  
          return _outputString;
      }
  
      public byte[] getResponseBytes()
      {
          return _outputByteStream.toByteArray();
      }
  
      public Cookie[] getCookies()
      {
          return (Cookie[]) _cookies.toArray(new Cookie[_cookies.size()]);
      }
  
      public String getContentType()
      {
          return _contentType;
      }
  
      public void setCharacterEncoding(String enc)
      {
      }
  
  }
  
  
  1.1                  
jakarta-tapestry/framework/src/test/org/apache/tapestry/test/mock/MockSession.java
  
  Index: MockSession.java
  ===================================================================
  // Copyright 2004, 2005 The Apache Software Foundation
  //
  // Licensed under the Apache License, Version 2.0 (the "License");
  // you may not use this file except in compliance with the License.
  // You may obtain a copy of the License at
  //
  //     http://www.apache.org/licenses/LICENSE-2.0
  //
  // 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.apache.tapestry.test.mock;
  
  import javax.servlet.ServletContext;
  import javax.servlet.http.HttpSession;
  import javax.servlet.http.HttpSessionBindingEvent;
  import javax.servlet.http.HttpSessionBindingListener;
  import javax.servlet.http.HttpSessionContext;
  
  /**
   *  Mock implementation of [EMAIL PROTECTED] javax.servlet.http.HttpSession}.
   *
   *
   *  @author Howard Lewis Ship
   *  @since 4.0
   */
  
  public class MockSession extends AttributeHolder implements HttpSession
  {
      private MockContext _context;
      private String _id;
  
      public MockSession(MockContext context, String id)
      {
          _context = context;
          _id = id;
      }
  
      public long getCreationTime()
      {
          return 0;
      }
  
      public String getId()
      {
          return _id;
      }
  
      public long getLastAccessedTime()
      {
          return 0;
      }
  
      public ServletContext getServletContext()
      {
          return _context;
      }
  
      public void setMaxInactiveInterval(int arg0)
      {
      }
  
      public int getMaxInactiveInterval()
      {
          return 0;
      }
  
      public HttpSessionContext getSessionContext()
      {
          return null;
      }
  
      public Object getValue(String name)
      {
          return getAttribute(name);
      }
  
      public String[] getValueNames()
      {
          return getAttributeNamesArray();
      }
  
      public void putValue(String name, Object value)
      {
          setAttribute(name, value);
      }
  
      public void removeValue(String name)
      {
          removeAttribute(name);
      }
  
      public void invalidate()
      {
      }
  
      public boolean isNew()
      {
          return false;
      }
  
      public void setAttribute(String name, Object value)
      {
          super.setAttribute(name, value);
  
          if (value instanceof HttpSessionBindingListener)
          {
              HttpSessionBindingListener listener = 
(HttpSessionBindingListener) value;
              HttpSessionBindingEvent event = new HttpSessionBindingEvent(this, 
name);
  
              listener.valueBound(event);
          }
      }
  
  }
  
  
  
  1.1                  
jakarta-tapestry/framework/src/test/org/apache/tapestry/test/mock/MockRequestDispatcher.java
  
  Index: MockRequestDispatcher.java
  ===================================================================
  // Copyright 2004, 2005 The Apache Software Foundation
  //
  // Licensed under the Apache License, Version 2.0 (the "License");
  // you may not use this file except in compliance with the License.
  // You may obtain a copy of the License at
  //
  //     http://www.apache.org/licenses/LICENSE-2.0
  //
  // 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.apache.tapestry.test.mock;
  
  import java.io.FileInputStream;
  import java.io.IOException;
  import java.io.InputStream;
  import java.io.OutputStream;
  
  import javax.servlet.RequestDispatcher;
  import javax.servlet.ServletException;
  import javax.servlet.ServletRequest;
  import javax.servlet.ServletResponse;
  
  /**
   * Used to enable mock testing of internal request forwarding.
   *
   * @author Howard Lewis Ship
   * @since 4.0
   */
  public class MockRequestDispatcher implements RequestDispatcher
  {     
        private String _resourcePath;
        
      public MockRequestDispatcher(String resourcePath)
      {
        _resourcePath = resourcePath;
      }
  
      public void forward(ServletRequest request, ServletResponse response)
          throws ServletException, IOException
      {
        if (_resourcePath.endsWith("/FAIL_SERVLET"))
                throw new ServletException("Test-directed ServletException from 
RequestDispatcher forward().");
        
        // For testing purposes, assume we only forward to static HTML files.
        
        
        InputStream in = new FileInputStream(_resourcePath);
  
                response.setContentType("test/html");
        
        OutputStream out =      response.getOutputStream();
  
        
        byte[] buffer = new byte[1000];
        
        while (true)
        {
                int length = in.read(buffer);
                
                if (length < 0)
                        break;
                        
                out.write(buffer, 0, length);
        }
        
        in.close();
        out.close();
      }
  
      public void include(ServletRequest request, ServletResponse response)
          throws ServletException, IOException
      {
        throw new ServletException("MockRequestDispatcher.include() not 
supported.");
      }
  
  }
  
  
  
  1.1                  
jakarta-tapestry/framework/src/test/org/apache/tapestry/test/mock/MockContext.java
  
  Index: MockContext.java
  ===================================================================
  // Copyright 2004, 2005 The Apache Software Foundation
  //
  // Licensed under the Apache License, Version 2.0 (the "License");
  // you may not use this file except in compliance with the License.
  // You may obtain a copy of the License at
  //
  //     http://www.apache.org/licenses/LICENSE-2.0
  //
  // 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.apache.tapestry.test.mock;
  
  import java.io.File;
  import java.io.IOException;
  import java.io.InputStream;
  import java.net.MalformedURLException;
  import java.net.URL;
  import java.util.Collections;
  import java.util.Enumeration;
  import java.util.HashMap;
  import java.util.Map;
  import java.util.Set;
  
  import javax.servlet.RequestDispatcher;
  import javax.servlet.Servlet;
  import javax.servlet.ServletContext;
  import javax.servlet.ServletException;
  
  /**
   * Mock implementation of [EMAIL PROTECTED] javax.servlet.ServletContext}.
   *
   * @author Howard Lewis Ship
   * @since 4.0
   */
  
  public class MockContext extends AttributeHolder implements ServletContext, 
InitParameterHolder
  {
      private MockSession _session;
  
      private static final Map _suffixToContentType = new HashMap();
  
      static {
          _suffixToContentType.put("html", "text/html");
          _suffixToContentType.put("gif", "image/gif");
          _suffixToContentType.put("png", "image/png");
      }
  
      private String _rootDirectory;
      private String _servletContextName = "test";
      private Map _initParameters = new HashMap();
  
      public MockContext()
      {
      }
  
      public MockContext(String testDirectory)
      {
          _rootDirectory = testDirectory + "/context";
      }
  
      public ServletContext getContext(String name)
      {
          return null;
      }
  
      public int getMajorVersion()
      {
          return 2;
      }
  
      public int getMinorVersion()
      {
          return 1;
      }
  
      public String getMimeType(String path)
      {
          int lastx = path.lastIndexOf('.');
          String suffix = path.substring(lastx + 1);
  
          return (String) _suffixToContentType.get(suffix);
      }
  
      public Set getResourcePaths(String arg0)
      {
          return null;
      }
  
      public URL getResource(String path) throws MalformedURLException
      {
          if (path == null || !path.startsWith("/"))
              throw new MalformedURLException("Not a valid context path.");
  
          String fullPath = _rootDirectory + path;
  
          File file = new File(fullPath);
  
          if (file.exists())
              return file.toURL();
  
          return null;
      }
  
      public InputStream getResourceAsStream(String path)
      {
          try
          {
              URL url = getResource(path);
  
              if (url == null)
                  return null;
  
              return url.openStream();
          }
          catch (MalformedURLException ex)
          {
              return null;
          }
          catch (IOException ex)
          {
              return null;
          }
      }
  
      /**
       *  Gets a dispatcher for the given path.  Path should be a relative path 
(relative
       *  to the context).  A special case:  "NULL" returns null (i.e., when a 
       *  dispatcher can't be found).
       * 
       **/
  
      public RequestDispatcher getRequestDispatcher(String path)
      {
          if (path.endsWith("/NULL"))
              return null;
  
          StringBuffer buffer = new StringBuffer(_rootDirectory);
          buffer.append(path);
  
          // Simulate the handling of directories by serving the index.html
          // in the directory.
  
          if (path.endsWith("/"))
              buffer.append("index.html");
  
          return new MockRequestDispatcher(buffer.toString());
      }
  
      public RequestDispatcher getNamedDispatcher(String name)
      {
          return null;
      }
  
      public Servlet getServlet(String name) throws ServletException
      {
          return null;
      }
  
      public Enumeration getServlets()
      {
          return null;
      }
  
      public Enumeration getServletNames()
      {
          return null;
      }
  
      public void log(String message)
      {
          log(message, null);
      }
  
      public void log(Exception exception, String message)
      {
          log(message, exception);
      }
  
      public void log(String message, Throwable exception)
      {
      }
  
      public String getRealPath(String arg0)
      {
          return null;
      }
  
      public String getServerInfo()
      {
          return "Tapestry Mock Objects";
      }
  
      public String getInitParameter(String name)
      {
          return (String) _initParameters.get(name);
      }
  
      public Enumeration getInitParameterNames()
      {
          return Collections.enumeration(_initParameters.keySet());
      }
  
      public void setInitParameter(String name, String value)
      {
          _initParameters.put(name, value);
      }
  
      public String getServletContextName()
      {
          return _servletContextName;
      }
  
      public MockSession createSession()
      {
          if (_session == null)
          {
              String id = Long.toHexString(System.currentTimeMillis());
  
              _session = new MockSession(this, id);
          }
  
          return _session;
      }
  
      public MockSession getSession()
      {
          return _session;
      }
  
      public void setServletContextName(String servletContextName)
      {
          _servletContextName = servletContextName;
      }
  
      public String getRootDirectory()
      {
          return _rootDirectory;
      }
  
      public void setRootDirectory(String rootDirectory)
      {
          _rootDirectory = rootDirectory;
      }
  
  }
  
  
  
  1.1                  
jakarta-tapestry/framework/src/test/org/apache/tapestry/test/mock/MockRequest.java
  
  Index: MockRequest.java
  ===================================================================
  // Copyright 2004, 2005 The Apache Software Foundation
  //
  // Licensed under the Apache License, Version 2.0 (the "License");
  // you may not use this file except in compliance with the License.
  // You may obtain a copy of the License at
  //
  //     http://www.apache.org/licenses/LICENSE-2.0
  //
  // 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.apache.tapestry.test.mock;
  
  import java.io.BufferedReader;
  import java.io.IOException;
  import java.io.UnsupportedEncodingException;
  import java.security.Principal;
  import java.util.ArrayList;
  import java.util.Arrays;
  import java.util.Collections;
  import java.util.Enumeration;
  import java.util.HashMap;
  import java.util.List;
  import java.util.Locale;
  import java.util.Map;
  
  import javax.servlet.RequestDispatcher;
  import javax.servlet.ServletInputStream;
  import javax.servlet.http.Cookie;
  import javax.servlet.http.HttpServletRequest;
  import javax.servlet.http.HttpSession;
  
  /**
   * Mock implementation of [EMAIL PROTECTED] 
javax.servlet.http.HttpServletRequest}.
   *
   *
   * @author Howard Lewis Ship
   * @since 4.0
   */
  
  public class MockRequest extends AttributeHolder implements HttpServletRequest
  {
      /**
       * HTTP content type header name.
       */
      private static final String CONTENT_TYPE_HEADER_KEY = "Content-type";
      /**
       *  Map of String[].
       * 
       */
  
      private Map _parameters = new HashMap();
  
      /**
       *  Map of String[]
       * 
       */
  
      private Map _headers = new HashMap();
  
      private String _method = "GET";
  
      private String _contextPath;
  
      private MockContext _servletContext;
      private MockSession _session;
      private String _servletPath;
      private List _cookies = new ArrayList();
      private String _contentPath;
  
      /**
       *  This can be stored within the header, but doing it this way emulates 
a browser that 
       *  does not put the encoding in the request, which appears to be the 
general case. 
       */
      private String _encoding = null;
  
      public MockRequest(MockContext servletContext, String servletPath)
      {
          _servletContext = servletContext;
  
          _contextPath = "/" + servletContext.getServletContextName();
          _servletPath = servletPath;
  
          _session = _servletContext.getSession();
      }
  
      public String getAuthType()
      {
          return null;
      }
  
      public Cookie[] getCookies()
      {
          return (Cookie[]) _cookies.toArray(new Cookie[_cookies.size()]);
      }
  
      public long getDateHeader(String arg0)
      {
          return 0;
      }
  
      public String getHeader(String key)
      {
          String getHeader = null;
  
          if (key != null)
          {
              getHeader = (String) _headers.get(key.toLowerCase());
          }
          return getHeader;
      }
  
      public Enumeration getHeaders(String name)
      {
          String[] headers = (String[]) _headers.get(name);
  
          if (headers == null)
              return Collections.enumeration(Collections.EMPTY_LIST);
  
          return Collections.enumeration(Arrays.asList(headers));
      }
  
      public Enumeration getHeaderNames()
      {
          return getEnumeration(_headers);
      }
  
      public int getIntHeader(String arg0)
      {
          return 0;
      }
  
      public String getMethod()
      {
          return _method;
      }
  
      public String getPathInfo()
      {
          return null;
      }
  
      public String getPathTranslated()
      {
          return null;
      }
  
      public String getContextPath()
      {
          return _contextPath;
      }
  
      public String getQueryString()
      {
          return null;
      }
  
      public String getRemoteUser()
      {
          return null;
      }
  
      public boolean isUserInRole(String arg0)
      {
          return false;
      }
  
      public Principal getUserPrincipal()
      {
          return null;
      }
  
      public String getRequestedSessionId()
      {
          return null;
      }
  
      public String getRequestURI()
      {
          return null;
      }
  
      public StringBuffer getRequestURL()
      {
          return null;
      }
  
      public String getServletPath()
      {
          return _servletPath;
      }
  
      public HttpSession getSession(boolean create)
      {
          if (create && _session == null)
              _session = _servletContext.createSession();
  
          return _session;
      }
  
      public HttpSession getSession()
      {
          return _session;
      }
  
      public boolean isRequestedSessionIdValid()
      {
          return false;
      }
  
      public boolean isRequestedSessionIdFromCookie()
      {
          return false;
      }
  
      public boolean isRequestedSessionIdFromURL()
      {
          return false;
      }
  
      public boolean isRequestedSessionIdFromUrl()
      {
          return false;
      }
  
      public String getCharacterEncoding()
      {
          return _encoding;
      }
  
      public void setCharacterEncoding(String arg0) throws 
UnsupportedEncodingException
      {
          _encoding = arg0;
      }
  
      public int getContentLength()
      {
          return 0;
      }
  
      public String getContentType()
      {
          return getHeader(CONTENT_TYPE_HEADER_KEY);
      }
  
      public void setContentType(String contentType)
      {
          setHeader(CONTENT_TYPE_HEADER_KEY, contentType);
      }
  
      public ServletInputStream getInputStream() throws IOException
      {
          if (_contentPath == null)
              return null;
  
          return new MockServletInputStream(_contentPath);
      }
  
      public String getParameter(String name)
      {
          String[] values = getParameterValues(name);
  
          if (values == null || values.length == 0)
              return null;
  
          return values[0];
      }
  
      public Enumeration getParameterNames()
      {
          return Collections.enumeration(_parameters.keySet());
      }
  
      public String[] getParameterValues(String name)
      {
          return (String[]) _parameters.get(name);
      }
  
      /** 
       *  Not part of 2.1 API, not used by Tapestry.
       * 
       */
  
      public Map getParameterMap()
      {
          return null;
      }
  
      public String getProtocol()
      {
          return null;
      }
  
      public String getScheme()
      {
          return "http";
      }
  
      public String getServerName()
      {
          return "junit-test";
      }
  
      public int getServerPort()
      {
          return 80;
      }
  
      public BufferedReader getReader() throws IOException
      {
          return null;
      }
  
      public String getRemoteAddr()
      {
          return null;
      }
  
      public String getRemoteHost()
      {
          return null;
      }
  
      private Locale _locale = Locale.ENGLISH;
  
      public Locale getLocale()
      {
          return _locale;
      }
  
      public void setLocale(Locale locale)
      {
          _locale = locale;
      }
  
      public Enumeration getLocales()
      {
          return Collections.enumeration(Collections.singleton(_locale));
      }
  
      public boolean isSecure()
      {
          return false;
      }
  
      public RequestDispatcher getRequestDispatcher(String path)
      {
          return _servletContext.getRequestDispatcher(path);
      }
  
      public String getRealPath(String arg0)
      {
          return null;
      }
  
      public void setContextPath(String contextPath)
      {
          _contextPath = contextPath;
      }
  
      public void setMethod(String method)
      {
          _method = method;
      }
  
      public void setParameter(String name, String[] values)
      {
          _parameters.put(name, values);
      }
  
      public void setParameter(String name, String value)
      {
          setParameter(name, new String[] { value });
      }
  
      public void addCookie(Cookie cookie)
      {
          _cookies.add(cookie);
      }
  
      public void addCookies(Cookie[] cookies)
      {
          if (cookies == null)
              return;
  
          for (int i = 0; i < cookies.length; i++)
              addCookie(cookies[i]);
      }
  
      private void setHeader(String key, String value)
      {
          if (key != null)
          {
              _headers.put(key.toLowerCase(), value);
          }
      }
  
      /**
       *  Delegates this to the [EMAIL PROTECTED] 
org.apache.tapestry.junit.mock.MockSession}, if
       *  it exists.
       * 
       */
  
      public void simulateFailover()
      {
          if (_session != null)
              _session.simulateFailover();
      }
  
      public String getContentPath()
      {
          return _contentPath;
      }
  
      public void setContentPath(String contentPath)
      {
          _contentPath = contentPath;
      }
  
      public int getRemotePort()
      {
          return 0;
      }
  
      public String getLocalName()
      {
          return null;
      }
  
      public String getLocalAddr()
      {
          return null;
      }
  
      public int getLocalPort()
      {
          return 0;
      }
  
  }
  
  
  
  1.1                  
jakarta-tapestry/framework/src/test/org/apache/tapestry/test/mock/MockServletInputStream.java
  
  Index: MockServletInputStream.java
  ===================================================================
  // Copyright 2004, 2005 The Apache Software Foundation
  //
  // Licensed under the Apache License, Version 2.0 (the "License");
  // you may not use this file except in compliance with the License.
  // You may obtain a copy of the License at
  //
  //     http://www.apache.org/licenses/LICENSE-2.0
  //
  // 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.apache.tapestry.test.mock;
  
  import java.io.FileInputStream;
  import java.io.IOException;
  import java.io.InputStream;
  
  import javax.servlet.ServletInputStream;
  
  /**
   * Implementation of [EMAIL PROTECTED] ServletInputStream} used in mock 
object testing.
   * The data in the stream is provided by a binary file.  The implemenation
   * wraps around a [EMAIL PROTECTED] java.io.FileInputStream} redirecting all 
method
   * invocations to the inner stream.
   *
   * @author Howard Lewis Ship
   * @since 4.0
   */
  
  public class MockServletInputStream extends ServletInputStream
  {
      private InputStream _inner;
  
      public MockServletInputStream(String path) throws IOException
      {
          _inner = new FileInputStream(path);
      }
  
      public int read() throws IOException
      {
          return _inner.read();
      }
  
      public int available() throws IOException
      {
          return _inner.available();
      }
  
      public void close() throws IOException
      {
          _inner.close();
      }
  
      public synchronized void mark(int readlimit)
      {
          _inner.mark(readlimit);
      }
  
      public boolean markSupported()
      {
          return _inner.markSupported();
      }
  
      public int read(byte[] b, int off, int len) throws IOException
      {
          return _inner.read(b, off, len);
      }
  
      public int read(byte[] b) throws IOException
      {
          return _inner.read(b);
      }
  
      public synchronized void reset() throws IOException
      {
          _inner.reset();
      }
  
      public long skip(long n) throws IOException
      {
          return _inner.skip(n);
      }
  
  }
  
  
  
  1.4       +0 -10     
jakarta-tapestry/framework/src/java/org/apache/tapestry/test/ScriptStrings.properties
  
  Index: ScriptStrings.properties
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tapestry/framework/src/java/org/apache/tapestry/test/ScriptStrings.properties,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ScriptStrings.properties  6 Jan 2005 02:17:24 -0000       1.3
  +++ ScriptStrings.properties  10 Aug 2005 14:00:48 -0000      1.4
  @@ -12,15 +12,5 @@
   # See the License for the specific language governing permissions and
   # limitations under the License.
   
  -expected-substring-missing=Expected text ("{0}", at {1}) was not found in 
the response.
  -
  -expected-regexp-missing=Expected regular expression ("{0}", at {1}) was not 
found in the response.
  -incorrect-regexp-match=Expected match was ''{0}'' (at {1}), but actual value 
matched was ''{2}''.
  -incorrect-regexp-match-count=Regular expression ''{0}'' (at {1}) should have 
generated {2,number,integer} matches, but generated {3,number,integer} instead.
  -
  -unexpected-attribute-in-element=Unexpected attribute ''{0}'' (in element 
{1}).
  -missing-required-attribute=Required attribute ''{0}'' is not supplied for 
element {1}.
  -invalid-int-attribute=Attribute ''{0}'' (of element {1}, at {2}) is ''{3}'', 
which is not an integer value.
  -
   wrong-type-for-enhancement=Can not create instance of {0}. Interfaces, 
arrays and primitive types may not be enhanced.
   unable-to-instantiate=Unable to instantiate enhanced subclass of {0}: {2}
  \ No newline at end of file
  
  
  
  1.7       +0 -41     
jakarta-tapestry/framework/src/java/org/apache/tapestry/test/ScriptMessages.java
  
  Index: ScriptMessages.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tapestry/framework/src/java/org/apache/tapestry/test/ScriptMessages.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- ScriptMessages.java       13 May 2005 13:21:06 -0000      1.6
  +++ ScriptMessages.java       10 Aug 2005 14:00:48 -0000      1.7
  @@ -14,7 +14,6 @@
   
   package org.apache.tapestry.test;
   
  -import org.apache.hivemind.Location;
   import org.apache.hivemind.impl.MessageFormatter;
   import org.apache.hivemind.service.ClassFabUtils;
   
  @@ -36,46 +35,6 @@
       protected static MessageFormatter _formatter = new 
MessageFormatter(ScriptMessages.class,
               "ScriptStrings");
   
  -    public static String expectedSubstringMissing(String substring, Location 
location)
  -    {
  -        return _formatter.format("expected-substring-missing", substring, 
location);
  -    }
  -
  -    public static String expectedRegexpMissing(String regexp, Location 
location)
  -    {
  -        return _formatter.format("expected-regexp-missing", regexp, 
location);
  -    }
  -
  -    static String unexpectedAttributeInElement(String attributeName, String 
elementName)
  -    {
  -        return _formatter.format("unexpected-attribute-in-element", 
attributeName, elementName);
  -    }
  -
  -    static String missingRequiredAttribute(String attributeName, String 
elementName)
  -    {
  -        return _formatter.format("missing-required-attribute", 
attributeName, elementName);
  -    }
  -
  -    static String invalidIntAttribute(String attributeName, String 
elementName,
  -            Location location, String attributeValue)
  -    {
  -        return _formatter.format("invalid-int-attribute", new Object[]
  -        { attributeName, elementName, location, attributeValue });
  -    }
  -
  -    public static String incorrectRegexpMatch(String expectedMatch, Location 
location,
  -            String actualMatch)
  -    {
  -        return _formatter.format("incorrect-regexp-match", expectedMatch, 
location, actualMatch);
  -    }
  -
  -    public static String incorrectRegexpMatchCount(String pattern, Location 
location,
  -            int expectedCount, int actualCount)
  -    {
  -        return _formatter.format("incorrect-regexp-match-count", new Object[]
  -        { pattern, location, new Integer(expectedCount), new 
Integer(actualCount) });
  -    }
  -
       static String wrongTypeForEnhancement(Class type)
       {
           return _formatter
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to