jdk/test/javax/management/namespace/SerialParamProcessorTest.java
changeset 1156 bbc2d15aaf7a
child 1227 4546977d0d66
equal deleted inserted replaced
1155:a9a142fcf1b5 1156:bbc2d15aaf7a
       
     1 /*
       
     2  * Copyright 2008 Sun Microsystems, Inc.  All Rights Reserved.
       
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       
     4  *
       
     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
       
     7  * published by the Free Software Foundation.
       
     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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
       
    20  * CA 95054 USA or visit www.sun.com if you need additional information or
       
    21  * have any questions.
       
    22  */
       
    23 
       
    24 /*
       
    25  *
       
    26  * @test SerialParamProcessorTest.java 1.8
       
    27  * @summary General SerialParamProcessorTest test.
       
    28  * @author Daniel Fuchs
       
    29  * @run clean SerialParamProcessorTest Wombat WombatMBean
       
    30  * @compile -XDignore.symbol.file=true  SerialParamProcessorTest.java
       
    31  * @run build SerialParamProcessorTest Wombat WombatMBean
       
    32  * @run main SerialParamProcessorTest
       
    33  */
       
    34 
       
    35 import com.sun.jmx.namespace.serial.RewritingProcessor;
       
    36 import java.beans.ConstructorProperties;
       
    37 import java.io.Serializable;
       
    38 import java.util.ArrayList;
       
    39 import java.util.Arrays;
       
    40 import java.util.HashMap;
       
    41 import java.util.LinkedList;
       
    42 import java.util.List;
       
    43 import java.util.Map;
       
    44 import javax.management.AttributeChangeNotification;
       
    45 import javax.management.AttributeList;
       
    46 import javax.management.JMException;
       
    47 import javax.management.Notification;
       
    48 import javax.management.ObjectName;
       
    49 import javax.management.StandardMBean;
       
    50 
       
    51 /**
       
    52  * Class SerialParamProcessorTest
       
    53  *
       
    54  * @author Sun Microsystems, Inc.
       
    55  */
       
    56 public class SerialParamProcessorTest {
       
    57 
       
    58     /**
       
    59      * Creates a new instance of SerialParamProcessorTest
       
    60      */
       
    61     public SerialParamProcessorTest() {
       
    62     }
       
    63 
       
    64     public static class MyCompositeData implements Serializable {
       
    65         private static final long serialVersionUID = 3186492415099133506L;
       
    66         public MyCompositeData(ObjectName foobar,ObjectName absolute,
       
    67                 long count, String name) {
       
    68             this(foobar,absolute,count,name,new ObjectName[]{foobar,absolute});
       
    69         }
       
    70         @ConstructorProperties(value={"fooBar","absolute","count","name",
       
    71                                         "allNames"})
       
    72         public MyCompositeData(ObjectName foobar,ObjectName absolute,
       
    73                 long count, String name, ObjectName[] allnames) {
       
    74             this.foobar = foobar;
       
    75             this.absolute = absolute;
       
    76             this.count = count;
       
    77             this.name = name;
       
    78             this.allnames = allnames;
       
    79         }
       
    80         ObjectName foobar,absolute,allnames[];
       
    81         long count;
       
    82         String name;
       
    83         public ObjectName getFooBar() {
       
    84             return foobar;
       
    85         }
       
    86         public ObjectName getAbsolute() {
       
    87             return absolute;
       
    88         }
       
    89         public ObjectName[] getAllNames() {
       
    90             return allnames;
       
    91         }
       
    92         public long getCount() {
       
    93             return count;
       
    94         }
       
    95         public String getName() {
       
    96             return name;
       
    97         }
       
    98         private Object[] toArray() {
       
    99             final Object[] props = {
       
   100                 getName(),getFooBar(),getAbsolute(),getAllNames(),getCount()
       
   101             };
       
   102             return props;
       
   103         }
       
   104         @Override
       
   105         public boolean equals(Object o) {
       
   106             if (o instanceof MyCompositeData)
       
   107                 return Arrays.deepEquals(toArray(),
       
   108                         ((MyCompositeData)o).toArray());
       
   109             return false;
       
   110         }
       
   111         @Override
       
   112         public int hashCode() {
       
   113             return Arrays.deepHashCode(toArray());
       
   114         }
       
   115     }
       
   116 
       
   117     public static interface MyMXBean {
       
   118         public Map<String,MyCompositeData> getAll();
       
   119         public MyCompositeData lookup(String name);
       
   120         public void put(String name, MyCompositeData data);
       
   121         public MyCompositeData remove(String name);
       
   122     }
       
   123 
       
   124     public static class My implements MyMXBean {
       
   125         Map<String,MyCompositeData> datas =
       
   126                 new HashMap<String,MyCompositeData>();
       
   127         public Map<String,MyCompositeData> getAll() {
       
   128             return datas;
       
   129         }
       
   130         public MyCompositeData lookup(String name) {
       
   131             return datas.get(name);
       
   132         }
       
   133         public void put(String name, MyCompositeData data) {
       
   134             datas.put(name,data);
       
   135         }
       
   136         public MyCompositeData remove(String name) {
       
   137             return datas.remove(name);
       
   138         }
       
   139     }
       
   140 
       
   141     public static class BandicootClass implements Serializable {
       
   142         private static final long serialVersionUID = -5494055748633966355L;
       
   143         public final Object gloups;
       
   144         public BandicootClass(Object gloups) {
       
   145             this.gloups = gloups;
       
   146         }
       
   147         private Object[] toArray() {
       
   148             final Object[] one = {gloups};
       
   149             return one;
       
   150         }
       
   151         @Override
       
   152         public boolean equals(Object obj) {
       
   153             if (!(obj instanceof BandicootClass)) return false;
       
   154             final Object[] one = {gloups};
       
   155             return Arrays.deepEquals(toArray(),((BandicootClass)obj).toArray());
       
   156         }
       
   157         @Override
       
   158         public int hashCode() {
       
   159             if (gloups == null) return 0;
       
   160             return Arrays.deepHashCode(toArray());
       
   161         }
       
   162     }
       
   163 
       
   164     // Need this to override equals.
       
   165     public static class BandicootNotification extends Notification {
       
   166         private static final long serialVersionUID = 664758643764049001L;
       
   167         public BandicootNotification(String type, Object source, long seq) {
       
   168             super(type,source,seq,0L,"");
       
   169         }
       
   170         private Object[] toArray() {
       
   171             final Object[] vals = {getMessage(),getSequenceNumber(),
       
   172                 getSource(),getTimeStamp(),getType(),getUserData()};
       
   173             return vals;
       
   174         }
       
   175         @Override
       
   176         public boolean equals(Object o) {
       
   177             if (!(o instanceof BandicootNotification)) return false;
       
   178             return Arrays.deepEquals(toArray(),
       
   179                     ((BandicootNotification)o).toArray());
       
   180         }
       
   181         @Override
       
   182         public int hashCode() {
       
   183             return Arrays.deepHashCode(toArray());
       
   184         }
       
   185 
       
   186     }
       
   187 
       
   188     // Need this to override equals.
       
   189     public static class BandicootAttributeChangeNotification
       
   190             extends AttributeChangeNotification {
       
   191         private static final long serialVersionUID = -1392435607144396125L;
       
   192         public BandicootAttributeChangeNotification(Object source,
       
   193                 long seq, long time, String msg, String name, String type,
       
   194                 Object oldv, Object newv) {
       
   195             super(source,seq,time,msg,name,type,oldv,newv);
       
   196         }
       
   197         private Object[] toArray() {
       
   198             final Object[] vals = {getMessage(),getSequenceNumber(),
       
   199                 getSource(),getTimeStamp(),getType(),getUserData(),
       
   200                 getAttributeName(), getAttributeType(),getNewValue(),
       
   201                 getOldValue()};
       
   202             return vals;
       
   203         }
       
   204         @Override
       
   205         public boolean equals(Object o) {
       
   206             if (!(o instanceof BandicootAttributeChangeNotification))
       
   207                 return false;
       
   208             return Arrays.deepEquals(toArray(),
       
   209                     ((BandicootAttributeChangeNotification)o).toArray());
       
   210         }
       
   211         @Override
       
   212         public int hashCode() {
       
   213             return Arrays.deepHashCode(toArray());
       
   214         }
       
   215         @Override
       
   216         public String toString() {
       
   217             final StringBuilder b = new StringBuilder();
       
   218             b.append(this.getClass().getName()).append(": ");
       
   219             b.append("[type=").append(getType()).append("]");
       
   220             b.append("[source=").append(getSource()).append("]");
       
   221             b.append("[message=").append(getMessage()).append("]");
       
   222             b.append("[sequence=").append(getSequenceNumber()).append("]");
       
   223 
       
   224             b.append("[attribute=").append(getAttributeName()).append("]");
       
   225             b.append("[class=").append(getAttributeType()).append("]");
       
   226             b.append("[oldvalue=").append(getOldValue()).append("]");
       
   227             b.append("[newvalue=").append(getNewValue()).append("]");
       
   228 
       
   229             b.append("[time=").append(getTimeStamp()).append("]");
       
   230             b.append("[data=").append(getUserData()).append("]");
       
   231             return b.toString();
       
   232         }
       
   233     }
       
   234 
       
   235     private static void addToList(Object[] foos, List<Object> foolist) {
       
   236         final ArrayList<Object> fal = new ArrayList<Object>(foos.length);
       
   237         for (Object f : foos) {
       
   238             if (f.getClass().isArray()) {
       
   239                 foolist.add(new BandicootClass(f));
       
   240                 fal.add(new BandicootClass(f));
       
   241             } else {
       
   242                 foolist.add(f);
       
   243                 fal.add(f);
       
   244             }
       
   245         }
       
   246         foolist.add(new BandicootClass(foos));
       
   247         foolist.add(fal);
       
   248     }
       
   249 
       
   250     public static void testSerial(String msg, Object foo, Object bar,
       
   251             RewritingProcessor procForFoo,
       
   252             RewritingProcessor procForBar, List<Object> foolist,
       
   253             List<Object> barlist, boolean recurse) {
       
   254         System.err.println(msg+" Testing serial - "+foo.getClass().getName());
       
   255         final Object bar1  = procForFoo.rewriteInput(foo);
       
   256         final Object foo1  = procForFoo.rewriteOutput(bar);
       
   257         final Object bar2  = procForFoo.rewriteInput(foo1);
       
   258         final Object foo2  = procForFoo.rewriteOutput(bar1);
       
   259 
       
   260         final Object bar3  = procForBar.rewriteOutput(foo);
       
   261         final Object foo3  = procForBar.rewriteInput(bar);
       
   262         final Object bar4  = procForBar.rewriteOutput(foo3);
       
   263         final Object foo4  = procForBar.rewriteInput(bar3);
       
   264 
       
   265         final Object bar5  = procForFoo.rewriteInput(foo3);
       
   266         final Object foo5  = procForFoo.rewriteOutput(bar3);
       
   267 
       
   268         final Object bar6  = procForBar.rewriteOutput(foo1);
       
   269         final Object foo6  = procForBar.rewriteInput(bar1);
       
   270 
       
   271         final Object[] foos = {foo, foo1, foo2, foo3, foo4, foo5, foo6};
       
   272         final Object[] bars = {bar, bar1, bar2, bar3, bar4, bar5, bar6};
       
   273 
       
   274         final Object[] foot = { foo };
       
   275         final Object[] bart = { bar };
       
   276         for (int j=1;j<foos.length;j++) {
       
   277             final Object[] foox = { foos[j] };
       
   278             final Object[] barx = { bars[j] };
       
   279             if (!Arrays.deepEquals(foot,foox)) {
       
   280                 System.err.println(msg+" foo"+j+" "+foos[j]+" != "+foo);
       
   281                 throw new RuntimeException(msg+" foo"+j+" != foo");
       
   282             }
       
   283             if (!Arrays.deepEquals(bart,barx)) {
       
   284                 System.err.println(msg+" bar"+j+" "+bars[j]+" != "+bar);
       
   285                 throw new RuntimeException(msg+" bar"+j+" != bar");
       
   286             }
       
   287 
       
   288         }
       
   289         if (recurse) {
       
   290             testSerial("Array: " + msg,foos,bars,procForFoo,
       
   291                     procForBar,foolist,barlist,false);
       
   292             addToList(foos,foolist);
       
   293             addToList(bars,barlist);
       
   294         }
       
   295     }
       
   296     public static void testSerial(Object[][] objects,
       
   297             RewritingProcessor procForFoo,
       
   298             RewritingProcessor procForBar) {
       
   299         int i=0;
       
   300         final List<Object> foolist  = new LinkedList<Object>();
       
   301         final List<Object> barlist = new LinkedList<Object>();
       
   302         for (Object[] row : objects) {
       
   303             i++;
       
   304             Object foo = row[0];
       
   305             Object bar = row[1];
       
   306             String msg1 = "[" +foo.getClass().getName() + "] step " +
       
   307                     i +": ";
       
   308 
       
   309             testSerial(msg1,foo,bar,procForFoo,procForBar,foolist,barlist,true);
       
   310 
       
   311             final BandicootClass kfoo = new BandicootClass(foo);
       
   312             final BandicootClass kbar = new BandicootClass(bar);
       
   313 
       
   314             String msg2 = "[" +kfoo.getClass().getName() + "] step " +
       
   315                     i +": ";
       
   316             testSerial(msg2,kfoo,kbar,procForFoo,procForBar,foolist,barlist,true);
       
   317         }
       
   318         String msg31 = "foo[] and bar[]: ";
       
   319         testSerial(msg31,foolist.toArray(),barlist.toArray(),
       
   320                    procForFoo,procForBar,foolist,barlist,false);
       
   321 
       
   322         String msg3 = "foolist and barlist: ";
       
   323         testSerial(msg3,new LinkedList<Object>(foolist),
       
   324                    new LinkedList<Object>(barlist),
       
   325                    procForFoo,procForBar,foolist,barlist,false);
       
   326 
       
   327         final BandicootClass kfoolist = new BandicootClass(foolist);
       
   328         final BandicootClass kbarlist = new BandicootClass(barlist);
       
   329         String msg4 = "kfoolist and kbarlist: ";
       
   330         testSerial(msg4,kfoolist,kbarlist,procForFoo,procForBar,foolist,barlist,false);
       
   331     }
       
   332 
       
   333     /**
       
   334      * The idea of this  method is to convert {@code foo} things into
       
   335      * {@code bar} things...
       
   336      * @param foo the string to replace.
       
   337      * @param bar the replacement for {@code foo}
       
   338      *        ({@code foo} becomes {@code bar}).
       
   339      * @param sfoo a string that may contain {@code foo}, that will be embedded
       
   340      *        in non-replaceable parts of the domain in order to attempt to
       
   341      *        trick the replacement logic.
       
   342      * @param sbar a string that may contain {@code bar}, that will be embedded
       
   343      *        in non-replaceable parts of the domain in order to attempt to
       
   344      *        trick the replacement logic.
       
   345      **/
       
   346     public static void doSerialTest(String foo, String bar, String sfoo,
       
   347                                String sbar) {
       
   348         try {
       
   349         final RewritingProcessor procForFoo = RewritingProcessor.
       
   350                 newRewritingProcessor(foo,bar);
       
   351         final RewritingProcessor procForBar =RewritingProcessor.
       
   352                 newRewritingProcessor(bar,foo);
       
   353         final String foop = (foo.isEmpty())?foo:foo+"//";
       
   354         final String pfoo = (foo.isEmpty())?foo:"//"+foo;
       
   355         final String barp = (bar.isEmpty())?bar:bar+"//";
       
   356         final String pbar = (bar.isEmpty())?bar:"//"+bar;
       
   357         final String sfoop = (sfoo.isEmpty())?sfoo:sfoo+"//";
       
   358         final String psfoo = (sfoo.isEmpty())?sfoo:"//"+sfoo;
       
   359         final String sbarp = (sbar.isEmpty())?sbar:sbar+"//";
       
   360         final String psbar = (sbar.isEmpty())?sbar:"//"+sbar;
       
   361 
       
   362         // A trick to avoid writing Open Data by hand...
       
   363         final My tricks = new My();
       
   364 
       
   365         // A treat to automagically convert trick things into Open Data.
       
   366         final StandardMBean treats =
       
   367                 new StandardMBean(tricks,MyMXBean.class,true);
       
   368 
       
   369         // datas[i][0] is expected to be transformed in datas[i][1]
       
   370         //
       
   371         final MyCompositeData[][] datas = {
       
   372             { // this foo thing:
       
   373             new MyCompositeData(new ObjectName(foop+sbarp+"x:y=z"),
       
   374                     new ObjectName("//"+foop+sbarp+"x:y=z"),1,sfoop+sbarp+"foobar"),
       
   375               // should be transformed into this bar thing:
       
   376             new MyCompositeData(new ObjectName(barp+sbarp+"x:y=z"),
       
   377                     new ObjectName("//"+foop+sbarp+"x:y=z"),1,sfoop+sbarp+"foobar"),
       
   378             },
       
   379             { // this foo thing:
       
   380             new MyCompositeData(new ObjectName(foop+sfoop+"x:y=z"),
       
   381                     new ObjectName("//"+foop+sfoop+"x:y=z"),1,sfoop+sbarp+"barfoo"),
       
   382               // should be transformed into this bar thing:
       
   383             new MyCompositeData(new ObjectName(barp+sfoop+"x:y=z"),
       
   384                     new ObjectName("//"+foop+sfoop+"x:y=z"),1,sfoop+sbarp+"barfoo"),
       
   385             }
       
   386         };
       
   387 
       
   388         // objects[i][0] is expected to be transformed into objects[i][1]
       
   389         //
       
   390         final Object[][] objects = new Object[][] {
       
   391             {new Long(1), new Long(1)},
       
   392             {
       
   393                 new ObjectName(foop+sbarp+"x:y=z"),
       
   394                         new ObjectName(barp+sbarp+"x:y=z")
       
   395             },
       
   396             {
       
   397                 new ObjectName(foop+sfoop+"x:y=z"),
       
   398                         new ObjectName(barp+sfoop+"x:y=z")
       
   399             },
       
   400             {
       
   401                 new ObjectName("//"+foop+sbarp+"x:y=z"),
       
   402                 new ObjectName("//"+foop+sbarp+"x:y=z"),
       
   403             },
       
   404             {
       
   405                 new ObjectName("//"+foop+sfoop+"x:y=z"),
       
   406                 new ObjectName("//"+foop+sfoop+"x:y=z")
       
   407             },
       
   408             {
       
   409                 foop+sbarp+"x:y=z",foop+sbarp+"x:y=z"
       
   410             },
       
   411             {
       
   412                 foop+sfoop+"x:y=z",foop+sfoop+"x:y=z"
       
   413             },
       
   414             {
       
   415                 barp+sbarp+"x:y=z",barp+sbarp+"x:y=z"
       
   416             },
       
   417             {
       
   418                 barp+sfoop+"x:y=z",barp+sfoop+"x:y=z"
       
   419             },
       
   420             {
       
   421             new BandicootNotification("test",new ObjectName(foop+sfoop+"x:y=z"),1L),
       
   422             new BandicootNotification("test",new ObjectName(barp+sfoop+"x:y=z"),1L),
       
   423             },
       
   424             {
       
   425             new BandicootNotification("test",new ObjectName("//"+foop+sfoop+"x:y=z"),2L),
       
   426             new BandicootNotification("test",new ObjectName("//"+foop+sfoop+"x:y=z"),2L),
       
   427             },
       
   428             {
       
   429             new BandicootAttributeChangeNotification(
       
   430                     new ObjectName(foop+sfoop+"x:y=z"),1L,2L,"blah","attrname",
       
   431                     ObjectName.class.getName(),
       
   432                     new ObjectName(foop+sfoop+"x:y=old"),
       
   433                     new ObjectName(foop+sfoop+"x:y=new")),
       
   434             new BandicootAttributeChangeNotification(
       
   435                     new ObjectName(barp+sfoop+"x:y=z"),1L,2L,"blah","attrname",
       
   436                     ObjectName.class.getName(),
       
   437                     new ObjectName(barp+sfoop+"x:y=old"),
       
   438                     new ObjectName(barp+sfoop+"x:y=new")),
       
   439             },
       
   440             {
       
   441             new BandicootAttributeChangeNotification(
       
   442                     new ObjectName("//"+foop+sfoop+"x:y=z"),1L,2L,"blah","attrname",
       
   443                     ObjectName.class.getName(),
       
   444                     new ObjectName("//"+foop+sfoop+"x:y=old"),
       
   445                     new ObjectName(foop+sfoop+"x:y=new")),
       
   446             new BandicootAttributeChangeNotification(
       
   447                     new ObjectName("//"+foop+sfoop+"x:y=z"),1L,2L,"blah","attrname",
       
   448                     ObjectName.class.getName(),
       
   449                     new ObjectName("//"+foop+sfoop+"x:y=old"),
       
   450                     new ObjectName(barp+sfoop+"x:y=new")),
       
   451             }
       
   452         };
       
   453 
       
   454         // List that will merge datas & objects & datas converted to open
       
   455         // types...
       
   456         //
       
   457         final List<Object[]> list = new ArrayList<Object[]>();
       
   458 
       
   459         // Add all objects...
       
   460         //
       
   461         list.addAll(Arrays.asList(objects));
       
   462 
       
   463         // Build Map<String,MyCompositeData> with datas[i][0] (cfoo)
       
   464         //
       
   465         for (int i=0;i<datas.length;i++) {
       
   466             tricks.put(sfoop+sbarp+"x"+i,datas[i][0]);
       
   467         }
       
   468 
       
   469         // Let MXBean convert Map<String,MyCompositeData> to TabularData
       
   470         // (foo things)
       
   471         final Object cfoo = treats.getAttribute("All");
       
   472         final AttributeList afoo = treats.getAttributes(new String[] {"All"});
       
   473 
       
   474         // Build Map<String,MyCompositeData> with datas[i][1] (cbar)
       
   475         //
       
   476         for (int i=0;i<datas.length;i++) {
       
   477             tricks.remove(sfoop+sbarp+"x"+i);
       
   478             tricks.put(sfoop+sbarp+"x"+i,datas[i][1]);
       
   479         }
       
   480 
       
   481         // Let MXBean convert Map<String,MyCompositeData> to TabularData
       
   482         // (bar things)
       
   483         final Object cbar = treats.getAttribute("All");
       
   484         final AttributeList abar = treats.getAttributes(new String[] {"All"});
       
   485 
       
   486         // Add all datas to list
       
   487         for (int i=0;i<datas.length;i++) {
       
   488             list.add(datas[i]);
       
   489         }
       
   490 
       
   491         // Add converted TabularDatas to list
       
   492         list.add(new Object[] {cfoo,cbar});
       
   493 
       
   494         // Add AttributeList containing TabularData to list
       
   495         list.add(new Object[] {afoo,abar});
       
   496 
       
   497         // Add Arrays of the above to list...
       
   498         list.add(new Object[] {new Object[] {cfoo,afoo,1L},
       
   499                                new Object[] {cbar,abar,1L}});
       
   500 
       
   501         // Add MBeanInfo...
       
   502         list.add(new Object[] {treats.getMBeanInfo(),treats.getMBeanInfo()});
       
   503 
       
   504         // No ready to test conversion of all foo things into bar things.
       
   505         //
       
   506         testSerial(list.toArray(new Object[list.size()][]),
       
   507                 procForFoo,procForBar);
       
   508         } catch (JMException x) {
       
   509             throw new RuntimeException(x);
       
   510         }
       
   511     }
       
   512 
       
   513     public static void aaaTest() {
       
   514         System.err.println("\n--------------------- aaaTest ----------------");
       
   515         System.err.println("---------------- 'foo' becomes 'bar' ---------\n");
       
   516         doSerialTest("foo","bar","foo","bar");
       
   517     }
       
   518 
       
   519     public static void aabTest() {
       
   520         System.err.println("\n--------------------- aabTest ----------------");
       
   521         System.err.println("---------- 'foo//bar' becomes 'bar//foo' -----\n");
       
   522         doSerialTest("foo//bar","bar//foo","foo","bar");
       
   523     }
       
   524 
       
   525     public static void aacTest() {
       
   526         System.err.println("\n----------------- aacTest --------------------");
       
   527         System.err.println("------------ 'foo//bar' becomes '' -----------\n");
       
   528         doSerialTest("foo//bar","","foo","bar");
       
   529     }
       
   530 
       
   531     public static void aadTest() {
       
   532         System.err.println("\n----------------- aadTest --------------------");
       
   533         System.err.println("----------- '' becomes 'bar//foo' ------------\n");
       
   534         doSerialTest("","bar//foo","","bar//foo");
       
   535     }
       
   536 
       
   537     public static void aaeTest() {
       
   538         System.err.println("\n----------------- aaeTest --------------------");
       
   539         System.err.println("----------------- '' becomes '' --------------\n");
       
   540         doSerialTest("","","foo","bar//foo");
       
   541     }
       
   542 
       
   543     // Let's be wild...
       
   544     public static void aafTest() {
       
   545         System.err.println("\n----------------- aafTest --------------------");
       
   546         System.err.println("----------- '' becomes '' -- (bis) -----------\n");
       
   547         doSerialTest("","","","");
       
   548     }
       
   549     public static void aagTest() {
       
   550         System.err.println("\n----------------- aagTest --------------------");
       
   551         System.err.println("----------- foobar becomes foobar ------------\n");
       
   552         doSerialTest("foobar","foobar","foobar","foobar");
       
   553     }
       
   554 
       
   555     // TODO add test with descriptor, MBeanInfo, Open Types, etc...
       
   556     public static void main(String[] args) {
       
   557         aaaTest();
       
   558         aabTest();
       
   559         aacTest();
       
   560         aadTest();
       
   561         aaeTest();
       
   562         aafTest();
       
   563         aagTest();
       
   564 
       
   565         // TODO: add a test case to test *exactly* the serialization
       
   566         // of Notification and AttributeChangeNotification, and not of
       
   567         // a subclass of these.
       
   568         // This will involve implementing some hack, because we
       
   569         // can't use equals() to compare the results.
       
   570     }
       
   571 }