Search in sources :

Example 1 with Group

use of com.sun.enterprise.admin.servermgmt.xml.stringsubs.Group in project Payara by payara.

the class StringSubstitutionEngine method substituteGroups.

@Override
public void substituteGroups(List<String> groups) throws StringSubstitutionException {
    if (!isValid(groups)) {
        throw new StringSubstitutionException(_strings.get("missingGroupIdentifiers"));
    }
    for (String groupId : groups) {
        Group group = findGroupById(groupId);
        if (group == null) {
            _logger.log(Level.WARNING, SLogger.MISSING_GROUP, groupId);
            continue;
        }
        doSubstitution(group);
    }
}
Also used : Group(com.sun.enterprise.admin.servermgmt.xml.stringsubs.Group) StringSubstitutionException(com.sun.enterprise.admin.servermgmt.stringsubs.StringSubstitutionException)

Example 2 with Group

use of com.sun.enterprise.admin.servermgmt.xml.stringsubs.Group in project Payara by payara.

the class TestStringSubstitutionFactory method testStringSubstitutorValidStream.

/**
 * Test String substitution for valid stream.
 */
@Test
public void testStringSubstitutorValidStream() {
    InputStream invalidStream = TestStringSubstitutionFactory.class.getClassLoader().getResourceAsStream(_stringSubsPath);
    try {
        StringSubstitutor substitutor = StringSubstitutionFactory.createStringSubstitutor(invalidStream);
        substitutor.setAttributePreprocessor(new AttributePreprocessorImpl(_substitutionMap));
        backUpTestFile();
        substitutor.substituteAll();
        for (Group group : substitutor.getStringSubsDefinition().getGroup()) {
            if (group.getId().equals(VALID_GROUP_ID)) {
                validateSubstitutedArchiveEntries(group);
                for (FileEntry fileEntry : group.getFileEntry()) {
                    if (fileEntry.getName().equalsIgnoreCase(_testFileName) && !validateTestFile(new File(fileEntry.getName()))) {
                        Assert.fail("Substitution failed in the test file.");
                        break;
                    }
                }
            }
        }
        restoreTestFile();
    } catch (StringSubstitutionException e) {
        Assert.fail("Exception occurred during string substitution process.", e);
    }
}
Also used : Group(com.sun.enterprise.admin.servermgmt.xml.stringsubs.Group) AttributePreprocessorImpl(com.sun.enterprise.admin.servermgmt.stringsubs.impl.AttributePreprocessorImpl) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) FileEntry(com.sun.enterprise.admin.servermgmt.xml.stringsubs.FileEntry) File(java.io.File) Test(org.testng.annotations.Test)

Aggregations

Group (com.sun.enterprise.admin.servermgmt.xml.stringsubs.Group)2 StringSubstitutionException (com.sun.enterprise.admin.servermgmt.stringsubs.StringSubstitutionException)1 AttributePreprocessorImpl (com.sun.enterprise.admin.servermgmt.stringsubs.impl.AttributePreprocessorImpl)1 FileEntry (com.sun.enterprise.admin.servermgmt.xml.stringsubs.FileEntry)1 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 InputStream (java.io.InputStream)1 Test (org.testng.annotations.Test)1