JSR-356 some more tests
This commit is contained in:
parent
441c98544a
commit
11bb7431d2
|
@ -23,7 +23,9 @@ import static org.junit.Assert.*;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.eclipse.jetty.websocket.server.pathmap.PathSpec;
|
||||||
import org.eclipse.jetty.websocket.server.pathmap.PathSpecGroup;
|
import org.eclipse.jetty.websocket.server.pathmap.PathSpecGroup;
|
||||||
|
import org.eclipse.jetty.websocket.server.pathmap.ServletPathSpec;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -42,13 +44,13 @@ public class WebSocketPathSpecTest
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assertMatches(WebSocketPathSpec spec, String path)
|
private void assertMatches(PathSpec spec, String path)
|
||||||
{
|
{
|
||||||
String msg = String.format("Spec(\"%s\").matches(\"%s\")",spec.getPathSpec(),path);
|
String msg = String.format("Spec(\"%s\").matches(\"%s\")",spec.getPathSpec(),path);
|
||||||
assertThat(msg,spec.matches(path),is(true));
|
assertThat(msg,spec.matches(path),is(true));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assertNotMatches(WebSocketPathSpec spec, String path)
|
private void assertNotMatches(PathSpec spec, String path)
|
||||||
{
|
{
|
||||||
String msg = String.format("!Spec(\"%s\").matches(\"%s\")",spec.getPathSpec(),path);
|
String msg = String.format("!Spec(\"%s\").matches(\"%s\")",spec.getPathSpec(),path);
|
||||||
assertThat(msg,spec.matches(path),is(false));
|
assertThat(msg,spec.matches(path),is(false));
|
||||||
|
@ -75,11 +77,15 @@ public class WebSocketPathSpecTest
|
||||||
assertEquals("Spec.pattern","^/a$",spec.getPattern().pattern());
|
assertEquals("Spec.pattern","^/a$",spec.getPattern().pattern());
|
||||||
assertEquals("Spec.pathDepth",1,spec.getPathDepth());
|
assertEquals("Spec.pathDepth",1,spec.getPathDepth());
|
||||||
assertEquals("Spec.group",PathSpecGroup.EXACT,spec.getGroup());
|
assertEquals("Spec.group",PathSpecGroup.EXACT,spec.getGroup());
|
||||||
|
|
||||||
|
assertMatches(spec,"/a");
|
||||||
|
assertNotMatches(spec,"/a/b");
|
||||||
|
assertNotMatches(spec,"/a/");
|
||||||
|
|
||||||
assertEquals("Spec.variableCount",0,spec.getVariableCount());
|
assertEquals("Spec.variableCount",0,spec.getVariableCount());
|
||||||
assertEquals("Spec.variable.length",0,spec.getVariables().length);
|
assertEquals("Spec.variable.length",0,spec.getVariables().length);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testExactTwoPathSpec()
|
public void testExactTwoPathSpec()
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue