View | Details | Raw Unified | Return to bug 54262
Collapse All | Expand All

(-)webapp-3.0-fragments-empty-absolute-ordering/WEB-INF/web.xml (+34 lines)
Line 0 Link Here
1
<?xml version="1.0" encoding="ISO-8859-1"?>
2
<!--
3
  Licensed to the Apache Software Foundation (ASF) under one or more
4
  contributor license agreements.  See the NOTICE file distributed with
5
  this work for additional information regarding copyright ownership.
6
  The ASF licenses this file to You under the Apache License, Version 2.0
7
  (the "License"); you may not use this file except in compliance with
8
  the License.  You may obtain a copy of the License at
9
10
      http://www.apache.org/licenses/LICENSE-2.0
11
12
  Unless required by applicable law or agreed to in writing, software
13
  distributed under the License is distributed on an "AS IS" BASIS,
14
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
  See the License for the specific language governing permissions and
16
  limitations under the License.
17
-->
18
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
19
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
20
  xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
21
                      http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
22
  version="3.0"
23
  metadata-complete="false">
24
25
  <display-name>Tomcat Test Application</display-name>
26
  <description>
27
     Used as part of the Tomcat unit tests when a full web application is
28
     required.
29
  </description>
30
31
  <absolute-ordering/>
32
33
</web-app>
34
native
(-)org/apache/catalina/startup/TestContextConfig.java (-21 / +34 lines)
Lines 67-81 Link Here
67
67
68
        tomcat.start();
68
        tomcat.start();
69
69
70
        ByteChunk res = new ByteChunk();
70
        assertPageContains("/test", 
71
71
                "OK - Custom default Servlet");
72
        int rc =getUrl("http://localhost:" + getPort() + "/test", res, null);
73
74
        // Check return code
75
        assertEquals(HttpServletResponse.SC_OK, rc);
76
77
        // Check context
78
        assertEquals("OK - Custom default Servlet", res.toString());
79
    }
72
    }
80
73
81
    @Test
74
    @Test
Lines 88-99 Link Here
88
81
89
        tomcat.start();
82
        tomcat.start();
90
83
91
        ByteChunk bc = new ByteChunk();
84
        assertPageContains("/test/bug51396.jsp", "<p>OK</p>");
92
        int rc = getUrl("http://localhost:" + getPort() +
93
                "/test/bug51396.jsp", bc, null);
94
95
        assertEquals(HttpServletResponse.SC_OK, rc);
96
        assertTrue(bc.toString().contains("<p>OK</p>"));
97
    }
85
    }
98
86
99
    @Test
87
    @Test
Lines 105-119 Link Here
105
93
106
        tomcat.start();
94
        tomcat.start();
107
95
108
        ByteChunk res = new ByteChunk();
96
        assertPageContains("/test/bug53574", "OK");
97
    }
98
99
    @Test
100
    public void testBug54262() throws Exception {
101
        Tomcat tomcat = getTomcatInstance();
109
102
110
        int rc = getUrl("http://localhost:" + getPort() +
103
        File appDir = new File("test/webapp-3.0-fragments-empty-absolute-ordering");
111
                "/test/bug53574", res, null);
104
        tomcat.addWebapp(null, "/test", appDir.getAbsolutePath());
112
105
113
        Assert.assertEquals(HttpServletResponse.SC_OK, rc);
106
        tomcat.start();
114
107
115
        String body = res.toString();
108
        assertPageContains("/test/resourceA.jsp", 
116
        Assert.assertTrue(body.contains("OK"));
109
                "resourceA.jsp in resources.jar");
110
        assertPageContains("/test/resources/HelloWorldExample", 
111
                null, HttpServletResponse.SC_NOT_FOUND);
117
    }
112
    }
118
113
119
    private static class CustomDefaultServletSCI
114
    private static class CustomDefaultServletSCI
Lines 146-149 Link Here
146
            resp.getWriter().print("OK - Custom default Servlet");
141
            resp.getWriter().print("OK - Custom default Servlet");
147
        }
142
        }
148
    }
143
    }
144
145
    private void assertPageContains(String pageUrl, String expectedBody)
146
            throws IOException {
147
        assertPageContains(pageUrl, expectedBody, HttpServletResponse.SC_OK);
148
    }
149
150
    private void assertPageContains(String pageUrl, String expectedBody,
151
            int expectedStatus) throws IOException {
152
        ByteChunk res = new ByteChunk();
153
        int sc = getUrl("http://localhost:" + getPort() + pageUrl, res, null);
154
155
        assertEquals(expectedStatus, sc);
156
157
        if (expectedStatus == HttpServletResponse.SC_OK) {
158
            String result = res.toString();
159
            assertTrue(result, result.indexOf(expectedBody) > -1);
160
        }
161
    }
149
}
162
}

Return to bug 54262