public void PutOnOneCacheGetOnAnotherCache() { var geodeServer = new GeodeServer(); var cacheXml = new CacheXml(new FileInfo("cache.xml"), geodeServer); var cacheFactory = new CacheFactory(); cacheOne = cacheFactory.Create(); cacheOne.InitializeDeclarativeCache(cacheXml.File.FullName); cacheTwo = cacheFactory.Create(); cacheTwo.InitializeDeclarativeCache(cacheXml.File.FullName); var regionForCache1 = cacheOne.GetRegion <string, string>("testRegion1"); var regionForCache2 = cacheTwo.GetRegion <string, string>("testRegion1"); const string key = "hello"; const string expectedResult = "dave"; regionForCache1.Put(key, expectedResult, null); var actualResult = regionForCache2.Get(key, null); Assert.Equal(expectedResult, actualResult); cacheXml.Dispose(); geodeServer.Dispose(); }
public CacheXml(FileInfo template, GeodeServer gfs, string regionName = "testRegion") { string content; using (var input = template.OpenText()) { content = input.ReadToEnd(); } content = content.Replace("LOCATOR_PORT", gfs.LocatorPort.ToString()); content = content.Replace("REGION_NAME", regionName); Debug.WriteLine(content); var tempFile = new FileInfo(Path.GetTempFileName()) { Attributes = FileAttributes.Temporary }; // Set the Attribute property of this file to Temporary. // Although this is not completely necessary, the .NET Framework is able // to optimize the use of Temporary files by keeping them cached in memory. using (var output = new StreamWriter(tempFile.FullName)) { output.Write(content); } File = tempFile; }
public void Start() { var gfs = new GeodeServer(); Assert.NotNull(gfs); Assert.NotEqual(0, gfs.LocatorPort); gfs.Dispose(); }
public void ConstructAndGenerate() { using (var gfs = new GeodeServer()) { var template = new FileInfo("cache.xml"); var cacheXml = new CacheXml(template, gfs); Assert.NotNull(cacheXml.File); Assert.True(cacheXml.File.Exists); using (var input = cacheXml.File.OpenText()) { var content = input.ReadToEnd(); Assert.True(content.Contains(gfs.LocatorPort.ToString())); } } }
public void StartTwo() { var gfs1 = new GeodeServer(); Assert.NotNull(gfs1); Assert.NotEqual(0, gfs1.LocatorPort); var gfs2 = new GeodeServer(); Assert.NotNull(gfs2); Assert.NotEqual(0, gfs2.LocatorPort); Assert.NotEqual(gfs1.LocatorPort, gfs2.LocatorPort); gfs1.Dispose(); gfs2.Dispose(); }
public void DisposeAndCleanup() { using (var gfs = new GeodeServer()) { FileInfo file; var template = new FileInfo("cache.xml"); using (var cacheXml = new CacheXml(template, gfs)) { Assert.NotNull(cacheXml.File); file = cacheXml.File; Assert.True(file.Exists); } file.Refresh(); // File deletion via File.Delete (inside the file.Refresh() call) // is not synchronous so we need to potentially wait until the file // has been deleted here Assert.True(SpinWait.SpinUntil(() => !file.Exists, 10000)); } }