1 package com.openinventions.webappfilter.processor.test; 2 3 import com.openinventions.metaframework.*; 4 import com.openinventions.webappfilter.*; 5 import com.openinventions.webappfilter.util.*; 6 import org.apache.commons.logging.*; 7 import java.util.regex.*; 8 import junit.framework.*; 9 10 public class JUnitAssert implements Processor { 11 private static final Log log = LogFactory.getLog(JUnitAssert.class); 12 13 public void process(State state, Element context) throws Exception { 14 Assert junitAssert = WebAppFilterTest.getTest(); 16 StateXPath stateXPath = (StateXPath) state.get("com.openinventions.webappfilter.util.StateXPath"); 17 String xpath = context.getValue("xpath"); 18 String value = stateXPath.getValue(state, xpath); 19 String regex = context.getValue("regex"); 20 Pattern pattern = Pattern.compile(regex); 21 Matcher matcher = pattern.matcher(value); 22 23 if (log.isDebugEnabled()) { 24 log.debug("regex = " + regex); 25 log.debug("value = " + value); 26 log.debug("ASSERT = " + matcher.matches()); 27 } 28 29 junitAssert.assertTrue("value " + value + "\n\n****************does not match**************\n\n " + regex, matcher.matches()); 30 31 } 32 } 33 84 85 86 87 | Popular Tags |