Package org.apache.tapestry.upload.services

Examples of org.apache.tapestry.upload.services.UploadedFile


    @Test
    public void process_submission_ignores_null_value() throws Exception
    {
        FormSupport formSupport = mockFormSupport();
        MultipartDecoder decoder = mockMultipartDecoder();
        UploadedFile uploadedFile = mockUploadedFile();

        Upload component = new Upload(null, null, decoder, null);

        expect(decoder.getFileUpload("test")).andReturn(uploadedFile);
        expect(uploadedFile.getFileName()).andReturn("").atLeastOnce();

        replay();

        component.processSubmission(formSupport, "test");
View Full Code Here


    @Test
    public void process_submission_calls_validator() throws Exception
    {
        FormSupport formSupport = mockFormSupport();
        MultipartDecoder decoder = mockMultipartDecoder();
        UploadedFile uploadedFile = mockUploadedFile();
        FieldValidator<Object> validate = mockFieldValidator();

        Upload component = new Upload(null, validate, decoder, null);

        expect(decoder.getFileUpload("test")).andReturn(uploadedFile);
        expect(uploadedFile.getFileName()).andReturn("test").atLeastOnce();
        validate.validate(uploadedFile);
        replay();

        component.processSubmission(formSupport, "test");
View Full Code Here

    @Test
    public void process_submission_tracks_validator_errors() throws Exception
    {
        FormSupport formSupport = mockFormSupport();
        MultipartDecoder decoder = mockMultipartDecoder();
        UploadedFile uploadedFile = mockUploadedFile();
        FieldValidator<Object> validate = mockFieldValidator();
        ValidationTracker tracker = mockValidationTracker();

        Upload component = new Upload(null, validate, decoder, tracker);

        expect(decoder.getFileUpload("test")).andReturn(uploadedFile);
        expect(uploadedFile.getFileName()).andReturn("test").atLeastOnce();
        validate.validate(uploadedFile);
        expectLastCall().andThrow(new ValidationException("an error"));
        tracker.recordError(component, "an error");
        replay();
View Full Code Here

    @Test
    public void process_submission_extracts_value_from_decoder() throws Exception
    {
        FormSupport formSupport = mockFormSupport();
        MultipartDecoder decoder = mockMultipartDecoder();
        UploadedFile uploadedFile = mockUploadedFile();

        Upload component = new Upload(null, null, decoder, null);

        expect(decoder.getFileUpload("test")).andReturn(uploadedFile);
        expect(uploadedFile.getFileName()).andReturn("foo").anyTimes();

        replay();

        component.processSubmission(formSupport, "test");
View Full Code Here

    @Test
    public void process_submission_extracts_value_from_decoder() throws Exception
    {
        FormSupport formSupport = mockFormSupport();
        MultipartDecoder decoder = mockMultipartDecoder();
        UploadedFile uploadedFile = mockUploadedFile();

        Upload component = new Upload(null, null, decoder, null, null);

        expect(decoder.getFileUpload("test")).andReturn(uploadedFile);
        expect(uploadedFile.getFileName()).andReturn("foo").anyTimes();

        replay();

        component.processSubmission(formSupport, "test");
View Full Code Here

    @Test
    public void process_submission_ignores_null_value() throws Exception
    {
        FormSupport formSupport = mockFormSupport();
        MultipartDecoder decoder = mockMultipartDecoder();
        UploadedFile uploadedFile = mockUploadedFile();

        Upload component = new Upload(null, null, decoder, null, null);

        expect(decoder.getFileUpload("test")).andReturn(uploadedFile);
        expect(uploadedFile.getFileName()).andReturn("").atLeastOnce();

        replay();

        component.processSubmission(formSupport, "test");
View Full Code Here

    @Test
    public void process_submission_calls_validator() throws Exception
    {
        FormSupport formSupport = mockFormSupport();
        MultipartDecoder decoder = mockMultipartDecoder();
        UploadedFile uploadedFile = mockUploadedFile();
        FieldValidator<Object> validate = mockFieldValidator();

        Upload component = new Upload(null, validate, decoder, null, null);

        expect(decoder.getFileUpload("test")).andReturn(uploadedFile);
        expect(uploadedFile.getFileName()).andReturn("test").atLeastOnce();
        validate.validate(uploadedFile);
        replay();

        component.processSubmission(formSupport, "test");
View Full Code Here

    @Test
    public void process_submission_tracks_validator_errors() throws Exception
    {
        FormSupport formSupport = mockFormSupport();
        MultipartDecoder decoder = mockMultipartDecoder();
        UploadedFile uploadedFile = mockUploadedFile();
        FieldValidator<Object> validate = mockFieldValidator();
        ValidationTracker tracker = mockValidationTracker();

        Upload component = new Upload(null, validate, decoder, tracker, null);

        expect(decoder.getFileUpload("test")).andReturn(uploadedFile);
        expect(uploadedFile.getFileName()).andReturn("test").atLeastOnce();
        validate.validate(uploadedFile);
        expectLastCall().andThrow(new ValidationException("an error"));
        tracker.recordError(component, "an error");
        replay();
View Full Code Here

    @SuppressWarnings({"unchecked"})
    @Override
    protected void processSubmission(String elementName)
    {
        UploadedFile uploaded = _decoder.getFileUpload(elementName);

        if (uploaded != null)
        {
            if (uploaded.getFileName() == null || uploaded.getFileName().length() == 0) uploaded = null;
        }

        try
        {
            _fieldValidationSupport.validate(uploaded, _resources, _validate);
View Full Code Here

    @SuppressWarnings({"unchecked"})
    @Test
    public void process_submission_extracts_value_from_decoder() throws Exception
    {
        MultipartDecoder decoder = mockMultipartDecoder();
        UploadedFile uploadedFile = mockUploadedFile();
        ComponentResources resources = mockComponentResources();
        FieldValidationSupport support = mockFieldValidationSupport();
        FieldValidator validate = mockFieldValidator();

        Upload component = new Upload(null, validate, decoder, null, resources, support);

        expect(decoder.getFileUpload("test")).andReturn(uploadedFile);
        expect(uploadedFile.getFileName()).andReturn("foo").anyTimes();

        support.validate(uploadedFile, resources, validate);

        replay();
View Full Code Here

TOP

Related Classes of org.apache.tapestry.upload.services.UploadedFile

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.