@Test public void testIsMatch() throws Exception { RecordedHttpRequest recordedHttpRequest1 = new RecordedHttpRequest(null, new URI("google.com"), null, null); RecordedHttpRequest recordedHttpRequest2 = new RecordedHttpRequest(null, new URI("google.com"), null, null); MatchRule matchRule = new MatchUri(); Assert.assertTrue(matchRule.test(recordedHttpRequest1, recordedHttpRequest2)); }
@Test public void testMatchDefaultPortHttp() throws Exception { RecordedHttpRequest recordedHttpRequest1 = new RecordedHttpRequest(null, new URI("http://www.example.org/"), null, null); RecordedHttpRequest recordedHttpRequest2 = new RecordedHttpRequest(null, new URI("http://www.example.org:80/"), null, null); MatchRule matchRule = new MatchUri(); Assert.assertTrue(matchRule.test(recordedHttpRequest1, recordedHttpRequest2)); }
@Test public void testNotMatchNonDefaultPort() throws Exception { RecordedHttpRequest recordedHttpRequest1 = new RecordedHttpRequest(null, new URI("http://www.example.org/"), null, null); RecordedHttpRequest recordedHttpRequest2 = new RecordedHttpRequest(null, new URI("http://www.example.org:8080/"), null, null); MatchRule matchRule = new MatchUri(); Assert.assertFalse(matchRule.test(recordedHttpRequest1, recordedHttpRequest2)); }
@Test public void testIsNotMatch() throws URISyntaxException { RecordedHttpRequest recordedHttpRequest1 = new RecordedHttpRequest(null, new URI("google.com"), null, null); RecordedHttpRequest recordedHttpRequest2 = new RecordedHttpRequest(null, new URI("yahoo.com"), null, null); MatchRule matchRule = new MatchUri(); Assert.assertFalse(matchRule.test(recordedHttpRequest1, recordedHttpRequest2)); } }
@Test public void testMatchDefaultPortHttps() throws Exception { RecordedHttpRequest recordedHttpRequest1 = new RecordedHttpRequest(null, new URI("https://www.example.org/"), null, null); RecordedHttpRequest recordedHttpRequest2 = new RecordedHttpRequest(null, new URI("https://www.example.org:443/"), null, null); MatchRule matchRule = new MatchUri(); Assert.assertTrue(matchRule.test(recordedHttpRequest1, recordedHttpRequest2)); }
/** * @return rule to match request URI and Method */ public static MatchRule matchMethodUri() { CompositeMatchRule compositeMatchRule = new CompositeMatchRule(); compositeMatchRule.addRule(new MatchMethod()); compositeMatchRule.addRule(new MatchUri()); return compositeMatchRule; }
@Test public void testIsMatch() throws Exception { RecordedHttpRequest recordedHttpRequest1 = new RecordedHttpRequest("get", new URI("google.com"), null, null); RecordedHttpRequest recordedHttpRequest2 = new RecordedHttpRequest("get", new URI("google.com"), null, null); Set<MatchRule> matchRuleSet = new HashSet<MatchRule>(); matchRuleSet.add(new MatchUri()); matchRuleSet.add(new MatchMethod()); CompositeMatchRule compositeMatchRule = new CompositeMatchRule(); compositeMatchRule.addAll(matchRuleSet); Assert.assertTrue(compositeMatchRule.test(recordedHttpRequest1, recordedHttpRequest2)); }
@Test public void testIsNotMatch() throws Exception { RecordedHttpRequest recordedHttpRequest1 = new RecordedHttpRequest("get", new URI("google.com"), null, null); RecordedHttpRequest recordedHttpRequest2 = new RecordedHttpRequest("post", new URI("google.com"), null, null); Set<MatchRule> matchRuleSet = new HashSet<MatchRule>(); matchRuleSet.add(new MatchUri()); matchRuleSet.add(new MatchMethod()); CompositeMatchRule compositeMatchRule = new CompositeMatchRule(); compositeMatchRule.addAll(matchRuleSet); Assert.assertFalse(compositeMatchRule.test(recordedHttpRequest1, recordedHttpRequest2)); } }
/** * @return rule to match request Method, URI and Body with any boundary */ public static MatchRule matchMethodUriBodyWithAnyBoundary() { CompositeMatchRule compositeMatchRule = new CompositeMatchRule(); compositeMatchRule.addRule(new MatchMethod()); compositeMatchRule.addRule(new MatchUri()); compositeMatchRule.addRule(new MatchBodyWithAnyBoundary()); return compositeMatchRule; }
/** * @return rule to match request URI, Body and Method */ public static MatchRule matchMethodBodyUri() { CompositeMatchRule compositeMatchRule = new CompositeMatchRule(); compositeMatchRule.addRule(new MatchBody()); compositeMatchRule.addRule(new MatchMethod()); compositeMatchRule.addRule(new MatchUri()); return compositeMatchRule; }
/** * @return rule to match request URI, Method, Headers, and Body */ public static MatchRule matchEntireRequest() { CompositeMatchRule compositeMatchRule = new CompositeMatchRule(); compositeMatchRule.addRule(new MatchMethod()); compositeMatchRule.addRule(new MatchUri()); compositeMatchRule.addRule(new MatchHeaders()); compositeMatchRule.addRule(new MatchBody()); return compositeMatchRule; }