Example usage for org.apache.commons.lang3 StringUtils capitalize

List of usage examples for org.apache.commons.lang3 StringUtils capitalize

Introduction

In this page you can find the example usage for org.apache.commons.lang3 StringUtils capitalize.

Prototype

public static String capitalize(final String str) 

Source Link

Document

Capitalizes a String changing the first letter to title case as per Character#toTitleCase(char) .

Usage

From source file:org.auraframework.def.BaseComponentDefTest.java

public void testAppendDependenciesWithAllReferences() throws QuickFixException {
    DefDescriptor<T> parentDesc = addSourceAutoCleanup(getDefClass(),
            String.format(baseTag, "extensible='true'", ""));
    DefDescriptor<ComponentDef> childDesc = addSourceAutoCleanup(ComponentDef.class, "<aura:component/>");
    DefDescriptor<InterfaceDef> intfDesc = addSourceAutoCleanup(InterfaceDef.class, "<aura:interface/>");
    DefDescriptor<EventDef> eventDesc = addSourceAutoCleanup(EventDef.class,
            "<aura:event type='component' support='GA'/>");
    DefDescriptor<ProviderDef> providerDesc = DefDescriptorImpl
            .getInstance("java://org.auraframework.impl.java.provider.ConcreteProvider", ProviderDef.class);

    DefDescriptor<T> cmpDesc = addSourceAutoCleanup(getDefClass(),
            String.format(baseTag,
                    String.format("extends='%s' implements='%s' provider='%s'", parentDesc.getDescriptorName(),
                            intfDesc.getDescriptorName(), providerDesc),
                    String.format("<%s/><aura:registerevent name='evt' type='%s'/>",
                            childDesc.getDescriptorName(), eventDesc.getDescriptorName())));

    DefDescriptor<ModelDef> modelDesc = DefDescriptorImpl.getAssociateDescriptor(cmpDesc, ModelDef.class,
            DefDescriptor.JAVASCRIPT_PREFIX);
    addSourceAutoCleanup(modelDesc, "{obj:{}}");
    DefDescriptor<ControllerDef> controllerDesc = DefDescriptorImpl.getAssociateDescriptor(cmpDesc,
            ControllerDef.class, DefDescriptor.JAVASCRIPT_PREFIX);
    addSourceAutoCleanup(controllerDesc, "{hi:function(){}}");

    DefDescriptor<RendererDef> renderDesc = DefDescriptorImpl.getAssociateDescriptor(cmpDesc, RendererDef.class,
            DefDescriptor.JAVASCRIPT_PREFIX);
    addSourceAutoCleanup(renderDesc, "({render:function(c){return this.superRender();}})");

    DefDescriptor<HelperDef> helperDesc = DefDescriptorImpl.getAssociateDescriptor(cmpDesc, HelperDef.class,
            DefDescriptor.JAVASCRIPT_PREFIX);
    addSourceAutoCleanup(helperDesc, "({help:function(){}})");

    DefDescriptor<StyleDef> styleDesc = Aura.getDefinitionService().getDefDescriptor(cmpDesc,
            DefDescriptor.CSS_PREFIX, StyleDef.class);
    String className = cmpDesc.getNamespace() + StringUtils.capitalize(cmpDesc.getName());
    addSourceAutoCleanup(styleDesc, String.format(".%s {font-style:italic;}", className));
    DefDescriptor<NamespaceDef> namespaceDesc = Aura.getDefinitionService().getDefDescriptor(
            String.format("%s://%s", DefDescriptor.MARKUP_PREFIX, styleDesc.getNamespace()),
            NamespaceDef.class);
    addSourceAutoCleanup(namespaceDesc, "<aura:namespace/>");

    Set<DefDescriptor<?>> dependencies = new HashSet<>();
    cmpDesc.getDef().appendDependencies(dependencies);

    @SuppressWarnings("unchecked")
    Set<DefDescriptor<?>> expected = Sets.newHashSet(parentDesc, childDesc, intfDesc, providerDesc, modelDesc,
            controllerDesc, eventDesc, styleDesc, renderDesc, helperDesc);
    if (!dependencies.containsAll(expected)) {
        fail(String.format("missing dependencies - EXPECTED: %s, ACTUAL: %s", expected, dependencies));
    }/*w ww .  j  a  va 2  s.c  om*/
    if (!expected.containsAll(dependencies)) {
        fail(String.format("extra dependencies - EXPECTED: %s, ACTUAL: %s", expected, dependencies));
    }
}

