Search in sources :

Example 1 with KettleFileRepositoryMeta

use of org.pentaho.di.repository.filerep.KettleFileRepositoryMeta in project pentaho-kettle by pentaho.

the class JobExportIT method setUp.

@Before
public void setUp() throws KettleException {
    KettleFileRepositoryMeta repositoryMeta = new KettleFileRepositoryMeta(FILE_REPOSITORY_ID, FILE_REPOSITORY_NAME, FILE_REPOSITORY_DESC, REPOSITORY_ROOT_DIR);
    repository = new KettleFileRepository();
    repository.init(repositoryMeta);
    repository.connect(null, null);
}
Also used : KettleFileRepositoryMeta(org.pentaho.di.repository.filerep.KettleFileRepositoryMeta) KettleFileRepository(org.pentaho.di.repository.filerep.KettleFileRepository) Before(org.junit.Before)

Example 2 with KettleFileRepositoryMeta

use of org.pentaho.di.repository.filerep.KettleFileRepositoryMeta in project pentaho-kettle by pentaho.

the class RepositoryConnectControllerTest method testRepoSwitch.

@Test
public void testRepoSwitch() throws Exception {
    when(pluginRegistry.loadClass(RepositoryPluginType.class, REPOSITORY_ID, Repository.class)).thenReturn(repository);
    KettleFileRepositoryMeta kettleFileRepositoryMeta = new KettleFileRepositoryMeta();
    kettleFileRepositoryMeta.setId(REPOSITORY_ID);
    kettleFileRepositoryMeta.setDescription(REPOSITORY_DESCRIPTION);
    kettleFileRepositoryMeta.setName(REPOSITORY_NAME);
    controller.connectToRepository(kettleFileRepositoryMeta);
    verify(spoon).closeAllJobsAndTransformations(true);
    when(spoon.getRepository()).thenReturn(repository);
    controller.connectToRepository(kettleFileRepositoryMeta);
    verify(spoon).closeRepository();
}
Also used : KettleFileRepositoryMeta(org.pentaho.di.repository.filerep.KettleFileRepositoryMeta) Test(org.junit.Test)

Example 3 with KettleFileRepositoryMeta

use of org.pentaho.di.repository.filerep.KettleFileRepositoryMeta in project pentaho-kettle by pentaho.

the class KettleFileRepositoryIT method testDatabaseRepository.

