@Test
public void test_integration() {

	
	RangerIpMatcher ipMatcher = createMatcher(null);
	// Matcher initialized with null policy should behave sensibly!  It matches everything!
	Assert.assertTrue(ipMatcher.isMatched(createRequest("1.2.3.4")));
	
	// empty ip-address list is same as null, i.e. matchs anything!
	ipMatcher = createMatcher(new String[]{});
	Assert.assertTrue(ipMatcher.isMatched(createRequest("1.2.3.4")));
	// wildcard address will match anything -- ipv4 and ipv6 addresses
	ipMatcher = createMatcher(new String[]{"*"});
	Assert.assertTrue(ipMatcher.isMatched(createRequest("1.2.3.4")));
	Assert.assertTrue(ipMatcher.isMatched(createRequest("1:2:3:4:5:6")));
	
	// partial wildcard matches work as expected.
	ipMatcher = createMatcher(new String[]{"1.2.3.*"} );
	Assert.assertTrue(ipMatcher.isMatched(createRequest("1.2.3.4")));
	Assert.assertTrue(ipMatcher.isMatched(createRequest("1.2.3.123")));
	// NOTE: absurd ipv4 address but it should match too!
	Assert.assertTrue(ipMatcher.isMatched(createRequest("1.2.3.123567")));
	Assert.assertTrue(ipMatcher.isMatched(createRequest("1.2.3..123567")));
	Assert.assertTrue(ipMatcher.isMatched(createRequest("1.2.3.boo")));
	// mismatches caught correctly
	Assert.assertFalse(ipMatcher.isMatched(createRequest("1.2.31.123567")));
	Assert.assertFalse(ipMatcher.isMatched(createRequest("1.2.33.123567")));
	// no address has special meaning
	Assert.assertFalse(ipMatcher.isMatched(createRequest("1.2.0.0")));
	Assert.assertFalse(ipMatcher.isMatched(createRequest("1.2.255.255")));
	Assert.assertFalse(ipMatcher.isMatched(createRequest("1.2.254.254")));
	Assert.assertFalse(ipMatcher.isMatched(createRequest("0.0.0.0")));
	Assert.assertFalse(ipMatcher.isMatched(createRequest("255.255.255.255")));
	// wild card can be more than one octets
	ipMatcher = createMatcher(new String[]{"11.22.*.*"} );
	Assert.assertTrue(ipMatcher.isMatched(createRequest("11.22.33.4")));
	Assert.assertTrue(ipMatcher.isMatched(createRequest("11.22.33.44")));
	Assert.assertTrue(ipMatcher.isMatched(createRequest("11.22.253.190")));
	Assert.assertTrue(ipMatcher.isMatched(createRequest("11.22.253.190")));
	// mismatches
	Assert.assertFalse(ipMatcher.isMatched(createRequest("11.222.253.190")));
	Assert.assertFalse(ipMatcher.isMatched(createRequest("11.21.253.190")));
	
	// one need't provide all the octets; missing ones are treaetd as wild cards
	ipMatcher = createMatcher(new String[]{"193.214.*"} ); // note just 3 octets in pattern
	Assert.assertTrue(ipMatcher.isMatched(createRequest("193.214.3.4")));
	Assert.assertFalse(ipMatcher.isMatched(createRequest("193.21.253.190")));
	// can't match ipv6 address using a ipv4 policy
	Assert.assertFalse(ipMatcher.isMatched(createRequest("193:214:3:4")));
	
	// same holds for ipv6 addresses
	ipMatcher = createMatcher(new String[]{"193:214:*"} );
	Assert.assertTrue(ipMatcher.isMatched(createRequest("193:214:3:4:5:6")));
	Assert.assertTrue(ipMatcher.isMatched(createRequest("193:214:13:94:a90:b4f")));
	// mismatches work as expected
	Assert.assertFalse(ipMatcher.isMatched(createRequest("193:215:13:94:a90:b4f")));
	// can't match ipv4 address against ipv6 policy
	Assert.assertFalse(ipMatcher.isMatched(createRequest("193.214.3.4")));
	
	// direct match works as expected
	ipMatcher = createMatcher(new String[]{"99:a9:b9:c9:d9:e9"} );
	Assert.assertTrue(ipMatcher.isMatched(createRequest("99:a9:b9:c9:d9:e9")));
	Assert.assertFalse(ipMatcher.isMatched(createRequest("99:a9:b9:c9:d0:e9")));
	
	// Matcher can support multiple patterns of different domains - a mix of ipv4 and ipv6 addresses
	ipMatcher = createMatcher(new String[]{"10.20.30.*", "99:a9:b9:c9:d9:*"} );
	Assert.assertTrue(ipMatcher.isMatched(createRequest("99:a9:b9:c9:d9:e9")));
	Assert.assertTrue(ipMatcher.isMatched(createRequest("99:a9:b9:c9:d9:e9")));
	Assert.assertFalse(ipMatcher.isMatched(createRequest("99:a9:b9:c9:dd:e9")));
	Assert.assertFalse(ipMatcher.isMatched(createRequest("89:a9:b9:c9:d9:e9")));
	Assert.assertTrue(ipMatcher.isMatched(createRequest("10.20.30.10")));
	Assert.assertTrue(ipMatcher.isMatched(createRequest("10.20.30.20")));
	Assert.assertFalse(ipMatcher.isMatched(createRequest("10.20.3.10")));
	Assert.assertFalse(ipMatcher.isMatched(createRequest("10.20.33.10")));
}