From source file:org.auraframework.impl.ClientOutOfSyncUITest.java

@ThreadHostileTest("NamespaceDef modification affects namespace")
public void testGetClientRenderingAfterStyleChange() throws Exception {
    DefDescriptor<ComponentDef> cmpDesc = addSourceAutoCleanup(ComponentDef.class,
            String.format(baseComponentTag, "", "<div id='out'>hi</div>"));
    String className = cmpDesc.getNamespace() + StringUtils.capitalize(cmpDesc.getName());
    DefDescriptor<?> styleDesc = Aura.getDefinitionService().getDefDescriptor(cmpDesc, DefDescriptor.CSS_PREFIX,
            StyleDef.class);
    addSourceAutoCleanup(styleDesc, String.format(".%s {font-style:italic;}", className));
    addSourceAutoCleanup(Aura.getDefinitionService().getDefDescriptor(
            String.format("%s://%s", DefDescriptor.MARKUP_PREFIX, styleDesc.getNamespace()),
            NamespaceDef.class), "<aura:namespace/>");
    open(cmpDesc);//w  w  w.ja va2s  . co  m
    assertEquals("italic",
            auraUITestingUtil.findDomElement(By.cssSelector("." + className)).getCssValue("font-style"));
    updateStringSource(styleDesc, String.format(".%s {font-style:normal;}", className));
    open(cmpDesc);
    assertEquals("normal",
            auraUITestingUtil.findDomElement(By.cssSelector("." + className)).getCssValue("font-style"));
}

From source file:org.auraframework.impl.ClientOutOfSyncUITest.java

@ThreadHostileTest("NamespaceDef modification affects namespace")
public void testGetClientRenderingAfterThemeChange() throws Exception {
    DefDescriptor<ComponentDef> cmpDesc = addSourceAutoCleanup(ComponentDef.class,
            String.format(baseComponentTag, "", "<div id='out'>hi</div>"));
    String className = cmpDesc.getNamespace() + StringUtils.capitalize(cmpDesc.getName());
    DefDescriptor<?> styleDesc = Aura.getDefinitionService().getDefDescriptor(cmpDesc, DefDescriptor.CSS_PREFIX,
            StyleDef.class);
    addSourceAutoCleanup(styleDesc, String.format(".%s {font-size:t(fsize);}", className));
    DefDescriptor<?> themeDesc = Aura.getDefinitionService().getDefDescriptor(String.format("%s://%s:%sTheme",
            DefDescriptor.MARKUP_PREFIX, cmpDesc.getNamespace(), cmpDesc.getNamespace()), ThemeDef.class);
    addSourceAutoCleanup(themeDesc, "<aura:theme><aura:var name='fsize' value='8px'/></aura:theme>");
    open(cmpDesc);/*from w  w w. j ava2 s  .c  o  m*/
    assertEquals("8px",
            auraUITestingUtil.findDomElement(By.cssSelector("." + className)).getCssValue("font-size"));
    updateStringSource(themeDesc, "<aura:theme><aura:var name='fsize' value='66px'/></aura:theme>");
    open(cmpDesc);
    assertEquals("66px",
            auraUITestingUtil.findDomElement(By.cssSelector("." + className)).getCssValue("font-size"));
}

From source file:org.auraframework.impl.ClientOutOfSyncUITest.java

@ThreadHostileTest("NamespaceDef modification affects namespace")
public void testPostAfterStyleChange() throws Exception {
    DefDescriptor<ComponentDef> cmpDesc = setupTriggerComponent("", "<div id='out'>hi</div>");
    String className = cmpDesc.getNamespace() + StringUtils.capitalize(cmpDesc.getName());
    DefDescriptor<?> styleDesc = Aura.getDefinitionService().getDefDescriptor(cmpDesc, DefDescriptor.CSS_PREFIX,
            StyleDef.class);
    addSourceAutoCleanup(styleDesc, String.format(".%s {font-style:italic;}", className));
    addSourceAutoCleanup(Aura.getDefinitionService().getDefDescriptor(
            String.format("%s://%s", DefDescriptor.MARKUP_PREFIX, styleDesc.getNamespace()),
            NamespaceDef.class), "<aura:namespace/>");
    open(cmpDesc);/* w w w  . ja v  a  2s  .c o m*/
    assertEquals("italic",
            auraUITestingUtil.findDomElement(By.cssSelector("." + className)).getCssValue("font-style"));
    updateStringSource(styleDesc, String.format(".%s {font-style:normal;}", className));
    triggerServerAction();
    auraUITestingUtil.waitForElementFunction(By.cssSelector("." + className),
            new Function<WebElement, Boolean>() {
                @Override
                public Boolean apply(WebElement element) {
                    return "normal".equals(element.getCssValue("font-style"));
                }
            });
}

