|
Struts example source code file (NamedVariablePatternMatcherTest.java)
The Struts NamedVariablePatternMatcherTest.java source code/* * Copyright 2002-2006,2009 The Apache Software Foundation. * * Licensed 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 com.opensymphony.xwork2.util; import com.opensymphony.xwork2.util.NamedVariablePatternMatcher.CompiledPattern; import junit.framework.TestCase; import java.util.Arrays; import java.util.HashMap; import java.util.Map; import java.util.regex.Pattern; public class NamedVariablePatternMatcherTest extends TestCase { public void testCompile() { NamedVariablePatternMatcher matcher = new NamedVariablePatternMatcher(); assertNull(matcher.compilePattern(null)); assertNull(matcher.compilePattern("")); CompiledPattern pattern = matcher.compilePattern("foo"); assertEquals("foo", pattern.getPattern().pattern()); pattern = matcher.compilePattern("foo{jim}"); assertEquals("foo([^/]+)", pattern.getPattern().pattern()); assertEquals("jim", pattern.getVariableNames().get(0)); pattern = matcher.compilePattern("foo{jim}/{bob}"); assertEquals("foo([^/]+)/([^/]+)", pattern.getPattern().pattern()); assertEquals("jim", pattern.getVariableNames().get(0)); assertEquals("bob", pattern.getVariableNames().get(1)); assertTrue(pattern.getPattern().matcher("foostar/jie").matches()); assertFalse(pattern.getPattern().matcher("foo/star/jie").matches()); } public void testMatch() { NamedVariablePatternMatcher matcher = new NamedVariablePatternMatcher(); Map<String,String> vars = new HashMap Other Struts examples (source code examples)Here is a short list of links related to this Struts NamedVariablePatternMatcherTest.java source code file: |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.