@Test
public void testSourceSignatureRegExMatcher()
{
// single primitive param, void return
Method m = getMethod("java.lang.AbstractStringBuilder", "ensureCapacity", new Class<?>[] { int.class });
MetaMethod method = new MetaMethod(m, null);
String sourceSig = "public void ensureCapacity(int foo)";
Matcher matcher = Pattern.compile(method.getSignatureRegEx()).matcher(sourceSig);
boolean match = matcher.find();
assertTrue(match);
// 2 primitive params,void return
Method m2 = getMethod("java.lang.AbstractStringBuilder", "setCharAt", new Class<?>[] { int.class, char.class });
MetaMethod method2 = new MetaMethod(m2, null);
String sourceSig2 = "public void setCharAt(int foo, char bar)";
Matcher matcher2 = Pattern.compile(method2.getSignatureRegEx()).matcher(sourceSig2);
boolean match2 = matcher2.find();
assertTrue(match2);
// Object param and return type
Method m3 = getMethod("java.lang.AbstractStringBuilder", "append", new Class<?>[] { java.lang.String.class });
MetaMethod methodFQ = new MetaMethod(m3, null);
String sourceSigFQ = "public AbstractStringBuilder append(String foo)";
Matcher matcherFQ = Pattern.compile(methodFQ.getSignatureRegEx()).matcher(sourceSigFQ);
boolean matchFQ = matcherFQ.find();
assertTrue(matchFQ);
// constructor with primitive params
Constructor<?> c1 = getConstructor("java.lang.AbstractStringBuilder", new Class<?>[] { int.class });
MetaConstructor con1 = new MetaConstructor(c1, null);
String sourceSigC1 = "AbstractStringBuilder(int foo)";
Matcher matcherC1 = Pattern.compile(con1.getSignatureRegEx()).matcher(sourceSigC1);
boolean matchC1 = matcherC1.find();
assertTrue(matchC1);
// array return type, no params
Method m4 = getMethod("java.lang.AbstractStringBuilder", "getValue", new Class<?>[0]);
MetaMethod method4 = new MetaMethod(m4, null);
String sourceSig4 = "final char[] getValue()";
Matcher matcher4 = Pattern.compile(method4.getSignatureRegEx()).matcher(sourceSig4);
boolean match4 = matcher4.find();
assertTrue(match4);
// array param and object return type
Method m5 = getMethod("java.lang.AbstractStringBuilder", "append", new Class<?>[] { char[].class });
MetaMethod method5 = new MetaMethod(m5, null);
String sourceSig5 = "public AbstractStringBuilder append(char[] foo)";
Matcher matcher5 = Pattern.compile(method5.getSignatureRegEx()).matcher(sourceSig5);
boolean match5 = matcher5.find();
assertTrue(match5);
}