BrokerInterceptorWithClassLoader load(BrokerInterceptorMetadata metadata, String narExtractionDirectory)
            throws IOException {
        final File narFile = metadata.getArchivePath().toAbsolutePath().toFile();
        NarClassLoader ncl = NarClassLoaderBuilder.builder()
                .narFile(narFile)
                .parentClassLoader(BrokerInterceptorUtils.class.getClassLoader())
                .extractionDirectory(narExtractionDirectory)
                .build();

        BrokerInterceptorDefinition def = getBrokerInterceptorDefinition(ncl);
        if (StringUtils.isBlank(def.getInterceptorClass())) {
            throw new IOException("Broker interceptors `" + def.getName() + "` does NOT provide a broker"
                    + " interceptors implementation");
        }

        try {
            Class interceptorClass = ncl.loadClass(def.getInterceptorClass());
            Object interceptor = interceptorClass.getDeclaredConstructor().newInstance();
            if (!(interceptor instanceof BrokerInterceptor)) {
                throw new IOException("Class " + def.getInterceptorClass()
                        + " does not implement broker interceptor interface");
            }
            BrokerInterceptor pi = (BrokerInterceptor) interceptor;
            return new BrokerInterceptorWithClassLoader(pi, ncl);
        } catch (Throwable t) {
            rethrowIOException(t);
            return null;
        }
    }
@Test(expectedExceptions = IOException.class)
    public void testLoadBrokerEventListenerWithBlankListenerClass() throws Exception {
        BrokerInterceptorDefinition def = new BrokerInterceptorDefinition();
        def.setDescription("test-broker-listener");

        String archivePath = "/path/to/broker/listener/nar";

        BrokerInterceptorMetadata metadata = new BrokerInterceptorMetadata();
        metadata.setDefinition(def);
        metadata.setArchivePath(Paths.get(archivePath));

        NarClassLoader mockLoader = mock(NarClassLoader.class);
        when(mockLoader.getServiceDefinition(eq(BrokerInterceptorUtils.BROKER_INTERCEPTOR_DEFINITION_FILE)))
                .thenReturn(ObjectMapperFactory.getYamlMapper().writer().writeValueAsString(def));
        Class listenerClass = MockBrokerInterceptor.class;
        when(mockLoader.loadClass(eq(MockBrokerInterceptor.class.getName())))
                .thenReturn(listenerClass);

        final NarClassLoaderBuilder mockedBuilder = mock(NarClassLoaderBuilder.class, RETURNS_SELF);
        when(mockedBuilder.build()).thenReturn(mockLoader);
        try (MockedStatic<NarClassLoaderBuilder> builder = Mockito.mockStatic(NarClassLoaderBuilder.class)) {
            builder.when(() -> NarClassLoaderBuilder.builder()).thenReturn(mockedBuilder);

            BrokerInterceptorUtils.load(metadata, "");
        }
    }