Search in sources :

Example 1 with TempFiles

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);
}
Also used : Weld(org.jboss.weld.environment.se.Weld) Bean(javax.enterprise.inject.spi.Bean) SimpleFileSystemProvider(org.uberfire.java.nio.fs.file.SimpleFileSystemProvider) CreationalContext(javax.enterprise.context.spi.CreationalContext) Paths(org.uberfire.backend.server.util.Paths) BeanManager(javax.enterprise.inject.spi.BeanManager) File(java.io.File) TempFiles(org.guvnor.test.TempFiles) Before(org.junit.Before)

Example 2 with TempFiles

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);
}
Also used : Weld(org.jboss.weld.environment.se.Weld) Bean(javax.enterprise.inject.spi.Bean) SimpleFileSystemProvider(org.uberfire.java.nio.fs.file.SimpleFileSystemProvider) CreationalContext(javax.enterprise.context.spi.CreationalContext) Paths(org.uberfire.backend.server.util.Paths) BeanManager(javax.enterprise.inject.spi.BeanManager) File(java.io.File) TempFiles(org.guvnor.test.TempFiles) Before(org.junit.Before)

Example 3 with TempFiles

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;
        }
    };
}
Also used : MavenRepository(org.appformer.maven.integration.MavenRepository) DependencyDescriptor(org.appformer.maven.integration.DependencyDescriptor) InvocationOnMock(org.mockito.invocation.InvocationOnMock) Collection(java.util.Collection) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) TempFiles(org.guvnor.test.TempFiles) Before(org.junit.Before)

Aggregations

TempFiles (org.guvnor.test.TempFiles)3 Before (org.junit.Before)3 File (java.io.File)2 CreationalContext (javax.enterprise.context.spi.CreationalContext)2 Bean (javax.enterprise.inject.spi.Bean)2 BeanManager (javax.enterprise.inject.spi.BeanManager)2 Weld (org.jboss.weld.environment.se.Weld)2 Paths (org.uberfire.backend.server.util.Paths)2 SimpleFileSystemProvider (org.uberfire.java.nio.fs.file.SimpleFileSystemProvider)2 Collection (java.util.Collection)1 DependencyDescriptor (org.appformer.maven.integration.DependencyDescriptor)1 MavenRepository (org.appformer.maven.integration.MavenRepository)1 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)1 InvocationOnMock (org.mockito.invocation.InvocationOnMock)1