mirror of https://github.com/apache/druid.git
fix loader
This commit is contained in:
parent
9df6f3341a
commit
e725df7110
|
@ -429,11 +429,13 @@
|
|||
<type>test-jar</type>
|
||||
<version>${project.parent.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.druid</groupId>
|
||||
<groupId>org.apache.druid.extensions</groupId>
|
||||
<artifactId>druid-datasketches</artifactId>
|
||||
<type>test-jar</type>
|
||||
<version>${project.parent.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
|
|
|
@ -19,10 +19,20 @@
|
|||
|
||||
package org.apache.druid.quidem;
|
||||
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
import com.google.common.cache.CacheLoader;
|
||||
import com.google.common.cache.LoadingCache;
|
||||
import org.apache.druid.sql.calcite.util.SqlTestFramework.QueryComponentSupplier;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.reflections.Reflections;
|
||||
import org.reflections.scanners.SubTypesScanner;
|
||||
import org.reflections.util.ConfigurationBuilder;
|
||||
import org.reflections.util.FilterBuilder;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.MalformedURLException;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
|
@ -51,4 +61,41 @@ public class QTest extends DruidQuidemTestBase
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testQTest() throws Exception
|
||||
{
|
||||
LoadingCache<String, Set<Class<? extends QueryComponentSupplier>>> componentSupplierClassCache = CacheBuilder
|
||||
.newBuilder()
|
||||
.build(new CacheLoader<String, Set<Class<? extends QueryComponentSupplier>>>()
|
||||
{
|
||||
@Override
|
||||
public Set<Class<? extends QueryComponentSupplier>> load(String pkg) throws MalformedURLException
|
||||
{
|
||||
return new Reflections(
|
||||
new ConfigurationBuilder()
|
||||
// .addUrls(ClasspathHelper.forPackage(pkg,
|
||||
// getClass().getClassLoader()))
|
||||
|
||||
// .addClassLoaders(getClass().getClassLoader().getParent())
|
||||
.setScanners(
|
||||
new SubTypesScanner(true)
|
||||
|
||||
)
|
||||
.filterInputsBy(
|
||||
new FilterBuilder().includePackage(pkg).and(
|
||||
s -> s.contains("ComponentSupplier")
|
||||
)
|
||||
|
||||
)
|
||||
.setUrls(org.reflections.util.ClasspathHelper.forJavaClassPath())
|
||||
|
||||
)
|
||||
.getSubTypesOf(QueryComponentSupplier.class);
|
||||
}
|
||||
});
|
||||
|
||||
Set<Class<? extends QueryComponentSupplier>> a = componentSupplierClassCache.get("");
|
||||
throw new RuntimeException("X" + a);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,7 +42,11 @@ import org.apache.http.client.utils.URLEncodedUtils;
|
|||
import org.junit.jupiter.api.extension.AfterAllCallback;
|
||||
import org.junit.jupiter.api.extension.BeforeEachCallback;
|
||||
import org.junit.jupiter.api.extension.ExtensionContext;
|
||||
import org.reflections.Configuration;
|
||||
import org.reflections.Reflections;
|
||||
import org.reflections.scanners.SubTypesScanner;
|
||||
import org.reflections.util.ConfigurationBuilder;
|
||||
import org.reflections.util.FilterBuilder;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
|
@ -506,7 +510,15 @@ public class SqlTestFrameworkConfig
|
|||
@Override
|
||||
public Set<Class<? extends QueryComponentSupplier>> load(String pkg)
|
||||
{
|
||||
return new Reflections(pkg).getSubTypesOf(QueryComponentSupplier.class);
|
||||
Configuration cfg = new ConfigurationBuilder()
|
||||
.setScanners(new SubTypesScanner(true))
|
||||
.setUrls(org.reflections.util.ClasspathHelper.forJavaClassPath())
|
||||
.filterInputsBy(
|
||||
new FilterBuilder()
|
||||
.includePackage(pkg)
|
||||
.and(s -> s.contains("ComponentSupplier"))
|
||||
);
|
||||
return new Reflections(cfg).getSubTypesOf(QueryComponentSupplier.class);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue