Merged CMIS063 to HEAD

15843: Java tests harness: next  portion of v0.62
  15918: CMIS Test Harness update.

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@17235 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
David Caruana
2009-10-29 17:01:43 +00:00
parent 689da0821f
commit 0e526dc4d1
33 changed files with 13212 additions and 3493 deletions

View File

@@ -1,118 +1,152 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Services;
using System.Web.Services.Protocols;
/*
* Copyright (C) 2005-2007 Alfresco Software Limited.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* As a special exception to the terms and conditions of version 2.0 of
* the GPL, you may redistribute this Program in connection with Free/Libre
* and Open Source Software ("FLOSS") applications as described in Alfresco's
* FLOSS exception. You should have recieved a copy of the text describing
* the FLOSS exception, and it is also available here:
* http://www.alfresco.com/legal/licensing"
*/
using System;
using System.Net;
using System.ServiceModel;
using System.ServiceModel.Security;
using System.ServiceModel.Security.Tokens;
using System.Security.Cryptography.X509Certificates;
using System.Net.Security;
using System.ServiceModel.Channels;
using www.cmis.org.ns._1._01;
using System.Security.Cryptography.X509Certificates;
using System.ServiceModel;
using WcfCmisWSTests.CmisServices;
using System.Reflection;
namespace CmisTest
{
class Program
public class Program
{
private const string INVALID_REACTION_MESSAGE = "Invalid Reaction! Exception should be thrown";
static void Main(string[] args)
private static RepositoryServicePortClient repositoryService = null;
private static NavigationServicePortClient navigationService = null;
private static ObjectServicePortClient objectService = null;
public static void Main(string[] args)
{
initialize();
cmisRepositoryEntryType[] repositories = repositoryService.getRepositories();
string repositoryId = repositories[0].id;
Console.WriteLine("Repositories description were received. Repositories amount: '" + repositories.Length + "'. First Repository Id='" + repositoryId + "'.");
string rootFolder = repositoryService.getRepositoryInfo(repositoryId).rootFolderId;
Console.WriteLine("Root folder Id='" + rootFolder + "'.\n");
try
{
Console.WriteLine("Actual Reaction of RepositoryService.getRepositoryInfo() service method with invalid Repository Id:");
repositoryService.getRepositoryInfo("Invalid Repository Id");
Console.WriteLine(INVALID_REACTION_MESSAGE);
}
catch (FaultException<cmisFaultType> e)
{
Console.WriteLine(" " + e.Message);
}
try
{
Console.WriteLine("Actual Reaction of ObjectService.getProperties() service method with invalid Object Id:");
objectService.getProperties(repositoryId, ("Invalid Object Id"), "*", false, null, false);
Console.WriteLine(INVALID_REACTION_MESSAGE);
}
catch (FaultException<cmisFaultType> e)
{
Console.WriteLine(" " + e.Message + "\n");
}
cmisObjectType[] childrenResponse = null;
try
{
bool hasMoreItems;
Console.WriteLine("Trying to receive Children Objects of Root Folder...");
childrenResponse = navigationService.getChildren(repositoryId, rootFolder, "*", false, null, false, false, "0", "0", null, out hasMoreItems);
Console.WriteLine("Children of Root Folder were received. Elements amount: '" + childrenResponse.Length + "'. Has More Items='" + hasMoreItems + "' (how it WAS " + ((hasMoreItems) ? ("NOT ") : ("")) + "expected).");
} catch (FaultException<cmisFaultType> e) {
Console.WriteLine("Can't receive Children of Root Folder. Cause error message: " + e.Message);
}
if (null != childrenResponse) {
Console.WriteLine("Root folder listing: ");
foreach (cmisObjectType cmisObject in childrenResponse) {
if (null != cmisObject) {
cmisProperty nameProperty = searchForProperty(cmisObject.properties, "cmis:Name");
cmisProperty baseTypeProperty = searchForProperty(cmisObject.properties, "cmis:BaseTypeId");
Console.WriteLine((("cmis:folder".Equals(getPropertyValue(baseTypeProperty))) ? ("Folder") : ("Document")) + " Child with Name='" + getPropertyValue(nameProperty) + "'");
}
}
}
}
private static void initialize() {
ServicePointManager.ServerCertificateValidationCallback = delegate(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
{
return true;
};
RepositoryServicePortClient repositoryService = new RepositoryServicePortClient();
repositoryService = new RepositoryServicePortClient();
repositoryService.ClientCredentials.UserName.UserName = "admin";
repositoryService.ClientCredentials.UserName.Password = "admin";
NavigationServicePortClient navigationService = new NavigationServicePortClient();
navigationService = new NavigationServicePortClient();
navigationService.ClientCredentials.UserName.UserName = "admin";
navigationService.ClientCredentials.UserName.Password = "admin";
ObjectServicePortClient objectService = new ObjectServicePortClient();
objectService = new ObjectServicePortClient();
objectService.ClientCredentials.UserName.UserName = "admin";
objectService.ClientCredentials.UserName.Password = "admin";
}
folderObjectType rootFolder = repositoryService.getRootFolder("*");
Console.WriteLine("Root folder OID = {0}\n", rootFolder.objectID);
try
{
repositoryService.getRootFolder("a");
}
catch (FaultException<basicFault> e)
{
Console.WriteLine(e.Message);
private static string getPropertyName(cmisProperty property)
{
string result = null;
if (null != property) {
result = (null != property.pdid) ? (property.pdid):(property.localname);
result = (null != result) ? (result):(property.displayname);
}
return result;
}
try
{
objectService.getProperties(rootFolder + "1", versionEnum.@this, "*");
}
catch (FaultException e)
{
Console.WriteLine(e.Message);
}
bool hasMoreItems;
documentOrFolderObjectType[] rootFolderListing = navigationService.getChildren(rootFolder.objectID, typesOfObjectsEnum.FoldersAndDocumets, "*", null, null,
out hasMoreItems);
string guestFolderOID = null;
Console.WriteLine("Root folder listing: ");
foreach (documentOrFolderObjectType docFolder in rootFolderListing)
{
if (docFolder.name == "Guest Home")
{
guestFolderOID = docFolder.objectID;
}
Console.WriteLine(docFolder.name);
}
if (guestFolderOID != null)
{
Console.Write("\nGet children for bad OID, error : ");
try
{
navigationService.getChildren(guestFolderOID + 1, typesOfObjectsEnum.FoldersAndDocumets, "*", null, null,
out hasMoreItems);
}
catch (FaultException e)
{
Console.WriteLine(e.Message);
}
documentOrFolderObjectType[] guestFolderListing =
navigationService.getChildren(guestFolderOID, typesOfObjectsEnum.FoldersAndDocumets, "*", null, null,
out hasMoreItems);
string alfrescoTutOID = null;
Console.WriteLine("\nGuest folder listing: ");
foreach (documentOrFolderObjectType docFolder in guestFolderListing)
{
if (docFolder.name == "Alfresco-Tutorial.pdf")
{
alfrescoTutOID = docFolder.objectID;
private static object getPropertyValue(cmisProperty property) {
if (null != property) {
Type propertyType = property.GetType();
PropertyInfo valueProperty = propertyType.GetProperty("value");
if ((null != valueProperty) && valueProperty.CanRead) {
object[] values = (object[])valueProperty.GetValue(property, null);
if ((null != values) && (values.Length > 0)) {
return values[0];
}
Console.WriteLine(docFolder.name);
}
if (alfrescoTutOID != null)
{
byte[] bytes = objectService.getContentStream(alfrescoTutOID, null, "100");
Console.WriteLine("\nAlfresco-Tutorial.pdf retrieved");
}
}
return null;
}
private static cmisProperty searchForProperty(cmisPropertiesType properties, string propertyName) {
if((null != properties) && (null != properties.Items) && (properties.Items.Length > 0) && (null != propertyName) && !"".Equals(propertyName)) {
foreach(cmisProperty property in properties.Items) {
string name = getPropertyName(property);
if((null != name) && name.Equals(propertyName)) {
return property;
}
}
}
return null;
}
}
}
}