use of org.guvnor.test.TempFiles in project kie-wb-common by kiegroup.
the class PackageNameWhiteListLoaderTest method setUp.
@Before
public void setUp() throws Exception {
final SimpleFileSystemProvider fs = new SimpleFileSystemProvider();
// Bootstrap WELD container
weld = new Weld();
final BeanManager beanManager = weld.initialize().getBeanManager();
// Instantiate Paths used in tests for Path conversion
final Bean pathsBean = (Bean) beanManager.getBeans(Paths.class).iterator().next();
final CreationalContext cc = beanManager.createCreationalContext(pathsBean);
Paths paths = (Paths) beanManager.getReference(pathsBean, Paths.class, cc);
// Ensure URLs use the default:// scheme
fs.forceAsDefault();
tempFiles = new TempFiles();
final File tempFile = tempFiles.createTempFile("white-list");
final org.uberfire.java.nio.file.Path nioPackagePath = fs.getPath(tempFile.toURI());
pathToWhiteList = paths.convert(nioPackagePath);
loader = new PackageNameWhiteListLoader(packageNameSearchProvider, ioService);
}
use of org.guvnor.test.TempFiles in project kie-wb-common by kiegroup.
the class PackageNameAllowListLoaderTest method setUp.
@Before
public void setUp() throws Exception {
final SimpleFileSystemProvider fs = new SimpleFileSystemProvider();
// Bootstrap WELD container
weld = new Weld();
final BeanManager beanManager = weld.initialize().getBeanManager();
// Instantiate Paths used in tests for Path conversion
final Bean pathsBean = (Bean) beanManager.getBeans(Paths.class).iterator().next();
final CreationalContext cc = beanManager.createCreationalContext(pathsBean);
Paths paths = (Paths) beanManager.getReference(pathsBean, Paths.class, cc);
tempFiles = new TempFiles();
final File tempFile = tempFiles.createTempFile("allow-list");
final org.uberfire.java.nio.file.Path nioPackagePath = fs.getPath(tempFile.toURI());
pathToAllowList = paths.convert(nioPackagePath);
loader = new PackageNameAllowListLoader(packageNameSearchProvider, ioService);
}
use of org.guvnor.test.TempFiles in project kie-wb-common by kiegroup.
the class DependencyServiceImplTest method setUp.
@Before
public void setUp() throws Exception {
tempFiles = new TempFiles();
when(mavenRepository.getArtifactDependecies(anyString())).thenAnswer(new Answer<Collection<DependencyDescriptor>>() {
@Override
public Collection<DependencyDescriptor> answer(final InvocationOnMock invocationOnMock) throws Throwable {
String gavString = (String) invocationOnMock.getArguments()[0];
Collection<DependencyDescriptor> result = new ArrayList<DependencyDescriptor>();
if (gavString.equals("junit:junit:4.11")) {
result.add(makeDependencyDescriptor("org.hamcrest", "hamcrest-core", "1.3"));
} else if (gavString.equals("org.guvnor:guvnor-web-app:5.0")) {
result.add(makeDependencyDescriptor("org.drools", "drools-core", "5.0"));
}
return result;
}
});
getJarWriter("junit:junit:4.11").addFile("org/junit/rules/SomeClass.class").addFile("org/junit/matchers/SomeClass.class").addFile("org/junit/doNotAddMe/SomeClass.txt").close();
getJarWriter("org.hamcrest:hamcrest-core:1.3").addFile("org/hamcrest/SomeClass.class").addFile("org/hamcrest/core/SomeClass.class").close();
service = new DependencyServiceImpl() {
@Override
protected MavenRepository getMavenRepository() {
return mavenRepository;
}
};
}
Aggregations