test/sun/net/InetAddress/nameservice/simple/DefaultCaching.java

Print this page




   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 /* @test
  25  * @bug 6442088
  26  * @summary Change default DNS caching behavior for code not running under
  27  *          security manager.
  28  *
  29  * @build B6442088 SimpleNameService SimpleNameServiceDescriptor
  30  * @run main/othervm/timeout=200 -Dsun.net.inetaddr.ttl=20 -Dsun.net.spi.nameservice.provider.1=simple,sun B6442088
  31  */
  32 import java.net.InetAddress;
  33 import java.net.UnknownHostException;
  34 import java.security.Security;
  35 
  36 public class B6442088 {
  37 
  38     public static void main(String args[]) throws Exception {
  39 
  40         // name service needs to resolve this.
  41         SimpleNameService.put("theclub", "129.156.220.219");
  42 
  43         test ("theclub", "129.156.220.219", true);      // lk: 1
  44         test ("luster", "1.16.20.2", false);            // lk: 2
  45 
  46         // name service now needs to know about luster
  47         SimpleNameService.put("luster", "10.5.18.21");
  48 
  49         test ("luster", "1.16.20.2", false);            // lk: 2
  50         sleep (10+1);
  51         test("luster", "10.5.18.21", true, 3);          // lk: 3
  52         sleep (5);
  53 
  54         SimpleNameService.put("foo", "10.5.18.22");
  55         SimpleNameService.put("theclub", "129.156.220.1");
  56 




   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 /* @test
  25  * @bug 6442088
  26  * @summary Change default DNS caching behavior for code not running under
  27  *          security manager.
  28  * @compile -XDignore.symbol.file=true SimpleNameService.java
  29  *                                     SimpleNameServiceDescriptor.java
  30  * @run main/othervm/timeout=200 -Dsun.net.inetaddr.ttl=20 -Dsun.net.spi.nameservice.provider.1=simple,sun DefaultCaching
  31  */
  32 import java.net.InetAddress;
  33 import java.net.UnknownHostException;
  34 import java.security.Security;
  35 
  36 public class DefaultCaching {
  37 
  38     public static void main(String args[]) throws Exception {
  39 
  40         // name service needs to resolve this.
  41         SimpleNameService.put("theclub", "129.156.220.219");
  42 
  43         test ("theclub", "129.156.220.219", true);      // lk: 1
  44         test ("luster", "1.16.20.2", false);            // lk: 2
  45 
  46         // name service now needs to know about luster
  47         SimpleNameService.put("luster", "10.5.18.21");
  48 
  49         test ("luster", "1.16.20.2", false);            // lk: 2
  50         sleep (10+1);
  51         test("luster", "10.5.18.21", true, 3);          // lk: 3
  52         sleep (5);
  53 
  54         SimpleNameService.put("foo", "10.5.18.22");
  55         SimpleNameService.put("theclub", "129.156.220.1");
  56