use of com.sun.enterprise.admin.servermgmt.xml.stringsubs.FileEntry in project Payara by payara.
the class TestFileEntryFactory method testGetFileFromDir.
/**
* Test get file by mentioning the path of an directory.
*/
@Test
public void testGetFileFromDir() {
FileEntry fileEntry = new FileEntry();
fileEntry.setName(_classFile.getParentFile().getAbsolutePath());
List<Substitutable> substitutables = _factory.getFileElements(fileEntry);
Assert.assertTrue(!substitutables.isEmpty());
boolean fileFound = false;
for (Substitutable substitutable : substitutables) {
if (substitutable.getName().endsWith(_classFile.getAbsolutePath())) {
fileFound = true;
break;
}
}
Assert.assertTrue(fileFound);
}
use of com.sun.enterprise.admin.servermgmt.xml.stringsubs.FileEntry in project Payara by payara.
the class TestFileEntryFactory method testGetFilesUsingWildCard.
/**
* Test get file by using wild card.
*/
@Test
public void testGetFilesUsingWildCard() {
FileEntry fileEntry = new FileEntry();
fileEntry.setName(_classFile.getParentFile().getAbsolutePath() + File.separator + "Test*");
List<Substitutable> substitutables = _factory.getFileElements(fileEntry);
Assert.assertTrue(!substitutables.isEmpty());
boolean validResult = true;
for (Substitutable substitutable : substitutables) {
if (!(new File(substitutable.getName())).getName().startsWith("Test")) {
validResult = false;
break;
}
}
Assert.assertTrue(validResult);
}
use of com.sun.enterprise.admin.servermgmt.xml.stringsubs.FileEntry in project Payara by payara.
the class TestFileEntryFactory method testGetFilesUsingWildCardBetweenPath.
/**
* Test get file by using wild card in between file path.
*/
@Test
public void testGetFilesUsingWildCardBetweenPath() {
FileEntry fileEntry = new FileEntry();
File parentFile = _classFile.getParentFile();
File grandParentFile = parentFile.getParentFile();
if (grandParentFile == null || !grandParentFile.exists()) {
return;
}
String className = this.getClass().getSimpleName() + ".class";
fileEntry.setName(grandParentFile.getAbsolutePath() + File.separator + "*" + File.separator + className);
List<Substitutable> substitutables = _factory.getFileElements(fileEntry);
Assert.assertTrue(!substitutables.isEmpty());
Assert.assertTrue(substitutables.size() == 1);
Assert.assertTrue((new File(substitutables.get(0).getName())).getName().equals(className));
}
Aggregations