/* * 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.http;
// Make sure the inner Parameter class behaves correctly
@Test publicvoid testInternal() { Assert.assertEquals("foo1=bar1", SIMPLE.toString()); // Note: testing requires that ' ' is encoded as '+', // because that is what browsers will send us. Assert.assertEquals("foo2=bar1&foo2=bar2&foo2=hello+world&foo2=%3F%25%40",
SIMPLE_MULTIPLE.toString()); Assert.assertEquals("foo3", NO_VALUE.toString()); Assert.assertEquals("foo4=", EMPTY_VALUE.toString());
}
@Test publicvoid testAddParameters() {
Parameters p = new Parameters();
// Empty at this point
Enumeration<String> names = p.getParameterNames(); Assert.assertFalse(names.hasMoreElements());
String[] values = p.getParameterValues("foo"); Assert.assertNull(values);
// Add a parameter with two values
p.addParameter("foo", "value1");
p.addParameter("foo", "value2");
@Test publicvoid testAddParametersLimit() {
Parameters p = new Parameters();
p.setLimit(2);
// Empty at this point
Enumeration<String> names = p.getParameterNames(); Assert.assertFalse(names.hasMoreElements());
String[] values = p.getParameterValues("foo1"); Assert.assertNull(values);
// Add a parameter
p.addParameter("foo1", "value1");
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.