Re: [shale][mock] Weird ClassCastException

2006-02-17 Thread Craig McClanahan
On 2/17/06, Sean Schofield <[EMAIL PROTECTED]> wrote:
>
> Yeah this is the test.


Ah, you meant line 131 of AbstractJsfTestCase :-)

The only thing I can think of is maybe somehow the "real" API classes might
be getting injected into the classpath somehow.  Maybe you could try
temporarily changing the variable type to RenderKit instead of
MockRenderKit, and change the assignment to:

   renderKit = renderKitFactory.getRenderKit(null,
RenderKitFactory.HTML_BASIC_RENDER_KIT);
   System.out.println("Renderer type is " + renderKit.getClass
().getClassName());

and see if you get the MyFaces implementation?

Craig



---
> Battery: org.apache.myfaces.custom.tree2.HtmlTreeRendererTest
>
> ---
> Tests run: 2, Failures: 0, Errors: 2, Time elapsed: 0.046 sec
>
> testHideRootNodeServer(
> org.apache.myfaces.custom.tree2.HtmlTreeRendererTest)
> Time elapsed: 0.016 sec  <<< ERROR!
>
> [ stdout ] ---
>
>
>
> [ stderr ] ---
>
>
>
> [ stacktrace ] ---
>
> java.lang.ClassCastException
> at org.apache.shale.test.base.AbstractJsfTestCase.setUp(
> AbstractJsfTestCase.java:131)
> at org.apache.myfaces.custom.tree2.HtmlTreeRendererTest.setUp(
> HtmlTreeRendererTest.java:82)
> at junit.framework.TestCase.runBare(TestCase.java:125)
> at junit.framework.TestResult$1.protect(TestResult.java:106)
> at junit.framework.TestResult.runProtected(TestResult.java:124)
> at junit.framework.TestResult.run(TestResult.java:109)
> at junit.framework.TestCase.run(TestCase.java:118)
> at junit.framework.TestSuite.runTest(TestSuite.java:208)
> at junit.framework.TestSuite.run(TestSuite.java:203)
>
> On 2/17/06, Craig McClanahan <[EMAIL PROTECTED]> wrote:
> > On 2/17/06, Sean Schofield <[EMAIL PROTECTED]> wrote:
> > >
> > > I'm attaching my test case.  Its a test for the latest MyFaces trunk
> code.
> >
> >
> > Are you sure this is the failing test?  It doesn't seem to have the line
> you
> > quotes earlier.
> >
> > Craig
> >
> >
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>


Re: [shale][mock] Weird ClassCastException

2006-02-17 Thread Sean Schofield
Yeah this is the test.

---
Battery: org.apache.myfaces.custom.tree2.HtmlTreeRendererTest
---
Tests run: 2, Failures: 0, Errors: 2, Time elapsed: 0.046 sec

testHideRootNodeServer(org.apache.myfaces.custom.tree2.HtmlTreeRendererTest)
 Time elapsed: 0.016 sec  <<< ERROR!

[ stdout ] ---



[ stderr ] ---



[ stacktrace ] ---

java.lang.ClassCastException
at 
org.apache.shale.test.base.AbstractJsfTestCase.setUp(AbstractJsfTestCase.java:131)
at 
org.apache.myfaces.custom.tree2.HtmlTreeRendererTest.setUp(HtmlTreeRendererTest.java:82)
at junit.framework.TestCase.runBare(TestCase.java:125)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)

On 2/17/06, Craig McClanahan <[EMAIL PROTECTED]> wrote:
> On 2/17/06, Sean Schofield <[EMAIL PROTECTED]> wrote:
> >
> > I'm attaching my test case.  Its a test for the latest MyFaces trunk code.
>
>
> Are you sure this is the failing test?  It doesn't seem to have the line you
> quotes earlier.
>
> Craig
>
>

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: [shale][mock] Weird ClassCastException

2006-02-17 Thread Craig McClanahan
On 2/17/06, Sean Schofield <[EMAIL PROTECTED]> wrote:
>
> I'm attaching my test case.  Its a test for the latest MyFaces trunk code.


Are you sure this is the failing test?  It doesn't seem to have the line you
quotes earlier.

Craig


Re: [shale][mock] Weird ClassCastException

2006-02-17 Thread Sean Schofield
I'm attaching my test case.  Its a test for the latest MyFaces trunk code.
/*
 * Copyright 2006 The Apache Software Foundation.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.apache.myfaces.custom.tree2;

import org.apache.shale.test.base.AbstractJsfTestCase;
import org.apache.shale.test.mock.MockPrintWriter;
import org.apache.shale.test.mock.MockResponseWriter;
import org.apache.myfaces.renderkit.JSFAttr;
import org.apache.myfaces.config.MyfacesConfig;
import org.apache.commons.lang.StringUtils;

import junit.framework.Test;
import junit.framework.TestSuite;

import javax.faces.component.UIComponentBase;
import javax.faces.context.FacesContext;
import java.io.BufferedWriter;
import java.io.CharArrayWriter;
import java.io.IOException;
import java.util.Stack;

/**
 * - .. Root (0)
 * |
 * - .. A (0:0)
 * ||
 * |+ .. AA (0:0:0)
 * ||
 * |+ .. AB (0:0:1)
 * ||
 * |+ .. AC (0:0:2)
 * | | .. aca (0:0:2:0)
 * | | .. acb (0:0:2:1)
 * |
 * + .. B (0:1)
 * ||
 * |+ .. BA (0:1:0)
 * ||
 * |+ .. BB (0:1:1)
 * |
 * | .. C (0:2)
 * |
 * | .. d (0:3)
 */

