Add OSGi integration tests
This commit is contained in:
parent
c94292698a
commit
7a2805c904
15 changed files with 583 additions and 0 deletions
14
pom.xml
14
pom.xml
|
@ -21,6 +21,7 @@
|
||||||
<module>rome-fetcher</module>
|
<module>rome-fetcher</module>
|
||||||
<module>rome-modules</module>
|
<module>rome-modules</module>
|
||||||
<module>rome-opml</module>
|
<module>rome-opml</module>
|
||||||
|
<module>rome-osgi-test</module>
|
||||||
<module>rome-propono</module>
|
<module>rome-propono</module>
|
||||||
<module>rome-utils</module>
|
<module>rome-utils</module>
|
||||||
</modules>
|
</modules>
|
||||||
|
@ -133,6 +134,19 @@
|
||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-failsafe-plugin</artifactId>
|
||||||
|
<version>2.19.1</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<goals>
|
||||||
|
<goal>integration-test</goal>
|
||||||
|
<goal>verify</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</pluginManagement>
|
</pluginManagement>
|
||||||
</build>
|
</build>
|
||||||
|
|
101
rome-osgi-test/pom.xml
Normal file
101
rome-osgi-test/pom.xml
Normal file
|
@ -0,0 +1,101 @@
|
||||||
|
<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/xsd/maven-4.0.0.xsd">
|
||||||
|
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<parent>
|
||||||
|
<groupId>com.rometools</groupId>
|
||||||
|
<artifactId>rome-parent</artifactId>
|
||||||
|
<version>1.6.0-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<artifactId>rome-osgi-test</artifactId>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.rometools</groupId>
|
||||||
|
<artifactId>rome</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.rometools</groupId>
|
||||||
|
<artifactId>rome-modules</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.rometools</groupId>
|
||||||
|
<artifactId>rome-fetcher</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>junit</groupId>
|
||||||
|
<artifactId>junit</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.felix</groupId>
|
||||||
|
<artifactId>org.apache.felix.framework</artifactId>
|
||||||
|
<version>5.4.0</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.ops4j.pax.exam</groupId>
|
||||||
|
<artifactId>pax-exam-container-native</artifactId>
|
||||||
|
<version>4.8.0</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.ops4j.pax.exam</groupId>
|
||||||
|
<artifactId>pax-exam-junit4</artifactId>
|
||||||
|
<version>4.8.0</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.ops4j.pax.exam</groupId>
|
||||||
|
<artifactId>pax-exam-link-mvn</artifactId>
|
||||||
|
<version>4.8.0</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.ops4j.pax.url</groupId>
|
||||||
|
<artifactId>pax-url-wrap</artifactId>
|
||||||
|
<version>2.4.5</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-deploy-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<skip>true</skip>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-failsafe-plugin</artifactId>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-dependency-plugin</artifactId>
|
||||||
|
<version>2.10</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>copy-dependencies</id>
|
||||||
|
<phase>package</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>copy-dependencies</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<outputDirectory>${project.build.directory}/lib</outputDirectory>
|
||||||
|
<stripVersion>true</stripVersion>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</project>
|
|
@ -0,0 +1,33 @@
|
||||||
|
/*
|
||||||
|
* 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 com.rometools.rome.osgi;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
|
import com.rometools.rome.feed.synd.SyndFeed;
|
||||||
|
import com.rometools.rome.io.SyndFeedInput;
|
||||||
|
import com.rometools.rome.io.XmlReader;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
public class CoreIT {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void test() throws Exception {
|
||||||
|
final XmlReader reader = new XmlReader(getClass().getResourceAsStream("core.xml"));
|
||||||
|
final SyndFeed feed = new SyndFeedInput().build(reader);
|
||||||
|
assertEquals("test-title", feed.getTitle());
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,36 @@
|
||||||
|
/*
|
||||||
|
* 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 com.rometools.rome.osgi;
|
||||||
|
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.ops4j.pax.exam.Configuration;
|
||||||
|
import org.ops4j.pax.exam.CoreOptions;
|
||||||
|
import org.ops4j.pax.exam.Option;
|
||||||
|
import org.ops4j.pax.exam.junit.PaxExam;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.net.URISyntaxException;
|
||||||
|
|
||||||
|
@RunWith(PaxExam.class)
|
||||||
|
public class CoreOsgiIT extends CoreIT {
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
public Option[] configuration() throws IOException, URISyntaxException {
|
||||||
|
return CoreOptions.options(
|
||||||
|
CoreOptions.junitBundles(),
|
||||||
|
CoreOptions.wrappedBundle("file:target/lib/jdom2.jar"),
|
||||||
|
CoreOptions.bundle("file:target/lib/rome.jar"));
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,70 @@
|
||||||
|
/*
|
||||||
|
* 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 com.rometools.rome.osgi;
|
||||||
|
|
||||||
|
import com.rometools.rome.feed.CopyFrom;
|
||||||
|
import com.rometools.rome.feed.module.Module;
|
||||||
|
import com.rometools.rome.io.ModuleParser;
|
||||||
|
|
||||||
|
import org.jdom2.Element;
|
||||||
|
import org.jdom2.Namespace;
|
||||||
|
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
|
public class CustomModule implements Module {
|
||||||
|
|
||||||
|
public static final String URI = "http://example.org";
|
||||||
|
|
||||||
|
private String title;
|
||||||
|
|
||||||
|
public CustomModule(String title) {
|
||||||
|
this.title = title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTitle() {
|
||||||
|
return title;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getUri() {
|
||||||
|
return URI;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Class<? extends CopyFrom> getInterface() {
|
||||||
|
return getClass();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void copyFrom(CopyFrom obj) {
|
||||||
|
title = ((CustomModule) obj).title;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object clone() throws CloneNotSupportedException {
|
||||||
|
return super.clone();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Parser implements ModuleParser {
|
||||||
|
|
||||||
|
public String getNamespaceUri() {
|
||||||
|
return URI;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Module parse(Element element, Locale locale) {
|
||||||
|
return new CustomModule(element.getChildText("title", Namespace.getNamespace(getNamespaceUri())));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,38 @@
|
||||||
|
/*
|
||||||
|
* 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 com.rometools.rome.osgi;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertNotNull;
|
||||||
|
|
||||||
|
import com.rometools.rome.feed.synd.SyndFeed;
|
||||||
|
import com.rometools.rome.io.SyndFeedInput;
|
||||||
|
import com.rometools.rome.io.XmlReader;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
public class CustomModuleIT {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testCustomModule() throws Exception {
|
||||||
|
final XmlReader reader = new XmlReader(getClass().getResourceAsStream("custom-module.xml"));
|
||||||
|
final SyndFeed feed = new SyndFeedInput().build(reader);
|
||||||
|
|
||||||
|
final CustomModule customModule = (CustomModule) feed.getModule(CustomModule.URI);
|
||||||
|
|
||||||
|
assertNotNull(customModule);
|
||||||
|
assertEquals("test-title", customModule.getTitle());
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,113 @@
|
||||||
|
/*
|
||||||
|
* 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 com.rometools.rome.osgi;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertNotNull;
|
||||||
|
import static org.junit.Assert.assertNull;
|
||||||
|
|
||||||
|
import com.rometools.rome.feed.impl.ConfigurableClassLoader;
|
||||||
|
import com.rometools.rome.feed.synd.SyndFeed;
|
||||||
|
import com.rometools.rome.io.SyndFeedInput;
|
||||||
|
import com.rometools.rome.io.XmlReader;
|
||||||
|
|
||||||
|
import org.junit.Rule;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.rules.ExpectedException;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.ops4j.pax.exam.Configuration;
|
||||||
|
import org.ops4j.pax.exam.CoreOptions;
|
||||||
|
import org.ops4j.pax.exam.Option;
|
||||||
|
import org.ops4j.pax.exam.junit.PaxExam;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.net.URISyntaxException;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.util.Enumeration;
|
||||||
|
|
||||||
|
@RunWith(PaxExam.class)
|
||||||
|
public class CustomModuleOsgiIT {
|
||||||
|
|
||||||
|
@Rule
|
||||||
|
public ExpectedException expectedException = ExpectedException.none();
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
public Option[] configuration() throws IOException, URISyntaxException {
|
||||||
|
return CoreOptions.options(
|
||||||
|
CoreOptions.junitBundles(),
|
||||||
|
CoreOptions.wrappedBundle("file:target/lib/jdom2.jar"),
|
||||||
|
CoreOptions.bundle("file:target/lib/rome.jar"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testDefaultClassLoader() throws Exception {
|
||||||
|
final XmlReader reader = new XmlReader(getClass().getResourceAsStream("custom-module.xml"));
|
||||||
|
final SyndFeed feed = new SyndFeedInput().build(reader);
|
||||||
|
|
||||||
|
final CustomModule customModule = (CustomModule) feed.getModule(CustomModule.URI);
|
||||||
|
|
||||||
|
assertNull(customModule);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testConfigurableClassLoader() throws Exception {
|
||||||
|
ConfigurableClassLoader.INSTANCE.setClassLoader(getClass().getClassLoader());
|
||||||
|
|
||||||
|
expectedException.expect(ExceptionInInitializerError.class);
|
||||||
|
|
||||||
|
final XmlReader reader = new XmlReader(getClass().getResourceAsStream("custom-module.xml"));
|
||||||
|
new SyndFeedInput().build(reader);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testConfigurableCompositeClassLoader() throws Exception {
|
||||||
|
final ClassLoader thisClassLoader = getClass().getClassLoader();
|
||||||
|
final ClassLoader romeClassLoader = ConfigurableClassLoader.INSTANCE.getClassLoader();
|
||||||
|
ConfigurableClassLoader.INSTANCE.setClassLoader(new CompositeClassLoader(thisClassLoader, romeClassLoader));
|
||||||
|
|
||||||
|
final XmlReader reader = new XmlReader(getClass().getResourceAsStream("custom-module.xml"));
|
||||||
|
final SyndFeed feed = new SyndFeedInput().build(reader);
|
||||||
|
|
||||||
|
final CustomModule customModule = (CustomModule) feed.getModule(CustomModule.URI);
|
||||||
|
|
||||||
|
assertNotNull(customModule);
|
||||||
|
assertEquals("test-title", customModule.getTitle());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class CompositeClassLoader extends ClassLoader {
|
||||||
|
|
||||||
|
private ClassLoader delegate;
|
||||||
|
|
||||||
|
public CompositeClassLoader(ClassLoader delegate, ClassLoader parent) {
|
||||||
|
super(parent);
|
||||||
|
this.delegate = delegate;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected final Class<?> findClass(String name) throws ClassNotFoundException {
|
||||||
|
return delegate.loadClass(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected final URL findResource(String name) {
|
||||||
|
return delegate.getResource(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected final Enumeration<URL> findResources(String name) throws IOException {
|
||||||
|
return delegate.getResources(name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,39 @@
|
||||||
|
/*
|
||||||
|
* 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 com.rometools.rome.osgi;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
|
import com.rometools.fetcher.FeedFetcher;
|
||||||
|
import com.rometools.fetcher.impl.FeedFetcherCache;
|
||||||
|
import com.rometools.fetcher.impl.HashMapFeedInfoCache;
|
||||||
|
import com.rometools.fetcher.impl.HttpURLFeedFetcher;
|
||||||
|
import com.rometools.rome.feed.synd.SyndFeed;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import java.net.URL;
|
||||||
|
|
||||||
|
public class FetcherIT {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void test() throws Exception {
|
||||||
|
FeedFetcherCache cache = HashMapFeedInfoCache.getInstance();
|
||||||
|
FeedFetcher fetcher = new HttpURLFeedFetcher(cache);
|
||||||
|
SyndFeed feed = fetcher.retrieveFeed(new URL("http://www.w3.org/blog/news/feed/atom"));
|
||||||
|
|
||||||
|
assertEquals("W3C News", feed.getTitle());
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,37 @@
|
||||||
|
/*
|
||||||
|
* 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 com.rometools.rome.osgi;
|
||||||
|
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.ops4j.pax.exam.Configuration;
|
||||||
|
import org.ops4j.pax.exam.CoreOptions;
|
||||||
|
import org.ops4j.pax.exam.Option;
|
||||||
|
import org.ops4j.pax.exam.junit.PaxExam;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.net.URISyntaxException;
|
||||||
|
|
||||||
|
@RunWith(PaxExam.class)
|
||||||
|
public class FetcherOsgiIT extends FetcherIT {
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
public Option[] configuration() throws IOException, URISyntaxException {
|
||||||
|
return CoreOptions.options(
|
||||||
|
CoreOptions.junitBundles(),
|
||||||
|
CoreOptions.wrappedBundle("file:target/lib/jdom2.jar"),
|
||||||
|
CoreOptions.bundle("file:target/lib/rome.jar"),
|
||||||
|
CoreOptions.bundle("file:target/lib/rome-fetcher.jar"));
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,47 @@
|
||||||
|
/*
|
||||||
|
* 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 com.rometools.rome.osgi;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertNotNull;
|
||||||
|
|
||||||
|
import com.rometools.modules.itunes.FeedInformation;
|
||||||
|
import com.rometools.modules.itunes.ITunes;
|
||||||
|
import com.rometools.rome.feed.synd.SyndFeed;
|
||||||
|
import com.rometools.rome.io.SyndFeedInput;
|
||||||
|
import com.rometools.rome.io.XmlReader;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.ops4j.pax.exam.Configuration;
|
||||||
|
import org.ops4j.pax.exam.CoreOptions;
|
||||||
|
import org.ops4j.pax.exam.Option;
|
||||||
|
import org.ops4j.pax.exam.junit.PaxExam;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.net.URISyntaxException;
|
||||||
|
|
||||||
|
public class ModulesIT {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void test() throws Exception {
|
||||||
|
final XmlReader reader = new XmlReader(getClass().getResourceAsStream("modules.xml"));
|
||||||
|
final SyndFeed feed = new SyndFeedInput().build(reader);
|
||||||
|
final FeedInformation itunes = (FeedInformation) feed.getModule(ITunes.URI);
|
||||||
|
|
||||||
|
assertNotNull(itunes);
|
||||||
|
assertEquals("test-author", itunes.getAuthor());
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,36 @@
|
||||||
|
/*
|
||||||
|
* 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 com.rometools.rome.osgi;
|
||||||
|
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.ops4j.pax.exam.Configuration;
|
||||||
|
import org.ops4j.pax.exam.CoreOptions;
|
||||||
|
import org.ops4j.pax.exam.Option;
|
||||||
|
import org.ops4j.pax.exam.junit.PaxExam;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.net.URISyntaxException;
|
||||||
|
|
||||||
|
@RunWith(PaxExam.class)
|
||||||
|
public class ModulesOsgiIT extends ModulesIT {
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
public Option[] configuration() throws IOException, URISyntaxException {
|
||||||
|
return CoreOptions.options(
|
||||||
|
CoreOptions.junitBundles(),
|
||||||
|
CoreOptions.wrappedBundle("file:target/lib/jdom2.jar"),
|
||||||
|
CoreOptions.bundle("file:target/lib/rome-modules.jar"));
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,6 @@
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
<rss version="2.0">
|
||||||
|
<channel>
|
||||||
|
<title>test-title</title>
|
||||||
|
</channel>
|
||||||
|
</rss>
|
|
@ -0,0 +1,6 @@
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
<rss version="2.0" xmlns:custom="http://example.org">
|
||||||
|
<channel>
|
||||||
|
<custom:title>test-title</custom:title>
|
||||||
|
</channel>
|
||||||
|
</rss>
|
|
@ -0,0 +1,6 @@
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
<rss version="2.0" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd">
|
||||||
|
<channel>
|
||||||
|
<itunes:author>test-author</itunes:author>
|
||||||
|
</channel>
|
||||||
|
</rss>
|
1
rome-osgi-test/src/test/resources/rome.properties
Normal file
1
rome-osgi-test/src/test/resources/rome.properties
Normal file
|
@ -0,0 +1 @@
|
||||||
|
rss_2.0.feed.ModuleParser.classes=com.rometools.rome.osgi.CustomModule$Parser
|
Loading…
Reference in a new issue