diff options
author | Angel Avila | 2013-02-06 01:32:27 +0000 |
---|---|---|
committer | Gerrit Code Review @ Eclipse.org | 2013-02-06 20:07:34 +0000 |
commit | 8de7e64ca22b06d979984612ba54183144a97fc5 (patch) | |
tree | 8676c725c64f28d48d326f2c8fa29757a00a464a | |
parent | a5c3eb24e1d06175e24ba11a4fa9afcf4ac4a652 (diff) | |
download | org.eclipse.osee-8de7e64ca22b06d979984612ba54183144a97fc5.tar.gz org.eclipse.osee-8de7e64ca22b06d979984612ba54183144a97fc5.tar.xz org.eclipse.osee-8de7e64ca22b06d979984612ba54183144a97fc5.zip |
refinement[ats_PX4HJ]: Create Help System Unit Test
Change-Id: I04d175e4f5dad3b0e55dc8db481711523ad2e8de
69 files changed, 3338 insertions, 3 deletions
diff --git a/plugins/org.eclipse.osee.ats.help.ui.test/.classpath b/plugins/org.eclipse.osee.ats.help.ui.test/.classpath new file mode 100644 index 00000000000..ad32c83a788 --- /dev/null +++ b/plugins/org.eclipse.osee.ats.help.ui.test/.classpath @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?> +<classpath> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/> + <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> + <classpathentry kind="src" path="src"/> + <classpathentry kind="output" path="bin"/> +</classpath> diff --git a/plugins/org.eclipse.osee.ats.help.ui.test/.project b/plugins/org.eclipse.osee.ats.help.ui.test/.project new file mode 100644 index 00000000000..776b33f08d9 --- /dev/null +++ b/plugins/org.eclipse.osee.ats.help.ui.test/.project @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>org.eclipse.osee.ats.help.ui.test</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + <buildCommand> + <name>org.eclipse.jdt.core.javabuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.ManifestBuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.SchemaBuilder</name> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>org.eclipse.pde.PluginNature</nature> + <nature>org.eclipse.jdt.core.javanature</nature> + </natures> +</projectDescription> diff --git a/plugins/org.eclipse.osee.ats.help.ui.test/AtsHelpUi_TestSuite.launch b/plugins/org.eclipse.osee.ats.help.ui.test/AtsHelpUi_TestSuite.launch new file mode 100644 index 00000000000..7f3089d3190 --- /dev/null +++ b/plugins/org.eclipse.osee.ats.help.ui.test/AtsHelpUi_TestSuite.launch @@ -0,0 +1,56 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<launchConfiguration type="org.eclipse.pde.ui.JunitLaunchConfig"> +<setAttribute key="additional_plugins"> +<setEntry value="org.eclipse.osee.ats.help.ui:0.11.0.qualifier:default:true"/> +<setEntry value="org.eclipse.osee.framework.dev.help.ui:0.11.0.qualifier:default:false"/> +<setEntry value="org.eclipse.osee.framework.help.ui:0.11.0.qualifier:default:false"/> +</setAttribute> +<booleanAttribute key="append.args" value="true"/> +<stringAttribute key="application" value="org.eclipse.pde.junit.runtime.coretestapplication"/> +<booleanAttribute key="askclear" value="false"/> +<booleanAttribute key="automaticAdd" value="true"/> +<booleanAttribute key="automaticValidate" value="true"/> +<stringAttribute key="bootstrap" value=""/> +<stringAttribute key="checked" value="[NONE]"/> +<booleanAttribute key="clearConfig" value="true"/> +<booleanAttribute key="clearws" value="true"/> +<booleanAttribute key="clearwslog" value="false"/> +<stringAttribute key="configLocation" value="${workspace_loc}/.metadata/.plugins/org.eclipse.pde.core/pde-junit"/> +<booleanAttribute key="default" value="false"/> +<booleanAttribute key="default_auto_start" value="true"/> +<stringAttribute key="deselected_workspace_plugins" value="ah6.ats.config.common,ats.config.common,com.boeing.ote.cdb.diff,com.hazelcast,com.hazelcast.source,com.sun.jersey,com.sun.jersey.client.apache,com.sun.jersey.client.apache.source,com.sun.jersey.source,com.vaadin,javax.ws.rs,javax.ws.rs.source,jms.activemq.launch,jms.libraries,lba.ats.config.common,lba.ats.config.common.test,lba.ats.config.osee,lba.ats.config.osee.test,lba.ats.help.ui,lba.authentication.provider,lba.db.connection,lba.define,lba.define.help.ui,lba.define.test,lba.framework.help.ui,lba.framework.ui.skynet,lba.framework.ui.skynet.test,lba.help,lba.myII.tc,lba.osee.client.integration.tests,lba.osee.coverage,lba.osee.x.server.customizations,lba.ote.client,lba.ote.client.ui,lba.ote.cnf.dsl,lba.ote.cnf.dsl.ui,lba.ote.commands,lba.ote.help.ui,lba.ote.launchTest,lba.ote.message.support,lba.ote.outfile.conversion,lba.ote.outfile.conversion.app,lba.ote.outfile.conversion.test,lba.ote.projectsets.three.four,lba.ote.result.upload,lba.ote.test.manager,lba.ote.test.manager.ofp,lba.ote.ui.test.manager,lba.ote.workspace.ui,lba.rdt.core,lba.rdt.core.test,lba.rdt.service,lba.rdt.service.osee,lba.rdt.ui,lba.rdt.ui.test,lba.server.station.config,lba.server.station.config.test,lba.start,lba.tools.road.map,lba.tte,lba.tte.test,lba.utility.count,lba.utility.external.editor,lba.utility.ui.count,mysql.driver.ext,net.jini,net.sf.ehcache,net.sf.ehcache.source,oracle.driver,org.boeing.count,org.eclipse.osee.ats,org.eclipse.osee.ats.api,org.eclipse.osee.ats.client.demo,org.eclipse.osee.ats.client.integration.tests,org.eclipse.osee.ats.core,org.eclipse.osee.ats.core.client,org.eclipse.osee.ats.core.client.test,org.eclipse.osee.ats.core.test,org.eclipse.osee.ats.dsl,org.eclipse.osee.ats.dsl.ui,org.eclipse.osee.ats.help.ui,org.eclipse.osee.ats.impl,org.eclipse.osee.ats.impl.test,org.eclipse.osee.ats.mocks,org.eclipse.osee.ats.presenter,org.eclipse.osee.ats.presenter.mock,org.eclipse.osee.ats.presenter.test,org.eclipse.osee.ats.reports,org.eclipse.osee.ats.reports.burndown,org.eclipse.osee.ats.reports.efficiency,org.eclipse.osee.ats.reports.split,org.eclipse.osee.ats.ui.api,org.eclipse.osee.ats.view.web,org.eclipse.osee.ats.view.web.test,org.eclipse.osee.authentication,org.eclipse.osee.authorization,org.eclipse.osee.client.demo,org.eclipse.osee.client.integration.tests,org.eclipse.osee.client.test.framework,org.eclipse.osee.cluster,org.eclipse.osee.cluster.hazelcast,org.eclipse.osee.cluster.rest,org.eclipse.osee.console.admin,org.eclipse.osee.console.admin.test,org.eclipse.osee.coverage,org.eclipse.osee.coverage.demo,org.eclipse.osee.coverage.help.ui,org.eclipse.osee.coverage.integration.tests,org.eclipse.osee.coverage.test,org.eclipse.osee.database,org.eclipse.osee.database.schema,org.eclipse.osee.define,org.eclipse.osee.define.test,org.eclipse.osee.display.api,org.eclipse.osee.display.mvp,org.eclipse.osee.display.mvp.test,org.eclipse.osee.display.presenter,org.eclipse.osee.display.presenter.mocks,org.eclipse.osee.display.presenter.test,org.eclipse.osee.display.view.web,org.eclipse.osee.distributed,org.eclipse.osee.event,org.eclipse.osee.event.monitor,org.eclipse.osee.event.osgi,org.eclipse.osee.executor.admin,org.eclipse.osee.executor.admin.test,org.eclipse.osee.framework.access,org.eclipse.osee.framework.access.provider,org.eclipse.osee.framework.access.test,org.eclipse.osee.framework.authentication.ldap.core,org.eclipse.osee.framework.branch.gantt,org.eclipse.osee.framework.core,org.eclipse.osee.framework.core.client,org.eclipse.osee.framework.core.dsl,org.eclipse.osee.framework.core.dsl.edit,org.eclipse.osee.framework.core.dsl.integration,org.eclipse.osee.framework.core.dsl.integration.test,org.eclipse.osee.framework.core.dsl.ui,org.eclipse.osee.framework.core.dsl.ui.integration,org.eclipse.osee.framework.core.dsl.ui.integration.test,org.eclipse.osee.framework.core.message,org.eclipse.osee.framework.core.message.test,org.eclipse.osee.framework.core.model,org.eclipse.osee.framework.core.model.test,org.eclipse.osee.framework.core.server,org.eclipse.osee.framework.core.server.test,org.eclipse.osee.framework.core.test,org.eclipse.osee.framework.database,org.eclipse.osee.framework.database.init,org.eclipse.osee.framework.database.test,org.eclipse.osee.framework.dev.help.ui,org.eclipse.osee.framework.h2,org.eclipse.osee.framework.help.ui,org.eclipse.osee.framework.help.ui.test,org.eclipse.osee.framework.jdk.core,org.eclipse.osee.framework.jdk.core.test,org.eclipse.osee.framework.jini,org.eclipse.osee.framework.lifecycle,org.eclipse.osee.framework.lifecycle.test,org.eclipse.osee.framework.logging,org.eclipse.osee.framework.logging.test,org.eclipse.osee.framework.manager.servlet,org.eclipse.osee.framework.messaging,org.eclipse.osee.framework.messaging.event.res,org.eclipse.osee.framework.messaging.event.res.test,org.eclipse.osee.framework.messaging.test,org.eclipse.osee.framework.plugin.core,org.eclipse.osee.framework.resource.management,org.eclipse.osee.framework.resource.management.test,org.eclipse.osee.framework.skynet.core,org.eclipse.osee.framework.skynet.core.test,org.eclipse.osee.framework.templates,org.eclipse.osee.framework.ui.admin,org.eclipse.osee.framework.ui.branch.graph,org.eclipse.osee.framework.ui.data.model.editor,org.eclipse.osee.framework.ui.plugin,org.eclipse.osee.framework.ui.product,org.eclipse.osee.framework.ui.skynet,org.eclipse.osee.framework.ui.skynet.test,org.eclipse.osee.framework.ui.swt,org.eclipse.osee.framework.ui.workspacebundleloader,org.eclipse.osee.framework.ui.ws,org.eclipse.osee.logback.config,org.eclipse.osee.logger,org.eclipse.osee.logger.slf4j,org.eclipse.osee.mail,org.eclipse.osee.mail.rest,org.eclipse.osee.mail.test,org.eclipse.osee.mvp.example,org.eclipse.osee.mvp.example.api,org.eclipse.osee.mvp.example.presenter,org.eclipse.osee.mvp.example.view,org.eclipse.osee.orcs,org.eclipse.osee.orcs.core,org.eclipse.osee.orcs.core.test,org.eclipse.osee.orcs.db,org.eclipse.osee.orcs.db.mock,org.eclipse.osee.orcs.db.test,org.eclipse.osee.orcs.rest,org.eclipse.osee.orcs.rest.client,org.eclipse.osee.orcs.rest.model,org.eclipse.osee.orcs.rest.test,org.eclipse.osee.orcs.test,org.eclipse.osee.ote.client,org.eclipse.osee.ote.client.msg,org.eclipse.osee.ote.connection.jini,org.eclipse.osee.ote.connection.service,org.eclipse.osee.ote.connection.service.test,org.eclipse.osee.ote.container,org.eclipse.osee.ote.core,org.eclipse.osee.ote.core.test,org.eclipse.osee.ote.define,org.eclipse.osee.ote.help.ui,org.eclipse.osee.ote.jms,org.eclipse.osee.ote.message,org.eclipse.osee.ote.message.test,org.eclipse.osee.ote.messaging.dds,org.eclipse.osee.ote.model.manager,org.eclipse.osee.ote.runtimeManager,org.eclipse.osee.ote.server,org.eclipse.osee.ote.ui,org.eclipse.osee.ote.ui.define,org.eclipse.osee.ote.ui.markers,org.eclipse.osee.ote.ui.output,org.eclipse.osee.ote.ui.test.manager,org.eclipse.osee.ote.ui.test.output,org.eclipse.osee.ote.version,org.eclipse.osee.ote.version.git,org.eclipse.osee.ote.version.git.test,org.eclipse.osee.ote.version.svn,org.eclipse.osee.rest.admin,org.eclipse.osee.rest.test.client,org.eclipse.osee.rest.test.model,org.eclipse.osee.rest.test.server,org.eclipse.osee.sos,org.eclipse.osee.support.dev.java,org.eclipse.osee.support.test.util,org.eclipse.osee.user.admin,org.eclipse.osee.vaadin,org.eclipse.osee.vaadin.example.ui,org.eclipse.osee.vaadin.themes,org.eclipse.osee.vaadin.widgets,org.eclipse.osee.x.server.application,org.json,org.jvnet.mimepull,org.jvnet.mimepull.source,org.mockito,org.mockito.source,org.mockito.test.example,org.objenesis,org.objenesis.source,org.postgresql.driver,org.xerial.sqlite,org.xerial.sqlite.source"/> +<stringAttribute key="featureDefaultLocation" value="workspace"/> +<stringAttribute key="featurePluginResolution" value="workspace"/> +<booleanAttribute key="includeOptional" value="true"/> +<stringAttribute key="location" value="${workspace_loc}/../junit-workspace"/> +<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS"> +<listEntry value="/org.eclipse.osee.ats.help.ui.test/src/org/eclipse/osee/ats/help/ui/AtsHelpUiTestSuite.java"/> +</listAttribute> +<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES"> +<listEntry value="1"/> +</listAttribute> +<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value=""/> +<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/> +<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/> +<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit4"/> +<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.eclipse.osee.ats.help.ui.AtsHelpUiTestSuite"/> +<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-os ${target.os} -ws ${target.ws} -arch ${target.arch} -nl ${target.nl} -consoleLog"/> +<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="org.eclipse.osee.ats.help.ui.test"/> +<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.pde.ui.workbenchClasspathProvider"/> +<stringAttribute key="pde.version" value="3.3"/> +<stringAttribute key="product" value="org.eclipse.osee.framework.ui.product.osee"/> +<booleanAttribute key="run_in_ui_thread" value="false"/> +<setAttribute key="selected_features"> +<setEntry value="org.eclipse.osee.core.feature:default"/> +<setEntry value="org.eclipse.osee.core.plugin.feature:default"/> +<setEntry value="org.eclipse.osee.core.runtime.feature:default"/> +<setEntry value="org.eclipse.osee.core.ui.feature:default"/> +</setAttribute> +<booleanAttribute key="show_selected_only" value="false"/> +<stringAttribute key="templateConfig" value="${target_home}\configuration\config.ini"/> +<booleanAttribute key="tracing" value="false"/> +<booleanAttribute key="useCustomFeatures" value="true"/> +<booleanAttribute key="useDefaultConfig" value="true"/> +<booleanAttribute key="useDefaultConfigArea" value="false"/> +<booleanAttribute key="useProduct" value="false"/> +</launchConfiguration> diff --git a/plugins/org.eclipse.osee.ats.help.ui.test/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.ats.help.ui.test/META-INF/MANIFEST.MF new file mode 100644 index 00000000000..fb54ad98879 --- /dev/null +++ b/plugins/org.eclipse.osee.ats.help.ui.test/META-INF/MANIFEST.MF @@ -0,0 +1,12 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: OSEE ATS Help UI Test (Incubation) +Bundle-SymbolicName: org.eclipse.osee.ats.help.ui.test +Bundle-Version: 0.11.0.qualifier +Bundle-Vendor: Eclipse Open System Engineering Environment +Fragment-Host: org.eclipse.osee.ats.help.ui +Bundle-RequiredExecutionEnvironment: JavaSE-1.6 +Require-Bundle: org.junit +Import-Package: org.eclipse.core.runtime;version="3.4.0", + org.eclipse.osee.framework.jdk.core.util, + org.osgi.framework diff --git a/plugins/org.eclipse.osee.ats.help.ui.test/build.properties b/plugins/org.eclipse.osee.ats.help.ui.test/build.properties new file mode 100644 index 00000000000..1b243b1a937 --- /dev/null +++ b/plugins/org.eclipse.osee.ats.help.ui.test/build.properties @@ -0,0 +1,5 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + . +additional.bundles = org.eclipse.osee.framework.jdk.core diff --git a/plugins/org.eclipse.osee.ats.help.ui.test/pom.xml b/plugins/org.eclipse.osee.ats.help.ui.test/pom.xml new file mode 100644 index 00000000000..5315b75cc1b --- /dev/null +++ b/plugins/org.eclipse.osee.ats.help.ui.test/pom.xml @@ -0,0 +1,30 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>org.eclipse.osee</groupId> + <artifactId>org.eclipse.osee.ats.parent</artifactId> + <version>0.11.0-SNAPSHOT</version> + <relativePath>../../plugins/org.eclipse.osee.ats.parent</relativePath> + </parent> + + <artifactId>org.eclipse.osee.ats.help.ui.test</artifactId> + <packaging>eclipse-test-plugin</packaging> + <name>OSEE ATS Help Test - (Incubation)</name> + + <build> + <plugins> + <plugin> + <groupId>org.eclipse.tycho</groupId> + <artifactId>tycho-surefire-plugin</artifactId> + <version>${tycho-version}</version> + <configuration> + <testSuite>org.eclipse.osee.ats.help.ui.test</testSuite> + <testClass>org.eclipse.osee.ats.help.ui.AtsHelpUiTestSuite</testClass> + </configuration> + </plugin> + </plugins> + </build> +</project>
\ No newline at end of file diff --git a/plugins/org.eclipse.osee.ats.help.ui.test/src/org/eclipse/osee/ats/help/ui/AtsHelpUiTestSuite.java b/plugins/org.eclipse.osee.ats.help.ui.test/src/org/eclipse/osee/ats/help/ui/AtsHelpUiTestSuite.java new file mode 100644 index 00000000000..4b1d0ce25e9 --- /dev/null +++ b/plugins/org.eclipse.osee.ats.help.ui.test/src/org/eclipse/osee/ats/help/ui/AtsHelpUiTestSuite.java @@ -0,0 +1,23 @@ +/******************************************************************************* + * Copyright (c) 2013 Boeing. + * 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: + * Boeing - initial API and implementation + *******************************************************************************/ +package org.eclipse.osee.ats.help.ui; + +import org.junit.runner.RunWith; +import org.junit.runners.Suite; + +/** + * @author Angel Avila + */ +@RunWith(Suite.class) +@Suite.SuiteClasses({HelpContextTest.class, HelpTableOfContentTest.class}) +public class AtsHelpUiTestSuite { + // Test Suite +} diff --git a/plugins/org.eclipse.osee.ats.help.ui.test/src/org/eclipse/osee/ats/help/ui/HelpContextTest.java b/plugins/org.eclipse.osee.ats.help.ui.test/src/org/eclipse/osee/ats/help/ui/HelpContextTest.java new file mode 100644 index 00000000000..3dee640931b --- /dev/null +++ b/plugins/org.eclipse.osee.ats.help.ui.test/src/org/eclipse/osee/ats/help/ui/HelpContextTest.java @@ -0,0 +1,85 @@ +/******************************************************************************* + * Copyright (c) 2013 Boeing. + * 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: + * Boeing - initial API and implementation + *******************************************************************************/ +package org.eclipse.osee.ats.help.ui; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import java.lang.reflect.Field; +import java.net.URL; +import java.util.HashMap; +import java.util.Map; +import org.eclipse.osee.ats.help.ui.util.ContextParser; +import org.eclipse.osee.ats.help.ui.util.ContextParser.ContextEntry; +import org.eclipse.osee.ats.help.ui.util.HelpTestUtil; +import org.eclipse.osee.framework.jdk.core.util.Compare; +import org.eclipse.osee.framework.ui.plugin.util.HelpContext; +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.Test; + +/** + * @author Angel Avila + */ +public class HelpContextTest { + + private static final String PLUGIN_ID = "org.eclipse.osee.ats.help.ui"; + + private static Map<String, HelpContext> contexts; + private static ContextParser parser; + + @BeforeClass + public static void setUp() throws Exception { + contexts = getContexts(AtsHelpContext.class); + parser = new ContextParser("contexts/contexts.xml"); + parser.parse(); + } + + @Test + public void testAdd() throws Exception { + assertEquals(12, contexts.size()); + } + + @Test + public void testContextsXml() throws Exception { + assertEquals(contexts.size(), parser.getEntries().size()); + + Assert.assertFalse(Compare.isDifferent(contexts.keySet(), parser.getIds())); + for (HelpContext context : contexts.values()) { + assertEquals(PLUGIN_ID, context.getPluginId()); + + String id = context.getName(); + ContextEntry entry = parser.getEntry(id); + assertNotNull(entry); + } + } + + @Test + public void testHrefFiles() throws Exception { + for (ContextEntry entry : parser.getEntries()) { + for (String reference : entry.getReferences()) { + URL url = HelpTestUtil.getResource(reference); + assertNotNull(String.format("[%s] was not valid", reference), url); + } + } + } + + private static Map<String, HelpContext> getContexts(Class<?> clazz) throws IllegalArgumentException, IllegalAccessException { + Map<String, HelpContext> contexts = new HashMap<String, HelpContext>(); + for (Field field : clazz.getFields()) { + Object object = field.get(null); + if (object instanceof HelpContext) { + HelpContext context = (HelpContext) object; + contexts.put(context.getName(), context); + } + } + return contexts; + } +} diff --git a/plugins/org.eclipse.osee.ats.help.ui.test/src/org/eclipse/osee/ats/help/ui/HelpTableOfContentTest.java b/plugins/org.eclipse.osee.ats.help.ui.test/src/org/eclipse/osee/ats/help/ui/HelpTableOfContentTest.java new file mode 100644 index 00000000000..b7e9145a77a --- /dev/null +++ b/plugins/org.eclipse.osee.ats.help.ui.test/src/org/eclipse/osee/ats/help/ui/HelpTableOfContentTest.java @@ -0,0 +1,60 @@ +/******************************************************************************* + * Copyright (c) 2013 Boeing. + * 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: + * Boeing - initial API and implementation + *******************************************************************************/ +package org.eclipse.osee.ats.help.ui; + +import static org.junit.Assert.assertNotNull; +import java.net.URL; +import java.util.Set; +import org.eclipse.osee.ats.help.ui.util.HelpTestUtil; +import org.eclipse.osee.ats.help.ui.util.HtmlParser; +import org.eclipse.osee.ats.help.ui.util.TocParser; +import org.junit.BeforeClass; +import org.junit.Test; + +/** + * @author Angel Avila + */ +public class HelpTableOfContentTest { + + private static final String PLUGIN_ID = "org.eclipse.osee.ats.help.ui"; + + private static TocParser parser; + + @BeforeClass + public static void setUp() throws Exception { + parser = new TocParser("toc.xml"); + parser.parse(); + } + + @Test + public void testAllTocReferencesExist() throws Exception { + for (String reference : parser.getEntries()) { + URL url = HelpTestUtil.getResource(reference); + assertNotNull(String.format("[%s] was not valid", reference), url); + } + } + + @Test + public void testTocReferencesValid() throws Exception { + HtmlParser htmlParser = new HtmlParser(PLUGIN_ID); + + for (String reference : parser.getEntries()) { + URL url = HelpTestUtil.getResource(reference); + + Set<String> entries = htmlParser.parse(url); + for (String resource : entries) { + URL referencedUrl = HelpTestUtil.getResource(reference); + assertNotNull(String.format("[%s] was not valid", resource), referencedUrl); + } + + } + } +} diff --git a/plugins/org.eclipse.osee.ats.help.ui.test/src/org/eclipse/osee/ats/help/ui/util/ContextParser.java b/plugins/org.eclipse.osee.ats.help.ui.test/src/org/eclipse/osee/ats/help/ui/util/ContextParser.java new file mode 100644 index 00000000000..045e8aef058 --- /dev/null +++ b/plugins/org.eclipse.osee.ats.help.ui.test/src/org/eclipse/osee/ats/help/ui/util/ContextParser.java @@ -0,0 +1,141 @@ +/******************************************************************************* + * Copyright (c) 2013 Boeing. + * 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: + * Boeing - initial API and implementation + *******************************************************************************/ +package org.eclipse.osee.ats.help.ui.util; + +import java.io.BufferedInputStream; +import java.io.InputStream; +import java.net.URL; +import java.util.Collection; +import java.util.HashMap; +import java.util.LinkedHashSet; +import java.util.Map; +import java.util.Set; +import javax.xml.stream.XMLInputFactory; +import javax.xml.stream.XMLStreamConstants; +import javax.xml.stream.XMLStreamReader; +import org.eclipse.osee.framework.jdk.core.util.Lib; +import org.eclipse.osee.framework.jdk.core.util.Strings; + +/** + * @author Angel Avila + */ +public class ContextParser { + + private static final XMLInputFactory xmlInputFactory = XMLInputFactory.newFactory(); + + private static final String CONTEXT = "context"; + private static final String TOPIC = "topic"; + private static final String HREF = "href"; + private static final String ID_TAG = "id"; + + public Map<String, ContextEntry> entries = new HashMap<String, ContextEntry>(); + public String path; + + private String localName; + private String uri; + private ContextEntry currentEntry; + + public ContextParser(String path) { + this.path = path; + } + + public void parse() throws Exception { + entries.clear(); + URL url = HelpTestUtil.getResource(path); + + InputStream inputStream = null; + try { + inputStream = new BufferedInputStream(url.openStream()); + XMLStreamReader streamReader = xmlInputFactory.createXMLStreamReader(inputStream); + while (streamReader.hasNext()) { + process(streamReader); + streamReader.next(); + } + + } finally { + Lib.close(inputStream); + } + } + + private void process(XMLStreamReader reader) { + int eventType = reader.getEventType(); + switch (eventType) { + case XMLStreamConstants.START_ELEMENT: + localName = reader.getLocalName(); + uri = reader.getNamespaceURI(); + if (CONTEXT.equals(localName)) { + + String id = reader.getAttributeValue(uri, ID_TAG); + if (Strings.isValid(id)) { + currentEntry = new ContextEntry(id); + } + + } else if (TOPIC.equals(localName) && currentEntry != null) { + String reference = reader.getAttributeValue(uri, HREF); + if (Strings.isValid(reference)) { + String path = normalizePath(reference); + currentEntry.getReferences().add(path); + } + } + break; + case XMLStreamConstants.END_ELEMENT: + localName = reader.getLocalName(); + uri = reader.getNamespaceURI(); + if (CONTEXT.equals(localName) && currentEntry != null) { + entries.put(currentEntry.getId(), currentEntry); + reset(); + } + break; + } + } + + private String normalizePath(String reference) { + return reference.replaceAll("\\.html#.*", ".html"); + } + + private void reset() { + localName = null; + uri = null; + currentEntry = null; + } + + public Collection<ContextEntry> getEntries() { + return entries.values(); + } + + public ContextEntry getEntry(String id) { + return entries.get(id); + } + + public Set<String> getIds() { + return entries.keySet(); + } + + public final class ContextEntry { + private final String id; + private final Set<String> references = new LinkedHashSet<String>(); + + public ContextEntry(String id) { + super(); + this.id = id; + } + + public String getId() { + return id; + } + + public Set<String> getReferences() { + return references; + } + + } + +} diff --git a/plugins/org.eclipse.osee.ats.help.ui.test/src/org/eclipse/osee/ats/help/ui/util/HelpTestUtil.java b/plugins/org.eclipse.osee.ats.help.ui.test/src/org/eclipse/osee/ats/help/ui/util/HelpTestUtil.java new file mode 100644 index 00000000000..0c32ce8f378 --- /dev/null +++ b/plugins/org.eclipse.osee.ats.help.ui.test/src/org/eclipse/osee/ats/help/ui/util/HelpTestUtil.java @@ -0,0 +1,44 @@ +/******************************************************************************* + * Copyright (c) 2013 Boeing. + * 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: + * Boeing - initial API and implementation + *******************************************************************************/ +package org.eclipse.osee.ats.help.ui.util; + +import static junit.framework.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import java.io.File; +import java.net.URL; +import org.eclipse.core.runtime.FileLocator; +import org.osgi.framework.Bundle; +import org.osgi.framework.FrameworkUtil; + +/** + * @author Angel Avila + */ +public final class HelpTestUtil { + + private HelpTestUtil() { + // Utility Class + } + + public static URL getResource(String resource) throws Exception { + Bundle bundle = FrameworkUtil.getBundle(HelpTestUtil.class); + URL url = bundle.getResource(resource); + + assertNotNull(String.format("Resource not found: [%s]", resource), url); + + url = FileLocator.toFileURL(url); + + File file = new File(url.toURI()); + assertEquals(String.format("[%s] does not exist", resource), true, file.exists()); + assertEquals(String.format("[%s] unreadable", resource), true, file.canRead()); + + return url; + } +} diff --git a/plugins/org.eclipse.osee.ats.help.ui.test/src/org/eclipse/osee/ats/help/ui/util/HtmlParser.java b/plugins/org.eclipse.osee.ats.help.ui.test/src/org/eclipse/osee/ats/help/ui/util/HtmlParser.java new file mode 100644 index 00000000000..c3a57acd34e --- /dev/null +++ b/plugins/org.eclipse.osee.ats.help.ui.test/src/org/eclipse/osee/ats/help/ui/util/HtmlParser.java @@ -0,0 +1,117 @@ +/******************************************************************************* + * Copyright (c) 2013 Boeing. + * 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: + * Boeing - initial API and implementation + *******************************************************************************/ +package org.eclipse.osee.ats.help.ui.util; + +import java.io.BufferedInputStream; +import java.io.InputStream; +import java.net.URL; +import java.util.HashSet; +import java.util.Set; +import javax.xml.stream.XMLInputFactory; +import javax.xml.stream.XMLStreamConstants; +import javax.xml.stream.XMLStreamReader; +import org.eclipse.osee.framework.jdk.core.util.Lib; +import org.eclipse.osee.framework.jdk.core.util.Strings; + +/** + * @author Angel Avila + */ +public class HtmlParser { + + private static final XMLInputFactory xmlInputFactory = XMLInputFactory.newFactory(); + + private static final String LINK_NODE = "link"; + private static final String HREF_TAG = "href"; + private static final String SRC_TAG = "src"; + + private final String pathHint; + + public HtmlParser(String pathHint) { + this.pathHint = pathHint; + } + + private String getPath(String fullPath) { + StringBuilder builder = new StringBuilder(); + + String[] parts = fullPath.split("/"); + boolean found = false; + for (String part : parts) { + if (found && !part.endsWith(".html")) { + builder.append(part); + builder.append("/"); + } + if (pathHint.equals(part)) { + found = true; + } + } + return builder.toString(); + } + + public Set<String> parse(URL url) throws Exception { + Set<String> entries = new HashSet<String>(); + entries.clear(); + + String pathPrefix = getPath(url.toString()); + + InputStream inputStream = null; + try { + inputStream = new BufferedInputStream(url.openStream()); + XMLStreamReader streamReader = xmlInputFactory.createXMLStreamReader(inputStream); + while (streamReader.hasNext()) { + process(streamReader, pathPrefix, entries); + streamReader.next(); + } + + } finally { + Lib.close(inputStream); + } + + return entries; + } + + private void process(XMLStreamReader reader, String pathPrefix, Set<String> entries) { + int eventType = reader.getEventType(); + switch (eventType) { + case XMLStreamConstants.START_ELEMENT: + String localName = reader.getLocalName(); + for (int index = 0; index < reader.getAttributeCount(); index++) { + + String attributeName = reader.getAttributeLocalName(index); + String value = reader.getAttributeValue(index); + + if (Strings.isValid(value)) { + if (!LINK_NODE.equals(localName)) { + if (HREF_TAG.equals(attributeName) || SRC_TAG.equals(attributeName)) { + processResource(pathPrefix, entries, value); + } + } + } + } + break; + } + } + + private void processResource(String pathPrefix, Set<String> references, String value) { + if (!isExternalLink(value)) { + String reference = normalizePath(pathPrefix, value); + references.add(reference); + } + } + + private String normalizePath(String pathPrefix, String reference) { + String path = reference.replaceAll("\\.html#.*", ".html"); + return String.format("%s%s", pathPrefix, path); + } + + private boolean isExternalLink(String resource) { + return resource.contains("://"); + } +} diff --git a/plugins/org.eclipse.osee.ats.help.ui.test/src/org/eclipse/osee/ats/help/ui/util/TocParser.java b/plugins/org.eclipse.osee.ats.help.ui.test/src/org/eclipse/osee/ats/help/ui/util/TocParser.java new file mode 100644 index 00000000000..4d671eb370a --- /dev/null +++ b/plugins/org.eclipse.osee.ats.help.ui.test/src/org/eclipse/osee/ats/help/ui/util/TocParser.java @@ -0,0 +1,103 @@ +/******************************************************************************* + * Copyright (c) 2013 Boeing. + * 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: + * Boeing - initial API and implementation + *******************************************************************************/ +package org.eclipse.osee.ats.help.ui.util; + +import java.io.BufferedInputStream; +import java.io.InputStream; +import java.net.URL; +import java.util.HashSet; +import java.util.Set; +import javax.xml.stream.XMLInputFactory; +import javax.xml.stream.XMLStreamConstants; +import javax.xml.stream.XMLStreamReader; +import org.eclipse.osee.framework.jdk.core.util.Lib; +import org.eclipse.osee.framework.jdk.core.util.Strings; + +/** + * @author Angel Avila + */ +public class TocParser { + + private static final XMLInputFactory xmlInputFactory = XMLInputFactory.newFactory(); + + private static final String TOC = "toc"; + private static final String TOPIC = "topic"; + private static final String HREF = "href"; + + public Set<String> entries = new HashSet<String>(); + public String path; + + private String localName; + private String uri; + + public TocParser(String path) { + this.path = path; + } + + public void parse() throws Exception { + entries.clear(); + URL url = HelpTestUtil.getResource(path); + + InputStream inputStream = null; + try { + inputStream = new BufferedInputStream(url.openStream()); + XMLStreamReader streamReader = xmlInputFactory.createXMLStreamReader(inputStream); + while (streamReader.hasNext()) { + process(streamReader); + streamReader.next(); + } + + } finally { + Lib.close(inputStream); + } + } + + private void process(XMLStreamReader reader) { + int eventType = reader.getEventType(); + switch (eventType) { + case XMLStreamConstants.START_ELEMENT: + localName = reader.getLocalName(); + uri = reader.getNamespaceURI(); + if (TOC.equals(localName)) { + processReference(reader, TOPIC); + } else if (TOPIC.equals(localName)) { + processReference(reader, HREF); + } + break; + case XMLStreamConstants.END_ELEMENT: + localName = reader.getLocalName(); + uri = reader.getNamespaceURI(); + reset(); + break; + } + } + + private void processReference(XMLStreamReader reader, String tag) { + String reference = reader.getAttributeValue(uri, tag); + if (Strings.isValid(reference)) { + String path = normalizePath(reference); + entries.add(path); + } + } + + private String normalizePath(String reference) { + return reference.replaceAll("\\.html#.*", ".html"); + } + + private void reset() { + localName = null; + uri = null; + } + + public Set<String> getEntries() { + return entries; + } +} diff --git a/plugins/org.eclipse.osee.ats.help.ui/contexts/contexts.xml b/plugins/org.eclipse.osee.ats.help.ui/contexts/contexts.xml index aad8d3cd412..5a52e08cc6a 100644 --- a/plugins/org.eclipse.osee.ats.help.ui/contexts/contexts.xml +++ b/plugins/org.eclipse.osee.ats.help.ui/contexts/contexts.xml @@ -16,7 +16,6 @@ <context id="atsConfigureWorkflow"> <description>Configure Workflow for use by Team Definition.</description> <topic href="OSEE/ATS/Users_Guide/Views/ATS-Workflow-Configuration-Editor.html" label="Workflow Configuration Editor"/> - <topic href="OSEE/ATS/Users_Guide/Workflow-Configuration.html" label="Workflow Configuration"/> <topic href="OSEE/ATS/Users_Guide/Views/Work-Page-Definition-Artifact.html" label="Work Page Definition"/> <topic href="OSEE/ATS/Users_Guide/Views/Work-Rule-Definition-Artifact.html" label="Work Rule Definition"/> <topic href="OSEE/ATS/Users_Guide/Views/Work-Rule-Widget-Artifact.html" label="Work Widget Definition"/> @@ -39,7 +38,6 @@ <description>Show loaded Action, Team Workflows, Tasks and Reviews.</description> <topic href="OSEE/ATS/Users_Guide/Views/ATS-World-View.html" label="ATS World View"/> <topic href="OSEE/ATS/Users_Guide/Views/Table-Customization.html" label="Table Customization"/> - <topic href="OSEE/ATS/Users_Guide/Views.html" label="ATS Icons"/> <topic href="OSEE/ATS/Users_Guide/Intro/Intro.html" label="ATS Overview"/> <topic href="OSEE/ATS/Users_Guide/Tips/Tips.html" label="ATS Tips"/> </context> diff --git a/plugins/org.eclipse.osee.ats.parent/pom.xml b/plugins/org.eclipse.osee.ats.parent/pom.xml index f6a24464838..52b5d9bc044 100644 --- a/plugins/org.eclipse.osee.ats.parent/pom.xml +++ b/plugins/org.eclipse.osee.ats.parent/pom.xml @@ -21,6 +21,7 @@ <module>../../plugins/org.eclipse.osee.ats.mocks</module> <module>../../plugins/org.eclipse.osee.ats.help.ui</module> + <module>../../plugins/org.eclipse.osee.ats.help.ui.test</module> <module>../../plugins/org.eclipse.osee.ats</module> <module>../../plugins/org.eclipse.osee.ats.core</module> <module>../../plugins/org.eclipse.osee.ats.core.test</module> diff --git a/plugins/org.eclipse.osee.client.parent/pom.xml b/plugins/org.eclipse.osee.client.parent/pom.xml index 27bc6e0852f..a7023a09d22 100644 --- a/plugins/org.eclipse.osee.client.parent/pom.xml +++ b/plugins/org.eclipse.osee.client.parent/pom.xml @@ -37,7 +37,10 @@ <module>../../plugins/org.eclipse.osee.framework.messaging.event.res.test</module> <module>../../plugins/org.eclipse.osee.framework.dev.help.ui</module> + <module>../../plugins/org.eclipse.osee.framework.dev.help.ui.test</module> + <module>../../plugins/org.eclipse.osee.framework.help.ui</module> + <module>../../plugins/org.eclipse.osee.framework.help.ui.test</module> <module>../../plugins/org.eclipse.osee.framework.skynet.core</module> <module>../../plugins/org.eclipse.osee.framework.skynet.core.test</module> diff --git a/plugins/org.eclipse.osee.coverage.help.ui.test/.classpath b/plugins/org.eclipse.osee.coverage.help.ui.test/.classpath new file mode 100644 index 00000000000..ad32c83a788 --- /dev/null +++ b/plugins/org.eclipse.osee.coverage.help.ui.test/.classpath @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?> +<classpath> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/> + <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> + <classpathentry kind="src" path="src"/> + <classpathentry kind="output" path="bin"/> +</classpath> diff --git a/plugins/org.eclipse.osee.coverage.help.ui.test/.project b/plugins/org.eclipse.osee.coverage.help.ui.test/.project new file mode 100644 index 00000000000..408d284a7dd --- /dev/null +++ b/plugins/org.eclipse.osee.coverage.help.ui.test/.project @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>org.eclipse.osee.coverage.help.ui.test</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + <buildCommand> + <name>org.eclipse.jdt.core.javabuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.ManifestBuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.SchemaBuilder</name> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>org.eclipse.pde.PluginNature</nature> + <nature>org.eclipse.jdt.core.javanature</nature> + </natures> +</projectDescription> diff --git a/plugins/org.eclipse.osee.coverage.help.ui.test/CoverageHelpUi_TestSuite.launch b/plugins/org.eclipse.osee.coverage.help.ui.test/CoverageHelpUi_TestSuite.launch new file mode 100644 index 00000000000..81701f6fd4a --- /dev/null +++ b/plugins/org.eclipse.osee.coverage.help.ui.test/CoverageHelpUi_TestSuite.launch @@ -0,0 +1,57 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<launchConfiguration type="org.eclipse.pde.ui.JunitLaunchConfig"> +<setAttribute key="additional_plugins"> +<setEntry value="org.eclipse.osee.coverage.help.ui:0.11.0.qualifier:default:true"/> +<setEntry value="org.eclipse.osee.framework.dev.help.ui:0.11.0.qualifier:default:false"/> +<setEntry value="org.eclipse.osee.framework.help.ui:0.11.0.qualifier:default:false"/> +<setEntry value="org.eclipse.osee.ote.help.ui:0.11.0.qualifier:default:false"/> +</setAttribute> +<booleanAttribute key="append.args" value="true"/> +<stringAttribute key="application" value="org.eclipse.pde.junit.runtime.coretestapplication"/> +<booleanAttribute key="askclear" value="false"/> +<booleanAttribute key="automaticAdd" value="true"/> +<booleanAttribute key="automaticValidate" value="true"/> +<stringAttribute key="bootstrap" value=""/> +<stringAttribute key="checked" value="[NONE]"/> +<booleanAttribute key="clearConfig" value="true"/> +<booleanAttribute key="clearws" value="true"/> +<booleanAttribute key="clearwslog" value="false"/> +<stringAttribute key="configLocation" value="${workspace_loc}/.metadata/.plugins/org.eclipse.pde.core/pde-junit"/> +<booleanAttribute key="default" value="false"/> +<booleanAttribute key="default_auto_start" value="true"/> +<stringAttribute key="deselected_workspace_plugins" value="ah6.ats.config.common,ats.config.common,com.boeing.ote.cdb.diff,com.hazelcast,com.hazelcast.source,com.sun.jersey,com.sun.jersey.client.apache,com.sun.jersey.client.apache.source,com.sun.jersey.source,com.vaadin,javax.ws.rs,javax.ws.rs.source,jms.activemq.launch,jms.libraries,lba.ats.config.common,lba.ats.config.common.test,lba.ats.config.osee,lba.ats.config.osee.test,lba.ats.help.ui,lba.authentication.provider,lba.db.connection,lba.define,lba.define.help.ui,lba.define.test,lba.framework.help.ui,lba.framework.ui.skynet,lba.framework.ui.skynet.test,lba.help,lba.myII.tc,lba.osee.client.integration.tests,lba.osee.coverage,lba.osee.x.server.customizations,lba.ote.client,lba.ote.client.ui,lba.ote.cnf.dsl,lba.ote.cnf.dsl.ui,lba.ote.commands,lba.ote.help.ui,lba.ote.launchTest,lba.ote.message.support,lba.ote.outfile.conversion,lba.ote.outfile.conversion.app,lba.ote.outfile.conversion.test,lba.ote.projectsets.three.four,lba.ote.result.upload,lba.ote.test.manager,lba.ote.test.manager.ofp,lba.ote.ui.test.manager,lba.ote.workspace.ui,lba.rdt.core,lba.rdt.core.test,lba.rdt.service,lba.rdt.service.osee,lba.rdt.ui,lba.rdt.ui.test,lba.server.station.config,lba.server.station.config.test,lba.start,lba.tools.road.map,lba.tte,lba.tte.test,lba.utility.count,lba.utility.external.editor,lba.utility.ui.count,mysql.driver.ext,net.jini,net.sf.ehcache,net.sf.ehcache.source,oracle.driver,org.boeing.count,org.eclipse.osee.ats,org.eclipse.osee.ats.api,org.eclipse.osee.ats.client.demo,org.eclipse.osee.ats.client.integration.tests,org.eclipse.osee.ats.core,org.eclipse.osee.ats.core.client,org.eclipse.osee.ats.core.client.test,org.eclipse.osee.ats.core.test,org.eclipse.osee.ats.dsl,org.eclipse.osee.ats.dsl.ui,org.eclipse.osee.ats.help.ui,org.eclipse.osee.ats.impl,org.eclipse.osee.ats.impl.test,org.eclipse.osee.ats.mocks,org.eclipse.osee.ats.presenter,org.eclipse.osee.ats.presenter.mock,org.eclipse.osee.ats.presenter.test,org.eclipse.osee.ats.reports,org.eclipse.osee.ats.reports.burndown,org.eclipse.osee.ats.reports.efficiency,org.eclipse.osee.ats.reports.split,org.eclipse.osee.ats.ui.api,org.eclipse.osee.ats.view.web,org.eclipse.osee.ats.view.web.test,org.eclipse.osee.authentication,org.eclipse.osee.authorization,org.eclipse.osee.client.demo,org.eclipse.osee.client.integration.tests,org.eclipse.osee.client.test.framework,org.eclipse.osee.cluster,org.eclipse.osee.cluster.hazelcast,org.eclipse.osee.cluster.rest,org.eclipse.osee.console.admin,org.eclipse.osee.console.admin.test,org.eclipse.osee.coverage,org.eclipse.osee.coverage.demo,org.eclipse.osee.coverage.help.ui,org.eclipse.osee.coverage.integration.tests,org.eclipse.osee.coverage.test,org.eclipse.osee.database,org.eclipse.osee.database.schema,org.eclipse.osee.define,org.eclipse.osee.define.test,org.eclipse.osee.display.api,org.eclipse.osee.display.mvp,org.eclipse.osee.display.mvp.test,org.eclipse.osee.display.presenter,org.eclipse.osee.display.presenter.mocks,org.eclipse.osee.display.presenter.test,org.eclipse.osee.display.view.web,org.eclipse.osee.distributed,org.eclipse.osee.event,org.eclipse.osee.event.monitor,org.eclipse.osee.event.osgi,org.eclipse.osee.executor.admin,org.eclipse.osee.executor.admin.test,org.eclipse.osee.framework.access,org.eclipse.osee.framework.access.provider,org.eclipse.osee.framework.access.test,org.eclipse.osee.framework.authentication.ldap.core,org.eclipse.osee.framework.branch.gantt,org.eclipse.osee.framework.core,org.eclipse.osee.framework.core.client,org.eclipse.osee.framework.core.dsl,org.eclipse.osee.framework.core.dsl.edit,org.eclipse.osee.framework.core.dsl.integration,org.eclipse.osee.framework.core.dsl.integration.test,org.eclipse.osee.framework.core.dsl.ui,org.eclipse.osee.framework.core.dsl.ui.integration,org.eclipse.osee.framework.core.dsl.ui.integration.test,org.eclipse.osee.framework.core.message,org.eclipse.osee.framework.core.message.test,org.eclipse.osee.framework.core.model,org.eclipse.osee.framework.core.model.test,org.eclipse.osee.framework.core.server,org.eclipse.osee.framework.core.server.test,org.eclipse.osee.framework.core.test,org.eclipse.osee.framework.database,org.eclipse.osee.framework.database.init,org.eclipse.osee.framework.database.test,org.eclipse.osee.framework.dev.help.ui,org.eclipse.osee.framework.h2,org.eclipse.osee.framework.help.ui,org.eclipse.osee.framework.help.ui.test,org.eclipse.osee.framework.jdk.core,org.eclipse.osee.framework.jdk.core.test,org.eclipse.osee.framework.jini,org.eclipse.osee.framework.lifecycle,org.eclipse.osee.framework.lifecycle.test,org.eclipse.osee.framework.logging,org.eclipse.osee.framework.logging.test,org.eclipse.osee.framework.manager.servlet,org.eclipse.osee.framework.messaging,org.eclipse.osee.framework.messaging.event.res,org.eclipse.osee.framework.messaging.event.res.test,org.eclipse.osee.framework.messaging.test,org.eclipse.osee.framework.plugin.core,org.eclipse.osee.framework.resource.management,org.eclipse.osee.framework.resource.management.test,org.eclipse.osee.framework.skynet.core,org.eclipse.osee.framework.skynet.core.test,org.eclipse.osee.framework.templates,org.eclipse.osee.framework.ui.admin,org.eclipse.osee.framework.ui.branch.graph,org.eclipse.osee.framework.ui.data.model.editor,org.eclipse.osee.framework.ui.plugin,org.eclipse.osee.framework.ui.product,org.eclipse.osee.framework.ui.skynet,org.eclipse.osee.framework.ui.skynet.test,org.eclipse.osee.framework.ui.swt,org.eclipse.osee.framework.ui.workspacebundleloader,org.eclipse.osee.framework.ui.ws,org.eclipse.osee.logback.config,org.eclipse.osee.logger,org.eclipse.osee.logger.slf4j,org.eclipse.osee.mail,org.eclipse.osee.mail.rest,org.eclipse.osee.mail.test,org.eclipse.osee.mvp.example,org.eclipse.osee.mvp.example.api,org.eclipse.osee.mvp.example.presenter,org.eclipse.osee.mvp.example.view,org.eclipse.osee.orcs,org.eclipse.osee.orcs.core,org.eclipse.osee.orcs.core.test,org.eclipse.osee.orcs.db,org.eclipse.osee.orcs.db.mock,org.eclipse.osee.orcs.db.test,org.eclipse.osee.orcs.rest,org.eclipse.osee.orcs.rest.client,org.eclipse.osee.orcs.rest.model,org.eclipse.osee.orcs.rest.test,org.eclipse.osee.orcs.test,org.eclipse.osee.ote.client,org.eclipse.osee.ote.client.msg,org.eclipse.osee.ote.connection.jini,org.eclipse.osee.ote.connection.service,org.eclipse.osee.ote.connection.service.test,org.eclipse.osee.ote.container,org.eclipse.osee.ote.core,org.eclipse.osee.ote.core.test,org.eclipse.osee.ote.define,org.eclipse.osee.ote.help.ui,org.eclipse.osee.ote.jms,org.eclipse.osee.ote.message,org.eclipse.osee.ote.message.test,org.eclipse.osee.ote.messaging.dds,org.eclipse.osee.ote.model.manager,org.eclipse.osee.ote.runtimeManager,org.eclipse.osee.ote.server,org.eclipse.osee.ote.ui,org.eclipse.osee.ote.ui.define,org.eclipse.osee.ote.ui.markers,org.eclipse.osee.ote.ui.output,org.eclipse.osee.ote.ui.test.manager,org.eclipse.osee.ote.ui.test.output,org.eclipse.osee.ote.version,org.eclipse.osee.ote.version.git,org.eclipse.osee.ote.version.git.test,org.eclipse.osee.ote.version.svn,org.eclipse.osee.rest.admin,org.eclipse.osee.rest.test.client,org.eclipse.osee.rest.test.model,org.eclipse.osee.rest.test.server,org.eclipse.osee.sos,org.eclipse.osee.support.dev.java,org.eclipse.osee.support.test.util,org.eclipse.osee.user.admin,org.eclipse.osee.vaadin,org.eclipse.osee.vaadin.example.ui,org.eclipse.osee.vaadin.themes,org.eclipse.osee.vaadin.widgets,org.eclipse.osee.x.server.application,org.json,org.jvnet.mimepull,org.jvnet.mimepull.source,org.mockito,org.mockito.source,org.mockito.test.example,org.objenesis,org.objenesis.source,org.postgresql.driver,org.xerial.sqlite,org.xerial.sqlite.source"/> +<stringAttribute key="featureDefaultLocation" value="workspace"/> +<stringAttribute key="featurePluginResolution" value="workspace"/> +<booleanAttribute key="includeOptional" value="true"/> +<stringAttribute key="location" value="${workspace_loc}/../junit-workspace"/> +<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS"> +<listEntry value="/org.eclipse.osee.coverage.help.ui.test/src/org/eclipse/osee/coverage/help/ui/CoverageHelpUiTestSuite.java"/> +</listAttribute> +<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES"> +<listEntry value="1"/> +</listAttribute> +<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value=""/> +<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/> +<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/> +<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit4"/> +<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.eclipse.osee.coverage.help.ui.CoverageHelpUiTestSuite"/> +<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-os ${target.os} -ws ${target.ws} -arch ${target.arch} -nl ${target.nl} -consoleLog"/> +<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="org.eclipse.osee.coverage.help.ui.test"/> +<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.pde.ui.workbenchClasspathProvider"/> +<stringAttribute key="pde.version" value="3.3"/> +<stringAttribute key="product" value="org.eclipse.osee.framework.ui.product.osee"/> +<booleanAttribute key="run_in_ui_thread" value="false"/> +<setAttribute key="selected_features"> +<setEntry value="org.eclipse.osee.core.feature:default"/> +<setEntry value="org.eclipse.osee.core.plugin.feature:default"/> +<setEntry value="org.eclipse.osee.core.runtime.feature:default"/> +<setEntry value="org.eclipse.osee.core.ui.feature:default"/> +</setAttribute> +<booleanAttribute key="show_selected_only" value="true"/> +<stringAttribute key="templateConfig" value="${target_home}\configuration\config.ini"/> +<booleanAttribute key="tracing" value="false"/> +<booleanAttribute key="useCustomFeatures" value="true"/> +<booleanAttribute key="useDefaultConfig" value="true"/> +<booleanAttribute key="useDefaultConfigArea" value="false"/> +<booleanAttribute key="useProduct" value="false"/> +</launchConfiguration> diff --git a/plugins/org.eclipse.osee.coverage.help.ui.test/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.coverage.help.ui.test/META-INF/MANIFEST.MF new file mode 100644 index 00000000000..3dc2678a4ca --- /dev/null +++ b/plugins/org.eclipse.osee.coverage.help.ui.test/META-INF/MANIFEST.MF @@ -0,0 +1,12 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: OSEE Coverage Help UI Test (Incubation) +Bundle-SymbolicName: org.eclipse.osee.coverage.help.ui.test +Bundle-Version: 0.11.0.qualifier +Bundle-Vendor: Eclipse Open System Engineering Environment +Fragment-Host: org.eclipse.osee.coverage.help.ui +Bundle-RequiredExecutionEnvironment: JavaSE-1.6 +Require-Bundle: org.junit +Import-Package: org.eclipse.core.runtime;version="3.4.0", + org.eclipse.osee.framework.jdk.core.util, + org.osgi.framework diff --git a/plugins/org.eclipse.osee.coverage.help.ui.test/build.properties b/plugins/org.eclipse.osee.coverage.help.ui.test/build.properties new file mode 100644 index 00000000000..1b243b1a937 --- /dev/null +++ b/plugins/org.eclipse.osee.coverage.help.ui.test/build.properties @@ -0,0 +1,5 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + . +additional.bundles = org.eclipse.osee.framework.jdk.core diff --git a/plugins/org.eclipse.osee.coverage.help.ui.test/pom.xml b/plugins/org.eclipse.osee.coverage.help.ui.test/pom.xml new file mode 100644 index 00000000000..e1b069d3f81 --- /dev/null +++ b/plugins/org.eclipse.osee.coverage.help.ui.test/pom.xml @@ -0,0 +1,30 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>org.eclipse.osee</groupId> + <artifactId>org.eclipse.osee.coverage.parent</artifactId> + <version>0.11.0-SNAPSHOT</version> + <relativePath>../../plugins/org.eclipse.osee.coverage.parent</relativePath> + </parent> + + <artifactId>org.eclipse.osee.coverage.help.ui.test</artifactId> + <packaging>eclipse-test-plugin</packaging> + <name>OSEE Coverage Help UI Test - (Incubation)</name> + + <build> + <plugins> + <plugin> + <groupId>org.eclipse.tycho</groupId> + <artifactId>tycho-surefire-plugin</artifactId> + <version>${tycho-version}</version> + <configuration> + <testSuite>org.eclipse.osee.coverage.help.ui.test</testSuite> + <testClass>org.eclipse.osee.coverage.help.ui.CoverageHelpUiTestSuite</testClass> + </configuration> + </plugin> + </plugins> + </build> +</project>
\ No newline at end of file diff --git a/plugins/org.eclipse.osee.coverage.help.ui.test/src/org/eclipse/osee/coverage/help/ui/CoverageHelpUiTestSuite.java b/plugins/org.eclipse.osee.coverage.help.ui.test/src/org/eclipse/osee/coverage/help/ui/CoverageHelpUiTestSuite.java new file mode 100644 index 00000000000..370a8747ed9 --- /dev/null +++ b/plugins/org.eclipse.osee.coverage.help.ui.test/src/org/eclipse/osee/coverage/help/ui/CoverageHelpUiTestSuite.java @@ -0,0 +1,23 @@ +/******************************************************************************* + * Copyright (c) 2013 Boeing. + * 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: + * Boeing - initial API and implementation + *******************************************************************************/ +package org.eclipse.osee.coverage.help.ui; + +import org.junit.runner.RunWith; +import org.junit.runners.Suite; + +/** + * @author Angel Avila + */ +@RunWith(Suite.class) +@Suite.SuiteClasses({HelpContextTest.class, HelpTableOfContentTest.class}) +public class CoverageHelpUiTestSuite { + // Test Suite +} diff --git a/plugins/org.eclipse.osee.coverage.help.ui.test/src/org/eclipse/osee/coverage/help/ui/HelpContextTest.java b/plugins/org.eclipse.osee.coverage.help.ui.test/src/org/eclipse/osee/coverage/help/ui/HelpContextTest.java new file mode 100644 index 00000000000..1cfe692e5f9 --- /dev/null +++ b/plugins/org.eclipse.osee.coverage.help.ui.test/src/org/eclipse/osee/coverage/help/ui/HelpContextTest.java @@ -0,0 +1,85 @@ +/******************************************************************************* + * Copyright (c) 2013 Boeing. + * 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: + * Boeing - initial API and implementation + *******************************************************************************/ +package org.eclipse.osee.coverage.help.ui; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import java.lang.reflect.Field; +import java.net.URL; +import java.util.HashMap; +import java.util.Map; +import org.eclipse.osee.coverage.help.ui.util.ContextParser; +import org.eclipse.osee.coverage.help.ui.util.ContextParser.ContextEntry; +import org.eclipse.osee.coverage.help.ui.util.HelpTestUtil; +import org.eclipse.osee.framework.jdk.core.util.Compare; +import org.eclipse.osee.framework.ui.plugin.util.HelpContext; +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.Test; + +/** + * @author Angel Avila + */ +public class HelpContextTest { + + private static final String PLUGIN_ID = "org.eclipse.osee.coverage.help.ui"; + + private static Map<String, HelpContext> contexts; + private static ContextParser parser; + + @BeforeClass + public static void setUp() throws Exception { + contexts = getContexts(CoverageHelpContext.class); + parser = new ContextParser("contexts/contexts.xml"); + parser.parse(); + } + + @Test + public void testAdd() throws Exception { + assertEquals(8, contexts.size()); + } + + @Test + public void testContextsXml() throws Exception { + assertEquals(contexts.size(), parser.getEntries().size()); + + Assert.assertFalse(Compare.isDifferent(contexts.keySet(), parser.getIds())); + for (HelpContext context : contexts.values()) { + assertEquals(PLUGIN_ID, context.getPluginId()); + + String id = context.getName(); + ContextEntry entry = parser.getEntry(id); + assertNotNull(entry); + } + } + + @Test + public void testHrefFiles() throws Exception { + for (ContextEntry entry : parser.getEntries()) { + for (String reference : entry.getReferences()) { + URL url = HelpTestUtil.getResource(reference); + assertNotNull(String.format("[%s] was not valid", reference), url); + } + } + } + + private static Map<String, HelpContext> getContexts(Class<?> clazz) throws IllegalArgumentException, IllegalAccessException { + Map<String, HelpContext> contexts = new HashMap<String, HelpContext>(); + for (Field field : clazz.getFields()) { + Object object = field.get(null); + if (object instanceof HelpContext) { + HelpContext context = (HelpContext) object; + contexts.put(context.getName(), context); + } + } + return contexts; + } +} diff --git a/plugins/org.eclipse.osee.coverage.help.ui.test/src/org/eclipse/osee/coverage/help/ui/HelpTableOfContentTest.java b/plugins/org.eclipse.osee.coverage.help.ui.test/src/org/eclipse/osee/coverage/help/ui/HelpTableOfContentTest.java new file mode 100644 index 00000000000..165b6fce590 --- /dev/null +++ b/plugins/org.eclipse.osee.coverage.help.ui.test/src/org/eclipse/osee/coverage/help/ui/HelpTableOfContentTest.java @@ -0,0 +1,62 @@ +/******************************************************************************* + * Copyright (c) 2013 Boeing. + * 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: + * Boeing - initial API and implementation + *******************************************************************************/ +package org.eclipse.osee.coverage.help.ui; + +import static org.junit.Assert.assertNotNull; +import java.net.URL; +import java.util.Set; +import org.eclipse.osee.coverage.help.ui.util.HelpTestUtil; +import org.eclipse.osee.coverage.help.ui.util.HtmlParser; +import org.eclipse.osee.coverage.help.ui.util.TocParser; +import org.junit.BeforeClass; +import org.junit.Test; + +; + +/** + * @author Angel Avila + */ +public class HelpTableOfContentTest { + + private static final String PLUGIN_ID = "org.eclipse.osee.coverage.help.ui"; + + private static TocParser parser; + + @BeforeClass + public static void setUp() throws Exception { + parser = new TocParser("toc.xml"); + parser.parse(); + } + + @Test + public void testAllTocReferencesExist() throws Exception { + for (String reference : parser.getEntries()) { + URL url = HelpTestUtil.getResource(reference); + assertNotNull(String.format("[%s] was not valid", reference), url); + } + } + + @Test + public void testTocReferencesValid() throws Exception { + HtmlParser htmlParser = new HtmlParser(PLUGIN_ID); + + for (String reference : parser.getEntries()) { + URL url = HelpTestUtil.getResource(reference); + + Set<String> entries = htmlParser.parse(url); + for (String resource : entries) { + URL referencedUrl = HelpTestUtil.getResource(reference); + assertNotNull(String.format("[%s] was not valid", resource), referencedUrl); + } + + } + } +} diff --git a/plugins/org.eclipse.osee.coverage.help.ui.test/src/org/eclipse/osee/coverage/help/ui/util/ContextParser.java b/plugins/org.eclipse.osee.coverage.help.ui.test/src/org/eclipse/osee/coverage/help/ui/util/ContextParser.java new file mode 100644 index 00000000000..2f7807c9c65 --- /dev/null +++ b/plugins/org.eclipse.osee.coverage.help.ui.test/src/org/eclipse/osee/coverage/help/ui/util/ContextParser.java @@ -0,0 +1,141 @@ +/******************************************************************************* + * Copyright (c) 2013 Boeing. + * 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: + * Boeing - initial API and implementation + *******************************************************************************/ +package org.eclipse.osee.coverage.help.ui.util; + +import java.io.BufferedInputStream; +import java.io.InputStream; +import java.net.URL; +import java.util.Collection; +import java.util.HashMap; +import java.util.LinkedHashSet; +import java.util.Map; +import java.util.Set; +import javax.xml.stream.XMLInputFactory; +import javax.xml.stream.XMLStreamConstants; +import javax.xml.stream.XMLStreamReader; +import org.eclipse.osee.framework.jdk.core.util.Lib; +import org.eclipse.osee.framework.jdk.core.util.Strings; + +/** + * @author Angel Avila + */ +public class ContextParser { + + private static final XMLInputFactory xmlInputFactory = XMLInputFactory.newFactory(); + + private static final String CONTEXT = "context"; + private static final String TOPIC = "topic"; + private static final String HREF = "href"; + private static final String ID_TAG = "id"; + + public Map<String, ContextEntry> entries = new HashMap<String, ContextEntry>(); + public String path; + + private String localName; + private String uri; + private ContextEntry currentEntry; + + public ContextParser(String path) { + this.path = path; + } + + public void parse() throws Exception { + entries.clear(); + URL url = HelpTestUtil.getResource(path); + + InputStream inputStream = null; + try { + inputStream = new BufferedInputStream(url.openStream()); + XMLStreamReader streamReader = xmlInputFactory.createXMLStreamReader(inputStream); + while (streamReader.hasNext()) { + process(streamReader); + streamReader.next(); + } + + } finally { + Lib.close(inputStream); + } + } + + private void process(XMLStreamReader reader) { + int eventType = reader.getEventType(); + switch (eventType) { + case XMLStreamConstants.START_ELEMENT: + localName = reader.getLocalName(); + uri = reader.getNamespaceURI(); + if (CONTEXT.equals(localName)) { + + String id = reader.getAttributeValue(uri, ID_TAG); + if (Strings.isValid(id)) { + currentEntry = new ContextEntry(id); + } + + } else if (TOPIC.equals(localName) && currentEntry != null) { + String reference = reader.getAttributeValue(uri, HREF); + if (Strings.isValid(reference)) { + String path = normalizePath(reference); + currentEntry.getReferences().add(path); + } + } + break; + case XMLStreamConstants.END_ELEMENT: + localName = reader.getLocalName(); + uri = reader.getNamespaceURI(); + if (CONTEXT.equals(localName) && currentEntry != null) { + entries.put(currentEntry.getId(), currentEntry); + reset(); + } + break; + } + } + + private String normalizePath(String reference) { + return reference.replaceAll("\\.html#.*", ".html"); + } + + private void reset() { + localName = null; + uri = null; + currentEntry = null; + } + + public Collection<ContextEntry> getEntries() { + return entries.values(); + } + + public ContextEntry getEntry(String id) { + return entries.get(id); + } + + public Set<String> getIds() { + return entries.keySet(); + } + + public final class ContextEntry { + private final String id; + private final Set<String> references = new LinkedHashSet<String>(); + + public ContextEntry(String id) { + super(); + this.id = id; + } + + public String getId() { + return id; + } + + public Set<String> getReferences() { + return references; + } + + } + +} diff --git a/plugins/org.eclipse.osee.coverage.help.ui.test/src/org/eclipse/osee/coverage/help/ui/util/HelpTestUtil.java b/plugins/org.eclipse.osee.coverage.help.ui.test/src/org/eclipse/osee/coverage/help/ui/util/HelpTestUtil.java new file mode 100644 index 00000000000..f5c88e52a9d --- /dev/null +++ b/plugins/org.eclipse.osee.coverage.help.ui.test/src/org/eclipse/osee/coverage/help/ui/util/HelpTestUtil.java @@ -0,0 +1,43 @@ +/******************************************************************************* + * Copyright (c) 2013 Boeing. + * 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: + * Boeing - initial API and implementation + *******************************************************************************/ +package org.eclipse.osee.coverage.help.ui.util; + +import static junit.framework.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import java.io.File; +import java.net.URL; +import org.eclipse.core.runtime.FileLocator; +import org.osgi.framework.Bundle; +import org.osgi.framework.FrameworkUtil; + +/** + * @author Angel Avila + */ +public final class HelpTestUtil { + + private HelpTestUtil() { + // Utility Class + } + + public static URL getResource(String resource) throws Exception { + Bundle bundle = FrameworkUtil.getBundle(HelpTestUtil.class); + URL url = bundle.getResource(resource); + + assertNotNull(String.format("Resource not found: [%s]", resource), url); + + url = FileLocator.toFileURL(url); + File file = new File(url.toURI()); + assertEquals(String.format("[%s] does not exist", resource), true, file.exists()); + assertEquals(String.format("[%s] unreadable", resource), true, file.canRead()); + + return url; + } +} diff --git a/plugins/org.eclipse.osee.coverage.help.ui.test/src/org/eclipse/osee/coverage/help/ui/util/HtmlParser.java b/plugins/org.eclipse.osee.coverage.help.ui.test/src/org/eclipse/osee/coverage/help/ui/util/HtmlParser.java new file mode 100644 index 00000000000..d2dd6451e1c --- /dev/null +++ b/plugins/org.eclipse.osee.coverage.help.ui.test/src/org/eclipse/osee/coverage/help/ui/util/HtmlParser.java @@ -0,0 +1,119 @@ +/******************************************************************************* + * Copyright (c) 2013 Boeing. + * 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: + * Boeing - initial API and implementation + *******************************************************************************/ +package org.eclipse.osee.coverage.help.ui.util; + +import java.io.BufferedInputStream; +import java.io.InputStream; +import java.net.URL; +import java.util.HashSet; +import java.util.Set; +import javax.xml.stream.XMLInputFactory; +import javax.xml.stream.XMLStreamConstants; +import javax.xml.stream.XMLStreamReader; +import org.eclipse.osee.framework.jdk.core.util.Lib; +import org.eclipse.osee.framework.jdk.core.util.Strings; + +; + +/** + * @author Angel Avila + */ +public class HtmlParser { + + private static final XMLInputFactory xmlInputFactory = XMLInputFactory.newFactory(); + + private static final String LINK_NODE = "link"; + private static final String HREF_TAG = "href"; + private static final String SRC_TAG = "src"; + + private final String pathHint; + + public HtmlParser(String pathHint) { + this.pathHint = pathHint; + } + + private String getPath(String fullPath) { + StringBuilder builder = new StringBuilder(); + + String[] parts = fullPath.split("/"); + boolean found = false; + for (String part : parts) { + if (found && !part.endsWith(".html")) { + builder.append(part); + builder.append("/"); + } + if (pathHint.equals(part)) { + found = true; + } + } + return builder.toString(); + } + + public Set<String> parse(URL url) throws Exception { + Set<String> entries = new HashSet<String>(); + entries.clear(); + + String pathPrefix = getPath(url.toString()); + + InputStream inputStream = null; + try { + inputStream = new BufferedInputStream(url.openStream()); + XMLStreamReader streamReader = xmlInputFactory.createXMLStreamReader(inputStream); + while (streamReader.hasNext()) { + process(streamReader, pathPrefix, entries); + streamReader.next(); + } + + } finally { + Lib.close(inputStream); + } + + return entries; + } + + private void process(XMLStreamReader reader, String pathPrefix, Set<String> entries) { + int eventType = reader.getEventType(); + switch (eventType) { + case XMLStreamConstants.START_ELEMENT: + String localName = reader.getLocalName(); + for (int index = 0; index < reader.getAttributeCount(); index++) { + + String attributeName = reader.getAttributeLocalName(index); + String value = reader.getAttributeValue(index); + + if (Strings.isValid(value)) { + if (!LINK_NODE.equals(localName)) { + if (HREF_TAG.equals(attributeName) || SRC_TAG.equals(attributeName)) { + processResource(pathPrefix, entries, value); + } + } + } + } + break; + } + } + + private void processResource(String pathPrefix, Set<String> references, String value) { + if (!isExternalLink(value)) { + String reference = normalizePath(pathPrefix, value); + references.add(reference); + } + } + + private String normalizePath(String pathPrefix, String reference) { + String path = reference.replaceAll("\\.html#.*", ".html"); + return String.format("%s%s", pathPrefix, path); + } + + private boolean isExternalLink(String resource) { + return resource.contains("://"); + } +} diff --git a/plugins/org.eclipse.osee.coverage.help.ui.test/src/org/eclipse/osee/coverage/help/ui/util/TocParser.java b/plugins/org.eclipse.osee.coverage.help.ui.test/src/org/eclipse/osee/coverage/help/ui/util/TocParser.java new file mode 100644 index 00000000000..5356804bcd5 --- /dev/null +++ b/plugins/org.eclipse.osee.coverage.help.ui.test/src/org/eclipse/osee/coverage/help/ui/util/TocParser.java @@ -0,0 +1,103 @@ +/******************************************************************************* + * Copyright (c) 2013 Boeing. + * 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: + * Boeing - initial API and implementation + *******************************************************************************/ +package org.eclipse.osee.coverage.help.ui.util; + +import java.io.BufferedInputStream; +import java.io.InputStream; +import java.net.URL; +import java.util.HashSet; +import java.util.Set; +import javax.xml.stream.XMLInputFactory; +import javax.xml.stream.XMLStreamConstants; +import javax.xml.stream.XMLStreamReader; +import org.eclipse.osee.framework.jdk.core.util.Lib; +import org.eclipse.osee.framework.jdk.core.util.Strings; + +/** + * @author Angel Avila + */ +public class TocParser { + + private static final XMLInputFactory xmlInputFactory = XMLInputFactory.newFactory(); + + private static final String TOC = "toc"; + private static final String TOPIC = "topic"; + private static final String HREF = "href"; + + public Set<String> entries = new HashSet<String>(); + public String path; + + private String localName; + private String uri; + + public TocParser(String path) { + this.path = path; + } + + public void parse() throws Exception { + entries.clear(); + URL url = HelpTestUtil.getResource(path); + + InputStream inputStream = null; + try { + inputStream = new BufferedInputStream(url.openStream()); + XMLStreamReader streamReader = xmlInputFactory.createXMLStreamReader(inputStream); + while (streamReader.hasNext()) { + process(streamReader); + streamReader.next(); + } + + } finally { + Lib.close(inputStream); + } + } + + private void process(XMLStreamReader reader) { + int eventType = reader.getEventType(); + switch (eventType) { + case XMLStreamConstants.START_ELEMENT: + localName = reader.getLocalName(); + uri = reader.getNamespaceURI(); + if (TOC.equals(localName)) { + processReference(reader, TOPIC); + } else if (TOPIC.equals(localName)) { + processReference(reader, HREF); + } + break; + case XMLStreamConstants.END_ELEMENT: + localName = reader.getLocalName(); + uri = reader.getNamespaceURI(); + reset(); + break; + } + } + + private void processReference(XMLStreamReader reader, String tag) { + String reference = reader.getAttributeValue(uri, tag); + if (Strings.isValid(reference)) { + String path = normalizePath(reference); + entries.add(path); + } + } + + private String normalizePath(String reference) { + return reference.replaceAll("\\.html#.*", ".html"); + } + + private void reset() { + localName = null; + uri = null; + } + + public Set<String> getEntries() { + return entries; + } +} diff --git a/plugins/org.eclipse.osee.coverage.help.ui/src/org/eclipse/osee/coverage/help/ui/CoverageHelpContext.java b/plugins/org.eclipse.osee.coverage.help.ui/src/org/eclipse/osee/coverage/help/ui/CoverageHelpContext.java index 5a33eeaf3a3..0ec06daa95d 100644 --- a/plugins/org.eclipse.osee.coverage.help.ui/src/org/eclipse/osee/coverage/help/ui/CoverageHelpContext.java +++ b/plugins/org.eclipse.osee.coverage.help.ui/src/org/eclipse/osee/coverage/help/ui/CoverageHelpContext.java @@ -22,7 +22,7 @@ public class CoverageHelpContext { // Private Constructor } - private static final String PLUGIN_ID = "org.eclipse.osee.framework.help.ui"; + private static final String PLUGIN_ID = "org.eclipse.osee.coverage.help.ui"; public static final HelpContext NAVIGATOR = toContext("coverage_navigator"); diff --git a/plugins/org.eclipse.osee.coverage.parent/pom.xml b/plugins/org.eclipse.osee.coverage.parent/pom.xml index 13ff4c60a01..e6dd7eceb03 100644 --- a/plugins/org.eclipse.osee.coverage.parent/pom.xml +++ b/plugins/org.eclipse.osee.coverage.parent/pom.xml @@ -21,6 +21,7 @@ <module>../../plugins/org.eclipse.osee.coverage.test</module> <module>../../plugins/org.eclipse.osee.coverage.help.ui</module> + <module>../../plugins/org.eclipse.osee.coverage.help.ui.test</module> <module>../../features/org.eclipse.osee.coverage.feature</module> <module>../../features/org.eclipse.osee.coverage.feature.source</module> diff --git a/plugins/org.eclipse.osee.framework.dev.help.ui.test/.classpath b/plugins/org.eclipse.osee.framework.dev.help.ui.test/.classpath new file mode 100644 index 00000000000..ad32c83a788 --- /dev/null +++ b/plugins/org.eclipse.osee.framework.dev.help.ui.test/.classpath @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?> +<classpath> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/> + <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> + <classpathentry kind="src" path="src"/> + <classpathentry kind="output" path="bin"/> +</classpath> diff --git a/plugins/org.eclipse.osee.framework.dev.help.ui.test/.project b/plugins/org.eclipse.osee.framework.dev.help.ui.test/.project new file mode 100644 index 00000000000..40a4ee7b296 --- /dev/null +++ b/plugins/org.eclipse.osee.framework.dev.help.ui.test/.project @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>org.eclipse.osee.framework.dev.help.ui.test</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + <buildCommand> + <name>org.eclipse.jdt.core.javabuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.ManifestBuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.SchemaBuilder</name> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>org.eclipse.pde.PluginNature</nature> + <nature>org.eclipse.jdt.core.javanature</nature> + </natures> +</projectDescription> diff --git a/plugins/org.eclipse.osee.framework.dev.help.ui.test/DevHelpUi_TestSuite.launch b/plugins/org.eclipse.osee.framework.dev.help.ui.test/DevHelpUi_TestSuite.launch new file mode 100644 index 00000000000..3a508f3a158 --- /dev/null +++ b/plugins/org.eclipse.osee.framework.dev.help.ui.test/DevHelpUi_TestSuite.launch @@ -0,0 +1,55 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<launchConfiguration type="org.eclipse.pde.ui.JunitLaunchConfig"> +<setAttribute key="additional_plugins"> +<setEntry value="org.eclipse.osee.framework.dev.help.ui:0.11.0.qualifier:default:true"/> +<setEntry value="org.eclipse.osee.framework.dev.help.ui:0.11.0.qualifier:default:false"/> +</setAttribute> +<booleanAttribute key="append.args" value="true"/> +<stringAttribute key="application" value="org.eclipse.pde.junit.runtime.coretestapplication"/> +<booleanAttribute key="askclear" value="false"/> +<booleanAttribute key="automaticAdd" value="true"/> +<booleanAttribute key="automaticValidate" value="true"/> +<stringAttribute key="bootstrap" value=""/> +<stringAttribute key="checked" value="[NONE]"/> +<booleanAttribute key="clearConfig" value="true"/> +<booleanAttribute key="clearws" value="true"/> +<booleanAttribute key="clearwslog" value="false"/> +<stringAttribute key="configLocation" value="${workspace_loc}/.metadata/.plugins/org.eclipse.pde.core/pde-junit"/> +<booleanAttribute key="default" value="false"/> +<booleanAttribute key="default_auto_start" value="true"/> +<stringAttribute key="deselected_workspace_plugins" value="ah6.ats.config.common,ats.config.common,com.boeing.ote.cdb.diff,com.hazelcast,com.hazelcast.source,com.sun.jersey,com.sun.jersey.client.apache,com.sun.jersey.client.apache.source,com.sun.jersey.source,com.vaadin,javax.ws.rs,javax.ws.rs.source,jms.activemq.launch,jms.libraries,lba.ats.config.common,lba.ats.config.common.test,lba.ats.config.osee,lba.ats.config.osee.test,lba.ats.help.ui,lba.authentication.provider,lba.db.connection,lba.define,lba.define.help.ui,lba.define.test,lba.framework.help.ui,lba.framework.ui.skynet,lba.framework.ui.skynet.test,lba.help,lba.myII.tc,lba.osee.client.integration.tests,lba.osee.coverage,lba.osee.x.server.customizations,lba.ote.client,lba.ote.client.ui,lba.ote.cnf.dsl,lba.ote.cnf.dsl.ui,lba.ote.commands,lba.ote.help.ui,lba.ote.launchTest,lba.ote.message.support,lba.ote.outfile.conversion,lba.ote.outfile.conversion.app,lba.ote.outfile.conversion.test,lba.ote.projectsets.three.four,lba.ote.result.upload,lba.ote.test.manager,lba.ote.test.manager.ofp,lba.ote.ui.test.manager,lba.ote.workspace.ui,lba.rdt.core,lba.rdt.core.test,lba.rdt.service,lba.rdt.service.osee,lba.rdt.ui,lba.rdt.ui.test,lba.server.station.config,lba.server.station.config.test,lba.start,lba.tools.road.map,lba.tte,lba.tte.test,lba.utility.count,lba.utility.external.editor,lba.utility.ui.count,mysql.driver.ext,net.jini,net.sf.ehcache,net.sf.ehcache.source,oracle.driver,org.boeing.count,org.eclipse.osee.ats,org.eclipse.osee.ats.api,org.eclipse.osee.ats.client.demo,org.eclipse.osee.ats.client.integration.tests,org.eclipse.osee.ats.core,org.eclipse.osee.ats.core.client,org.eclipse.osee.ats.core.client.test,org.eclipse.osee.ats.core.test,org.eclipse.osee.ats.dsl,org.eclipse.osee.ats.dsl.ui,org.eclipse.osee.ats.help.ui,org.eclipse.osee.ats.impl,org.eclipse.osee.ats.impl.test,org.eclipse.osee.ats.mocks,org.eclipse.osee.ats.presenter,org.eclipse.osee.ats.presenter.mock,org.eclipse.osee.ats.presenter.test,org.eclipse.osee.ats.reports,org.eclipse.osee.ats.reports.burndown,org.eclipse.osee.ats.reports.efficiency,org.eclipse.osee.ats.reports.split,org.eclipse.osee.ats.ui.api,org.eclipse.osee.ats.view.web,org.eclipse.osee.ats.view.web.test,org.eclipse.osee.authentication,org.eclipse.osee.authorization,org.eclipse.osee.client.demo,org.eclipse.osee.client.integration.tests,org.eclipse.osee.client.test.framework,org.eclipse.osee.cluster,org.eclipse.osee.cluster.hazelcast,org.eclipse.osee.cluster.rest,org.eclipse.osee.console.admin,org.eclipse.osee.console.admin.test,org.eclipse.osee.coverage,org.eclipse.osee.coverage.demo,org.eclipse.osee.coverage.help.ui,org.eclipse.osee.coverage.integration.tests,org.eclipse.osee.coverage.test,org.eclipse.osee.database,org.eclipse.osee.database.schema,org.eclipse.osee.define,org.eclipse.osee.define.test,org.eclipse.osee.display.api,org.eclipse.osee.display.mvp,org.eclipse.osee.display.mvp.test,org.eclipse.osee.display.presenter,org.eclipse.osee.display.presenter.mocks,org.eclipse.osee.display.presenter.test,org.eclipse.osee.display.view.web,org.eclipse.osee.distributed,org.eclipse.osee.event,org.eclipse.osee.event.monitor,org.eclipse.osee.event.osgi,org.eclipse.osee.executor.admin,org.eclipse.osee.executor.admin.test,org.eclipse.osee.framework.access,org.eclipse.osee.framework.access.provider,org.eclipse.osee.framework.access.test,org.eclipse.osee.framework.authentication.ldap.core,org.eclipse.osee.framework.branch.gantt,org.eclipse.osee.framework.core,org.eclipse.osee.framework.core.client,org.eclipse.osee.framework.core.dsl,org.eclipse.osee.framework.core.dsl.edit,org.eclipse.osee.framework.core.dsl.integration,org.eclipse.osee.framework.core.dsl.integration.test,org.eclipse.osee.framework.core.dsl.ui,org.eclipse.osee.framework.core.dsl.ui.integration,org.eclipse.osee.framework.core.dsl.ui.integration.test,org.eclipse.osee.framework.core.message,org.eclipse.osee.framework.core.message.test,org.eclipse.osee.framework.core.model,org.eclipse.osee.framework.core.model.test,org.eclipse.osee.framework.core.server,org.eclipse.osee.framework.core.server.test,org.eclipse.osee.framework.core.test,org.eclipse.osee.framework.database,org.eclipse.osee.framework.database.init,org.eclipse.osee.framework.database.test,org.eclipse.osee.framework.dev.help.ui,org.eclipse.osee.framework.h2,org.eclipse.osee.framework.help.ui,org.eclipse.osee.framework.help.ui.test,org.eclipse.osee.framework.jdk.core,org.eclipse.osee.framework.jdk.core.test,org.eclipse.osee.framework.jini,org.eclipse.osee.framework.lifecycle,org.eclipse.osee.framework.lifecycle.test,org.eclipse.osee.framework.logging,org.eclipse.osee.framework.logging.test,org.eclipse.osee.framework.manager.servlet,org.eclipse.osee.framework.messaging,org.eclipse.osee.framework.messaging.event.res,org.eclipse.osee.framework.messaging.event.res.test,org.eclipse.osee.framework.messaging.test,org.eclipse.osee.framework.plugin.core,org.eclipse.osee.framework.resource.management,org.eclipse.osee.framework.resource.management.test,org.eclipse.osee.framework.skynet.core,org.eclipse.osee.framework.skynet.core.test,org.eclipse.osee.framework.templates,org.eclipse.osee.framework.ui.admin,org.eclipse.osee.framework.ui.branch.graph,org.eclipse.osee.framework.ui.data.model.editor,org.eclipse.osee.framework.ui.plugin,org.eclipse.osee.framework.ui.product,org.eclipse.osee.framework.ui.skynet,org.eclipse.osee.framework.ui.skynet.test,org.eclipse.osee.framework.ui.swt,org.eclipse.osee.framework.ui.workspacebundleloader,org.eclipse.osee.framework.ui.ws,org.eclipse.osee.logback.config,org.eclipse.osee.logger,org.eclipse.osee.logger.slf4j,org.eclipse.osee.mail,org.eclipse.osee.mail.rest,org.eclipse.osee.mail.test,org.eclipse.osee.mvp.example,org.eclipse.osee.mvp.example.api,org.eclipse.osee.mvp.example.presenter,org.eclipse.osee.mvp.example.view,org.eclipse.osee.orcs,org.eclipse.osee.orcs.core,org.eclipse.osee.orcs.core.test,org.eclipse.osee.orcs.db,org.eclipse.osee.orcs.db.mock,org.eclipse.osee.orcs.db.test,org.eclipse.osee.orcs.rest,org.eclipse.osee.orcs.rest.client,org.eclipse.osee.orcs.rest.model,org.eclipse.osee.orcs.rest.test,org.eclipse.osee.orcs.test,org.eclipse.osee.ote.client,org.eclipse.osee.ote.client.msg,org.eclipse.osee.ote.connection.jini,org.eclipse.osee.ote.connection.service,org.eclipse.osee.ote.connection.service.test,org.eclipse.osee.ote.container,org.eclipse.osee.ote.core,org.eclipse.osee.ote.core.test,org.eclipse.osee.ote.define,org.eclipse.osee.ote.help.ui,org.eclipse.osee.ote.jms,org.eclipse.osee.ote.message,org.eclipse.osee.ote.message.test,org.eclipse.osee.ote.messaging.dds,org.eclipse.osee.ote.model.manager,org.eclipse.osee.ote.runtimeManager,org.eclipse.osee.ote.server,org.eclipse.osee.ote.ui,org.eclipse.osee.ote.ui.define,org.eclipse.osee.ote.ui.markers,org.eclipse.osee.ote.ui.output,org.eclipse.osee.ote.ui.test.manager,org.eclipse.osee.ote.ui.test.output,org.eclipse.osee.ote.version,org.eclipse.osee.ote.version.git,org.eclipse.osee.ote.version.git.test,org.eclipse.osee.ote.version.svn,org.eclipse.osee.rest.admin,org.eclipse.osee.rest.test.client,org.eclipse.osee.rest.test.model,org.eclipse.osee.rest.test.server,org.eclipse.osee.sos,org.eclipse.osee.support.dev.java,org.eclipse.osee.support.test.util,org.eclipse.osee.user.admin,org.eclipse.osee.vaadin,org.eclipse.osee.vaadin.example.ui,org.eclipse.osee.vaadin.themes,org.eclipse.osee.vaadin.widgets,org.eclipse.osee.x.server.application,org.json,org.jvnet.mimepull,org.jvnet.mimepull.source,org.mockito,org.mockito.source,org.mockito.test.example,org.objenesis,org.objenesis.source,org.postgresql.driver,org.xerial.sqlite,org.xerial.sqlite.source"/> +<stringAttribute key="featureDefaultLocation" value="workspace"/> +<stringAttribute key="featurePluginResolution" value="workspace"/> +<booleanAttribute key="includeOptional" value="true"/> +<stringAttribute key="location" value="${workspace_loc}/../junit-workspace"/> +<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS"> +<listEntry value="/org.eclipse.osee.framework.dev.help.ui.test/src/org/eclipse/osee/framework/dev/help/ui/DevHelpUiTestSuite.java"/> +</listAttribute> +<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES"> +<listEntry value="1"/> +</listAttribute> +<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value=""/> +<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/> +<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/> +<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit4"/> +<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.eclipse.osee.framework.dev.help.ui.DevHelpUiTestSuite"/> +<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-os ${target.os} -ws ${target.ws} -arch ${target.arch} -nl ${target.nl} -consoleLog"/> +<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="org.eclipse.osee.framework.dev.help.ui.test"/> +<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.pde.ui.workbenchClasspathProvider"/> +<stringAttribute key="pde.version" value="3.3"/> +<stringAttribute key="product" value="org.eclipse.osee.framework.ui.product.osee"/> +<booleanAttribute key="run_in_ui_thread" value="false"/> +<setAttribute key="selected_features"> +<setEntry value="org.eclipse.osee.core.feature:default"/> +<setEntry value="org.eclipse.osee.core.plugin.feature:default"/> +<setEntry value="org.eclipse.osee.core.runtime.feature:default"/> +<setEntry value="org.eclipse.osee.core.ui.feature:default"/> +</setAttribute> +<booleanAttribute key="show_selected_only" value="true"/> +<stringAttribute key="templateConfig" value="${target_home}\configuration\config.ini"/> +<booleanAttribute key="tracing" value="false"/> +<booleanAttribute key="useCustomFeatures" value="true"/> +<booleanAttribute key="useDefaultConfig" value="true"/> +<booleanAttribute key="useDefaultConfigArea" value="false"/> +<booleanAttribute key="useProduct" value="false"/> +</launchConfiguration> diff --git a/plugins/org.eclipse.osee.framework.dev.help.ui.test/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.framework.dev.help.ui.test/META-INF/MANIFEST.MF new file mode 100644 index 00000000000..b234ee49b7c --- /dev/null +++ b/plugins/org.eclipse.osee.framework.dev.help.ui.test/META-INF/MANIFEST.MF @@ -0,0 +1,12 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: OSEE Framework Dev Help UI Test (Incubation) +Bundle-SymbolicName: org.eclipse.osee.framework.dev.help.ui.test +Bundle-Version: 0.11.0.qualifier +Bundle-Vendor: Eclipse Open System Engineering Environment +Fragment-Host: org.eclipse.osee.framework.dev.help.ui +Bundle-RequiredExecutionEnvironment: JavaSE-1.6 +Require-Bundle: org.junit +Import-Package: org.eclipse.core.runtime;version="3.4.0", + org.eclipse.osee.framework.jdk.core.util, + org.osgi.framework diff --git a/plugins/org.eclipse.osee.framework.dev.help.ui.test/build.properties b/plugins/org.eclipse.osee.framework.dev.help.ui.test/build.properties new file mode 100644 index 00000000000..1b243b1a937 --- /dev/null +++ b/plugins/org.eclipse.osee.framework.dev.help.ui.test/build.properties @@ -0,0 +1,5 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + . +additional.bundles = org.eclipse.osee.framework.jdk.core diff --git a/plugins/org.eclipse.osee.framework.dev.help.ui.test/pom.xml b/plugins/org.eclipse.osee.framework.dev.help.ui.test/pom.xml new file mode 100644 index 00000000000..b02cfdbb1b0 --- /dev/null +++ b/plugins/org.eclipse.osee.framework.dev.help.ui.test/pom.xml @@ -0,0 +1,30 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>org.eclipse.osee</groupId> + <artifactId>org.eclipse.osee.client.parent</artifactId> + <version>0.11.0-SNAPSHOT</version> + <relativePath>../../plugins/org.eclipse.osee.client.parent</relativePath> + </parent> + + <artifactId>org.eclipse.osee.framework.dev.help.ui.test</artifactId> + <packaging>eclipse-test-plugin</packaging> + <name>OSEE Framework Dev Help UI Test - (Incubation)</name> + + <build> + <plugins> + <plugin> + <groupId>org.eclipse.tycho</groupId> + <artifactId>tycho-surefire-plugin</artifactId> + <version>${tycho-version}</version> + <configuration> + <testSuite>org.eclipse.osee.framework.dev.help.ui.test</testSuite> + <testClass>org.eclipse.osee.framework.dev.help.ui.DevHelpUiTestSuite</testClass> + </configuration> + </plugin> + </plugins> + </build> +</project>
\ No newline at end of file diff --git a/plugins/org.eclipse.osee.framework.dev.help.ui.test/src/org/eclipse/osee/framework/dev/help/ui/DevHelpUiTestSuite.java b/plugins/org.eclipse.osee.framework.dev.help.ui.test/src/org/eclipse/osee/framework/dev/help/ui/DevHelpUiTestSuite.java new file mode 100644 index 00000000000..92198f96215 --- /dev/null +++ b/plugins/org.eclipse.osee.framework.dev.help.ui.test/src/org/eclipse/osee/framework/dev/help/ui/DevHelpUiTestSuite.java @@ -0,0 +1,23 @@ +/******************************************************************************* + * Copyright (c) 2013 Boeing. + * 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: + * Boeing - initial API and implementation + *******************************************************************************/ +package org.eclipse.osee.framework.dev.help.ui; + +import org.junit.runner.RunWith; +import org.junit.runners.Suite; + +/** + * @author Angel Avila + */ +@RunWith(Suite.class) +@Suite.SuiteClasses({HelpTableOfContentTest.class}) +public class DevHelpUiTestSuite { + // Test Suite +} diff --git a/plugins/org.eclipse.osee.framework.dev.help.ui.test/src/org/eclipse/osee/framework/dev/help/ui/HelpTableOfContentTest.java b/plugins/org.eclipse.osee.framework.dev.help.ui.test/src/org/eclipse/osee/framework/dev/help/ui/HelpTableOfContentTest.java new file mode 100644 index 00000000000..a968f894aa1 --- /dev/null +++ b/plugins/org.eclipse.osee.framework.dev.help.ui.test/src/org/eclipse/osee/framework/dev/help/ui/HelpTableOfContentTest.java @@ -0,0 +1,60 @@ +/******************************************************************************* + * Copyright (c) 2013 Boeing. + * 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: + * Boeing - initial API and implementation + *******************************************************************************/ +package org.eclipse.osee.framework.dev.help.ui; + +import static org.junit.Assert.assertNotNull; +import java.net.URL; +import java.util.Set; +import org.eclipse.osee.framework.dev.help.ui.util.HelpTestUtil; +import org.eclipse.osee.framework.dev.help.ui.util.HtmlParser; +import org.eclipse.osee.framework.dev.help.ui.util.TocParser; +import org.junit.BeforeClass; +import org.junit.Test; + +/** + * @author Angel Avila + */ +public class HelpTableOfContentTest { + + private static final String PLUGIN_ID = "org.eclipse.osee.framework.dev.help.ui"; + + private static TocParser parser; + + @BeforeClass + public static void setUp() throws Exception { + parser = new TocParser("toc.xml"); + parser.parse(); + } + + @Test + public void testAllTocReferencesExist() throws Exception { + for (String reference : parser.getEntries()) { + URL url = HelpTestUtil.getResource(reference); + assertNotNull(String.format("[%s] was not valid", reference), url); + } + } + + @Test + public void testTocReferencesValid() throws Exception { + HtmlParser htmlParser = new HtmlParser(PLUGIN_ID); + + for (String reference : parser.getEntries()) { + URL url = HelpTestUtil.getResource(reference); + + Set<String> entries = htmlParser.parse(url); + for (String resource : entries) { + URL referencedUrl = HelpTestUtil.getResource(reference); + assertNotNull(String.format("[%s] was not valid", resource), referencedUrl); + } + + } + } +} diff --git a/plugins/org.eclipse.osee.framework.dev.help.ui.test/src/org/eclipse/osee/framework/dev/help/ui/util/HelpTestUtil.java b/plugins/org.eclipse.osee.framework.dev.help.ui.test/src/org/eclipse/osee/framework/dev/help/ui/util/HelpTestUtil.java new file mode 100644 index 00000000000..59e1a62314f --- /dev/null +++ b/plugins/org.eclipse.osee.framework.dev.help.ui.test/src/org/eclipse/osee/framework/dev/help/ui/util/HelpTestUtil.java @@ -0,0 +1,43 @@ +/******************************************************************************* + * Copyright (c) 2013 Boeing. + * 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: + * Boeing - initial API and implementation + *******************************************************************************/ +package org.eclipse.osee.framework.dev.help.ui.util; + +import static junit.framework.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import java.io.File; +import java.net.URL; +import org.eclipse.core.runtime.FileLocator; +import org.osgi.framework.Bundle; +import org.osgi.framework.FrameworkUtil; + +/** + * @author Angel Avila + */ +public final class HelpTestUtil { + + private HelpTestUtil() { + // Utility Class + } + + public static URL getResource(String resource) throws Exception { + Bundle bundle = FrameworkUtil.getBundle(HelpTestUtil.class); + URL url = bundle.getResource(resource); + + assertNotNull(String.format("Resource not found: [%s]", resource), url); + + url = FileLocator.toFileURL(url); + File file = new File(url.toURI()); + assertEquals(String.format("[%s] does not exist", resource), true, file.exists()); + assertEquals(String.format("[%s] unreadable", resource), true, file.canRead()); + + return url; + } +} diff --git a/plugins/org.eclipse.osee.framework.dev.help.ui.test/src/org/eclipse/osee/framework/dev/help/ui/util/HtmlParser.java b/plugins/org.eclipse.osee.framework.dev.help.ui.test/src/org/eclipse/osee/framework/dev/help/ui/util/HtmlParser.java new file mode 100644 index 00000000000..5715f105c5c --- /dev/null +++ b/plugins/org.eclipse.osee.framework.dev.help.ui.test/src/org/eclipse/osee/framework/dev/help/ui/util/HtmlParser.java @@ -0,0 +1,117 @@ +/******************************************************************************* + * Copyright (c) 2013 Boeing. + * 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: + * Boeing - initial API and implementation + *******************************************************************************/ +package org.eclipse.osee.framework.dev.help.ui.util; + +import java.io.BufferedInputStream; +import java.io.InputStream; +import java.net.URL; +import java.util.HashSet; +import java.util.Set; +import javax.xml.stream.XMLInputFactory; +import javax.xml.stream.XMLStreamConstants; +import javax.xml.stream.XMLStreamReader; +import org.eclipse.osee.framework.jdk.core.util.Lib; +import org.eclipse.osee.framework.jdk.core.util.Strings; + +/** + * @author Angel Avila + */ +public class HtmlParser { + + private static final XMLInputFactory xmlInputFactory = XMLInputFactory.newFactory(); + + private static final String LINK_NODE = "link"; + private static final String HREF_TAG = "href"; + private static final String SRC_TAG = "src"; + + private final String pathHint; + + public HtmlParser(String pathHint) { + this.pathHint = pathHint; + } + + private String getPath(String fullPath) { + StringBuilder builder = new StringBuilder(); + + String[] parts = fullPath.split("/"); + boolean found = false; + for (String part : parts) { + if (found && !part.endsWith(".html")) { + builder.append(part); + builder.append("/"); + } + if (pathHint.equals(part)) { + found = true; + } + } + return builder.toString(); + } + + public Set<String> parse(URL url) throws Exception { + Set<String> entries = new HashSet<String>(); + entries.clear(); + + String pathPrefix = getPath(url.toString()); + + InputStream inputStream = null; + try { + inputStream = new BufferedInputStream(url.openStream()); + XMLStreamReader streamReader = xmlInputFactory.createXMLStreamReader(inputStream); + while (streamReader.hasNext()) { + process(streamReader, pathPrefix, entries); + streamReader.next(); + } + + } finally { + Lib.close(inputStream); + } + + return entries; + } + + private void process(XMLStreamReader reader, String pathPrefix, Set<String> entries) { + int eventType = reader.getEventType(); + switch (eventType) { + case XMLStreamConstants.START_ELEMENT: + String localName = reader.getLocalName(); + for (int index = 0; index < reader.getAttributeCount(); index++) { + + String attributeName = reader.getAttributeLocalName(index); + String value = reader.getAttributeValue(index); + + if (Strings.isValid(value)) { + if (!LINK_NODE.equals(localName)) { + if (HREF_TAG.equals(attributeName) || SRC_TAG.equals(attributeName)) { + processResource(pathPrefix, entries, value); + } + } + } + } + break; + } + } + + private void processResource(String pathPrefix, Set<String> references, String value) { + if (!isExternalLink(value)) { + String reference = normalizePath(pathPrefix, value); + references.add(reference); + } + } + + private String normalizePath(String pathPrefix, String reference) { + String path = reference.replaceAll("\\.html#.*", ".html"); + return String.format("%s%s", pathPrefix, path); + } + + private boolean isExternalLink(String resource) { + return resource.contains("://"); + } +} diff --git a/plugins/org.eclipse.osee.framework.dev.help.ui.test/src/org/eclipse/osee/framework/dev/help/ui/util/TocParser.java b/plugins/org.eclipse.osee.framework.dev.help.ui.test/src/org/eclipse/osee/framework/dev/help/ui/util/TocParser.java new file mode 100644 index 00000000000..688fb20d7e8 --- /dev/null +++ b/plugins/org.eclipse.osee.framework.dev.help.ui.test/src/org/eclipse/osee/framework/dev/help/ui/util/TocParser.java @@ -0,0 +1,103 @@ +/******************************************************************************* + * Copyright (c) 2013 Boeing. + * 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: + * Boeing - initial API and implementation + *******************************************************************************/ +package org.eclipse.osee.framework.dev.help.ui.util; + +import java.io.BufferedInputStream; +import java.io.InputStream; +import java.net.URL; +import java.util.HashSet; +import java.util.Set; +import javax.xml.stream.XMLInputFactory; +import javax.xml.stream.XMLStreamConstants; +import javax.xml.stream.XMLStreamReader; +import org.eclipse.osee.framework.jdk.core.util.Lib; +import org.eclipse.osee.framework.jdk.core.util.Strings; + +/** + * @author Angel Avila + */ +public class TocParser { + + private static final XMLInputFactory xmlInputFactory = XMLInputFactory.newFactory(); + + private static final String TOC = "toc"; + private static final String TOPIC = "topic"; + private static final String HREF = "href"; + + public Set<String> entries = new HashSet<String>(); + public String path; + + private String localName; + private String uri; + + public TocParser(String path) { + this.path = path; + } + + public void parse() throws Exception { + entries.clear(); + URL url = HelpTestUtil.getResource(path); + + InputStream inputStream = null; + try { + inputStream = new BufferedInputStream(url.openStream()); + XMLStreamReader streamReader = xmlInputFactory.createXMLStreamReader(inputStream); + while (streamReader.hasNext()) { + process(streamReader); + streamReader.next(); + } + + } finally { + Lib.close(inputStream); + } + } + + private void process(XMLStreamReader reader) { + int eventType = reader.getEventType(); + switch (eventType) { + case XMLStreamConstants.START_ELEMENT: + localName = reader.getLocalName(); + uri = reader.getNamespaceURI(); + if (TOC.equals(localName)) { + processReference(reader, TOPIC); + } else if (TOPIC.equals(localName)) { + processReference(reader, HREF); + } + break; + case XMLStreamConstants.END_ELEMENT: + localName = reader.getLocalName(); + uri = reader.getNamespaceURI(); + reset(); + break; + } + } + + private void processReference(XMLStreamReader reader, String tag) { + String reference = reader.getAttributeValue(uri, tag); + if (Strings.isValid(reference)) { + String path = normalizePath(reference); + entries.add(path); + } + } + + private String normalizePath(String reference) { + return reference.replaceAll("\\.html#.*", ".html"); + } + + private void reset() { + localName = null; + uri = null; + } + + public Set<String> getEntries() { + return entries; + } +} diff --git a/plugins/org.eclipse.osee.framework.help.ui.test/.classpath b/plugins/org.eclipse.osee.framework.help.ui.test/.classpath new file mode 100644 index 00000000000..ad32c83a788 --- /dev/null +++ b/plugins/org.eclipse.osee.framework.help.ui.test/.classpath @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?> +<classpath> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/> + <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> + <classpathentry kind="src" path="src"/> + <classpathentry kind="output" path="bin"/> +</classpath> diff --git a/plugins/org.eclipse.osee.framework.help.ui.test/.project b/plugins/org.eclipse.osee.framework.help.ui.test/.project new file mode 100644 index 00000000000..9422d3e978c --- /dev/null +++ b/plugins/org.eclipse.osee.framework.help.ui.test/.project @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>org.eclipse.osee.framework.help.ui.test</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + <buildCommand> + <name>org.eclipse.jdt.core.javabuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.ManifestBuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.SchemaBuilder</name> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>org.eclipse.pde.PluginNature</nature> + <nature>org.eclipse.jdt.core.javanature</nature> + </natures> +</projectDescription> diff --git a/plugins/org.eclipse.osee.framework.help.ui.test/HelpUi_TestSuite.launch b/plugins/org.eclipse.osee.framework.help.ui.test/HelpUi_TestSuite.launch new file mode 100644 index 00000000000..927d11fe6d6 --- /dev/null +++ b/plugins/org.eclipse.osee.framework.help.ui.test/HelpUi_TestSuite.launch @@ -0,0 +1,54 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<launchConfiguration type="org.eclipse.pde.ui.JunitLaunchConfig"> +<setAttribute key="additional_plugins"> +<setEntry value="org.eclipse.osee.framework.help.ui:0.11.0.qualifier:default:true"/> +</setAttribute> +<booleanAttribute key="append.args" value="true"/> +<stringAttribute key="application" value="org.eclipse.pde.junit.runtime.coretestapplication"/> +<booleanAttribute key="askclear" value="false"/> +<booleanAttribute key="automaticAdd" value="true"/> +<booleanAttribute key="automaticValidate" value="true"/> +<stringAttribute key="bootstrap" value=""/> +<stringAttribute key="checked" value="[NONE]"/> +<booleanAttribute key="clearConfig" value="true"/> +<booleanAttribute key="clearws" value="true"/> +<booleanAttribute key="clearwslog" value="false"/> +<stringAttribute key="configLocation" value="${workspace_loc}/.metadata/.plugins/org.eclipse.pde.core/pde-junit"/> +<booleanAttribute key="default" value="false"/> +<booleanAttribute key="default_auto_start" value="true"/> +<stringAttribute key="deselected_workspace_plugins" value="ah6.ats.config.common,ats.config.common,com.boeing.ote.cdb.diff,com.hazelcast,com.hazelcast.source,com.sun.jersey,com.sun.jersey.client.apache,com.sun.jersey.client.apache.source,com.sun.jersey.source,com.vaadin,javax.ws.rs,javax.ws.rs.source,jms.activemq.launch,jms.libraries,lba.ats.config.common,lba.ats.config.common.test,lba.ats.config.osee,lba.ats.config.osee.test,lba.ats.help.ui,lba.authentication.provider,lba.db.connection,lba.define,lba.define.help.ui,lba.define.test,lba.framework.help.ui,lba.framework.ui.skynet,lba.framework.ui.skynet.test,lba.help,lba.myII.tc,lba.osee.client.integration.tests,lba.osee.coverage,lba.osee.x.server.customizations,lba.ote.client,lba.ote.client.ui,lba.ote.cnf.dsl,lba.ote.cnf.dsl.ui,lba.ote.commands,lba.ote.help.ui,lba.ote.launchTest,lba.ote.message.support,lba.ote.outfile.conversion,lba.ote.outfile.conversion.app,lba.ote.outfile.conversion.test,lba.ote.projectsets.three.four,lba.ote.result.upload,lba.ote.test.manager,lba.ote.test.manager.ofp,lba.ote.ui.test.manager,lba.ote.workspace.ui,lba.rdt.core,lba.rdt.core.test,lba.rdt.service,lba.rdt.service.osee,lba.rdt.ui,lba.rdt.ui.test,lba.server.station.config,lba.server.station.config.test,lba.start,lba.tools.road.map,lba.tte,lba.tte.test,lba.utility.count,lba.utility.external.editor,lba.utility.ui.count,mysql.driver.ext,net.jini,net.sf.ehcache,net.sf.ehcache.source,oracle.driver,org.boeing.count,org.eclipse.osee.ats,org.eclipse.osee.ats.api,org.eclipse.osee.ats.client.demo,org.eclipse.osee.ats.client.integration.tests,org.eclipse.osee.ats.core,org.eclipse.osee.ats.core.client,org.eclipse.osee.ats.core.client.test,org.eclipse.osee.ats.core.test,org.eclipse.osee.ats.dsl,org.eclipse.osee.ats.dsl.ui,org.eclipse.osee.ats.help.ui,org.eclipse.osee.ats.impl,org.eclipse.osee.ats.impl.test,org.eclipse.osee.ats.mocks,org.eclipse.osee.ats.presenter,org.eclipse.osee.ats.presenter.mock,org.eclipse.osee.ats.presenter.test,org.eclipse.osee.ats.reports,org.eclipse.osee.ats.reports.burndown,org.eclipse.osee.ats.reports.efficiency,org.eclipse.osee.ats.reports.split,org.eclipse.osee.ats.ui.api,org.eclipse.osee.ats.view.web,org.eclipse.osee.ats.view.web.test,org.eclipse.osee.authentication,org.eclipse.osee.authorization,org.eclipse.osee.client.demo,org.eclipse.osee.client.integration.tests,org.eclipse.osee.client.test.framework,org.eclipse.osee.cluster,org.eclipse.osee.cluster.hazelcast,org.eclipse.osee.cluster.rest,org.eclipse.osee.console.admin,org.eclipse.osee.console.admin.test,org.eclipse.osee.coverage,org.eclipse.osee.coverage.demo,org.eclipse.osee.coverage.help.ui,org.eclipse.osee.coverage.integration.tests,org.eclipse.osee.coverage.test,org.eclipse.osee.database,org.eclipse.osee.database.schema,org.eclipse.osee.define,org.eclipse.osee.define.test,org.eclipse.osee.display.api,org.eclipse.osee.display.mvp,org.eclipse.osee.display.mvp.test,org.eclipse.osee.display.presenter,org.eclipse.osee.display.presenter.mocks,org.eclipse.osee.display.presenter.test,org.eclipse.osee.display.view.web,org.eclipse.osee.distributed,org.eclipse.osee.event,org.eclipse.osee.event.monitor,org.eclipse.osee.event.osgi,org.eclipse.osee.executor.admin,org.eclipse.osee.executor.admin.test,org.eclipse.osee.framework.access,org.eclipse.osee.framework.access.provider,org.eclipse.osee.framework.access.test,org.eclipse.osee.framework.authentication.ldap.core,org.eclipse.osee.framework.branch.gantt,org.eclipse.osee.framework.core,org.eclipse.osee.framework.core.client,org.eclipse.osee.framework.core.dsl,org.eclipse.osee.framework.core.dsl.edit,org.eclipse.osee.framework.core.dsl.integration,org.eclipse.osee.framework.core.dsl.integration.test,org.eclipse.osee.framework.core.dsl.ui,org.eclipse.osee.framework.core.dsl.ui.integration,org.eclipse.osee.framework.core.dsl.ui.integration.test,org.eclipse.osee.framework.core.message,org.eclipse.osee.framework.core.message.test,org.eclipse.osee.framework.core.model,org.eclipse.osee.framework.core.model.test,org.eclipse.osee.framework.core.server,org.eclipse.osee.framework.core.server.test,org.eclipse.osee.framework.core.test,org.eclipse.osee.framework.database,org.eclipse.osee.framework.database.init,org.eclipse.osee.framework.database.test,org.eclipse.osee.framework.dev.help.ui,org.eclipse.osee.framework.h2,org.eclipse.osee.framework.help.ui,org.eclipse.osee.framework.help.ui.test,org.eclipse.osee.framework.jdk.core,org.eclipse.osee.framework.jdk.core.test,org.eclipse.osee.framework.jini,org.eclipse.osee.framework.lifecycle,org.eclipse.osee.framework.lifecycle.test,org.eclipse.osee.framework.logging,org.eclipse.osee.framework.logging.test,org.eclipse.osee.framework.manager.servlet,org.eclipse.osee.framework.messaging,org.eclipse.osee.framework.messaging.event.res,org.eclipse.osee.framework.messaging.event.res.test,org.eclipse.osee.framework.messaging.test,org.eclipse.osee.framework.plugin.core,org.eclipse.osee.framework.resource.management,org.eclipse.osee.framework.resource.management.test,org.eclipse.osee.framework.skynet.core,org.eclipse.osee.framework.skynet.core.test,org.eclipse.osee.framework.templates,org.eclipse.osee.framework.ui.admin,org.eclipse.osee.framework.ui.branch.graph,org.eclipse.osee.framework.ui.data.model.editor,org.eclipse.osee.framework.ui.plugin,org.eclipse.osee.framework.ui.product,org.eclipse.osee.framework.ui.skynet,org.eclipse.osee.framework.ui.skynet.test,org.eclipse.osee.framework.ui.swt,org.eclipse.osee.framework.ui.workspacebundleloader,org.eclipse.osee.framework.ui.ws,org.eclipse.osee.logback.config,org.eclipse.osee.logger,org.eclipse.osee.logger.slf4j,org.eclipse.osee.mail,org.eclipse.osee.mail.rest,org.eclipse.osee.mail.test,org.eclipse.osee.mvp.example,org.eclipse.osee.mvp.example.api,org.eclipse.osee.mvp.example.presenter,org.eclipse.osee.mvp.example.view,org.eclipse.osee.orcs,org.eclipse.osee.orcs.core,org.eclipse.osee.orcs.core.test,org.eclipse.osee.orcs.db,org.eclipse.osee.orcs.db.mock,org.eclipse.osee.orcs.db.test,org.eclipse.osee.orcs.rest,org.eclipse.osee.orcs.rest.client,org.eclipse.osee.orcs.rest.model,org.eclipse.osee.orcs.rest.test,org.eclipse.osee.orcs.test,org.eclipse.osee.ote.client,org.eclipse.osee.ote.client.msg,org.eclipse.osee.ote.connection.jini,org.eclipse.osee.ote.connection.service,org.eclipse.osee.ote.connection.service.test,org.eclipse.osee.ote.container,org.eclipse.osee.ote.core,org.eclipse.osee.ote.core.test,org.eclipse.osee.ote.define,org.eclipse.osee.ote.help.ui,org.eclipse.osee.ote.jms,org.eclipse.osee.ote.message,org.eclipse.osee.ote.message.test,org.eclipse.osee.ote.messaging.dds,org.eclipse.osee.ote.model.manager,org.eclipse.osee.ote.runtimeManager,org.eclipse.osee.ote.server,org.eclipse.osee.ote.ui,org.eclipse.osee.ote.ui.define,org.eclipse.osee.ote.ui.markers,org.eclipse.osee.ote.ui.output,org.eclipse.osee.ote.ui.test.manager,org.eclipse.osee.ote.ui.test.output,org.eclipse.osee.ote.version,org.eclipse.osee.ote.version.git,org.eclipse.osee.ote.version.git.test,org.eclipse.osee.ote.version.svn,org.eclipse.osee.rest.admin,org.eclipse.osee.rest.test.client,org.eclipse.osee.rest.test.model,org.eclipse.osee.rest.test.server,org.eclipse.osee.sos,org.eclipse.osee.support.dev.java,org.eclipse.osee.support.test.util,org.eclipse.osee.user.admin,org.eclipse.osee.vaadin,org.eclipse.osee.vaadin.example.ui,org.eclipse.osee.vaadin.themes,org.eclipse.osee.vaadin.widgets,org.eclipse.osee.x.server.application,org.json,org.jvnet.mimepull,org.jvnet.mimepull.source,org.mockito,org.mockito.source,org.mockito.test.example,org.objenesis,org.objenesis.source,org.postgresql.driver,org.xerial.sqlite,org.xerial.sqlite.source"/> +<stringAttribute key="featureDefaultLocation" value="workspace"/> +<stringAttribute key="featurePluginResolution" value="workspace"/> +<booleanAttribute key="includeOptional" value="true"/> +<stringAttribute key="location" value="${workspace_loc}/../junit-workspace"/> +<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS"> +<listEntry value="/org.eclipse.osee.framework.help.ui.test/src/org/eclipse/osee/framework/help/ui/HelpUiTestSuite.java"/> +</listAttribute> +<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES"> +<listEntry value="1"/> +</listAttribute> +<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value=""/> +<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/> +<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/> +<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit4"/> +<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.eclipse.osee.framework.help.ui.HelpUiTestSuite"/> +<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-os ${target.os} -ws ${target.ws} -arch ${target.arch} -nl ${target.nl} -consoleLog"/> +<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="org.eclipse.osee.framework.help.ui.test"/> +<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.pde.ui.workbenchClasspathProvider"/> +<stringAttribute key="pde.version" value="3.3"/> +<stringAttribute key="product" value="org.eclipse.osee.framework.ui.product.osee"/> +<booleanAttribute key="run_in_ui_thread" value="false"/> +<setAttribute key="selected_features"> +<setEntry value="org.eclipse.osee.core.feature:default"/> +<setEntry value="org.eclipse.osee.core.plugin.feature:default"/> +<setEntry value="org.eclipse.osee.core.runtime.feature:default"/> +<setEntry value="org.eclipse.osee.core.ui.feature:default"/> +</setAttribute> +<booleanAttribute key="show_selected_only" value="true"/> +<stringAttribute key="templateConfig" value="${target_home}\configuration\config.ini"/> +<booleanAttribute key="tracing" value="false"/> +<booleanAttribute key="useCustomFeatures" value="true"/> +<booleanAttribute key="useDefaultConfig" value="true"/> +<booleanAttribute key="useDefaultConfigArea" value="false"/> +<booleanAttribute key="useProduct" value="false"/> +</launchConfiguration> diff --git a/plugins/org.eclipse.osee.framework.help.ui.test/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.framework.help.ui.test/META-INF/MANIFEST.MF new file mode 100644 index 00000000000..b4b7d1e1cee --- /dev/null +++ b/plugins/org.eclipse.osee.framework.help.ui.test/META-INF/MANIFEST.MF @@ -0,0 +1,12 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: OSEE Framework Help UI Test (Incubation) +Bundle-SymbolicName: org.eclipse.osee.framework.help.ui.test +Bundle-Version: 0.11.0.qualifier +Bundle-Vendor: Eclipse Open System Engineering Environment +Fragment-Host: org.eclipse.osee.framework.help.ui +Bundle-RequiredExecutionEnvironment: JavaSE-1.6 +Require-Bundle: org.junit +Import-Package: org.eclipse.core.runtime;version="3.4.0", + org.eclipse.osee.framework.jdk.core.util, + org.osgi.framework diff --git a/plugins/org.eclipse.osee.framework.help.ui.test/build.properties b/plugins/org.eclipse.osee.framework.help.ui.test/build.properties new file mode 100644 index 00000000000..1b243b1a937 --- /dev/null +++ b/plugins/org.eclipse.osee.framework.help.ui.test/build.properties @@ -0,0 +1,5 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + . +additional.bundles = org.eclipse.osee.framework.jdk.core diff --git a/plugins/org.eclipse.osee.framework.help.ui.test/pom.xml b/plugins/org.eclipse.osee.framework.help.ui.test/pom.xml new file mode 100644 index 00000000000..db61271531d --- /dev/null +++ b/plugins/org.eclipse.osee.framework.help.ui.test/pom.xml @@ -0,0 +1,30 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>org.eclipse.osee</groupId> + <artifactId>org.eclipse.osee.client.parent</artifactId> + <version>0.11.0-SNAPSHOT</version> + <relativePath>../../plugins/org.eclipse.osee.client.parent</relativePath> + </parent> + + <artifactId>org.eclipse.osee.framework.help.ui.test</artifactId> + <packaging>eclipse-test-plugin</packaging> + <name>OSEE Framework Help UI Test - (Incubation)</name> + + <build> + <plugins> + <plugin> + <groupId>org.eclipse.tycho</groupId> + <artifactId>tycho-surefire-plugin</artifactId> + <version>${tycho-version}</version> + <configuration> + <testSuite>org.eclipse.osee.framework.help.ui.test</testSuite> + <testClass>org.eclipse.osee.framework.help.ui.HelpUiTestSuite</testClass> + </configuration> + </plugin> + </plugins> + </build> +</project>
\ No newline at end of file diff --git a/plugins/org.eclipse.osee.framework.help.ui.test/src/org/eclipse/osee/framework/help/ui/HelpContextTest.java b/plugins/org.eclipse.osee.framework.help.ui.test/src/org/eclipse/osee/framework/help/ui/HelpContextTest.java new file mode 100644 index 00000000000..1edb580adb8 --- /dev/null +++ b/plugins/org.eclipse.osee.framework.help.ui.test/src/org/eclipse/osee/framework/help/ui/HelpContextTest.java @@ -0,0 +1,85 @@ +/******************************************************************************* + * Copyright (c) 2013 Boeing. + * 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: + * Boeing - initial API and implementation + *******************************************************************************/ +package org.eclipse.osee.framework.help.ui; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import java.lang.reflect.Field; +import java.net.URL; +import java.util.HashMap; +import java.util.Map; +import org.eclipse.osee.framework.help.ui.util.ContextParser; +import org.eclipse.osee.framework.help.ui.util.HelpTestUtil; +import org.eclipse.osee.framework.help.ui.util.ContextParser.ContextEntry; +import org.eclipse.osee.framework.jdk.core.util.Compare; +import org.eclipse.osee.framework.ui.plugin.util.HelpContext; +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.Test; + +/** + * @author Angel Avila + */ +public class HelpContextTest { + + private static final String PLUGIN_ID = "org.eclipse.osee.framework.help.ui"; + + private static Map<String, HelpContext> contexts; + private static ContextParser parser; + + @BeforeClass + public static void setUp() throws Exception { + contexts = getContexts(OseeHelpContext.class); + parser = new ContextParser("contexts/contexts.xml"); + parser.parse(); + } + + @Test + public void testAdd() throws Exception { + assertEquals(24, contexts.size()); + } + + @Test + public void testContextsXml() throws Exception { + assertEquals(contexts.size(), parser.getEntries().size()); + + Assert.assertFalse(Compare.isDifferent(contexts.keySet(), parser.getIds())); + for (HelpContext context : contexts.values()) { + assertEquals(PLUGIN_ID, context.getPluginId()); + + String id = context.getName(); + ContextEntry entry = parser.getEntry(id); + assertNotNull(entry); + } + } + + @Test + public void testHrefFiles() throws Exception { + for (ContextEntry entry : parser.getEntries()) { + for (String reference : entry.getReferences()) { + URL url = HelpTestUtil.getResource(reference); + assertNotNull(String.format("[%s] was not valid", reference), url); + } + } + } + + private static Map<String, HelpContext> getContexts(Class<?> clazz) throws IllegalArgumentException, IllegalAccessException { + Map<String, HelpContext> contexts = new HashMap<String, HelpContext>(); + for (Field field : clazz.getFields()) { + Object object = field.get(null); + if (object instanceof HelpContext) { + HelpContext context = (HelpContext) object; + contexts.put(context.getName(), context); + } + } + return contexts; + } +} diff --git a/plugins/org.eclipse.osee.framework.help.ui.test/src/org/eclipse/osee/framework/help/ui/HelpTableOfContentTest.java b/plugins/org.eclipse.osee.framework.help.ui.test/src/org/eclipse/osee/framework/help/ui/HelpTableOfContentTest.java new file mode 100644 index 00000000000..7fce639d7fa --- /dev/null +++ b/plugins/org.eclipse.osee.framework.help.ui.test/src/org/eclipse/osee/framework/help/ui/HelpTableOfContentTest.java @@ -0,0 +1,61 @@ +/******************************************************************************* + * Copyright (c) 2013 Boeing. + * 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: + * Boeing - initial API and implementation + *******************************************************************************/ +package org.eclipse.osee.framework.help.ui; + +import static org.junit.Assert.assertNotNull; +import java.net.URL; +import java.util.Set; +import org.eclipse.osee.framework.help.ui.util.HelpTestUtil; +import org.eclipse.osee.framework.help.ui.util.HtmlParser; +import org.eclipse.osee.framework.help.ui.util.TocParser; +import org.junit.BeforeClass; +import org.junit.Test; + +/** + * @author Angel Avila + */ +public class HelpTableOfContentTest { + + private static final String PLUGIN_ID = "org.eclipse.osee.framework.help.ui"; + + private static TocParser parser; + + @BeforeClass + public static void setUp() throws Exception { + parser = new TocParser("toc.xml"); + parser.parse(); + } + + @Test + public void testAllTocReferencesExist() throws Exception { + for (String reference : parser.getEntries()) { + URL url = HelpTestUtil.getResource(reference); + assertNotNull(String.format("[%s] was not valid", reference), url); + } + } + + @Test + public void testTocReferencesValid() throws Exception { + HtmlParser htmlParser = new HtmlParser(PLUGIN_ID); + + for (String reference : parser.getEntries()) { + URL url = HelpTestUtil.getResource(reference); + + Set<String> entries = htmlParser.parse(url); + for (String resource : entries) { + URL referencedUrl = HelpTestUtil.getResource(reference); + assertNotNull(String.format("[%s] was not valid", resource), referencedUrl); + } + + } + } + +} diff --git a/plugins/org.eclipse.osee.framework.help.ui.test/src/org/eclipse/osee/framework/help/ui/HelpUiTestSuite.java b/plugins/org.eclipse.osee.framework.help.ui.test/src/org/eclipse/osee/framework/help/ui/HelpUiTestSuite.java new file mode 100644 index 00000000000..c28b7998764 --- /dev/null +++ b/plugins/org.eclipse.osee.framework.help.ui.test/src/org/eclipse/osee/framework/help/ui/HelpUiTestSuite.java @@ -0,0 +1,23 @@ +/******************************************************************************* + * Copyright (c) 2013 Boeing. + * 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: + * Boeing - initial API and implementation + *******************************************************************************/ +package org.eclipse.osee.framework.help.ui; + +import org.junit.runner.RunWith; +import org.junit.runners.Suite; + +/** + * @author Angel Avila + */ +@RunWith(Suite.class) +@Suite.SuiteClasses({HelpTableOfContentTest.class, HelpTableOfContentTest.class}) +public class HelpUiTestSuite { + // Test Suite +} diff --git a/plugins/org.eclipse.osee.framework.help.ui.test/src/org/eclipse/osee/framework/help/ui/util/ContextParser.java b/plugins/org.eclipse.osee.framework.help.ui.test/src/org/eclipse/osee/framework/help/ui/util/ContextParser.java new file mode 100644 index 00000000000..37b205854e2 --- /dev/null +++ b/plugins/org.eclipse.osee.framework.help.ui.test/src/org/eclipse/osee/framework/help/ui/util/ContextParser.java @@ -0,0 +1,141 @@ +/******************************************************************************* + * Copyright (c) 2013 Boeing. + * 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: + * Boeing - initial API and implementation + *******************************************************************************/ +package org.eclipse.osee.framework.help.ui.util; + +import java.io.BufferedInputStream; +import java.io.InputStream; +import java.net.URL; +import java.util.Collection; +import java.util.HashMap; +import java.util.LinkedHashSet; +import java.util.Map; +import java.util.Set; +import javax.xml.stream.XMLInputFactory; +import javax.xml.stream.XMLStreamConstants; +import javax.xml.stream.XMLStreamReader; +import org.eclipse.osee.framework.jdk.core.util.Lib; +import org.eclipse.osee.framework.jdk.core.util.Strings; + +/** + * @author Angel Avila + */ +public class ContextParser { + + private static final XMLInputFactory xmlInputFactory = XMLInputFactory.newFactory(); + + private static final String CONTEXT = "context"; + private static final String TOPIC = "topic"; + private static final String HREF = "href"; + private static final String ID_TAG = "id"; + + public Map<String, ContextEntry> entries = new HashMap<String, ContextEntry>(); + public String path; + + private String localName; + private String uri; + private ContextEntry currentEntry; + + public ContextParser(String path) { + this.path = path; + } + + public void parse() throws Exception { + entries.clear(); + URL url = HelpTestUtil.getResource(path); + + InputStream inputStream = null; + try { + inputStream = new BufferedInputStream(url.openStream()); + XMLStreamReader streamReader = xmlInputFactory.createXMLStreamReader(inputStream); + while (streamReader.hasNext()) { + process(streamReader); + streamReader.next(); + } + + } finally { + Lib.close(inputStream); + } + } + + private void process(XMLStreamReader reader) { + int eventType = reader.getEventType(); + switch (eventType) { + case XMLStreamConstants.START_ELEMENT: + localName = reader.getLocalName(); + uri = reader.getNamespaceURI(); + if (CONTEXT.equals(localName)) { + + String id = reader.getAttributeValue(uri, ID_TAG); + if (Strings.isValid(id)) { + currentEntry = new ContextEntry(id); + } + + } else if (TOPIC.equals(localName) && currentEntry != null) { + String reference = reader.getAttributeValue(uri, HREF); + if (Strings.isValid(reference)) { + String path = normalizePath(reference); + currentEntry.getReferences().add(path); + } + } + break; + case XMLStreamConstants.END_ELEMENT: + localName = reader.getLocalName(); + uri = reader.getNamespaceURI(); + if (CONTEXT.equals(localName) && currentEntry != null) { + entries.put(currentEntry.getId(), currentEntry); + reset(); + } + break; + } + } + + private String normalizePath(String reference) { + return reference.replaceAll("\\.html#.*", ".html"); + } + + private void reset() { + localName = null; + uri = null; + currentEntry = null; + } + + public Collection<ContextEntry> getEntries() { + return entries.values(); + } + + public ContextEntry getEntry(String id) { + return entries.get(id); + } + + public Set<String> getIds() { + return entries.keySet(); + } + + public final class ContextEntry { + private final String id; + private final Set<String> references = new LinkedHashSet<String>(); + + public ContextEntry(String id) { + super(); + this.id = id; + } + + public String getId() { + return id; + } + + public Set<String> getReferences() { + return references; + } + + } + +} diff --git a/plugins/org.eclipse.osee.framework.help.ui.test/src/org/eclipse/osee/framework/help/ui/util/HelpTestUtil.java b/plugins/org.eclipse.osee.framework.help.ui.test/src/org/eclipse/osee/framework/help/ui/util/HelpTestUtil.java new file mode 100644 index 00000000000..42ce38c0e9b --- /dev/null +++ b/plugins/org.eclipse.osee.framework.help.ui.test/src/org/eclipse/osee/framework/help/ui/util/HelpTestUtil.java @@ -0,0 +1,43 @@ +/******************************************************************************* + * Copyright (c) 2013 Boeing. + * 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: + * Boeing - initial API and implementation + *******************************************************************************/ +package org.eclipse.osee.framework.help.ui.util; + +import static junit.framework.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import java.io.File; +import java.net.URL; +import org.eclipse.core.runtime.FileLocator; +import org.osgi.framework.Bundle; +import org.osgi.framework.FrameworkUtil; + +/** + * @author Angel Avila + */ +public final class HelpTestUtil { + + private HelpTestUtil() { + // Utility Class + } + + public static URL getResource(String resource) throws Exception { + Bundle bundle = FrameworkUtil.getBundle(HelpTestUtil.class); + URL url = bundle.getResource(resource); + + assertNotNull(String.format("Resource not found: [%s]", resource), url); + + url = FileLocator.toFileURL(url); + File file = new File(url.toURI()); + assertEquals(String.format("[%s] does not exist", resource), true, file.exists()); + assertEquals(String.format("[%s] unreadable", resource), true, file.canRead()); + + return url; + } +} diff --git a/plugins/org.eclipse.osee.framework.help.ui.test/src/org/eclipse/osee/framework/help/ui/util/HtmlParser.java b/plugins/org.eclipse.osee.framework.help.ui.test/src/org/eclipse/osee/framework/help/ui/util/HtmlParser.java new file mode 100644 index 00000000000..8f431a79aaf --- /dev/null +++ b/plugins/org.eclipse.osee.framework.help.ui.test/src/org/eclipse/osee/framework/help/ui/util/HtmlParser.java @@ -0,0 +1,117 @@ +/******************************************************************************* + * Copyright (c) 2013 Boeing. + * 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: + * Boeing - initial API and implementation + *******************************************************************************/ +package org.eclipse.osee.framework.help.ui.util; + +import java.io.BufferedInputStream; +import java.io.InputStream; +import java.net.URL; +import java.util.HashSet; +import java.util.Set; +import javax.xml.stream.XMLInputFactory; +import javax.xml.stream.XMLStreamConstants; +import javax.xml.stream.XMLStreamReader; +import org.eclipse.osee.framework.jdk.core.util.Lib; +import org.eclipse.osee.framework.jdk.core.util.Strings; + +/** + * @author Angel Avila + */ +public class HtmlParser { + + private static final XMLInputFactory xmlInputFactory = XMLInputFactory.newFactory(); + + private static final String LINK_NODE = "link"; + private static final String HREF_TAG = "href"; + private static final String SRC_TAG = "src"; + + private final String pathHint; + + public HtmlParser(String pathHint) { + this.pathHint = pathHint; + } + + private String getPath(String fullPath) { + StringBuilder builder = new StringBuilder(); + + String[] parts = fullPath.split("/"); + boolean found = false; + for (String part : parts) { + if (found && !part.endsWith(".html")) { + builder.append(part); + builder.append("/"); + } + if (pathHint.equals(part)) { + found = true; + } + } + return builder.toString(); + } + + public Set<String> parse(URL url) throws Exception { + Set<String> entries = new HashSet<String>(); + entries.clear(); + + String pathPrefix = getPath(url.toString()); + + InputStream inputStream = null; + try { + inputStream = new BufferedInputStream(url.openStream()); + XMLStreamReader streamReader = xmlInputFactory.createXMLStreamReader(inputStream); + while (streamReader.hasNext()) { + process(streamReader, pathPrefix, entries); + streamReader.next(); + } + + } finally { + Lib.close(inputStream); + } + + return entries; + } + + private void process(XMLStreamReader reader, String pathPrefix, Set<String> entries) { + int eventType = reader.getEventType(); + switch (eventType) { + case XMLStreamConstants.START_ELEMENT: + String localName = reader.getLocalName(); + for (int index = 0; index < reader.getAttributeCount(); index++) { + + String attributeName = reader.getAttributeLocalName(index); + String value = reader.getAttributeValue(index); + + if (Strings.isValid(value)) { + if (!LINK_NODE.equals(localName)) { + if (HREF_TAG.equals(attributeName) || SRC_TAG.equals(attributeName)) { + processResource(pathPrefix, entries, value); + } + } + } + } + break; + } + } + + private void processResource(String pathPrefix, Set<String> references, String value) { + if (!isExternalLink(value)) { + String reference = normalizePath(pathPrefix, value); + references.add(reference); + } + } + + private String normalizePath(String pathPrefix, String reference) { + String path = reference.replaceAll("\\.html#.*", ".html"); + return String.format("%s%s", pathPrefix, path); + } + + private boolean isExternalLink(String resource) { + return resource.contains("://"); + } +} diff --git a/plugins/org.eclipse.osee.framework.help.ui.test/src/org/eclipse/osee/framework/help/ui/util/TocParser.java b/plugins/org.eclipse.osee.framework.help.ui.test/src/org/eclipse/osee/framework/help/ui/util/TocParser.java new file mode 100644 index 00000000000..25c5d76b035 --- /dev/null +++ b/plugins/org.eclipse.osee.framework.help.ui.test/src/org/eclipse/osee/framework/help/ui/util/TocParser.java @@ -0,0 +1,103 @@ +/******************************************************************************* + * Copyright (c) 2013 Boeing. + * 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: + * Boeing - initial API and implementation + *******************************************************************************/ +package org.eclipse.osee.framework.help.ui.util; + +import java.io.BufferedInputStream; +import java.io.InputStream; +import java.net.URL; +import java.util.HashSet; +import java.util.Set; +import javax.xml.stream.XMLInputFactory; +import javax.xml.stream.XMLStreamConstants; +import javax.xml.stream.XMLStreamReader; +import org.eclipse.osee.framework.jdk.core.util.Lib; +import org.eclipse.osee.framework.jdk.core.util.Strings; + +/** + * @author Angel Avila + */ +public class TocParser { + + private static final XMLInputFactory xmlInputFactory = XMLInputFactory.newFactory(); + + private static final String TOC = "toc"; + private static final String TOPIC = "topic"; + private static final String HREF = "href"; + + public Set<String> entries = new HashSet<String>(); + public String path; + + private String localName; + private String uri; + + public TocParser(String path) { + this.path = path; + } + + public void parse() throws Exception { + entries.clear(); + URL url = HelpTestUtil.getResource(path); + + InputStream inputStream = null; + try { + inputStream = new BufferedInputStream(url.openStream()); + XMLStreamReader streamReader = xmlInputFactory.createXMLStreamReader(inputStream); + while (streamReader.hasNext()) { + process(streamReader); + streamReader.next(); + } + + } finally { + Lib.close(inputStream); + } + } + + private void process(XMLStreamReader reader) { + int eventType = reader.getEventType(); + switch (eventType) { + case XMLStreamConstants.START_ELEMENT: + localName = reader.getLocalName(); + uri = reader.getNamespaceURI(); + if (TOC.equals(localName)) { + processReference(reader, TOPIC); + } else if (TOPIC.equals(localName)) { + processReference(reader, HREF); + } + break; + case XMLStreamConstants.END_ELEMENT: + localName = reader.getLocalName(); + uri = reader.getNamespaceURI(); + reset(); + break; + } + } + + private void processReference(XMLStreamReader reader, String tag) { + String reference = reader.getAttributeValue(uri, tag); + if (Strings.isValid(reference)) { + String path = normalizePath(reference); + entries.add(path); + } + } + + private String normalizePath(String reference) { + return reference.replaceAll("\\.html#.*", ".html"); + } + + private void reset() { + localName = null; + uri = null; + } + + public Set<String> getEntries() { + return entries; + } +} diff --git a/plugins/org.eclipse.osee.ote.help.ui.test/.classpath b/plugins/org.eclipse.osee.ote.help.ui.test/.classpath new file mode 100644 index 00000000000..ad32c83a788 --- /dev/null +++ b/plugins/org.eclipse.osee.ote.help.ui.test/.classpath @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?> +<classpath> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/> + <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> + <classpathentry kind="src" path="src"/> + <classpathentry kind="output" path="bin"/> +</classpath> diff --git a/plugins/org.eclipse.osee.ote.help.ui.test/.project b/plugins/org.eclipse.osee.ote.help.ui.test/.project new file mode 100644 index 00000000000..6600992d2cd --- /dev/null +++ b/plugins/org.eclipse.osee.ote.help.ui.test/.project @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>org.eclipse.osee.ote.help.ui.test</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + <buildCommand> + <name>org.eclipse.jdt.core.javabuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.ManifestBuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.SchemaBuilder</name> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>org.eclipse.pde.PluginNature</nature> + <nature>org.eclipse.jdt.core.javanature</nature> + </natures> +</projectDescription> diff --git a/plugins/org.eclipse.osee.ote.help.ui.test/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.ote.help.ui.test/META-INF/MANIFEST.MF new file mode 100644 index 00000000000..0e6c39909d3 --- /dev/null +++ b/plugins/org.eclipse.osee.ote.help.ui.test/META-INF/MANIFEST.MF @@ -0,0 +1,12 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: OSEE OTE Help UI Test (Incubation) +Bundle-SymbolicName: org.eclipse.osee.ote.help.ui.test +Bundle-Version: 0.11.0.qualifier +Bundle-Vendor: Eclipse Open System Engineering Environment +Fragment-Host: org.eclipse.osee.ote.help.ui +Bundle-RequiredExecutionEnvironment: JavaSE-1.6 +Require-Bundle: org.junit +Import-Package: org.eclipse.core.runtime;version="3.4.0", + org.eclipse.osee.framework.jdk.core.util, + org.osgi.framework diff --git a/plugins/org.eclipse.osee.ote.help.ui.test/OteHelpUi_TestSuite.launch b/plugins/org.eclipse.osee.ote.help.ui.test/OteHelpUi_TestSuite.launch new file mode 100644 index 00000000000..c5df4cd78fc --- /dev/null +++ b/plugins/org.eclipse.osee.ote.help.ui.test/OteHelpUi_TestSuite.launch @@ -0,0 +1,56 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<launchConfiguration type="org.eclipse.pde.ui.JunitLaunchConfig"> +<setAttribute key="additional_plugins"> +<setEntry value="org.eclipse.osee.framework.dev.help.ui:0.11.0.qualifier:default:false"/> +<setEntry value="org.eclipse.osee.framework.help.ui:0.11.0.qualifier:default:false"/> +<setEntry value="org.eclipse.osee.ote.help.ui:0.11.0.qualifier:default:true"/> +</setAttribute> +<booleanAttribute key="append.args" value="true"/> +<stringAttribute key="application" value="org.eclipse.pde.junit.runtime.coretestapplication"/> +<booleanAttribute key="askclear" value="false"/> +<booleanAttribute key="automaticAdd" value="true"/> +<booleanAttribute key="automaticValidate" value="true"/> +<stringAttribute key="bootstrap" value=""/> +<stringAttribute key="checked" value="[NONE]"/> +<booleanAttribute key="clearConfig" value="true"/> +<booleanAttribute key="clearws" value="true"/> +<booleanAttribute key="clearwslog" value="false"/> +<stringAttribute key="configLocation" value="${workspace_loc}/.metadata/.plugins/org.eclipse.pde.core/pde-junit"/> +<booleanAttribute key="default" value="false"/> +<booleanAttribute key="default_auto_start" value="true"/> +<stringAttribute key="deselected_workspace_plugins" value="ah6.ats.config.common,ats.config.common,com.boeing.ote.cdb.diff,com.hazelcast,com.hazelcast.source,com.sun.jersey,com.sun.jersey.client.apache,com.sun.jersey.client.apache.source,com.sun.jersey.source,com.vaadin,javax.ws.rs,javax.ws.rs.source,jms.activemq.launch,jms.libraries,lba.ats.config.common,lba.ats.config.common.test,lba.ats.config.osee,lba.ats.config.osee.test,lba.ats.help.ui,lba.authentication.provider,lba.db.connection,lba.define,lba.define.help.ui,lba.define.test,lba.framework.help.ui,lba.framework.ui.skynet,lba.framework.ui.skynet.test,lba.help,lba.myII.tc,lba.osee.client.integration.tests,lba.osee.coverage,lba.osee.x.server.customizations,lba.ote.client,lba.ote.client.ui,lba.ote.cnf.dsl,lba.ote.cnf.dsl.ui,lba.ote.commands,lba.ote.help.ui,lba.ote.launchTest,lba.ote.message.support,lba.ote.outfile.conversion,lba.ote.outfile.conversion.app,lba.ote.outfile.conversion.test,lba.ote.projectsets.three.four,lba.ote.result.upload,lba.ote.test.manager,lba.ote.test.manager.ofp,lba.ote.ui.test.manager,lba.ote.workspace.ui,lba.rdt.core,lba.rdt.core.test,lba.rdt.service,lba.rdt.service.osee,lba.rdt.ui,lba.rdt.ui.test,lba.server.station.config,lba.server.station.config.test,lba.start,lba.tools.road.map,lba.tte,lba.tte.test,lba.utility.count,lba.utility.external.editor,lba.utility.ui.count,mysql.driver.ext,net.jini,net.sf.ehcache,net.sf.ehcache.source,oracle.driver,org.boeing.count,org.eclipse.osee.ats,org.eclipse.osee.ats.api,org.eclipse.osee.ats.client.demo,org.eclipse.osee.ats.client.integration.tests,org.eclipse.osee.ats.core,org.eclipse.osee.ats.core.client,org.eclipse.osee.ats.core.client.test,org.eclipse.osee.ats.core.test,org.eclipse.osee.ats.dsl,org.eclipse.osee.ats.dsl.ui,org.eclipse.osee.ats.help.ui,org.eclipse.osee.ats.impl,org.eclipse.osee.ats.impl.test,org.eclipse.osee.ats.mocks,org.eclipse.osee.ats.presenter,org.eclipse.osee.ats.presenter.mock,org.eclipse.osee.ats.presenter.test,org.eclipse.osee.ats.reports,org.eclipse.osee.ats.reports.burndown,org.eclipse.osee.ats.reports.efficiency,org.eclipse.osee.ats.reports.split,org.eclipse.osee.ats.ui.api,org.eclipse.osee.ats.view.web,org.eclipse.osee.ats.view.web.test,org.eclipse.osee.authentication,org.eclipse.osee.authorization,org.eclipse.osee.client.demo,org.eclipse.osee.client.integration.tests,org.eclipse.osee.client.test.framework,org.eclipse.osee.cluster,org.eclipse.osee.cluster.hazelcast,org.eclipse.osee.cluster.rest,org.eclipse.osee.console.admin,org.eclipse.osee.console.admin.test,org.eclipse.osee.coverage,org.eclipse.osee.coverage.demo,org.eclipse.osee.coverage.help.ui,org.eclipse.osee.coverage.integration.tests,org.eclipse.osee.coverage.test,org.eclipse.osee.database,org.eclipse.osee.database.schema,org.eclipse.osee.define,org.eclipse.osee.define.test,org.eclipse.osee.display.api,org.eclipse.osee.display.mvp,org.eclipse.osee.display.mvp.test,org.eclipse.osee.display.presenter,org.eclipse.osee.display.presenter.mocks,org.eclipse.osee.display.presenter.test,org.eclipse.osee.display.view.web,org.eclipse.osee.distributed,org.eclipse.osee.event,org.eclipse.osee.event.monitor,org.eclipse.osee.event.osgi,org.eclipse.osee.executor.admin,org.eclipse.osee.executor.admin.test,org.eclipse.osee.framework.access,org.eclipse.osee.framework.access.provider,org.eclipse.osee.framework.access.test,org.eclipse.osee.framework.authentication.ldap.core,org.eclipse.osee.framework.branch.gantt,org.eclipse.osee.framework.core,org.eclipse.osee.framework.core.client,org.eclipse.osee.framework.core.dsl,org.eclipse.osee.framework.core.dsl.edit,org.eclipse.osee.framework.core.dsl.integration,org.eclipse.osee.framework.core.dsl.integration.test,org.eclipse.osee.framework.core.dsl.ui,org.eclipse.osee.framework.core.dsl.ui.integration,org.eclipse.osee.framework.core.dsl.ui.integration.test,org.eclipse.osee.framework.core.message,org.eclipse.osee.framework.core.message.test,org.eclipse.osee.framework.core.model,org.eclipse.osee.framework.core.model.test,org.eclipse.osee.framework.core.server,org.eclipse.osee.framework.core.server.test,org.eclipse.osee.framework.core.test,org.eclipse.osee.framework.database,org.eclipse.osee.framework.database.init,org.eclipse.osee.framework.database.test,org.eclipse.osee.framework.dev.help.ui,org.eclipse.osee.framework.h2,org.eclipse.osee.framework.help.ui,org.eclipse.osee.framework.help.ui.test,org.eclipse.osee.framework.jdk.core,org.eclipse.osee.framework.jdk.core.test,org.eclipse.osee.framework.jini,org.eclipse.osee.framework.lifecycle,org.eclipse.osee.framework.lifecycle.test,org.eclipse.osee.framework.logging,org.eclipse.osee.framework.logging.test,org.eclipse.osee.framework.manager.servlet,org.eclipse.osee.framework.messaging,org.eclipse.osee.framework.messaging.event.res,org.eclipse.osee.framework.messaging.event.res.test,org.eclipse.osee.framework.messaging.test,org.eclipse.osee.framework.plugin.core,org.eclipse.osee.framework.resource.management,org.eclipse.osee.framework.resource.management.test,org.eclipse.osee.framework.skynet.core,org.eclipse.osee.framework.skynet.core.test,org.eclipse.osee.framework.templates,org.eclipse.osee.framework.ui.admin,org.eclipse.osee.framework.ui.branch.graph,org.eclipse.osee.framework.ui.data.model.editor,org.eclipse.osee.framework.ui.plugin,org.eclipse.osee.framework.ui.product,org.eclipse.osee.framework.ui.skynet,org.eclipse.osee.framework.ui.skynet.test,org.eclipse.osee.framework.ui.swt,org.eclipse.osee.framework.ui.workspacebundleloader,org.eclipse.osee.framework.ui.ws,org.eclipse.osee.logback.config,org.eclipse.osee.logger,org.eclipse.osee.logger.slf4j,org.eclipse.osee.mail,org.eclipse.osee.mail.rest,org.eclipse.osee.mail.test,org.eclipse.osee.mvp.example,org.eclipse.osee.mvp.example.api,org.eclipse.osee.mvp.example.presenter,org.eclipse.osee.mvp.example.view,org.eclipse.osee.orcs,org.eclipse.osee.orcs.core,org.eclipse.osee.orcs.core.test,org.eclipse.osee.orcs.db,org.eclipse.osee.orcs.db.mock,org.eclipse.osee.orcs.db.test,org.eclipse.osee.orcs.rest,org.eclipse.osee.orcs.rest.client,org.eclipse.osee.orcs.rest.model,org.eclipse.osee.orcs.rest.test,org.eclipse.osee.orcs.test,org.eclipse.osee.ote.client,org.eclipse.osee.ote.client.msg,org.eclipse.osee.ote.connection.jini,org.eclipse.osee.ote.connection.service,org.eclipse.osee.ote.connection.service.test,org.eclipse.osee.ote.container,org.eclipse.osee.ote.core,org.eclipse.osee.ote.core.test,org.eclipse.osee.ote.define,org.eclipse.osee.ote.help.ui,org.eclipse.osee.ote.jms,org.eclipse.osee.ote.message,org.eclipse.osee.ote.message.test,org.eclipse.osee.ote.messaging.dds,org.eclipse.osee.ote.model.manager,org.eclipse.osee.ote.runtimeManager,org.eclipse.osee.ote.server,org.eclipse.osee.ote.ui,org.eclipse.osee.ote.ui.define,org.eclipse.osee.ote.ui.markers,org.eclipse.osee.ote.ui.output,org.eclipse.osee.ote.ui.test.manager,org.eclipse.osee.ote.ui.test.output,org.eclipse.osee.ote.version,org.eclipse.osee.ote.version.git,org.eclipse.osee.ote.version.git.test,org.eclipse.osee.ote.version.svn,org.eclipse.osee.rest.admin,org.eclipse.osee.rest.test.client,org.eclipse.osee.rest.test.model,org.eclipse.osee.rest.test.server,org.eclipse.osee.sos,org.eclipse.osee.support.dev.java,org.eclipse.osee.support.test.util,org.eclipse.osee.user.admin,org.eclipse.osee.vaadin,org.eclipse.osee.vaadin.example.ui,org.eclipse.osee.vaadin.themes,org.eclipse.osee.vaadin.widgets,org.eclipse.osee.x.server.application,org.json,org.jvnet.mimepull,org.jvnet.mimepull.source,org.mockito,org.mockito.source,org.mockito.test.example,org.objenesis,org.objenesis.source,org.postgresql.driver,org.xerial.sqlite,org.xerial.sqlite.source"/> +<stringAttribute key="featureDefaultLocation" value="workspace"/> +<stringAttribute key="featurePluginResolution" value="workspace"/> +<booleanAttribute key="includeOptional" value="true"/> +<stringAttribute key="location" value="${workspace_loc}/../junit-workspace"/> +<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS"> +<listEntry value="/org.eclipse.osee.ote.help.ui.test/src/org/eclipse/osee/ote/help/ui/OteHelpUiTestSuite.java"/> +</listAttribute> +<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES"> +<listEntry value="1"/> +</listAttribute> +<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value=""/> +<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/> +<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/> +<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit4"/> +<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.eclipse.osee.ote.help.ui.OteHelpUiTestSuite"/> +<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-os ${target.os} -ws ${target.ws} -arch ${target.arch} -nl ${target.nl} -consoleLog"/> +<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="org.eclipse.osee.ote.help.ui.test"/> +<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.pde.ui.workbenchClasspathProvider"/> +<stringAttribute key="pde.version" value="3.3"/> +<stringAttribute key="product" value="org.eclipse.osee.framework.ui.product.osee"/> +<booleanAttribute key="run_in_ui_thread" value="false"/> +<setAttribute key="selected_features"> +<setEntry value="org.eclipse.osee.core.feature:default"/> +<setEntry value="org.eclipse.osee.core.plugin.feature:default"/> +<setEntry value="org.eclipse.osee.core.runtime.feature:default"/> +<setEntry value="org.eclipse.osee.core.ui.feature:default"/> +</setAttribute> +<booleanAttribute key="show_selected_only" value="true"/> +<stringAttribute key="templateConfig" value="${target_home}\configuration\config.ini"/> +<booleanAttribute key="tracing" value="false"/> +<booleanAttribute key="useCustomFeatures" value="true"/> +<booleanAttribute key="useDefaultConfig" value="true"/> +<booleanAttribute key="useDefaultConfigArea" value="false"/> +<booleanAttribute key="useProduct" value="false"/> +</launchConfiguration> diff --git a/plugins/org.eclipse.osee.ote.help.ui.test/build.properties b/plugins/org.eclipse.osee.ote.help.ui.test/build.properties new file mode 100644 index 00000000000..1b243b1a937 --- /dev/null +++ b/plugins/org.eclipse.osee.ote.help.ui.test/build.properties @@ -0,0 +1,5 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + . +additional.bundles = org.eclipse.osee.framework.jdk.core diff --git a/plugins/org.eclipse.osee.ote.help.ui.test/pom.xml b/plugins/org.eclipse.osee.ote.help.ui.test/pom.xml new file mode 100644 index 00000000000..ece01321071 --- /dev/null +++ b/plugins/org.eclipse.osee.ote.help.ui.test/pom.xml @@ -0,0 +1,30 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>org.eclipse.osee</groupId> + <artifactId>org.eclipse.osee.ote.parent</artifactId> + <version>0.11.0-SNAPSHOT</version> + <relativePath>../../plugins/org.eclipse.osee.ote.parent</relativePath> + </parent> + + <artifactId>org.eclipse.osee.ote.help.ui.test</artifactId> + <packaging>eclipse-test-plugin</packaging> + <name>OSEE OTE Help UI Test - (Incubation)</name> + + <build> + <plugins> + <plugin> + <groupId>org.eclipse.tycho</groupId> + <artifactId>tycho-surefire-plugin</artifactId> + <version>${tycho-version}</version> + <configuration> + <testSuite>org.eclipse.osee.ote.help.ui.test</testSuite> + <testClass>org.eclipse.osee.ote.help.ui.OteHelpUiTestSuite</testClass> + </configuration> + </plugin> + </plugins> + </build> +</project>
\ No newline at end of file diff --git a/plugins/org.eclipse.osee.ote.help.ui.test/src/org/eclipse/osee/ote/help/ui/HelpContextTest.java b/plugins/org.eclipse.osee.ote.help.ui.test/src/org/eclipse/osee/ote/help/ui/HelpContextTest.java new file mode 100644 index 00000000000..86eb58062a6 --- /dev/null +++ b/plugins/org.eclipse.osee.ote.help.ui.test/src/org/eclipse/osee/ote/help/ui/HelpContextTest.java @@ -0,0 +1,85 @@ +/******************************************************************************* + * Copyright (c) 2013 Boeing. + * 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: + * Boeing - initial API and implementation + *******************************************************************************/ +package org.eclipse.osee.ote.help.ui; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import java.lang.reflect.Field; +import java.net.URL; +import java.util.HashMap; +import java.util.Map; +import org.eclipse.osee.framework.jdk.core.util.Compare; +import org.eclipse.osee.framework.ui.plugin.util.HelpContext; +import org.eclipse.osee.ote.help.ui.util.ContextParser; +import org.eclipse.osee.ote.help.ui.util.ContextParser.ContextEntry; +import org.eclipse.osee.ote.help.ui.util.HelpTestUtil; +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.Test; + +/** + * @author Angel Avila + */ +public class HelpContextTest { + + private static final String PLUGIN_ID = "org.eclipse.osee.ote.help.ui"; + + private static Map<String, HelpContext> contexts; + private static ContextParser parser; + + @BeforeClass + public static void setUp() throws Exception { + contexts = getContexts(OteHelpContext.class); + parser = new ContextParser("contexts/contexts.xml"); + parser.parse(); + } + + @Test + public void testAdd() throws Exception { + assertEquals(12, contexts.size()); + } + + @Test + public void testContextsXml() throws Exception { + assertEquals(contexts.size(), parser.getEntries().size()); + + Assert.assertFalse(Compare.isDifferent(contexts.keySet(), parser.getIds())); + for (HelpContext context : contexts.values()) { + assertEquals(PLUGIN_ID, context.getPluginId()); + + String id = context.getName(); + ContextEntry entry = parser.getEntry(id); + assertNotNull(entry); + } + } + + @Test + public void testHrefFiles() throws Exception { + for (ContextEntry entry : parser.getEntries()) { + for (String reference : entry.getReferences()) { + URL url = HelpTestUtil.getResource(reference); + assertNotNull(String.format("[%s] was not valid", reference), url); + } + } + } + + private static Map<String, HelpContext> getContexts(Class<?> clazz) throws IllegalArgumentException, IllegalAccessException { + Map<String, HelpContext> contexts = new HashMap<String, HelpContext>(); + for (Field field : clazz.getFields()) { + Object object = field.get(null); + if (object instanceof HelpContext) { + HelpContext context = (HelpContext) object; + contexts.put(context.getName(), context); + } + } + return contexts; + } +} diff --git a/plugins/org.eclipse.osee.ote.help.ui.test/src/org/eclipse/osee/ote/help/ui/HelpTableOfContentTest.java b/plugins/org.eclipse.osee.ote.help.ui.test/src/org/eclipse/osee/ote/help/ui/HelpTableOfContentTest.java new file mode 100644 index 00000000000..6a1ff5fe6ff --- /dev/null +++ b/plugins/org.eclipse.osee.ote.help.ui.test/src/org/eclipse/osee/ote/help/ui/HelpTableOfContentTest.java @@ -0,0 +1,60 @@ +/******************************************************************************* + * Copyright (c) 2013 Boeing. + * 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: + * Boeing - initial API and implementation + *******************************************************************************/ +package org.eclipse.osee.ote.help.ui; + +import static org.junit.Assert.assertNotNull; +import java.net.URL; +import java.util.Set; +import org.eclipse.osee.ote.help.ui.util.HelpTestUtil; +import org.eclipse.osee.ote.help.ui.util.HtmlParser; +import org.eclipse.osee.ote.help.ui.util.TocParser; +import org.junit.BeforeClass; +import org.junit.Test; + +/** + * @author Angel Avila + */ +public class HelpTableOfContentTest { + + private static final String PLUGIN_ID = "org.eclipse.osee.ote.help.ui"; + + private static TocParser parser; + + @BeforeClass + public static void setUp() throws Exception { + parser = new TocParser("toc.xml"); + parser.parse(); + } + + @Test + public void testAllTocReferencesExist() throws Exception { + for (String reference : parser.getEntries()) { + URL url = HelpTestUtil.getResource(reference); + assertNotNull(String.format("[%s] was not valid", reference), url); + } + } + + @Test + public void testTocReferencesValid() throws Exception { + HtmlParser htmlParser = new HtmlParser(PLUGIN_ID); + + for (String reference : parser.getEntries()) { + URL url = HelpTestUtil.getResource(reference); + + Set<String> entries = htmlParser.parse(url); + for (String resource : entries) { + URL referencedUrl = HelpTestUtil.getResource(reference); + assertNotNull(String.format("[%s] was not valid", resource), referencedUrl); + } + + } + } +} diff --git a/plugins/org.eclipse.osee.ote.help.ui.test/src/org/eclipse/osee/ote/help/ui/OteHelpUiTestSuite.java b/plugins/org.eclipse.osee.ote.help.ui.test/src/org/eclipse/osee/ote/help/ui/OteHelpUiTestSuite.java new file mode 100644 index 00000000000..e01b751cd37 --- /dev/null +++ b/plugins/org.eclipse.osee.ote.help.ui.test/src/org/eclipse/osee/ote/help/ui/OteHelpUiTestSuite.java @@ -0,0 +1,23 @@ +/******************************************************************************* + * Copyright (c) 2013 Boeing. + * 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: + * Boeing - initial API and implementation + *******************************************************************************/ +package org.eclipse.osee.ote.help.ui; + +import org.junit.runner.RunWith; +import org.junit.runners.Suite; + +/** + * @author Angel Avila + */ +@RunWith(Suite.class) +@Suite.SuiteClasses({HelpContextTest.class, HelpTableOfContentTest.class}) +public class OteHelpUiTestSuite { + // Test Suite +} diff --git a/plugins/org.eclipse.osee.ote.help.ui.test/src/org/eclipse/osee/ote/help/ui/util/ContextParser.java b/plugins/org.eclipse.osee.ote.help.ui.test/src/org/eclipse/osee/ote/help/ui/util/ContextParser.java new file mode 100644 index 00000000000..e9d2c3ea926 --- /dev/null +++ b/plugins/org.eclipse.osee.ote.help.ui.test/src/org/eclipse/osee/ote/help/ui/util/ContextParser.java @@ -0,0 +1,141 @@ +/******************************************************************************* + * Copyright (c) 2013 Boeing. + * 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: + * Boeing - initial API and implementation + *******************************************************************************/ +package org.eclipse.osee.ote.help.ui.util; +import java.io.BufferedInputStream; +import java.io.InputStream; +import java.net.URL; +import java.util.Collection; +import java.util.HashMap; +import java.util.LinkedHashSet; +import java.util.Map; +import java.util.Set; +import javax.xml.stream.XMLInputFactory; +import javax.xml.stream.XMLStreamConstants; +import javax.xml.stream.XMLStreamReader; +import org.eclipse.osee.framework.jdk.core.util.Lib; +import org.eclipse.osee.framework.jdk.core.util.Strings; + + +/** + * @author Angel Avila + */ +public class ContextParser { + + private static final XMLInputFactory xmlInputFactory = XMLInputFactory.newFactory(); + + private static final String CONTEXT = "context"; + private static final String TOPIC = "topic"; + private static final String HREF = "href"; + private static final String ID_TAG = "id"; + + public Map<String, ContextEntry> entries = new HashMap<String, ContextEntry>(); + public String path; + + private String localName; + private String uri; + private ContextEntry currentEntry; + + public ContextParser(String path) { + this.path = path; + } + + public void parse() throws Exception { + entries.clear(); + URL url = HelpTestUtil.getResource(path); + + InputStream inputStream = null; + try { + inputStream = new BufferedInputStream(url.openStream()); + XMLStreamReader streamReader = xmlInputFactory.createXMLStreamReader(inputStream); + while (streamReader.hasNext()) { + process(streamReader); + streamReader.next(); + } + + } finally { + Lib.close(inputStream); + } + } + + private void process(XMLStreamReader reader) { + int eventType = reader.getEventType(); + switch (eventType) { + case XMLStreamConstants.START_ELEMENT: + localName = reader.getLocalName(); + uri = reader.getNamespaceURI(); + if (CONTEXT.equals(localName)) { + + String id = reader.getAttributeValue(uri, ID_TAG); + if (Strings.isValid(id)) { + currentEntry = new ContextEntry(id); + } + + } else if (TOPIC.equals(localName) && currentEntry != null) { + String reference = reader.getAttributeValue(uri, HREF); + if (Strings.isValid(reference)) { + String path = normalizePath(reference); + currentEntry.getReferences().add(path); + } + } + break; + case XMLStreamConstants.END_ELEMENT: + localName = reader.getLocalName(); + uri = reader.getNamespaceURI(); + if (CONTEXT.equals(localName) && currentEntry != null) { + entries.put(currentEntry.getId(), currentEntry); + reset(); + } + break; + } + } + + private String normalizePath(String reference) { + return reference.replaceAll("\\.html#.*", ".html"); + } + + private void reset() { + localName = null; + uri = null; + currentEntry = null; + } + + public Collection<ContextEntry> getEntries() { + return entries.values(); + } + + public ContextEntry getEntry(String id) { + return entries.get(id); + } + + public Set<String> getIds() { + return entries.keySet(); + } + + public final class ContextEntry { + private final String id; + private final Set<String> references = new LinkedHashSet<String>(); + + public ContextEntry(String id) { + super(); + this.id = id; + } + + public String getId() { + return id; + } + + public Set<String> getReferences() { + return references; + } + + } + +} diff --git a/plugins/org.eclipse.osee.ote.help.ui.test/src/org/eclipse/osee/ote/help/ui/util/HelpTestUtil.java b/plugins/org.eclipse.osee.ote.help.ui.test/src/org/eclipse/osee/ote/help/ui/util/HelpTestUtil.java new file mode 100644 index 00000000000..157b5fd57db --- /dev/null +++ b/plugins/org.eclipse.osee.ote.help.ui.test/src/org/eclipse/osee/ote/help/ui/util/HelpTestUtil.java @@ -0,0 +1,43 @@ +/******************************************************************************* + * Copyright (c) 2013 Boeing. + * 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: + * Boeing - initial API and implementation + *******************************************************************************/ +package org.eclipse.osee.ote.help.ui.util; + +import static junit.framework.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import java.io.File; +import java.net.URL; +import org.eclipse.core.runtime.FileLocator; +import org.osgi.framework.Bundle; +import org.osgi.framework.FrameworkUtil; + +/** + * @author Angel Avila + */ +public final class HelpTestUtil { + + private HelpTestUtil() { + // Utility Class + } + + public static URL getResource(String resource) throws Exception { + Bundle bundle = FrameworkUtil.getBundle(HelpTestUtil.class); + URL url = bundle.getResource(resource); + + assertNotNull(String.format("Resource not found: [%s]", resource), url); + + url = FileLocator.toFileURL(url); + File file = new File(url.toURI()); + assertEquals(String.format("[%s] does not exist", resource), true, file.exists()); + assertEquals(String.format("[%s] unreadable", resource), true, file.canRead()); + + return url; + } +} diff --git a/plugins/org.eclipse.osee.ote.help.ui.test/src/org/eclipse/osee/ote/help/ui/util/HtmlParser.java b/plugins/org.eclipse.osee.ote.help.ui.test/src/org/eclipse/osee/ote/help/ui/util/HtmlParser.java new file mode 100644 index 00000000000..f9e0c42a171 --- /dev/null +++ b/plugins/org.eclipse.osee.ote.help.ui.test/src/org/eclipse/osee/ote/help/ui/util/HtmlParser.java @@ -0,0 +1,119 @@ +/******************************************************************************* + * Copyright (c) 2013 Boeing. + * 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: + * Boeing - initial API and implementation + *******************************************************************************/ +package org.eclipse.osee.ote.help.ui.util; + +import java.io.BufferedInputStream; +import java.io.InputStream; +import java.net.URL; +import java.util.HashSet; +import java.util.Set; +import javax.xml.stream.XMLInputFactory; +import javax.xml.stream.XMLStreamConstants; +import javax.xml.stream.XMLStreamReader; +import org.eclipse.osee.framework.jdk.core.util.Lib; +import org.eclipse.osee.framework.jdk.core.util.Strings; + +; + +/** + * @author Angel Avila + */ +public class HtmlParser { + + private static final XMLInputFactory xmlInputFactory = XMLInputFactory.newFactory(); + + private static final String LINK_NODE = "link"; + private static final String HREF_TAG = "href"; + private static final String SRC_TAG = "src"; + + private final String pathHint; + + public HtmlParser(String pathHint) { + this.pathHint = pathHint; + } + + private String getPath(String fullPath) { + StringBuilder builder = new StringBuilder(); + + String[] parts = fullPath.split("/"); + boolean found = false; + for (String part : parts) { + if (found && !part.endsWith(".html")) { + builder.append(part); + builder.append("/"); + } + if (pathHint.equals(part)) { + found = true; + } + } + return builder.toString(); + } + + public Set<String> parse(URL url) throws Exception { + Set<String> entries = new HashSet<String>(); + entries.clear(); + + String pathPrefix = getPath(url.toString()); + + InputStream inputStream = null; + try { + inputStream = new BufferedInputStream(url.openStream()); + XMLStreamReader streamReader = xmlInputFactory.createXMLStreamReader(inputStream); + while (streamReader.hasNext()) { + process(streamReader, pathPrefix, entries); + streamReader.next(); + } + + } finally { + Lib.close(inputStream); + } + + return entries; + } + + private void process(XMLStreamReader reader, String pathPrefix, Set<String> entries) { + int eventType = reader.getEventType(); + switch (eventType) { + case XMLStreamConstants.START_ELEMENT: + String localName = reader.getLocalName(); + for (int index = 0; index < reader.getAttributeCount(); index++) { + + String attributeName = reader.getAttributeLocalName(index); + String value = reader.getAttributeValue(index); + + if (Strings.isValid(value)) { + if (!LINK_NODE.equals(localName)) { + if (HREF_TAG.equals(attributeName) || SRC_TAG.equals(attributeName)) { + processResource(pathPrefix, entries, value); + } + } + } + } + break; + } + } + + private void processResource(String pathPrefix, Set<String> references, String value) { + if (!isExternalLink(value)) { + String reference = normalizePath(pathPrefix, value); + references.add(reference); + } + } + + private String normalizePath(String pathPrefix, String reference) { + String path = reference.replaceAll("\\.html#.*", ".html"); + return String.format("%s%s", pathPrefix, path); + } + + private boolean isExternalLink(String resource) { + return resource.contains("://"); + } +} diff --git a/plugins/org.eclipse.osee.ote.help.ui.test/src/org/eclipse/osee/ote/help/ui/util/TocParser.java b/plugins/org.eclipse.osee.ote.help.ui.test/src/org/eclipse/osee/ote/help/ui/util/TocParser.java new file mode 100644 index 00000000000..db79a07fd48 --- /dev/null +++ b/plugins/org.eclipse.osee.ote.help.ui.test/src/org/eclipse/osee/ote/help/ui/util/TocParser.java @@ -0,0 +1,103 @@ +/******************************************************************************* + * Copyright (c) 2013 Boeing. + * 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: + * Boeing - initial API and implementation + *******************************************************************************/ +package org.eclipse.osee.ote.help.ui.util; +import java.io.BufferedInputStream; +import java.io.InputStream; +import java.net.URL; +import java.util.HashSet; +import java.util.Set; +import javax.xml.stream.XMLInputFactory; +import javax.xml.stream.XMLStreamConstants; +import javax.xml.stream.XMLStreamReader; +import org.eclipse.osee.framework.jdk.core.util.Lib; +import org.eclipse.osee.framework.jdk.core.util.Strings; + + +/** + * @author Angel Avila + */ +public class TocParser { + + private static final XMLInputFactory xmlInputFactory = XMLInputFactory.newFactory(); + + private static final String TOC = "toc"; + private static final String TOPIC = "topic"; + private static final String HREF = "href"; + + public Set<String> entries = new HashSet<String>(); + public String path; + + private String localName; + private String uri; + + public TocParser(String path) { + this.path = path; + } + + public void parse() throws Exception { + entries.clear(); + URL url = HelpTestUtil.getResource(path); + + InputStream inputStream = null; + try { + inputStream = new BufferedInputStream(url.openStream()); + XMLStreamReader streamReader = xmlInputFactory.createXMLStreamReader(inputStream); + while (streamReader.hasNext()) { + process(streamReader); + streamReader.next(); + } + + } finally { + Lib.close(inputStream); + } + } + + private void process(XMLStreamReader reader) { + int eventType = reader.getEventType(); + switch (eventType) { + case XMLStreamConstants.START_ELEMENT: + localName = reader.getLocalName(); + uri = reader.getNamespaceURI(); + if (TOC.equals(localName)) { + processReference(reader, TOPIC); + } else if (TOPIC.equals(localName)) { + processReference(reader, HREF); + } + break; + case XMLStreamConstants.END_ELEMENT: + localName = reader.getLocalName(); + uri = reader.getNamespaceURI(); + reset(); + break; + } + } + + private void processReference(XMLStreamReader reader, String tag) { + String reference = reader.getAttributeValue(uri, tag); + if (Strings.isValid(reference)) { + String path = normalizePath(reference); + entries.add(path); + } + } + + private String normalizePath(String reference) { + return reference.replaceAll("\\.html#.*", ".html"); + } + + private void reset() { + localName = null; + uri = null; + } + + public Set<String> getEntries() { + return entries; + } +} diff --git a/plugins/org.eclipse.osee.ote.parent/pom.xml b/plugins/org.eclipse.osee.ote.parent/pom.xml index fbc2ae01ce5..321212c3cea 100644 --- a/plugins/org.eclipse.osee.ote.parent/pom.xml +++ b/plugins/org.eclipse.osee.ote.parent/pom.xml @@ -35,6 +35,8 @@ <module>../../plugins/org.eclipse.osee.ote.server</module> <module>../../plugins/org.eclipse.osee.ote.help.ui</module> + <module>../../plugins/org.eclipse.osee.ote.help.ui.test</module> + <module>../../plugins/org.eclipse.osee.ote.ui</module> <!-- <module>../../plugins/org.eclipse.osee.ote.ui.host.cmd</module> --> <module>../../plugins/org.eclipse.osee.ote.ui.markers</module> |