Skip to content

Commit

Permalink
Fixing Unit-tests, Adding tld parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
cuioss committed Jun 5, 2024
1 parent 169b523 commit c13578e
Show file tree
Hide file tree
Showing 13 changed files with 81 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,12 @@ void shouldRenderSpinnerOnlyOnceTest() {
component.decode(getFacesContext());
params.isCollapsed = false;
params.renderSpinner = false;
// --> render childs
// --> render children
component.setCollapsed(params.isCollapsed);
expected = getHtmlTree(params);
assertRenderResult(component, expected.getDocument());
params.isCollapsed = true;
// --> render childs also!
// --> render children also!
component.setCollapsed(params.isCollapsed);
expected = getHtmlTree(params);
assertRenderResult(component, expected.getDocument());
Expand Down Expand Up @@ -175,8 +175,7 @@ private static HtmlTreeBuilder getHtmlTree(final PanelParams params) {
void shouldRenderWithChildren() {
final var component = new BootstrapPanelComponent();
component.getChildren().add(new HtmlOutputText());
getComponentConfigDecorator().registerMockRendererForHtmlOutputText().registerBehavior(AjaxBehavior.BEHAVIOR_ID,
AjaxBehavior.class);
getComponentConfigDecorator().registerBehavior(AjaxBehavior.BEHAVIOR_ID, AjaxBehavior.class);
final var params = new PanelParams();
params.renderHeader = false;
params.isCollapsed = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ void shouldRenderMinimal() {
void shouldRenderWithChildren() {
final var component = new ControlGroupComponent();
component.getChildren().add(new HtmlOutputText());
getComponentConfigDecorator().registerMockRendererForHtmlOutputText();
final var expected = new HtmlTreeBuilder().withNode(Node.DIV).withStyleClass(CssBootstrap.FORM_GROUP)
.withNode(Node.DIV).withStyleClass(MINIMAL_COLUMN_CSS).withNode(Node.SPAN);
assertRenderResult(component, expected.getDocument());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ void shouldRenderMinimal() {
void shouldRenderWithChildren() {
var component = new RowComponent();
component.getChildren().add(new HtmlOutputText());
getComponentConfigDecorator().registerMockRendererForHtmlOutputText();
var expected = new HtmlTreeBuilder().withNode(Node.DIV).withStyleClass(CssBootstrap.ROW)
.withNode(Node.SPAN);
assertRenderResult(component, expected.getDocument());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,6 @@ protected UIComponent getComponent() {
public void configureComponents(final ComponentConfigDecorator decorator) {
decorator.registerUIComponent(CuiMessageComponent.class).registerRenderer(CuiMessageRenderer.class)
.registerUIComponent(Button.class)
.registerMockRenderer(BootstrapFamily.COMPONENT_FAMILY, BootstrapFamily.BUTTON_RENDERER)
.registerMockRenderer(JsfComponentIdentifier.INPUT_FAMILY, JsfComponentIdentifier.HIDDEN_RENDERER_TYPE)
.registerMockRendererForHtmlInputText();
.registerMockRenderer(BootstrapFamily.COMPONENT_FAMILY, BootstrapFamily.BUTTON_RENDERER);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
*/
package de.cuioss.jsf.bootstrap.layout.input;

import de.cuioss.jsf.api.components.JsfComponentIdentifier;
import de.cuioss.jsf.api.components.css.impl.StyleClassBuilderImpl;
import de.cuioss.jsf.api.components.html.AttributeName;
import de.cuioss.jsf.api.components.html.HtmlTreeBuilder;
Expand Down Expand Up @@ -102,7 +101,7 @@ void shouldRenderMinimal() {
.withAttribute(AttributeName.NAME, CLIENT_ID + COLON_INPUT)
.withAttribute(AttributeName.DISABLED, AttributeName.DISABLED.getContent())
.withAttribute(AttributeName.TYPE, "text").withStyleClass(CssBootstrap.FORM_CONTROL)
.currentHierarchyUp().withNode("InputGuardComponent")
.currentHierarchyUp().withNode(Node.INPUT)
.withAttribute(AttributeName.ID, CLIENT_ID + ":guarded_value")
.withAttribute(AttributeName.NAME, CLIENT_ID + ":guarded_value")
.withAttribute(AttributeName.VALUE, Boolean.TRUE.toString())
Expand Down Expand Up @@ -130,8 +129,6 @@ protected UIComponent getComponent() {
public void configureComponents(final ComponentConfigDecorator decorator) {
decorator.registerUIComponent(CuiMessageComponent.class).registerRenderer(CuiMessageRenderer.class)
.registerUIComponent(CommandButton.class)
.registerMockRenderer(BootstrapFamily.COMPONENT_FAMILY, BootstrapFamily.COMMAND_BUTTON_RENDERER)
.registerMockRenderer(JsfComponentIdentifier.INPUT_FAMILY, JsfComponentIdentifier.HIDDEN_RENDERER_TYPE)
.registerMockRendererForHtmlInputText();
.registerMockRenderer(BootstrapFamily.COMPONENT_FAMILY, BootstrapFamily.COMMAND_BUTTON_RENDERER);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,6 @@ void shouldRenderIdIfSetWithInputAndPrependFacet() {
final var prependId = "prependId";
prepend.setId(prependId);
final var prependClientId = LABELED_CONTAINER_ID + ":" + prependId;
getComponentConfigDecorator().registerMockRendererForHtmlOutputText();
component.getFacets().put("prepend", prepend);
component.processEvent(new PostAddToViewEvent(component));
component.processEvent(new PreRenderComponentEvent(component));
Expand Down Expand Up @@ -507,7 +506,6 @@ protected UIComponent getComponent() {

@Override
public void configureComponents(final ComponentConfigDecorator decorator) {
decorator.registerUIComponent(CuiMessageComponent.class).registerRenderer(CuiMessageRenderer.class)
.registerMockRendererForHtmlInputText();
decorator.registerUIComponent(CuiMessageComponent.class).registerRenderer(CuiMessageRenderer.class);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -417,8 +417,7 @@ public void configureComponents(final ComponentConfigDecorator decorator) {
.registerMockRenderer(UIOutcomeTarget.COMPONENT_FAMILY, "jakarta.faces.Link");
decorator.registerUIComponent(HtmlOutputLink.COMPONENT_TYPE, HtmlOutputLink.class)
.registerMockRenderer(UIOutput.COMPONENT_FAMILY, "jakarta.faces.Link");
decorator.registerUIComponent(HtmlOutputText.COMPONENT_TYPE, HtmlOutputText.class)
.registerMockRendererForHtmlOutputText();
decorator.registerUIComponent(HtmlOutputText.COMPONENT_TYPE, HtmlOutputText.class);
decorator.registerUIComponent(NavigationMenuComponent.class).registerRenderer(NavigationMenuRenderer.class);
decorator.registerUIComponent(IconComponent.class).registerRenderer(IconRenderer.class);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
</converter>
</tag>
<tag>
<description><![CDATA[Converter utilized for drop-down elements. The instanceMap is utilized for the
<description><![CDATA[Converter used for drop-down elements. The instanceMap is utilized for the
mapping between the serializable keys and the corresponding model classes. The keys must
be Serializable because they are sent to the client. The corresponding toString() method
must return a String representation that can be used for key lookup within the map. The
Expand Down
11 changes: 11 additions & 0 deletions modules/cui-jsf-dev/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,16 @@
<groupId>jaxen</groupId>
<artifactId>jaxen</artifactId>
</dependency>
<dependency>
<groupId>org.apache.myfaces.core</groupId>
<artifactId>myfaces-impl</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<classifier>jakarta</classifier>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package de.cuioss.jsf.dev.metadata;

import lombok.AccessLevel;
import lombok.Getter;
import lombok.RequiredArgsConstructor;

import static de.cuioss.jsf.dev.metadata.TagLib.JSF_2_2_FACELET_TAGLIB_NAMESPACE;
import static de.cuioss.jsf.dev.metadata.TagLib.JSF_4_0_FACELET_TAGLIB_NAMESPACE;

/**
* Isolates concrete {@link TagLib}s to be loaded.
*/
@RequiredArgsConstructor(access = AccessLevel.PRIVATE)
public enum LibraryTagLib {

CUI_CORE("/META-INF/cui-core.taglib.xml", JSF_4_0_FACELET_TAGLIB_NAMESPACE),
CUI_BOOTSTRAP("/META-INF/cui-core.taglib.xml", JSF_4_0_FACELET_TAGLIB_NAMESPACE),
PRIME_FACES("/META-INF/primefaces-p.taglib.xml", JSF_2_2_FACELET_TAGLIB_NAMESPACE),
OMNI_FACES("/META-INF/omnifaces-ui.taglib.xml", JSF_4_0_FACELET_TAGLIB_NAMESPACE),
MY_FACES("/META-INF/standard-faces-config.xml", JSF_4_0_FACELET_TAGLIB_NAMESPACE);

@Getter
private final String path;

@Getter
private final String namespace;

public TagLib load() {
return new TagLib(this.path, this.namespace);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package de.cuioss.jsf.dev.metadata;

import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.junit.jupiter.api.Assertions.assertNotNull;

class LibraryTagLibTest {

@Test
void shouldLoadTaglibs() {
for (var lib : LibraryTagLib.values()) {
var loaded = assertDoesNotThrow(lib::load, lib.name());
assertNotNull(loaded);
}
}

@Test
void shouldHandleMyFaces() {
var loaded = LibraryTagLib.MY_FACES.load();
assertNotNull(loaded);
System.out.println(loaded);
}
}
5 changes: 5 additions & 0 deletions modules/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@
<groupId>org.omnifaces</groupId>
<artifactId>omnifaces</artifactId>
</dependency>
<dependency>
<!-- For omnifaces -->
<groupId>jakarta.websocket</groupId>
<artifactId>jakarta.websocket-api</artifactId>
</dependency>
<!-- Test-->
<dependency>
<groupId>de.cuioss.test</groupId>
Expand Down
1 change: 0 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
<module>modules</module>
<module>web-modules</module>
</modules>

<profiles>
<profile>
<id>javadoc-mm-reporting</id>
Expand Down

0 comments on commit c13578e

Please sign in to comment.