Author: mareshkau
Date: 2010-09-21 11:17:10 -0400 (Tue, 21 Sep 2010)
New Revision: 25058
Modified:
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/CommonContentAssistantTestCase.java
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/ContentAssistantTestCase.java
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/Jbide1791Test.java
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/JstJspJbide1585Test.java
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/JstJspJbide1641Test.java
Log:
junit tests code has been adjuster, added copyright information, string has been
externalized, removed unused import's and variables
Modified:
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/CommonContentAssistantTestCase.java
===================================================================
---
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/CommonContentAssistantTestCase.java 2010-09-21
15:13:42 UTC (rev 25057)
+++
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/CommonContentAssistantTestCase.java 2010-09-21
15:17:10 UTC (rev 25058)
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007-2008 Red Hat, Inc.
+ * Copyright (c) 2007-2010 Red Hat, Inc.
* Distributed under license by Red Hat, Inc. All rights reserved.
* This program is made available under the terms of the
* Eclipse Public License v1.0 which accompanies this distribution,
@@ -33,7 +33,7 @@
@Override
public void setUp() throws Exception {
- provider = new TestProjectProvider("org.jboss.tools.seam.ui.test",
null, getSetUpProjectName(), makeCopy);
+ provider = new TestProjectProvider("org.jboss.tools.seam.ui.test",
null, getSetUpProjectName(), makeCopy); //$NON-NLS-1$
project = provider.getProject();
}
Modified:
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/ContentAssistantTestCase.java
===================================================================
---
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/ContentAssistantTestCase.java 2010-09-21
15:13:42 UTC (rev 25057)
+++
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/ContentAssistantTestCase.java 2010-09-21
15:17:10 UTC (rev 25058)
@@ -1,3 +1,14 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
package org.jboss.tools.jst.jsp.test.ca;
import java.util.List;
@@ -6,16 +17,13 @@
import org.eclipse.core.resources.IProject;
import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.contentassist.ContentAssistant;
import org.eclipse.jface.text.contentassist.ICompletionProposal;
-import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
import org.eclipse.jface.text.contentassist.IContentAssistant;
import org.eclipse.jface.text.source.SourceViewerConfiguration;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.PlatformUI;
import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument;
import org.eclipse.wst.sse.ui.internal.StructuredTextViewer;
-import org.eclipse.wst.sse.ui.internal.contentassist.StructuredContentAssistant;
import org.jboss.tools.common.text.ext.util.Utils;
import org.jboss.tools.jst.jsp.contentassist.AutoContentAssistantProposal;
import org.jboss.tools.jst.jsp.jspeditor.JSPMultiPageEditor;
@@ -32,7 +40,7 @@
protected IDocument document = null;
public void openEditor(String fileName) {
- IEditorPart editorPart = WorkbenchUtils.openEditor(project.getName()+"/"+
fileName);
+ IEditorPart editorPart = WorkbenchUtils.openEditor(project.getName()+"/"+
fileName); //$NON-NLS-1$
// System.out.println("openEditor: " + project.getName()+"/"+
fileName);
if (editorPart instanceof JSPMultiPageEditor)
jspEditor = (JSPMultiPageEditor) editorPart;
@@ -46,11 +54,11 @@
.getContentAssistant(viewer));
assertTrue(
- "Cannot get the Content Assistant instance for the editor for page
\""
- + fileName + "\"", (contentAssistant != null));
+ "Cannot get the Content Assistant instance for the editor for page \""
//$NON-NLS-1$
+ + fileName + "\"", (contentAssistant != null)); //$NON-NLS-1$
- assertTrue("The IDocument is not instance of IStructuredDocument for page
\""
- + fileName + "\"",
+ assertTrue("The IDocument is not instance of IStructuredDocument for page
\"" //$NON-NLS-1$
+ + fileName + "\"", //$NON-NLS-1$
(document instanceof IStructuredDocument));
}
@@ -76,7 +84,7 @@
List<ICompletionProposal> res = TestUtil.collectProposals(contentAssistant,
viewer, position+offset);
- assertTrue("Content Assistant returned no proposals", (res != null
&& res.size() > 0));
+ assertTrue("Content Assistant returned no proposals", (res != null
&& res.size() > 0)); //$NON-NLS-1$
// for (int i = 0; i < result.length; i++) {
// System.out.println("proposal - "+result[i].getDisplayString());
@@ -88,14 +96,14 @@
boolean found = compareProposal(proposals[i], result);
if (found)
foundCounter++;
- assertTrue("Proposal " + proposals[i] + " not found!",
found );
+ assertTrue("Proposal " + proposals[i] + " not found!",
found ); //$NON-NLS-1$ //$NON-NLS-2$
}
if (exactly) {
if (excludeELProposalsFromExactTest) {
- assertTrue("Some other proposals were found!", foundCounter ==
proposals.length);
+ assertTrue("Some other proposals were found!", foundCounter ==
proposals.length); //$NON-NLS-1$
} else {
- assertTrue("Some other proposals were found!", result.length ==
proposals.length);
+ assertTrue("Some other proposals were found!", result.length ==
proposals.length); //$NON-NLS-1$
}
}
@@ -111,20 +119,20 @@
if (replacementString.equalsIgnoreCase(proposalName)) return true;
// For a tag proposal there will be not only the the tag name but all others
characters like default attributes, tag ending characters and so on
- String[] replacementStringParts = replacementString.split(" ");
+ String[] replacementStringParts = replacementString.split(" ");
//$NON-NLS-1$
if (replacementStringParts != null && replacementStringParts.length > 0)
{
if (replacementStringParts[0].equalsIgnoreCase(proposalName)) return true;
}
// for an attribute proposal there will be a pare of attribute-value (i.e.
attrName="attrValue")
- replacementStringParts = replacementString.split("=");
+ replacementStringParts = replacementString.split("="); //$NON-NLS-1$
if (replacementStringParts != null && replacementStringParts.length > 0)
{
if (replacementStringParts[0].equalsIgnoreCase(proposalName)) return true;
}
// for an Unclosed EL the closing character is appended to the proposal string (i.e.
person} )
// perform case sensitive compare operation
- replacementStringParts = replacementString.split("}");
+ replacementStringParts = replacementString.split("}"); //$NON-NLS-1$
if (replacementStringParts != null && replacementStringParts.length > 0)
{
if (replacementStringParts[0].equals(proposalName)) return true;
}
Modified:
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/Jbide1791Test.java
===================================================================
---
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/Jbide1791Test.java 2010-09-21
15:13:42 UTC (rev 25057)
+++
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/Jbide1791Test.java 2010-09-21
15:17:10 UTC (rev 25058)
@@ -26,8 +26,8 @@
*
*/
public class Jbide1791Test extends ContentAssistantTestCase {
- private static final String PROJECT_NAME = "JsfJbide1791Test";
- private static final String PAGE_NAME =
"/WebContent/pages/jbide1791.xhtml";
+ private static final String PROJECT_NAME = "JsfJbide1791Test";
//$NON-NLS-1$
+ private static final String PAGE_NAME =
"/WebContent/pages/jbide1791.xhtml"; //$NON-NLS-1$
private TestProjectProvider provider = null;
public static Test suite() {
@@ -35,9 +35,8 @@
}
public void setUp() throws Exception {
- provider = new TestProjectProvider("org.jboss.tools.jst.jsp.test",
null, PROJECT_NAME,false);
+ provider = new TestProjectProvider("org.jboss.tools.jst.jsp.test",
null, PROJECT_NAME,false); //$NON-NLS-1$
project = provider.getProject();
- Throwable exception = null;
}
protected void tearDown() throws Exception {
@@ -48,18 +47,18 @@
public void testJbide1791(){
final String[] proposals = new String[]{
- "h1",
- "h2",
- "h3",
- "h4",
- "h5",
- "h6",
- "hr"
+ "h1", //$NON-NLS-1$
+ "h2", //$NON-NLS-1$
+ "h3", //$NON-NLS-1$
+ "h4", //$NON-NLS-1$
+ "h5", //$NON-NLS-1$
+ "h6", //$NON-NLS-1$
+ "hr" //$NON-NLS-1$
};
openEditor(PAGE_NAME);
IRegion reg=null;
try {
- reg = new FindReplaceDocumentAdapter(this.document).find(0,
"</style>", true, false, false, false);
+ reg = new FindReplaceDocumentAdapter(this.document).find(0,
"</style>", true, false, false, false); //$NON-NLS-1$
} catch (BadLocationException e) {
fail(e.getMessage());
}
@@ -74,7 +73,7 @@
*/
private void checkResult(ICompletionProposal[] rst, String[] proposals) {
for ( int i = 0 ; i < proposals.length ; i ++ ){
- assertTrue("Should be in proposals
list",isInResultList(rst,proposals[i]));
+ assertTrue("Should be in proposals
list",isInResultList(rst,proposals[i])); //$NON-NLS-1$
}
}
Modified:
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/JstJspJbide1585Test.java
===================================================================
---
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/JstJspJbide1585Test.java 2010-09-21
15:13:42 UTC (rev 25057)
+++
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/JstJspJbide1585Test.java 2010-09-21
15:17:10 UTC (rev 25058)
@@ -1,3 +1,14 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
package org.jboss.tools.jst.jsp.test.ca;
import java.util.List;
@@ -5,9 +16,7 @@
import junit.framework.Test;
import junit.framework.TestSuite;
-import org.eclipse.jface.text.contentassist.ContentAssistant;
import org.eclipse.jface.text.contentassist.ICompletionProposal;
-import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
import org.jboss.tools.jst.jsp.contentassist.AutoContentAssistantProposal;
import org.jboss.tools.jst.jsp.test.TestUtil;
import org.jboss.tools.test.util.TestProjectProvider;
@@ -15,10 +24,10 @@
public class JstJspJbide1585Test extends ContentAssistantTestCase {
TestProjectProvider provider = null;
boolean makeCopy = false;
- private static final String PROJECT_NAME = "JsfJbide1585Test";
- private static final String PAGE_NAME = "/WebContent/pages/inputname.xhtml";
- private static final String TAG_OPEN_STRING = "<";
- private static final String PREFIX_STRING = "ui:in";
+ private static final String PROJECT_NAME = "JsfJbide1585Test"; //$NON-NLS-1$
+ private static final String PAGE_NAME = "/WebContent/pages/inputname.xhtml";
//$NON-NLS-1$
+ private static final String TAG_OPEN_STRING = "<"; //$NON-NLS-1$
+ private static final String PREFIX_STRING = "ui:in"; //$NON-NLS-1$
private static final String INSERTION_STRING = TAG_OPEN_STRING + PREFIX_STRING;
public static Test suite() {
@@ -26,11 +35,11 @@
}
public void setUp() throws Exception {
- provider = new TestProjectProvider("org.jboss.tools.jst.jsp.test", null,
PROJECT_NAME, makeCopy);
+ provider = new TestProjectProvider("org.jboss.tools.jst.jsp.test", null,
PROJECT_NAME, makeCopy); //$NON-NLS-1$
project = provider.getProject();
Throwable exception = null;
- assertNull("An exception caught: " + (exception != null?
exception.getMessage() : ""), exception);
+ assertNull("An exception caught: " + (exception != null?
exception.getMessage() : ""), exception); //$NON-NLS-1$//$NON-NLS-2$
}
protected void tearDown() throws Exception {
@@ -44,10 +53,10 @@
// Find start of <ui:define> tag
String documentContent = document.get();
- int start = (documentContent == null ? -1 :
documentContent.indexOf("<ui:define"));
+ int start = (documentContent == null ? -1 :
documentContent.indexOf("<ui:define")); //$NON-NLS-1$
int offsetToTest = start + INSERTION_STRING.length();
- assertTrue("Cannot find the starting point in the test file \"" +
PAGE_NAME + "\"", (start != -1));
+ assertTrue("Cannot find the starting point in the test file \"" +
PAGE_NAME + "\"", (start != -1)); //$NON-NLS-1$ //$NON-NLS-2$
String documentContentModified = documentContent.substring(0, start) +
INSERTION_STRING + documentContent.substring(start);
@@ -57,19 +66,19 @@
try {
List<ICompletionProposal> res = TestUtil.collectProposals(contentAssistant,
viewer, offsetToTest);
- assertTrue("Content Assistant returned no proposals", (res != null
&& res.size() > 0));
+ assertTrue("Content Assistant returned no proposals", (res != null
&& res.size() > 0)); //$NON-NLS-1$
for (ICompletionProposal p : res) {
- assertTrue("Content Assistant returned proposals which type (" +
p.getClass().getName() + ") differs from AutoContentAssistantProposal", (p
instanceof AutoContentAssistantProposal));
+ assertTrue("Content Assistant returned proposals which type (" +
p.getClass().getName() + ") differs from AutoContentAssistantProposal", (p
instanceof AutoContentAssistantProposal)); //$NON-NLS-1$//$NON-NLS-2$
AutoContentAssistantProposal proposal = (AutoContentAssistantProposal)p;
String proposalString = proposal.getReplacementString();
int proposalReplacementOffset = proposal.getReplacementOffset();
int proposalReplacementLength = proposal.getReplacementLength();
- assertTrue("The proposal replacement Offset is not correct.",
proposalReplacementOffset == start + TAG_OPEN_STRING.length());
- assertTrue("The proposal replacement Length is not correct.",
proposalReplacementLength == PREFIX_STRING.length());
- assertTrue("The proposal isn\'t filtered properly in the Content
Assistant.", proposalString.startsWith(PREFIX_STRING));
+ assertTrue("The proposal replacement Offset is not correct.",
proposalReplacementOffset == start + TAG_OPEN_STRING.length()); //$NON-NLS-1$
+ assertTrue("The proposal replacement Length is not correct.",
proposalReplacementLength == PREFIX_STRING.length()); //$NON-NLS-1$
+ assertTrue("The proposal isn\'t filtered properly in the Content
Assistant.", proposalString.startsWith(PREFIX_STRING)); //$NON-NLS-1$
}
} finally {
closeEditor();
Modified:
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/JstJspJbide1641Test.java
===================================================================
---
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/JstJspJbide1641Test.java 2010-09-21
15:13:42 UTC (rev 25057)
+++
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/JstJspJbide1641Test.java 2010-09-21
15:17:10 UTC (rev 25058)
@@ -1,3 +1,14 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
package org.jboss.tools.jst.jsp.test.ca;
import java.util.List;