Fix for: https://bugs.eclipse.org/bugs/show_bug.cgi?id=149743

Adds null check for IValidValues.getExpectedReturnType().
Test coverage for case.
diff --git a/jsf/tests/org.eclipse.jst.jsf.contentassist.tests/META-INF/MANIFEST.MF b/jsf/tests/org.eclipse.jst.jsf.contentassist.tests/META-INF/MANIFEST.MF
index d988dd0..0f5e5d2 100644
--- a/jsf/tests/org.eclipse.jst.jsf.contentassist.tests/META-INF/MANIFEST.MF
+++ b/jsf/tests/org.eclipse.jst.jsf.contentassist.tests/META-INF/MANIFEST.MF
@@ -3,11 +3,22 @@
 Bundle-Name: org.eclipse.jst.jsf.contentassist Tests Plug-in
 Bundle-SymbolicName: org.eclipse.jst.jsf.contentassist.tests
 Bundle-Version: 0.5.0
-Bundle-Activator: org.eclipse.jst.jsf.contentassist.tests.Activator
+Bundle-Activator: org.eclipse.jst.jsf.contentassist.tests.ContentAssistTestsPlugin
 Bundle-Localization: plugin
 Bundle-ClassPath: jsfcontentassisttests.jar
 Require-Bundle: org.eclipse.ui,
  org.eclipse.core.runtime,
  org.junit,
- org.eclipse.jst.jsf.contentassist
+ org.eclipse.jst.jsf.contentassist,
+ org.eclipse.jst.jsf.test.util,
+ org.eclipse.core.resources,
+ org.eclipse.wst.sse.core,
+ org.eclipse.jst.jsp.core,
+ org.eclipse.wst.html.core,
+ org.eclipse.wst.xml.core,
+ org.eclipse.jst.jsf.context,
+ org.eclipse.jst.jsf.context.resolver,
+ org.eclipse.jst.jsf.context.resolver.structureddocument,
+ org.eclipse.jst.jsf.context.structureddocument,
+ org.eclipse.jst.jsf.core.tests
 Eclipse-LazyStart: true
diff --git a/jsf/tests/org.eclipse.jst.jsf.contentassist.tests/src/org/eclipse/jst/jsf/contentassist/tests/Activator.java b/jsf/tests/org.eclipse.jst.jsf.contentassist.tests/src/org/eclipse/jst/jsf/contentassist/tests/ContentAssistTestsPlugin.java
similarity index 87%
rename from jsf/tests/org.eclipse.jst.jsf.contentassist.tests/src/org/eclipse/jst/jsf/contentassist/tests/Activator.java
rename to jsf/tests/org.eclipse.jst.jsf.contentassist.tests/src/org/eclipse/jst/jsf/contentassist/tests/ContentAssistTestsPlugin.java
index a9c3275..883b8c9 100644
--- a/jsf/tests/org.eclipse.jst.jsf.contentassist.tests/src/org/eclipse/jst/jsf/contentassist/tests/Activator.java
+++ b/jsf/tests/org.eclipse.jst.jsf.contentassist.tests/src/org/eclipse/jst/jsf/contentassist/tests/ContentAssistTestsPlugin.java
@@ -18,7 +18,7 @@
 /**
  * The activator class controls the plug-in life cycle
  */