From source file:org.auraframework.impl.ClientOutOfSyncUITest.java

/**
 * A routine to do _many_ iterations of a client out of sync test.
 * //from w w  w . jav  a  2s.c o  m
 * This test really shouldn't be run unless one of the tests is flapping. It lets you iterate a number of times to
 * force a failure.... No guarantees, but without the _waitingForReload check in the trigger function, this will
 * cause a failure in very few iterations.
 */
@ThreadHostileTest("NamespaceDef modification affects namespace")
public void _testPostManyAfterStyleChange() throws Exception {
    DefDescriptor<ComponentDef> cmpDesc = setupTriggerComponent("", "<div id='out'>hi</div>");
    String className = cmpDesc.getNamespace() + StringUtils.capitalize(cmpDesc.getName());
    DefDescriptor<?> styleDesc = Aura.getDefinitionService().getDefDescriptor(cmpDesc, DefDescriptor.CSS_PREFIX,
            StyleDef.class);
    addSourceAutoCleanup(styleDesc, String.format(".%s {font-style:italic;}", className));
    addSourceAutoCleanup(Aura.getDefinitionService().getDefDescriptor(
            String.format("%s://%s", DefDescriptor.MARKUP_PREFIX, styleDesc.getNamespace()),
            NamespaceDef.class), "<aura:namespace/>");
    open(cmpDesc);
    assertEquals("italic",
            auraUITestingUtil.findDomElement(By.cssSelector("." + className)).getCssValue("font-style"));
    for (int i = 0; i < 1000; i++) {
        updateStringSource(styleDesc, String.format(".%s {font-style:normal;}", className));
        triggerServerAction();
        auraUITestingUtil.waitForElementFunction(By.cssSelector("." + className),
                new Function<WebElement, Boolean>() {
                    @Override
                    public Boolean apply(WebElement element) {
                        return "normal".equals(element.getCssValue("font-style"));
                    }
                });
        updateStringSource(styleDesc, String.format(".%s {font-style:italic;}", className));
        triggerServerAction();
        auraUITestingUtil.waitForElementFunction(By.cssSelector("." + className),
                new Function<WebElement, Boolean>() {
                    @Override
                    public Boolean apply(WebElement element) {
                        return "italic".equals(element.getCssValue("font-style"));
                    }
                });
    }
}

From source file:org.auraframework.impl.ClientOutOfSyncUITest.java

@ThreadHostileTest("NamespaceDef modification affects namespace")
public void testPostAfterThemeChange() throws Exception {
    DefDescriptor<ComponentDef> cmpDesc = setupTriggerComponent("", "<div id='out'>hi</div>");
    String className = cmpDesc.getNamespace() + StringUtils.capitalize(cmpDesc.getName());
    DefDescriptor<?> styleDesc = Aura.getDefinitionService().getDefDescriptor(cmpDesc, DefDescriptor.CSS_PREFIX,
            StyleDef.class);
    addSourceAutoCleanup(styleDesc, String.format(".%s {font-size:t(fsize);}", className));
    DefDescriptor<?> themeDesc = Aura.getDefinitionService().getDefDescriptor(String.format("%s://%s:%sTheme",
            DefDescriptor.MARKUP_PREFIX, cmpDesc.getNamespace(), cmpDesc.getNamespace()), ThemeDef.class);
    addSourceAutoCleanup(themeDesc, "<aura:theme><aura:var name='fsize' value='8px'/></aura:theme>");
    open(cmpDesc);/*from ww w  .  ja va 2 s  . c o m*/
    assertEquals("8px",
            auraUITestingUtil.findDomElement(By.cssSelector("." + className)).getCssValue("font-size"));
    updateStringSource(themeDesc, "<aura:theme><aura:var name='fsize' value='66px'/></aura:theme>");
    triggerServerAction();
    auraUITestingUtil.waitForElementFunction(By.cssSelector("." + className),
            new Function<WebElement, Boolean>() {
                @Override
                public Boolean apply(WebElement element) {
                    return "66px".equals(element.getCssValue("font-size"));
                }
            });
}

