Skip to content

Commit

Permalink
Correct test
Browse files Browse the repository at this point in the history
  • Loading branch information
volosied committed Dec 18, 2024
1 parent efe6bd4 commit c73ab9a
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 32 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2015, 2023 IBM Corporation and others.
* Copyright (c) 2015, 2024 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
Expand Down Expand Up @@ -62,7 +62,8 @@ public static void setup() throws Exception {
"com.ibm.ws.jsf22.fat.componentrenderer.jsf599",
"com.ibm.ws.jsf22.fat.componentrenderer.jsf703",
isEE10 ? "com.ibm.ws.jsf22.fat.componentrenderer.jsf943.bean.faces40" : "com.ibm.ws.jsf22.fat.componentrenderer.jsf943.bean.jsf22",
"com.ibm.ws.jsf22.fat.componentrenderer.jsf997");
"com.ibm.ws.jsf22.fat.componentrenderer.jsf997",
"com.ibm.ws.jsf22.fat.componentrenderer.myfaces4117");

jsfTestServer2.startServer(c.getSimpleName() + ".log");
}
Expand Down Expand Up @@ -288,4 +289,28 @@ public void testJsf599() throws Exception {
assertTrue(page.asText().contains("I'm a place!"));
}
}

/*
* Two items are tested.
* 1) Default tag name is assigned when one is not specified on the @FacesComonent annotation.
* 2) Verifies a custom renderer is used when specified. This was added because we don't have any
* exisiting tests for the @FacesRenderer annotation. The component class doesn't render the element, but
* the renderer class does.
*
*/
@Test
public void testMyFaces4117AndRenderer() throws Exception {
try (WebClient webClient = new WebClient()) {

URL url = JSFUtils.createHttpUrl(jsfTestServer2, contextRoot, "myfaces4117.xhtml");
HtmlPage page = (HtmlPage) webClient.getPage(url);

if (page == null) {
Assert.fail("myfaces4117.xhtml did not render properly.");
}

assertTrue(page.getWebResponse().getContentAsString().contains("Renderer Works!"));
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -259,29 +259,6 @@ public void JSF22ComponentTester_TestCommandLinkOrder() throws Exception {
assertEquals(page.findElement(By.id("testOutput")).getText(), "test action called");
}

/*
* Two items are tested.
* 1) Default tag name is assigned when one is not specified on the @FacesComonent annotation.
* 2) Verifies a customer renderer is used when specified. This was added because we don't have any
* exisiting tests for the @FacesRenderer annotation. The component doesn't render the element, but
* the renderer.
*
*/
@Test
public void testMyFaces4117AndRenderer() throws Exception {
try (WebClient webClient = getWebClient()) {

URL url = JSFUtils.createHttpUrl(jsfTestServer2, contextRoot, "myfaces4117.xhtml");
HtmlPage page = (HtmlPage) webClient.getPage(url);

if (page == null) {
Assert.fail("myfaces4117.xhtml did not render properly.");
}

assertTrue(page.getWebResponse().getContentAsString().contains("Renderer Works!"));
}
}

/**
* Instantiate a WebClient instance that plays nicely with modern web features
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
* Copyright (c) 2015, 2019 IBM Corporation and others.
* Copyright (c) 2024 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* IBM Corporation - initial API and implementation
-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:f="http://xmlns.jcp.org/jsf/core"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:g="http://xmlns.jcp.org/jsf/composite/components">
xmlns:g="http://xmlns.jcp.org/jsf/component">
<h:body>
<g:testFacesComponent/>
</h:body>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import javax.faces.render.Renderer;

/*
* No testing FATS use @FacesRenderer, so this is added to verify the annotation works.
* No existing FATS use @FacesRenderer, so this is added to verify the annotation works.
*/
@FacesRenderer(componentFamily="test.component", rendererType="test.renderer")
public class TestFacesRenderer extends Renderer {
Expand Down Expand Up @@ -48,4 +48,4 @@ public void encodeEnd(FacesContext context, UIComponent component) throws IOExce
super.encodeEnd(context, component);
}

}
}

0 comments on commit c73ab9a

Please sign in to comment.