ASF Bugzilla – Attachment 25766 Details for
Bug 49600
Bad exception thrown by ProxyDirContext.lookup
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
Unit tests illustrating the problems
ProxyDirContextTest.java (text/java), 3.17 KB, created by
Marc Guillemot
on 2010-07-16 05:38:47 UTC
(
hide
)
Description:
Unit tests illustrating the problems
Filename:
MIME Type:
Creator:
Marc Guillemot
Created:
2010-07-16 05:38:47 UTC
Size:
3.17 KB
patch
obsolete
>/* > * 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.naming.resources; > >import javax.naming.NameNotFoundException; >import javax.naming.NamingException; > >import org.apache.catalina.Context; >import org.apache.catalina.startup.Tomcat; >import org.apache.catalina.startup.TomcatBaseTest; >import org.apache.naming.resources.ProxyDirContext; > >/** > * Unit test for the {@link ProxyDirContext}. > * @author Marc Guillemot > * @version $Revision: $ > */ >public class ProxyDirContextTest extends TomcatBaseTest { > > /** > * lookup doesn't always throw the same exception. > */ > public void testLookupException() throws Exception { > Tomcat tomcat = getTomcatInstance(); > > // Must have a real docBase - just use temp > Context ctx = tomcat.addContext("/", System.getProperty("java.io.tmpdir")); > tomcat.start(); > > try { > ctx.getResources().lookup("/WEB-INF/web.xml"); > fail(); > } > catch (final NameNotFoundException e) { > // as expected > } > Thread.sleep(5005); // see ProxyDirContext.cacheTTL > try { > ctx.getResources().lookup("/WEB-INF/web.xml"); > fail(); > } > catch (final NameNotFoundException e) { > // as expected > } > } > > /** > * Exception throw by lookup doesn't contain the right stack trace. > * In fact it seems to be initialized at Tomcat's startup. > */ > public void testLookupExceptionStackTrace() throws Exception { > Tomcat tomcat = getTomcatInstance(); > > // Must have a real docBase - just use temp > final Context ctx = tomcat.addContext("/", System.getProperty("java.io.tmpdir")); > tomcat.start(); > > doLookupExceptionStackTraceTest(ctx); > } > > private void doLookupExceptionStackTraceTest(final Context ctx) { > final Exception exception = new Exception(); > final StackTraceElement here = exception.getStackTrace()[0]; > > Exception thrownByLookup = null; > try { > ctx.getResources().lookup("/WEB-INF/web.xml"); > fail(); > } > catch (final NamingException e) { > thrownByLookup = e; > } > > for (final StackTraceElement elt : thrownByLookup.getStackTrace()) { > if (elt.getClassName().equals(here.getClassName())) { > assertEquals(here.getMethodName(), elt.getMethodName()); > return; > } > } > fail("StackTraceElement not found"); > } >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 49600
: 25766