You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by rd...@apache.org on 2011/05/26 15:58:16 UTC

svn commit: r1127916 - in /myfaces/test/trunk/test20/src: main/resources/org/ main/resources/org/apache/ main/resources/org/apache/myfaces/ main/resources/org/apache/myfaces/test/ main/resources/org/apache/myfaces/test/runners/ test/java/org/apache/myf...

Author: rdebusscher
Date: Thu May 26 13:58:16 2011
New Revision: 1127916

URL: http://svn.apache.org/viewvc?rev=1127916&view=rev
Log:
MYFACESTEST-50: myfaces-test20 TestPerClassLoaderRunner non-functional. Thx to Matt Benson

Added:
    myfaces/test/trunk/test20/src/main/resources/org/
    myfaces/test/trunk/test20/src/main/resources/org/apache/
    myfaces/test/trunk/test20/src/main/resources/org/apache/myfaces/
    myfaces/test/trunk/test20/src/main/resources/org/apache/myfaces/test/
    myfaces/test/trunk/test20/src/main/resources/org/apache/myfaces/test/runners/
    myfaces/test/trunk/test20/src/main/resources/org/apache/myfaces/test/runners/excluded.properties
    myfaces/test/trunk/test20/src/test/java/org/apache/myfaces/test/runner/
    myfaces/test/trunk/test20/src/test/java/org/apache/myfaces/test/runner/TestPerCLassLoaderDefaultTestCase.java
    myfaces/test/trunk/test20/src/test/java/org/apache/myfaces/test/runner/TestPerClassLoaderTestCase.java
    myfaces/test/trunk/test20/src/test/java/org/apache/myfaces/test/runner/WebXmlParameter.java
    myfaces/test/trunk/test20/src/test/java/org/apache/myfaces/test/runner/WebXmlUtils.java

Added: myfaces/test/trunk/test20/src/main/resources/org/apache/myfaces/test/runners/excluded.properties
URL: http://svn.apache.org/viewvc/myfaces/test/trunk/test20/src/main/resources/org/apache/myfaces/test/runners/excluded.properties?rev=1127916&view=auto
==============================================================================
--- myfaces/test/trunk/test20/src/main/resources/org/apache/myfaces/test/runners/excluded.properties (added)
+++ myfaces/test/trunk/test20/src/main/resources/org/apache/myfaces/test/runners/excluded.properties Thu May 26 13:58:16 2011
@@ -0,0 +1,12 @@
+#
+# The list of excluded package paths for the TestCaseClassLoader
+#
+excluded.0=sun.*
+excluded.1=com.sun.*
+excluded.2=org.omg.*
+excluded.3=javax.*
+excluded.4=sunw.*
+excluded.5=java.*
+excluded.6=org.w3c.dom.*
+excluded.7=org.xml.sax.*
+excluded.8=net.jini.*

Added: myfaces/test/trunk/test20/src/test/java/org/apache/myfaces/test/runner/TestPerCLassLoaderDefaultTestCase.java
URL: http://svn.apache.org/viewvc/myfaces/test/trunk/test20/src/test/java/org/apache/myfaces/test/runner/TestPerCLassLoaderDefaultTestCase.java?rev=1127916&view=auto
==============================================================================
--- myfaces/test/trunk/test20/src/test/java/org/apache/myfaces/test/runner/TestPerCLassLoaderDefaultTestCase.java (added)
+++ myfaces/test/trunk/test20/src/test/java/org/apache/myfaces/test/runner/TestPerCLassLoaderDefaultTestCase.java Thu May 26 13:58:16 2011
@@ -0,0 +1,71 @@
+/*
+ * 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.
+ */
+package org.apache.myfaces.test.runner;
+
+import junit.framework.Assert;
+
+import org.apache.myfaces.test.base.junit4.AbstractJsfConfigurableMockTestCase;
+import org.apache.myfaces.test.runners.NamedRunner;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+/**
+ * 
+ * @author Rudy De Busscher
+ */
+@RunWith(value = NamedRunner.class)
+public class TestPerCLassLoaderDefaultTestCase extends
+        AbstractJsfConfigurableMockTestCase
+{
+
+    @Override
+    protected void setUpExternalContext() throws Exception
+    {
+
+        super.setUpExternalContext();
+
+        if (needXmlParameters())
+        {
+            servletContext
+                    .addInitParameter(WebXmlParameter.PARAMETER_KEY, "60");
+        }
+
+    }
+
+    @Test
+    public void testGetParameterDefault()
+    {
+        Assert.assertNull(WebXmlParameter.PARAMETER);
+    }
+
+    @Test
+    public void testGetParameterWebXml()
+    {
+
+        Assert.assertNull(WebXmlParameter.PARAMETER);
+        // Although the parameter is set, the final variable keeps it value
+        // Since we aren't running with the TestPerClassLoader Test case.
+        Assert.assertNotNull(servletContext
+                .getInitParameter(WebXmlParameter.PARAMETER_KEY));
+    }
+
+    // These methods can be placed in a common super class.
+    protected boolean needXmlParameters()
+    {
+        return NamedRunner.getTestMethodName().contains("Xml");
+    }
+}

