You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@synapse.apache.org by hi...@apache.org on 2010/08/13 19:58:02 UTC
svn commit: r985307 - in
/synapse/trunk/java/modules/commons/src/test/java/org/apache/synapse/commons/evaluators/config:
MatchBuilderTest.java MatchSerializerTest.java
Author: hiranya
Date: Fri Aug 13 17:58:02 2010
New Revision: 985307
URL: http://svn.apache.org/viewvc?rev=985307&view=rev
Log:
Test case for match builder
Added:
synapse/trunk/java/modules/commons/src/test/java/org/apache/synapse/commons/evaluators/config/MatchBuilderTest.java
Modified:
synapse/trunk/java/modules/commons/src/test/java/org/apache/synapse/commons/evaluators/config/MatchSerializerTest.java
Added: synapse/trunk/java/modules/commons/src/test/java/org/apache/synapse/commons/evaluators/config/MatchBuilderTest.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/commons/src/test/java/org/apache/synapse/commons/evaluators/config/MatchBuilderTest.java?rev=985307&view=auto
==============================================================================
--- synapse/trunk/java/modules/commons/src/test/java/org/apache/synapse/commons/evaluators/config/MatchBuilderTest.java (added)
+++ synapse/trunk/java/modules/commons/src/test/java/org/apache/synapse/commons/evaluators/config/MatchBuilderTest.java Fri Aug 13 17:58:02 2010
@@ -0,0 +1,74 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.synapse.commons.evaluators.config;
+
+import junit.framework.TestCase;
+import org.apache.axiom.om.util.AXIOMUtil;
+import org.apache.synapse.commons.evaluators.MatchEvaluator;
+import org.apache.synapse.commons.evaluators.EvaluatorConstants;
+
+public class MatchBuilderTest extends TestCase {
+
+ private static final String SOURCE = "foo";
+ private static final String REGEX = "bar";
+
+ private MatchFactory fac = new MatchFactory();
+
+ public void testHeaderMatch() {
+ String input = "<match type=\"header\" source=\"" + SOURCE +
+ "\" regex=\"" + REGEX + "\"/>";
+
+ try {
+ MatchEvaluator eval = (MatchEvaluator) fac.create(AXIOMUtil.stringToOM(input));
+ assertEquals(eval.getType(), EvaluatorConstants.TYPE_HEADER);
+ assertEquals(eval.getSource(), SOURCE);
+ assertEquals(eval.getRegex().pattern(), REGEX);
+ } catch (Exception e) {
+ fail("Error while parsing the input XML");
+ }
+ }
+
+ public void testParameterMatch() {
+ String input = "<match type=\"param\" source=\"" + SOURCE +
+ "\" regex=\"" + REGEX + "\"/>";
+
+ try {
+ MatchEvaluator eval = (MatchEvaluator) fac.create(AXIOMUtil.stringToOM(input));
+ assertEquals(eval.getType(), EvaluatorConstants.TYPE_PARAM);
+ assertEquals(eval.getSource(), SOURCE);
+ assertEquals(eval.getRegex().pattern(), REGEX);
+ } catch (Exception e) {
+ fail("Error while parsing the input XML");
+ }
+ }
+
+ public void testURLMatch() {
+ String input = "<match type=\"url\" regex=\"" + REGEX + "\"/>";
+
+ try {
+ MatchEvaluator eval = (MatchEvaluator) fac.create(AXIOMUtil.stringToOM(input));
+ assertEquals(eval.getType(), EvaluatorConstants.TYPE_URL);
+ assertNull(eval.getSource());
+ assertEquals(eval.getRegex().pattern(), REGEX);
+ } catch (Exception e) {
+ fail("Error while parsing the input XML");
+ }
+ }
+}
Modified: synapse/trunk/java/modules/commons/src/test/java/org/apache/synapse/commons/evaluators/config/MatchSerializerTest.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/commons/src/test/java/org/apache/synapse/commons/evaluators/config/MatchSerializerTest.java?rev=985307&r1=985306&r2=985307&view=diff
==============================================================================
--- synapse/trunk/java/modules/commons/src/test/java/org/apache/synapse/commons/evaluators/config/MatchSerializerTest.java (original)
+++ synapse/trunk/java/modules/commons/src/test/java/org/apache/synapse/commons/evaluators/config/MatchSerializerTest.java Fri Aug 13 17:58:02 2010
@@ -1,20 +1,20 @@
/*
- * Copyright (c) 2005-2008, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * WSO2 Inc. licenses this file to you under the Apache License,
- * Version 2.0 (the "License"); you may not use this file except
- * in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- *
*/
package org.apache.synapse.commons.evaluators.config;