MYFACESTEST-50: myfaces-test20 TestPerClassLoaderRunner non-functional. Thx to Matt Benson
diff --git a/test20/src/main/resources/org/apache/myfaces/test/runners/excluded.properties b/test20/src/main/resources/org/apache/myfaces/test/runners/excluded.properties
new file mode 100644
index 0000000..a936e9a
--- /dev/null
+++ b/test20/src/main/resources/org/apache/myfaces/test/runners/excluded.properties
@@ -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.*
diff --git a/test20/src/test/java/org/apache/myfaces/test/runner/TestPerCLassLoaderDefaultTestCase.java b/test20/src/test/java/org/apache/myfaces/test/runner/TestPerCLassLoaderDefaultTestCase.java
new file mode 100644
index 0000000..9106b8d
--- /dev/null
+++ b/test20/src/test/java/org/apache/myfaces/test/runner/TestPerCLassLoaderDefaultTestCase.java
@@ -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");
+ }
+}
diff --git a/test20/src/test/java/org/apache/myfaces/test/runner/TestPerClassLoaderTestCase.java b/test20/src/test/java/org/apache/myfaces/test/runner/TestPerClassLoaderTestCase.java
new file mode 100644
index 0000000..86fe9ed
--- /dev/null
+++ b/test20/src/test/java/org/apache/myfaces/test/runner/TestPerClassLoaderTestCase.java
@@ -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");
+ }
+}
diff --git a/test20/src/test/java/org/apache/myfaces/test/runner/WebXmlParameter.java b/test20/src/test/java/org/apache/myfaces/test/runner/WebXmlParameter.java
new file mode 100644
index 0000000..f8ad99b
--- /dev/null
+++ b/test20/src/test/java/org/apache/myfaces/test/runner/WebXmlParameter.java
@@ -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);
+
+}
diff --git a/test20/src/test/java/org/apache/myfaces/test/runner/WebXmlUtils.java b/test20/src/test/java/org/apache/myfaces/test/runner/WebXmlUtils.java
new file mode 100644
index 0000000..f122dfc
--- /dev/null
+++ b/test20/src/test/java/org/apache/myfaces/test/runner/WebXmlUtils.java
@@ -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;
+ }
+
+}