-public class Activator extends AbstractUIPlugin {
+public class ContentAssistTestsPlugin extends AbstractUIPlugin {
 
 	/**
 	 * The plug-in ID
@@ -26,12 +26,12 @@
 	public static final String PLUGIN_ID = "org.eclipse.jst.jsf.contentassist.tests";
 
 	// The shared instance
-	private static Activator plugin;
+	private static ContentAssistTestsPlugin plugin;
 	
 	/**
 	 * The constructor
 	 */
-	public Activator() {
+	public ContentAssistTestsPlugin() {
 		plugin = this;
 	}
 
@@ -57,7 +57,7 @@
 	 *
 	 * @return the shared instance
 	 */
-	public static Activator getDefault() {
+	public static ContentAssistTestsPlugin getDefault() {
 		return plugin;
 	}
 
diff --git a/jsf/tests/org.eclipse.jst.jsf.contentassist.tests/src/org/eclipse/jst/jsf/contentassist/tests/Test_bug_149743.java b/jsf/tests/org.eclipse.jst.jsf.contentassist.tests/src/org/eclipse/jst/jsf/contentassist/tests/Test_bug_149743.java
new file mode 100644
index 0000000..4cf3592
--- /dev/null
+++ b/jsf/tests/org.eclipse.jst.jsf.contentassist.tests/src/org/eclipse/jst/jsf/contentassist/tests/Test_bug_149743.java
@@ -0,0 +1,180 @@
+package org.eclipse.jst.jsf.contentassist.tests;
+
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jface.text.contentassist.ICompletionProposal;
+import org.eclipse.jst.jsf.contentassist.internal.el.ContentAssistParser;
+import org.eclipse.jst.jsf.contentassist.internal.el.ContentAssistStrategy;
+import org.eclipse.jst.jsf.context.resolver.structureddocument.internal.ITextRegionContextResolver;
+import org.eclipse.jst.jsf.context.resolver.structureddocument.internal.provisional.IDOMContextResolver;
+import org.eclipse.jst.jsf.context.resolver.structureddocument.internal.provisional.IStructuredDocumentContextResolverFactory;
+import org.eclipse.jst.jsf.context.structureddocument.internal.provisional.IStructuredDocumentContext;
+import org.eclipse.jst.jsf.context.structureddocument.internal.provisional.IStructuredDocumentContextFactory;
+import org.eclipse.jst.jsf.core.tests.util.JSFFacetedTestEnvironment;
+import org.eclipse.jst.jsf.test.util.JDTTestEnvironment;
+import org.eclipse.jst.jsf.test.util.TestFileResource;
+import org.eclipse.jst.jsf.test.util.WebProjectTestEnvironment;
+import org.eclipse.jst.jsp.core.internal.domdocument.DOMModelForJSP;
+import org.eclipse.wst.sse.core.StructuredModelManager;
+import org.eclipse.wst.sse.core.internal.provisional.IModelManager;
+import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Node;
+
+/**
+ * Test a situation where no expected return type information is 
+ * available for a tag.
+ * 
+ * @author cbateman
+ *
+ */
+public class Test_bug_149743 extends TestCase 
+{
+    private WebProjectTestEnvironment       _testEnv;
+    
+    protected void setUp() throws Exception 
+    {
+        super.setUp();
+
+        _testEnv = new WebProjectTestEnvironment("Test_bug_149743_"+getName());
+        _testEnv.createProject();
+        assertNotNull(_testEnv);       
+        assertNotNull(_testEnv.getTestProject());
+        assertTrue(_testEnv.getTestProject().isAccessible());
+        
+        JSFFacetedTestEnvironment jsfFacedEnv = new JSFFacetedTestEnvironment(_testEnv);
+        jsfFacedEnv.initialize();
+        
+        _testEnv.loadResourceInWebRoot(ContentAssistTestsPlugin.getDefault().getBundle(),
+                                      "/testdata/faces-config_bug149743.xml.data", 
+                                      "/WEB-INF/faces-config.xml");
+        _testEnv.loadResourceInWebRoot(ContentAssistTestsPlugin.getDefault().getBundle(),
+                                      "/testdata/bug_149743.jsp.data",
+                                      "/bug_149743.jsp");
+        
+        final JDTTestEnvironment jdtTestEnv = new JDTTestEnvironment(_testEnv);
+        TestFileResource resource = new TestFileResource();
+        resource.load(ContentAssistTestsPlugin.getDefault().getBundle(), 
+                      "/testdata/MyBean.java.data");
+        jdtTestEnv.addSourceFile("src", "beans", "MyBean", resource.toString());
+    }
+
+    /**
+     * Sanity check
+     */
+    public void testSanity()
+    {
+        ContextWrapper wrapper = null;
+        
+        try
+        {
+            wrapper = getDocumentContext();
+            final IStructuredDocumentContext context = wrapper.getContext();
+            final IDOMContextResolver resolver =
+                IStructuredDocumentContextResolverFactory.INSTANCE.
+                    getDOMContextResolver(context);
+            Node node = resolver.getNode();
+            assertTrue(node instanceof Attr);
+            assertEquals("value", ((Attr)node).getNodeName());
+            assertEquals("#{myBean.property}", ((Attr)node).getNodeValue());
+        }
+        catch (Exception e)
+        {
+            e.printStackTrace();
+            fail(e.getLocalizedMessage());
+        }
+        finally
+        {
+            if (wrapper != null)
+            {
+                wrapper.dispose();
+            }
+        }
+    }
+    
+    /**
+     * Checks the scenario for Test_bug_149743
+     */
+    public void testCompletionProposalsForId()
+    {
+        ContextWrapper wrapper = null;
+        
+        try
+        {
+            wrapper = getDocumentContext();
+            ITextRegionContextResolver  resolver = 
+                IStructuredDocumentContextResolverFactory.INSTANCE.
+                    getTextRegionResolver(wrapper.getContext());
+    
+            final String elText = resolver.getRegionText().trim();
+            assertNotNull(elText);
+
+            final ContentAssistStrategy strategy = 
+                ContentAssistParser.getPrefix
+                    (wrapper.getContext().getDocumentPosition() 
+                            - resolver.getStartOffset() + 1, elText);
+
+            List proposals = strategy.getProposals(wrapper.getContext());
+            assertEquals(1, proposals.size());
+            final ICompletionProposal proposal = (ICompletionProposal) proposals.get(0);
+            assertEquals("property", proposal.getDisplayString());
+        }
+        catch(Exception e)
+        {
+            e.printStackTrace();
+        }
+        finally
+        {
+            if (wrapper != null)
+            {
+                wrapper.dispose();
+            }
+        }
+    }
+    
+    private ContextWrapper getDocumentContext() throws Exception
+    {
+        IProject project = _testEnv.getTestProject();
+        IFile jspFile = project.getFile(new Path("/WebContent/bug_149743.jsp"));
+        assertTrue(jspFile.exists());
+        
+        final IModelManager modelManager = 
+            StructuredModelManager.getModelManager();
+
+        IStructuredModel model = null;
+        
+        model = modelManager.getModelForRead(jspFile);
+        assertTrue(model instanceof DOMModelForJSP);
+        final IStructuredDocumentContext context = 
+            IStructuredDocumentContextFactory.INSTANCE.
+                getContext(model.getStructuredDocument(), 548);
+        return new ContextWrapper(context, model);
+    }
+
+    private static class ContextWrapper
+    {
+        private final IStructuredDocumentContext _context;
+        private final IStructuredModel  _model;
+        
+        ContextWrapper(final IStructuredDocumentContext context, final IStructuredModel model) {
+            super();
+            _context = context;
+            _model = model;
+        }
+        IStructuredDocumentContext getContext() {
+            return _context;
+        }
+        IStructuredModel getModel() {
+            return _model;
+        }
+        void dispose()
+        {
+            _model.releaseFromRead();
+        }
+    }
+}
diff --git a/jsf/tests/org.eclipse.jst.jsf.contentassist.tests/testdata/MyBean.java.data b/jsf/tests/org.eclipse.jst.jsf.contentassist.tests/testdata/MyBean.java.data
new file mode 100644
index 0000000..e683924
--- /dev/null
+++ b/jsf/tests/org.eclipse.jst.jsf.contentassist.tests/testdata/MyBean.java.data
@@ -0,0 +1,8 @@
+package beans;
+
+public class MyBean {
+	public String[] getProperty()
+	{
+		return new String[]{"blah"};
+	}
+}
\ No newline at end of file
diff --git a/jsf/tests/org.eclipse.jst.jsf.contentassist.tests/testdata/bug_149743.jsp.data b/jsf/tests/org.eclipse.jst.jsf.contentassist.tests/testdata/bug_149743.jsp.data
new file mode 100644
index 0000000..5a68a6c
--- /dev/null
+++ b/jsf/tests/org.eclipse.jst.jsf.contentassist.tests/testdata/bug_149743.jsp.data
@@ -0,0 +1,23 @@
+<%@page contentType="text/html"%>
+<%@page pageEncoding="UTF-8"%>
+ 
+<%@taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
+<%@taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
+
+
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
+   "http://www.w3.org/TR/html4/loose.dtd">
+
+<html>
+  <head>
+  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+        <title>JSP Page</title>
+    </head>
+    <body>
+    <f:view>
+    <h1>JSP Page</h1>
+    	<!--  no errors -->
+    	<f:selectItems value="#{myBean.property}"/>
+    </f:view>
+    </body>
+</html>
diff --git a/jsf/tests/org.eclipse.jst.jsf.contentassist.tests/testdata/faces-config_bug149743.xml.data b/jsf/tests/org.eclipse.jst.jsf.contentassist.tests/testdata/faces-config_bug149743.xml.data
new file mode 100644
index 0000000..5db9cf5
--- /dev/null
+++ b/jsf/tests/org.eclipse.jst.jsf.contentassist.tests/testdata/faces-config_bug149743.xml.data
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!DOCTYPE faces-config PUBLIC
+    "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN"
+    "http://java.sun.com/dtd/web-facesconfig_1_1.dtd">
+
+<faces-config>
+	<managed-bean>
+		<managed-bean-name>
+		myBean</managed-bean-name>
+		<managed-bean-class>
+		beans.MyBean</managed-bean-class>
+		<managed-bean-scope>
+		none</managed-bean-scope>
+	</managed-bean>
+
+</faces-config>
diff --git a/jsf/tests/org.eclipse.jst.jsf.test.util/src/org/eclipse/jst/jsf/test/util/WebProjectTestEnvironment.java b/jsf/tests/org.eclipse.jst.jsf.test.util/src/org/eclipse/jst/jsf/test/util/WebProjectTestEnvironment.java
index 8617671..fb6a0f4 100644
--- a/jsf/tests/org.eclipse.jst.jsf.test.util/src/org/eclipse/jst/jsf/test/util/WebProjectTestEnvironment.java
+++ b/jsf/tests/org.eclipse.jst.jsf.test.util/src/org/eclipse/jst/jsf/test/util/WebProjectTestEnvironment.java
@@ -99,6 +99,8 @@
     
        
     /**
+     * Creates or overwrites destFileName with the contents of srcFileName in bundle
+     * 
      * @param bundle
      * @param srcFileName
      * @param destDirName
@@ -113,7 +115,15 @@
         resource.load(bundle, srcFileName);
         
         IFile file = getWebRoot(true, true).getFile(new Path(destFileName)).getUnderlyingFile();
-        file.create(new ByteArrayInputStream(resource.toBytes()), true, null);
+        
+        if (!file.exists())
+        {            
+            file.create(new ByteArrayInputStream(resource.toBytes()), true, null);
+        }
+        else
+        {
+            file.setContents(new ByteArrayInputStream(resource.toBytes()), true, true, null);
+        }
         
         return file;
     }