/* * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * 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.
*/
// Verify that all options have been set. We only check the option we // have set. Unknown options are ignored.
Map<String, String> outOptions = bean.getRecordingOptions(recId);
logMap("set options", options);
logMap("get options", outOptions); for (String key : options.keySet()) {
Asserts.assertTrue(outOptions.containsKey(key), "Missing key " + key);
Asserts.assertEquals(options.get(key), outOptions.get(key), "Wrong value for key "+ key);
}
// try empty map
bean.setRecordingOptions(recId, new HashMap<>());
// try map that does not have string keys
Map<Integer, String> invalidKeys = new HashMap<>();
invalidKeys.put(4711, "value"); try {
bean.setRecordingOptions(recId, (Map) invalidKeys); thrownew Error("Expected IllagalStateException for non String key");
} catch (IllegalArgumentException iae) { // OK, as expected
} // try map that does not have string values
Map<String, Integer> invalidValues = new HashMap<>();
invalidValues.put("duration", 4711); try {
bean.setRecordingOptions(recId, (Map) invalidKeys); thrownew Error("Expected IllagalStateException for non String value");
} catch (IllegalArgumentException iae) { // OK, as expected
}
// Try one incorrect value, and make sure non // of the other values are set.
Map<String, String> lastIncorrect = new LinkedHashMap<>();
lastIncorrect.put("duration", "10 h");
lastIncorrect.put("whatever", "4711"); try {
bean.setRecordingOptions(recId, lastIncorrect); thrownew Error("Expected IllagalStateException for incorrect key");
} catch (IllegalArgumentException iae) { // ok
Asserts.assertEquals("1 h", bean.getRecordingOptions(recId).get("duration"));
}
// verify that defaults are set back, if we use null
Map<String, String> nullMap = new HashMap<>();
nullMap.put("name", null);
nullMap.put("maxAge", null);
nullMap.put("maxSize", null);
nullMap.put("dumpOnExit", null);
nullMap.put("disk", null);
nullMap.put("duration", null);
nullMap.put("destination", null);
bean.setRecordingOptions(recId, nullMap);
Asserts.assertEquals(bean.getRecordingOptions(recId), defaults);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.