public void testDatabaseRepository() throws Exception {
    KettleEnvironment.init();
    String dirName = System.getProperty("java.io.tmpdir") + "/" + UUID.randomUUID();
    File dirFile = new File(dirName);
    if (!dirFile.mkdir()) {
        throw new KettleException("bad luck, directory '" + dirName + "' already exists and can't be used to put a file repository in it.");
    }
    System.out.println("Using folder '" + dirName + "' to store a file repository in.");
    try {
        repositoryMeta = new KettleFileRepositoryMeta("KettleFileRepository", "FileRep", "File repository", dirName);
        repository = new KettleFileRepository();
        repository.init(repositoryMeta);
        // Test connecting... (no security needed)
        // 
        repository.connect(null, null);
        assertTrue(repository.isConnected());
        // Test loading the directory tree
        // 
        tree = repository.loadRepositoryDirectoryTree();
        assertNotNull(tree);
        // Test directory creation
        // 
        RepositoryDirectoryInterface fooDirectory = repository.createRepositoryDirectory(tree, "foo");
        RepositoryDirectoryInterface barDirectory = repository.createRepositoryDirectory(fooDirectory, "bar");
        RepositoryDirectoryInterface samplesDirectory = repository.createRepositoryDirectory(fooDirectory, "samples");
        // Test directory path lookup
        RepositoryDirectoryInterface checkBar = tree.findDirectory("/foo/bar");
        assertNotNull(checkBar);
        assertTrue(checkBar.equals(barDirectory));
        // Save all the transformations samples.
        // 
        verifyTransformationSamples(samplesDirectory);
        verifyJobSamples(samplesDirectory);
        // Verify metastore functionality
        // 
        IMetaStore metaStore = repository.getMetaStore();
        KettleMetaStoreTestBase testBase = new KettleMetaStoreTestBase();
        testBase.testFunctionality(metaStore);
        // Test directory deletion
        repository.deleteRepositoryDirectory(samplesDirectory);
        RepositoryDirectoryInterface checkDelete = tree.findDirectory("/foo/bar/samples");
        assertNull(checkDelete);
        // Finally test disconnecting
        repository.disconnect();
        assertFalse(repository.isConnected());
    } catch (Exception e) {
        e.printStackTrace();
        throw new KettleException("Error during database repository unit testing", e);
    } finally {
        // Remove all the files and folders in the repository...
        // 
        FileUtils.deleteDirectory(dirFile);
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) KettleFileRepositoryMeta(org.pentaho.di.repository.filerep.KettleFileRepositoryMeta) File(java.io.File) IMetaStore(org.pentaho.metastore.api.IMetaStore) KettleFileRepository(org.pentaho.di.repository.filerep.KettleFileRepository) KettleException(org.pentaho.di.core.exception.KettleException)

Example 4 with KettleFileRepositoryMeta

use of org.pentaho.di.repository.filerep.KettleFileRepositoryMeta in project pentaho-kettle by pentaho.

the class GetRepositoryNamesTest method prepareFileRepository.

private static void prepareFileRepository() throws IOException, KettleException {
    baseDirName = Files.createTempDirectory("GetRepositoryNamesIT");
    RepositoryMeta repoMeta = new KettleFileRepositoryMeta(UUID.randomUUID().toString(), UUID.randomUUID().toString(), UUID.randomUUID().toString(), baseDirName.toString());
    repo = new KettleFileRepository();
    repo.init(repoMeta);
    repo.connect(null, null);
    // Populate
    RepositoryDirectoryInterface rootDir = repo.findDirectory("/");
    RepositoryDirectoryInterface subdir1 = new RepositoryDirectory(rootDir, "subdir1");
    repo.saveRepositoryDirectory(subdir1);
    TransMeta transMeta1 = new TransMeta();
    transMeta1.setName("Trans1");
    transMeta1.setRepositoryDirectory(subdir1);
    repo.save(transMeta1, null, null);
    JobMeta jobMeta1 = new JobMeta();
    jobMeta1.setName("Job1");
    jobMeta1.setRepositoryDirectory(subdir1);
    repo.save(jobMeta1, null, null);
    RepositoryDirectoryInterface subdir2 = new RepositoryDirectory(subdir1, "subdir2");
    repo.saveRepositoryDirectory(subdir2);
    TransMeta transMeta2 = new TransMeta();
    transMeta2.setName("Trans2");
    transMeta2.setRepositoryDirectory(subdir2);
    repo.save(transMeta2, null, null);
    JobMeta jobMeta2 = new JobMeta();
    jobMeta2.setName("Job2");
    jobMeta2.setRepositoryDirectory(subdir2);
    repo.save(jobMeta2, null, null);
}
Also used : KettleFileRepositoryMeta(org.pentaho.di.repository.filerep.KettleFileRepositoryMeta) RepositoryMeta(org.pentaho.di.repository.RepositoryMeta) RepositoryDirectoryInterface(org.pentaho.di.repository.RepositoryDirectoryInterface) JobMeta(org.pentaho.di.job.JobMeta) RepositoryDirectory(org.pentaho.di.repository.RepositoryDirectory) TransMeta(org.pentaho.di.trans.TransMeta) KettleFileRepositoryMeta(org.pentaho.di.repository.filerep.KettleFileRepositoryMeta) KettleFileRepository(org.pentaho.di.repository.filerep.KettleFileRepository)

Example 5 with KettleFileRepositoryMeta

use of org.pentaho.di.repository.filerep.KettleFileRepositoryMeta in project pentaho-kettle by pentaho.

the class RepositoryConnectControllerTest method testGetRepository.

@Test
public void testGetRepository() throws Exception {
    KettleFileRepositoryMeta kettleFileRepositoryMeta = new KettleFileRepositoryMeta();
    kettleFileRepositoryMeta.setId(REPOSITORY_ID);
    kettleFileRepositoryMeta.setDescription(REPOSITORY_DESCRIPTION);
    kettleFileRepositoryMeta.setName(REPOSITORY_NAME);
    when(repositoriesMeta.findRepository(REPOSITORY_NAME)).thenReturn(kettleFileRepositoryMeta);
    String output = controller.getRepository(REPOSITORY_NAME);
    assertEquals(true, output.contains(REPOSITORY_ID));
    assertEquals(true, output.contains(REPOSITORY_DESCRIPTION));
    assertEquals(true, output.contains(REPOSITORY_NAME));
}
Also used : KettleFileRepositoryMeta(org.pentaho.di.repository.filerep.KettleFileRepositoryMeta) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Aggregations

KettleFileRepositoryMeta (org.pentaho.di.repository.filerep.KettleFileRepositoryMeta)5 KettleFileRepository (org.pentaho.di.repository.filerep.KettleFileRepository)3 Test (org.junit.Test)2 File (java.io.File)1 Before (org.junit.Before)1 Matchers.anyString (org.mockito.Matchers.anyString)1 KettleException (org.pentaho.di.core.exception.KettleException)1 JobMeta (org.pentaho.di.job.JobMeta)1 RepositoryDirectory (org.pentaho.di.repository.RepositoryDirectory)1 RepositoryDirectoryInterface (org.pentaho.di.repository.RepositoryDirectoryInterface)1 RepositoryMeta (org.pentaho.di.repository.RepositoryMeta)1 TransMeta (org.pentaho.di.trans.TransMeta)1 IMetaStore (org.pentaho.metastore.api.IMetaStore)1