Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 92171 Details for
Bug 197666
[Cheatsheet][Simple][Tests][Conf] JUnit tests for XML model
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
org.eclipse.pde.ui.tests.patch
org.eclipse.pde.ui.tests.patch (text/plain), 8.11 KB, created by
Chris Aniszczyk
on 2008-03-11 10:55:50 EDT
(
hide
)
Description:
org.eclipse.pde.ui.tests.patch
Filename:
MIME Type:
Creator:
Chris Aniszczyk
Created:
2008-03-11 10:55:50 EDT
Size:
8.11 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.pde.ui.tests >Index: src/org/eclipse/pde/ui/tests/AllPDETests.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/AllPDETests.java,v >retrieving revision 1.23 >diff -u -r1.23 AllPDETests.java >--- src/org/eclipse/pde/ui/tests/AllPDETests.java 4 Jan 2008 20:05:37 -0000 1.23 >+++ src/org/eclipse/pde/ui/tests/AllPDETests.java 11 Mar 2008 14:54:57 -0000 >@@ -12,9 +12,9 @@ > > import junit.framework.Test; > import junit.framework.TestSuite; >- > import org.eclipse.pde.ui.tests.imports.AllImportTests; > import org.eclipse.pde.ui.tests.model.bundle.AllBundleModelTests; >+import org.eclipse.pde.ui.tests.model.cheatsheet.AllCheatSheetModelTests; > import org.eclipse.pde.ui.tests.model.xml.AllXMLModelTests; > import org.eclipse.pde.ui.tests.target.AllTargetTests; > import org.eclipse.pde.ui.tests.wizards.AllNewProjectTests; >@@ -28,6 +28,7 @@ > suite.addTest(AllImportTests.suite()); > suite.addTest(AllBundleModelTests.suite()); > suite.addTest(AllXMLModelTests.suite()); >+ suite.addTest(AllCheatSheetModelTests.suite()); > return suite; > } > >Index: src/org/eclipse/pde/ui/tests/model/cheatsheet/AllCheatSheetModelTests.java >=================================================================== >RCS file: src/org/eclipse/pde/ui/tests/model/cheatsheet/AllCheatSheetModelTests.java >diff -N src/org/eclipse/pde/ui/tests/model/cheatsheet/AllCheatSheetModelTests.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/pde/ui/tests/model/cheatsheet/AllCheatSheetModelTests.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,24 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are 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 >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.pde.ui.tests.model.cheatsheet; >+ >+import junit.framework.Test; >+import junit.framework.TestSuite; >+ >+public class AllCheatSheetModelTests { >+ >+ public static Test suite() { >+ TestSuite suite = new TestSuite("Test Suite for testing the cheatsheet model"); //$NON-NLS-1$ >+ suite.addTestSuite(SimpleCSIntroTestCase.class); >+ return suite; >+ } >+ >+} >Index: src/org/eclipse/pde/ui/tests/model/cheatsheet/SimpleCSIntroTestCase.java >=================================================================== >RCS file: src/org/eclipse/pde/ui/tests/model/cheatsheet/SimpleCSIntroTestCase.java >diff -N src/org/eclipse/pde/ui/tests/model/cheatsheet/SimpleCSIntroTestCase.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/pde/ui/tests/model/cheatsheet/SimpleCSIntroTestCase.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,46 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are 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 >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.pde.ui.tests.model.cheatsheet; >+ >+import org.eclipse.pde.internal.core.icheatsheet.simple.*; >+ >+public class SimpleCSIntroTestCase extends AbstractCheatSheetModelTestCase { >+ >+ protected static String INTRO_HREF = "/org.eclipse.platform.doc.user/reference/ref-cheatsheets.htm"; //$NON-NLS-1$ >+ protected static String DESCRIPTION = "some description"; //$NON-NLS-1$ >+ >+ public void testAddSimpleCSIntro() { >+ StringBuffer buffer = new StringBuffer(); >+ buffer.append("<intro href=\"").append(INTRO_HREF).append("\">"); >+ buffer.append(LF); >+ buffer.append("<description>"); >+ buffer.append(DESCRIPTION); >+ buffer.append("</description>"); >+ buffer.append(LF); >+ buffer.append("</intro>"); >+ setXMLContents(buffer, LF); >+ load(); >+ >+ ISimpleCS model = fModel.getSimpleCS(); >+ String title = model.getTitle(); >+ >+ // check intro >+ ISimpleCSIntro intro = model.getIntro(); >+ assertNotNull(intro); >+ assertEquals(intro.getHref(), INTRO_HREF); >+ >+ // check description >+ ISimpleCSDescription description = intro.getDescription(); >+ assertNotNull(description); >+ assertEquals(DESCRIPTION, description.getContent()); >+ } >+ >+} >Index: src/org/eclipse/pde/ui/tests/model/cheatsheet/AbstractCheatSheetModelTestCase.java >=================================================================== >RCS file: src/org/eclipse/pde/ui/tests/model/cheatsheet/AbstractCheatSheetModelTestCase.java >diff -N src/org/eclipse/pde/ui/tests/model/cheatsheet/AbstractCheatSheetModelTestCase.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/pde/ui/tests/model/cheatsheet/AbstractCheatSheetModelTestCase.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,87 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are 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 >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.pde.ui.tests.model.cheatsheet; >+ >+import junit.framework.TestCase; >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.jface.text.BadLocationException; >+import org.eclipse.jface.text.Document; >+import org.eclipse.pde.internal.core.text.IModelTextChangeListener; >+import org.eclipse.pde.internal.core.text.cheatsheet.simple.SimpleCSModel; >+import org.eclipse.pde.internal.core.text.plugin.XMLTextChangeListener; >+import org.eclipse.text.edits.*; >+ >+public abstract class AbstractCheatSheetModelTestCase extends TestCase { >+ >+ protected static final String LF = "\n"; //$NON-NLS-1$ >+ protected static final String CR = "\r"; //$NON-NLS-1$ >+ protected static final String CRLF = CR + LF; >+ >+ protected Document fDocument; >+ protected SimpleCSModel fModel; >+ protected IModelTextChangeListener fListener; >+ >+ public AbstractCheatSheetModelTestCase() { >+ } >+ >+ protected void setUp() throws Exception { >+ fDocument = new Document(); >+ } >+ >+ protected void load() { >+ load(false); >+ } >+ >+ protected void load(boolean addListener) { >+ try { >+ fModel = new SimpleCSModel(fDocument, false); >+ fModel.load(); >+ if (!fModel.isLoaded() || !fModel.isValid()) >+ fail("model cannot be loaded"); >+ if (addListener) { >+ fListener = new XMLTextChangeListener(fModel.getDocument()); >+ fModel.addModelChangedListener(fListener); >+ } >+ } catch (CoreException e) { >+ fail("model cannot be loaded"); >+ } >+ } >+ >+ protected void setXMLContents(StringBuffer body, String newline) { >+ StringBuffer sb = new StringBuffer(); >+ sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); >+ sb.append(newline); >+ sb.append("<cheatsheet title=\"sample cheatsheet\">"); >+ sb.append(newline); >+ if (body != null) >+ sb.append(body.toString()); >+ sb.append(newline); >+ sb.append("</cheatsheet>"); >+ sb.append(newline); >+ fDocument.set(sb.toString()); >+ } >+ >+ protected void reload() { >+ TextEdit[] ops = fListener.getTextOperations(); >+ if (ops.length == 0) >+ return; >+ MultiTextEdit multi = new MultiTextEdit(); >+ multi.addChildren(ops); >+ try { >+ multi.apply(fDocument); >+ } catch (MalformedTreeException e) { >+ fail(e.getMessage()); >+ } catch (BadLocationException e) { >+ fail(e.getMessage()); >+ } >+ load(); >+ } >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 197666
:
92171
|
92696
|
95802