Added: myfaces/test/trunk/test20/src/test/java/org/apache/myfaces/test/runner/TestPerClassLoaderTestCase.java
URL: http://svn.apache.org/viewvc/myfaces/test/trunk/test20/src/test/java/org/apache/myfaces/test/runner/TestPerClassLoaderTestCase.java?rev=1127916&view=auto
==============================================================================
--- myfaces/test/trunk/test20/src/test/java/org/apache/myfaces/test/runner/TestPerClassLoaderTestCase.java (added)
+++ myfaces/test/trunk/test20/src/test/java/org/apache/myfaces/test/runner/TestPerClassLoaderTestCase.java Thu May 26 13:58:16 2011
@@ -0,0 +1,66 @@
+/*
+ * 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.
+ */
+package org.apache.myfaces.test.runner;
+
+import junit.framework.Assert;
+
+import org.apache.myfaces.test.base.junit4.AbstractJsfConfigurableMockTestCase;
+import org.apache.myfaces.test.runners.TestPerClassLoaderRunner;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+/**
+ * 
+ * @author Rudy De Busscher
+ */
+@RunWith(value = TestPerClassLoaderRunner.class)
+public class TestPerClassLoaderTestCase extends
+        AbstractJsfConfigurableMockTestCase
+{
+
+    @Override
+    protected void setUpExternalContext() throws Exception
+    {
+
+        super.setUpExternalContext();
+
+        if (needXmlParameters())
+        {
+            servletContext
+                    .addInitParameter(WebXmlParameter.PARAMETER_KEY, "60");
+        }
+
+    }
+
+    @Test
+    public void testGetParameterDefault()
+    {
+        Assert.assertNull(WebXmlParameter.PARAMETER);
+    }
+
+    @Test
+    public void testGetParameterWebXml()
+    {
+        Assert.assertEquals("60", WebXmlParameter.PARAMETER);
+    }
+
+    // These methods can be placed in a common super class.
+    protected boolean needXmlParameters()
+    {
+        return TestPerClassLoaderRunner.getTestMethodName().contains("Xml");
+    }
+}

Added: myfaces/test/trunk/test20/src/test/java/org/apache/myfaces/test/runner/WebXmlParameter.java
URL: http://svn.apache.org/viewvc/myfaces/test/trunk/test20/src/test/java/org/apache/myfaces/test/runner/WebXmlParameter.java?rev=1127916&view=auto
==============================================================================
--- myfaces/test/trunk/test20/src/test/java/org/apache/myfaces/test/runner/WebXmlParameter.java (added)
+++ myfaces/test/trunk/test20/src/test/java/org/apache/myfaces/test/runner/WebXmlParameter.java Thu May 26 13:58:16 2011
@@ -0,0 +1,29 @@
+/*
+ * 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.
+ */
+package org.apache.myfaces.test.runner;
+
+/**
+ * 
+ * @author Rudy De Busscher
+ */
+public class WebXmlParameter
+{
+    public static final String PARAMETER_KEY = "PARAMETER";
+
+    static final String PARAMETER = WebXmlUtils.getInitParameter(PARAMETER_KEY);
+
+}

Added: myfaces/test/trunk/test20/src/test/java/org/apache/myfaces/test/runner/WebXmlUtils.java
URL: http://svn.apache.org/viewvc/myfaces/test/trunk/test20/src/test/java/org/apache/myfaces/test/runner/WebXmlUtils.java?rev=1127916&view=auto
==============================================================================
--- myfaces/test/trunk/test20/src/test/java/org/apache/myfaces/test/runner/WebXmlUtils.java (added)
+++ myfaces/test/trunk/test20/src/test/java/org/apache/myfaces/test/runner/WebXmlUtils.java Thu May 26 13:58:16 2011
@@ -0,0 +1,40 @@
+/*
+ * 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.
+ */
+package org.apache.myfaces.test.runner;
+
+import javax.faces.context.FacesContext;
+
+/**
+ * 
+ * @author Rudy De Busscher
+ */
+public final class WebXmlUtils
+{
+
+    private WebXmlUtils()
+    {
+
+    }
+
+    public static String getInitParameter(String parameterName)
+    {
+        String value = FacesContext.getCurrentInstance().getExternalContext()
+                .getInitParameter(parameterName);
+        return (value != null) ? value.replace(" ", "").trim() : null;
+    }
+
+}