protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { BurrowFramework bf = new BurrowFramework(); IConversation conversation = bf.CurrentConversation; Checker.CheckSpanningConversations(0); if (conversation == null) { throw new Exception("The page doesn't have conversation"); } //if (BurrowFramework.ActiveConversations.Count != 1) // throw new Exception("There are more conversations that the expected"); object lastConversationId = Session["conversationId"]; if (lastConversationId == null) { throw new Exception("We haven't found the Id of previous conversation"); } if (conversation.Id.Equals(lastConversationId)) { throw new Exception("The conversation is same that previous, the new conversation was not created"); } } }
protected void Page_Load(object sender, EventArgs e) { BurrowFramework bf = new BurrowFramework(); IConversation conversation = bf.CurrentConversation; if (conversation == null) { throw new Exception("The page doesn't have conversation"); } if (Session["conversationId"] == null) { throw new Exception("We haven't found the Id's conversation in the ASP.NET session"); } object id = Session["conversationId"]; if (!conversation.Id.Equals(id)) { throw new Exception("The conversation in iframe isn't same that conversation in container page. Current.Id " + conversation.Id); } Checker.CheckSpanningConversations(1); lblConversationId.Text = conversation.Id.ToString(); }
private void CheckResults() { BurrowFramework bf = new BurrowFramework(); ISessionFactoryImplementor factory = (ISessionFactoryImplementor)bf.GetSessionFactory(MockPersistenceUnitCfg.MockPUName); Assert.IsNotNull(factory); Assert.AreEqual(TestConfigurator.TestAdoBatchSize, factory.Settings.AdoBatchSize); }
public void ModifyBurrowConfigruationTest() { BurrowFramework f = new BurrowFramework(); IBurrowConfig section = f.BurrowEnvironment.Configuration; Assert.IsNotNull(section); Assert.AreEqual(5, section.ConversationCleanupFrequency); Random r = new Random(3); int freq = r.Next(10, 100); try { section.ConversationCleanupFrequency = freq; Assert.Fail("Failed to throw ChangeConfigWhenRunningException"); } catch (ChangeConfigWhenRunningException) { } f.BurrowEnvironment.ShutDown(); section.ConversationCleanupFrequency = freq; Assert.AreEqual(freq, section.ConversationCleanupFrequency); freq = r.Next(10, 100); section.ConversationCleanupFrequency = freq; Assert.AreEqual(freq, section.ConversationCleanupFrequency); f.BurrowEnvironment.Start(); }
public void Setup() { BurrowFramework framework = new BurrowFramework(); framework.InitWorkSpace(); NHibernateSessionManager.Instance.BeginTransaction(null); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { BurrowFramework bf = new BurrowFramework(); IConversation conversation = bf.CurrentConversation; if (conversation == null) { throw new Exception("The page doesn't have conversation"); } object lastConversationId = Session["conversationId"]; if (lastConversationId == null) { throw new Exception("We haven't found the Id of previous conversation"); } if (!conversation.Id.Equals(lastConversationId)) { throw new Exception( "Failed to join the conversation in the same workspace, a new conversation was created"); } } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack || Session["continue"] != null && (bool)Session["continue"]) { BurrowFramework bf = new BurrowFramework(); IConversation conversation = bf.CurrentConversation; if (conversation == null) { throw new Exception("The page doesn't have conversation"); } Checker.CheckSpanningConversations(1); object lastConversationId = Session["conversationId"]; if (lastConversationId == null) { throw new Exception("We haven't found the Id of previous conversation"); } if (!conversation.Id.Equals(lastConversationId)) { throw new Exception("The conversation isn't same that previous, the new conversation was created"); } } if (StepCompleted("a") && StepCompleted("b")) { Session.Remove("continue"); btnNextStep.Visible = true; } else if (IsPostBack) { lblMessage.Text = "You should complete the step 6a, 6b, 6c a before continue"; } }
public static void Initialize(TestContext context) { _burrowsFramework = new BurrowFramework(); _burrowsFramework.InitWorkSpace(); _sessionFactory = _burrowsFramework.GetSessionFactory("PersistenceUnit1"); _session = _sessionFactory.OpenSession(); }
protected void btnStart_Click(object sender, EventArgs e) { MEInConversation = new MockEntity(); BurrowFramework f = new BurrowFramework(); f.CurrentConversation.SpanWithPostBacks(GetStrategy()); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { BurrowFramework bf = new BurrowFramework(); IConversation conversation = bf.CurrentConversation; Checker.CheckSpanningConversations(1); if (conversation == null) { throw new Exception("The page doesn't have conversation"); } object lastConversationId = Session["conversationId"]; if (lastConversationId == null) { throw new Exception("We haven't found the Id of previous conversation"); } if (!conversation.Id.Equals(lastConversationId)) { throw new Exception("The conversation isn't same that previous, the new conversation was created"); } conversation.FinishSpan(); } }
protected void Page_Load(object sender, EventArgs e) { BurrowFramework bf = new BurrowFramework(); IConversation conversation = bf.CurrentConversation; if (!IsPostBack) { if (conversation == null) { throw new Exception("The page doesn't have conversation"); } Checker.CheckSpanningConversations(0); conversation.SpanWithPostBacks(); Checker.CheckSpanningConversations(1); Session["continue"] = false; //if (BurrowFramework.ActiveConversations.Count != 1) // throw new Exception("There are more conversations that the expected"); } //else if (conversation.Items.ContainsKey("continue")) else if (Session["continue"] != null && (bool)Session["continue"]) { Session.Remove("continue"); btnNextStep.Visible = true; } else { lblMessage.Text = "You should complete the step 3 a before continue"; } }
private void HandleUpdateCancelled(object sender, EventArgs e) { BurrowFramework burrow = new BurrowFramework(); burrow.CurrentConversation.FinishSpan(); Response.Redirect("ListCustomers.aspx", false); }
protected void Page_Load(object sender, EventArgs e) { BurrowFramework bf = new BurrowFramework(); IConversation conversation = bf.CurrentConversation; if (conversation == null) { throw new Exception("The page doesn't have current conversation!"); } if (!IsPostBack) { Checker.CheckSpanningConversations(0); conversation.SpanWithPostBacks(); Checker.CheckSpanningConversations(1); //conversation.Items["step"] = 0; Session["conversationId"] = conversation.Id; Session["step"] = 0; btnNextStep.Text = "step 1"; } else { if (!conversation.Id.Equals(Session["conversationId"])) { throw new Exception("The current conversation isn't the correct"); } //if (conversation.Items["step"] == null) // throw new Exception("The current conversation has lost state"); lblMessage.Text = "We have successfully checked that the conversation is shared between postbacks"; } }
protected void btnNextStep_Click(object sender, EventArgs e) { BurrowFramework bf = new BurrowFramework(); IConversation conversation = bf.CurrentConversation; //int step = (int)conversation.Items["step"]; int step = (int)Session["step"]; step++; //conversation.Items["step"] = step; Session["step"] = step; if (step < 5) { btnNextStep.Text = "step 1 + " + step + "/5"; Checker.CheckSpanningConversations(1); } else { conversation.FinishSpan(); Checker.CheckSpanningConversations(0); Response.Redirect("Step02.aspx"); } }
public WebRegistry() { For <IUnitOfWork>().HttpContextScoped().Use <NHUnitOfWork>(); For <IPropertySettingsResolver>().Use <AppSettingsPropertySettingsResolver>(); For <ISystemSettings>().Use(delegate() { var propertySettingsResolver = ObjectFactory.Container.GetInstance <IPropertySettingsResolver>(); var settingsProvider = new SettingsProvider <SystemSettings>(propertySettingsResolver); return(settingsProvider.ResolveSettings()); }); For <IWebMembership>().Use <WebMembership>(); For <IDynamicControlsResolver>().Use <DynamicControlsResolver>(); For <ISession>().Use(s => { try { var burrowFramework = new BurrowFramework(); if (!burrowFramework.WorkSpaceIsReady) { burrowFramework.InitWorkSpace(); } var debugSession = burrowFramework.GetSession(); return(debugSession); } catch { //throw; } return(null); }); //For<ISessionFactoryProvider>().Use<WebSessionFactoryProvider>(); }
public void ConnectionStringTest() { new BurrowFramework().InitWorkSpace(); string cs = new BurrowFramework().BurrowEnvironment.Configuration.DBConnectionString(typeof(MockEntity)); Assert.IsTrue(cs.IndexOf("Server") >= 0); new BurrowFramework().CloseWorkSpace(); }
public void StartOneAfterAnotherTest() { BurrowFramework bf = new BurrowFramework(); bf.InitWorkSpace(); bf.CloseWorkSpace(); bf.InitWorkSpace(); bf.CloseWorkSpace(); }
protected void btnNextStep_Click(object sender, EventArgs e) { IConversation conversation = new BurrowFramework().CurrentConversation; conversation.SpanWithCookie("WorkSpaceStep06"); //Span the conversation in WorkSpace "WorkSpaceStep06" Session["conversationId"] = conversation.Id; Response.Redirect("Step06.aspx"); }
private void HandleUpdateCompleted(object sender, EventArgs e) { // PageMethods is perfect for managing strongly-typed redirects... // definitely use it with your web apps instead of the following. BurrowFramework burrow = new BurrowFramework(); burrow.CurrentConversation.FinishSpan(); Response.Redirect("ListCustomers.aspx?action=updated", false); }
public void DynamicConfigTest() { BurrowFramework bf = new BurrowFramework(); TestConfigurator c = new TestConfigurator(); bf.BurrowEnvironment.ReConfig(c); CheckResults(); bf.BurrowEnvironment.ReConfig(null); }
public void ConfiguratorSetFromConfigFileTest() { BurrowFramework bf = new BurrowFramework(); TestConfigurator c = (TestConfigurator) bf.BurrowEnvironment.Configuration.Configurator; Assert.IsNotNull(c, "configurator not set"); CheckResults(); }
/// <summary> /// Wraps a url with Conversation Information so that conversation can span with Request query /// </summary> /// <param name="originalUrl"></param> /// <returns></returns> /// <remarks> /// Please deter calling this method as late as possible. And only call it when you are spanning the conversation. /// If you wrap a url with conversation info and finish or cancel that conversation later in the same request handle, hitting the url will cause a conversationUnavailable error. /// </remarks> /// <exception cref="IncorrectConversationSpanStatusException" > /// thrown if called when the current conversation isn't spanning. /// </exception> public string WrapUrlWithConversationInfo(string originalUrl) { BurrowFramework bf = new BurrowFramework(); if (bf.CurrentConversation !=null && bf.CurrentConversation.IsSpanning) { return WorkSpace.Current.WrapUrlWithSpanInfo(originalUrl); } return originalUrl; }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { BurrowFramework burrow = new BurrowFramework(); burrow.CurrentConversation.SpanWithPostBacks(); } InitEditCustomerView(); }
public void ConfiguratorSetFromConfigFileTest() { BurrowFramework bf = new BurrowFramework(); TestConfigurator c = (TestConfigurator)bf.BurrowEnvironment.Configuration.Configurator; Assert.IsNotNull(c, "configurator not set"); CheckResults(); }
public void CheckCanChangeCfg() { BurrowFramework f = new BurrowFramework(); if (f.BurrowEnvironment != null && f.BurrowEnvironment.IsRunning) { throw new ChangeConfigWhenRunningException( "Configuration Setting can only be changed on the fly when the environment is shut down"); } }
/// <summary> /// Wraps a url with Conversation Information so that conversation can span with Request query /// </summary> /// <param name="originalUrl"></param> /// <returns></returns> /// <remarks> /// Please deter calling this method as late as possible. And only call it when you are spanning the conversation. /// If you wrap a url with conversation info and finish or cancel that conversation later in the same request handle, hitting the url will cause a conversationUnavailable error. /// </remarks> /// <exception cref="IncorrectConversationSpanStatusException" > /// thrown if called when the current conversation isn't spanning. /// </exception> public string WrapUrlWithConversationInfo(string originalUrl) { BurrowFramework bf = new BurrowFramework(); if (bf.CurrentConversation != null && bf.CurrentConversation.IsSpanning) { return(WorkSpace.Current.WrapUrlWithSpanInfo(originalUrl)); } return(originalUrl); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { Util.ResetEnvironment(); BurrowFramework bf = new BurrowFramework(); bf.CurrentConversation.SpanWithPostBacks(); Session["conversationId"] = bf.CurrentConversation.Id; } }
public void ReadNHConfigFileTest() { IBurrowConfig section = new BurrowFramework().BurrowEnvironment.Configuration; Assert.IsNotNull(section); Assert.IsTrue(section.PersistenceUnitCfgs.Count > 0); foreach (IPersistenceUnitCfg puSection in section.PersistenceUnitCfgs) { Assert.IsTrue(puSection.NHConfigFile.IndexOf(".xml") > 0); } }
protected void btnClose_Click(object sender, EventArgs e) { BurrowFramework bf = new BurrowFramework(); IConversation conversation = bf.CurrentConversation; Session["continue"] = true; conversation.FinishSpan(); Checker.CheckSpanningConversations(1); hdClose.Value = "1"; }
public static void ResetEnvironment() { SchemaUtil su = new SchemaUtil(); su.CreateSchemas(); BurrowFramework f = new BurrowFramework(); f.CloseWorkSpace(); f.BurrowEnvironment.ShutDown(); //Restart the environment to prepare a fresh start f.BurrowEnvironment.Start(); Checker.CheckSpanningConversations(0); f.InitWorkSpace(); }
public void ModifyNHConfigruationTest() { IFrameworkEnvironment fe = new BurrowFramework().BurrowEnvironment; NHibernate.Cfg.Configuration cfg = fe.GetNHConfig("PersistenceUnit1"); cfg.SetProperty("dialect", "NHibernate.Dialect.MsSql2000Dialect"); fe.RebuildSessionFactories(); Assert.AreEqual( new BurrowFramework().GetSessionFactory(typeof (MockEntity)).Dialect.GetType(), typeof (NHibernate.Dialect.MsSql2000Dialect)); cfg.SetProperty("dialect", "NHibernate.Dialect.MsSql2005Dialect"); fe.RebuildSessionFactories(); Assert.AreEqual( new BurrowFramework().GetSessionFactory(typeof (MockEntity)).Dialect.GetType(), typeof (NHibernate.Dialect.MsSql2005Dialect)); }
protected void btnNextStep_Click(object sender, EventArgs e) { BurrowFramework bf = new BurrowFramework(); IConversation conversation = bf.CurrentConversation; Checker.CheckSpanningConversations(1); Session["conversationId"] = conversation.Id; //using string.Empty as workspace name will span the conversation over all pages, NOT recommendded though conversation.SpanWithCookie(String.Empty); Checker.CheckSpanningConversations(1); Response.Redirect("Step05.aspx"); }
public void ModifyNHConfigruationTest() { IFrameworkEnvironment fe = new BurrowFramework().BurrowEnvironment; NHibernate.Cfg.Configuration cfg = fe.GetNHConfig("PersistenceUnit1"); cfg.SetProperty("dialect", "NHibernate.Dialect.MsSql2000Dialect"); fe.RebuildSessionFactories(); Assert.AreEqual(((ISessionFactoryImplementor) new BurrowFramework().GetSessionFactory(typeof(MockEntity))).Dialect.GetType(), typeof(NHibernate.Dialect.MsSql2000Dialect)); cfg.SetProperty("dialect", "NHibernate.Dialect.MsSql2005Dialect"); fe.RebuildSessionFactories(); Assert.AreEqual(((ISessionFactoryImplementor) new BurrowFramework().GetSessionFactory(typeof(MockEntity))).Dialect.GetType(), typeof(NHibernate.Dialect.MsSql2005Dialect)); }
public void TestFixtureSetup() { bf = new BurrowFramework(); bf.BurrowEnvironment.ShutDown(); PersistenceUnitElement item = new PersistenceUnitElement(); item.NHConfigFile = "~/MultiDB/SecondPU.Cfg.xml"; PersistenceUnitElement item2 = new PersistenceUnitElement(); item2.NHConfigFile = "~/MultiDB/FirstPU.Cfg.xml"; bf.BurrowEnvironment.Configuration.PersistenceUnitCfgs.Clear(); bf.BurrowEnvironment.Configuration.PersistenceUnitCfgs.Add(item); bf.BurrowEnvironment.Configuration.PersistenceUnitCfgs.Add(item2); bf.BurrowEnvironment.Start(); new SchemaUtil().CreateSchemas(false, true); }
public ConversationExpirationCheckerByTimeout() { IBurrowConfig cfg = new BurrowFramework().BurrowEnvironment.Configuration; int timeoutMinutes = cfg.ConversationTimeOut; if (timeoutMinutes < 1) { throw new ConfigurationErrorsException("ConversationTimeOut must be greater than 1"); } timeout = TimeSpan.FromMinutes(timeoutMinutes); int freq = cfg.ConversationCleanupFrequency; if (freq < 1) { throw new ConfigurationErrorsException("ConversationCleanupFrequency must be greater than 1"); } cleanUpTimeSpan = new TimeSpan(0, timeoutMinutes * freq, 0); }
public void ThreadProc() { try { new BurrowFramework().InitWorkSpace(); ISession session = new BurrowFramework().GetSession(); Assert.IsNotNull(session); int code = session.GetHashCode(); session.Flush(); Assert.IsTrue(sesss.Add(code)); Output("Thread # " + num + " succeeded."); threadPerformed++; } catch (Exception e) { Output("Thread #" + num + " occurs error:" + e.Message); error++; throw; } finally { new BurrowFramework().CloseWorkSpace(); } }
public void GetSessionFactoryTest() { BurrowFramework bf = new BurrowFramework(); Assert.IsNotNull(bf.GetSessionFactory(typeof (MockEntities.MockEntity))); }
/// <summary> /// create a workspace in which transaction is automatically managed and has the same life cycle as conversation /// </summary> /// <param name="states"></param> /// <param name="currentWorkSpaceName"></param> /// <returns></returns> public static WorkSpace Create(NameValueCollection states, string currentWorkSpaceName) { string cid = GetWorkSpaceState(states, ConversationIdKeyName, currentWorkSpaceName); if (!string.IsNullOrEmpty(cid)) { AbstractConversation c = ConversationPool.Instance[new Guid(cid)]; c.Reconnect(); return new WorkSpace(c); } else { AbstractConversation c = new BurrowFramework().BurrowEnvironment.Configuration.ManualTransactionManagement ? (AbstractConversation) new ConversationWithManualTransactionImpl() : new ConversationWithManagedTransactionImpl(); return new WorkSpace(c); } }