/* * 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.catalina.mapper;
mapper.addHost("sjbjdvwsbvhrb", new String[0], createHost("blah1"));
mapper.addHost("sjbjdvwsbvhr/", new String[0], createHost("blah1"));
mapper.addHost("wekhfewuifweuibf", new String[0], createHost("blah2"));
mapper.addHost("ylwrehirkuewh", new String[0], createHost("blah3"));
mapper.addHost("iohgeoihro", new String[0], createHost("blah4"));
mapper.addHost("fwehoihoihwfeo", new String[0], createHost("blah5"));
mapper.addHost("owefojiwefoi", new String[0], createHost("blah6"));
mapper.addHost("iowejoiejfoiew", new String[0], createHost("blah7"));
mapper.addHost("ohewoihfewoih", new String[0], createHost("blah8"));
mapper.addHost("fewohfoweoih", new String[0], createHost("blah9"));
mapper.addHost("ttthtiuhwoih", new String[0], createHost("blah10"));
mapper.addHost("lkwefjwojweffewoih", new String[0], createHost("blah11"));
mapper.addHost("zzzuyopjvewpovewjhfewoih", new String[0], createHost("blah12"));
mapper.addHost("xxxxgqwiwoih", new String[0], createHost("blah13"));
mapper.addHost("qwigqwiwoih", new String[0], createHost("blah14"));
mapper.addHost("qwerty.net", new String[0], createHost("blah15"));
mapper.addHost("*.net", new String[0], createHost("blah16"));
mapper.addHost("zzz.com", new String[0], createHost("blah17"));
mapper.addHostAlias("iowejoiejfoiew", "iowejoiejfoiew_alias");
@Test publicvoid testAddHost() throws Exception { // Try to add duplicates // Duplicate Host name
mapper.addHost("iowejoiejfoiew", new String[0], createHost("blah17")); // Alias conflicting with existing Host
mapper.addHostAlias("iowejoiejfoiew", "qwigqwiwoih"); // Alias conflicting with existing Alias
mapper.addHostAlias("sjbjdvwsbvhrb", "iowejoiejfoiew_alias"); // Redundancy. Alias name = Host name. No error here.
mapper.addHostAlias("qwigqwiwoih", "qwigqwiwoih"); // Redundancy. Duplicate Alias for the same Host name. No error here.
mapper.addHostAlias("iowejoiejfoiew", "iowejoiejfoiew_alias");
mapper.addHostAlias("iowejoiejfoiew", "iowejoiejfoiew_alias");
// Check we have the right number // (added 17 including one host alias. Three duplicates do not increase the count.) Assert.assertEquals(19, mapper.hosts.length);
// Make sure adding a duplicate *does not* overwrite finalint iowPos = 4; Assert.assertEquals("blah7", mapper.hosts[iowPos].object.getName());
// Check for alphabetical order of host names
String previous;
String current = mapper.hosts[0].name; for (int i = 1; i < mapper.hosts.length; i++) {
previous = current;
current = mapper.hosts[i].name; Assert.assertTrue(previous.compareTo(current) < 0);
}
// Check that host alias has the same data
Mapper.MappedHost host = mapper.hosts[iowPos];
Mapper.MappedHost alias = mapper.hosts[iowPos + 1]; Assert.assertEquals("iowejoiejfoiew", host.name); Assert.assertEquals("iowejoiejfoiew_alias", alias.name); Assert.assertFalse(host.isAlias()); Assert.assertTrue(alias.isAlias()); Assert.assertEquals(host.object, alias.object);
// Test addContextVersion() followed by addHost()
Host hostZ = createHost("zzzz");
Context contextZ = createContext("contextZ");
mapper.removeHost("iowejoiejfoiew"); Assert.assertEquals(17, mapper.hosts.length); // Both host and alias removed for (Mapper.MappedHost host : mapper.hosts) { Assert.assertTrue(host.name, !host.name.startsWith("iowejoiejfoiew"));
}
}
// Mark context as paused // This is what happens when context reload starts
mapper.pauseContextVersion(oldContext, hostName, contextPath, "0");
mappingData.recycle();
mapper.map(hostMB, uriMB, null, mappingData); Assert.assertEquals("blah7", mappingData.host.getName()); Assert.assertEquals("context2", mappingData.context.getName()); // Wrapper is not mapped for incoming requests if context is paused Assert.assertNull(mappingData.wrapper);
mappingData.recycle();
mapper.map(oldContext, uriMB, mappingData); // Wrapper is mapped for mapping method used by forward or include dispatch Assert.assertEquals("wrapper5", mappingData.wrapper.getName());
// Re-add the same context, but different list of wrappers // This is what happens when context reload completes
mapper.addContextVersion(hostName, oldHost, contextPath, "0", oldContext, null, null,
Arrays.asList(new WrapperMappingInfo[] { new WrapperMappingInfo("/", createWrapper("newDefaultWrapper"), false, false) }));
mapper.addHost("aaa", new String[0], createHost("a3"));
mapper.addHost("aaaa", new String[0], createHost("a4"));
mapper.addHost("aaaaa", new String[0], createHost("a5"));
mapper.addHost("aaaaaa", new String[0], createHost("a6"));
mapper.addHost("aaaaaaa", new String[0], createHost("a7"));
¤ 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.3Bemerkung:
(vorverarbeitet am 2026-06-07)
¤
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.