Sharpen.Pattern.Pattern C# (CSharp) Method

Pattern() private method

private Pattern ( Regex r ) : System
r System.Text.RegularExpressions.Regex
return System
        private Pattern(Regex r)
        {
            this.regex = r;
        }

Usage Example

Example #1
0
 /// <summary>Attempts to start a NameNode with the given operation.</summary>
 /// <remarks>
 /// Attempts to start a NameNode with the given operation.  Starting
 /// the NameNode should throw an exception.
 /// </remarks>
 /// <param name="operation">- NameNode startup operation</param>
 /// <param name="exceptionClass">
 /// - if non-null, will check that the caught exception
 /// is assignment-compatible with exceptionClass
 /// </param>
 /// <param name="messagePattern">
 /// - if non-null, will check that a substring of the
 /// message from the caught exception matches this pattern, via the
 /// <see cref="Matcher#find()"/>
 /// method.
 /// </param>
 internal virtual void StartNameNodeShouldFail(HdfsServerConstants.StartupOption operation
                                               , Type exceptionClass, Sharpen.Pattern messagePattern)
 {
     try
     {
         cluster = new MiniDFSCluster.Builder(conf).NumDataNodes(0).StartupOption(operation
                                                                                  ).Format(false).ManageDataDfsDirs(false).ManageNameDfsDirs(false).Build();
         // should fail
         NUnit.Framework.Assert.Fail("NameNode should have failed to start");
     }
     catch (Exception e)
     {
         // expect exception
         if (exceptionClass != null)
         {
             NUnit.Framework.Assert.IsTrue("Caught exception is not of expected class " + exceptionClass
                                           .Name + ": " + StringUtils.StringifyException(e), exceptionClass.IsInstanceOfType
                                               (e));
         }
         if (messagePattern != null)
         {
             NUnit.Framework.Assert.IsTrue("Caught exception message string does not match expected pattern \""
                                           + messagePattern.Pattern() + "\" : " + StringUtils.StringifyException(e), messagePattern
                                           .Matcher(e.Message).Find());
         }
         Log.Info("Successfully detected expected NameNode startup failure.");
     }
 }
All Usage Examples Of Sharpen.Pattern::Pattern