package org.onetwo.boot.permission.utils;

import java.util.ArrayList;
import java.util.List;

import org.junit.Assert;
import org.junit.Test;
import org.onetwo.ext.permission.utils.UrlResourceInfo;
import org.onetwo.ext.permission.utils.UrlResourceInfoParser;

public class UrlResourceInfoParserTest {
	
	UrlResourceInfoParser parser = new UrlResourceInfoParser();
	
	@Test
	public void testParser(){
		List<UrlResourceInfo> urlResourceInfo = parser.parseToUrlResourceInfos(null);
		Assert.assertTrue(urlResourceInfo.size()==0);
		
		urlResourceInfo = parser.parseToUrlResourceInfos("  ");
		Assert.assertTrue(urlResourceInfo.size()==0);
		
		urlResourceInfo = new ArrayList<UrlResourceInfo>();
		urlResourceInfo.add(new UrlResourceInfo("/user/list"));
		String pasedString = parser.parseToString(urlResourceInfo);
		System.out.println("parsedstirng: " + pasedString);
		
		List<UrlResourceInfo> parsedResourceInfo = parser.parseToUrlResourceInfos(pasedString);
		Assert.assertEquals(urlResourceInfo, parsedResourceInfo);
		
		urlResourceInfo.add(new UrlResourceInfo("/user/create", "post"));
		pasedString = parser.parseToString(urlResourceInfo);
		System.out.println("parsedstirng: " + pasedString);
		
		parsedResourceInfo = parser.parseToUrlResourceInfos(pasedString);
		Assert.assertEquals(urlResourceInfo, parsedResourceInfo);
	}

}

@@ -253,16 +253,64 @@
 oParser;
+%0Aimport org.springframework.util.AntPathMatcher;
 %0A%0Apublic
@@ -1377,12 +1377,193 @@
 nfo);%0A%09%7D
+%0A%09%0A%09@Test%0A%09public void testAntMatcher()%7B%0A%09%09AntPathMatcher path = new AntPathMatcher();%0A%09%09boolean rs = path.match(%22/user.*%22, %22/user.json?aaa=bbb&cc=ddd%22);%0A%09%09Assert.assertTrue(rs);%0A%09%7D
 %0A%0A%7D%0A

add simple test