You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by ak...@apache.org on 2006/08/17 08:43:45 UTC
svn commit: r432166 - in /incubator/felix/sandbox/akarasulu/itest: ./
maven-felix-integration/ maven-felix-integration/src/
maven-felix-integration/src/main/ maven-felix-integration/src/main/java/
maven-felix-integration/src/main/java/org/ maven-felix-...
Author: akarasulu
Date: Wed Aug 16 23:43:44 2006
New Revision: 432166
URL: http://svn.apache.org/viewvc?rev=432166&view=rev
Log:
simple test mojo for running felix for integration tests
Added:
incubator/felix/sandbox/akarasulu/itest/
incubator/felix/sandbox/akarasulu/itest/maven-felix-integration/ (with props)
incubator/felix/sandbox/akarasulu/itest/maven-felix-integration/.project
incubator/felix/sandbox/akarasulu/itest/maven-felix-integration/pom.xml
incubator/felix/sandbox/akarasulu/itest/maven-felix-integration/src/
incubator/felix/sandbox/akarasulu/itest/maven-felix-integration/src/main/
incubator/felix/sandbox/akarasulu/itest/maven-felix-integration/src/main/java/
incubator/felix/sandbox/akarasulu/itest/maven-felix-integration/src/main/java/org/
incubator/felix/sandbox/akarasulu/itest/maven-felix-integration/src/main/java/org/apache/
incubator/felix/sandbox/akarasulu/itest/maven-felix-integration/src/main/java/org/apache/felix/
incubator/felix/sandbox/akarasulu/itest/maven-felix-integration/src/main/java/org/apache/felix/integration/
incubator/felix/sandbox/akarasulu/itest/maven-felix-integration/src/main/java/org/apache/felix/integration/FelixIntegrationMojo.java
incubator/felix/sandbox/akarasulu/itest/pom.xml
incubator/felix/sandbox/akarasulu/itest/simple-service/ (with props)
incubator/felix/sandbox/akarasulu/itest/simple-service/pom.xml
incubator/felix/sandbox/akarasulu/itest/simple-service/src/
incubator/felix/sandbox/akarasulu/itest/simple-service/src/main/
incubator/felix/sandbox/akarasulu/itest/simple-service/src/main/java/
incubator/felix/sandbox/akarasulu/itest/simple-service/src/main/java/org/
incubator/felix/sandbox/akarasulu/itest/simple-service/src/main/java/org/apache/
incubator/felix/sandbox/akarasulu/itest/simple-service/src/main/java/org/apache/felix/
incubator/felix/sandbox/akarasulu/itest/simple-service/src/main/java/org/apache/felix/integration/
incubator/felix/sandbox/akarasulu/itest/simple-service/src/main/java/org/apache/felix/integration/test/
incubator/felix/sandbox/akarasulu/itest/simple-service/src/main/java/org/apache/felix/integration/test/service/
incubator/felix/sandbox/akarasulu/itest/simple-service/src/main/java/org/apache/felix/integration/test/service/DictionaryService.java
incubator/felix/sandbox/akarasulu/itest/simple-service/src/main/java/org/apache/felix/integration/test/service/impl/
incubator/felix/sandbox/akarasulu/itest/simple-service/src/main/java/org/apache/felix/integration/test/service/impl/Activator.java
incubator/felix/sandbox/akarasulu/itest/simple-test/ (with props)
incubator/felix/sandbox/akarasulu/itest/simple-test/pom.xml
incubator/felix/sandbox/akarasulu/itest/simple-test/src/
incubator/felix/sandbox/akarasulu/itest/simple-test/src/main/
incubator/felix/sandbox/akarasulu/itest/simple-test/src/main/java/
incubator/felix/sandbox/akarasulu/itest/simple-test/src/main/java/org/
incubator/felix/sandbox/akarasulu/itest/simple-test/src/main/java/org/apache/
incubator/felix/sandbox/akarasulu/itest/simple-test/src/main/java/org/apache/felix/
incubator/felix/sandbox/akarasulu/itest/simple-test/src/main/java/org/apache/felix/integration/
incubator/felix/sandbox/akarasulu/itest/simple-test/src/main/java/org/apache/felix/integration/test/
incubator/felix/sandbox/akarasulu/itest/simple-test/src/main/java/org/apache/felix/integration/test/Activator.java
Propchange: incubator/felix/sandbox/akarasulu/itest/maven-felix-integration/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Wed Aug 16 23:43:44 2006
@@ -0,0 +1,6 @@
+.classpath
+.project
+.settings
+*.log
+target
+
Added: incubator/felix/sandbox/akarasulu/itest/maven-felix-integration/.project
URL: http://svn.apache.org/viewvc/incubator/felix/sandbox/akarasulu/itest/maven-felix-integration/.project?rev=432166&view=auto
==============================================================================
--- incubator/felix/sandbox/akarasulu/itest/maven-felix-integration/.project (added)
+++ incubator/felix/sandbox/akarasulu/itest/maven-felix-integration/.project Wed Aug 16 23:43:44 2006
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>maven-felix-integration</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
Added: incubator/felix/sandbox/akarasulu/itest/maven-felix-integration/pom.xml
URL: http://svn.apache.org/viewvc/incubator/felix/sandbox/akarasulu/itest/maven-felix-integration/pom.xml?rev=432166&view=auto
==============================================================================
--- incubator/felix/sandbox/akarasulu/itest/maven-felix-integration/pom.xml (added)
+++ incubator/felix/sandbox/akarasulu/itest/maven-felix-integration/pom.xml Wed Aug 16 23:43:44 2006
@@ -0,0 +1,37 @@
+<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>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-felix-integration</artifactId>
+ <packaging>maven-plugin</packaging>
+ <version>1.0-SNAPSHOT</version>
+ <name>Maven Felix Integration Plugin</name>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-project</artifactId>
+ <version>2.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-plugin-api</artifactId>
+ <version>2.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.framework</artifactId>
+ <version>0.8.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.osgi.core</artifactId>
+ <version>0.8.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+</project>
Added: incubator/felix/sandbox/akarasulu/itest/maven-felix-integration/src/main/java/org/apache/felix/integration/FelixIntegrationMojo.java
URL: http://svn.apache.org/viewvc/incubator/felix/sandbox/akarasulu/itest/maven-felix-integration/src/main/java/org/apache/felix/integration/FelixIntegrationMojo.java?rev=432166&view=auto
==============================================================================
--- incubator/felix/sandbox/akarasulu/itest/maven-felix-integration/src/main/java/org/apache/felix/integration/FelixIntegrationMojo.java (added)
+++ incubator/felix/sandbox/akarasulu/itest/maven-felix-integration/src/main/java/org/apache/felix/integration/FelixIntegrationMojo.java Wed Aug 16 23:43:44 2006
@@ -0,0 +1,124 @@
+package org.apache.felix.integration;
+
+
+import java.io.File;
+import java.net.MalformedURLException;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.Properties;
+
+import org.apache.felix.framework.Felix;
+import org.apache.felix.framework.util.MutablePropertyResolver;
+import org.apache.felix.framework.util.MutablePropertyResolverImpl;
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.project.MavenProject;
+
+
+/**
+ * Starts up Felix, installs this module's bundle artifact with dependent
+ * bundles, and starts them.
+ *
+ * @goal test
+ * @phase integration-test
+ */
+public class FelixIntegrationMojo extends AbstractMojo
+{
+ /**
+ * The name of the felix cache profile.
+ *
+ * @parameter expression=â${test.felix.cache.profile}â default-value="test"
+ * @description the felix.cache.profile property value
+ */
+ private String felixCacheProfile;
+
+ /**
+ * The location of the felix bundle cache directory.
+ *
+ * @parameter expression=â${test.felix.cache.dir}â default-value="${basedir}/target/.felix"
+ * @description the felix.cache.dir property value
+ */
+ private File felixCacheDir;
+
+ /**
+ * The location of the test bundle.
+ *
+ * @parameter expression="${test.felix.test.bundle}"
+ * default-value="${basedir}/target/${project.artifactId}-${project.version}.jar"
+ */
+ private File felixTestBundle;
+
+ /**
+ * @parameter default-value="${project}"
+ */
+ private MavenProject project;
+
+ /**
+ * The felix container used to run the integration tests.
+ */
+ private Felix felixContainer = new Felix();
+
+
+ public void execute() throws MojoExecutionException, MojoFailureException
+ {
+ getLog().info( "felix.cache.dir=" + felixCacheDir.getAbsolutePath() );
+
+ Properties props = new Properties();
+ props.put( "felix.cache.dir", felixCacheDir.getAbsolutePath() );
+ props.put( "felix.cache.profile", felixCacheProfile );
+ props.put( "felix.embedded.execution", "true" );
+ props.put( "org.osgi.framework.system.packages",
+ "org.osgi.framework; version=1.3.0, " +
+ "org.osgi.service.packageadmin; version=1.2.0, " +
+ "org.osgi.service.startlevel; version=1.0.0, " +
+ "org.osgi.service.url; version=1.0.0, " +
+ "${jre-${java.specification.version}}" );
+ try
+ {
+ props.put( "felix.auto.start.1", getAutoStart() );
+ }
+ catch ( MalformedURLException e )
+ {
+ e.printStackTrace();
+ }
+
+ MutablePropertyResolver resolver = new MutablePropertyResolverImpl(props);
+
+ felixContainer.start( resolver, new ArrayList() );
+
+ getLog().info( "-=============================-" );
+ getLog().info( "| Felix: successfully started |" );
+ getLog().info( "-=============================-" );
+
+ felixContainer.shutdown();
+
+ getLog().info( "-==============================-" );
+ getLog().info( "| Felix: successfully shutdown |" );
+ getLog().info( "-==============================-" );
+ }
+
+
+ public String getAutoStart() throws MalformedURLException
+ {
+ StringBuffer buf = new StringBuffer();
+ for ( Iterator ii = project.getDependencyArtifacts().iterator(); ii.hasNext(); /**/)
+ {
+ Artifact dep = ( Artifact ) ii.next();
+ if ( dep.getScope().equalsIgnoreCase( "provided" ) )
+ {
+ if ( dep.getArtifactId().equalsIgnoreCase( "org.osgi.core" ) )
+ {
+ continue;
+ }
+
+ buf.append( dep.getFile().toURL() );
+ buf.append( " " );
+ }
+ }
+
+ buf.append( felixTestBundle.toURL() );
+ return buf.toString();
+ }
+}
Added: incubator/felix/sandbox/akarasulu/itest/pom.xml
URL: http://svn.apache.org/viewvc/incubator/felix/sandbox/akarasulu/itest/pom.xml?rev=432166&view=auto
==============================================================================
--- incubator/felix/sandbox/akarasulu/itest/pom.xml (added)
+++ incubator/felix/sandbox/akarasulu/itest/pom.xml Wed Aug 16 23:43:44 2006
@@ -0,0 +1,98 @@
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>itest</artifactId>
+ <packaging>pom</packaging>
+ <name>Apache Felix ITest (parent)</name>
+ <version>0.8.0-SNAPSHOT</version>
+ <modules>
+ <module>maven-felix-integration</module>
+ <module>simple-service</module>
+ <module>simple-test</module>
+ </modules>
+
+ <repositories>
+ <!-- For snapshots (no release jars or non-apache jars) -->
+ <repository>
+ <id>apache.snapshots</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://cvs.apache.org/maven-snapshot-repository</url>
+ </repository>
+
+ <repository>
+ <id>safehaus</id>
+ <name>Alternate Repository for Missing Ibiblio Artifacts</name>
+ <url>http://m2.safehaus.org</url>
+ </repository>
+ </repositories>
+
+ <distributionManagement>
+ <snapshotRepository>
+ <name>Apache Snapshots</name>
+ <id>apache.snapshots</id>
+ <url>
+ scp://apache.org/www/cvs.apache.org/maven-snapshot-repository
+ </url>
+ </snapshotRepository>
+ <repository>
+ <name>ASF Mirrored M2 Distributions</name>
+ <id>apache.distributions</id>
+ <url>
+ scp://minotaur.apache.org/www/www.apache.org/dist/maven-repository
+ </url>
+ </repository>
+ </distributionManagement>
+
+ <pluginRepositories>
+ <pluginRepository>
+ <id>apache.snapshots</id>
+ <name>snapshot plugins</name>
+ <url>
+ http://cvs.apache.org/maven-snapshot-repository
+ </url>
+ </pluginRepository>
+ </pluginRepositories>
+
+ <!-- definitions for testing -->
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8.1</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>easymock</groupId>
+ <artifactId>easymock</artifactId>
+ <version>1.2_Java1.3</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <target>1.4</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-report-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
+ <reporting>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-project-info-reports-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </reporting>
+</project>
Propchange: incubator/felix/sandbox/akarasulu/itest/simple-service/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Wed Aug 16 23:43:44 2006
@@ -0,0 +1,6 @@
+.classpath
+.project
+.settings
+*.log
+target
+
Added: incubator/felix/sandbox/akarasulu/itest/simple-service/pom.xml
URL: http://svn.apache.org/viewvc/incubator/felix/sandbox/akarasulu/itest/simple-service/pom.xml?rev=432166&view=auto
==============================================================================
--- incubator/felix/sandbox/akarasulu/itest/simple-service/pom.xml (added)
+++ incubator/felix/sandbox/akarasulu/itest/simple-service/pom.xml Wed Aug 16 23:43:44 2006
@@ -0,0 +1,41 @@
+<project>
+ <parent>
+ <artifactId>build</artifactId>
+ <groupId>org.apache.felix</groupId>
+ <version>0.8.0-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <packaging>osgi-bundle</packaging>
+ <name>Simple Felix Example Service</name>
+ <artifactId>simple-service</artifactId>
+ <dependencies>
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix.plugins</groupId>
+ <artifactId>maven-osgi-plugin</artifactId>
+ <version>0.8.0-SNAPSHOT</version>
+ <extensions>true</extensions>
+ <configuration>
+ <osgiManifest>
+ <bundleName>Felix Simple Example Service</bundleName>
+ <bundleVendor>Apache Software Foundation</bundleVendor>
+ <bundleDescription>
+ A bundle that registersan English dictionary service.
+ </bundleDescription>
+ <bundleActivator>
+ org.apache.felix.integration.test.service.impl.Activator
+ </bundleActivator>
+ <exportPackage>
+ org.apache.felix.integration.test.service
+ </exportPackage>
+ <importPackage>
+ org.osgi.framework
+ </importPackage>
+ </osgiManifest>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
Added: incubator/felix/sandbox/akarasulu/itest/simple-service/src/main/java/org/apache/felix/integration/test/service/DictionaryService.java
URL: http://svn.apache.org/viewvc/incubator/felix/sandbox/akarasulu/itest/simple-service/src/main/java/org/apache/felix/integration/test/service/DictionaryService.java?rev=432166&view=auto
==============================================================================
--- incubator/felix/sandbox/akarasulu/itest/simple-service/src/main/java/org/apache/felix/integration/test/service/DictionaryService.java (added)
+++ incubator/felix/sandbox/akarasulu/itest/simple-service/src/main/java/org/apache/felix/integration/test/service/DictionaryService.java Wed Aug 16 23:43:44 2006
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2006 The Apache Software Foundation
+ *
+ * Licensed 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.apache.felix.integration.test.service;
+
+
+/**
+ * A simple service interface that defines a dictionary service. A dictionary
+ * service simply verifies the existence of a word.
+ *
+ * @author <a href="mailto:felix-dev@incubator.apache.org">Felix Project Team</a>
+ */
+public interface DictionaryService
+{
+ /**
+ * Check for the existence of a word.
+ *
+ * @param word the word to be checked.
+ * @return true if the word is in the dictionary, false otherwise.
+ */
+ public boolean checkWord( String word );
+
+}
Added: incubator/felix/sandbox/akarasulu/itest/simple-service/src/main/java/org/apache/felix/integration/test/service/impl/Activator.java
URL: http://svn.apache.org/viewvc/incubator/felix/sandbox/akarasulu/itest/simple-service/src/main/java/org/apache/felix/integration/test/service/impl/Activator.java?rev=432166&view=auto
==============================================================================
--- incubator/felix/sandbox/akarasulu/itest/simple-service/src/main/java/org/apache/felix/integration/test/service/impl/Activator.java (added)
+++ incubator/felix/sandbox/akarasulu/itest/simple-service/src/main/java/org/apache/felix/integration/test/service/impl/Activator.java Wed Aug 16 23:43:44 2006
@@ -0,0 +1,95 @@
+/*
+ * Copyright 2006 The Apache Software Foundation
+ *
+ * Licensed 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.apache.felix.integration.test.service.impl;
+
+
+import java.util.Properties;
+
+import org.apache.felix.integration.test.service.DictionaryService;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+
+
+/**
+ * This class implements a simple bundle that uses the bundle context to
+ * register an English language dictionary service with the OSGi framework. The
+ * dictionary service interface is defined in a separate class file and is
+ * implemented by an inner class.
+ *
+ * @author <a href="mailto:felix-dev@incubator.apache.org">Felix Project Team</a>
+ */
+public class Activator implements BundleActivator
+{
+ /**
+ * Implements BundleActivator.start(). Registers an instance of a dictionary
+ * service using the bundle context; attaches properties to the service that
+ * can be queried when performing a service look-up.
+ *
+ * @param context the framework context for the bundle.
+ */
+ public void start( BundleContext context )
+ {
+ Properties props = new Properties();
+ props.put( "Language", "English" );
+ context.registerService( DictionaryService.class.getName(), new DictionaryImpl(), props );
+ }
+
+
+ /**
+ * Implements BundleActivator.stop(). Does nothing since the framework will
+ * automatically unregister any registered services.
+ *
+ * @param context the framework context for the bundle.
+ */
+ public void stop( BundleContext context )
+ {
+ // NOTE: The service is automatically unregistered.
+ }
+
+
+ /**
+ * A private inner class that implements a dictionary service; see
+ * DictionaryService for details of the service.
+ */
+ private static class DictionaryImpl implements DictionaryService
+ {
+ // The set of words contained in the dictionary.
+ String[] m_dictionary = { "welcome", "to", "the", "osgi", "tutorial" };
+
+ /**
+ * Implements DictionaryService.checkWord(). Determines if the passed in
+ * word is contained in the dictionary.
+ *
+ * @param word the word to be checked.
+ * @return true if the word is in the dictionary, false otherwise.
+ */
+ public boolean checkWord( String word )
+ {
+ word = word.toLowerCase();
+
+ // This is very inefficient
+ for ( int i = 0; i < m_dictionary.length; i++ )
+ {
+ if ( m_dictionary[i].equals( word ) )
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+ }
+}
Propchange: incubator/felix/sandbox/akarasulu/itest/simple-test/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Wed Aug 16 23:43:44 2006
@@ -0,0 +1,5 @@
+.classpath
+.project
+.settings
+*.log
+target
Added: incubator/felix/sandbox/akarasulu/itest/simple-test/pom.xml
URL: http://svn.apache.org/viewvc/incubator/felix/sandbox/akarasulu/itest/simple-test/pom.xml?rev=432166&view=auto
==============================================================================
--- incubator/felix/sandbox/akarasulu/itest/simple-test/pom.xml (added)
+++ incubator/felix/sandbox/akarasulu/itest/simple-test/pom.xml Wed Aug 16 23:43:44 2006
@@ -0,0 +1,60 @@
+<project>
+ <parent>
+ <artifactId>build</artifactId>
+ <groupId>org.apache.felix</groupId>
+ <version>0.8.0-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <packaging>osgi-bundle</packaging>
+ <name>Simple Felix Integration Test</name>
+ <artifactId>simple-test</artifactId>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>simple-service</artifactId>
+ <version>0.8.0-SNAPSHOT</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-felix-integration</artifactId>
+ <executions>
+ <execution>
+ <id>test</id>
+ <configuration>
+ <felixCacheDir>${basedir}/target/.felix</felixCacheDir>
+ </configuration>
+ <goals>
+ <goal>test</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.felix.plugins</groupId>
+ <artifactId>maven-osgi-plugin</artifactId>
+ <version>0.8.0-SNAPSHOT</version>
+ <extensions>true</extensions>
+ <configuration>
+ <osgiManifest>
+ <bundleName>Dictionary Client Example</bundleName>
+ <bundleVendor>Apache Software Foundation</bundleVendor>
+ <bundleDescription>
+ A bundle using the dictionary service if it finds it at startup.
+ </bundleDescription>
+ <bundleActivator>
+ org.apache.felix.integration.test.Activator
+ </bundleActivator>
+ <importPackage>
+ org.osgi.framework, org.apache.felix.integration.test.service
+ </importPackage>
+ </osgiManifest>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
Added: incubator/felix/sandbox/akarasulu/itest/simple-test/src/main/java/org/apache/felix/integration/test/Activator.java
URL: http://svn.apache.org/viewvc/incubator/felix/sandbox/akarasulu/itest/simple-test/src/main/java/org/apache/felix/integration/test/Activator.java?rev=432166&view=auto
==============================================================================
--- incubator/felix/sandbox/akarasulu/itest/simple-test/src/main/java/org/apache/felix/integration/test/Activator.java (added)
+++ incubator/felix/sandbox/akarasulu/itest/simple-test/src/main/java/org/apache/felix/integration/test/Activator.java Wed Aug 16 23:43:44 2006
@@ -0,0 +1,118 @@
+/*
+ * Copyright 2006 The Apache Software Foundation
+ *
+ * Licensed 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.apache.felix.integration.test;
+
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+
+import org.apache.felix.integration.test.service.DictionaryService;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+
+
+/**
+ * This class implements a bundle that uses a dictionary service to check for
+ * the proper spelling of a word by check for its existence in the dictionary.
+ * This bundle uses the first service that it finds and does not monitor the
+ * dynamic availability of the service (i.e., it does not listen for the arrival
+ * or departure of dictionary services). When starting this bundle, the thread
+ * calling the start() method is used to read words from standard input. You can
+ * stop checking words by entering an empty line, but to start checking words
+ * again you must stop and then restart the bundle.
+ *
+ * @author <a href="mailto:felix-dev@incubator.apache.org">Felix Project Team</a>
+ */
+public class Activator implements BundleActivator
+{
+ /**
+ * Implements BundleActivator.start(). Queries for all available dictionary
+ * services. If none are found it simply prints a message and returns,
+ * otherwise it reads words from standard input and checks for their
+ * existence from the first dictionary that it finds. (NOTE: It is very bad
+ * practice to use the calling thread to perform a lengthy process like
+ * this; this is only done for the purpose of the tutorial.)
+ *
+ * @param context the framework context for the bundle.
+ */
+ public void start( BundleContext context ) throws Exception
+ {
+ // Query for all service references matching any language.
+ ServiceReference[] refs = context.getServiceReferences( DictionaryService.class.getName(), "(Language=*)" );
+
+ if ( refs != null )
+ {
+ try
+ {
+ System.out.println( "Enter a blank line to exit." );
+ BufferedReader in = new BufferedReader( new InputStreamReader( System.in ) );
+ String word = "";
+
+ // Loop endlessly.
+ while ( true )
+ {
+ // Ask the user to enter a word.
+ System.out.print( "Enter word: " );
+ word = in.readLine();
+
+ // If the user entered a blank line, then
+ // exit the loop.
+ if ( word.length() == 0 )
+ {
+ break;
+ }
+
+ // First, get a dictionary service and then check
+ // if the word is correct.
+ DictionaryService dictionary = ( DictionaryService ) context.getService( refs[0] );
+ if ( dictionary.checkWord( word ) )
+ {
+ System.out.println( "Correct." );
+ }
+ else
+ {
+ System.out.println( "Incorrect." );
+ }
+
+ // Unget the dictionary service.
+ context.ungetService( refs[0] );
+ }
+ }
+ catch ( IOException ex )
+ {
+ }
+ }
+ else
+ {
+ System.out.println( "Couldn't find any dictionary service..." );
+ }
+ }
+
+
+ /**
+ * Implements BundleActivator.stop(). Does nothing since the framework will
+ * automatically unget any used services.
+ *
+ * @param context the framework context for the bundle.
+ */
+ public void stop( BundleContext context )
+ {
+ // NOTE: The service is automatically released.
+ }
+}