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

(-)java/javax/el/ImportHandler.java (+4 lines)
Lines 180-185 Link Here
180
            Class<?> conflict = clazzes.get(simpleName);
180
            Class<?> conflict = clazzes.get(simpleName);
181
181
182
            if (conflict != null) {
182
            if (conflict != null) {
183
                // Adding the line below
184
                // fixes TestImportHandler.testResolveClass03()
185
                // but breaks TestImportHandler.testImportClass03()
186
                // clazzes.remove(simpleName);
183
                throw new ELException(Util.message(null,
187
                throw new ELException(Util.message(null,
184
                        "importHandler.ambiguousImport", name, conflict.getName()));
188
                        "importHandler.ambiguousImport", name, conflict.getName()));
185
            }
189
            }
(-)test/javax/el/TestImportHandler.java (-6 / +30 lines)
Lines 54-60 Link Here
54
    /**
54
    /**
55
     * Conflict on resolution.
55
     * Conflict on resolution.
56
     */
56
     */
57
    @Test(expected=ELException.class)
57
    @Test
58
    public void testResolveClass03() {
58
    public void testResolveClass03() {
59
        ImportHandler handler = new ImportHandler();
59
        ImportHandler handler = new ImportHandler();
60
60
Lines 61-67 Link Here
61
        handler.importPackage("org.apache.tomcat.util");
61
        handler.importPackage("org.apache.tomcat.util");
62
        handler.importPackage("org.apache.jasper.util");
62
        handler.importPackage("org.apache.jasper.util");
63
63
64
        handler.resolveClass("ExceptionUtils");
64
        for (int i = 1; i <= 3; i++) {
65
            try {
66
                Class<?> clazz = handler.resolveClass("ExceptionUtils");
67
                Assert.fail("Expected ELException but got [" + clazz.getName()
68
                        + "] on iteration " + i);
69
            } catch (ELException ex) {
70
                // Expected
71
            }
72
        }
65
    }
73
    }
66
74
67
75
Lines 111-122 Link Here
111
    /**
119
    /**
112
     * Import conflicting classes
120
     * Import conflicting classes
113
     */
121
     */
114
    @Test(expected=ELException.class)
122
    @Test
115
    public void testImportClass03() {
123
    public void testImportClass03() {
116
        ImportHandler handler = new ImportHandler();
124
        ImportHandler handler = new ImportHandler();
117
125
118
        handler.importClass("org.apache.tomcat.util.ExceptionUtils");
126
        handler.importClass("org.apache.tomcat.util.ExceptionUtils");
119
        handler.importClass("org.apache.jasper.util.ExceptionUtils");
127
        for (int i = 1; i <= 3; i++) {
128
            try {
129
                handler.importClass("org.apache.jasper.util.ExceptionUtils");
130
                Assert.fail("Expected ELException but got none on iteration "
131
                        + i);
132
            } catch (ELException ex) {
133
                // Expected
134
            }
135
        }
120
    }
136
    }
121
137
122
138
Lines 175-185 Link Here
175
    /**
191
    /**
176
     * Import an invalid static field - conflict.
192
     * Import an invalid static field - conflict.
177
     */
193
     */
178
    @Test(expected=ELException.class)
194
    @Test
179
    public void testImportStatic04() {
195
    public void testImportStatic04() {
180
        ImportHandler handler = new ImportHandler();
196
        ImportHandler handler = new ImportHandler();
181
197
182
        handler.importStatic("org.apache.tomcat.util.buf.Constants.Package");
198
        handler.importStatic("org.apache.tomcat.util.buf.Constants.Package");
183
        handler.importStatic("org.apache.tomcat.util.scan.Constants.Package");
199
        for (int i = 1; i <= 3; i++) {
200
            try {
201
                handler.importStatic("org.apache.tomcat.util.scan.Constants.Package");
202
                Assert.fail("Expected ELException but got none on iteration "
203
                        + i);
204
            } catch (ELException ex) {
205
                // Expected
206
            }
207
        }
184
    }
208
    }
185
}
209
}

Return to bug 57132