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