jdk/test/java/nio/charset/StandardCharsets/Standard.java
changeset 24692 268fbc344d53
parent 9685 b9cfe747eaa0
equal deleted inserted replaced
24691:f96e172a6ce8 24692:268fbc344d53
     1 /*
     1 /*
     2  * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
    97         try { realMain(args); } catch (Throwable t) { unexpected(t); }
    97         try { realMain(args); } catch (Throwable t) { unexpected(t); }
    98 
    98 
    99         System.out.printf("%nPassed = %d, failed = %d%n%n", passed, failed);
    99         System.out.printf("%nPassed = %d, failed = %d%n%n", passed, failed);
   100         if (failed > 0) throw new Exception("Some tests failed");
   100         if (failed > 0) throw new Exception("Some tests failed");
   101     }
   101     }
   102     private static abstract class Fun {abstract void f() throws Throwable;}
       
   103     private static void THROWS(Class<? extends Throwable> k, Fun... fs) {
       
   104           for (Fun f : fs)
       
   105               try { f.f(); fail("Expected " + k.getName() + " not thrown"); }
       
   106               catch (Throwable t) {
       
   107                   if (k.isAssignableFrom(t.getClass())) pass();
       
   108                   else unexpected(t);}}
       
   109     static byte[] serializedForm(Object obj) {
   102     static byte[] serializedForm(Object obj) {
   110         try {
   103         try {
   111             ByteArrayOutputStream baos = new ByteArrayOutputStream();
   104             ByteArrayOutputStream baos = new ByteArrayOutputStream();
   112             new ObjectOutputStream(baos).writeObject(obj);
   105             new ObjectOutputStream(baos).writeObject(obj);
   113             return baos.toByteArray();
   106             return baos.toByteArray();