Author: mes Date: 2012-06-12 16:53:03 -0700 (Tue, 12 Jun 2012) New Revision: 29542
Added: core3/functional-testing/trunk/ core3/functional-testing/trunk/pom.xml core3/functional-testing/trunk/src/ core3/functional-testing/trunk/src/test/ core3/functional-testing/trunk/src/test/java/ core3/functional-testing/trunk/src/test/java/org/ core3/functional-testing/trunk/src/test/java/org/cytoscape/ core3/functional-testing/trunk/src/test/java/org/cytoscape/functional/ core3/functional-testing/trunk/src/test/java/org/cytoscape/functional/menus/ core3/functional-testing/trunk/src/test/java/org/cytoscape/functional/menus/BasicMenuTest.java Log: initial import Added: core3/functional-testing/trunk/pom.xml =================================================================== --- core3/functional-testing/trunk/pom.xml (rev 0) +++ core3/functional-testing/trunk/pom.xml 2012-06-12 23:53:03 UTC (rev 29542) @@ -0,0 +1,89 @@ + +<?xml version="1.0" encoding="UTF-8"?> +<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> + <artifactId>parent</artifactId> + <groupId>org.cytoscape</groupId> + <version>3.0.0-beta2-SNAPSHOT</version> + <relativePath>../parent</relativePath> + </parent> + + <artifactId>functional-testing</artifactId> + <version>3.0.0-alpha9-SNAPSHOT</version> + <name>Cytoscape Functional Testing</name> + <packaging>jar</packaging> + + <properties> + <cytoscape.api.version>3.0.0-beta2-SNAPSHOT</cytoscape.api.version> + <cytoscape.support.version>3.0.0-alpha8-SNAPSHOT</cytoscape.support.version> + </properties> + + <build> + <plugins> + <plugin> + <groupId>org.apache.servicemix.tooling</groupId> + <artifactId>depends-maven-plugin</artifactId> + <version>1.2</version> + <executions> + <execution> + <id>generate-depends-file</id> + <goals> + <goal>generate-depends-file</goal> + </goals> + </execution> + </executions> + </plugin> + </plugins> + </build> + + + + <dependencies> + <dependency> + <groupId>org.openengsb.labs.paxexam.karaf</groupId> + <artifactId>paxexam-karaf-container</artifactId> + <version>1.0.0</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.ops4j.pax.exam</groupId> + <artifactId>pax-exam-junit4</artifactId> + <version>2.4.0</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>4.8.2</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.cytoscape</groupId> + <artifactId>swing-application-api</artifactId> + <version>${cytoscape.api.version}</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>cytoscape-temp</groupId> + <artifactId>uispec4j</artifactId> + <version>2.4</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.apache.karaf</groupId> + <artifactId>apache-karaf</artifactId> + <version>2.2.7</version> + <type>zip</type> + <scope>test</scope> + <exclusions> + <exclusion> + <groupId>org.apache.karaf.shell</groupId> + <artifactId>org.apache.karaf.shell.dev</artifactId> + </exclusion> + </exclusions> + </dependency> + </dependencies> +</project> Added: core3/functional-testing/trunk/src/test/java/org/cytoscape/functional/menus/BasicMenuTest.java =================================================================== --- core3/functional-testing/trunk/src/test/java/org/cytoscape/functional/menus/BasicMenuTest.java (rev 0) +++ core3/functional-testing/trunk/src/test/java/org/cytoscape/functional/menus/BasicMenuTest.java 2012-06-12 23:53:03 UTC (rev 29542) @@ -0,0 +1,110 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.cytoscape.functional.menus; + +import static junit.framework.Assert.*; +import static org.openengsb.labs.paxexam.karaf.options.KarafDistributionOption.*; +import static org.ops4j.pax.exam.CoreOptions.*; + +import javax.inject.Inject; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.ops4j.pax.exam.Option; +import org.ops4j.pax.exam.junit.Configuration; +import org.ops4j.pax.exam.junit.ExamReactorStrategy; +import org.ops4j.pax.exam.junit.JUnit4TestRunner; +import org.ops4j.pax.exam.spi.reactors.AllConfinedStagedReactorFactory; +import org.openengsb.labs.paxexam.karaf.options.LogLevelOption.LogLevel; +import org.openengsb.labs.paxexam.karaf.options.KarafDistributionConfigurationFilePutOption; + +import org.cytoscape.application.swing.CySwingApplication; + +import org.uispec4j.UISpec4J; +import org.uispec4j.Window; + +@RunWith(JUnit4TestRunner.class) +@ExamReactorStrategy(AllConfinedStagedReactorFactory.class) +public class BasicMenuTest { + + // Inject any other desired services in the same way. + @Inject + private CySwingApplication swingApp; + + @Configuration + public Option[] config() { + // Very important to initialize uispec4j before any guis are created. + UISpec4J.init(); + + return new Option[] { + karafDistributionConfiguration("mvn:org.apache.karaf/apache-karaf/2.2.7/zip", "karaf", "2.2.7"), + + // These custom properties are the same as the custom properties + // found in framework/etc/custom.properties and are needed to + // get the startlevels right. + customProperty("karaf.systemBundlesStartLevel","99"), + customProperty("karaf.startlevel.bundle","200"), + customProperty("org.osgi.framework.startlevel.beginning","200"), + customProperty("org.osgi.framework.system.packages.extra", + "org.apache.karaf.branding,org.cytoscape.launcher.internal,com.sun.xml.internal.bind,com.apple.eawt"), + + // This ensures that the pax-exam probe starts at the proper start level. + useOwnExamBundlesStartLevel(200), + + // The actual features file we're loading. + scanFeatures( + maven().groupId("org.cytoscape.distribution").artifactId("features").type("xml") + .classifier("features").version("3.0.0-M5-SNAPSHOT"), "cytoscape-gui").start(), + + // Load an OSGi-ified uispec4j jar - this makes the jar availabe to pax-exam, + // and thus the tests below. + mavenBundle().groupId("cytoscape-temp").artifactId("uispec4j").type("jar").versionAsInProject(), + }; + } + + // Utility method for setting custom properties. + private static KarafDistributionConfigurationFilePutOption customProperty(String key, String value) { + return new KarafDistributionConfigurationFilePutOption("etc/custom.properties",key,value); + } + + + // Each @Test starts a new instance of Cytoscape, so it's probably + // a good idea to do as many tests as you can on a single instance + // rather than restarting Cytoscape a bunch of times with separate + // @Test methods. + + @Test + public void test() throws Exception { + assertNotNull(swingApp); + Window mainWindow = new Window(swingApp.getJFrame()); + checkTopLevelMenus(mainWindow); + // more tests... + } + + private void checkTopLevelMenus(Window mainWindow) { + assertNotNull(mainWindow.getMenuBar().getMenu("File")); + assertNotNull(mainWindow.getMenuBar().getMenu("Edit")); + assertNotNull(mainWindow.getMenuBar().getMenu("View")); + assertNotNull(mainWindow.getMenuBar().getMenu("Select")); + assertNotNull(mainWindow.getMenuBar().getMenu("Layout")); + assertNotNull(mainWindow.getMenuBar().getMenu("Apps")); + assertNotNull(mainWindow.getMenuBar().getMenu("Tools")); + assertNotNull(mainWindow.getMenuBar().getMenu("Help")); + } + +} -- You received this message because you are subscribed to the Google Groups "cytoscape-cvs" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/cytoscape-cvs?hl=en.
