Search in sources :

Example 6 with FileEntry

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);
}
Also used : Substitutable(com.sun.enterprise.admin.servermgmt.stringsubs.Substitutable) FileEntry(com.sun.enterprise.admin.servermgmt.xml.stringsubs.FileEntry) Test(org.testng.annotations.Test)

Example 7 with FileEntry

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);
}
Also used : Substitutable(com.sun.enterprise.admin.servermgmt.stringsubs.Substitutable) FileEntry(com.sun.enterprise.admin.servermgmt.xml.stringsubs.FileEntry) File(java.io.File) Test(org.testng.annotations.Test)

Example 8 with FileEntry

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));
}
Also used : Substitutable(com.sun.enterprise.admin.servermgmt.stringsubs.Substitutable) FileEntry(com.sun.enterprise.admin.servermgmt.xml.stringsubs.FileEntry) File(java.io.File) Test(org.testng.annotations.Test)

Aggregations

FileEntry (com.sun.enterprise.admin.servermgmt.xml.stringsubs.FileEntry)8 Substitutable (com.sun.enterprise.admin.servermgmt.stringsubs.Substitutable)7 Test (org.testng.annotations.Test)7 File (java.io.File)3 StringSubstitutionException (com.sun.enterprise.admin.servermgmt.stringsubs.StringSubstitutionException)1 SubstitutionAlgorithm (com.sun.enterprise.admin.servermgmt.stringsubs.SubstitutionAlgorithm)1 AttributePreprocessorImpl (com.sun.enterprise.admin.servermgmt.stringsubs.impl.AttributePreprocessorImpl)1 Archive (com.sun.enterprise.admin.servermgmt.xml.stringsubs.Archive)1 ChangePair (com.sun.enterprise.admin.servermgmt.xml.stringsubs.ChangePair)1 ChangePairRef (com.sun.enterprise.admin.servermgmt.xml.stringsubs.ChangePairRef)1 Group (com.sun.enterprise.admin.servermgmt.xml.stringsubs.Group)1 ModeType (com.sun.enterprise.admin.servermgmt.xml.stringsubs.ModeType)1 FileInputStream (java.io.FileInputStream)1 InputStream (java.io.InputStream)1 HashMap (java.util.HashMap)1