You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lo...@apache.org on 2010/06/11 18:36:17 UTC
svn commit: r953759 - in /myfaces/tobago/trunk: tobago-core/
tobago-core/src/test/java/org/apache/myfaces/tobago/component/
tobago-core/src/test/java/org/apache/myfaces/tobago/internal/context/
tobago-core/src/test/java/org/apache/myfaces/tobago/intern...
Author: lofwyr
Date: Fri Jun 11 16:36:16 2010
New Revision: 953759
URL: http://svn.apache.org/viewvc?rev=953759&view=rev
Log:
clean up testing classes
- add new base class for JSF-tests (with proper initilized objects)
- removing dependencies to shale (using myfaces-test12 instead)
- removing Mock classes for JSF of Tobago (using myfaces-test12 instead)
- moving other test helper from tobago-jsf-compat to tobago-core
- remove duplicate code
Added:
myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/mock/
myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/mock/faces/
myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/mock/faces/AbstractTobagoTestBase.java
myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/mock/faces/MockRenderersConfig.java
myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/mock/faces/MockTheme.java
myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/mock/servlet/
myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/mock/servlet/MockHttpServletRequest.java (contents, props changed)
- copied, changed from r953300, myfaces/tobago/trunk/tobago-jsf-compat/src/test/java/org/apache/myfaces/tobago/mock/servlet/MockHttpServletRequest.java
myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/mock/servlet/MockHttpServletResponse.java (contents, props changed)
- copied, changed from r953300, myfaces/tobago/trunk/tobago-jsf-compat/src/test/java/org/apache/myfaces/tobago/mock/servlet/MockHttpServletResponse.java
myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/mock/servlet/MockHttpSession.java (contents, props changed)
- copied, changed from r953300, myfaces/tobago/trunk/tobago-jsf-compat/src/test/java/org/apache/myfaces/tobago/mock/servlet/MockHttpSession.java
myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/mock/servlet/MockJspWriter.java (contents, props changed)
- copied, changed from r953300, myfaces/tobago/trunk/tobago-jsf-compat/src/test/java/org/apache/myfaces/tobago/mock/servlet/MockJspWriter.java
myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/mock/servlet/MockPageContext.java (contents, props changed)
- copied, changed from r953300, myfaces/tobago/trunk/tobago-jsf-compat/src/test/java/org/apache/myfaces/tobago/mock/servlet/MockPageContext.java
myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/mock/servlet/MockServletContext.java (contents, props changed)
- copied, changed from r953300, myfaces/tobago/trunk/tobago-jsf-compat/src/test/java/org/apache/myfaces/tobago/mock/servlet/MockServletContext.java
myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/mock/servlet/MockServletInputStream.java (contents, props changed)
- copied, changed from r953300, myfaces/tobago/trunk/tobago-jsf-compat/src/test/java/org/apache/myfaces/tobago/mock/servlet/MockServletInputStream.java
myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/taglib/component/GenericTestBase.java (contents, props changed)
- copied, changed from r953300, myfaces/tobago/trunk/tobago-jsf-compat/src/test/java/org/apache/myfaces/tobago/internal/taglib/component/GenericTestBase.java
Removed:
myfaces/tobago/trunk/tobago-jsf-compat/src/test/java/org/apache/myfaces/tobago/internal/
myfaces/tobago/trunk/tobago-jsf-compat/src/test/java/org/apache/myfaces/tobago/mock/
Modified:
myfaces/tobago/trunk/tobago-core/pom.xml
myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/component/UIMessagesUnitTest.java
myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/context/ResponseWriterDividerUnitTest.java
myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/taglib/component/GenericComponentTagUnitTest.java
myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/taglib/component/GenericTagUnitTest.java
myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/webapp/TobagoMultipartFormdataRequestUnitTest.java
myfaces/tobago/trunk/tobago-extension/tobago-sandbox/pom.xml
myfaces/tobago/trunk/tobago-extension/tobago-sandbox/src/test/java/org/apache/myfaces/tobago/internal/taglib/sandbox/SandboxGenericTagUnitTest.java
myfaces/tobago/trunk/tobago-jsf-compat/pom.xml
myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/pom.xml
Modified: myfaces/tobago/trunk/tobago-core/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/pom.xml?rev=953759&r1=953758&r2=953759&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/pom.xml (original)
+++ myfaces/tobago/trunk/tobago-core/pom.xml Fri Jun 11 16:36:16 2010
@@ -224,6 +224,17 @@
</configuration>
</plugin>
<plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <executions>
+ <execution>
+ <goals>
+ <goal>test-jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<executions>
@@ -260,20 +271,6 @@
<version>${project.version}</version>
</dependency>
<dependency>
- <groupId>org.apache.myfaces.tobago</groupId>
- <artifactId>tobago-jsf-compat</artifactId>
- <version>${project.version}</version>
- <classifier>tests</classifier>
- <scope>test</scope>
- </dependency>
- <!--dependency>
- <groupId>org.apache.shale</groupId>
- <artifactId>shale-test</artifactId>
- <version>1.0.4</version>
- <scope>test</scope>
- </dependency-->
-
- <dependency>
<groupId>javax.el</groupId>
<artifactId>el-api</artifactId>
</dependency>
@@ -344,16 +341,9 @@
<scope>provided</scope>
</dependency>
<dependency>
- <groupId>org.apache.shale</groupId>
- <artifactId>shale-test</artifactId>
- <version>1.0.4</version>
- <!--version>1.1.0-SNAPSHOT</version-->
- <scope>test</scope>
- </dependency>
- <dependency>
<groupId>org.apache.myfaces.test</groupId>
<artifactId>myfaces-test12</artifactId>
- <version>1.0.0-alpha</version>
+ <version>1.0.0-beta-3</version>
<scope>test</scope>
</dependency>
</dependencies>
Modified: myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/component/UIMessagesUnitTest.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/component/UIMessagesUnitTest.java?rev=953759&r1=953758&r2=953759&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/component/UIMessagesUnitTest.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/component/UIMessagesUnitTest.java Fri Jun 11 16:36:16 2010
@@ -17,22 +17,19 @@ package org.apache.myfaces.tobago.compon
* limitations under the License.
*/
-import org.apache.shale.test.mock.MockFacesContext;
+import org.apache.myfaces.tobago.internal.mock.faces.AbstractTobagoTestBase;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import javax.faces.application.FacesMessage;
-import javax.faces.context.FacesContext;
import java.util.List;
-public class UIMessagesUnitTest {
-
- private FacesContext facesContext;
+public class UIMessagesUnitTest extends AbstractTobagoTestBase {
@Before
public void setUp() throws Exception {
- facesContext = new MockFacesContext();
+ super.setUp();
facesContext.addMessage("id0", new FacesMessage(FacesMessage.SEVERITY_INFO, "test", "a test"));
facesContext.addMessage("id0", new FacesMessage(FacesMessage.SEVERITY_WARN, "test", "a test"));
facesContext.addMessage("id1", new FacesMessage(FacesMessage.SEVERITY_ERROR, "test", "a test"));
Modified: myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/context/ResponseWriterDividerUnitTest.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/context/ResponseWriterDividerUnitTest.java?rev=953759&r1=953758&r2=953759&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/context/ResponseWriterDividerUnitTest.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/context/ResponseWriterDividerUnitTest.java Fri Jun 11 16:36:16 2010
@@ -17,9 +17,7 @@ package org.apache.myfaces.tobago.intern
* limitations under the License.
*/
-import org.apache.myfaces.test.mock.MockExternalContext;
-import org.apache.myfaces.test.mock.MockFacesContext;
-import org.apache.myfaces.test.mock.MockHttpServletRequest;
+import org.apache.myfaces.tobago.internal.mock.faces.AbstractTobagoTestBase;
import org.apache.myfaces.tobago.internal.webapp.TobagoResponseXmlWriterImpl;
import org.junit.Assert;
import org.junit.Test;
@@ -30,14 +28,11 @@ import javax.swing.tree.TreeNode;
import java.io.IOException;
import java.io.StringWriter;
-public class ResponseWriterDividerUnitTest {
+public class ResponseWriterDividerUnitTest extends AbstractTobagoTestBase {
@Test
public void test() throws IOException {
- // TODO: check how to use this classes
- MockFacesContext facesContext = new MockFacesContext();
- MockExternalContext externalContext = new MockExternalContext(null, new MockHttpServletRequest(), null);
- facesContext.setExternalContext(externalContext);
+
StringWriter stringWriter = new StringWriter();
facesContext.setResponseWriter(new TobagoResponseXmlWriterImpl(stringWriter, "text/xml", "ISO-8859-1"));
Added: myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/mock/faces/AbstractTobagoTestBase.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/mock/faces/AbstractTobagoTestBase.java?rev=953759&view=auto
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/mock/faces/AbstractTobagoTestBase.java (added)
+++ myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/mock/faces/AbstractTobagoTestBase.java Fri Jun 11 16:36:16 2010
@@ -0,0 +1,193 @@
+package org.apache.myfaces.tobago.internal.mock.faces;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you 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.
+ */
+
+import org.apache.myfaces.test.mock.MockApplication;
+import org.apache.myfaces.test.mock.MockExternalContext;
+import org.apache.myfaces.test.mock.MockFacesContext;
+import org.apache.myfaces.test.mock.MockFacesContextFactory;
+import org.apache.myfaces.test.mock.MockHttpServletRequest;
+import org.apache.myfaces.test.mock.MockHttpServletResponse;
+import org.apache.myfaces.test.mock.MockHttpSession;
+import org.apache.myfaces.test.mock.MockRenderKit;
+import org.apache.myfaces.test.mock.MockServletConfig;
+import org.apache.myfaces.test.mock.MockServletContext;
+import org.apache.myfaces.test.mock.lifecycle.MockLifecycle;
+import org.apache.myfaces.test.mock.lifecycle.MockLifecycleFactory;
+import org.apache.myfaces.tobago.component.ComponentTypes;
+import org.apache.myfaces.tobago.component.UIInput;
+import org.apache.myfaces.tobago.component.UIOut;
+import org.apache.myfaces.tobago.config.TobagoConfig;
+import org.apache.myfaces.tobago.context.ClientProperties;
+import org.apache.myfaces.tobago.context.Theme;
+import org.junit.After;
+import org.junit.Before;
+
+import javax.faces.FactoryFinder;
+import javax.faces.application.ApplicationFactory;
+import javax.faces.component.UIViewRoot;
+import javax.faces.lifecycle.LifecycleFactory;
+import javax.faces.render.RenderKitFactory;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * <p>Abstract JUnit test case base class, which sets up the JavaServer Faces
+ * mock object environment for a particular simulated request.
+ * </p>
+ * <p>
+ * This is a port of the class AbstractJsfTestCase from myfaces-test12 to JUnit 4.
+ * It also contains Tobago specifics.
+ * </p>
+ */
+
+public abstract class AbstractTobagoTestBase {
+
+ // Mock object instances for our tests
+ protected MockApplication application = null;
+ protected MockServletConfig config = null;
+ protected MockExternalContext externalContext = null;
+ protected MockFacesContext facesContext = null;
+ protected MockFacesContextFactory facesContextFactory = null;
+ protected MockLifecycle lifecycle = null;
+ protected MockLifecycleFactory lifecycleFactory = null;
+ protected MockRenderKit renderKit = null;
+ protected MockHttpServletRequest request = null;
+ protected MockHttpServletResponse response = null;
+ protected MockServletContext servletContext = null;
+ protected MockHttpSession session = null;
+
+ // Thread context class loader saved and restored after each test
+ private ClassLoader threadContextClassLoader = null;
+
+
+ /**
+ * <p>Set up instance variables required by this test case.</p>
+ */
+ @Before
+ public void setUp() throws Exception {
+
+ // Set up a new thread context class loader
+ threadContextClassLoader = Thread.currentThread().getContextClassLoader();
+ Thread.currentThread().setContextClassLoader(new URLClassLoader(new URL[0],
+ this.getClass().getClassLoader()));
+
+ // Set up Servlet API Objects
+ servletContext = new MockServletContext();
+ config = new MockServletConfig(servletContext);
+ session = new MockHttpSession();
+ session.setServletContext(servletContext);
+ request = new MockHttpServletRequest(session);
+ request.setServletContext(servletContext);
+ response = new MockHttpServletResponse();
+
+ // Set up JSF API Objects
+ FactoryFinder.releaseFactories();
+ FactoryFinder.setFactory(FactoryFinder.APPLICATION_FACTORY,
+ "org.apache.myfaces.test.mock.MockApplicationFactory");
+ FactoryFinder.setFactory(FactoryFinder.FACES_CONTEXT_FACTORY,
+ "org.apache.myfaces.test.mock.MockFacesContextFactory");
+ FactoryFinder.setFactory(FactoryFinder.LIFECYCLE_FACTORY,
+ "org.apache.myfaces.test.mock.lifecycle.MockLifecycleFactory");
+ FactoryFinder.setFactory(FactoryFinder.RENDER_KIT_FACTORY,
+ "org.apache.myfaces.test.mock.MockRenderKitFactory");
+
+ externalContext =
+ new MockExternalContext(servletContext, request, response);
+ lifecycleFactory = (MockLifecycleFactory)
+ FactoryFinder.getFactory(FactoryFinder.LIFECYCLE_FACTORY);
+ lifecycle = (MockLifecycle)
+ lifecycleFactory.getLifecycle(LifecycleFactory.DEFAULT_LIFECYCLE);
+ facesContextFactory = (MockFacesContextFactory)
+ FactoryFinder.getFactory(FactoryFinder.FACES_CONTEXT_FACTORY);
+ facesContext = (MockFacesContext)
+ facesContextFactory.getFacesContext(servletContext,
+ request,
+ response,
+ lifecycle);
+ externalContext = (MockExternalContext) facesContext.getExternalContext();
+ UIViewRoot root = new UIViewRoot();
+ root.setViewId("/viewId");
+ root.setRenderKitId(RenderKitFactory.HTML_BASIC_RENDER_KIT);
+ facesContext.setViewRoot(root);
+ ApplicationFactory applicationFactory = (ApplicationFactory)
+ FactoryFinder.getFactory(FactoryFinder.APPLICATION_FACTORY);
+ application = (MockApplication) applicationFactory.getApplication();
+ facesContext.setApplication(application);
+ RenderKitFactory renderKitFactory = (RenderKitFactory)
+ FactoryFinder.getFactory(FactoryFinder.RENDER_KIT_FACTORY);
+ renderKit = new MockRenderKit();
+ renderKitFactory.addRenderKit(RenderKitFactory.HTML_BASIC_RENDER_KIT, renderKit);
+
+ // Tobago specific extensions
+
+ TobagoConfig tobagoConfig = new TobagoConfig();
+ Theme theme = new MockTheme("default", "Default Mock Theme", Collections.EMPTY_LIST);
+ Theme one = new MockTheme("one", "Mock Theme One", Arrays.asList(theme));
+ Map<String, Theme> availableThemes = new HashMap<String, Theme>();
+ availableThemes.put(theme.getName(), theme);
+ availableThemes.put(one.getName(), one);
+ tobagoConfig.setAvailableThemes(availableThemes);
+ tobagoConfig.resolveThemes();
+ tobagoConfig.initProjectState(servletContext);
+ servletContext.setAttribute(TobagoConfig.TOBAGO_CONFIG, tobagoConfig);
+
+ final ClientProperties clientProperties = new ClientProperties();
+ clientProperties.setTheme(one);
+ session.setAttribute(ClientProperties.MANAGED_BEAN_NAME, clientProperties);
+
+ // XXX is there a better way? Get it from Tobagos generated faces-config.xml?
+ application.addComponent(ComponentTypes.IN, UIInput.class.getName());
+ application.addComponent(ComponentTypes.OUT, UIOut.class.getName());
+ application.addComponent("javax.faces.ViewRoot", "org.apache.myfaces.tobago.component.UIViewRoot");
+ application.addComponent("javax.faces.Command", "javax.faces.component.UICommand");
+ application.addComponent("org.apache.myfaces.tobago.Command", "org.apache.myfaces.tobago.component.UICommand");
+ application.addComponent("org.apache.myfaces.tobago.Link", "org.apache.myfaces.tobago.component.UILink");
+ application.addComponent("org.apache.myfaces.tobago.Button", "org.apache.myfaces.tobago.component.UIButton");
+
+ }
+
+ /**
+ * <p>Tear down instance variables required by this test case.</p>
+ */
+ @After
+ public void tearDown() throws Exception {
+
+ application = null;
+ config = null;
+ externalContext = null;
+ facesContext.release();
+ facesContext = null;
+ lifecycle = null;
+ lifecycleFactory = null;
+ renderKit = null;
+ request = null;
+ response = null;
+ servletContext = null;
+ session = null;
+ FactoryFinder.releaseFactories();
+
+ Thread.currentThread().setContextClassLoader(threadContextClassLoader);
+ threadContextClassLoader = null;
+
+ }
+}
Added: myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/mock/faces/MockRenderersConfig.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/mock/faces/MockRenderersConfig.java?rev=953759&view=auto
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/mock/faces/MockRenderersConfig.java (added)
+++ myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/mock/faces/MockRenderersConfig.java Fri Jun 11 16:36:16 2010
@@ -0,0 +1,37 @@
+package org.apache.myfaces.tobago.internal.mock.faces;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you 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.
+ */
+
+import org.apache.myfaces.tobago.context.RendererConfig;
+import org.apache.myfaces.tobago.context.RenderersConfig;
+
+import java.util.Collection;
+
+public class MockRenderersConfig implements RenderersConfig {
+
+ /**
+ * To keep it simple, we allow every value shorter than 10 characters.
+ */
+ public boolean isMarkupSupported(String rendererName, String markup) {
+ return markup.length() < 10;
+ }
+
+ public Collection<RendererConfig> getRendererConfigs() {
+ return null;
+ }
+}
Added: myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/mock/faces/MockTheme.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/mock/faces/MockTheme.java?rev=953759&view=auto
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/mock/faces/MockTheme.java (added)
+++ myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/mock/faces/MockTheme.java Fri Jun 11 16:36:16 2010
@@ -0,0 +1,60 @@
+package org.apache.myfaces.tobago.internal.mock.faces;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you 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.
+ */
+
+import org.apache.myfaces.tobago.context.RenderersConfig;
+import org.apache.myfaces.tobago.context.Theme;
+
+import java.util.List;
+
+public class MockTheme implements Theme {
+
+ private String name;
+
+ private String displayName;
+
+ private List<Theme> fallbackThemeList;
+
+ private RenderersConfig config = new MockRenderersConfig();
+
+ public MockTheme(String name, String displayName, List<Theme> fallbackThemeList) {
+ this.name = name;
+ this.displayName = displayName;
+ this.fallbackThemeList = fallbackThemeList;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public List<Theme> getFallbackList() {
+ return fallbackThemeList;
+ }
+
+ public String getDisplayName() {
+ return displayName;
+ }
+
+ public String getResourcePath() {
+ return null;
+ }
+
+ public RenderersConfig getRenderersConfig() {
+ return config;
+ }
+}
Copied: myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/mock/servlet/MockHttpServletRequest.java (from r953300, myfaces/tobago/trunk/tobago-jsf-compat/src/test/java/org/apache/myfaces/tobago/mock/servlet/MockHttpServletRequest.java)
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/mock/servlet/MockHttpServletRequest.java?p2=myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/mock/servlet/MockHttpServletRequest.java&p1=myfaces/tobago/trunk/tobago-jsf-compat/src/test/java/org/apache/myfaces/tobago/mock/servlet/MockHttpServletRequest.java&r1=953300&r2=953759&rev=953759&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-jsf-compat/src/test/java/org/apache/myfaces/tobago/mock/servlet/MockHttpServletRequest.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/mock/servlet/MockHttpServletRequest.java Fri Jun 11 16:36:16 2010
@@ -1,4 +1,4 @@
-package org.apache.myfaces.tobago.mock.servlet;
+package org.apache.myfaces.tobago.internal.mock.servlet;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
Propchange: myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/mock/servlet/MockHttpServletRequest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/mock/servlet/MockHttpServletRequest.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Copied: myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/mock/servlet/MockHttpServletResponse.java (from r953300, myfaces/tobago/trunk/tobago-jsf-compat/src/test/java/org/apache/myfaces/tobago/mock/servlet/MockHttpServletResponse.java)
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/mock/servlet/MockHttpServletResponse.java?p2=myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/mock/servlet/MockHttpServletResponse.java&p1=myfaces/tobago/trunk/tobago-jsf-compat/src/test/java/org/apache/myfaces/tobago/mock/servlet/MockHttpServletResponse.java&r1=953300&r2=953759&rev=953759&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-jsf-compat/src/test/java/org/apache/myfaces/tobago/mock/servlet/MockHttpServletResponse.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/mock/servlet/MockHttpServletResponse.java Fri Jun 11 16:36:16 2010
@@ -1,4 +1,4 @@
-package org.apache.myfaces.tobago.mock.servlet;
+package org.apache.myfaces.tobago.internal.mock.servlet;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
Propchange: myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/mock/servlet/MockHttpServletResponse.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/mock/servlet/MockHttpServletResponse.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Copied: myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/mock/servlet/MockHttpSession.java (from r953300, myfaces/tobago/trunk/tobago-jsf-compat/src/test/java/org/apache/myfaces/tobago/mock/servlet/MockHttpSession.java)
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/mock/servlet/MockHttpSession.java?p2=myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/mock/servlet/MockHttpSession.java&p1=myfaces/tobago/trunk/tobago-jsf-compat/src/test/java/org/apache/myfaces/tobago/mock/servlet/MockHttpSession.java&r1=953300&r2=953759&rev=953759&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-jsf-compat/src/test/java/org/apache/myfaces/tobago/mock/servlet/MockHttpSession.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/mock/servlet/MockHttpSession.java Fri Jun 11 16:36:16 2010
@@ -1,4 +1,4 @@
-package org.apache.myfaces.tobago.mock.servlet;
+package org.apache.myfaces.tobago.internal.mock.servlet;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
Propchange: myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/mock/servlet/MockHttpSession.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/mock/servlet/MockHttpSession.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Copied: myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/mock/servlet/MockJspWriter.java (from r953300, myfaces/tobago/trunk/tobago-jsf-compat/src/test/java/org/apache/myfaces/tobago/mock/servlet/MockJspWriter.java)
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/mock/servlet/MockJspWriter.java?p2=myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/mock/servlet/MockJspWriter.java&p1=myfaces/tobago/trunk/tobago-jsf-compat/src/test/java/org/apache/myfaces/tobago/mock/servlet/MockJspWriter.java&r1=953300&r2=953759&rev=953759&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-jsf-compat/src/test/java/org/apache/myfaces/tobago/mock/servlet/MockJspWriter.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/mock/servlet/MockJspWriter.java Fri Jun 11 16:36:16 2010
@@ -1,4 +1,4 @@
-package org.apache.myfaces.tobago.mock.servlet;
+package org.apache.myfaces.tobago.internal.mock.servlet;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
Propchange: myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/mock/servlet/MockJspWriter.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/mock/servlet/MockJspWriter.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Copied: myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/mock/servlet/MockPageContext.java (from r953300, myfaces/tobago/trunk/tobago-jsf-compat/src/test/java/org/apache/myfaces/tobago/mock/servlet/MockPageContext.java)
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/mock/servlet/MockPageContext.java?p2=myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/mock/servlet/MockPageContext.java&p1=myfaces/tobago/trunk/tobago-jsf-compat/src/test/java/org/apache/myfaces/tobago/mock/servlet/MockPageContext.java&r1=953300&r2=953759&rev=953759&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-jsf-compat/src/test/java/org/apache/myfaces/tobago/mock/servlet/MockPageContext.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/mock/servlet/MockPageContext.java Fri Jun 11 16:36:16 2010
@@ -1,4 +1,4 @@
-package org.apache.myfaces.tobago.mock.servlet;
+package org.apache.myfaces.tobago.internal.mock.servlet;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
@@ -17,6 +17,7 @@ package org.apache.myfaces.tobago.mock.s
* limitations under the License.
*/
+import javax.el.ELContext;
import javax.servlet.Servlet;
import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;
@@ -28,7 +29,6 @@ import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.PageContext;
import javax.servlet.jsp.el.ExpressionEvaluator;
import javax.servlet.jsp.el.VariableResolver;
-import javax.el.ELContext;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Enumeration;
Propchange: myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/mock/servlet/MockPageContext.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/mock/servlet/MockPageContext.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Copied: myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/mock/servlet/MockServletContext.java (from r953300, myfaces/tobago/trunk/tobago-jsf-compat/src/test/java/org/apache/myfaces/tobago/mock/servlet/MockServletContext.java)
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/mock/servlet/MockServletContext.java?p2=myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/mock/servlet/MockServletContext.java&p1=myfaces/tobago/trunk/tobago-jsf-compat/src/test/java/org/apache/myfaces/tobago/mock/servlet/MockServletContext.java&r1=953300&r2=953759&rev=953759&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-jsf-compat/src/test/java/org/apache/myfaces/tobago/mock/servlet/MockServletContext.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/mock/servlet/MockServletContext.java Fri Jun 11 16:36:16 2010
@@ -1,4 +1,4 @@
-package org.apache.myfaces.tobago.mock.servlet;
+package org.apache.myfaces.tobago.internal.mock.servlet;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
@@ -25,9 +25,9 @@ import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Enumeration;
-import java.util.Set;
-import java.util.Map;
import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
public class MockServletContext implements ServletContext {
private Map attributes = new HashMap();
Propchange: myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/mock/servlet/MockServletContext.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/mock/servlet/MockServletContext.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Copied: myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/mock/servlet/MockServletInputStream.java (from r953300, myfaces/tobago/trunk/tobago-jsf-compat/src/test/java/org/apache/myfaces/tobago/mock/servlet/MockServletInputStream.java)
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/mock/servlet/MockServletInputStream.java?p2=myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/mock/servlet/MockServletInputStream.java&p1=myfaces/tobago/trunk/tobago-jsf-compat/src/test/java/org/apache/myfaces/tobago/mock/servlet/MockServletInputStream.java&r1=953300&r2=953759&rev=953759&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-jsf-compat/src/test/java/org/apache/myfaces/tobago/mock/servlet/MockServletInputStream.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/mock/servlet/MockServletInputStream.java Fri Jun 11 16:36:16 2010
@@ -1,4 +1,4 @@
-package org.apache.myfaces.tobago.mock.servlet;
+package org.apache.myfaces.tobago.internal.mock.servlet;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
Propchange: myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/mock/servlet/MockServletInputStream.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/mock/servlet/MockServletInputStream.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Modified: myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/taglib/component/GenericComponentTagUnitTest.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/taglib/component/GenericComponentTagUnitTest.java?rev=953759&r1=953758&r2=953759&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/taglib/component/GenericComponentTagUnitTest.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/taglib/component/GenericComponentTagUnitTest.java Fri Jun 11 16:36:16 2010
@@ -18,114 +18,36 @@ package org.apache.myfaces.tobago.intern
*/
import org.apache.myfaces.tobago.component.Attributes;
-import org.apache.myfaces.tobago.config.TobagoConfig;
-import org.apache.myfaces.tobago.context.RenderersConfig;
-import org.apache.myfaces.tobago.context.Theme;
import org.apache.myfaces.tobago.internal.taglib.TobagoTag;
-import org.apache.myfaces.tobago.mock.faces.MockExternalContext;
-import org.apache.myfaces.tobago.mock.faces.MockFacesContext;
-import org.apache.myfaces.tobago.mock.faces.MockRenderKit;
-import org.apache.myfaces.tobago.mock.servlet.MockHttpServletRequest;
-import org.apache.myfaces.tobago.mock.servlet.MockHttpServletResponse;
-import org.apache.myfaces.tobago.mock.servlet.MockServletContext;
import org.apache.myfaces.tobago.util.ComponentUtils;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import javax.faces.FactoryFinder;
-import javax.faces.application.Application;
-import javax.faces.application.ApplicationFactory;
import javax.faces.component.UICommand;
import javax.faces.component.UIComponent;
-import javax.faces.component.UIViewRoot;
-import javax.faces.context.ExternalContext;
-import javax.faces.lifecycle.Lifecycle;
-import javax.faces.render.RenderKit;
-import javax.faces.render.RenderKitFactory;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.Tag;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashMap;
import java.util.Iterator;
-import java.util.List;
import java.util.Map;
public class GenericComponentTagUnitTest extends GenericTestBase {
private static final Logger LOG = LoggerFactory.getLogger(GenericComponentTagUnitTest.class);
- private Application application;
- private MockFacesContext facesContext;
- //private PageContext pageContext;
-
-
- public GenericComponentTagUnitTest(String name) {
- super(name);
-
- }
-
+ @Before
public void setUp() throws Exception {
String[] tldPaths = new String[1];
tldPaths[0] = "META-INF/org/apache/myfaces/tobago/internal/taglib/component/tobago.tld";
setTldPaths(tldPaths);
super.setUp();
-
- MockServletContext servletContext = new MockServletContext();
- TobagoConfig tobagoConfig = new TobagoConfig();
- Theme theme = new MockTheme("default", Collections.EMPTY_LIST);
- Theme theme1 = new MockTheme("one", Arrays.asList(theme));
- Map<String, Theme> availableThemes = new HashMap<String, Theme>();
- availableThemes.put(theme.getName(), theme);
- availableThemes.put(theme1.getName(), theme1);
- tobagoConfig.setAvailableThemes(availableThemes);
- tobagoConfig.resolveThemes();
- tobagoConfig.initProjectState(servletContext);
- servletContext.setAttribute(TobagoConfig.TOBAGO_CONFIG, tobagoConfig);
- HttpServletRequest request = new MockHttpServletRequest();
- HttpServletResponse response = new MockHttpServletResponse();
- //pageContext = new MockPageContext(request);
- ExternalContext externalContext =
- new MockExternalContext(servletContext, request, response);
- Lifecycle lifecycle = null;
- facesContext = new MockFacesContext(externalContext, lifecycle);
- // Set up Faces API Objects
- FactoryFinder.setFactory(FactoryFinder.APPLICATION_FACTORY,
- "org.apache.myfaces.tobago.mock.faces.MockApplicationFactory");
- FactoryFinder.setFactory(FactoryFinder.RENDER_KIT_FACTORY,
- "org.apache.myfaces.tobago.mock.faces.MockRenderKitFactory");
-
- ApplicationFactory applicationFactory = (ApplicationFactory)
- FactoryFinder.getFactory(FactoryFinder.APPLICATION_FACTORY);
- application = applicationFactory.getApplication();
- application.addComponent("javax.faces.ViewRoot", "org.apache.myfaces.tobago.component.UIViewRoot");
- application.addComponent("javax.faces.Command", "javax.faces.component.UICommand");
- application.addComponent("org.apache.myfaces.tobago.Command", "org.apache.myfaces.tobago.component.UICommand");
- application
- .addComponent("org.apache.myfaces.tobago.LinkCommand", "org.apache.myfaces.tobago.component.UILink");
- application
- .addComponent("org.apache.myfaces.tobago.ButtonCommand", "org.apache.myfaces.tobago.component.UIButton");
-
- facesContext.setApplication(application);
- UIViewRoot root = facesContext
- .getApplication().getViewHandler().createView(facesContext, "testViewId");
- root.setViewId("/viewId");
- facesContext.setViewRoot(root);
-
- RenderKitFactory renderKitFactory = (RenderKitFactory)
- FactoryFinder.getFactory(FactoryFinder.RENDER_KIT_FACTORY);
- RenderKit renderKit = new MockRenderKit();
- try {
- renderKitFactory.addRenderKit(RenderKitFactory.HTML_BASIC_RENDER_KIT, renderKit);
- } catch (IllegalArgumentException e) {
- // ignore
- }
request.setAttribute("peter", new DummyBean(true, 20, "Peter"));
request.setAttribute("marry", new DummyBean(false, 17, "Marry"));
}
+ @Test
public void testComponent()
throws JspException, IllegalAccessException, InstantiationException, ClassNotFoundException {
// TODO create new test
@@ -166,39 +88,8 @@ public class GenericComponentTagUnitTest
Object height = attributes.get(Attributes.HEIGHT);
LOG.debug("height = '" + height + "'");
- assertTrue(ComponentUtils.getBooleanAttribute(command, Attributes.DISABLED));
- assertFalse(ComponentUtils.getBooleanAttribute(command, Attributes.HEIGHT));
- }
- }
-
- private static class MockTheme implements Theme {
- private String name;
- private List<Theme> fallbackThemeList;
-
- private MockTheme(String name, List<Theme> fallbackThemeList) {
- this.name = name;
- this.fallbackThemeList = fallbackThemeList;
- }
-
- public String getName() {
- return name;
- }
-
- public List<Theme> getFallbackList() {
- return fallbackThemeList;
- }
-
- public String getDisplayName() {
- return "";
- }
-
- public String getResourcePath() {
- return null;
- }
-
- public RenderersConfig getRenderersConfig() {
- return null;
+ Assert.assertTrue(ComponentUtils.getBooleanAttribute(command, Attributes.DISABLED));
+ Assert.assertFalse(ComponentUtils.getBooleanAttribute(command, Attributes.HEIGHT));
}
}
}
-
Modified: myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/taglib/component/GenericTagUnitTest.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/taglib/component/GenericTagUnitTest.java?rev=953759&r1=953758&r2=953759&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/taglib/component/GenericTagUnitTest.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/taglib/component/GenericTagUnitTest.java Fri Jun 11 16:36:16 2010
@@ -17,15 +17,12 @@ package org.apache.myfaces.tobago.intern
* limitations under the License.
*/
+import org.junit.Before;
public class GenericTagUnitTest extends GenericTestBase {
- public GenericTagUnitTest(String name) {
- super(name);
-
- }
-
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
String[] tldPaths = new String[1];
tldPaths[0] = "META-INF/org/apache/myfaces/tobago/internal/taglib/component/tobago.tld";
//TODO move to tobago-taglib-extension
@@ -33,6 +30,4 @@ public class GenericTagUnitTest extends
setTldPaths(tldPaths);
super.setUp();
}
-
}
-
Copied: myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/taglib/component/GenericTestBase.java (from r953300, myfaces/tobago/trunk/tobago-jsf-compat/src/test/java/org/apache/myfaces/tobago/internal/taglib/component/GenericTestBase.java)
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/taglib/component/GenericTestBase.java?p2=myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/taglib/component/GenericTestBase.java&p1=myfaces/tobago/trunk/tobago-jsf-compat/src/test/java/org/apache/myfaces/tobago/internal/taglib/component/GenericTestBase.java&r1=953300&r2=953759&rev=953759&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-jsf-compat/src/test/java/org/apache/myfaces/tobago/internal/taglib/component/GenericTestBase.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/taglib/component/GenericTestBase.java Fri Jun 11 16:36:16 2010
@@ -17,17 +17,15 @@ package org.apache.myfaces.tobago.intern
* limitations under the License.
*/
-import junit.framework.TestCase;
import net.sf.maventaglib.checker.TagAttribute;
import net.sf.maventaglib.checker.Tld;
import net.sf.maventaglib.checker.TldParser;
import org.apache.commons.beanutils.PropertyUtils;
-import org.apache.myfaces.tobago.mock.faces.MockExternalContext;
-import org.apache.myfaces.tobago.mock.faces.MockFacesContext;
-import org.apache.myfaces.tobago.mock.servlet.MockHttpServletRequest;
-import org.apache.myfaces.tobago.mock.servlet.MockHttpServletResponse;
-import org.apache.myfaces.tobago.mock.servlet.MockPageContext;
-import org.apache.myfaces.tobago.mock.servlet.MockServletContext;
+import org.apache.myfaces.tobago.internal.mock.faces.AbstractTobagoTestBase;
+import org.apache.myfaces.tobago.internal.mock.servlet.MockPageContext;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.w3c.dom.Document;
@@ -35,14 +33,6 @@ import org.xml.sax.EntityResolver;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
-import javax.faces.FactoryFinder;
-import javax.faces.application.Application;
-import javax.faces.application.ApplicationFactory;
-import javax.faces.component.UIViewRoot;
-import javax.faces.context.ExternalContext;
-import javax.faces.lifecycle.Lifecycle;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
import javax.servlet.jsp.tagext.Tag;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
@@ -51,21 +41,16 @@ import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.InvocationTargetException;
import java.util.HashMap;
-//import org.apache.myfaces.tobago.mock.servlet.MockPageContext;
-public abstract class GenericTestBase extends TestCase {
+public abstract class GenericTestBase extends AbstractTobagoTestBase {
+
private static final Logger LOG = LoggerFactory.getLogger(GenericTestBase.class);
private Tld[] tlds;
private String[] tldPaths;
- private Application application;
- private MockFacesContext facesContext;
-
- public GenericTestBase(String name) {
- super(name);
- }
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
super.setUp();
tlds = new Tld[tldPaths.length];
for (int i = 0; i < tldPaths.length; i++) {
@@ -73,39 +58,9 @@ public abstract class GenericTestBase ex
tlds[i] = getTld(tldPaths[i], stream);
stream.close();
}
-
- MockServletContext servletContext = new MockServletContext();
- HttpServletRequest request = new MockHttpServletRequest();
- HttpServletResponse response = new MockHttpServletResponse();
- //pageContext = new MockPageContext(request);
- ExternalContext externalContext =
- new MockExternalContext(servletContext, request, response);
- Lifecycle lifecycle = null;
- facesContext = new MockFacesContext(externalContext, lifecycle);
- // Set up Faces API Objects
- FactoryFinder.setFactory(FactoryFinder.APPLICATION_FACTORY,
- "org.apache.myfaces.tobago.mock.faces.MockApplicationFactory");
- FactoryFinder.setFactory(FactoryFinder.RENDER_KIT_FACTORY,
- "org.apache.myfaces.tobago.mock.faces.MockRenderKitFactory");
-
- ApplicationFactory applicationFactory = (ApplicationFactory)
- FactoryFinder.getFactory(FactoryFinder.APPLICATION_FACTORY);
- application = applicationFactory.getApplication();
- application.addComponent("javax.faces.ViewRoot", "org.apache.myfaces.tobago.component.UIViewRoot");
- application.addComponent("javax.faces.Command", "javax.faces.component.UICommand");
- application.addComponent("org.apache.myfaces.tobago.Command", "org.apache.myfaces.tobago.component.UICommand");
- application
- .addComponent("org.apache.myfaces.tobago.LinkCommand", "org.apache.myfaces.tobago.component.UILinkCommand");
- application
- .addComponent("org.apache.myfaces.tobago.ButtonCommand", "org.apache.myfaces.tobago.component.UIButtonCommand");
-
- facesContext.setApplication(application);
- UIViewRoot root = facesContext
- .getApplication().getViewHandler().createView(facesContext, "testViewId");
- root.setViewId("/viewId");
- facesContext.setViewRoot(root);
}
+ @Test
public void testRelease() throws IllegalAccessException,
NoSuchMethodException, InvocationTargetException, IOException,
SAXException, ClassNotFoundException, InstantiationException {
@@ -117,6 +72,7 @@ public abstract class GenericTestBase ex
}
}
+ @Test
public void testSetterExist() throws NoSuchMethodException,
IllegalAccessException, InvocationTargetException, IOException,
SAXException, ClassNotFoundException, InstantiationException {
@@ -145,10 +101,8 @@ public abstract class GenericTestBase ex
NoSuchMethodException, InvocationTargetException, ClassNotFoundException {
PropertyDescriptor propertyDescriptor
= PropertyUtils.getPropertyDescriptor(tagObject, name);
- assertNotNull("setter '" + name + "' of class " + tagObject.getClass().getName() + " has "
+ Assert.assertNotNull("setter '" + name + "' of class " + tagObject.getClass().getName() + " has "
+ "property descriptor.", propertyDescriptor);
- //assertNotNull("setter '" + name + "' of class " + tagObject.getClass().getName() + " exists.",
- // propertyDescriptor.getWriteMethod());
}
public void setTlds(Tld[] tlds) {
@@ -212,7 +166,7 @@ public abstract class GenericTestBase ex
Object oldValue = initialValues.get(name);
String msg = "release of property '" + name + "' for tag '"
+ tag.getClass().getName() + "' failed.";
- assertEquals(msg, oldValue, newValue);
+ Assert.assertEquals(msg, oldValue, newValue);
// XXX: first error stops loop
// if (newValue != null && !newValue.equals(oldValue)) {
} catch (NoSuchMethodException e1) {
@@ -248,4 +202,3 @@ public abstract class GenericTestBase ex
}
}
}
-
Propchange: myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/taglib/component/GenericTestBase.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/taglib/component/GenericTestBase.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Modified: myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/webapp/TobagoMultipartFormdataRequestUnitTest.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/webapp/TobagoMultipartFormdataRequestUnitTest.java?rev=953759&r1=953758&r2=953759&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/webapp/TobagoMultipartFormdataRequestUnitTest.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/webapp/TobagoMultipartFormdataRequestUnitTest.java Fri Jun 11 16:36:16 2010
@@ -19,8 +19,8 @@ package org.apache.myfaces.tobago.webapp
import junit.framework.TestCase;
import org.apache.commons.fileupload.FileItem;
+import org.apache.myfaces.tobago.internal.mock.servlet.MockHttpServletRequest;
import org.apache.myfaces.tobago.internal.webapp.TobagoMultipartFormdataRequest;
-import org.apache.myfaces.tobago.mock.servlet.MockHttpServletRequest;
import java.io.UnsupportedEncodingException;
import java.util.Arrays;
Modified: myfaces/tobago/trunk/tobago-extension/tobago-sandbox/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-extension/tobago-sandbox/pom.xml?rev=953759&r1=953758&r2=953759&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-extension/tobago-sandbox/pom.xml (original)
+++ myfaces/tobago/trunk/tobago-extension/tobago-sandbox/pom.xml Fri Jun 11 16:36:16 2010
@@ -278,7 +278,7 @@
</dependency>
<dependency>
<groupId>org.apache.myfaces.tobago</groupId>
- <artifactId>tobago-jsf-compat</artifactId>
+ <artifactId>tobago-core</artifactId>
<version>${project.version}</version>
<classifier>tests</classifier>
<scope>test</scope>
@@ -337,6 +337,12 @@
<artifactId>slf4j-simple</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.apache.myfaces.test</groupId>
+ <artifactId>myfaces-test12</artifactId>
+ <version>1.0.0-beta-3</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<profiles>
Modified: myfaces/tobago/trunk/tobago-extension/tobago-sandbox/src/test/java/org/apache/myfaces/tobago/internal/taglib/sandbox/SandboxGenericTagUnitTest.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-extension/tobago-sandbox/src/test/java/org/apache/myfaces/tobago/internal/taglib/sandbox/SandboxGenericTagUnitTest.java?rev=953759&r1=953758&r2=953759&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-extension/tobago-sandbox/src/test/java/org/apache/myfaces/tobago/internal/taglib/sandbox/SandboxGenericTagUnitTest.java (original)
+++ myfaces/tobago/trunk/tobago-extension/tobago-sandbox/src/test/java/org/apache/myfaces/tobago/internal/taglib/sandbox/SandboxGenericTagUnitTest.java Fri Jun 11 16:36:16 2010
@@ -18,14 +18,12 @@ package org.apache.myfaces.tobago.intern
*/
import org.apache.myfaces.tobago.internal.taglib.component.GenericTestBase;
+import org.junit.Before;
public class SandboxGenericTagUnitTest extends GenericTestBase {
- public SandboxGenericTagUnitTest(String name) {
- super(name);
- }
-
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
String[] tldPaths = new String[1];
tldPaths[0] = "META-INF/org/apache/myfaces/tobago/internal/taglib/sandbox/tobago-sandbox.tld";
setTldPaths(tldPaths);
Modified: myfaces/tobago/trunk/tobago-jsf-compat/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-jsf-compat/pom.xml?rev=953759&r1=953758&r2=953759&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-jsf-compat/pom.xml (original)
+++ myfaces/tobago/trunk/tobago-jsf-compat/pom.xml Fri Jun 11 16:36:16 2010
@@ -40,17 +40,6 @@
<showWarnings>true</showWarnings>
</configuration>
</plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-jar-plugin</artifactId>
- <executions>
- <execution>
- <goals>
- <goal>test-jar</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
</plugins>
</build>
@@ -80,11 +69,6 @@
<artifactId>commons-beanutils</artifactId>
</dependency>
<dependency>
- <groupId>commons-collections</groupId>
- <artifactId>commons-collections</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
<groupId>maven-taglib</groupId>
<artifactId>maven-taglib-plugin</artifactId>
</dependency>
Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/pom.xml?rev=953759&r1=953758&r2=953759&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/pom.xml (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/pom.xml Fri Jun 11 16:36:16 2010
@@ -78,13 +78,6 @@
<scope>test</scope>
</dependency>
<dependency>
- <groupId>org.apache.shale</groupId>
- <artifactId>shale-test</artifactId>
- <version>1.0.4</version>
- <!--version>1.1.0-SNAPSHOT</version-->
- <scope>test</scope>
- </dependency>
- <dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<scope>test</scope>