-
Notifications
You must be signed in to change notification settings - Fork 117
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
28 changed files
with
1,703 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
105 changes: 105 additions & 0 deletions
105
impl/src/test/java/jakarta/faces/component/ActionListenerTestImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
/* | ||
* Copyright (c) 1997, 2020 Oracle and/or its affiliates. All rights reserved. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License v. 2.0, which is available at | ||
* http://www.eclipse.org/legal/epl-2.0. | ||
* | ||
* This Source Code may also be made available under the following Secondary | ||
* Licenses when the conditions for such availability set forth in the | ||
* Eclipse Public License v. 2.0 are satisfied: GNU General Public License, | ||
* version 2 with the GNU Classpath Exception, which is available at | ||
* https://www.gnu.org/software/classpath/license.html. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 | ||
*/ | ||
|
||
package jakarta.faces.component; | ||
|
||
import jakarta.faces.context.FacesContext; | ||
import jakarta.faces.event.ActionEvent; | ||
import jakarta.faces.event.ActionListener; | ||
|
||
/** | ||
* <p> | ||
* Test {@link ActionListener} implementation. | ||
* </p> | ||
*/ | ||
public class ActionListenerTestImpl implements ActionListener, StateHolder { | ||
|
||
public ActionListenerTestImpl() { | ||
} | ||
|
||
public ActionListenerTestImpl(String id) { | ||
this.id = id; | ||
} | ||
|
||
private String id = null; | ||
|
||
// ----------------------------------------------------------- Pubic Methods | ||
public String getId() { | ||
return this.id; | ||
} | ||
|
||
@Override | ||
public void processAction(ActionEvent event) { | ||
trace(getId() + "@" + event.getPhaseId().toString()); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object otherObj) { | ||
if (!(otherObj instanceof ActionListenerTestImpl)) { | ||
return false; | ||
} | ||
ActionListenerTestImpl other = (ActionListenerTestImpl) otherObj; | ||
if (null != id && null == other.id || null == id && null != other.id) { | ||
return false; | ||
} | ||
boolean idsAreEqual = true; | ||
if (null != id) { | ||
idsAreEqual = id.equals(other.id); | ||
} | ||
return idsAreEqual; | ||
} | ||
|
||
// ---------------------------------------------------- Static Trace Methods | ||
// Accumulated trace log | ||
private static final StringBuffer trace = new StringBuffer(); | ||
|
||
// Append to the current trace log (or clear if null) | ||
public static void trace(String text) { | ||
if (text == null) { | ||
trace.setLength(0); | ||
} else { | ||
trace.append('/'); | ||
trace.append(text); | ||
} | ||
} | ||
|
||
// Retrieve the current trace log | ||
public static String trace() { | ||
return trace.toString(); | ||
} | ||
|
||
// | ||
// methods from StateHolder | ||
// | ||
@Override | ||
public Object saveState(FacesContext context) { | ||
return id; | ||
} | ||
|
||
@Override | ||
public void restoreState(FacesContext context, Object state) { | ||
id = (String) state; | ||
} | ||
|
||
@Override | ||
public boolean isTransient() { | ||
return false; | ||
} | ||
|
||
@Override | ||
public void setTransient(boolean newT) { | ||
} | ||
} |
58 changes: 58 additions & 0 deletions
58
impl/src/test/java/jakarta/faces/component/CommandActionListenerTestImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* | ||
* Copyright (c) 1997, 2020 Oracle and/or its affiliates. All rights reserved. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License v. 2.0, which is available at | ||
* http://www.eclipse.org/legal/epl-2.0. | ||
* | ||
* This Source Code may also be made available under the following Secondary | ||
* Licenses when the conditions for such availability set forth in the | ||
* Eclipse Public License v. 2.0 are satisfied: GNU General Public License, | ||
* version 2 with the GNU Classpath Exception, which is available at | ||
* https://www.gnu.org/software/classpath/license.html. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 | ||
*/ | ||
|
||
package jakarta.faces.component; | ||
|
||
import jakarta.faces.event.ActionEvent; | ||
import jakarta.faces.event.ActionListener; | ||
|
||
/** | ||
* <p> | ||
* Test implementation of {@link ActionListener}. | ||
* </p> | ||
*/ | ||
public class CommandActionListenerTestImpl implements ActionListener { | ||
|
||
protected String actionListenerId = null; | ||
|
||
public CommandActionListenerTestImpl(String actionListenerId) { | ||
this.actionListenerId = actionListenerId; | ||
} | ||
|
||
@Override | ||
public void processAction(ActionEvent event) { | ||
trace(actionListenerId); | ||
} | ||
|
||
// ---------------------------------------------------- Static Trace Methods | ||
// Accumulated trace log | ||
private static StringBuffer trace = new StringBuffer(); | ||
|
||
// Append to the current trace log (or clear if null) | ||
public static void trace(String text) { | ||
if (text == null) { | ||
trace.setLength(0); | ||
} else { | ||
trace.append('/'); | ||
trace.append(text); | ||
} | ||
} | ||
|
||
// Retrieve the current trace log | ||
public static String trace() { | ||
return trace.toString(); | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
impl/src/test/java/jakarta/faces/component/CommandTestImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* Copyright (c) 1997, 2020 Oracle and/or its affiliates. All rights reserved. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License v. 2.0, which is available at | ||
* http://www.eclipse.org/legal/epl-2.0. | ||
* | ||
* This Source Code may also be made available under the following Secondary | ||
* Licenses when the conditions for such availability set forth in the | ||
* Eclipse Public License v. 2.0 are satisfied: GNU General Public License, | ||
* version 2 with the GNU Classpath Exception, which is available at | ||
* https://www.gnu.org/software/classpath/license.html. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 | ||
*/ | ||
|
||
package jakarta.faces.component; | ||
|
||
/** | ||
* <p> | ||
* Test {@link UICommand} subclass. | ||
* </p> | ||
*/ | ||
public class CommandTestImpl extends UICommand { | ||
|
||
public CommandTestImpl() { | ||
super(); | ||
} | ||
|
||
public CommandTestImpl(String id) { | ||
setId(id); | ||
} | ||
} |
122 changes: 122 additions & 0 deletions
122
impl/src/test/java/jakarta/faces/component/ComponentTestImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
/* | ||
* Copyright (c) 1997, 2020 Oracle and/or its affiliates. All rights reserved. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License v. 2.0, which is available at | ||
* http://www.eclipse.org/legal/epl-2.0. | ||
* | ||
* This Source Code may also be made available under the following Secondary | ||
* Licenses when the conditions for such availability set forth in the | ||
* Eclipse Public License v. 2.0 are satisfied: GNU General Public License, | ||
* version 2 with the GNU Classpath Exception, which is available at | ||
* https://www.gnu.org/software/classpath/license.html. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 | ||
*/ | ||
|
||
package jakarta.faces.component; | ||
|
||
import java.io.IOException; | ||
|
||
import jakarta.faces.context.FacesContext; | ||
|
||
/** | ||
* <p> | ||
* Test <code>UIComponent</code> for unit tests. | ||
* </p> | ||
*/ | ||
public class ComponentTestImpl extends UIComponentBase { | ||
|
||
public ComponentTestImpl() { | ||
this("test"); | ||
} | ||
|
||
public ComponentTestImpl(String componentId) { | ||
super(); | ||
setId(componentId); | ||
} | ||
|
||
public String getComponentType() { | ||
return "TestComponent"; | ||
} | ||
|
||
@Override | ||
public String getFamily() { | ||
return "Test"; | ||
} | ||
|
||
// -------------------------------------------------- Trace-Enabled Methods | ||
@Override | ||
public void decode(FacesContext context) { | ||
trace("d-" + getId()); | ||
super.decode(context); | ||
} | ||
|
||
@Override | ||
public void encodeBegin(FacesContext context) throws IOException { | ||
trace("eB-" + getId()); | ||
super.encodeBegin(context); | ||
} | ||
|
||
@Override | ||
public void encodeChildren(FacesContext context) throws IOException { | ||
trace("eC-" + getId()); | ||
super.encodeChildren(context); | ||
} | ||
|
||
@Override | ||
public void encodeEnd(FacesContext context) throws IOException { | ||
trace("eE-" + getId()); | ||
super.encodeEnd(context); | ||
} | ||
|
||
public void updateModel(FacesContext context) { | ||
trace("u-" + getId()); | ||
// super.updateModel(context); | ||
} | ||
|
||
@Override | ||
public void processDecodes(FacesContext context) { | ||
trace("pD-" + getId()); | ||
super.processDecodes(context); | ||
} | ||
|
||
@Override | ||
public void processValidators(FacesContext context) { | ||
trace("pV-" + getId()); | ||
super.processValidators(context); | ||
} | ||
|
||
@Override | ||
public void processUpdates(FacesContext context) { | ||
trace("pU-" + getId()); | ||
super.processUpdates(context); | ||
} | ||
|
||
public void callPushComponent(FacesContext context) { | ||
pushComponentToEL(context, null); | ||
} | ||
|
||
public void callPopComponent(FacesContext context) { | ||
popComponentFromEL(context); | ||
} | ||
|
||
// --------------------------------------------------- Static Trace Methods | ||
// Accumulated trace log | ||
private static StringBuffer trace = new StringBuffer(); | ||
|
||
// Append to the current trace log (or clear if null) | ||
public static void trace(String text) { | ||
if (text == null) { | ||
trace.setLength(0); | ||
} else { | ||
trace.append('/'); | ||
trace.append(text); | ||
} | ||
} | ||
|
||
// Retrieve the current trace log | ||
public static String trace() { | ||
return trace.toString(); | ||
} | ||
} |
Oops, something went wrong.