/*
* 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 4982668
* @summary Test that a map containing 'null' values is handled
* properly when converting the map into a hashtable,
* i.e. all 'null' values should be removed before creating
* the hashtable in order to avoid a NullPointerException.
* Check also that null values for keys are not allowed in
* the maps passed to the JMXConnector[Server] factories.
* @author Luis-Miguel Alventosa
* @run clean MapNullValuesTest
* @run build MapNullValuesTest
* @run main MapNullValuesTest
*/
public class MapNullValuesTest {
private static int port;
public MapNullValuesTest() {
// Map 0
//
// Map 1
//
// Map 2
//
// Map 3
//
// Map Array
//
}
throws IllegalArgumentException {
size--;
} else { // Check for equality
throw new IllegalArgumentException("Unknown key!");
throw new IllegalArgumentException("Value mismatch!");
}
}
throw new IllegalArgumentException("Size mismatch!");
}
private int mapToHashtableTests() {
int errorCount = 0;
echo("");
try {
echo("\tHashtable = " + t);
checkContents(maps[i], t);
} catch (Exception e) {
errorCount++;
}
}
if (errorCount == 0) {
echo("");
} else {
echo("");
}
return errorCount;
}
private int jmxConnectorServerFactoryTests() {
int errorCount = 0;
echo("");
try {
echo("\tCreate the MBean server");
echo("\tCreate the RMI connector server");
new JMXServiceURL("service:jmx:rmi:///jndi/rmi://:" +
port + "/JMXConnectorServerFactory" + i);
maps[i],
mbs);
echo("\tStart the RMI connector server");
echo("\tCall RMIConnectorServer.toJMXConnector(Map)");
echo("\tStop the RMI connector server");
} catch (Exception e) {
errorCount++;
}
}
if (errorCount == 0) {
echo("");
} else {
echo("");
}
return errorCount;
}
private int jmxConnectorFactoryTests() {
int errorCount = 0;
echo("");
try {
echo("\tCreate the MBean server");
echo("\tCreate the RMI connector server");
new JMXServiceURL("service:jmx:rmi:///jndi/rmi://:" +
port + "/JMXConnectorFactory" + i);
null,
mbs);
echo("\tStart the RMI connector server");
echo("\tCreate and connect the RMI connector");
echo("\tClose the RMI connector");
} catch (Exception e) {
errorCount++;
}
}
if (errorCount == 0) {
echo("");
} else {
echo("");
}
return errorCount;
}
private int nullKeyFactoryTests() {
int errorCount = 0;
echo("");
try {
echo("\tJMXConnectorServerFactory.newJMXConnectorServer()");
try {
map3,
mbs);
errorCount++;
echo("\tTest FAILED!");
} catch (Exception e) {
echo("\tTest PASSED!");
}
echo("\tJMXConnectorServerFactory.toJMXConnector()");
try {
null,
mbs);
errorCount++;
echo("\tTest FAILED!");
} catch (Exception e) {
echo("\tTest PASSED!");
} finally {
}
echo("\tJMXConnectorFactory.newJMXConnector()");
try {
null,
mbs);
map3);
errorCount++;
echo("\tTest FAILED!");
} catch (Exception e) {
echo("\tTest PASSED!");
} finally {
}
echo("\tJMXConnectorFactory.connect()");
try {
null,
mbs);
errorCount++;
echo("\tTest FAILED!");
} catch (Exception e) {
echo("\tTest PASSED!");
} finally {
}
echo("\tJMXConnector.connect()");
try {
null,
mbs);
null);
errorCount++;
echo("\tTest FAILED!");
} catch (Exception e) {
echo("\tTest PASSED!");
} finally {
}
} catch (Exception e) {
echo("\tGot unexpected exception!");
errorCount = 1;
}
if (errorCount == 0) {
echo("");
} else {
echo("");
}
return errorCount;
}
final int MAX_LINE = 80;
}
}
int errorCount = 0;
// Create an RMI registry
//
echo("");
port = 7500;
while (port++ < 7550) {
try {
break;
} catch (RemoteException e) {
// Failed to create RMI registry...
//
}
}
}
// Run tests
//
if (errorCount == 0) {
} else {
}
}
}