public class HtmlTreeRendererTest extends AbstractJsfTestCase
{
private static final String DEFAULT_NODE_TYPE = "default";
private static final String TREE_ID = "some_foo_tree";

private HtmlTree tree;
private NodeSimulator nodeSim;

/**
 * Constructor
 * @param name String
 */
public HtmlTreeRendererTest(String name)
{
super(name);
}

/**
 * See abstract class
 */
public void setUp()
{
super.setUp();

tree = new HtmlTree();
tree.setId(TREE_ID);

nodeSim = new NodeSimulator();

// additional setup not provided automatically by the shale mock stuff
facesContext.getExternalContext().getApplicationMap().put(MyfacesConfig.class.getName(), new MyfacesConfig());
facesContext.setResponseWriter(new MockResponseWriter(new BufferedWriter(new CharArrayWriter()), null, null));

// set up the test tree with the standard data
TreeNodeBase Root_node = new TreeNodeBase(DEFAULT_NODE_TYPE, "Root", "Root", false);

TreeNodeBase A_node = new TreeNodeBase(DEFAULT_NODE_TYPE, "A", "A", false);
A_node.getChildren().add(new TreeNodeBase(DEFAULT_NODE_TYPE, "AA", "AA", false));
A_node.getChildren().add(new TreeNodeBase(DEFAULT_NODE_TYPE, "AB", "AB", false));
TreeNodeBase AC_node = new TreeNodeBase(DEFAULT_NODE_TYPE, "AC", "AC", false);
AC_node.getChildren().add(new TreeNodeBase(DEFAULT_NODE_TYPE, "aca", "aca", true));
AC_node.getChildren().add(new TreeNodeBase(DEFAULT_NODE_TYPE, "acb", "acb", true));
A_node.getChildren().add(AC_node);
Root_node.getChildren().add(A_node);

TreeNodeBase B_node = new TreeNodeBase(DEFAULT_NODE_TYPE, "B", "B", false);
B_node.getChildren().add(new TreeNodeBase(DEFAULT_NODE_TYPE, "BA", "BA", false));
B_node.getChildren().add(new TreeNodeBase(DEFAULT_NODE_TYPE, "BB", "BB", false));
Root_node.getChildren().add(B_node);

TreeNodeBase C_node = new TreeNodeBase(DEFAULT_NODE_TYPE, "C", "C", false);
Root_node.getChildren().add(C_node);

TreeNodeBase d_node = new TreeNodeBase(DEFAULT_NODE_TYPE, "d", "d", true);
Root_node.getChildren().add(d_node);

tree.setValue(Root_node);

// the tree needs a default facet - use a node simulator instead of the usual components
// so we can detect when a node is rendered
tree.getFacets().put(DEFAULT_NODE_TYPE, nodeSim);

// set up the renderer for the component.  with mock stuff we don't have faces config doing this for us
renderKit.addRenderer(HtmlTree.COMPONENT_FAMILY, HtmlTree.COMPONENT_TYPE, new HtmlTreeRenderer());
}

/**
 * Tests the option of hiding the root node (with server side toggling option)
 * @throws Exception
 */
public void testHideRootNodeServer() throws Exception
{
tree.getAttributes().put(JSFAttr.CLIENT_SIDE_TOGGLE, Boolean.FALSE);
tree.getAttributes().put(JSFAttr.SHOW_ROOT_NODE, Boolean.FALSE);

HtmlTreeRenderer treeRenderer = new HtmlTreeRenderer();
treeRenderer.encodeChildren(facesContext, tree);

// we expect the nodes to come off the stack in the reverse order in which they were added
Stack nodeStack = nodeSim.nodeStack;
int numRendered = nodeStack

[shale][mock] Weird ClassCastException

2006-02-17 Thread Sean Schofield
I am trying to use the mock stuff in my app.  The test works fine in
my IDE (1.4.2_04-b05) but does not run in maven (1.4.2_08-b03.)

Specifically, the class cast exception is on line 131:

renderKit = (MockRenderKit)
  renderKitFactory.getRenderKit(null,
RenderKitFactory.HTML_BASIC_RENDER_KIT);

Any ideas on what might be going on here?  I'm puzzled why the maven
approach yields a different result.  I don't think its the JDK but who
knows?  My IDE is using the same snapshot of shale as maven is using.

Sean

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]