From source file:org.auraframework.impl.root.component.BaseComponentDefTest.java

@Test
public void testAppendDependenciesWithAllReferences() throws QuickFixException {
    DefDescriptor<T> parentDesc = addSourceAutoCleanup(getDefClass(),
            String.format(baseTag, "extensible='true'", ""));
    DefDescriptor<ComponentDef> childDesc = addSourceAutoCleanup(ComponentDef.class, "<aura:component/>");
    DefDescriptor<InterfaceDef> intfDesc = addSourceAutoCleanup(InterfaceDef.class, "<aura:interface/>");
    DefDescriptor<EventDef> eventDesc = addSourceAutoCleanup(EventDef.class,
            "<aura:event type='component' support='GA'/>");
    DefDescriptor<ProviderDef> providerDesc = definitionService.getDefDescriptor(
            "java://org.auraframework.impl.java.provider.ConcreteProvider", ProviderDef.class);

    DefDescriptor<T> cmpDesc = addSourceAutoCleanup(getDefClass(),
            String.format(baseTag,
                    String.format("extends='%s' implements='%s' provider='%s'", parentDesc.getDescriptorName(),
                            intfDesc.getDescriptorName(), providerDesc),
                    String.format("<%s/><aura:registerevent name='evt' type='%s'/>",
                            childDesc.getDescriptorName(), eventDesc.getDescriptorName())));

    DefDescriptor<ModelDef> modelDesc = DefDescriptorImpl.getAssociateDescriptor(cmpDesc, ModelDef.class,
            DefDescriptor.JAVASCRIPT_PREFIX);
    addSourceAutoCleanup(modelDesc, "{obj:{}}");
    DefDescriptor<ControllerDef> controllerDesc = DefDescriptorImpl.getAssociateDescriptor(cmpDesc,
            ControllerDef.class, DefDescriptor.JAVASCRIPT_PREFIX);
    addSourceAutoCleanup(controllerDesc, "{hi:function(){}}");

    DefDescriptor<RendererDef> renderDesc = DefDescriptorImpl.getAssociateDescriptor(cmpDesc, RendererDef.class,
            DefDescriptor.JAVASCRIPT_PREFIX);
    addSourceAutoCleanup(renderDesc, "({render:function(c){return this.superRender();}})");

    DefDescriptor<HelperDef> helperDesc = DefDescriptorImpl.getAssociateDescriptor(cmpDesc, HelperDef.class,
            DefDescriptor.JAVASCRIPT_PREFIX);
    addSourceAutoCleanup(helperDesc, "({help:function(){}})");

    DefDescriptor<StyleDef> styleDesc = definitionService.getDefDescriptor(cmpDesc, DefDescriptor.CSS_PREFIX,
            StyleDef.class);
    String className = cmpDesc.getNamespace() + StringUtils.capitalize(cmpDesc.getName());
    addSourceAutoCleanup(styleDesc, String.format(".%s {font-style:italic;}", className));

    Set<DefDescriptor<?>> dependencies = new HashSet<>();
    definitionService.getDefinition(cmpDesc).appendDependencies(dependencies);

    Set<DefDescriptor<?>> expected = Sets.newHashSet(parentDesc, childDesc, intfDesc, providerDesc, modelDesc,
            controllerDesc, eventDesc, styleDesc, renderDesc, helperDesc);
    if (!dependencies.containsAll(expected)) {
        fail(String.format("missing dependencies - EXPECTED: %s, ACTUAL: %s", expected, dependencies));
    }/*from w ww  .  j  a  v  a 2  s.c o  m*/
    if (!expected.containsAll(dependencies)) {
        fail(String.format("extra dependencies - EXPECTED: %s, ACTUAL: %s", expected, dependencies));
    }
}

