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);
}
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();
}
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);
}
}
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);
}
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));
}
Aggregations