Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
   // Copyright 2006, 2007, 2008, 2009, 2010 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.tapestry5.test;
  
  import static org.apache.tapestry5.ioc.internal.util.CollectionFactory.newList;
  
  import java.net.URL;
  import java.util.Arrays;
  import java.util.List;
  import java.util.Locale;
  import java.util.Map;
  
  
Base test case that adds a number of convenience factory and training methods for the public interfaces of Tapestry.
  
  @SuppressWarnings("all")
  public abstract class TapestryTestCase extends IOCTestCase
  {

    
Creates a new markup writer instance (not a markup writer mock). Output can be directed at the writer, which uses the default (HTML) markup model. The writer's toString() value represents all the collected markup in the writer.
  
      protected final MarkupWriter createMarkupWriter()
      {
          return new MarkupWriterImpl();
      }

    

Deprecated:
May be removed in Tapestry 5.3
  
      protected final void train_getAliasesForMode(AliasManager managerString modeMap<ClassObjectconfiguration)
      {
          expect(manager.getAliasesForMode(mode)).andReturn(configuration);
      }
  
      {
          return newMock(ApplicationStateCreator.class);
      }
  
      {
          return newMock(ApplicationStatePersistenceStrategy.class);
      }
  
      {
          return newMock(ApplicationStatePersistenceStrategySource.class);
      }
 
     protected final Asset mockAsset()
     {
         return newMock(Asset.class);
     }
 
     protected final AssetFactory mockAssetFactory()
     {
         return newMock(AssetFactory.class);
     }
 
     protected final AssetSource mockAssetSource()
     {
         return newMock(AssetSource.class);
     }
 
     protected final Binding mockBinding()
     {
         return newMock(Binding.class);
     }
 
     protected final BindingFactory mockBindingFactory()
     {
         return newMock(BindingFactory.class);
     }
 
     protected final BindingSource mockBindingSource()
     {
         return newMock(BindingSource.class);
     }
 
     protected final Block mockBlock()
     {
         return newMock(Block.class);
     }
 
     {
         return newMock(ClasspathAssetAliasManager.class);
     }
 
     protected final ClassTransformation mockClassTransformation()
     {
         return newMock(ClassTransformation.class);
     }
 
     protected final Component mockComponent()
     {
         return newMock(Component.class);
     }
 
     {
         return newMock(ComponentClassResolver.class);
     }
 
     {
         return newMock(ComponentEventCallback.class);
     }
 
     protected final ComponentModel mockComponentModel()
     {
         return newMock(ComponentModel.class);
     }
 
     protected final ComponentResources mockComponentResources()
     {
         return newMock(ComponentResources.class);
     }
 
     protected final Context mockContext()
     {
         return newMock(Context.class);
     }
 
     protected final Environment mockEnvironment()
     {
         return newMock(Environment.class);
     }
 
     protected final Field mockField()
     {
         return newMock(Field.class);
     }
 
     protected final FieldValidator mockFieldValidator()
     {
         return newMock(FieldValidator.class);
     }
 
     {
         return newMock(FieldValidatorSource.class);
     }
 
     protected final Field mockFieldWithLabel(String label)
     {
         Field field = mockField();
 
         train_getLabel(fieldlabel);
 
         return field;
     }
 
     protected final Heartbeat mockHeartbeat()
     {
         return newMock(Heartbeat.class);
     }
 
     protected final HttpServletRequest mockHttpServletRequest()
     {
         return newMock(HttpServletRequest.class);
     }
 
     protected final HttpServletResponse mockHttpServletResponse()
     {
         return newMock(HttpServletResponse.class);
     }
 
     protected final HttpSession mockHttpSession()
     {
         return newMock(HttpSession.class);
     }
 
     protected final Inject mockInject()
     {
         return newMock(Inject.class);
     }
 
     protected final Link mockLink()
     {
         return newMock(Link.class);
     }
 
     protected final MarkupWriter mockMarkupWriter()
     {
         return newMock(MarkupWriter.class);
     }
 
     {
         return newMock(MutableComponentModel.class);
     }
 
     protected final ParameterModel mockParameterModel()
     {
         return newMock(ParameterModel.class);
     }
 
     protected final Path mockPath()
     {
         return newMock(Path.class);
     }
 
     protected final PropertyConduit mockPropertyConduit()
     {
         return newMock(PropertyConduit.class);
     }
 
     protected final PropertyModel mockPropertyModel()
     {
         return newMock(PropertyModel.class);
     }
 
     protected final Request mockRequest()
     {
         return newMock(Request.class);
     }
 
     protected final RequestHandler mockRequestHandler()
     {
         return newMock(RequestHandler.class);
     }
 
     {
         return newMock(ResourceDigestGenerator.class);
     }
 
     protected final Response mockResponse()
     {
         return newMock(Response.class);
     }
 
     protected final Session mockSession()
     {
         return newMock(Session.class);
     }
 
     protected final Translator mockTranslator()
     {
         return newMock(Translator.class);
     }
 
     {
         return newMock(ValidationConstraintGenerator.class);
     }

    

Deprecated:
May be removed in Tapestry 5.3
 
     {
         return newMock(ValidationMessagesSource.class);
     }
 
     protected final ValidationTracker mockValidationTracker()
     {
         return newMock(ValidationTracker.class);
     }
 
     protected final Validator mockValidator()
     {
         return newMock(Validator.class);
     }

    

Deprecated:
May be removed in Tapestry 5.3
 
     protected final void train_addField(ClassTransformation transformationint modifiersString type,
             String suggestedNameString actualName)
     {
         expect(transformation.addField(modifierstypesuggestedName)).andReturn(actualName);
     }

    

Deprecated:
May be removed in Tapestry 5.3
 
     protected final void train_addInjectedField(ClassTransformation ctClass typeString suggestedNameObject value,
             String fieldName)
     {
         expect(ct.addInjectedField(typesuggestedNamevalue)).andReturn(fieldName);
     }
 
     protected final void train_buildConstraints(ValidationConstraintGenerator generatorClass propertyType,
             AnnotationProvider providerString... constraints)
     {
         expect(generator.buildConstraints(propertyTypeprovider)).andReturn(Arrays.asList(constraints));
     }
 
     protected final <T> void train_create(ApplicationStateCreator<T> creator, T aso)
     {
         expect(creator.create()).andReturn(aso);
     }
 
     protected final void train_createAsset(AssetFactory factoryResource resourceAsset asset)
     {
         expect(factory.createAsset(resource)).andReturn(asset);
     }
 
     protected final void train_createValidator(FieldValidatorSource sourceField fieldString validatorType,
             String constraintValueString overrideIdMessages overrideMessagesLocale localeFieldValidator result)
     {
         expect(source.createValidator(fieldvalidatorTypeconstraintValueoverrideIdoverrideMessageslocale))
                 .andReturn(result);
     }
 
     protected final void train_encodeRedirectURL(Response responseString URIString encoded)
     {
         expect(response.encodeRedirectURL(URI)).andReturn(encoded);
     }
 
     protected final void train_encodeURL(Response responseString inputURLString outputURL)
     {
         expect(response.encodeURL(inputURL)).andReturn(outputURL);
     }
 
     protected final <T> void train_exists(ApplicationStatePersistenceStrategy strategyClass<T> asoClass,
             boolean exists)
     {
         expect(strategy.exists(asoClass)).andReturn(exists);
     }
 
     protected final void train_getAsset(AssetSource sourceResource rootString pathLocale localeAsset asset)
     {
         expect(source.getAsset(rootpathlocale)).andReturn(asset);
     }

    

Deprecated:
May be removed in Tapestry 5.3
 
     protected final void train_findFieldsWithAnnotation(ClassTransformation transformation,
             Class<? extends AnnotationannotationClassList<StringfieldNames)
     {
         expect(transformation.findFieldsWithAnnotation(annotationClass)).andReturn(fieldNames);
     }

    

Deprecated:
May be removed in Tapestry 5.3
 
     protected final void train_findFieldsWithAnnotation(ClassTransformation transformation,
             Class<? extends AnnotationannotationClassString... fieldNames)
     {
         train_findFieldsWithAnnotation(transformationannotationClass, Arrays.asList(fieldNames));
     }

    

Deprecated:
May be removed in Tapestry 5.3
 
     protected final void train_findMethods(ClassTransformation transformation,
             final TransformMethodSignature... signatures)
     {
         {
             public List<TransformMethodSignatureanswer() throws Throwable
             {
                 // Can't think of a way to do this without duplicating some code out of
                 // InternalClassTransformationImpl
 
                 List<TransformMethodSignatureresult = newList();
                 MethodFilter filter = (MethodFilter) EasyMock.getCurrentArguments()[0];
 
                 for (TransformMethodSignature sig : signatures)
                 {
                     if (filter.accept(sig))
                         result.add(sig);
                 }
 
                 // We don't have to sort them for testing purposes. Usually there's just going to be
                 // one in there.
 
                 return result;
             }
         };
 
         expect(transformation.findMethods(EasyMock.isA(MethodFilter.class))).andAnswer(answer);
     }

    

Deprecated:
May be removed in Tapestry 5.3
 
     protected final void train_findMethodsWithAnnotation(ClassTransformation tf,
             Class<? extends AnnotationannotationTypeList<TransformMethodSignaturesigs)
     {
         expect(tf.findMethodsWithAnnotation(annotationType)).andReturn(sigs);
     }

    

Deprecated:
May be removed in Tapestry 5.3
 
     protected final void train_findUnclaimedFields(ClassTransformation transformationString... fieldNames)
     {
         expect(transformation.findUnclaimedFields()).andReturn(Arrays.asList(fieldNames));
     }
 
     protected final void train_generateChecksum(ResourceDigestGenerator generatorURL urlString digest)
     {
         expect(generator.generateDigest(url)).andReturn(digest);
     }
 
     protected final <T> void train_get(ApplicationStatePersistenceStrategy strategyClass<T> asoClass,
             ApplicationStateCreator<T> creator, T aso)
     {
         expect(strategy.get(asoClasscreator)).andReturn(aso);
     }
 
     protected final void train_get(ApplicationStatePersistenceStrategySource sourceString strategyName,
             ApplicationStatePersistenceStrategy strategy)
     {
         expect(source.get(strategyName)).andReturn(strategy).atLeastOnce();
     }
 
     protected final void train_get(Binding bindingObject value)
     {
         expect(binding.get()).andReturn(value);
     }
 
     protected void train_getAttribute(HttpSession sessionString attributeNameObject value)
     {
         expect(session.getAttribute(attributeName)).andReturn(value);
     }
 
     protected final void train_getAttribute(Session sessionString nameObject attribute)
     {
         expect(session.getAttribute(name)).andReturn(attribute);
     }
 
     protected final void train_getAttributeNames(Session sessionString prefixString... names)
     {
         expect(session.getAttributeNames(prefix)).andReturn(Arrays.asList(names));
     }
 
     protected final void train_getBaseResource(ComponentModel modelResource resource)
     {
         expect(model.getBaseResource()).andReturn(resource).atLeastOnce();
     }
 
     protected final void train_getClassName(ClassTransformation transformationString className)
     {
         expect(transformation.getClassName()).andReturn(className).atLeastOnce();
     }
 
     protected final void train_getClasspathAsset(AssetSource sourceString pathAsset asset)
     {
         expect(source.getClasspathAsset(path)).andReturn(asset);
     }
 
     protected final void train_getClasspathAsset(AssetSource sourceString pathLocale localeAsset asset)
     {
         expect(source.getClasspathAsset(pathlocale)).andReturn(asset);
     }
 
     protected final void train_getCompleteId(ComponentResourcesCommon resourcesString completeId)
     {
         expect(resources.getCompleteId()).andReturn(completeId).atLeastOnce();
     }
 
     protected final void train_getComponent(ComponentResources resourcesComponent component)
     {
         expect(resources.getComponent()).andReturn(component).atLeastOnce();
     }
 
     protected final void train_getComponentClassName(ComponentModel modelString className)
     {
         expect(model.getComponentClassName()).andReturn(className).atLeastOnce();
     }
 
     protected final void train_getComponentResources(Component componentComponentResources resources)
     {
         expect(component.getComponentResources()).andReturn(resources).atLeastOnce();
     }
 
     protected final void train_getConduit(PropertyModel modelPropertyConduit conduit)
     {
         expect(model.getConduit()).andReturn(conduit).atLeastOnce();
     }
 
     protected <C, T> void train_getConstraintType(Validator<C, T> validatorClass<C> constraintType)
     {
         expect(validator.getConstraintType()).andReturn(constraintType).atLeastOnce();
     }
 
     protected final void train_getContainer(ComponentResources resourcesComponent container)
     {
         expect(resources.getContainer()).andReturn(container).atLeastOnce();
     }
 
     protected final void train_getContainerMessages(ComponentResources resourcesMessages containerMessages)
     {
         expect(resources.getContainerMessages()).andReturn(containerMessages).atLeastOnce();
     }
 
     protected final void train_getContainerResources(ComponentResources resourcesComponentResources containerResources)
     {
         expect(resources.getContainerResources()).andReturn(containerResources).atLeastOnce();
     }
 
     protected final void train_getDateHeader(Request requestString namelong value)
     {
         expect(request.getDateHeader(name)).andReturn(value).atLeastOnce();
     }

    

Deprecated:
May be removed in Tapestry 5.3
 
     protected final <T extends Annotationvoid train_getFieldAnnotation(ClassTransformation transformation,
             String fieldNameClass<T> annotationClass, T annotation)
     {
         expect(transformation.getFieldAnnotation(fieldNameannotationClass)).andReturn(annotation);
     }
 
     protected final void train_getFieldPersistenceStrategy(ComponentModel modelString fieldNameString fieldStrategy)
     {
         expect(model.getFieldPersistenceStrategy(fieldName)).andReturn(fieldStrategy).atLeastOnce();
     }

    

Deprecated:
May be removed in Tapestry 5.3
 
     protected final void train_getFieldType(ClassTransformation transformationString fieldNameString type)
     {
         expect(transformation.getFieldType(fieldName)).andReturn(type).atLeastOnce();
     }
 
     protected final void train_getId(ComponentResources resourcesString id)
     {
         expect(resources.getId()).andReturn(id).atLeastOnce();
     }
 
     protected final void train_getLabel(Field fieldString label)
     {
         expect(field.getLabel()).andReturn(label).atLeastOnce();
     }
 
     protected final void train_getLocale(ComponentResourcesCommon resourcesLocale locale)
     {
         expect(resources.getLocale()).andReturn(locale).atLeastOnce();
     }
 
     protected final void train_getLocale(Request requestLocale locale)
     {
         expect(request.getLocale()).andReturn(locale).atLeastOnce();
     }
 
     protected void train_getMessageKey(Validator validatorString messageKey)
     {
         expect(validator.getMessageKey()).andReturn(messageKey).atLeastOnce();
     }
 
     protected final void train_getMessages(ComponentResources resourcesMessages messages)
     {
         expect(resources.getMessages()).andReturn(messages).atLeastOnce();
     }
 
     protected final void train_getMeta(ComponentModel modelString keyString value)
     {
         expect(model.getMeta(key)).andReturn(value).atLeastOnce();
     }

    

Deprecated:
May be removed in Tapestry 5.3
 
     protected final <T extends Annotationvoid train_getMethodAnnotation(ClassTransformation ct,
             TransformMethodSignature signatureClass<T> annotationClass, T annotation)
     {
         expect(ct.getMethodAnnotation(signatureannotationClass)).andReturn(annotation).atLeastOnce();
     }
 
     protected final void train_getMethodIdentifier(ClassTransformation transformation,
             TransformMethodSignature signatureString id)
     {
         expect(transformation.getMethodIdentifier(signature)).andReturn(id);
     }
 
     protected final void train_getOutputStream(HttpServletResponse responseServletOutputStream stream)
     {
         try
         {
             expect(response.getOutputStream()).andReturn(stream);
         }
         catch (IOException e)
         {
             fail(e.getMessage(), e);
         }
     }
 
     protected final void train_getPage(ComponentResources resourcesComponent page)
     {
         expect(resources.getPage()).andReturn(page).atLeastOnce();
     }
 
     protected final void train_getParameterModel(ComponentModel modelString parameterName,
             ParameterModel parameterModel)
     {
         expect(model.getParameterModel(parameterName)).andReturn(parameterModel).atLeastOnce();
     }
 
     protected final void train_getParameterNames(ComponentModel modelString... names)
     {
         expect(model.getParameterNames()).andReturn(Arrays.asList(names));
     }
 
     protected final void train_getParentModel(ComponentModel modelComponentModel parentModel)
     {
         expect(model.getParentModel()).andReturn(parentModel).atLeastOnce();
     }
 
     protected final void train_getPath(Request requestString path)
     {
         expect(request.getPath()).andReturn(path).atLeastOnce();
     }
 
     protected final void train_getPersistentFieldNames(ComponentModel modelString... names)
     {
         expect(model.getPersistentFieldNames()).andReturn(Arrays.asList(names)).atLeastOnce();
     }

    

Deprecated:
May be removed in Tapestry 5.3
 
     protected final void train_getResourcesFieldName(ClassTransformation transformationString name)
     {
         expect(transformation.getResourcesFieldName()).andReturn(name).atLeastOnce();
     }
 
     protected final void train_getRootResource(AssetFactory factoryResource rootResource)
     {
         expect(factory.getRootResource()).andReturn(rootResource);
     }
 
     protected final void train_getSession(HttpServletRequest requestboolean createHttpSession session)
     {
         expect(request.getSession(create)).andReturn(session);
     }
 
     protected void train_getSession(Request requestboolean createSession session)
     {
         expect(request.getSession(create)).andReturn(session);
     }
 
     protected final void train_getSupportsInformalParameters(ComponentModel modelboolean supports)
     {
         expect(model.getSupportsInformalParameters()).andReturn(supports).atLeastOnce();
     }

    

Deprecated:
May be removed in Tapestry 5.3
 
     protected final void train_getValidationMessages(ValidationMessagesSource messagesSourceLocale locale,
             Messages messages)
     {
         expect(messagesSource.getValidationMessages(locale)).andReturn(messages).atLeastOnce();
     }
 
     protected final void train_getValueType(Validator validatorClass valueType)
     {
         expect(validator.getValueType()).andReturn(valueType).atLeastOnce();
     }
 
     @SuppressWarnings("unchecked")
     protected final void train_handleResult(ComponentEventCallback handlerObject resultboolean abort)
     {
         expect(handler.handleResult(result)).andReturn(abort);
     }
 
     protected final void train_inError(ValidationTracker trackerField fieldboolean inError)
     {
         expect(tracker.inError(field)).andReturn(inError);
     }
 
     protected final void train_isRequired(Validator validatorboolean isRequired)
     {
         expect(validator.isRequired()).andReturn(isRequired).atLeastOnce();
     }
 
     protected final void train_isInvariant(Binding bindingboolean isInvariant)
     {
         expect(binding.isInvariant()).andReturn(isInvariant);
     }
 
     protected final void train_isRequired(ParameterModel modelboolean isRequired)
     {
         expect(model.isRequired()).andReturn(isRequired);
     }
 
     protected final void train_isRootClass(MutableComponentModel modelboolean isRootClass)
     {
         expect(model.isRootClass()).andReturn(isRootClass);
     }
 
     protected final void train_name(Parameter parameterString name)
     {
         expect(parameter.name()).andReturn(name).atLeastOnce();
     }
 
     protected final void train_newBinding(BindingFactory factoryString descriptionComponentResources container,
             ComponentResources componentString expressionLocation lBinding binding)
     {
         expect(factory.newBinding(descriptioncontainercomponentexpressionl)).andReturn(binding);
     }
 
     protected void train_newBinding(BindingSource bindingSourceString description,
             ComponentResources componentResourcesString defaultBindingPrefixString expressionBinding binding)
     {
         expect(bindingSource.newBinding(descriptioncomponentResourcesdefaultBindingPrefixexpression)).andReturn(
                 binding);
     }
 
     protected final void train_newMemberName(ClassTransformation transformationString suggestedString name)
     {
         expect(transformation.newMemberName(suggested)).andReturn(name);
     }
 
     protected final void train_newMemberName(ClassTransformation transformationString prefixString baseName,
             String name)
     {
         expect(transformation.newMemberName(prefixbaseName)).andReturn(name);
     }
 
     protected final <T> void train_peek(Environment envClass<T> type, T value)
     {
         expect(env.peek(type)).andReturn(value);
     }
 
     protected final <T> void train_peekRequired(Environment envClass<T> type, T value)
     {
         expect(env.peekRequired(type)).andReturn(value);
     }
 
     protected final void train_provideInjection(InjectionProvider providerString fieldNameClass fieldType,
             ObjectLocator locatorClassTransformation transformationMutableComponentModel modelboolean result)
     {
         expect(provider.provideInjection(fieldNamefieldTypelocatortransformationmodel)).andReturn(result);
     }
 
     @SuppressWarnings("unchecked")
     protected final void train_renderInformalParameters(ComponentResources resourcesfinal MarkupWriter writer,
             final Object... informals)
     {
         resources.renderInformalParameters(writer);
         IAnswer answer = new IAnswer()
         {
             public Object answer() throws Throwable
             {
                 writer.attributes(informals);
 
                 return null;
             }
         };
 
         setAnswer(answer);
     }
 
     protected final void train_requiresDigest(ResourceDigestGenerator generatorString pathboolean requiresDigest)
     {
         expect(generator.requiresDigest(path)).andReturn(requiresDigest);
     }
 
     protected final void train_service(RequestHandler handlerRequest requestResponse responseboolean result)
             throws IOException
     {
         expect(handler.service(requestresponse)).andReturn(result);
     }
 
     protected final void train_setContentLength(HttpServletResponse responseint length)
     {
         response.setContentLength(length);
     }
 
     protected final void train_setContentType(HttpServletResponse responseString contentType)
     {
         response.setContentType(contentType);
     }
 
     protected final void train_setDateHeader(HttpServletResponse responseString headerNamelong date)
     {
         response.setDateHeader(headerNamedate);
     }
 
     protected final void train_toClass(ClassTransformation transformationString typeClass classForType)
     {
         expect(transformation.toClass(type)).andReturn(classForType);
     }
 
     protected final void train_toClientURL(Asset assetString URL)
     {
         expect(asset.toClientURL()).andReturn(URL).atLeastOnce();
     }
 
     protected final void train_toClientURL(ClasspathAssetAliasManager managerString resourcePathString clientURL)
     {
         expect(manager.toClientURL(resourcePath)).andReturn(clientURL);
     }
 
     protected final void train_toRedirectURI(Link linkString URI)
     {
         expect(link.toRedirectURI()).andReturn(URI).atLeastOnce();
     }

    

Deprecated:
May be removed in Tapestry 5.3
 
     protected final void train_toResourcePath(ClasspathAssetAliasManager managerString clientURLString resourcePath)
     {
         expect(manager.toResourcePath(clientURL)).andReturn(resourcePath).atLeastOnce();
     }
 
     protected final void train_value(Id annotationString value)
     {
         expect(annotation.value()).andReturn(value).atLeastOnce();
     }
 
     protected final void train_value(Path annotationString value)
     {
         expect(annotation.value()).andReturn(value).atLeastOnce();
     }

    

Deprecated:
May be removed in Tapestry 5.3
 
     protected final void train_create(BeanModelSource sourceClass beanClassboolean filterReadOnly,
             Messages messagesBeanModel model)
     {
         expect(source.create(beanClassfilterReadOnlymessages)).andReturn(model);
     }
 
     protected final void train_getBoundType(ComponentResources resourcesString parameterNameClass type)
     {
         expect(resources.getBoundType(parameterName)).andReturn(type);
     }
 
     protected final BeanModel mockBeanModel()
     {
         return newMock(BeanModel.class);
     }
 
     protected final BeanModelSource mockBeanModelSource()
     {
         return newMock(BeanModelSource.class);
     }
 
     public final void train_getLocation(Locatable locatableLocation location)
     {
         expect(locatable.getLocation()).andReturn(location).atLeastOnce();
     }
 
     public final void train_getResource(Location locationResource resource)
     {
         expect(location.getResource()).andReturn(resource).atLeastOnce();
     }
 
     public final void train_getLine(Location locationint line)
     {
         expect(location.getLine()).andReturn(line).atLeastOnce();
     }
 
     protected final void train_getParameter(Request requestString elementNameString value)
     {
         expect(request.getParameter(elementName)).andReturn(value).atLeastOnce();
     }
 
     protected final void train_getPageName(ComponentResourcesCommon resourcesString pageName)
     {
         expect(resources.getPageName()).andReturn(pageName).atLeastOnce();
     }
 
     protected final FormSupport mockFormSupport()
     {
         return newMock(FormSupport.class);
     }

    
Provides access to component messages, suitable for testing. Reads the associated .properties file for the class (NOT any localization of it). Only the messages directly in the .properties file is available.

Parameters:
componentClass component class whose messages are needed *
Returns:
the Messages instance
 
     protected final Messages messagesFor(Class componentClassthrows IOException
     {
         String file = componentClass.getSimpleName() + ".properties";
 
         Properties properties = new Properties();
 
         InputStream is = null;
 
         try
         {
             is = componentClass.getResourceAsStream(file);
 
             if (is == null)
                 throw new RuntimeException(String.format("Class %s does not have a message catalog.",
                         componentClass.getName()));
 
             properties.load(is);
         }
         finally
         {
             InternalUtils.close(is);
         }
 
         Map<StringStringmap = CollectionFactory.newCaseInsensitiveMap();
 
         for (Object key : properties.keySet())
         {
 
             String skey = (Stringkey;
 
             map.put(skeyproperties.getProperty(skey));
         }
 
         return new MapMessages(.map);
     }
 
     {
         return newMock(FieldValidationSupport.class);
     }

    

Deprecated:
May be removed in Tapestry 5.3
 
     protected final RenderSupport mockRenderSupport()
     {
         return newMock(RenderSupport.class);
     }
 
     protected final void train_getInheritInformalParameters(EmbeddedComponentModel modelboolean inherits)
     {
         expect(model.getInheritInformalParameters()).andReturn(inherits).atLeastOnce();
     }
 
     {
         return newMock(ApplicationStateManager.class);
     }
 
     protected final <T> void train_get(ApplicationStateManager managerClass<T> asoClass, T aso)
     {
         expect(manager.get(asoClass)).andReturn(aso);
     }
 
     protected final void train_getInput(ValidationTracker trackerField fieldString input)
     {
         expect(tracker.getInput(field)).andReturn(input);
     }
 
     protected final void train_isXHR(Request requestboolean isXHR)
     {
         expect(request.isXHR()).andReturn(isXHR).atLeastOnce();
     }
 
     protected void train_getPathInfo(HttpServletRequest requestString pathInfo)
     {
         expect(request.getPathInfo()).andReturn(pathInfo).atLeastOnce();
     }
 
     protected final void train_service(HttpServletRequestHandler handlerHttpServletRequest request,
             HttpServletResponse responseboolean resultthrows IOException
     {
         expect(handler.service(requestresponse)).andReturn(result);
     }
 
     protected final void train_getServletPath(HttpServletRequest requestString path)
     {
         expect(request.getServletPath()).andReturn(path).atLeastOnce();
     }
 
     {
         return newMock(HttpServletRequestHandler.class);
     }
 
     protected final NullFieldStrategy mockNullFieldStrategy()
     {
         return newMock(NullFieldStrategy.class);
     }
 
     protected final ValueEncoderSource mockValueEncoderSource()
    {
        return newMock(ValueEncoderSource.class);
    }
    protected final ValueEncoder mockValueEncoder()
    {
        return newMock(ValueEncoder.class);
    }