/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License.
*/ package org.apache.tomcat.util.buf;
ByteChunk bc = new ByteChunk();
CharChunk cc = new CharChunk(32);
for (int i = 0; i < msgCount; i++) {
bc.append(UTF16_MESSAGE, 0, UTF16_MESSAGE.length);
conv.convert(bc, cc, true); Assert.assertEquals("ABC", cc.toString());
bc.recycle();
cc.recycle();
conv.recycle();
}
System.out.println(cc);
}
@Test publicvoid testLeftoverSize() { float maxLeftover = 0;
String charsetName = "UNSET"; for (Charset charset : Charset.availableCharsets().values()) { float leftover; if (charset.name().toLowerCase(Locale.ENGLISH).startsWith("x-")) { // Non-standard charset that browsers won't be using // Likely something used internally by the JRE continue;
} try {
leftover = charset.newEncoder().maxBytesPerChar();
} catch (UnsupportedOperationException uoe) { // Skip it continue;
} if (leftover > maxLeftover) {
maxLeftover = leftover;
charsetName = charset.name();
}
} Assert.assertTrue("Limit needs to be at least " + maxLeftover + " (used in charset '" + charsetName + "')",
maxLeftover <= B2CConverter.LEFTOVER_SIZE);
}
@Test(expected=MalformedInputException.class) publicvoid testBug54602a() throws Exception { // Check invalid input is rejected straight away
B2CConverter conv = new B2CConverter(StandardCharsets.UTF_8);
ByteChunk bc = new ByteChunk();
CharChunk cc = new CharChunk();
@Test(expected=MalformedInputException.class) publicvoid testBug54602b() throws Exception { // Check partial input is rejected
B2CConverter conv = new B2CConverter(StandardCharsets.UTF_8);
ByteChunk bc = new ByteChunk();
CharChunk cc = new CharChunk();
@Test publicvoid testBug54602c() throws Exception { // Check partial input is rejected once it is known to be all available
B2CConverter conv = new B2CConverter(StandardCharsets.UTF_8);
ByteChunk bc = new ByteChunk();
CharChunk cc = new CharChunk();
¤ 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.0.15Bemerkung:
(vorverarbeitet)
¤
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 ist noch experimentell.