/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 6486655
* @summary Test that attributes and operations appear in the same order
* in MBeanInfo as they did in the Standard MBean or MXBean Interface.
* @author Eamonn McManus
*/
/*
* For more background on this test, see:
*/
public class FeatureOrderTest {
private static boolean failed;
public static interface OrderMXBean {
public int getMercury();
public boolean isMars();
public double getJupiter();
public byte getSaturn();
public short getUranus();
public void setUranus(short x);
public long getNeptune();
// No more Pluto! Yay!
public void neptune();
public void uranus(int x);
public int saturn(int x, int y);
public short jupiter(int x, long y, double z);
public void mars(boolean x);
public int mercury();
}
public int getMercury() {
return 0;
}
return null;
}
}
return null;
}
}
public boolean isMars() {
return true;
}
public double getJupiter() {
return 0;
}
public byte getSaturn() {
return 0;
}
public short getUranus() {
return 0;
}
public void setUranus(short x) {
}
public long getNeptune() {
return 0;
}
public void neptune() {
}
public void uranus(int x) {
}
public int saturn(int x, int y) {
return 0;
}
public short jupiter(int x, long y, double z) {
return 0;
}
public void mars(boolean x) {
}
return null;
}
public double earth(double x) {
return 0;
}
return null;
}
public int mercury() {
return 0;
}
}
private static final boolean[] booleans = {false, true};
// Build the lists of attributes and operations that we would expect
// if they are derived by reflection and preserve the reflection order
m.getReturnType() != void.class)
m.getReturnType() == boolean.class)
m.getReturnType() == void.class &&
} else
}
for (boolean withStandardMBean : booleans) {
"using javax.management.StandardMBean: " +
if (mxbean) {
if (withStandardMBean) {
mbean = new StandardMBean(
new OrderImpl(), OrderMXBean.class, true);
} else
} else {
if (withStandardMBean)
else
}
/* Make sure we are testing what we think. */
boolean isWithStandardMBean =
throw new Exception("Test error: MXBean mismatch");
if (withStandardMBean != isWithStandardMBean)
throw new Exception("Test error: StandardMBean mismatch");
// Check that order of attributes and operations matches
"number of attributes");
"order of attributes");
"number of operations");
"order of operations");
}
}
if (failed)
throw new Exception("TEST FAILED");
}
else {
failed = true;
}
}
}