所以,我是Sitecore的新手,並不確切知道如何啓用它。我在服務器A上安裝了Sitecore,並且正在運行服務器B的單元測試。但是,我遇到了通過它們的API遠程訪問Sitecore的問題(在Sitecore.Kernel.dll中)。單元測試Sitecore從不同服務器安裝
- 的Sitecore的安裝已正確設置,我可以訪問CMS管理,我可以添加項目,我可以看到數據庫等
- 從下面的堆棧跟蹤,我可以看到它在尋找數據文件夾(服務器B上不存在,它是服務器A上的Sitecore安裝的一部分)。
- 許可證存儲在這個目錄(數據文件夾),因爲失敗的調用代碼被稱爲LicenseManager,我猜測有些東西正試圖驗證許可證。
- 我已經在下面的參考鏈接中指定了我的單元測試。這有我的設置的所有具體細節(但隨意提問)。
問:有(最好是通過DLL中的Sitecore的API)的方式來設置此,從不同的服務器執行鍼對Sitecore的安裝單元測試?
參考文獻:
- http://www.experimentsincode.com/?p=232 - 一般設置
- http://sdn.sitecore.net/upload/sitecore6/content_api_cookbook-a4.pdf - 內容API REF
實施例試驗編號:
[TestMethod]
public void GetItemTest()
{
var database = global::Sitecore.Configuration.Factory.GetDatabase("master");
Assert.IsNotNull(database);
var item = database.GetItem("/sitecore/content");
Assert.IsNotNull(item);
Assert.AreEqual("content", item.Name);
}
例外:
System.TypeInitializationException was unhandled by user code
Message=The type initializer for 'Sitecore.SecurityModel.License.LicenseManager' threw an exception.
Source=Sitecore.Kernel
TypeName=Sitecore.SecurityModel.License.LicenseManager
StackTrace:
at Sitecore.SecurityModel.License.LicenseManager.DemandRuntime(Boolean acceptExpress)
at Sitecore.Data.Managers.ItemManager.get_Provider()
at Sitecore.Data.Managers.ItemManager.GetItem(String itemPath, Language language, Version version, Database database)
at Sitecore.Data.Database.GetItem(String path)
at Spacely.Web.Tests.Services.SitecoreServiceTest.GetItemTest() in C:\Users\foo\src\spacely\Spacely.Web.Tests\Services\SitecoreServiceTest.cs:line 25
InnerException: System.Reflection.TargetInvocationException
Message=Exception has been thrown by the target of an invocation.
Source=mscorlib
StackTrace:
at System.RuntimeMethodHandle._InvokeConstructor(IRuntimeMethodInfo method, Object[] args, SignatureStruct& signature, RuntimeType declaringType)
at System.RuntimeMethodHandle.InvokeConstructor(IRuntimeMethodInfo method, Object[] args, SignatureStruct signature, RuntimeType declaringType)
at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.Reflection.ConstructorInfo.Invoke(Object[] parameters)
at Sitecore.Reflection.ReflectionUtil.CreateObject(Type type, Object[] parameters)
at Sitecore.Reflection.ReflectionUtil.CreateObject(String assembly, String className, Object[] parameters)
at Sitecore.Reflection.ReflectionUtil.CreateObject(String typeName, Object[] parameters)
at Sitecore.Reflection.Nexus.GetApi[T](String typeName, T& api)
at Sitecore.Reflection.Nexus.get_LicenseApi()
at Sitecore.SecurityModel.License.LicenseManager.GetSnapshotData(Guid instance)
at Sitecore.SecurityModel.License.LicenseManager.UpdateSnapshot()
at Sitecore.SecurityModel.License.LicenseManager..cctor()
InnerException: System.ArgumentException
Message=The directory name \data is invalid.
Source=System
StackTrace:
at System.IO.FileSystemWatcher.set_Path(String value)
at Sitecore.IO.FileWatcher.InitializeWatcher(String filter, String folder)
at Sitecore.IO.FileWatcher..ctor(String folder, String filter)
at Sitecore.SecurityModel.License.LicenseWatcher..ctor()
at Sitecore.Nexus.Licensing.NexusLicenseApi.()
at Sitecore.Nexus.Licensing.NexusLicenseApi..ctor()
InnerException:
的部分是什麼你提到爲我工作!關鍵步驟是在該文件中添加數據目錄和許可證副本,並將其部署到正確的測試位置(實際執行測試的位置)。有趣的是,我實際上已經在我的桌上得到了答案......對於任何感興趣的人,請查看John West的專業Sitecore開發書。我的解決方案在第8章 - 自動測試第338頁 - 「考慮在沒有HTTP上下文的情況下調用Sitecore API」(具體而言,我錯過了第10步和第11步)。噓。 – longda 2013-03-06 23:42:32