Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve JSF's testAjaxInputFile #30311

Open
wants to merge 1 commit into
base: integration
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,10 @@ public void testAjaxInputFile() throws Exception {
//Ensure the correct content type is used.
assertNotNull("The 'multipart/form-data; boundary=' content type was not found!", jsfTestServer2.waitForStringInTraceUsingMark(".*multipart/form-data; boundary=.*"));

Log.info(c, name.getMethodName(), page.getPageSource());

page.waitForCondition(driver -> page.isInPage("File Size: 12"));

page.findElement(By.id("form1:uploadButton")).click();

Log.info(c, name.getMethodName(), page.getPageSource());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@
<h:form id="form1" enctype="multipart/form-data">
<p>Enter a file to upload:</p>
<h:inputFile id="file1" value="#{fileBean.file}">
<f:ajax event="change"/>
<f:ajax render="size" event="change"/>
</h:inputFile>
<h:commandButton id="uploadButton" value="Upload File" action="#{fileBean.uploadFile}"/>
<br/>
<h:outputText id="size" value="File Size: #{fileBean.getFileSize()}"/>
</h:form>
</h:body>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,12 @@ public void setFile(Part file) {
public String getFileContents() {
return fileContents;
}

public long getFileSize(){
if(this.file == null){
System.out.println("0L");
return 0L;
}
return this.file.getSize();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@ public Part getFile() {
return file;
}

public long getFileSize(){
if(this.file == null){
return 0L;
}
return this.file.getSize();
}

public void setFile(Part file) {
this.file = file;
}
Expand Down