You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pluto-scm@portals.apache.org by as...@apache.org on 2018/01/05 15:01:37 UTC

[2/3] portals-pluto git commit: PLUTO-675 Move the web.xml parsing classes to tck-common

PLUTO-675 Move the web.xml parsing classes to tck-common


Project: http://git-wip-us.apache.org/repos/asf/portals-pluto/repo
Commit: http://git-wip-us.apache.org/repos/asf/portals-pluto/commit/fea0d6d0
Tree: http://git-wip-us.apache.org/repos/asf/portals-pluto/tree/fea0d6d0
Diff: http://git-wip-us.apache.org/repos/asf/portals-pluto/diff/fea0d6d0

Branch: refs/heads/master
Commit: fea0d6d0981a3ae9bae86d3b2b0b73360daa9ba1
Parents: a21ccfd
Author: Neil Griffin <ne...@gmail.com>
Authored: Fri Jan 5 09:59:36 2018 -0500
Committer: Neil Griffin <ne...@gmail.com>
Committed: Fri Jan 5 09:59:36 2018 -0500

----------------------------------------------------------------------
 .../portlet/tck/servlet/StartupListener.java    |  77 -------------
 .../javax/portlet/tck/util/ResourceReader.java  |  36 ------
 .../javax/portlet/tck/util/SAXHandlerBase.java  |  79 -------------
 .../java/javax/portlet/tck/util/WebConfig.java  |  48 --------
 .../javax/portlet/tck/util/WebConfigParser.java | 112 -------------------
 .../portlet/tck/util/WebConfigScanner.java      | 100 -----------------
 .../portlet/tck/servlet/StartupListener.java    |  77 +++++++++++++
 .../javax/portlet/tck/util/ResourceReader.java  |  36 ++++++
 .../javax/portlet/tck/util/SAXHandlerBase.java  |  79 +++++++++++++
 .../java/javax/portlet/tck/util/WebConfig.java  |  48 ++++++++
 .../javax/portlet/tck/util/WebConfigParser.java | 112 +++++++++++++++++++
 .../portlet/tck/util/WebConfigScanner.java      | 100 +++++++++++++++++
 12 files changed, 452 insertions(+), 452 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/fea0d6d0/portlet-tck_3.0/V2AddlEnvironmentTests/src/main/java/javax/portlet/tck/servlet/StartupListener.java
