public void MSWDVMODUU_S03_TC04_PropFindExtension_Resource_Descendant()
{
// In the server, the following resource structure is existed before running this test case.
// [Root-Folder]
// --- [Sub-Folder]
// --- New_File003.txt
bool isSuccessful = false;
bool doesCaptureRequirement_105 = false;
string destinationUri_File004 = string.Empty;
string newFilePath_File004 = string.Empty;
// Step1.
// Call HTTP PUT request with following settings:
// - Set the "Request-URI" to "[Sub-Folder]\New_File004.txt".
destinationUri_File004 = Common.GetConfigurationPropertyValue("Server_NewFile004Uri", this.Site);
newFilePath_File004 = Common.GetConfigurationPropertyValue("Client_NewFile004Name", this.Site);
isSuccessful = this.PutNewFileIntoServer(destinationUri_File004, newFilePath_File004);
Site.Assert.IsTrue(isSuccessful, "Upload file New_File004 should be successful.");
this.ArrayListForDeleteFile.Add((object)destinationUri_File004);
// Step2.
// Call HTTP PROPFIND request with following settings:
// - Set "Depth" header to "1";
// - Set the time stamp to the default time stamp "1969-01-01T12:00:00Z";
// - Set the "Request-URI" to "[Sub-Folder]".
string requestUri = Common.GetConfigurationPropertyValue("Server_SubFolderUri", this.Site);
NameValueCollection headersCollection = S03_PropFindExtension.ConstructHttpHeaders("1");
string body = S03_PropFindExtension.ConstructHttpBody(DefaultTimeStamp);
WDVMODUUResponse response = Adapter.PropFind(requestUri, body, headersCollection);
// Get XML data from the response
this.Site.Assert.IsNotNull(response.BodyXmlData, "The response object 'response.BodyXmlData' should not be null!");
XmlDocument xmlDoc = response.BodyXmlData;
// Get valid resource list from the response of Step 2.
ArrayList resourceList_1 = this.GetValidResourceUnderMultistatusElement(xmlDoc);
this.Site.Assert.IsTrue((resourceList_1 != null) && (resourceList_1.Count > 0), "There should be some valid resource in the response!");
this.Site.Log.Add(LogEntryKind.Comment, "resourceList_1.Count = {0}", resourceList_1.Count);
// Step3.
// Based on the response of step 2, calculate the critical time stamp for resource "[Sub-Folder]" and resource "New_File003.txt".
// The critical time stamp is the last modified date time of the resource plus 5 minutes and 1 second.
DateTime criticalTimeStamp_SubFolder = DateTime.MinValue;
DateTime criticalTimeStamp_New_File003 = DateTime.MinValue;
string expectedHref_SubFolder = requestUri;
string expectedHref_New_File003 = Common.GetConfigurationPropertyValue("Server_NewFile003Uri", this.Site);
IEnumerator enumratorResInfo = resourceList_1.GetEnumerator();
while (enumratorResInfo.MoveNext())
{
ResourceInfo resInfo = (ResourceInfo)enumratorResInfo.Current;
// Try to find the resource "New_File003.txt",and calculate the critical time stamp.
if (string.Compare(resInfo.Href, expectedHref_New_File003, true) == 0)
{
this.Site.Log.Add(LogEntryKind.Comment, "The last modified data time for 'NewFile003' is {0}.", resInfo.LastModifiedDateTime);
criticalTimeStamp_New_File003 = resInfo.LastModifiedDateTime.AddSeconds((5 * 60) + 1);
}
// Try to find the resource "[Sub-Folder]", and calculate the critical time stamp.
// In some protocol server, the return URI for collection resource end with "/";
// In some protocol server, the return URI for collection resource end without "/";
// The example for such URI can be:
// http://SUT01/sites/WDVMODUU/shared20%documents/SubFolder/
// or http://SUT01/sites/WDVMODUU/shared20%documents/SubFolder
// The two URI identify the same collection resource.
// So following codes use two compare results to check if the resource "[Sub-Folder]" is existed in the resource list.
if ((string.Compare(resInfo.Href, expectedHref_SubFolder, true) == 0)
|| (string.Compare(resInfo.Href + "/", expectedHref_SubFolder, true) == 0))
{
this.Site.Log.Add(LogEntryKind.Comment, "The last modified data time for '[Sub-Folder]' is {0}.", resInfo.LastModifiedDateTime);
criticalTimeStamp_SubFolder = resInfo.LastModifiedDateTime.AddSeconds((5 * 60) + 1);
}
}
this.Site.Assert.IsTrue(criticalTimeStamp_SubFolder != DateTime.MinValue, "The resource \"[Sub-Folder]\" should be existed in the resource list.");
this.Site.Assert.IsTrue(criticalTimeStamp_New_File003 != DateTime.MinValue, "The resource \"New_File003.txt\" should be existed in the resource list");
// Step4.
// Call HTTP PROPFIND request with following settings:
// - Set "Depth" header to "1";
// - Set the time stamp to the critical time stamp for resource "New_File003.txt";
// - Set the "Request-URI" to "[Sub-Folder]".
requestUri = Common.GetConfigurationPropertyValue("Server_SubFolderUri", this.Site);
headersCollection = S03_PropFindExtension.ConstructHttpHeaders("1");
body = S03_PropFindExtension.ConstructHttpBody(S03_PropFindExtension.GetUtcFormatString(criticalTimeStamp_New_File003));
response = this.Adapter.PropFind(requestUri, body, headersCollection);
// Get XML data from the response
this.Site.Assert.IsNotNull(response.BodyXmlData, "The response object 'response.BodyXmlData' should not be null!");
xmlDoc = response.BodyXmlData;
// Get valid resource list from the response of Step 4.
ArrayList resourceList_2 = this.GetValidResourceUnderMultistatusElement(xmlDoc);
this.Site.Assert.IsTrue((resourceList_2 != null) && (resourceList_2.Count > 0), "There should be some valid resource in the response!");
this.Site.Log.Add(LogEntryKind.Comment, "resourceList_2.Count = {0}", resourceList_2.Count);
// Step5.
// In the response of step 4, make sure the resource "New_File003.txt" is still returned based on Rule 2.
// Because its parent resource "[Sub-Folder]" is returned based on Rule 1.
bool findNewFile003DueToRule2 = false;
enumratorResInfo = resourceList_2.GetEnumerator();
while (enumratorResInfo.MoveNext())
{
ResourceInfo resInfo = (ResourceInfo)enumratorResInfo.Current;
if (string.Compare(resInfo.Href, expectedHref_New_File003, true) == 0)
{
findNewFile003DueToRule2 = true;
break;
}
}
this.Site.Assert.IsTrue(findNewFile003DueToRule2, "The resource \"New_File003.txt\" should be returned based on Rule 2.");
// Step6.
// Call HTTP PROPFIND request with following settings:
// - Set "Depth" header to "1";
// - Set the time stamp to the critical time stamp for resource "[Sub-Folder]";
// - Set the "Request-URI" to "[Sub-Folder]".
requestUri = Common.GetConfigurationPropertyValue("Server_SubFolderUri", this.Site);
headersCollection = S03_PropFindExtension.ConstructHttpHeaders("1");
body = S03_PropFindExtension.ConstructHttpBody(S03_PropFindExtension.GetUtcFormatString(criticalTimeStamp_SubFolder));
response = this.Adapter.PropFind(requestUri, body, headersCollection);
// Get XML data from the response
this.Site.Assert.IsNotNull(response.BodyXmlData, "The response object 'response.BodyXmlData' should not be null!");
xmlDoc = response.BodyXmlData;
// Get valid resource list from the response of Step 6.
ArrayList resourceList_3 = this.GetValidResourceUnderMultistatusElement(xmlDoc);
this.Site.Log.Add(LogEntryKind.Comment, "resourceList_3.Count = {0}", resourceList_3.Count);
// Step7.
// In the response of step 6, make sure resource "[Sub-Folder]", "New_File003.txt" and "New_File004.txt" are all not returned.
enumratorResInfo = resourceList_3.GetEnumerator();
bool doesNotReturnSubFolder = true;
bool doesNotReturnNewFile003 = true;
bool doesNotReturnNewFile004 = true;
string expectedHref_New_File004 = destinationUri_File004;
while (enumratorResInfo.MoveNext())
{
ResourceInfo resInfo = (ResourceInfo)enumratorResInfo.Current;
// Try to find the resource "[Sub-Folder]".
// In some protocol server, the return URI for collection resource end with "/";
// In some protocol server, the return URI for collection resource end without "/";
// The example for such URI can be:
// http://SUT01/sites/WDVMODUU/shared20%documents/SubFolder/
// or http://SUT01/sites/WDVMODUU/shared20%documents/SubFolder
// The two URI identify the same collection resource.
// So following codes use two compare results to check if the resource "[Sub-Folder]" is existed in the resource list.
if ((string.Compare(resInfo.Href, expectedHref_SubFolder, true) == 0)
|| (string.Compare(resInfo.Href + "/", expectedHref_SubFolder, true) == 0))
{
doesNotReturnSubFolder = false;
}
// Try to find the resource "New_File003.txt".
if (string.Compare(resInfo.Href, expectedHref_New_File003, true) == 0)
{
doesNotReturnNewFile003 = false;
}
// Try to find the resource "New_File004.txt".
if (string.Compare(resInfo.Href, expectedHref_New_File004, true) == 0)
{
doesNotReturnNewFile004 = false;
}
}
this.Site.Assert.IsTrue(doesNotReturnSubFolder, "The resource \"[Sub-Folder]\" should not be return.");
this.Site.Assert.IsTrue(doesNotReturnNewFile003, "The resource \"New_File003.txt\" should not be return.");
this.Site.Assert.IsTrue(doesNotReturnNewFile004, "The resource \"New_File004.txt\" should not be return.");
// Step8.
// Call HTTP DELETE method to delete the test file "New_File004.txt" that uploaded in the step 1.
isSuccessful = this.DeleteTheFileInTheServer(destinationUri_File004);
this.Site.Assert.IsTrue(isSuccessful, "Delete the test file \"New_File004.txt\" should be successful. ");
this.RemoveFileUriFromDeleteList(destinationUri_File004);
// Step9.
// If the response "New_File003.txt" is return in the response of step 4,
// and resource "[Sub-Folder]", "New_File003.txt" and "New_File004.txt" are all not return in the response of step 6 ,
// then capture MS-WDVMODUU_R105.
if (findNewFile003DueToRule2 && doesNotReturnSubFolder && doesNotReturnNewFile003 && doesNotReturnNewFile004)
{
doesCaptureRequirement_105 = true;
}
this.Site.CaptureRequirementIfIsTrue(
doesCaptureRequirement_105,
105,
@"[In Repl:collblob and Repl:repl] [When the server receives a PROPFIND request with the Repl:collblob element set to a timestamp, it includes a response element for each resource in the multistatus element that is a descendant of the Request-URI (limited by the Depth header specified in [RFC2518]) and that has changed according to the rule:] The resource is a descendant of a resource that has changed later than or equal to 5 minutes before the timestamp.");
}