From source file:org.auraframework.integration.test.ClientOutOfSyncUITest.java

@ThreadHostileTest("NamespaceDef modification affects namespace")
@Test//from  w  w  w . j a  v a 2s .c  o m
public void testGetClientRenderingAfterStyleChange() throws Exception {
    DefDescriptor<ComponentDef> cmpDesc = addSourceAutoCleanup(ComponentDef.class,
            String.format(baseComponentTag, "", "<div id='out'>hi</div>"));
    String className = cmpDesc.getNamespace() + StringUtils.capitalize(cmpDesc.getName());
    DefDescriptor<?> styleDesc = definitionService.getDefDescriptor(cmpDesc, DefDescriptor.CSS_PREFIX,
            StyleDef.class);
    addSourceAutoCleanup(styleDesc, String.format(".%s {font-style:italic;}", className));
    open(cmpDesc);
    assertEquals("italic",
            getAuraUITestingUtil().findDomElement(By.cssSelector("." + className)).getCssValue("font-style"));
    updateStringSource(styleDesc, String.format(".%s {font-style:normal;}", className));
    open(cmpDesc);
    assertEquals("normal",
            getAuraUITestingUtil().findDomElement(By.cssSelector("." + className)).getCssValue("font-style"));
}

From source file:org.auraframework.integration.test.ClientOutOfSyncUITest.java

@ThreadHostileTest("NamespaceDef modification affects namespace")
@Test//from w  w w  .j a  v a2s.co  m
public void testGetClientRenderingAfterTokensChange() throws Exception {
    DefDescriptor<ComponentDef> cmpDesc = addSourceAutoCleanup(ComponentDef.class,
            String.format(baseComponentTag, "", "<div id='out'>hi</div>"));
    String className = cmpDesc.getNamespace() + StringUtils.capitalize(cmpDesc.getName());
    DefDescriptor<?> styleDesc = definitionService.getDefDescriptor(cmpDesc, DefDescriptor.CSS_PREFIX,
            StyleDef.class);
    addSourceAutoCleanup(styleDesc, String.format(".%s {font-size:t(fsize);}", className));
    DefDescriptor<?> tokensDesc = definitionService.getDefDescriptor(String.format("%s://%s:%sNamespace",
            DefDescriptor.MARKUP_PREFIX, cmpDesc.getNamespace(), cmpDesc.getNamespace()), TokensDef.class);
    addSourceAutoCleanup(tokensDesc, "<aura:tokens><aura:token name='fsize' value='8px'/></aura:tokens>");
    open(cmpDesc);
    assertEquals("8px",
            getAuraUITestingUtil().findDomElement(By.cssSelector("." + className)).getCssValue("font-size"));
    updateStringSource(tokensDesc, "<aura:tokens><aura:token name='fsize' value='66px'/></aura:tokens>");
    open(cmpDesc);
    assertEquals("66px",
            getAuraUITestingUtil().findDomElement(By.cssSelector("." + className)).getCssValue("font-size"));
}

From source file:org.auraframework.integration.test.ClientOutOfSyncUITest.java

@ThreadHostileTest("NamespaceDef modification affects namespace")
@Test//from  w w  w .  ja va2s  .co  m
public void testPostAfterStyleChange() throws Exception {
    DefDescriptor<ComponentDef> cmpDesc = setupTriggerComponent("", "<div id='out'>hi</div>");
    String className = cmpDesc.getNamespace() + StringUtils.capitalize(cmpDesc.getName());
    DefDescriptor<?> styleDesc = definitionService.getDefDescriptor(cmpDesc, DefDescriptor.CSS_PREFIX,
            StyleDef.class);
    addSourceAutoCleanup(styleDesc, String.format(".%s {font-style:italic;}", className));
    open(cmpDesc);
    assertEquals("italic",
            getAuraUITestingUtil().findDomElement(By.cssSelector("." + className)).getCssValue("font-style"));
    updateStringSource(styleDesc, String.format(".%s {font-style:normal;}", className));
    triggerServerAction();
    getAuraUITestingUtil().waitForElementFunction(By.cssSelector("." + className),
            new Function<WebElement, Boolean>() {
                @Override
                public Boolean apply(WebElement element) {
                    return "normal".equals(element.getCssValue("font-style"));
                }
            });
}