7152564: Improve CodeSource.matchLocation(CodeSource) performance
7155693: CodeSource.matchLocation getPort test can be improved
Reviewed-by: chegar
diff --git a/test/java/security/CodeSource/Implies.java b/test/java/security/CodeSource/Implies.java
index bc37dcb..9e4c26b 100644
--- a/test/java/security/CodeSource/Implies.java
+++ b/test/java/security/CodeSource/Implies.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,25 +23,42 @@
 
 /*
  * @test
- * @bug 4866847
- * @summary NullPointerException from CodeSource.matchLocation
+ * @bug 4866847 7152564 7155693
+ * @summary various CodeSource.implies tests
  */
 
 import java.security.CodeSource;
-import java.net.*;
+import java.net.URL;
 
 public class Implies {
     public static void main(String[] args) throws Exception {
         URL thisURL = new URL("http", "localhost", "file");
         URL thatURL = new URL("http", null, "file");
+        // should not throw NullPointerException
+        testImplies(thisURL, thatURL, false);
+
+        thisURL = new URL("http", "localhost", "dir/-");
+        thatURL = new URL("HTTP", "localhost", "dir/file");
+        // protocol check should ignore case
+        testImplies(thisURL, thatURL, true);
+
+        thisURL = new URL("http", "localhost", 80, "dir/-");
+        thatURL = new URL("HTTP", "localhost", "dir/file");
+        // port check should match default port of thatURL
+        testImplies(thisURL, thatURL, true);
+
+        System.out.println("test passed");
+    }
+
+    private static void testImplies(URL thisURL, URL thatURL, boolean result)
+        throws SecurityException
+    {
         CodeSource thisCs =
             new CodeSource(thisURL, (java.security.cert.Certificate[]) null);
         CodeSource thatCs =
             new CodeSource(thatURL, (java.security.cert.Certificate[]) null);
-
-        if (thisCs.implies(thatCs)) {
+        if (thisCs.implies(thatCs) != result) {
             throw new SecurityException("test failed");
         }
-        System.out.println("test passed");
     }
 }