Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/
package org.apache.openejb.config;

import org.apache.openejb.util.LogCategory;
import org.apache.xbean.finder.filter.Filters;
import org.junit.Test;

import java.io.File;
Expand All @@ -26,9 +26,6 @@
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.logging.Handler;
import java.util.logging.LogRecord;
import java.util.logging.Logger;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
Expand Down Expand Up @@ -59,39 +56,11 @@ public void reportWebappJarsDroppedByContainerExclusions() throws Exception {
exclusions.getParentFile().mkdirs();
Files.write(exclusions.toPath(), "internal-\n".getBytes(StandardCharsets.UTF_8));

final List<LogRecord> records = new ArrayList<>();
final Handler handler = new Handler() {
@Override
public void publish(final LogRecord record) {
records.add(record);
}
final List<URL> scannable = DeploymentLoader.filterWebappUrls(webUrls, null, exclusions.toURI().toURL());
assertEquals(Collections.singletonList(appJar), scannable);

@Override
public void flush() {
// no-op
}

@Override
public void close() {
// no-op
}
};
final Logger logger = Logger.getLogger(LogCategory.OPENEJB_STARTUP_CONFIG.getName());
logger.addHandler(handler);
try {
final List<URL> scannable = DeploymentLoader.filterWebappUrls(webUrls, null, exclusions.toURI().toURL());
assertEquals(Collections.singletonList(appJar), scannable);
} finally {
logger.removeHandler(handler);
}

final List<String> messages = new ArrayList<>();
for (final LogRecord record : records) {
if (record.getMessage().startsWith("Application jars not scanned")) {
messages.add(record.getMessage());
}
}
assertEquals(1, messages.size());
assertTrue(messages.get(0), messages.get(0).contains("[ant-reporting-web.jar (prefix 'ant-')]"));
// only the application jar dropped by the container list is reported, not the one excluded by the app itself
assertEquals(Collections.singletonList("ant-reporting-web.jar (prefix 'ant-')"),
new ArrayList<>(DeploymentLoader.builtinExcludedWebappJars(webUrls, scannable, Filters.prefixes("internal-"))));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -359,12 +359,12 @@ public void addListener(final AsyncListener listener, final ServletRequest reque

@Override
public ServletRequest getRequest() {
throw new UnsupportedOperationException();
return null; // AsyncEvent(AsyncContext) reads both with some Servlet API versions
}

@Override
public ServletResponse getResponse() {
throw new UnsupportedOperationException();
return null; // AsyncEvent(AsyncContext) reads both with some Servlet API versions
}

@Override
Expand Down
Loading