From: Manish A. <mag...@us...> - 2007-01-09 10:46:47
|
User: magrawal Date: 07/01/09 02:46:48 Added: andromda-nspring/src/test/expected/org/andromda/cartridges/nspring ITestEntity1Dao.cs ServiceOneException.cs ServiceOneTests.cs ServiceOneTestsImpl.cs ServiceTwoNoStubsException.cs ServiceTwoNoStubsTests.cs ServiceTwoNoStubsTestsImpl.cs TestEntity1DaoBase.cs TestEntity1DaoImpl.cs Log: added templates to generate simple test cases for each public method in the service layer. Revision Changes Path 1.1 cartridges/andromda-nspring/src/test/expected/org/andromda/cartridges/nspring/ITestEntity1Dao.cs Index: ITestEntity1Dao.cs =================================================================== // Name: ITestEntity1Dao.cs // license-header cs merge-point // // Attention: Generated code! Do not modify by hand! // Generated by: NSpringDaoInterface.vsl in andromda-nspring-cartridge. using System; namespace org.andromda.cartridges.nspring { /// <summary> /// This enumeration is used to define transformation flags. Using these flag /// entities can be converted automatically into value objects or other types. /// Different methods in a dao class support this feature: look for an /// <code>int</code> parameter called <code>transform</code>. /// </summary> public enum TransformTestEntity1 { // Denotes no transformation will occur. TRANSFORM_NONE = 0, } /// <summary> /// <see cref="org.andromda.cartridges.nspring.TestEntity1"/> /// </summary> public interface ITestEntity1Dao : AndroMDA.NHibernateSupport.INHibernateDaoSupport { /// <summary> /// Loads an instance of org.andromda.cartridges.nspring.TestEntity1 from the persistent store. /// </summary> org.andromda.cartridges.nspring.TestEntity1 Load(datatype::Long id); /// <summary> /// <p> /// Does the same thing as <seealso cref="ITestEntity1Dao.Load(datatype::Long)"/> with an /// additional flag called <code>transform</code>. If this flag is set to <code>TransformTestEntity1.TRANSFORM_NONE</code> then /// the returned entity will <strong>NOT</strong> be transformed. If this flag is any of the other constants /// defined in this class then the result <strong>WILL BE</strong> passed through an operation which can /// optionally transform the entity (into a value object for example). By default, transformation does /// not occur. /// </p> /// </summary> /// <param name="id">the identifier of the entity to load.</param> /// <returns>either the entity or the object transformed from the entity.</returns> Object Load(int transform, datatype::Long id); /// <summary> /// Loads all entities of type <seealso cref="org.andromda.cartridges.nspring.TestEntity1"/>. /// </summary> /// <returns>the loaded entities.</returns> System.Collections.IList LoadAll(); /// <summary> /// <p> /// Does the same thing as <seealso cref="ITestEntity1Dao.LoadAll()"/> with an /// additional flag called <code>transform</code>. If this flag is set to <code>TransformTestEntity1.TRANSFORM_NONE</code> then /// the returned entity will <strong>NOT</strong> be transformed. If this flag is any of the other constants /// defined here then the result <strong>WILL BE</strong> passed through an operation which can optionally /// transform the entity (into a value object for example). By default, transformation does /// not occur. /// </p> /// </summary> /// <param name="transform">the flag indicating what transformation to use.</param> /// <returns>the loaded entities.</returns> System.Collections.IList LoadAll(int transform); /// <summary> /// Creates an instance of org.andromda.cartridges.nspring.TestEntity1 and adds it to the persistent store. /// </summary> org.andromda.cartridges.nspring.TestEntity1 Create(org.andromda.cartridges.nspring.TestEntity1 testEntity1); /// <summary> /// <p> /// Does the same thing as <seealso cref="ITestEntity1Dao.Create(org.andromda.cartridges.nspring.TestEntity1)"/> with an /// additional flag called <code>transform</code>. If this flag is set to <code>TransformTestEntity1.TRANSFORM_NONE</code> then /// the returned entity will <strong>NOT</strong> be transformed. If this flag is any of the other constants /// defined here then the result <strong>WILL BE</strong> passed through an operation which can optionally /// transform the entity (into a value object for example). By default, transformation does /// not occur. /// </p> /// </summary> Object Create(int transform, org.andromda.cartridges.nspring.TestEntity1 testEntity1); /// <summary> /// Creates a new instance of org.andromda.cartridges.nspring.TestEntity1 and adds /// from the passed in <code>entities</code> collection /// </summary> /// <param name="entities">the collection of org.andromda.cartridges.nspring.TestEntity1 instances to create.</param> /// <returns>the created instances.</returns> System.Collections.ICollection Create(System.Collections.ICollection entities); /// <summary> /// <p> /// Does the same thing as <seealso cref="ITestEntity1Dao.Create(org.andromda.cartridges.nspring.TestEntity1)"/> with an /// additional flag called <code>transform</code>. If this flag is set to <code>TransformTestEntity1.TRANSFORM_NONE</code> then /// the returned entity will <strong>NOT</strong> be transformed. If this flag is any of the other constants /// defined here then the result <strong>WILL BE</strong> passed through an operation which can optionally /// transform the entities (into value objects for example). By default, transformation does /// not occur. /// </p> /// </summary> System.Collections.ICollection Create(int transform, System.Collections.ICollection entities); /// <summary> /// <p> /// Creates a new <code>org.andromda.cartridges.nspring.TestEntity1</code> /// instance from <strong>all</strong> attributes and adds it to /// the persistent store. /// </p> /// </summary> org.andromda.cartridges.nspring.TestEntity1 Create( datatype::String firstName); /// <summary> /// <p> /// Does the same thing as <seealso cref="ITestEntity1Dao.Create(datatype::String)"/> with an /// additional flag called <code>transform</code>. If this flag is set to <code>TransformTestEntity1.TRANSFORM_NONE</code> then /// the returned entity will <strong>NOT</strong> be transformed. If this flag is any of the other constants /// defined here then the result <strong>WILL BE</strong> passed through an operation which can optionally /// transform the entity (into a value object for example). By default, transformation does /// not occur. /// </p> /// </summary> Object Create( int transform, datatype::String firstName); /// <summary> /// Updates the <code>testEntity1</code> instance in the persistent store. /// </summary> void Update(org.andromda.cartridges.nspring.TestEntity1 testEntity1); /// <summary> /// Updates all instances in the <code>entities</code> collection in the persistent store. /// </summary> void Update(System.Collections.ICollection entities); /// <summary> /// Removes the instance of org.andromda.cartridges.nspring.TestEntity1 from the persistent store. /// </summary> void Remove(org.andromda.cartridges.nspring.TestEntity1 testEntity1); /// <summary> /// Removes the instance of org.andromda.cartridges.nspring.TestEntity1 having the given /// <code>identifier</code> from the persistent store. /// </summary> void Remove(datatype::Long id); /// <summary> /// Removes all entities in the given <code>entities<code> collection. /// </summary> void Remove(System.Collections.ICollection entities); // NSpringDaoInterface.vsl merge-point } } 1.1 cartridges/andromda-nspring/src/test/expected/org/andromda/cartridges/nspring/ServiceOneException.cs Index: ServiceOneException.cs =================================================================== // Name: ServiceOneException.cs // license-header cs merge-point // // Attention: Generated code! Do not modify by hand! // Generated by: NSpringServiceException.vsl using System; using System.Xml; using System.Runtime.Serialization; /* using System.Web; using System.Web.Services.Protocols; */ namespace org.andromda.cartridges.nspring { public class ServiceOneException : System.ApplicationException { /// <summary> /// Initializes a new instance of ServiceOneException with a specified error message. /// </summary> /// <param name="message">A message that describes the error.</param> internal ServiceOneException(Exception e) : base(e.Message, e) { } /// <summary> /// Create a new instance of the ServiceOneException. /// </summary> /// <param name="exception">Actual exception that contains the error information.</param> public static ServiceOneException Create(Exception e) { if (e is ServiceOneException) { return (ServiceOneException)e; } else { return new ServiceOneException(e); } } // NSpringServiceException.vsl merge-point } /* [Serializable] public class ServiceOneException : System.ApplicationException, ISerializable { private XmlNode detail = null; private const string ErrorMessage = "A call to TimeTrackingService failed. Please check the inner exception for more detail."; private static XmlDocument doc = new XmlDocument(); private bool isKnownException = false; /// <summary> /// Contains the details about the exception. Contains the InnerException if any /// Format of the InnerException is <exception type="FullNameOfTheException"><message></message></exception> /// </summary> public XmlNode Detail { get { return this.detail; } set { this.detail = value; } } /// <summary> /// Says whether this exception is a known business exception /// </summary> public bool KnownException { get { return this.isKnownException; } set { this.isKnownException = value; } } /// <summary> /// Initializes a new instance of ServiceOneException with a specified error message. /// </summary> /// <param name="message">A message that describes the error.</param> internal ServiceOneException(String message) : base(message) { this.isKnownException = true; } /// <summary> /// Initializes a new instance of ServiceOneException at the time of deserialization. /// Do not call the base class constructor as that initializes few properties that are not getting serialized /// </summary> /// <param name="info">Contains the state information of the serialized object.</param> /// <param name="context">Contains the context information.</param> public ServiceOneException(SerializationInfo info, StreamingContext context) // : base(info, context) { this.detail = info.GetValue("Detail", typeof(XmlNode) ) as XmlNode; this.isKnownException = info.GetBoolean("KnownException"); } /// <summary> /// Initializes a new instance of ServiceOneException that wraps the actual exception. /// </summary> /// <param name="message">A message that describes the error.</param> /// <param name="innerException">The exception that is the cause of the current exception.</param> internal ServiceOneException(String message, Exception innerException) : base(message) { this.detail = ToXmlNode( message, innerException ); } #region ISerializable Members void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context) { /// Do not call the base class method as that initializes few properties that are not getting serialized //base.GetObjectData(info, context); info.AddValue("Detail", this.detail); info.AddValue("KnownException", isKnownException ); } #endregion /// <summary> /// Create a new instance of the ServiceOneException. /// </summary> /// <param name="message">A message that describes the error.</param> public static ServiceOneException Create(string message) { return new ServiceOneException(message); } /// <summary> /// Create a new instance of the ServiceOneException. /// </summary> /// <param name="exception">Actual exception that contains the error information.</param> public static ServiceOneException Create(Exception e) { if (e is ServiceOneException) { return (ServiceOneException)e; } else if (e is SoapException) { return UnwrapSoapException((SoapException)e); } else { return new ServiceOneException(ErrorMessage, e); } } /// <summary> /// This method wraps the a exception as a ServiceOneException and then as a SoapException. /// </summary> /// <param name="e">Actual exception that contains the error information.</param> public static SoapException WrapSoapException(Exception e) { //Make sure the exception that is wrapped is a ServiceOneException ServiceOneException ttse = Create(e); string actor = (HttpContext.Current != null) ? HttpContext.Current.Request.Url.AbsoluteUri : string.Empty; return new SoapException("Fault occurred", SoapException.ClientFaultCode, actor, ToXmlNode(e.Message, ttse)); } /// <summary> /// This method unwraps the ServiceOneException from the SoapException. /// </summary> /// <param name="se">Actual exception that contains the error information.</param> private static ServiceOneException UnwrapSoapException(SoapException se) { ServiceOneException ttse = null; XmlNode detailNode = se.Detail; if (detailNode != null) { string message = detailNode.SelectSingleNode("message").InnerText; ttse = new ServiceOneException(message); XmlNode exceptionNode = detailNode.SelectSingleNode("exception"); if (exceptionNode != null) ttse.Detail = exceptionNode; } return ttse; } /// <summary> /// Helper method to create a xml node that contains the information about the parameters passed. /// </summary> /// <param name="message">A message that describes the error.</param> /// <param name="exception">Actual exception that contains the error information.</param> private static XmlNode ToXmlNode(string message, Exception e) { // Build the detail element of the SOAP fault. System.Xml.XmlNode detailNode = doc.CreateNode(XmlNodeType.Element, SoapException.DetailElementName.Name, SoapException.DetailElementName.Namespace); // Build specific details for the SoapException. XmlNode messageNode = ToXmlNode( "message", e.Message); detailNode.AppendChild(messageNode); bool IsKnownException = false; ServiceOneException ttse = e as ServiceOneException; if (ttse != null) { IsKnownException = ttse.KnownException; } XmlNode knownExceptionNode = ToXmlNode("KnownException", IsKnownException.ToString() ); detailNode.AppendChild(knownExceptionNode); if (e != null) { detailNode.AppendChild(ToXmlNode(e)); } return detailNode; } /// <summary> /// Helper method to create a xml node that contains the information about the parameters passed. /// </summary> /// <param name="exception">Actual exception that contains the error information.</param> private static XmlNode ToXmlNode(Exception e) { System.Xml.XmlNode exception = null; if (e != null) { // Create exception node. exception = doc.CreateNode(XmlNodeType.Element, "exception", null); XmlAttribute typeAttribute = doc.CreateAttribute("t", "type", null); typeAttribute.Value = e.GetType().FullName; exception.Attributes.Append(typeAttribute); exception.AppendChild(ToXmlNode("message", e.Message)); if (e.InnerException != null) { exception.AppendChild(ToXmlNode(e.InnerException)); } } return exception; } /// <summary> /// Helper method to create a xml node that contains the information about the parameters passed. /// </summary> /// <param name="nodeName">A name of the node to be created.</param> /// <param name="text">Text that is the value of the node.</param> private static XmlNode ToXmlNode(string nodeName, string text) { System.Xml.XmlNode messageNode = doc.CreateNode(XmlNodeType.Element, nodeName, null); XmlNode messageTextNode = doc.CreateNode(XmlNodeType.Text, "Text", null); messageTextNode.Value = text; messageNode.AppendChild(messageTextNode); return messageNode; } } */ } 1.1 cartridges/andromda-nspring/src/test/expected/org/andromda/cartridges/nspring/ServiceOneTests.cs Index: ServiceOneTests.cs =================================================================== // Name: ServiceOneTests.cs // license-header cs merge-point // // Attention: Generated code! Do not modify by hand! // Generated by: NSpringServiceTestBase.vsl in andromda-nspring-cartridge. using System; using AndroMDA.NHibernateSupport; using NUnit.Framework; namespace org.andromda.cartridges.nspring.Tests { /// <summary> /// <p> /// Spring Service test base class for <code>org::andromda::cartridges::nspring::ServiceOne</code>, /// </p> /// /// @see $service.fullyQualifiedNameTests /// </summary> public abstract class ServiceOneTests { #region private properties private static readonly log4net.ILog log = log4net.LogManager.GetLogger(typeof(ServiceOneTests)); private org.andromda.cartridges.nspring.IServiceOne _ServiceOne; /// <summary>Property to access ServiceOne</summary> protected org.andromda.cartridges.nspring.IServiceOne ServiceOne { get { if (null == _ServiceOne) { _ServiceOne = new org.andromda.cartridges.nspring.ServiceOneImpl(); } return _ServiceOne; } } #endregion #region setup and teardown [TestFixtureSetUp] public void TestFixtureSetUp() { // Initialize Log4Net log4net.Config.XmlConfigurator.Configure(); // Initialize NHibernate SessionManagerFactory.SessionManager = new DefaultSessionManager(); SessionManagerFactory.SessionManager.HandleApplicationStart(); HandleTestFixtureSetup(); } protected abstract void HandleTestFixtureSetup(); [TestFixtureTearDown] public void TestFixtureTearDown() { HandleTestFixtureTearDown(); SessionManagerFactory.SessionManager.HandleApplicationEnd(); } protected abstract void HandleTestFixtureTearDown(); [SetUp] public void Setup() { HandleSetup(); } protected abstract void HandleSetup(); [TearDown] public void TearDown() { HandleTearDown(); } protected abstract void HandleTearDown(); #endregion /// <summary> /// @see org::andromda::cartridges::nspring::ServiceOneTests#TestdoSomething /// </summary> [Test] public void TestdoSomething() { HandleTestdoSomething(); } /// <summary> /// Performs the core logic for {@link #TestdoSomething()} /// <summary> protected abstract void HandleTestdoSomething(); /// <summary> /// @see org::andromda::cartridges::nspring::ServiceOneTests#TestdoSomethingElse /// </summary> [Test] public void TestdoSomethingElse() { HandleTestdoSomethingElse(); } /// <summary> /// Performs the core logic for {@link #TestdoSomethingElse()} /// <summary> protected abstract void HandleTestdoSomethingElse(); } } 1.1 cartridges/andromda-nspring/src/test/expected/org/andromda/cartridges/nspring/ServiceOneTestsImpl.cs Index: ServiceOneTestsImpl.cs =================================================================== // Name: ServiceOneTestsImpl.cs // license-header cs merge-point // // This is only generated once! It will never be overwritten. // You can (and have to!) safely modify it by hand. using System; using AndroMDA.NHibernateSupport; using NUnit.Framework; namespace org.andromda.cartridges.nspring.Tests { /// <summary> /// @see org::andromda::cartridges::nspring::ServiceOneTestsImpl /// </summary> [TestFixture] public class ServiceOneTestsImpl : ServiceOneTests { #region private member variables private static readonly log4net.ILog log = log4net.LogManager.GetLogger(typeof(ServiceOneTestsImpl)); #endregion #region setup and teardown protected override void HandleTestFixtureSetup() { //TODO: put any fixture level setup code here. } protected override void HandleTestFixtureTearDown() { //TODO: put any fixture level tear down code here. } protected override void HandleSetup() { //TODO: put any testcase setup code here. } protected override void HandleTearDown() { //TODO: put any testcase teardown code here. } #endregion /// <summary> /// @see org::andromda::cartridges::nspring::ServiceOneTests#HandleTestdoSomething /// </summary> protected override void HandleTestdoSomething() { // put your implementation here throw new Exception("org.andromda.cartridges.nspring.Tests.ServiceOneTestsImpl.HandleTestdoSomething is not implemented."); } /// <summary> /// @see org::andromda::cartridges::nspring::ServiceOneTests#HandleTestdoSomethingElse /// </summary> protected override void HandleTestdoSomethingElse() { // put your implementation here throw new Exception("org.andromda.cartridges.nspring.Tests.ServiceOneTestsImpl.HandleTestdoSomethingElse is not implemented."); } } } 1.1 cartridges/andromda-nspring/src/test/expected/org/andromda/cartridges/nspring/ServiceTwoNoStubsException.cs Index: ServiceTwoNoStubsException.cs =================================================================== // Name: ServiceTwoNoStubsException.cs // license-header cs merge-point // // Attention: Generated code! Do not modify by hand! // Generated by: NSpringServiceException.vsl using System; using System.Xml; using System.Runtime.Serialization; /* using System.Web; using System.Web.Services.Protocols; */ namespace org.andromda.cartridges.nspring { public class ServiceTwoNoStubsException : System.ApplicationException { /// <summary> /// Initializes a new instance of ServiceTwoNoStubsException with a specified error message. /// </summary> /// <param name="message">A message that describes the error.</param> internal ServiceTwoNoStubsException(Exception e) : base(e.Message, e) { } /// <summary> /// Create a new instance of the ServiceTwoNoStubsException. /// </summary> /// <param name="exception">Actual exception that contains the error information.</param> public static ServiceTwoNoStubsException Create(Exception e) { if (e is ServiceTwoNoStubsException) { return (ServiceTwoNoStubsException)e; } else { return new ServiceTwoNoStubsException(e); } } // NSpringServiceException.vsl merge-point } /* [Serializable] public class ServiceTwoNoStubsException : System.ApplicationException, ISerializable { private XmlNode detail = null; private const string ErrorMessage = "A call to TimeTrackingService failed. Please check the inner exception for more detail."; private static XmlDocument doc = new XmlDocument(); private bool isKnownException = false; /// <summary> /// Contains the details about the exception. Contains the InnerException if any /// Format of the InnerException is <exception type="FullNameOfTheException"><message></message></exception> /// </summary> public XmlNode Detail { get { return this.detail; } set { this.detail = value; } } /// <summary> /// Says whether this exception is a known business exception /// </summary> public bool KnownException { get { return this.isKnownException; } set { this.isKnownException = value; } } /// <summary> /// Initializes a new instance of ServiceTwoNoStubsException with a specified error message. /// </summary> /// <param name="message">A message that describes the error.</param> internal ServiceTwoNoStubsException(String message) : base(message) { this.isKnownException = true; } /// <summary> /// Initializes a new instance of ServiceTwoNoStubsException at the time of deserialization. /// Do not call the base class constructor as that initializes few properties that are not getting serialized /// </summary> /// <param name="info">Contains the state information of the serialized object.</param> /// <param name="context">Contains the context information.</param> public ServiceTwoNoStubsException(SerializationInfo info, StreamingContext context) // : base(info, context) { this.detail = info.GetValue("Detail", typeof(XmlNode) ) as XmlNode; this.isKnownException = info.GetBoolean("KnownException"); } /// <summary> /// Initializes a new instance of ServiceTwoNoStubsException that wraps the actual exception. /// </summary> /// <param name="message">A message that describes the error.</param> /// <param name="innerException">The exception that is the cause of the current exception.</param> internal ServiceTwoNoStubsException(String message, Exception innerException) : base(message) { this.detail = ToXmlNode( message, innerException ); } #region ISerializable Members void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context) { /// Do not call the base class method as that initializes few properties that are not getting serialized //base.GetObjectData(info, context); info.AddValue("Detail", this.detail); info.AddValue("KnownException", isKnownException ); } #endregion /// <summary> /// Create a new instance of the ServiceTwoNoStubsException. /// </summary> /// <param name="message">A message that describes the error.</param> public static ServiceTwoNoStubsException Create(string message) { return new ServiceTwoNoStubsException(message); } /// <summary> /// Create a new instance of the ServiceTwoNoStubsException. /// </summary> /// <param name="exception">Actual exception that contains the error information.</param> public static ServiceTwoNoStubsException Create(Exception e) { if (e is ServiceTwoNoStubsException) { return (ServiceTwoNoStubsException)e; } else if (e is SoapException) { return UnwrapSoapException((SoapException)e); } else { return new ServiceTwoNoStubsException(ErrorMessage, e); } } /// <summary> /// This method wraps the a exception as a ServiceTwoNoStubsException and then as a SoapException. /// </summary> /// <param name="e">Actual exception that contains the error information.</param> public static SoapException WrapSoapException(Exception e) { //Make sure the exception that is wrapped is a ServiceTwoNoStubsException ServiceTwoNoStubsException ttse = Create(e); string actor = (HttpContext.Current != null) ? HttpContext.Current.Request.Url.AbsoluteUri : string.Empty; return new SoapException("Fault occurred", SoapException.ClientFaultCode, actor, ToXmlNode(e.Message, ttse)); } /// <summary> /// This method unwraps the ServiceTwoNoStubsException from the SoapException. /// </summary> /// <param name="se">Actual exception that contains the error information.</param> private static ServiceTwoNoStubsException UnwrapSoapException(SoapException se) { ServiceTwoNoStubsException ttse = null; XmlNode detailNode = se.Detail; if (detailNode != null) { string message = detailNode.SelectSingleNode("message").InnerText; ttse = new ServiceTwoNoStubsException(message); XmlNode exceptionNode = detailNode.SelectSingleNode("exception"); if (exceptionNode != null) ttse.Detail = exceptionNode; } return ttse; } /// <summary> /// Helper method to create a xml node that contains the information about the parameters passed. /// </summary> /// <param name="message">A message that describes the error.</param> /// <param name="exception">Actual exception that contains the error information.</param> private static XmlNode ToXmlNode(string message, Exception e) { // Build the detail element of the SOAP fault. System.Xml.XmlNode detailNode = doc.CreateNode(XmlNodeType.Element, SoapException.DetailElementName.Name, SoapException.DetailElementName.Namespace); // Build specific details for the SoapException. XmlNode messageNode = ToXmlNode( "message", e.Message); detailNode.AppendChild(messageNode); bool IsKnownException = false; ServiceTwoNoStubsException ttse = e as ServiceTwoNoStubsException; if (ttse != null) { IsKnownException = ttse.KnownException; } XmlNode knownExceptionNode = ToXmlNode("KnownException", IsKnownException.ToString() ); detailNode.AppendChild(knownExceptionNode); if (e != null) { detailNode.AppendChild(ToXmlNode(e)); } return detailNode; } /// <summary> /// Helper method to create a xml node that contains the information about the parameters passed. /// </summary> /// <param name="exception">Actual exception that contains the error information.</param> private static XmlNode ToXmlNode(Exception e) { System.Xml.XmlNode exception = null; if (e != null) { // Create exception node. exception = doc.CreateNode(XmlNodeType.Element, "exception", null); XmlAttribute typeAttribute = doc.CreateAttribute("t", "type", null); typeAttribute.Value = e.GetType().FullName; exception.Attributes.Append(typeAttribute); exception.AppendChild(ToXmlNode("message", e.Message)); if (e.InnerException != null) { exception.AppendChild(ToXmlNode(e.InnerException)); } } return exception; } /// <summary> /// Helper method to create a xml node that contains the information about the parameters passed. /// </summary> /// <param name="nodeName">A name of the node to be created.</param> /// <param name="text">Text that is the value of the node.</param> private static XmlNode ToXmlNode(string nodeName, string text) { System.Xml.XmlNode messageNode = doc.CreateNode(XmlNodeType.Element, nodeName, null); XmlNode messageTextNode = doc.CreateNode(XmlNodeType.Text, "Text", null); messageTextNode.Value = text; messageNode.AppendChild(messageTextNode); return messageNode; } } */ } 1.1 cartridges/andromda-nspring/src/test/expected/org/andromda/cartridges/nspring/ServiceTwoNoStubsTests.cs Index: ServiceTwoNoStubsTests.cs =================================================================== // Name: ServiceTwoNoStubsTests.cs // license-header cs merge-point // // Attention: Generated code! Do not modify by hand! // Generated by: NSpringServiceTestBase.vsl in andromda-nspring-cartridge. using System; using AndroMDA.NHibernateSupport; using NUnit.Framework; namespace org.andromda.cartridges.nspring.Tests { /// <summary> /// <p> /// Spring Service test base class for <code>org::andromda::cartridges::nspring::ServiceTwoNoStubs</code>, /// </p> /// /// @see $service.fullyQualifiedNameTests /// </summary> public abstract class ServiceTwoNoStubsTests { #region private properties private static readonly log4net.ILog log = log4net.LogManager.GetLogger(typeof(ServiceTwoNoStubsTests)); private org.andromda.cartridges.nspring.IServiceTwoNoStubs _ServiceTwoNoStubs; /// <summary>Property to access ServiceTwoNoStubs</summary> protected org.andromda.cartridges.nspring.IServiceTwoNoStubs ServiceTwoNoStubs { get { if (null == _ServiceTwoNoStubs) { _ServiceTwoNoStubs = new org.andromda.cartridges.nspring.ServiceTwoNoStubsImpl(); } return _ServiceTwoNoStubs; } } #endregion #region setup and teardown [TestFixtureSetUp] public void TestFixtureSetUp() { // Initialize Log4Net log4net.Config.XmlConfigurator.Configure(); // Initialize NHibernate SessionManagerFactory.SessionManager = new DefaultSessionManager(); SessionManagerFactory.SessionManager.HandleApplicationStart(); HandleTestFixtureSetup(); } protected abstract void HandleTestFixtureSetup(); [TestFixtureTearDown] public void TestFixtureTearDown() { HandleTestFixtureTearDown(); SessionManagerFactory.SessionManager.HandleApplicationEnd(); } protected abstract void HandleTestFixtureTearDown(); [SetUp] public void Setup() { HandleSetup(); } protected abstract void HandleSetup(); [TearDown] public void TearDown() { HandleTearDown(); } protected abstract void HandleTearDown(); #endregion /// <summary> /// @see org::andromda::cartridges::nspring::ServiceTwoNoStubsTests#TestdoSomething /// </summary> [Test] public void TestdoSomething() { HandleTestdoSomething(); } /// <summary> /// Performs the core logic for {@link #TestdoSomething()} /// <summary> protected abstract void HandleTestdoSomething(); /// <summary> /// @see org::andromda::cartridges::nspring::ServiceTwoNoStubsTests#TestdoSomethingElse /// </summary> [Test] public void TestdoSomethingElse() { HandleTestdoSomethingElse(); } /// <summary> /// Performs the core logic for {@link #TestdoSomethingElse()} /// <summary> protected abstract void HandleTestdoSomethingElse(); } } 1.1 cartridges/andromda-nspring/src/test/expected/org/andromda/cartridges/nspring/ServiceTwoNoStubsTestsImpl.cs Index: ServiceTwoNoStubsTestsImpl.cs =================================================================== // Name: ServiceTwoNoStubsTestsImpl.cs // license-header cs merge-point // // This is only generated once! It will never be overwritten. // You can (and have to!) safely modify it by hand. using System; using AndroMDA.NHibernateSupport; using NUnit.Framework; namespace org.andromda.cartridges.nspring.Tests { /// <summary> /// @see org::andromda::cartridges::nspring::ServiceTwoNoStubsTestsImpl /// </summary> [TestFixture] public class ServiceTwoNoStubsTestsImpl : ServiceTwoNoStubsTests { #region private member variables private static readonly log4net.ILog log = log4net.LogManager.GetLogger(typeof(ServiceTwoNoStubsTestsImpl)); #endregion #region setup and teardown protected override void HandleTestFixtureSetup() { //TODO: put any fixture level setup code here. } protected override void HandleTestFixtureTearDown() { //TODO: put any fixture level tear down code here. } protected override void HandleSetup() { //TODO: put any testcase setup code here. } protected override void HandleTearDown() { //TODO: put any testcase teardown code here. } #endregion /// <summary> /// @see org::andromda::cartridges::nspring::ServiceTwoNoStubsTests#HandleTestdoSomething /// </summary> protected override void HandleTestdoSomething() { // put your implementation here throw new Exception("org.andromda.cartridges.nspring.Tests.ServiceTwoNoStubsTestsImpl.HandleTestdoSomething is not implemented."); } /// <summary> /// @see org::andromda::cartridges::nspring::ServiceTwoNoStubsTests#HandleTestdoSomethingElse /// </summary> protected override void HandleTestdoSomethingElse() { // put your implementation here throw new Exception("org.andromda.cartridges.nspring.Tests.ServiceTwoNoStubsTestsImpl.HandleTestdoSomethingElse is not implemented."); } } } 1.1 cartridges/andromda-nspring/src/test/expected/org/andromda/cartridges/nspring/TestEntity1DaoBase.cs Index: TestEntity1DaoBase.cs =================================================================== // Name: TestEntity1DaoBase.cs // license-header cs merge-point // // Attention: Generated code! Do not modify by hand! // Generated by: NSpringHibernateDaoBase.vsl in andromda-nspring-cartridge. using System; using NHibernate; using AndroMDA.NHibernateSupport; namespace org.andromda.cartridges.nspring { /// <summary> /// <p> /// Base Spring DAO Class: is able to create, update, remove, load, and find /// objects of type <code>org.andromda.cartridges.nspring.TestEntity1</code>. /// </p> /// /// <see cref="org.andromda.cartridges.nspring.TestEntity1"/> /// </summary> public abstract class TestEntity1DaoBase : NHibernateDaoSupport, org.andromda.cartridges.nspring.ITestEntity1Dao { /// <summary> /// <see cref="org.andromda.cartridges.nspring.ITestEntity1Dao.Load(int, datatype::Long)"/> /// </summary> public virtual Object Load(int transform, datatype::Long id) { if (id == null) { throw new ArgumentNullException( "TestEntity1.Load - 'id' can not be null"); } Object entity = Session.Load(typeof(org.andromda.cartridges.nspring.TestEntity1Impl), id); return TransformEntity(transform, (org::andromda::cartridges::nspring::TestEntity1)entity); } /// <summary> /// <see cref="org.andromda.cartridges.nspring.ITestEntity1Dao.Load(datatype::Long)"/> /// </summary> public virtual org.andromda.cartridges.nspring.TestEntity1 Load(datatype::Long id) { return (org.andromda.cartridges.nspring.TestEntity1)this.Load((int)TransformTestEntity1.TRANSFORM_NONE, id); } /// <summary> /// <see cref="org.andromda.cartridges.nspring.ITestEntity1Dao.LoadAll()"/> /// </summary> public virtual System.Collections.IList LoadAll() { return this.LoadAll((int)TransformTestEntity1.TRANSFORM_NONE); } /// <summary> /// <see cref="org.andromda.cartridges.nspring.ITestEntity1Dao.LoadAll(int)" /> /// </summary> public virtual System.Collections.IList LoadAll(int transform) { System.Collections.IList entities = Session.Find("from org.andromda.cartridges.nspring.TestEntity1Impl"); System.Collections.IList results = this.TransformEntities(transform, entities); return results; } /// <summary> /// <see cref="org.andromda.cartridges.nspring.ITestEntity1Dao.Create(org.andromda.cartridges.nspring.TestEntity1)"/> /// </summary> public virtual org.andromda.cartridges.nspring.TestEntity1 Create(org.andromda.cartridges.nspring.TestEntity1 testEntity1) { return (org.andromda.cartridges.nspring.TestEntity1)this.Create((int)TransformTestEntity1.TRANSFORM_NONE, testEntity1); } /// <summary> /// <see cref="org.andromda.cartridges.nspring.ITestEntity1Dao.Create(int transform, org.andromda.cartridges.nspring.TestEntity1)"/> /// </summary> public virtual Object Create(int transform, org::andromda::cartridges::nspring::TestEntity1 testEntity1) { if (testEntity1 == null) { throw new ArgumentNullException( "TestEntity1.Create - 'testEntity1' can not be null"); } Session.Save(testEntity1); return this.TransformEntity(transform, testEntity1); } /// <summary> /// <see cref="org.andromda.cartridges.nspring.ITestEntity1Dao.Create(System.Collections.ICollection)"/> /// </summary> public virtual System.Collections.ICollection Create(System.Collections.ICollection entities) { return Create((int)TransformTestEntity1.TRANSFORM_NONE, entities); } /// <summary> /// <see cref="org.andromda.cartridges.nspring.ITestEntity1Dao.Create(int, System.Collections.ICollection)"/> /// </summary> public virtual System.Collections.ICollection Create(int transform, System.Collections.ICollection entities) { if (entities == null) { throw new ArgumentNullException( "TestEntity1.Create - 'entities' can not be null"); } System.Collections.ArrayList result = new System.Collections.ArrayList(); foreach (Object entity in entities) { result.Add(Create(transform, (org.andromda.cartridges.nspring.TestEntity1)entity)); } return result; } /// <summary> /// <see cref="org.andromda.cartridges.nspring.ITestEntity1Dao.Create(datatype::String)"/> /// </summary> public virtual org.andromda.cartridges.nspring.TestEntity1 Create( datatype::String firstName) { return (org.andromda.cartridges.nspring.TestEntity1)this.Create((int)TransformTestEntity1.TRANSFORM_NONE, firstName); } /// <summary> /// <see cref="org.andromda.cartridges.nspring.ITestEntity1Dao.Create(int, datatype::String)"/> /// </summary> public virtual Object Create( int transform, datatype::String firstName) { org.andromda.cartridges.nspring.TestEntity1 entity = new org.andromda.cartridges.nspring.TestEntity1Impl(); entity.FirstName = firstName; return this.Create(transform, entity); } /// <summary> /// <see cref="org.andromda.cartridges.nspring.ITestEntity1Dao.Update(org.andromda.cartridges.nspring.TestEntity1)"/> /// </summary> public virtual void Update(org.andromda.cartridges.nspring.TestEntity1 testEntity1) { if (testEntity1 == null) { throw new ArgumentNullException( "TestEntity1.Update - 'testEntity1' can not be null"); } Session.Update(testEntity1); } /// <summary> /// <see cref="org.andromda.cartridges.nspring.ITestEntity1Dao.Update(System.Collections.ICollection)"/> /// </summary> public virtual void Update(System.Collections.ICollection entities) { if (entities == null) { throw new ArgumentNullException( "TestEntity1.Update - 'entities' can not be null"); } foreach (Object entity in entities) { Session.Update((org.andromda.cartridges.nspring.TestEntity1)entity); } } /// <summary> /// <see cref="org.andromda.cartridges.nspring.ITestEntity1Dao.Remove(org.andromda.cartridges.nspring.TestEntity1)"/> /// </summary> public virtual void Remove(org.andromda.cartridges.nspring.TestEntity1 testEntity1) { if (testEntity1 == null) { throw new ArgumentNullException( "TestEntity1.Remove - 'testEntity1' can not be null"); } Session.Delete(testEntity1); } /// <summary> /// <see cref="org.andromda.cartridges.nspring.ITestEntity1Dao.Remove(datatype::Long)"/> /// </summary> public virtual void Remove(datatype::Long id) { if (id == null) { throw new ArgumentNullException( "TestEntity1.Remove - 'id' can not be null"); } org.andromda.cartridges.nspring.TestEntity1 entity = this.Load(id); if (entity != null) { this.Remove(entity); } } /// <summary> /// <see cref="org.andromda.cartridges.nspring.ITestEntity1Dao.Remove(System.Collections.ICollection)"/> /// </summary> public virtual void Remove(System.Collections.ICollection entities) { if (entities == null) { throw new ArgumentNullException( "TestEntity1.Remove - 'entities' can not be null"); } foreach (TestEntity1 entity in entities) this.Remove(entity); } /// <summary> /// Allows transformation of entities into value objects /// (or something else for that matter), when the <code>transform</code> /// flag is set to one of the constants defined in <code>org.andromda.cartridges.nspring.ITestEntity1Dao</code>, please note /// that the <seealso cref="#TransformTestEntity1.TRANSFORM_NONE"/> constant denotes no transformation, so the entity itself /// will be returned. /// /// If the integer argument value is unknown <seealso cref="TRANSFORM_NONE"/> is assumed. /// </summary> /// <param name="transform">one of the constants declared in <seealso cref="org.andromda.cartridges.nspring.ITestEntity1Dao"/></param> /// <param name="entity">an entity that was found</param> /// <returns>the transformed entity (i.e. new value object, etc) <see cref="#TransformEntities(int,System.Collections.ICollection)"/></returns> protected Object TransformEntity(int transform, org::andromda::cartridges::nspring::TestEntity1 entity) { Object target = null; if (entity != null) { switch (transform) { case (int)TransformTestEntity1.TRANSFORM_NONE : // fall-through default: target = entity; break; } } return target; } /// <summary> /// Transforms a collection of entities using the /// <seealso cref="#TransformEntity(int,org::andromda::cartridges::nspring::TestEntity1)"/> method. /// <p/> /// This method is to be used internally only. /// </summary> /// <param name="transform">one of the constants declared in <code>org.andromda.cartridges.nspring.ITestEntity1Dao</code></param> /// <param name="entities">the collection of entities to transform</param> /// <returns>a new list containing the transformed entities <see cref="#TransformEntity(int,org::andromda::cartridges::nspring::TestEntity1)"/></returns> protected virtual System.Collections.IList TransformEntities(int transform, System.Collections.ICollection entities) { System.Collections.IList entityList = null; switch (transform) { case (int)TransformTestEntity1.TRANSFORM_NONE : // fall-through default: // Convert collection to list if necesary entityList = entities as System.Collections.IList; if (entityList == null) entityList = new System.Collections.ArrayList(entities); break; } return entityList; } // NSpringHibernateDaoBase.vsl merge-point } } 1.1 cartridges/andromda-nspring/src/test/expected/org/andromda/cartridges/nspring/TestEntity1DaoImpl.cs Index: TestEntity1DaoImpl.cs =================================================================== // Name: TestEntity1DaoImpl.cs // license-header cs merge-point // // Attention: Generated code! Do not modify by hand! // Generated by: NSpringHibernateDaoImpl.vsl in andromda-nspring-cartridge. using System; namespace org.andromda.cartridges.nspring { /// <summary> /// <see cref="org::andromda::cartridges::nspring::TestEntity1"/> /// </summary> public class TestEntity1DaoImpl : org.andromda.cartridges.nspring.TestEntity1DaoBase { // NSpringHibernateDaoImpl.vsl merge-point } } |