----------------------------------------------------------------------
diff --git a/portlet-tck_3.0/V2AddlEnvironmentTests/src/main/java/javax/portlet/tck/servlet/StartupListener.java b/portlet-tck_3.0/V2AddlEnvironmentTests/src/main/java/javax/portlet/tck/servlet/StartupListener.java
deleted file mode 100644
index 373b1fe..0000000
--- a/portlet-tck_3.0/V2AddlEnvironmentTests/src/main/java/javax/portlet/tck/servlet/StartupListener.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*  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 javax.portlet.tck.servlet;
-
-import java.util.Map;
-
-import javax.portlet.tck.util.ResourceReader;
-import javax.portlet.tck.util.WebConfig;
-import javax.portlet.tck.util.WebConfigScanner;
-import javax.servlet.ServletContext;
-import javax.servlet.ServletContextEvent;
-import javax.servlet.ServletContextListener;
-import javax.xml.parsers.SAXParser;
-import javax.xml.parsers.SAXParserFactory;
-
-public class StartupListener implements ServletContextListener {
-
-	private static Map<String, String> configuredContextParams;
-	private static String displayName;
-	private static ServletContext servletContext;
-
-	public static ServletContext getServletContext() {
-		return servletContext;
-	}
-
-	@Override
-	public void contextDestroyed(ServletContextEvent servletContextEvent) {
-	}
-
-	@Override
-	public void contextInitialized(ServletContextEvent servletContextEvent) {
-		servletContext = servletContextEvent.getServletContext();
-
-		ResourceReader resourceReader = new ResourceReader(servletContext);
-		SAXParserFactory saxParserFactory = SAXParserFactory.newInstance();
-		boolean validating = false;
-		saxParserFactory.setValidating(validating);
-		saxParserFactory.setNamespaceAware(true);
-		SAXParser saxParser;
-		try {
-			saxParser = saxParserFactory.newSAXParser();
-			boolean resolveEntities = false;
-			boolean scanWebFragments = true;
-			WebConfigScanner webConfigScanner = new WebConfigScanner(getClass().getClassLoader(), resourceReader,
-					saxParser, resolveEntities, scanWebFragments);
-			WebConfig webConfig = webConfigScanner.scan();
-			configuredContextParams = webConfig.getConfiguredContextParams();
-			displayName = webConfig.getDisplayName();
-		} catch (Exception e) {
-			e.printStackTrace();
-		}
-	}
-
-	public static Map<String, String> getConfiguredContextParams() {
-		return configuredContextParams;
-	}
-
-	public static String getDisplayName() {
-		return displayName;
-	}
-}

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/fea0d6d0/portlet-tck_3.0/V2AddlEnvironmentTests/src/main/java/javax/portlet/tck/util/ResourceReader.java
----------------------------------------------------------------------
diff --git a/portlet-tck_3.0/V2AddlEnvironmentTests/src/main/java/javax/portlet/tck/util/ResourceReader.java b/portlet-tck_3.0/V2AddlEnvironmentTests/src/main/java/javax/portlet/tck/util/ResourceReader.java
deleted file mode 100644
index 94e04d6..0000000
--- a/portlet-tck_3.0/V2AddlEnvironmentTests/src/main/java/javax/portlet/tck/util/ResourceReader.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*  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 javax.portlet.tck.util;
-
-import java.io.InputStream;
-
-import javax.servlet.ServletContext;
-
-public class ResourceReader {
-
-	private ServletContext servletContext;
-
-	public ResourceReader(ServletContext servletContext) {
-		this.servletContext = servletContext;
-	}
-
-	public InputStream getResourceAsStream(String path) {
-		return servletContext.getResourceAsStream(path);
-	}
-}

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/fea0d6d0/portlet-tck_3.0/V2AddlEnvironmentTests/src/main/java/javax/portlet/tck/util/SAXHandlerBase.java
----------------------------------------------------------------------
diff --git a/portlet-tck_3.0/V2AddlEnvironmentTests/src/main/java/javax/portlet/tck/util/SAXHandlerBase.java b/portlet-tck_3.0/V2AddlEnvironmentTests/src/main/java/javax/portlet/tck/util/SAXHandlerBase.java
deleted file mode 100644
index 85fe682..0000000
--- a/portlet-tck_3.0/V2AddlEnvironmentTests/src/main/java/javax/portlet/tck/util/SAXHandlerBase.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*  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 javax.portlet.tck.util;
-
-import java.io.IOException;
-import java.io.StringReader;
-import java.net.URL;
-
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-import org.xml.sax.helpers.DefaultHandler;
-
-public class SAXHandlerBase extends DefaultHandler {
-
-	// Protected Data Members
-	protected StringBuilder content;
-
-	// Private Data Members
-	private boolean resolveEntities;
-	private URL url;
-
-	public SAXHandlerBase(boolean resolveEntities) {
-		super();
-		this.resolveEntities = resolveEntities;
-	}
-
-	@Override
-	public void characters(char[] ch, int start, int length) throws SAXException {
-
-		if ((content != null) && (ch != null) && (length > 0)) {
-			content.append(ch, start, length);
-		}
-	}
-
-	@Override
-	public InputSource resolveEntity(String publicId, String systemId) throws IOException, SAXException {
-
-		InputSource inputSource = new InputSource(new StringReader(""));
-
-		if (resolveEntities) {
-			inputSource = super.resolveEntity(publicId, systemId);
-
-			if (inputSource == null) {
-
-				try {
-
-					// Note: Not sure why, but following line of code has suffered terrible performance problems.
-					// At times, it could take over a minute for the stream to open. This is why the web.xml
-					// default for resolving entities is false.
-					inputSource = new InputSource(new URL(systemId).openStream());
-				}
-				catch (IOException ioException) {
-
-					// Don't bother logging this as a warning or an error, because we can't assume connectivity to
-					// the Internet to download a public URL.
-					System.err.println("Unable to download publicId=[" + publicId + "], systemId=[" + systemId + "], referenced-in=[" + url +"]");
-				}
-			}
-		}
-
-		return inputSource;
-	}
-}

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/fea0d6d0/portlet-tck_3.0/V2AddlEnvironmentTests/src/main/java/javax/portlet/tck/util/WebConfig.java
----------------------------------------------------------------------
diff --git a/portlet-tck_3.0/V2AddlEnvironmentTests/src/main/java/javax/portlet/tck/util/WebConfig.java b/portlet-tck_3.0/V2AddlEnvironmentTests/src/main/java/javax/portlet/tck/util/WebConfig.java
deleted file mode 100644
index 0892d29..0000000
--- a/portlet-tck_3.0/V2AddlEnvironmentTests/src/main/java/javax/portlet/tck/util/WebConfig.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*  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 javax.portlet.tck.util;
-
-import java.util.HashMap;
-import java.util.Map;
-
-public class WebConfig {
-
-	// Private Data Members
-	private Map<String, String> configuredContextParams;
-	private String displayName;
-
-	public WebConfig() {
-		this.configuredContextParams = new HashMap<String, String>();
-	}
-
-	public WebConfig(
-		Map<String, String> configuredContextParams, String displayName) {
-
-		this.configuredContextParams = configuredContextParams;
-		this.displayName = displayName;
-	}
-
-	public Map<String, String> getConfiguredContextParams() {
-		return configuredContextParams;
-	}
-
-	public String getDisplayName() {
-		return displayName;
-	}
-}

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/fea0d6d0/portlet-tck_3.0/V2AddlEnvironmentTests/src/main/java/javax/portlet/tck/util/WebConfigParser.java
----------------------------------------------------------------------
diff --git a/portlet-tck_3.0/V2AddlEnvironmentTests/src/main/java/javax/portlet/tck/util/WebConfigParser.java b/portlet-tck_3.0/V2AddlEnvironmentTests/src/main/java/javax/portlet/tck/util/WebConfigParser.java
deleted file mode 100644
index a2d4344..0000000
--- a/portlet-tck_3.0/V2AddlEnvironmentTests/src/main/java/javax/portlet/tck/util/WebConfigParser.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*  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 javax.portlet.tck.util;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.xml.parsers.SAXParser;
-
-import org.xml.sax.Attributes;
-import org.xml.sax.SAXException;
-
-public class WebConfigParser extends SAXHandlerBase {
-
-	// Private Constants
-	private static final String CONTEXT_PARAM = "context-param";
-	private static final String DISPLAY_NAME = "display-name";
-	private static final String PARAM_VALUE = "param-value";
-	private static final String PARAM_NAME = "param-name";
-
-	// Private Data Members
-	private Map<String, String> configuredContextParams;
-	private String displayName;
-	private boolean parsingContextParam;
-	private boolean parsingDisplayName;
-	private boolean parsingParamName;
-	private boolean parsingParamValue;
-	private String paramValue;
-	private String paramName;
-	private SAXParser saxParser;
-
-	public WebConfigParser(SAXParser saxParser, boolean resolveEntities) {
-		super(resolveEntities);
-		this.saxParser = saxParser;
-	}
-
-	@Override
-	public void endElement(String uri, String localName, String qName) throws SAXException {
-
-		if (parsingDisplayName) {
-			displayName = content.toString().trim();
-			parsingDisplayName = false;
-		} else if (parsingContextParam) {
-
-			if (parsingParamName) {
-				paramName = content.toString().trim();
-				parsingParamName = false;
-			} else if (parsingParamValue) {
-				paramValue = content.toString().trim();
-				parsingParamValue = false;
-			}
-
-			if (CONTEXT_PARAM.equals(qName)) {
-				System.out.println("    Found context-param name=" + paramName + " value=" + paramValue);
-				configuredContextParams.put(paramName, paramValue);
-				parsingContextParam = false;
-			}
-		}
-	}
-
-	public WebConfig parse(InputStream inputStream, WebConfig webConfig) throws IOException {
-
-		Map<String, String> configuredContextParams = webConfig.getConfiguredContextParams();
-		this.configuredContextParams = new HashMap<String, String>(configuredContextParams);
-
-		try {
-			saxParser.parse(inputStream, this);
-			webConfig = new WebConfig(this.configuredContextParams, this.displayName);
-			saxParser.reset();
-
-			return webConfig;
-		} catch (SAXException e) {
-			e.printStackTrace();
-			throw new IOException(e.getMessage());
-		}
-	}
-
-	@Override
-	public void startElement(String uri, String localName, String elementName, Attributes attributes)
-			throws SAXException {
-
-		content = new StringBuilder();
-
-		if (localName.equals(DISPLAY_NAME)) {
-			parsingDisplayName = true;
-		} else if (localName.equals(CONTEXT_PARAM)) {
-			parsingContextParam = true;
-		} else if (localName.equals(PARAM_NAME)) {
-			parsingParamName = true;
-		} else if (localName.equals(PARAM_VALUE)) {
-			parsingParamValue = true;
-		}
-	}
-}

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/fea0d6d0/portlet-tck_3.0/V2AddlEnvironmentTests/src/main/java/javax/portlet/tck/util/WebConfigScanner.java
----------------------------------------------------------------------
diff --git a/portlet-tck_3.0/V2AddlEnvironmentTests/src/main/java/javax/portlet/tck/util/WebConfigScanner.java b/portlet-tck_3.0/V2AddlEnvironmentTests/src/main/java/javax/portlet/tck/util/WebConfigScanner.java
deleted file mode 100644
index ea870a9..0000000
--- a/portlet-tck_3.0/V2AddlEnvironmentTests/src/main/java/javax/portlet/tck/util/WebConfigScanner.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*  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 javax.portlet.tck.util;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-import java.util.Enumeration;
-
-import javax.xml.parsers.SAXParser;
-
-public class WebConfigScanner {
-
-	// Private Constants
-	private static final String WEB_XML_PATH = "/WEB-INF/web.xml";
-	private static final String WEB_FRAGMENT_META_INF_PATH = "META-INF/web-fragment.xml";
-
-	// Private Data Members
-	private ClassLoader classLoader;
-	private boolean resolveEntities;
-	private ResourceReader resourceReader;
-	private SAXParser saxParser;
-	private boolean scanWebFragments;
-
-	public WebConfigScanner(ClassLoader classLoader, ResourceReader resourceReader, SAXParser saxParser,
-			boolean resolveEntities, boolean scanWebFragments) {
-		this.classLoader = classLoader;
-		this.resourceReader = resourceReader;
-		this.saxParser = saxParser;
-		this.resolveEntities = resolveEntities;
-		this.scanWebFragments = scanWebFragments;
-	}
-
-	protected WebConfigParser newWebConfigParser() {
-		return new WebConfigParser(saxParser, resolveEntities);
-	}
-
-	public WebConfig scan() throws IOException {
-
-		// Parse the Servlet 3.0 META-INF/web-fragment.xml descriptor files
-		// found in the classpath.
-		WebConfig webConfig = new WebConfig();
-		InputStream inputStream = null;
-		if (scanWebFragments) {
-			Enumeration<URL> webFragmentURLs = classLoader.getResources(WEB_FRAGMENT_META_INF_PATH);
-
-			if (webFragmentURLs != null) {
-
-				while (webFragmentURLs.hasMoreElements()) {
-					URL webFragmentURL = webFragmentURLs.nextElement();
-					System.out.println("Processing web-fragment: [" + webFragmentURL + "]");
-					inputStream = webFragmentURL.openStream();
-
-					WebConfigParser webConfigParser = newWebConfigParser();
-
-					try {
-						webConfig = webConfigParser.parse(inputStream, webConfig);
-						inputStream.close();
-					} catch (Exception e) {
-						e.printStackTrace();
-					}
-				}
-			}
-		}
-
-		// Parse the WEB-INF/web.xml descriptor.
-		inputStream = resourceReader.getResourceAsStream(WEB_XML_PATH);
-
-		if (inputStream != null) {
-			System.out.println("Processing web-app: [" + WEB_XML_PATH + "]");
-
-			WebConfigParser webConfigParser = newWebConfigParser();
-
-			try {
-				webConfig = webConfigParser.parse(inputStream, webConfig);
-			} catch (IOException e) {
-				e.printStackTrace();
-				throw new IOException(e.getMessage());
-			}
-		}
-
-		return webConfig;
-	}
-}

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/fea0d6d0/portlet-tck_3.0/common/src/main/java/javax/portlet/tck/servlet/StartupListener.java
----------------------------------------------------------------------
diff --git a/portlet-tck_3.0/common/src/main/java/javax/portlet/tck/servlet/StartupListener.java b/portlet-tck_3.0/common/src/main/java/javax/portlet/tck/servlet/StartupListener.java
new file mode 100644
index 0000000..373b1fe
--- /dev/null
+++ b/portlet-tck_3.0/common/src/main/java/javax/portlet/tck/servlet/StartupListener.java
@@ -0,0 +1,77 @@
+/*  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 javax.portlet.tck.servlet;
+
+import java.util.Map;
+
+import javax.portlet.tck.util.ResourceReader;
+import javax.portlet.tck.util.WebConfig;
+import javax.portlet.tck.util.WebConfigScanner;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletContextEvent;
+import javax.servlet.ServletContextListener;
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
+
+public class StartupListener implements ServletContextListener {
+
+	private static Map<String, String> configuredContextParams;
+	private static String displayName;
+	private static ServletContext servletContext;
+
+	public static ServletContext getServletContext() {
+		return servletContext;
+	}
+
+	@Override
+	public void contextDestroyed(ServletContextEvent servletContextEvent) {
+	}
+
+	@Override
+	public void contextInitialized(ServletContextEvent servletContextEvent) {
+		servletContext = servletContextEvent.getServletContext();
+
+		ResourceReader resourceReader = new ResourceReader(servletContext);
+		SAXParserFactory saxParserFactory = SAXParserFactory.newInstance();
+		boolean validating = false;
+		saxParserFactory.setValidating(validating);
+		saxParserFactory.setNamespaceAware(true);
+		SAXParser saxParser;
+		try {
+			saxParser = saxParserFactory.newSAXParser();
+			boolean resolveEntities = false;
+			boolean scanWebFragments = true;
+			WebConfigScanner webConfigScanner = new WebConfigScanner(getClass().getClassLoader(), resourceReader,
+					saxParser, resolveEntities, scanWebFragments);
+			WebConfig webConfig = webConfigScanner.scan();
+			configuredContextParams = webConfig.getConfiguredContextParams();
+			displayName = webConfig.getDisplayName();
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+	}
+
+	public static Map<String, String> getConfiguredContextParams() {
+		return configuredContextParams;
+	}
+
+	public static String getDisplayName() {
+		return displayName;
+	}
+}

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/fea0d6d0/portlet-tck_3.0/common/src/main/java/javax/portlet/tck/util/ResourceReader.java
----------------------------------------------------------------------
diff --git a/portlet-tck_3.0/common/src/main/java/javax/portlet/tck/util/ResourceReader.java b/portlet-tck_3.0/common/src/main/java/javax/portlet/tck/util/ResourceReader.java
new file mode 100644
index 0000000..94e04d6
--- /dev/null
+++ b/portlet-tck_3.0/common/src/main/java/javax/portlet/tck/util/ResourceReader.java
@@ -0,0 +1,36 @@
+/*  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 javax.portlet.tck.util;
+
+import java.io.InputStream;
+
+import javax.servlet.ServletContext;
+
+public class ResourceReader {
+
+	private ServletContext servletContext;
+
+	public ResourceReader(ServletContext servletContext) {
+		this.servletContext = servletContext;
+	}
+
+	public InputStream getResourceAsStream(String path) {
+		return servletContext.getResourceAsStream(path);
+	}
+}

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/fea0d6d0/portlet-tck_3.0/common/src/main/java/javax/portlet/tck/util/SAXHandlerBase.java
----------------------------------------------------------------------
diff --git a/portlet-tck_3.0/common/src/main/java/javax/portlet/tck/util/SAXHandlerBase.java b/portlet-tck_3.0/common/src/main/java/javax/portlet/tck/util/SAXHandlerBase.java
new file mode 100644
index 0000000..85fe682
--- /dev/null
+++ b/portlet-tck_3.0/common/src/main/java/javax/portlet/tck/util/SAXHandlerBase.java
@@ -0,0 +1,79 @@
+/*  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 javax.portlet.tck.util;
+
+import java.io.IOException;
+import java.io.StringReader;
+import java.net.URL;
+
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.DefaultHandler;
+
+public class SAXHandlerBase extends DefaultHandler {
+
+	// Protected Data Members
+	protected StringBuilder content;
+
+	// Private Data Members
+	private boolean resolveEntities;
+	private URL url;
+
+	public SAXHandlerBase(boolean resolveEntities) {
+		super();
+		this.resolveEntities = resolveEntities;
+	}
+
+	@Override
+	public void characters(char[] ch, int start, int length) throws SAXException {
+
+		if ((content != null) && (ch != null) && (length > 0)) {
+			content.append(ch, start, length);
+		}
+	}
+
+	@Override
+	public InputSource resolveEntity(String publicId, String systemId) throws IOException, SAXException {
+
+		InputSource inputSource = new InputSource(new StringReader(""));
+
+		if (resolveEntities) {
+			inputSource = super.resolveEntity(publicId, systemId);
+
+			if (inputSource == null) {
+
+				try {
+
+					// Note: Not sure why, but following line of code has suffered terrible performance problems.
+					// At times, it could take over a minute for the stream to open. This is why the web.xml
+					// default for resolving entities is false.
+					inputSource = new InputSource(new URL(systemId).openStream());
+				}
+				catch (IOException ioException) {
+
+					// Don't bother logging this as a warning or an error, because we can't assume connectivity to
+					// the Internet to download a public URL.
+					System.err.println("Unable to download publicId=[" + publicId + "], systemId=[" + systemId + "], referenced-in=[" + url +"]");
+				}
+			}
+		}
+
+		return inputSource;
+	}
+}

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/fea0d6d0/portlet-tck_3.0/common/src/main/java/javax/portlet/tck/util/WebConfig.java
----------------------------------------------------------------------
diff --git a/portlet-tck_3.0/common/src/main/java/javax/portlet/tck/util/WebConfig.java b/portlet-tck_3.0/common/src/main/java/javax/portlet/tck/util/WebConfig.java
new file mode 100644
index 0000000..0892d29
--- /dev/null
+++ b/portlet-tck_3.0/common/src/main/java/javax/portlet/tck/util/WebConfig.java
@@ -0,0 +1,48 @@
+/*  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 javax.portlet.tck.util;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class WebConfig {
+
+	// Private Data Members
+	private Map<String, String> configuredContextParams;
+	private String displayName;
+
+	public WebConfig() {
+		this.configuredContextParams = new HashMap<String, String>();
+	}
+
+	public WebConfig(
+		Map<String, String> configuredContextParams, String displayName) {
+
+		this.configuredContextParams = configuredContextParams;
+		this.displayName = displayName;
+	}
+
+	public Map<String, String> getConfiguredContextParams() {
+		return configuredContextParams;
+	}
+
+	public String getDisplayName() {
+		return displayName;
+	}
+}

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/fea0d6d0/portlet-tck_3.0/common/src/main/java/javax/portlet/tck/util/WebConfigParser.java
----------------------------------------------------------------------
diff --git a/portlet-tck_3.0/common/src/main/java/javax/portlet/tck/util/WebConfigParser.java b/portlet-tck_3.0/common/src/main/java/javax/portlet/tck/util/WebConfigParser.java
new file mode 100644
index 0000000..a2d4344
--- /dev/null
+++ b/portlet-tck_3.0/common/src/main/java/javax/portlet/tck/util/WebConfigParser.java
@@ -0,0 +1,112 @@
+/*  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 javax.portlet.tck.util;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.xml.parsers.SAXParser;
+
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+
+public class WebConfigParser extends SAXHandlerBase {
+
+	// Private Constants
+	private static final String CONTEXT_PARAM = "context-param";
+	private static final String DISPLAY_NAME = "display-name";
+	private static final String PARAM_VALUE = "param-value";
+	private static final String PARAM_NAME = "param-name";
+
+	// Private Data Members
+	private Map<String, String> configuredContextParams;
+	private String displayName;
+	private boolean parsingContextParam;
+	private boolean parsingDisplayName;
+	private boolean parsingParamName;
+	private boolean parsingParamValue;
+	private String paramValue;
+	private String paramName;
+	private SAXParser saxParser;
+
+	public WebConfigParser(SAXParser saxParser, boolean resolveEntities) {
+		super(resolveEntities);
+		this.saxParser = saxParser;
+	}
+
+	@Override
+	public void endElement(String uri, String localName, String qName) throws SAXException {
+
+		if (parsingDisplayName) {
+			displayName = content.toString().trim();
+			parsingDisplayName = false;
+		} else if (parsingContextParam) {
+
+			if (parsingParamName) {
+				paramName = content.toString().trim();
+				parsingParamName = false;
+			} else if (parsingParamValue) {
+				paramValue = content.toString().trim();
+				parsingParamValue = false;
+			}
+
+			if (CONTEXT_PARAM.equals(qName)) {
+				System.out.println("    Found context-param name=" + paramName + " value=" + paramValue);
+				configuredContextParams.put(paramName, paramValue);
+				parsingContextParam = false;
+			}
+		}
+	}
+
+	public WebConfig parse(InputStream inputStream, WebConfig webConfig) throws IOException {
+
+		Map<String, String> configuredContextParams = webConfig.getConfiguredContextParams();
+		this.configuredContextParams = new HashMap<String, String>(configuredContextParams);
+
+		try {
+			saxParser.parse(inputStream, this);
+			webConfig = new WebConfig(this.configuredContextParams, this.displayName);
+			saxParser.reset();
+
+			return webConfig;
+		} catch (SAXException e) {
+			e.printStackTrace();
+			throw new IOException(e.getMessage());
+		}
+	}
+
+	@Override
+	public void startElement(String uri, String localName, String elementName, Attributes attributes)
+			throws SAXException {
+
+		content = new StringBuilder();
+
+		if (localName.equals(DISPLAY_NAME)) {
+			parsingDisplayName = true;
+		} else if (localName.equals(CONTEXT_PARAM)) {
+			parsingContextParam = true;
+		} else if (localName.equals(PARAM_NAME)) {
+			parsingParamName = true;
+		} else if (localName.equals(PARAM_VALUE)) {
+			parsingParamValue = true;
+		}
+	}
+}

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/fea0d6d0/portlet-tck_3.0/common/src/main/java/javax/portlet/tck/util/WebConfigScanner.java
----------------------------------------------------------------------
diff --git a/portlet-tck_3.0/common/src/main/java/javax/portlet/tck/util/WebConfigScanner.java b/portlet-tck_3.0/common/src/main/java/javax/portlet/tck/util/WebConfigScanner.java
new file mode 100644
index 0000000..ea870a9
--- /dev/null
+++ b/portlet-tck_3.0/common/src/main/java/javax/portlet/tck/util/WebConfigScanner.java
@@ -0,0 +1,100 @@
+/*  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 javax.portlet.tck.util;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.Enumeration;
+
+import javax.xml.parsers.SAXParser;
+
+public class WebConfigScanner {
+
+	// Private Constants
+	private static final String WEB_XML_PATH = "/WEB-INF/web.xml";
+	private static final String WEB_FRAGMENT_META_INF_PATH = "META-INF/web-fragment.xml";
+
+	// Private Data Members
+	private ClassLoader classLoader;
+	private boolean resolveEntities;
+	private ResourceReader resourceReader;
+	private SAXParser saxParser;
+	private boolean scanWebFragments;
+
+	public WebConfigScanner(ClassLoader classLoader, ResourceReader resourceReader, SAXParser saxParser,
+			boolean resolveEntities, boolean scanWebFragments) {
+		this.classLoader = classLoader;
+		this.resourceReader = resourceReader;
+		this.saxParser = saxParser;
+		this.resolveEntities = resolveEntities;
+		this.scanWebFragments = scanWebFragments;
+	}
+
+	protected WebConfigParser newWebConfigParser() {
+		return new WebConfigParser(saxParser, resolveEntities);
+	}
+
+	public WebConfig scan() throws IOException {
+
+		// Parse the Servlet 3.0 META-INF/web-fragment.xml descriptor files
+		// found in the classpath.
+		WebConfig webConfig = new WebConfig();
+		InputStream inputStream = null;
+		if (scanWebFragments) {
+			Enumeration<URL> webFragmentURLs = classLoader.getResources(WEB_FRAGMENT_META_INF_PATH);
+
+			if (webFragmentURLs != null) {
+
+				while (webFragmentURLs.hasMoreElements()) {
+					URL webFragmentURL = webFragmentURLs.nextElement();
+					System.out.println("Processing web-fragment: [" + webFragmentURL + "]");
+					inputStream = webFragmentURL.openStream();
+
+					WebConfigParser webConfigParser = newWebConfigParser();
+
+					try {
+						webConfig = webConfigParser.parse(inputStream, webConfig);
+						inputStream.close();
+					} catch (Exception e) {
+						e.printStackTrace();
+					}
+				}
+			}
+		}
+
+		// Parse the WEB-INF/web.xml descriptor.
+		inputStream = resourceReader.getResourceAsStream(WEB_XML_PATH);
+
+		if (inputStream != null) {
+			System.out.println("Processing web-app: [" + WEB_XML_PATH + "]");
+
+			WebConfigParser webConfigParser = newWebConfigParser();
+
+			try {
+				webConfig = webConfigParser.parse(inputStream, webConfig);
+			} catch (IOException e) {
+				e.printStackTrace();
+				throw new IOException(e.getMessage());
+			}
+		}
+
+		return webConfig;
+	}
+}