Formatted code
Updated POM
This commit is contained in:
parent
9e24592ef3
commit
14696ebed0
19 changed files with 803 additions and 887 deletions
275
pom.xml
275
pom.xml
|
@ -1,26 +1,34 @@
|
||||||
|
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
<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">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||||
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
<groupId>org.rometools</groupId>
|
<groupId>org.rometools</groupId>
|
||||||
<artifactId>rome-opml</artifactId>
|
<artifactId>rome-opml</artifactId>
|
||||||
<packaging>jar</packaging>
|
<version>2.0.0-SNAPSHOT</version>
|
||||||
<version>1.5-SNAPSHOT</version>
|
|
||||||
<name>rome-opml</name>
|
<name>rome-opml</name>
|
||||||
|
|
||||||
<url>http://rometools.github.io/rome-opml/</url>
|
<url>http://rometools.github.io/rome-opml/</url>
|
||||||
|
|
||||||
<description>Support for OPML 1 and OPML 2 in ROME</description>
|
<description>Support for OPML 1 and OPML 2 in ROME</description>
|
||||||
|
|
||||||
<organization>
|
<organization>
|
||||||
<name>ROME Project</name>
|
<name>ROME Project</name>
|
||||||
<url>https://github.com/rometools/</url>
|
<url>https://github.com/rometools/</url>
|
||||||
</organization>
|
</organization>
|
||||||
|
|
||||||
<issueManagement>
|
<issueManagement>
|
||||||
<url>https://github.com/rometools/rome-opml/issues</url>
|
<url>https://github.com/rometools/rome-opml/issues</url>
|
||||||
</issueManagement>
|
</issueManagement>
|
||||||
|
|
||||||
<scm>
|
<scm>
|
||||||
<connection>scm:git:git@github.com:rometools/rome-opml.git</connection>
|
<connection>scm:git:git@github.com:rometools/rome-opml.git</connection>
|
||||||
<developerConnection>scm:git:git@github.com:rometools/rome-opml.git</developerConnection>
|
<developerConnection>scm:git:git@github.com:rometools/rome-opml.git</developerConnection>
|
||||||
<url>https://github.com/rometools/rome-opml/</url>
|
<url>https://github.com/rometools/rome-opml/</url>
|
||||||
</scm>
|
</scm>
|
||||||
|
|
||||||
<developers>
|
<developers>
|
||||||
<developer>
|
<developer>
|
||||||
<id>kebernet</id>
|
<id>kebernet</id>
|
||||||
|
@ -28,6 +36,7 @@
|
||||||
<name>Robert Cooper</name>
|
<name>Robert Cooper</name>
|
||||||
</developer>
|
</developer>
|
||||||
</developers>
|
</developers>
|
||||||
|
|
||||||
<licenses>
|
<licenses>
|
||||||
<license>
|
<license>
|
||||||
<name>The Apache Software License, Version 2.0</name>
|
<name>The Apache Software License, Version 2.0</name>
|
||||||
|
@ -35,169 +44,137 @@
|
||||||
<distribution>repo</distribution>
|
<distribution>repo</distribution>
|
||||||
</license>
|
</license>
|
||||||
</licenses>
|
</licenses>
|
||||||
<repositories>
|
|
||||||
|
<properties>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<distributionManagement>
|
||||||
<repository>
|
<repository>
|
||||||
<id>maven2-repository.dev.java.net</id>
|
<id>central.staging</id>
|
||||||
<url>http://download.java.net/maven/2</url>
|
<url>http://oss.sonatype.org/service/local/staging/deploy/maven2</url>
|
||||||
</repository>
|
</repository>
|
||||||
</repositories>
|
<snapshotRepository>
|
||||||
<dependencies>
|
<id>sonatype.snapshots</id>
|
||||||
<dependency>
|
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
|
||||||
<groupId>junit</groupId>
|
</snapshotRepository>
|
||||||
<artifactId>junit</artifactId>
|
</distributionManagement>
|
||||||
<version>3.8.1</version>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>rome</groupId>
|
|
||||||
<artifactId>rome</artifactId>
|
|
||||||
<version>1.0</version>
|
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
<build>
|
<build>
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<!-- <plugin> -->
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<!-- <groupId>org.apache.maven.plugins</groupId> -->
|
||||||
<artifactId>maven-scm-plugin</artifactId>
|
<!-- <artifactId>maven-scm-plugin</artifactId> -->
|
||||||
<version>1.0</version>
|
<!-- <version>1.8.1</version> -->
|
||||||
<configuration>
|
<!-- <configuration> -->
|
||||||
<goals>install</goals>
|
<!-- <goals>install</goals> -->
|
||||||
</configuration>
|
<!-- </configuration> -->
|
||||||
</plugin>
|
<!-- </plugin> -->
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<version>2.0.2</version>
|
<version>3.1</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<source>1.4</source>
|
<source>1.6</source>
|
||||||
<target>1.4</target>
|
<target>1.6</target>
|
||||||
<encoding>${project.build.sourceEncoding}</encoding>
|
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-resources-plugin</artifactId>
|
<artifactId>maven-resources-plugin</artifactId>
|
||||||
<version>2.6</version>
|
<version>2.6</version>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-site-plugin</artifactId>
|
||||||
|
<version>3.3</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<encoding>${project.build.sourceEncoding}</encoding>
|
<port>9000</port>
|
||||||
|
<tempWebappDirectory>${basedir}/target/site/tempdir</tempWebappDirectory>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-site-plugin</artifactId>
|
<artifactId>maven-scm-publish-plugin</artifactId>
|
||||||
<version>3.3</version>
|
<version>1.0-beta-2</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<port>9000</port>
|
<scmBranch>gh-pages</scmBranch>
|
||||||
<tempWebappDirectory>${basedir}/target/site/tempdir</tempWebappDirectory>
|
<pubScmUrl>scm:git:git@github.com:rometools/rome-opml.git</pubScmUrl>
|
||||||
</configuration>
|
<content>${project.build.directory}/site</content>
|
||||||
</plugin>
|
</configuration>
|
||||||
<plugin>
|
</plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<plugin>
|
||||||
<artifactId>maven-scm-publish-plugin</artifactId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<version>1.0-beta-2</version>
|
<artifactId>maven-source-plugin</artifactId>
|
||||||
<configuration>
|
<version>2.2.1</version>
|
||||||
<scmBranch>gh-pages</scmBranch>
|
<executions>
|
||||||
<pubScmUrl>scm:git:git@github.com:rometools/rome-opml.git</pubScmUrl>
|
<execution>
|
||||||
<content>${project.build.directory}/site</content>
|
<id>attach-sources</id>
|
||||||
</configuration>
|
<goals>
|
||||||
</plugin>
|
<goal>jar</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-javadoc-plugin</artifactId>
|
||||||
|
<version>2.9.1</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>attach-javadocs</id>
|
||||||
|
<goals>
|
||||||
|
<goal>jar</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
<profiles>
|
|
||||||
<profile>
|
<reporting>
|
||||||
<id>release</id>
|
<plugins>
|
||||||
<activation>
|
<plugin>
|
||||||
<property>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<name>performRelease</name>
|
<artifactId>maven-project-info-reports-plugin</artifactId>
|
||||||
<value>true</value>
|
<version>2.7</version>
|
||||||
</property>
|
</plugin>
|
||||||
</activation>
|
<plugin>
|
||||||
<distributionManagement>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<repository>
|
<artifactId>maven-javadoc-plugin</artifactId>
|
||||||
<id>central.staging</id>
|
<version>2.9.1</version>
|
||||||
<name>Nexus Release Repository</name>
|
<reportSets>
|
||||||
<url>http://oss.sonatype.org/service/local/staging/deploy/maven2</url>
|
<reportSet>
|
||||||
</repository>
|
<reports>
|
||||||
<snapshotRepository>
|
<report>javadoc</report>
|
||||||
<id>sonatype.snapshots</id>
|
<report>test-javadoc</report>
|
||||||
<name>My Nexus Snapshots Repository</name>
|
</reports>
|
||||||
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
|
</reportSet>
|
||||||
</snapshotRepository>
|
<reportSet>
|
||||||
</distributionManagement>
|
<id>aggregate</id>
|
||||||
<build>
|
<inherited>false</inherited>
|
||||||
<plugins>
|
<reports>
|
||||||
<plugin>
|
<report>aggregate</report>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
</reports>
|
||||||
<artifactId>maven-gpg-plugin</artifactId>
|
</reportSet>
|
||||||
<executions>
|
</reportSets>
|
||||||
<execution>
|
</plugin>
|
||||||
<id>sign-artifacts</id>
|
</plugins>
|
||||||
<phase>verify</phase>
|
</reporting>
|
||||||
<goals>
|
|
||||||
<goal>sign</goal>
|
<dependencies>
|
||||||
</goals>
|
<dependency>
|
||||||
</execution>
|
<groupId>junit</groupId>
|
||||||
</executions>
|
<artifactId>junit</artifactId>
|
||||||
</plugin>
|
<version>4.11</version>
|
||||||
<plugin>
|
<scope>test</scope>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
</dependency>
|
||||||
<artifactId>maven-source-plugin</artifactId>
|
<dependency>
|
||||||
<executions>
|
<groupId>org.rometools</groupId>
|
||||||
<execution>
|
<artifactId>rome</artifactId>
|
||||||
<id>attach-sources</id>
|
<version>2.0.0-SNAPSHOT</version>
|
||||||
<goals>
|
<scope>compile</scope>
|
||||||
<goal>jar</goal>
|
</dependency>
|
||||||
</goals>
|
</dependencies>
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-javadoc-plugin</artifactId>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<id>attach-javadocs</id>
|
|
||||||
<goals>
|
|
||||||
<goal>jar</goal>
|
|
||||||
</goals>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
</build>
|
|
||||||
</profile>
|
|
||||||
</profiles>
|
|
||||||
<properties>
|
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
|
||||||
</properties>
|
|
||||||
<reporting>
|
|
||||||
<plugins>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-project-info-reports-plugin</artifactId>
|
|
||||||
<version>2.6</version>
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-javadoc-plugin</artifactId>
|
|
||||||
<version>2.9</version>
|
|
||||||
<reportSets>
|
|
||||||
<reportSet>
|
|
||||||
<reports>
|
|
||||||
<report>javadoc</report>
|
|
||||||
<report>test-javadoc</report>
|
|
||||||
</reports>
|
|
||||||
</reportSet>
|
|
||||||
<reportSet>
|
|
||||||
<id>aggregate</id>
|
|
||||||
<inherited>false</inherited>
|
|
||||||
<reports>
|
|
||||||
<report>aggregate</report>
|
|
||||||
</reports>
|
|
||||||
</reportSet>
|
|
||||||
</reportSets>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
</reporting>
|
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -22,7 +22,6 @@ import com.sun.syndication.feed.impl.ToStringBean;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is a simple name-value pair attribute for outlines.
|
* This is a simple name-value pair attribute for outlines.
|
||||||
*
|
*
|
||||||
|
@ -39,6 +38,7 @@ public class Attribute implements Cloneable, Serializable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new instance of Attribute.
|
* Creates a new instance of Attribute.
|
||||||
|
*
|
||||||
* @param name name of the attribute.
|
* @param name name of the attribute.
|
||||||
* @param value value of the attribute.
|
* @param value value of the attribute.
|
||||||
*/
|
*/
|
||||||
|
@ -53,6 +53,7 @@ public class Attribute implements Cloneable, Serializable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* name of the attribute.
|
* name of the attribute.
|
||||||
|
*
|
||||||
* @param name name of the attribute.
|
* @param name name of the attribute.
|
||||||
*/
|
*/
|
||||||
public void setName(String name) {
|
public void setName(String name) {
|
||||||
|
@ -61,6 +62,7 @@ public class Attribute implements Cloneable, Serializable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* name of the attribute.
|
* name of the attribute.
|
||||||
|
*
|
||||||
* @return name of the attribute.
|
* @return name of the attribute.
|
||||||
*/
|
*/
|
||||||
public String getName() {
|
public String getName() {
|
||||||
|
@ -69,6 +71,7 @@ public class Attribute implements Cloneable, Serializable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* value of the attribute.
|
* value of the attribute.
|
||||||
|
*
|
||||||
* @param value value of the attribute.
|
* @param value value of the attribute.
|
||||||
*/
|
*/
|
||||||
public void setValue(String value) {
|
public void setValue(String value) {
|
||||||
|
@ -77,28 +80,33 @@ public class Attribute implements Cloneable, Serializable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* value of the attribute.
|
* value of the attribute.
|
||||||
|
*
|
||||||
* @return value of the attribute.
|
* @return value of the attribute.
|
||||||
*/
|
*/
|
||||||
public String getValue() {
|
public String getValue() {
|
||||||
return _value;
|
return _value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Object clone() {
|
public Object clone() {
|
||||||
return new Attribute(this._name, this._value);
|
return new Attribute(this._name, this._value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object obj) {
|
||||||
EqualsBean eBean = new EqualsBean(Attribute.class, this);
|
EqualsBean eBean = new EqualsBean(Attribute.class, this);
|
||||||
|
|
||||||
return eBean.beanEquals(obj);
|
return eBean.beanEquals(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
EqualsBean equals = new EqualsBean(Attribute.class, this);
|
EqualsBean equals = new EqualsBean(Attribute.class, this);
|
||||||
|
|
||||||
return equals.beanHashCode();
|
return equals.beanHashCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
ToStringBean tsBean = new ToStringBean(Attribute.class, this);
|
ToStringBean tsBean = new ToStringBean(Attribute.class, this);
|
||||||
|
|
||||||
|
|
|
@ -23,10 +23,9 @@ import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class represents the root of an OPML 1/2 feed and contains the elements that
|
* This class represents the root of an OPML 1/2 feed and contains the elements that may appear in the <head> tag of the feed.
|
||||||
* may appear in the <head> tag of the feed.
|
*
|
||||||
* @author <a href="mailto:cooper@screaming-penguin.com"> Robert "kebernet" Cooper</a>
|
* @author <a href="mailto:cooper@screaming-penguin.com"> Robert "kebernet" Cooper</a>
|
||||||
*/
|
*/
|
||||||
public class Opml extends WireFeed {
|
public class Opml extends WireFeed {
|
||||||
|
@ -52,6 +51,7 @@ public class Opml extends WireFeed {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <dateCreated> is a date-time, indicating when the document was created.
|
* <dateCreated> is a date-time, indicating when the document was created.
|
||||||
|
*
|
||||||
* @param created date-time, indicating when the document was created.
|
* @param created date-time, indicating when the document was created.
|
||||||
*/
|
*/
|
||||||
public void setCreated(Date created) {
|
public void setCreated(Date created) {
|
||||||
|
@ -60,6 +60,7 @@ public class Opml extends WireFeed {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <dateCreated> is a date-time, indicating when the document was created.
|
* <dateCreated> is a date-time, indicating when the document was created.
|
||||||
|
*
|
||||||
* @return date-time, indicating when the document was created.
|
* @return date-time, indicating when the document was created.
|
||||||
*/
|
*/
|
||||||
public Date getCreated() {
|
public Date getCreated() {
|
||||||
|
@ -67,7 +68,9 @@ public class Opml extends WireFeed {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* (OPML 2) <docs> is the http address of documentation for the format used in the OPML file. It's probably a pointer to <a href="http://www.opml.org/spec2">this page</a> for people who might stumble across the file on a web server 25 years from now and wonder what it is.
|
* (OPML 2) <docs> is the http address of documentation for the format used in the OPML file. It's probably a pointer to <a
|
||||||
|
* href="http://www.opml.org/spec2">this page</a> for people who might stumble across the file on a web server 25 years from now and wonder what it is.
|
||||||
|
*
|
||||||
* @param docs http address of documentation for the format used
|
* @param docs http address of documentation for the format used
|
||||||
*/
|
*/
|
||||||
public void setDocs(String docs) {
|
public void setDocs(String docs) {
|
||||||
|
@ -75,7 +78,9 @@ public class Opml extends WireFeed {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* (OPML 2) <docs> is the http address of documentation for the format used in the OPML file. It's probably a pointer to <a href="http://www.opml.org/spec2">this page</a> for people who might stumble across the file on a web server 25 years from now and wonder what it is.
|
* (OPML 2) <docs> is the http address of documentation for the format used in the OPML file. It's probably a pointer to <a
|
||||||
|
* href="http://www.opml.org/spec2">this page</a> for people who might stumble across the file on a web server 25 years from now and wonder what it is.
|
||||||
|
*
|
||||||
* @return http address of documentation for the format used
|
* @return http address of documentation for the format used
|
||||||
*/
|
*/
|
||||||
public String getDocs() {
|
public String getDocs() {
|
||||||
|
@ -83,7 +88,10 @@ public class Opml extends WireFeed {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <expansionState>is a comma-separated list of line numbers that are expanded. The line numbers in the list tell you which headlines to expand. The order is important. For each element in the list, X, starting at the first summit, navigate flatdown X times and expand. Repeat for each element in the list.
|
* <expansionState>is a comma-separated list of line numbers that are expanded. The line numbers in the list tell you which headlines to expand. The
|
||||||
|
* order is important. For each element in the list, X, starting at the first summit, navigate flatdown X times and expand. Repeat for each element in the
|
||||||
|
* list.
|
||||||
|
*
|
||||||
* @param expansionState int array containing expanded elements.
|
* @param expansionState int array containing expanded elements.
|
||||||
*/
|
*/
|
||||||
public void setExpansionState(int[] expansionState) {
|
public void setExpansionState(int[] expansionState) {
|
||||||
|
@ -91,7 +99,10 @@ public class Opml extends WireFeed {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <expansionState> is a comma-separated list of line numbers that are expanded. The line numbers in the list tell you which headlines to expand. The order is important. For each element in the list, X, starting at the first summit, navigate flatdown X times and expand. Repeat for each element in the list.
|
* <expansionState> is a comma-separated list of line numbers that are expanded. The line numbers in the list tell you which headlines to expand. The
|
||||||
|
* order is important. For each element in the list, X, starting at the first summit, navigate flatdown X times and expand. Repeat for each element in the
|
||||||
|
* list.
|
||||||
|
*
|
||||||
* @return int array containing expanded elements.
|
* @return int array containing expanded elements.
|
||||||
*/
|
*/
|
||||||
public int[] getExpansionState() {
|
public int[] getExpansionState() {
|
||||||
|
@ -100,6 +111,7 @@ public class Opml extends WireFeed {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <dateModified> is a date-time, indicating when the document was last modified.
|
* <dateModified> is a date-time, indicating when the document was last modified.
|
||||||
|
*
|
||||||
* @param modified date-time, indicating when the document was last modified.
|
* @param modified date-time, indicating when the document was last modified.
|
||||||
*/
|
*/
|
||||||
public void setModified(Date modified) {
|
public void setModified(Date modified) {
|
||||||
|
@ -108,6 +120,7 @@ public class Opml extends WireFeed {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <dateModified> is a date-time, indicating when the document was last modified.
|
* <dateModified> is a date-time, indicating when the document was last modified.
|
||||||
|
*
|
||||||
* @return date-time, indicating when the document was last modified.
|
* @return date-time, indicating when the document was last modified.
|
||||||
*/
|
*/
|
||||||
public Date getModified() {
|
public Date getModified() {
|
||||||
|
@ -116,6 +129,7 @@ public class Opml extends WireFeed {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Root level Outline object that should appear in the <body>
|
* Root level Outline object that should appear in the <body>
|
||||||
|
*
|
||||||
* @param outlines Root level Outline object that should appear in the <body>
|
* @param outlines Root level Outline object that should appear in the <body>
|
||||||
*/
|
*/
|
||||||
public void setOutlines(List outlines) {
|
public void setOutlines(List outlines) {
|
||||||
|
@ -124,6 +138,7 @@ public class Opml extends WireFeed {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Root level Outline object that should appear in the <body>
|
* Root level Outline object that should appear in the <body>
|
||||||
|
*
|
||||||
* @return Root level Outline object that should appear in the <body>
|
* @return Root level Outline object that should appear in the <body>
|
||||||
*/
|
*/
|
||||||
public List getOutlines() {
|
public List getOutlines() {
|
||||||
|
@ -135,7 +150,8 @@ public class Opml extends WireFeed {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <ownerEmail> is a string, the email address of the owner of the document.
|
* <ownerEmail> is a string, the email address of the owner of the document.
|
||||||
|
*
|
||||||
* @param ownerEmail the email address of the owner of the document.
|
* @param ownerEmail the email address of the owner of the document.
|
||||||
*/
|
*/
|
||||||
public void setOwnerEmail(String ownerEmail) {
|
public void setOwnerEmail(String ownerEmail) {
|
||||||
|
@ -143,7 +159,8 @@ public class Opml extends WireFeed {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <ownerEmail> is a string, the email address of the owner of the document.
|
* <ownerEmail> is a string, the email address of the owner of the document.
|
||||||
|
*
|
||||||
* @return the email address of the owner of the document.
|
* @return the email address of the owner of the document.
|
||||||
*/
|
*/
|
||||||
public String getOwnerEmail() {
|
public String getOwnerEmail() {
|
||||||
|
@ -151,23 +168,30 @@ public class Opml extends WireFeed {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* (OPML 2) <ownerId> is the http address of a web page that contains <strike>an HTML</strike> a form that allows a human reader to communicate with the author of the document via email or other means.
|
* (OPML 2) <ownerId> is the http address of a web page that contains <strike>an HTML</strike> a form that allows a human reader to communicate with
|
||||||
* @param ownerId http address of a web page that contains <strike>an HTML</strike> a form that allows a human reader to communicate with the author of the document via email or other means.
|
* the author of the document via email or other means.
|
||||||
|
*
|
||||||
|
* @param ownerId http address of a web page that contains <strike>an HTML</strike> a form that allows a human reader to communicate with the author of the
|
||||||
|
* document via email or other means.
|
||||||
*/
|
*/
|
||||||
public void setOwnerId(String ownerId) {
|
public void setOwnerId(String ownerId) {
|
||||||
this._ownerId = ownerId;
|
this._ownerId = ownerId;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* (OPML 2) <ownerId> is the http address of a web page that contains <strike>an HTML</strike> a form that allows a human reader to communicate with the author of the document via email or other means.
|
* (OPML 2) <ownerId> is the http address of a web page that contains <strike>an HTML</strike> a form that allows a human reader to communicate with
|
||||||
* @return http address of a web page that contains <strike>an HTML</strike> a form that allows a human reader to communicate with the author of the document via email or other means.
|
* the author of the document via email or other means.
|
||||||
|
*
|
||||||
|
* @return http address of a web page that contains <strike>an HTML</strike> a form that allows a human reader to communicate with the author of the
|
||||||
|
* document via email or other means.
|
||||||
*/
|
*/
|
||||||
public String getOwnerId() {
|
public String getOwnerId() {
|
||||||
return _ownerId;
|
return _ownerId;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <ownerName> is a string, the owner of the document.
|
* <ownerName> is a string, the owner of the document.
|
||||||
|
*
|
||||||
* @param ownerName the owner of the document.
|
* @param ownerName the owner of the document.
|
||||||
*/
|
*/
|
||||||
public void setOwnerName(String ownerName) {
|
public void setOwnerName(String ownerName) {
|
||||||
|
@ -175,7 +199,8 @@ public class Opml extends WireFeed {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <ownerName> is a string, the owner of the document.
|
* <ownerName> is a string, the owner of the document.
|
||||||
|
*
|
||||||
* @return the owner of the document.
|
* @return the owner of the document.
|
||||||
*/
|
*/
|
||||||
public String getOwnerName() {
|
public String getOwnerName() {
|
||||||
|
@ -183,7 +208,8 @@ public class Opml extends WireFeed {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <title> is the title of the document.
|
* <title> is the title of the document.
|
||||||
|
*
|
||||||
* @param title title of the document.
|
* @param title title of the document.
|
||||||
*/
|
*/
|
||||||
public void setTitle(String title) {
|
public void setTitle(String title) {
|
||||||
|
@ -191,7 +217,8 @@ public class Opml extends WireFeed {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <title> is the title of the document.
|
* <title> is the title of the document.
|
||||||
|
*
|
||||||
* @return title of the document.
|
* @return title of the document.
|
||||||
*/
|
*/
|
||||||
public String getTitle() {
|
public String getTitle() {
|
||||||
|
@ -199,7 +226,9 @@ public class Opml extends WireFeed {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <vertScrollState> is a number, saying which line of the outline is displayed on the top line of the window. This number is calculated with the expansion state already applied.
|
* <vertScrollState> is a number, saying which line of the outline is displayed on the top line of the window. This number is calculated with the
|
||||||
|
* expansion state already applied.
|
||||||
|
*
|
||||||
* @param verticalScrollState which line of the outline is displayed on the top line of the window.
|
* @param verticalScrollState which line of the outline is displayed on the top line of the window.
|
||||||
*/
|
*/
|
||||||
public void setVerticalScrollState(Integer verticalScrollState) {
|
public void setVerticalScrollState(Integer verticalScrollState) {
|
||||||
|
@ -207,8 +236,10 @@ public class Opml extends WireFeed {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <vertScrollState> is a number, saying which line of the outline is displayed on the top line of the window. This number is calculated with the expansion state already applied.
|
* <vertScrollState> is a number, saying which line of the outline is displayed on the top line of the window. This number is calculated with the
|
||||||
* @return which line of the outline is displayed on the top line of the window. This number is calculated with the expansion state already applied.
|
* expansion state already applied.
|
||||||
|
*
|
||||||
|
* @return which line of the outline is displayed on the top line of the window. This number is calculated with the expansion state already applied.
|
||||||
*/
|
*/
|
||||||
public Integer getVerticalScrollState() {
|
public Integer getVerticalScrollState() {
|
||||||
return _verticalScrollState;
|
return _verticalScrollState;
|
||||||
|
@ -216,6 +247,7 @@ public class Opml extends WireFeed {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <windowBottom> is a number, the pixel location of the bottom edge of the window.
|
* <windowBottom> is a number, the pixel location of the bottom edge of the window.
|
||||||
|
*
|
||||||
* @param windowBottom the pixel location of the bottom edge of the window.
|
* @param windowBottom the pixel location of the bottom edge of the window.
|
||||||
*/
|
*/
|
||||||
public void setWindowBottom(Integer windowBottom) {
|
public void setWindowBottom(Integer windowBottom) {
|
||||||
|
@ -224,7 +256,8 @@ public class Opml extends WireFeed {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <windowBottom> is a number, the pixel location of the bottom edge of the window.
|
* <windowBottom> is a number, the pixel location of the bottom edge of the window.
|
||||||
* @return the pixel location of the bottom edge of the window.
|
*
|
||||||
|
* @return the pixel location of the bottom edge of the window.
|
||||||
*/
|
*/
|
||||||
public Integer getWindowBottom() {
|
public Integer getWindowBottom() {
|
||||||
return _windowBottom;
|
return _windowBottom;
|
||||||
|
@ -232,6 +265,7 @@ public class Opml extends WireFeed {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <windowLeft> is a number, the pixel location of the left edge of the window.
|
* <windowLeft> is a number, the pixel location of the left edge of the window.
|
||||||
|
*
|
||||||
* @param windowLeft the pixel location of the left edge of the window.
|
* @param windowLeft the pixel location of the left edge of the window.
|
||||||
*/
|
*/
|
||||||
public void setWindowLeft(Integer windowLeft) {
|
public void setWindowLeft(Integer windowLeft) {
|
||||||
|
@ -240,6 +274,7 @@ public class Opml extends WireFeed {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <windowLeft> is a number, the pixel location of the left edge of the window.
|
* <windowLeft> is a number, the pixel location of the left edge of the window.
|
||||||
|
*
|
||||||
* @return the pixel location of the left edge of the window.
|
* @return the pixel location of the left edge of the window.
|
||||||
*/
|
*/
|
||||||
public Integer getWindowLeft() {
|
public Integer getWindowLeft() {
|
||||||
|
@ -248,6 +283,7 @@ public class Opml extends WireFeed {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <windowRight> is a number, the pixel location of the right edge of the window.
|
* <windowRight> is a number, the pixel location of the right edge of the window.
|
||||||
|
*
|
||||||
* @param windowRight the pixel location of the right edge of the window.
|
* @param windowRight the pixel location of the right edge of the window.
|
||||||
*/
|
*/
|
||||||
public void setWindowRight(Integer windowRight) {
|
public void setWindowRight(Integer windowRight) {
|
||||||
|
@ -256,6 +292,7 @@ public class Opml extends WireFeed {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <windowRight> is a number, the pixel location of the right edge of the window.
|
* <windowRight> is a number, the pixel location of the right edge of the window.
|
||||||
|
*
|
||||||
* @return the pixel location of the right edge of the window.
|
* @return the pixel location of the right edge of the window.
|
||||||
*/
|
*/
|
||||||
public Integer getWindowRight() {
|
public Integer getWindowRight() {
|
||||||
|
@ -264,6 +301,7 @@ public class Opml extends WireFeed {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <windowTop> is a number, the pixel location of the top edge of the window.
|
* <windowTop> is a number, the pixel location of the top edge of the window.
|
||||||
|
*
|
||||||
* @param windowTop the pixel location of the top edge of the window.
|
* @param windowTop the pixel location of the top edge of the window.
|
||||||
*/
|
*/
|
||||||
public void setWindowTop(Integer windowTop) {
|
public void setWindowTop(Integer windowTop) {
|
||||||
|
@ -272,6 +310,7 @@ public class Opml extends WireFeed {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <windowTop> is a number, the pixel location of the top edge of the window.
|
* <windowTop> is a number, the pixel location of the top edge of the window.
|
||||||
|
*
|
||||||
* @return the pixel location of the top edge of the window.
|
* @return the pixel location of the top edge of the window.
|
||||||
*/
|
*/
|
||||||
public Integer getWindowTop() {
|
public Integer getWindowTop() {
|
||||||
|
|
|
@ -29,9 +29,9 @@ import java.util.Collections;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class represents an OPML outline element.
|
* This class represents an OPML outline element.
|
||||||
|
*
|
||||||
* @author <a href="mailto:cooper@screaming-penguin.com">Robert "kebernet" Cooper</a>
|
* @author <a href="mailto:cooper@screaming-penguin.com">Robert "kebernet" Cooper</a>
|
||||||
*/
|
*/
|
||||||
public class Outline implements Cloneable, Serializable {
|
public class Outline implements Cloneable, Serializable {
|
||||||
|
@ -53,6 +53,7 @@ public class Outline implements Cloneable, Serializable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new outline with the specified type and text values.
|
* Creates a new outline with the specified type and text values.
|
||||||
|
*
|
||||||
* @param type type attribute value/
|
* @param type type attribute value/
|
||||||
* @param text text attribute value
|
* @param text text attribute value
|
||||||
*/
|
*/
|
||||||
|
@ -63,8 +64,8 @@ public class Outline implements Cloneable, Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an outline with the given title, xmlUrl and htmlUrl. This is traditionally
|
* Creates an outline with the given title, xmlUrl and htmlUrl. This is traditionally used for aggregator feed lists and will get a type of "rss".
|
||||||
* used for aggregator feed lists and will get a type of "rss".
|
*
|
||||||
* @param title Title of the entry.
|
* @param title Title of the entry.
|
||||||
* @param xmlUrl link to XML file.
|
* @param xmlUrl link to XML file.
|
||||||
* @param htmlUrl link to html page.
|
* @param htmlUrl link to html page.
|
||||||
|
@ -86,6 +87,7 @@ public class Outline implements Cloneable, Serializable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List of attributes on this outline excluding the "common types" for the specification.
|
* List of attributes on this outline excluding the "common types" for the specification.
|
||||||
|
*
|
||||||
* @param attributes List of attributes on this outline.
|
* @param attributes List of attributes on this outline.
|
||||||
*/
|
*/
|
||||||
public void setAttributes(List attributes) {
|
public void setAttributes(List attributes) {
|
||||||
|
@ -94,6 +96,7 @@ public class Outline implements Cloneable, Serializable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List of attributes on this outline excluding the "common types" for the specification.
|
* List of attributes on this outline excluding the "common types" for the specification.
|
||||||
|
*
|
||||||
* @return List of attributes on this outline.
|
* @return List of attributes on this outline.
|
||||||
*/
|
*/
|
||||||
public List getAttributes() {
|
public List getAttributes() {
|
||||||
|
@ -105,7 +108,9 @@ public class Outline implements Cloneable, Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* isBreakpoint is a string, either "true" or "false", indicating whether a breakpoint is set on this outline. This attribute is mainly necessary for outlines used to edit scripts. If it's not present, the value is false.
|
* isBreakpoint is a string, either "true" or "false", indicating whether a breakpoint is set on this outline. This attribute is mainly necessary for
|
||||||
|
* outlines used to edit scripts. If it's not present, the value is false.
|
||||||
|
*
|
||||||
* @param breakpoint whether a breakpoint is set on this outline.
|
* @param breakpoint whether a breakpoint is set on this outline.
|
||||||
*/
|
*/
|
||||||
public void setBreakpoint(boolean breakpoint) {
|
public void setBreakpoint(boolean breakpoint) {
|
||||||
|
@ -113,8 +118,10 @@ public class Outline implements Cloneable, Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* isBreakpoint is a string, either "true" or "false", indicating whether a breakpoint is set on this outline. This attribute is mainly necessary for outlines used to edit scripts. If it's not present, the value is false.
|
* isBreakpoint is a string, either "true" or "false", indicating whether a breakpoint is set on this outline. This attribute is mainly necessary for
|
||||||
* @return whether a breakpoint is set on this outline
|
* outlines used to edit scripts. If it's not present, the value is false.
|
||||||
|
*
|
||||||
|
* @return whether a breakpoint is set on this outline
|
||||||
*/
|
*/
|
||||||
public boolean isBreakpoint() {
|
public boolean isBreakpoint() {
|
||||||
return _breakpoint;
|
return _breakpoint;
|
||||||
|
@ -122,6 +129,7 @@ public class Outline implements Cloneable, Serializable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* (OPML 2) A List of Strings indicating values in the category attribute.
|
* (OPML 2) A List of Strings indicating values in the category attribute.
|
||||||
|
*
|
||||||
* @param categories (OPML 2) A List of Strings indicating values in the category attribute.
|
* @param categories (OPML 2) A List of Strings indicating values in the category attribute.
|
||||||
*/
|
*/
|
||||||
public void setCategories(List categories) {
|
public void setCategories(List categories) {
|
||||||
|
@ -130,6 +138,7 @@ public class Outline implements Cloneable, Serializable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* (OPML 2) A List of Strings indicating values in the category attribute.
|
* (OPML 2) A List of Strings indicating values in the category attribute.
|
||||||
|
*
|
||||||
* @return (OPML 2) A List of Strings indicating values in the category attribute.
|
* @return (OPML 2) A List of Strings indicating values in the category attribute.
|
||||||
*/
|
*/
|
||||||
public List getCategories() {
|
public List getCategories() {
|
||||||
|
@ -142,6 +151,7 @@ public class Outline implements Cloneable, Serializable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A list of sub-outlines for this entry.
|
* A list of sub-outlines for this entry.
|
||||||
|
*
|
||||||
* @param children A list of sub-outlines for this entry.
|
* @param children A list of sub-outlines for this entry.
|
||||||
*/
|
*/
|
||||||
public void setChildren(List children) {
|
public void setChildren(List children) {
|
||||||
|
@ -150,6 +160,7 @@ public class Outline implements Cloneable, Serializable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A list of sub-outlines for this entry.
|
* A list of sub-outlines for this entry.
|
||||||
|
*
|
||||||
* @return A list of sub-outlines for this entry.
|
* @return A list of sub-outlines for this entry.
|
||||||
*/
|
*/
|
||||||
public List getChildren() {
|
public List getChildren() {
|
||||||
|
@ -161,7 +172,9 @@ public class Outline implements Cloneable, Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* isComment is a string, either "true" or "false", indicating whether the outline is commented or not. By convention if an outline is commented, all subordinate outlines are considered to also be commented. If it's not present, the value is false.
|
* isComment is a string, either "true" or "false", indicating whether the outline is commented or not. By convention if an outline is commented, all
|
||||||
|
* subordinate outlines are considered to also be commented. If it's not present, the value is false.
|
||||||
|
*
|
||||||
* @param comment whether the outline is commented
|
* @param comment whether the outline is commented
|
||||||
*/
|
*/
|
||||||
public void setComment(boolean comment) {
|
public void setComment(boolean comment) {
|
||||||
|
@ -169,8 +182,10 @@ public class Outline implements Cloneable, Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* isComment is a string, either "true" or "false", indicating whether the outline is commented or not. By convention if an outline is commented, all subordinate outlines are considered to also be commented. If it's not present, the value is false.
|
* isComment is a string, either "true" or "false", indicating whether the outline is commented or not. By convention if an outline is commented, all
|
||||||
* @return whether the outline is commented
|
* subordinate outlines are considered to also be commented. If it's not present, the value is false.
|
||||||
|
*
|
||||||
|
* @return whether the outline is commented
|
||||||
*/
|
*/
|
||||||
public boolean isComment() {
|
public boolean isComment() {
|
||||||
return _comment;
|
return _comment;
|
||||||
|
@ -178,6 +193,7 @@ public class Outline implements Cloneable, Serializable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* (OPML 2) created is the date-time that the outline node was created.
|
* (OPML 2) created is the date-time that the outline node was created.
|
||||||
|
*
|
||||||
* @param created date-time that the outline node was created.
|
* @param created date-time that the outline node was created.
|
||||||
*/
|
*/
|
||||||
public void setCreated(Date created) {
|
public void setCreated(Date created) {
|
||||||
|
@ -186,6 +202,7 @@ public class Outline implements Cloneable, Serializable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* (OPML 2) created is the date-time that the outline node was created.
|
* (OPML 2) created is the date-time that the outline node was created.
|
||||||
|
*
|
||||||
* @return date-time that the outline node was created.
|
* @return date-time that the outline node was created.
|
||||||
*/
|
*/
|
||||||
public Date getCreated() {
|
public Date getCreated() {
|
||||||
|
@ -194,14 +211,16 @@ public class Outline implements Cloneable, Serializable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A convenience method to return the value of the url attribute.
|
* A convenience method to return the value of the url attribute.
|
||||||
|
*
|
||||||
* @return value of the htmlUrl attribute.
|
* @return value of the htmlUrl attribute.
|
||||||
*/
|
*/
|
||||||
public String getUrl() {
|
public String getUrl() {
|
||||||
return getAttributeValue("url");
|
return getAttributeValue("url");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A convenience method to return the value of the htmlUrl attribute.
|
* A convenience method to return the value of the htmlUrl attribute.
|
||||||
|
*
|
||||||
* @return value of the htmlUrl attribute.
|
* @return value of the htmlUrl attribute.
|
||||||
*/
|
*/
|
||||||
public String getHtmlUrl() {
|
public String getHtmlUrl() {
|
||||||
|
@ -222,6 +241,7 @@ public class Outline implements Cloneable, Serializable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The "text" attribute of the outline.
|
* The "text" attribute of the outline.
|
||||||
|
*
|
||||||
* @param text The "text" attribute of the outline.
|
* @param text The "text" attribute of the outline.
|
||||||
*/
|
*/
|
||||||
public void setText(String text) {
|
public void setText(String text) {
|
||||||
|
@ -230,6 +250,7 @@ public class Outline implements Cloneable, Serializable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The "text" attribute of the outline.
|
* The "text" attribute of the outline.
|
||||||
|
*
|
||||||
* @return The "text" attribute of the outline.
|
* @return The "text" attribute of the outline.
|
||||||
*/
|
*/
|
||||||
public String getText() {
|
public String getText() {
|
||||||
|
@ -238,6 +259,7 @@ public class Outline implements Cloneable, Serializable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The "title" attribute of the outline.
|
* The "title" attribute of the outline.
|
||||||
|
*
|
||||||
* @param title The "title" attribute of the outline.
|
* @param title The "title" attribute of the outline.
|
||||||
*/
|
*/
|
||||||
public void setTitle(String title) {
|
public void setTitle(String title) {
|
||||||
|
@ -246,6 +268,7 @@ public class Outline implements Cloneable, Serializable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The "title" attribute of the outline.
|
* The "title" attribute of the outline.
|
||||||
|
*
|
||||||
* @return The "title" attribute of the outline.
|
* @return The "title" attribute of the outline.
|
||||||
*/
|
*/
|
||||||
public String getTitle() {
|
public String getTitle() {
|
||||||
|
@ -254,6 +277,7 @@ public class Outline implements Cloneable, Serializable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The "type" attribute of the outline.
|
* The "type" attribute of the outline.
|
||||||
|
*
|
||||||
* @param type The "type" attribute of the outline.
|
* @param type The "type" attribute of the outline.
|
||||||
*/
|
*/
|
||||||
public void setType(String type) {
|
public void setType(String type) {
|
||||||
|
@ -262,6 +286,7 @@ public class Outline implements Cloneable, Serializable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The "type" attribute of the outline.
|
* The "type" attribute of the outline.
|
||||||
|
*
|
||||||
* @return The "type" attribute of the outline.
|
* @return The "type" attribute of the outline.
|
||||||
*/
|
*/
|
||||||
public String getType() {
|
public String getType() {
|
||||||
|
@ -270,16 +295,19 @@ public class Outline implements Cloneable, Serializable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A convenience method to return the value of the xmlUrl attribute.
|
* A convenience method to return the value of the xmlUrl attribute.
|
||||||
* @return value of the xmlUrl attribute.
|
*
|
||||||
|
* @return value of the xmlUrl attribute.
|
||||||
*/
|
*/
|
||||||
public String getXmlUrl() {
|
public String getXmlUrl() {
|
||||||
return getAttributeValue("xmlUrl");
|
return getAttributeValue("xmlUrl");
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns the value of an attribute on the outline or null.
|
/**
|
||||||
|
* Returns the value of an attribute on the outline or null.
|
||||||
|
*
|
||||||
* @param name name of the attribute.
|
* @param name name of the attribute.
|
||||||
*/
|
*/
|
||||||
public String getAttributeValue(String name ){
|
public String getAttributeValue(String name) {
|
||||||
List attributes = Collections.synchronizedList(this.getAttributes());
|
List attributes = Collections.synchronizedList(this.getAttributes());
|
||||||
|
|
||||||
for (int i = 0; i < attributes.size(); i++) {
|
for (int i = 0; i < attributes.size(); i++) {
|
||||||
|
@ -293,6 +321,7 @@ public class Outline implements Cloneable, Serializable {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Object clone() {
|
public Object clone() {
|
||||||
Outline o = new Outline();
|
Outline o = new Outline();
|
||||||
o.setBreakpoint(this.isBreakpoint());
|
o.setBreakpoint(this.isBreakpoint());
|
||||||
|
@ -323,18 +352,21 @@ public class Outline implements Cloneable, Serializable {
|
||||||
return o;
|
return o;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object obj) {
|
||||||
EqualsBean eBean = new EqualsBean(Outline.class, this);
|
EqualsBean eBean = new EqualsBean(Outline.class, this);
|
||||||
|
|
||||||
return eBean.beanEquals(obj);
|
return eBean.beanEquals(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
EqualsBean equals = new EqualsBean(Outline.class, this);
|
EqualsBean equals = new EqualsBean(Outline.class, this);
|
||||||
|
|
||||||
return equals.beanHashCode();
|
return equals.beanHashCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
ToStringBean tsBean = new ToStringBean(Outline.class, this);
|
ToStringBean tsBean = new ToStringBean(Outline.class, this);
|
||||||
|
|
||||||
|
|
|
@ -41,14 +41,12 @@ import com.sun.syndication.feed.synd.SyndLinkImpl;
|
||||||
import com.sun.syndication.feed.synd.SyndPerson;
|
import com.sun.syndication.feed.synd.SyndPerson;
|
||||||
import com.sun.syndication.feed.synd.SyndPersonImpl;
|
import com.sun.syndication.feed.synd.SyndPersonImpl;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author cooper
|
* @author cooper
|
||||||
*/
|
*/
|
||||||
public class ConverterForOPML10 implements Converter {
|
public class ConverterForOPML10 implements Converter {
|
||||||
private static final Logger LOG = Logger.getLogger(ConverterForOPML10.class.getName()
|
private static final Logger LOG = Logger.getLogger(ConverterForOPML10.class.getName().toString());
|
||||||
.toString());
|
|
||||||
public static final String URI_TREE = "urn:rome.tree";
|
public static final String URI_TREE = "urn:rome.tree";
|
||||||
public static final String URI_ATTRIBUTE = "urn:rome.attribute#";
|
public static final String URI_ATTRIBUTE = "urn:rome.attribute#";
|
||||||
|
|
||||||
|
@ -58,7 +56,7 @@ public class ConverterForOPML10 implements Converter {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void addOwner(Opml opml, SyndFeed syndFeed) {
|
protected void addOwner(Opml opml, SyndFeed syndFeed) {
|
||||||
if((opml.getOwnerEmail() != null) || (opml.getOwnerName() != null)) {
|
if ((opml.getOwnerEmail() != null) || (opml.getOwnerName() != null)) {
|
||||||
List authors = new ArrayList();
|
List authors = new ArrayList();
|
||||||
SyndPerson person = new SyndPersonImpl();
|
SyndPerson person = new SyndPersonImpl();
|
||||||
person.setEmail(opml.getOwnerEmail());
|
person.setEmail(opml.getOwnerEmail());
|
||||||
|
@ -77,43 +75,38 @@ public class ConverterForOPML10 implements Converter {
|
||||||
* @param feed real feed to copy/convert.
|
* @param feed real feed to copy/convert.
|
||||||
* @param syndFeed the SyndFeedImpl that will contain the copied/converted values of the real feed.
|
* @param syndFeed the SyndFeedImpl that will contain the copied/converted values of the real feed.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void copyInto(WireFeed feed, SyndFeed syndFeed) {
|
public void copyInto(WireFeed feed, SyndFeed syndFeed) {
|
||||||
Opml opml = (Opml) feed;
|
Opml opml = (Opml) feed;
|
||||||
syndFeed.setTitle(opml.getTitle());
|
syndFeed.setTitle(opml.getTitle());
|
||||||
addOwner(opml, syndFeed);
|
addOwner(opml, syndFeed);
|
||||||
syndFeed.setPublishedDate((opml.getModified() != null)
|
syndFeed.setPublishedDate((opml.getModified() != null) ? opml.getModified() : opml.getCreated());
|
||||||
? opml.getModified() : opml.getCreated());
|
|
||||||
syndFeed.setFeedType(opml.getFeedType());
|
syndFeed.setFeedType(opml.getFeedType());
|
||||||
syndFeed.setModules(opml.getModules());
|
syndFeed.setModules(opml.getModules());
|
||||||
syndFeed.setFeedType(this.getType());
|
syndFeed.setFeedType(this.getType());
|
||||||
|
|
||||||
ArrayList entries = new ArrayList();
|
ArrayList entries = new ArrayList();
|
||||||
createEntries(new TreeContext(), syndFeed.getEntries(),
|
createEntries(new TreeContext(), syndFeed.getEntries(), opml.getOutlines());
|
||||||
opml.getOutlines());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void createEntries(TreeContext context, List allEntries,
|
protected void createEntries(TreeContext context, List allEntries, List outlines) {
|
||||||
List outlines) {
|
|
||||||
List so = Collections.synchronizedList(outlines);
|
List so = Collections.synchronizedList(outlines);
|
||||||
|
|
||||||
for(int i = 0; i < so.size(); i++) {
|
for (int i = 0; i < so.size(); i++) {
|
||||||
createEntry(context, allEntries, (Outline) so.get(i));
|
createEntry(context, allEntries, (Outline) so.get(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected SyndEntry createEntry(TreeContext context, List allEntries,
|
protected SyndEntry createEntry(TreeContext context, List allEntries, Outline outline) {
|
||||||
Outline outline) {
|
|
||||||
SyndEntry entry = new SyndEntryImpl();
|
SyndEntry entry = new SyndEntryImpl();
|
||||||
|
|
||||||
if((outline.getType() != null) && outline.getType().equals("rss")) {
|
if ((outline.getType() != null) && outline.getType().equals("rss")) {
|
||||||
entry.setLink((outline.getHtmlUrl() != null) ? outline.getHtmlUrl()
|
entry.setLink((outline.getHtmlUrl() != null) ? outline.getHtmlUrl() : outline.getXmlUrl());
|
||||||
: outline.getXmlUrl());
|
} else if ((outline.getType() != null) && outline.getType().equals("link")) {
|
||||||
} else if((outline.getType() != null) &&
|
|
||||||
outline.getType().equals("link")) {
|
|
||||||
entry.setLink(outline.getUrl());
|
entry.setLink(outline.getUrl());
|
||||||
}
|
}
|
||||||
|
|
||||||
if(outline.getHtmlUrl() != null) {
|
if (outline.getHtmlUrl() != null) {
|
||||||
SyndLink link = new SyndLinkImpl();
|
SyndLink link = new SyndLinkImpl();
|
||||||
link.setRel("alternate");
|
link.setRel("alternate");
|
||||||
link.setType("text/html");
|
link.setType("text/html");
|
||||||
|
@ -122,39 +115,37 @@ public class ConverterForOPML10 implements Converter {
|
||||||
entry.setLink(outline.getHtmlUrl());
|
entry.setLink(outline.getHtmlUrl());
|
||||||
}
|
}
|
||||||
|
|
||||||
if((outline.getXmlUrl() != null) && (outline.getType() != null) &&
|
if ((outline.getXmlUrl() != null) && (outline.getType() != null) && outline.getType().equalsIgnoreCase("rss")) {
|
||||||
outline.getType().equalsIgnoreCase("rss")) {
|
|
||||||
SyndLink link = new SyndLinkImpl();
|
SyndLink link = new SyndLinkImpl();
|
||||||
link.setRel("alternate");
|
link.setRel("alternate");
|
||||||
link.setType("application/rss+xml");
|
link.setType("application/rss+xml");
|
||||||
link.setHref(outline.getXmlUrl());
|
link.setHref(outline.getXmlUrl());
|
||||||
entry.getLinks().add(link);
|
entry.getLinks().add(link);
|
||||||
|
|
||||||
if(entry.getLink() == null) {
|
if (entry.getLink() == null) {
|
||||||
entry.setLink(outline.getXmlUrl());
|
entry.setLink(outline.getXmlUrl());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if((outline.getXmlUrl() != null) && (outline.getType() != null) &&
|
if ((outline.getXmlUrl() != null) && (outline.getType() != null) && outline.getType().equalsIgnoreCase("atom")) {
|
||||||
outline.getType().equalsIgnoreCase("atom")) {
|
|
||||||
SyndLink link = new SyndLinkImpl();
|
SyndLink link = new SyndLinkImpl();
|
||||||
link.setRel("alternate");
|
link.setRel("alternate");
|
||||||
link.setType("application/atom+xml");
|
link.setType("application/atom+xml");
|
||||||
link.setHref(outline.getXmlUrl());
|
link.setHref(outline.getXmlUrl());
|
||||||
entry.getLinks().add(link);
|
entry.getLinks().add(link);
|
||||||
|
|
||||||
if(entry.getLink() == null) {
|
if (entry.getLink() == null) {
|
||||||
entry.setLink(outline.getXmlUrl());
|
entry.setLink(outline.getXmlUrl());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if((outline.getType() != null) && outline.getType().equals("rss")) {
|
if ((outline.getType() != null) && outline.getType().equals("rss")) {
|
||||||
entry.setTitle(outline.getTitle());
|
entry.setTitle(outline.getTitle());
|
||||||
} else {
|
} else {
|
||||||
entry.setTitle(outline.getText());
|
entry.setTitle(outline.getText());
|
||||||
}
|
}
|
||||||
|
|
||||||
if((outline.getText() == null) && (entry.getTitle() != null)) {
|
if ((outline.getText() == null) && (entry.getTitle() != null)) {
|
||||||
SyndContent c = new SyndContentImpl();
|
SyndContent c = new SyndContentImpl();
|
||||||
c.setValue(outline.getText());
|
c.setValue(outline.getText());
|
||||||
entry.setDescription(c);
|
entry.setDescription(c);
|
||||||
|
@ -169,7 +160,7 @@ public class ConverterForOPML10 implements Converter {
|
||||||
cat.setName(nodeName);
|
cat.setName(nodeName);
|
||||||
entry.getCategories().add(cat);
|
entry.getCategories().add(cat);
|
||||||
|
|
||||||
if(context.size() > 0) {
|
if (context.size() > 0) {
|
||||||
Integer parent = (Integer) context.peek();
|
Integer parent = (Integer) context.peek();
|
||||||
SyndCategory pcat = new TreeCategoryImpl();
|
SyndCategory pcat = new TreeCategoryImpl();
|
||||||
pcat.setTaxonomyUri(URI_TREE);
|
pcat.setTaxonomyUri(URI_TREE);
|
||||||
|
@ -179,7 +170,7 @@ public class ConverterForOPML10 implements Converter {
|
||||||
|
|
||||||
List attributes = Collections.synchronizedList(outline.getAttributes());
|
List attributes = Collections.synchronizedList(outline.getAttributes());
|
||||||
|
|
||||||
for(int i = 0; i < attributes.size(); i++) {
|
for (int i = 0; i < attributes.size(); i++) {
|
||||||
Attribute a = (Attribute) attributes.get(i);
|
Attribute a = (Attribute) attributes.get(i);
|
||||||
SyndCategory acat = new SyndCategoryImpl();
|
SyndCategory acat = new SyndCategoryImpl();
|
||||||
acat.setName(a.getValue());
|
acat.setName(a.getValue());
|
||||||
|
@ -204,6 +195,7 @@ public class ConverterForOPML10 implements Converter {
|
||||||
* @return a real feed with copied/converted values of the SyndFeedImpl.
|
* @return a real feed with copied/converted values of the SyndFeedImpl.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public WireFeed createRealFeed(SyndFeed syndFeed) {
|
public WireFeed createRealFeed(SyndFeed syndFeed) {
|
||||||
List entries = Collections.synchronizedList(syndFeed.getEntries());
|
List entries = Collections.synchronizedList(syndFeed.getEntries());
|
||||||
|
|
||||||
|
@ -211,7 +203,7 @@ public class ConverterForOPML10 implements Converter {
|
||||||
ArrayList doAfterPass = new ArrayList(); // this will hold entries that we can't parent the first time.
|
ArrayList doAfterPass = new ArrayList(); // this will hold entries that we can't parent the first time.
|
||||||
ArrayList root = new ArrayList(); // this holds root level outlines;
|
ArrayList root = new ArrayList(); // this holds root level outlines;
|
||||||
|
|
||||||
for(int i = 0; i < entries.size(); i++) {
|
for (int i = 0; i < entries.size(); i++) {
|
||||||
SyndEntry entry = (SyndEntry) entries.get(i);
|
SyndEntry entry = (SyndEntry) entries.get(i);
|
||||||
Outline o = new Outline();
|
Outline o = new Outline();
|
||||||
|
|
||||||
|
@ -219,36 +211,30 @@ public class ConverterForOPML10 implements Converter {
|
||||||
boolean parentFound = false;
|
boolean parentFound = false;
|
||||||
StringBuffer category = new StringBuffer();
|
StringBuffer category = new StringBuffer();
|
||||||
|
|
||||||
for(int j = 0; j < cats.size(); j++) {
|
for (int j = 0; j < cats.size(); j++) {
|
||||||
SyndCategory cat = (SyndCategory) cats.get(j);
|
SyndCategory cat = (SyndCategory) cats.get(j);
|
||||||
|
|
||||||
if((cat.getTaxonomyUri() != null) &&
|
if ((cat.getTaxonomyUri() != null) && cat.getTaxonomyUri().equals(URI_TREE)) {
|
||||||
cat.getTaxonomyUri().equals(URI_TREE)) {
|
String nodeVal = cat.getName().substring(cat.getName().lastIndexOf("."), cat.getName().length());
|
||||||
String nodeVal = cat.getName()
|
|
||||||
.substring(cat.getName().lastIndexOf("."),
|
|
||||||
cat.getName().length());
|
|
||||||
|
|
||||||
if(cat.getName().startsWith("node.")) {
|
if (cat.getName().startsWith("node.")) {
|
||||||
entriesByNode.put(nodeVal, o);
|
entriesByNode.put(nodeVal, o);
|
||||||
} else if(cat.getName().startsWith("parent.")) {
|
} else if (cat.getName().startsWith("parent.")) {
|
||||||
parentFound = true;
|
parentFound = true;
|
||||||
|
|
||||||
Outline parent = (Outline) entriesByNode.get(nodeVal);
|
Outline parent = (Outline) entriesByNode.get(nodeVal);
|
||||||
|
|
||||||
if(parent != null) {
|
if (parent != null) {
|
||||||
parent.getChildren().add(o);
|
parent.getChildren().add(o);
|
||||||
} else {
|
} else {
|
||||||
doAfterPass.add(new OutlineHolder(o, nodeVal));
|
doAfterPass.add(new OutlineHolder(o, nodeVal));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if((cat.getTaxonomyUri() != null) &&
|
} else if ((cat.getTaxonomyUri() != null) && cat.getTaxonomyUri().startsWith(URI_ATTRIBUTE)) {
|
||||||
cat.getTaxonomyUri().startsWith(URI_ATTRIBUTE)) {
|
String name = cat.getTaxonomyUri().substring(cat.getTaxonomyUri().indexOf("#") + 1, cat.getTaxonomyUri().length());
|
||||||
String name = cat.getTaxonomyUri()
|
|
||||||
.substring(cat.getTaxonomyUri().indexOf("#") +
|
|
||||||
1, cat.getTaxonomyUri().length());
|
|
||||||
o.getAttributes().add(new Attribute(name, cat.getName()));
|
o.getAttributes().add(new Attribute(name, cat.getName()));
|
||||||
} else {
|
} else {
|
||||||
if(category.length() > 0) {
|
if (category.length() > 0) {
|
||||||
category.append(", ");
|
category.append(", ");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -256,64 +242,57 @@ public class ConverterForOPML10 implements Converter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!parentFound) {
|
if (!parentFound) {
|
||||||
root.add(o);
|
root.add(o);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(category.length() > 0) {
|
if (category.length() > 0) {
|
||||||
o.getAttributes()
|
o.getAttributes().add(new Attribute("category", category.toString()));
|
||||||
.add(new Attribute("category", category.toString()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
List links = Collections.synchronizedList(entry.getLinks());
|
List links = Collections.synchronizedList(entry.getLinks());
|
||||||
String entryLink = entry.getLink();
|
String entryLink = entry.getLink();
|
||||||
|
|
||||||
for(int j = 0; j < links.size(); j++) {
|
for (int j = 0; j < links.size(); j++) {
|
||||||
SyndLink link = (SyndLink) links.get(j);
|
SyndLink link = (SyndLink) links.get(j);
|
||||||
|
|
||||||
//if(link.getHref().equals(entryLink)) {
|
// if(link.getHref().equals(entryLink)) {
|
||||||
if(((link.getType() != null) && (link.getRel() != null) &&
|
if (((link.getType() != null) && (link.getRel() != null) && link.getRel().equals("alternate"))
|
||||||
link.getRel().equals("alternate")) &&
|
&& (link.getType().equals("application/rss+xml") || link.getType().equals("application/atom+xml"))) {
|
||||||
(link.getType().equals("application/rss+xml") ||
|
|
||||||
link.getType().equals("application/atom+xml"))) {
|
|
||||||
o.setType("rss");
|
o.setType("rss");
|
||||||
|
|
||||||
if(o.getXmlUrl() == null) {
|
if (o.getXmlUrl() == null) {
|
||||||
o.getAttributes()
|
o.getAttributes().add(new Attribute("xmlUrl", link.getHref()));
|
||||||
.add(new Attribute("xmlUrl", link.getHref()));
|
|
||||||
}
|
}
|
||||||
} else if((link.getType() != null) &&
|
} else if ((link.getType() != null) && (link.getType().equals("text/html"))) {
|
||||||
(link.getType().equals("text/html"))) {
|
if (o.getHtmlUrl() == null) {
|
||||||
if(o.getHtmlUrl() == null) {
|
o.getAttributes().add(new Attribute("htmlUrl", link.getHref()));
|
||||||
o.getAttributes()
|
|
||||||
.add(new Attribute("htmlUrl", link.getHref()));
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
o.setType(link.getType());
|
o.setType(link.getType());
|
||||||
}
|
}
|
||||||
|
|
||||||
//}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
if((o.getType() == null) || o.getType().equals("link")) {
|
if ((o.getType() == null) || o.getType().equals("link")) {
|
||||||
o.setText(entry.getTitle());
|
o.setText(entry.getTitle());
|
||||||
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
o.setTitle(entry.getTitle());
|
o.setTitle(entry.getTitle());
|
||||||
}
|
}
|
||||||
|
|
||||||
if((o.getText() == null) && (entry.getDescription() != null)) {
|
if ((o.getText() == null) && (entry.getDescription() != null)) {
|
||||||
o.setText(entry.getDescription().getValue());
|
o.setText(entry.getDescription().getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Do back and parenting for things we missed.
|
// Do back and parenting for things we missed.
|
||||||
for(int i = 0; i < doAfterPass.size(); i++) {
|
for (int i = 0; i < doAfterPass.size(); i++) {
|
||||||
OutlineHolder o = (OutlineHolder) doAfterPass.get(i);
|
OutlineHolder o = (OutlineHolder) doAfterPass.get(i);
|
||||||
Outline parent = (Outline) entriesByNode.get(o.parent);
|
Outline parent = (Outline) entriesByNode.get(o.parent);
|
||||||
|
|
||||||
if(parent == null) {
|
if (parent == null) {
|
||||||
root.add(o.outline);
|
root.add(o.outline);
|
||||||
LOG.warning("Unable to find parent node :" + o.parent);
|
LOG.warning("Unable to find parent node :" + o.parent);
|
||||||
} else {
|
} else {
|
||||||
|
@ -328,11 +307,10 @@ public class ConverterForOPML10 implements Converter {
|
||||||
|
|
||||||
List authors = Collections.synchronizedList(syndFeed.getAuthors());
|
List authors = Collections.synchronizedList(syndFeed.getAuthors());
|
||||||
|
|
||||||
for(int i = 0; i < authors.size(); i++) {
|
for (int i = 0; i < authors.size(); i++) {
|
||||||
SyndPerson p = (SyndPerson) authors.get(i);
|
SyndPerson p = (SyndPerson) authors.get(i);
|
||||||
|
|
||||||
if((syndFeed.getAuthor() == null) ||
|
if ((syndFeed.getAuthor() == null) || syndFeed.getAuthor().equals(p.getName())) {
|
||||||
syndFeed.getAuthor().equals(p.getName())) {
|
|
||||||
opml.setOwnerName(p.getName());
|
opml.setOwnerName(p.getName());
|
||||||
opml.setOwnerEmail(p.getEmail());
|
opml.setOwnerEmail(p.getEmail());
|
||||||
opml.setOwnerId(p.getUri());
|
opml.setOwnerId(p.getUri());
|
||||||
|
@ -350,8 +328,9 @@ public class ConverterForOPML10 implements Converter {
|
||||||
*
|
*
|
||||||
* @return the real feed type.
|
* @return the real feed type.
|
||||||
* @see WireFeed for details on the format of this string.
|
* @see WireFeed for details on the format of this string.
|
||||||
* <p>
|
* <p>
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public String getType() {
|
public String getType() {
|
||||||
return "opml_1.0";
|
return "opml_1.0";
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,6 @@ package org.rometools.feed.synd.impl;
|
||||||
import com.sun.syndication.feed.WireFeed;
|
import com.sun.syndication.feed.WireFeed;
|
||||||
import com.sun.syndication.feed.synd.SyndFeed;
|
import com.sun.syndication.feed.synd.SyndFeed;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author cooper
|
* @author cooper
|
||||||
|
@ -28,8 +27,9 @@ public class ConverterForOPML20 extends ConverterForOPML10 {
|
||||||
*
|
*
|
||||||
* @return the real feed type.
|
* @return the real feed type.
|
||||||
* @see WireFeed for details on the format of this string.
|
* @see WireFeed for details on the format of this string.
|
||||||
* <p>
|
* <p>
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public String getType() {
|
public String getType() {
|
||||||
return "opml_2.0";
|
return "opml_2.0";
|
||||||
}
|
}
|
||||||
|
@ -43,6 +43,7 @@ public class ConverterForOPML20 extends ConverterForOPML10 {
|
||||||
* @param feed real feed to copy/convert.
|
* @param feed real feed to copy/convert.
|
||||||
* @param syndFeed the SyndFeedImpl that will contain the copied/converted values of the real feed.
|
* @param syndFeed the SyndFeedImpl that will contain the copied/converted values of the real feed.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void copyInto(WireFeed feed, SyndFeed syndFeed) {
|
public void copyInto(WireFeed feed, SyndFeed syndFeed) {
|
||||||
super.copyInto(feed, syndFeed);
|
super.copyInto(feed, syndFeed);
|
||||||
}
|
}
|
||||||
|
@ -54,6 +55,7 @@ public class ConverterForOPML20 extends ConverterForOPML10 {
|
||||||
* @param syndFeed SyndFeedImpl to copy/convert value from.
|
* @param syndFeed SyndFeedImpl to copy/convert value from.
|
||||||
* @return a real feed with copied/converted values of the SyndFeedImpl.
|
* @return a real feed with copied/converted values of the SyndFeedImpl.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public WireFeed createRealFeed(SyndFeed syndFeed) {
|
public WireFeed createRealFeed(SyndFeed syndFeed) {
|
||||||
WireFeed retValue;
|
WireFeed retValue;
|
||||||
|
|
||||||
|
|
|
@ -23,9 +23,10 @@ public class TreeCategoryImpl extends SyndCategoryImpl {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
SyndCategory c = (SyndCategory) o;
|
SyndCategory c = (SyndCategory) o;
|
||||||
if( c.getTaxonomyUri() != null && c.getTaxonomyUri().equals( this.getTaxonomyUri() ) )
|
if (c.getTaxonomyUri() != null && c.getTaxonomyUri().equals(this.getTaxonomyUri()))
|
||||||
return true;
|
return true;
|
||||||
else
|
else
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -26,14 +26,13 @@ import com.sun.syndication.io.WireFeedGenerator;
|
||||||
import com.sun.syndication.io.impl.BaseWireFeedGenerator;
|
import com.sun.syndication.io.impl.BaseWireFeedGenerator;
|
||||||
import com.sun.syndication.io.impl.DateParser;
|
import com.sun.syndication.io.impl.DateParser;
|
||||||
|
|
||||||
import org.jdom.Document;
|
import org.jdom2.Document;
|
||||||
import org.jdom.Element;
|
import org.jdom2.Element;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author <a href="mailto:cooper@screaming-penguin.com">Robert "kebernet" Cooper</a>
|
* @author <a href="mailto:cooper@screaming-penguin.com">Robert "kebernet" Cooper</a>
|
||||||
|
@ -54,10 +53,10 @@ public class OPML10Generator extends BaseWireFeedGenerator implements WireFeedGe
|
||||||
*
|
*
|
||||||
* @param feed the feed bean to generate the XML document from.
|
* @param feed the feed bean to generate the XML document from.
|
||||||
* @return the generated XML document (JDOM).
|
* @return the generated XML document (JDOM).
|
||||||
* @throws IllegalArgumentException thrown if the type of the given feed bean does not
|
* @throws IllegalArgumentException thrown if the type of the given feed bean does not match with the type of the WireFeedGenerator.
|
||||||
* match with the type of the WireFeedGenerator.
|
|
||||||
* @throws FeedException thrown if the XML Document could not be created.
|
* @throws FeedException thrown if the XML Document could not be created.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public Document generate(WireFeed feed) throws IllegalArgumentException, FeedException {
|
public Document generate(WireFeed feed) throws IllegalArgumentException, FeedException {
|
||||||
if (!(feed instanceof Opml)) {
|
if (!(feed instanceof Opml)) {
|
||||||
throw new IllegalArgumentException("Not an OPML file");
|
throw new IllegalArgumentException("Not an OPML file");
|
||||||
|
|
|
@ -26,8 +26,8 @@ import com.sun.syndication.io.WireFeedParser;
|
||||||
import com.sun.syndication.io.impl.BaseWireFeedParser;
|
import com.sun.syndication.io.impl.BaseWireFeedParser;
|
||||||
import com.sun.syndication.io.impl.DateParser;
|
import com.sun.syndication.io.impl.DateParser;
|
||||||
|
|
||||||
import org.jdom.Document;
|
import org.jdom2.Document;
|
||||||
import org.jdom.Element;
|
import org.jdom2.Element;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -35,7 +35,6 @@ import java.util.StringTokenizer;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author <a href="mailto:cooper@screaming-penguin.com">Robert "kebernet" Cooper</a>
|
* @author <a href="mailto:cooper@screaming-penguin.com">Robert "kebernet" Cooper</a>
|
||||||
|
@ -61,12 +60,12 @@ public class OPML10Parser extends BaseWireFeedParser implements WireFeedParser {
|
||||||
* @param document XML Document (JDOM) to check if it can be parsed by this parser.
|
* @param document XML Document (JDOM) to check if it can be parsed by this parser.
|
||||||
* @return <b>true</b> if the parser know how to parser this feed, <b>false</b> otherwise.
|
* @return <b>true</b> if the parser know how to parser this feed, <b>false</b> otherwise.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public boolean isMyType(Document document) {
|
public boolean isMyType(Document document) {
|
||||||
Element e = document.getRootElement();
|
Element e = document.getRootElement();
|
||||||
|
|
||||||
if (e.getName().equals("opml")
|
if (e.getName().equals("opml") && (e.getChild("head") == null || e.getChild("head").getChild("docs") == null)
|
||||||
&& ( e.getChild("head") == null || e.getChild("head").getChild("docs") == null)
|
&& (e.getAttributeValue("version") == null || e.getAttributeValue("version").equals("1.0"))) {
|
||||||
&& (e.getAttributeValue("version") == null || e.getAttributeValue("version").equals("1.0"))) {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,6 +82,7 @@ public class OPML10Parser extends BaseWireFeedParser implements WireFeedParser {
|
||||||
* @throws IllegalArgumentException thrown if the parser cannot handle the given feed type.
|
* @throws IllegalArgumentException thrown if the parser cannot handle the given feed type.
|
||||||
* @throws FeedException thrown if a feed bean cannot be created out of the XML document (JDOM).
|
* @throws FeedException thrown if a feed bean cannot be created out of the XML document (JDOM).
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public WireFeed parse(Document document, boolean validate) throws IllegalArgumentException, FeedException {
|
public WireFeed parse(Document document, boolean validate) throws IllegalArgumentException, FeedException {
|
||||||
Opml opml = new Opml();
|
Opml opml = new Opml();
|
||||||
opml.setFeedType("opml_1.0");
|
opml.setFeedType("opml_1.0");
|
||||||
|
@ -182,9 +182,10 @@ public class OPML10Parser extends BaseWireFeedParser implements WireFeedParser {
|
||||||
ArrayList attributes = new ArrayList();
|
ArrayList attributes = new ArrayList();
|
||||||
|
|
||||||
for (int i = 0; i < jAttributes.size(); i++) {
|
for (int i = 0; i < jAttributes.size(); i++) {
|
||||||
org.jdom.Attribute a = (org.jdom.Attribute) jAttributes.get(i);
|
org.jdom2.Attribute a = (org.jdom2.Attribute) jAttributes.get(i);
|
||||||
|
|
||||||
if (!a.getName().equals("isBreakpoint") && !a.getName().equals("isComment") && !a.getName().equals("title") && !a.getName().equals("text") && !a.getName().equals("type")) {
|
if (!a.getName().equals("isBreakpoint") && !a.getName().equals("isComment") && !a.getName().equals("title") && !a.getName().equals("text")
|
||||||
|
&& !a.getName().equals("type")) {
|
||||||
attributes.add(new Attribute(a.getName(), a.getValue()));
|
attributes.add(new Attribute(a.getName(), a.getValue()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,9 +14,8 @@ import org.rometools.feed.opml.Outline;
|
||||||
import com.sun.syndication.io.FeedException;
|
import com.sun.syndication.io.FeedException;
|
||||||
import com.sun.syndication.io.impl.DateParser;
|
import com.sun.syndication.io.impl.DateParser;
|
||||||
|
|
||||||
import org.jdom.Document;
|
import org.jdom2.Document;
|
||||||
import org.jdom.Element;
|
import org.jdom2.Element;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -33,8 +32,9 @@ public class OPML20Generator extends OPML10Generator {
|
||||||
*
|
*
|
||||||
* @return the type of feed the generator creates.
|
* @return the type of feed the generator creates.
|
||||||
* @see WireFeed for details on the format of this string.
|
* @see WireFeed for details on the format of this string.
|
||||||
* <p>
|
* <p>
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public String getType() {
|
public String getType() {
|
||||||
return "opml_2.0";
|
return "opml_2.0";
|
||||||
}
|
}
|
||||||
|
@ -45,10 +45,10 @@ public class OPML20Generator extends OPML10Generator {
|
||||||
*
|
*
|
||||||
* @param feed the feed bean to generate the XML document from.
|
* @param feed the feed bean to generate the XML document from.
|
||||||
* @return the generated XML document (JDOM).
|
* @return the generated XML document (JDOM).
|
||||||
* @throws IllegalArgumentException thrown if the type of the given feed bean does not
|
* @throws IllegalArgumentException thrown if the type of the given feed bean does not match with the type of the WireFeedGenerator.
|
||||||
* match with the type of the WireFeedGenerator.
|
|
||||||
* @throws FeedException thrown if the XML Document could not be created.
|
* @throws FeedException thrown if the XML Document could not be created.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public Document generate(WireFeed feed) throws IllegalArgumentException, FeedException {
|
public Document generate(WireFeed feed) throws IllegalArgumentException, FeedException {
|
||||||
Document retValue;
|
Document retValue;
|
||||||
|
|
||||||
|
@ -58,6 +58,7 @@ public class OPML20Generator extends OPML10Generator {
|
||||||
return retValue;
|
return retValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected Element generateHead(Opml opml) {
|
protected Element generateHead(Opml opml) {
|
||||||
Element retValue;
|
Element retValue;
|
||||||
|
|
||||||
|
@ -69,6 +70,7 @@ public class OPML20Generator extends OPML10Generator {
|
||||||
return retValue;
|
return retValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected Element generateOutline(Outline outline) {
|
protected Element generateOutline(Outline outline) {
|
||||||
Element retValue;
|
Element retValue;
|
||||||
|
|
||||||
|
|
|
@ -24,13 +24,10 @@ import org.rometools.feed.opml.Outline;
|
||||||
import com.sun.syndication.io.FeedException;
|
import com.sun.syndication.io.FeedException;
|
||||||
import com.sun.syndication.io.impl.DateParser;
|
import com.sun.syndication.io.impl.DateParser;
|
||||||
|
|
||||||
import org.jdom.Document;
|
import org.jdom2.Document;
|
||||||
import org.jdom.Element;
|
import org.jdom2.Element;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.StringTokenizer;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -51,10 +48,14 @@ public class OPML20Parser extends OPML10Parser {
|
||||||
* @param document XML Document (JDOM) to check if it can be parsed by this parser.
|
* @param document XML Document (JDOM) to check if it can be parsed by this parser.
|
||||||
* @return <b>true</b> if the parser know how to parser this feed, <b>false</b> otherwise.
|
* @return <b>true</b> if the parser know how to parser this feed, <b>false</b> otherwise.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public boolean isMyType(Document document) {
|
public boolean isMyType(Document document) {
|
||||||
Element e = document.getRootElement();
|
Element e = document.getRootElement();
|
||||||
|
|
||||||
if (e.getName().equals("opml") && (((e.getChild("head") != null) && (e.getChild("head").getChild("docs") != null)) || ((e.getAttributeValue("version") != null) && e.getAttributeValue("version").equals("2.0")) || ((e.getChild("head") != null) && (e.getChild("head").getChild("ownerId") != null)))) {
|
if (e.getName().equals("opml")
|
||||||
|
&& (((e.getChild("head") != null) && (e.getChild("head").getChild("docs") != null))
|
||||||
|
|| ((e.getAttributeValue("version") != null) && e.getAttributeValue("version").equals("2.0")) || ((e.getChild("head") != null) && (e
|
||||||
|
.getChild("head").getChild("ownerId") != null)))) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,6 +72,7 @@ public class OPML20Parser extends OPML10Parser {
|
||||||
* @throws IllegalArgumentException thrown if the parser cannot handle the given feed type.
|
* @throws IllegalArgumentException thrown if the parser cannot handle the given feed type.
|
||||||
* @throws FeedException thrown if a feed bean cannot be created out of the XML document (JDOM).
|
* @throws FeedException thrown if a feed bean cannot be created out of the XML document (JDOM).
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public WireFeed parse(Document document, boolean validate) throws IllegalArgumentException, FeedException {
|
public WireFeed parse(Document document, boolean validate) throws IllegalArgumentException, FeedException {
|
||||||
Opml opml;
|
Opml opml;
|
||||||
opml = (Opml) super.parse(document, validate);
|
opml = (Opml) super.parse(document, validate);
|
||||||
|
@ -91,6 +93,7 @@ public class OPML20Parser extends OPML10Parser {
|
||||||
return opml;
|
return opml;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected Outline parseOutline(Element e, boolean validate) throws FeedException {
|
protected Outline parseOutline(Element e, boolean validate) throws FeedException {
|
||||||
Outline retValue;
|
Outline retValue;
|
||||||
|
|
||||||
|
|
|
@ -1,63 +1,64 @@
|
||||||
package org.rometools.unittest;
|
package org.rometools.unittest;
|
||||||
|
|
||||||
|
import java.io.ByteArrayInputStream;
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.ObjectInputStream;
|
||||||
|
import java.io.ObjectOutputStream;
|
||||||
|
|
||||||
import com.sun.syndication.feed.WireFeed;
|
import com.sun.syndication.feed.WireFeed;
|
||||||
import com.sun.syndication.feed.synd.SyndFeed;
|
import com.sun.syndication.feed.synd.SyndFeed;
|
||||||
import com.sun.syndication.feed.synd.SyndFeedImpl;
|
import com.sun.syndication.feed.synd.SyndFeedImpl;
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
|
||||||
import java.io.ObjectOutputStream;
|
|
||||||
import java.io.ByteArrayInputStream;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.ObjectInputStream;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* <p>
|
* <p>
|
||||||
|
*
|
||||||
* @author Alejandro Abdelnur
|
* @author Alejandro Abdelnur
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public abstract class FeedOpsTest extends FeedTest {
|
public abstract class FeedOpsTest extends FeedTest {
|
||||||
|
|
||||||
protected FeedOpsTest(String feedType) {
|
protected FeedOpsTest(final String feedType) {
|
||||||
super(feedType+".xml");
|
super(feedType + ".xml");
|
||||||
System.out.println("Testing "+feedType+".xml");
|
|
||||||
new File("target/test-reports").mkdirs();
|
new File("target/test-reports").mkdirs();
|
||||||
}
|
}
|
||||||
|
|
||||||
//1.2a
|
// 1.2a
|
||||||
public void testWireFeedEquals() throws Exception {
|
public void testWireFeedEquals() throws Exception {
|
||||||
WireFeed feed1 = getCachedWireFeed();
|
final WireFeed feed1 = getCachedWireFeed();
|
||||||
WireFeed feed2 = getWireFeed();
|
final WireFeed feed2 = getWireFeed();
|
||||||
assertTrue(feed1.equals(feed2));
|
assertTrue(feed1.equals(feed2));
|
||||||
}
|
}
|
||||||
|
|
||||||
//1.2b
|
// 1.2b
|
||||||
public void testWireFeedNotEqual() throws Exception {
|
public void testWireFeedNotEqual() throws Exception {
|
||||||
WireFeed feed1 = getCachedWireFeed();
|
final WireFeed feed1 = getCachedWireFeed();
|
||||||
WireFeed feed2 = getWireFeed();
|
final WireFeed feed2 = getWireFeed();
|
||||||
feed2.setFeedType("dummy");
|
feed2.setFeedType("dummy");
|
||||||
assertFalse(feed1.equals(feed2));
|
assertFalse(feed1.equals(feed2));
|
||||||
}
|
}
|
||||||
|
|
||||||
//1.3
|
// 1.3
|
||||||
public void testWireFeedCloning() throws Exception {
|
public void testWireFeedCloning() throws Exception {
|
||||||
WireFeed feed1 = getCachedWireFeed();
|
final WireFeed feed1 = getCachedWireFeed();
|
||||||
WireFeed feed2 = (WireFeed) feed1.clone();;
|
final WireFeed feed2 = (WireFeed) feed1.clone();
|
||||||
|
;
|
||||||
assertTrue(feed1.equals(feed2));
|
assertTrue(feed1.equals(feed2));
|
||||||
}
|
}
|
||||||
|
|
||||||
// 1.4
|
// 1.4
|
||||||
public void testWireFeedSerialization() throws Exception {
|
public void testWireFeedSerialization() throws Exception {
|
||||||
WireFeed feed1 = getCachedWireFeed();
|
final WireFeed feed1 = getCachedWireFeed();
|
||||||
|
|
||||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||||
ObjectOutputStream oos = new ObjectOutputStream(baos);
|
final ObjectOutputStream oos = new ObjectOutputStream(baos);
|
||||||
oos.writeObject(feed1);
|
oos.writeObject(feed1);
|
||||||
oos.close();
|
oos.close();
|
||||||
|
|
||||||
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
|
final ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
|
||||||
ObjectInputStream ois = new ObjectInputStream(bais);
|
final ObjectInputStream ois = new ObjectInputStream(bais);
|
||||||
WireFeed feed2 = (WireFeed) ois.readObject();
|
final WireFeed feed2 = (WireFeed) ois.readObject();
|
||||||
ois.close();
|
ois.close();
|
||||||
|
|
||||||
assertTrue(feed1.equals(feed2));
|
assertTrue(feed1.equals(feed2));
|
||||||
|
@ -65,47 +66,48 @@ public abstract class FeedOpsTest extends FeedTest {
|
||||||
|
|
||||||
// 1.6
|
// 1.6
|
||||||
public void testWireFeedSyndFeedConversion() throws Exception {
|
public void testWireFeedSyndFeedConversion() throws Exception {
|
||||||
SyndFeed sFeed1 = getCachedSyndFeed();
|
final SyndFeed sFeed1 = getCachedSyndFeed();
|
||||||
WireFeed wFeed1 = sFeed1.createWireFeed();
|
final WireFeed wFeed1 = sFeed1.createWireFeed();
|
||||||
SyndFeed sFeed2 = new SyndFeedImpl(wFeed1);
|
final SyndFeed sFeed2 = new SyndFeedImpl(wFeed1);
|
||||||
|
|
||||||
assertEquals(sFeed1, sFeed2 );
|
assertEquals(sFeed1, sFeed2);
|
||||||
}
|
}
|
||||||
|
|
||||||
//1.7a
|
// 1.7a
|
||||||
public void testSyndFeedEquals() throws Exception {
|
public void testSyndFeedEquals() throws Exception {
|
||||||
SyndFeed feed1 = getCachedSyndFeed();
|
final SyndFeed feed1 = getCachedSyndFeed();
|
||||||
SyndFeed feed2 = getSyndFeed();
|
final SyndFeed feed2 = getSyndFeed();
|
||||||
assertTrue(feed1.equals(feed2));
|
assertTrue(feed1.equals(feed2));
|
||||||
}
|
}
|
||||||
|
|
||||||
//1.7b
|
// 1.7b
|
||||||
public void testSyndFeedNotEqual() throws Exception {
|
public void testSyndFeedNotEqual() throws Exception {
|
||||||
SyndFeed feed1 = getCachedSyndFeed();
|
final SyndFeed feed1 = getCachedSyndFeed();
|
||||||
SyndFeed feed2 = getSyndFeed();
|
final SyndFeed feed2 = getSyndFeed();
|
||||||
feed2.setFeedType("dummy");
|
feed2.setFeedType("dummy");
|
||||||
assertFalse(feed1.equals(feed2));
|
assertFalse(feed1.equals(feed2));
|
||||||
}
|
}
|
||||||
|
|
||||||
//1.8
|
// 1.8
|
||||||
public void testSyndFeedCloning() throws Exception {
|
public void testSyndFeedCloning() throws Exception {
|
||||||
SyndFeed feed1 = getCachedSyndFeed();
|
final SyndFeed feed1 = getCachedSyndFeed();
|
||||||
SyndFeed feed2 = (SyndFeed) feed1.clone();;
|
final SyndFeed feed2 = (SyndFeed) feed1.clone();
|
||||||
|
;
|
||||||
assertTrue(feed1.equals(feed2));
|
assertTrue(feed1.equals(feed2));
|
||||||
}
|
}
|
||||||
|
|
||||||
//1.9
|
// 1.9
|
||||||
public void testSyndFeedSerialization() throws Exception {
|
public void testSyndFeedSerialization() throws Exception {
|
||||||
SyndFeed feed1 = getCachedSyndFeed();
|
final SyndFeed feed1 = getCachedSyndFeed();
|
||||||
|
|
||||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||||
ObjectOutputStream oos = new ObjectOutputStream(baos);
|
final ObjectOutputStream oos = new ObjectOutputStream(baos);
|
||||||
oos.writeObject(feed1);
|
oos.writeObject(feed1);
|
||||||
oos.close();
|
oos.close();
|
||||||
|
|
||||||
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
|
final ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
|
||||||
ObjectInputStream ois = new ObjectInputStream(bais);
|
final ObjectInputStream ois = new ObjectInputStream(bais);
|
||||||
SyndFeed feed2 = (SyndFeed) ois.readObject();
|
final SyndFeed feed2 = (SyndFeed) ois.readObject();
|
||||||
ois.close();
|
ois.close();
|
||||||
|
|
||||||
assertTrue(feed1.equals(feed2));
|
assertTrue(feed1.equals(feed2));
|
||||||
|
|
|
@ -1,30 +1,30 @@
|
||||||
package org.rometools.unittest;
|
package org.rometools.unittest;
|
||||||
|
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.io.Reader;
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
import com.sun.syndication.feed.synd.SyndFeed;
|
import org.jdom2.Document;
|
||||||
|
import org.jdom2.input.SAXBuilder;
|
||||||
|
|
||||||
import com.sun.syndication.feed.WireFeed;
|
import com.sun.syndication.feed.WireFeed;
|
||||||
|
import com.sun.syndication.feed.synd.SyndFeed;
|
||||||
import com.sun.syndication.io.SyndFeedInput;
|
import com.sun.syndication.io.SyndFeedInput;
|
||||||
import com.sun.syndication.io.WireFeedInput;
|
import com.sun.syndication.io.WireFeedInput;
|
||||||
|
|
||||||
import java.io.InputStreamReader;
|
|
||||||
import java.io.Reader;
|
|
||||||
import java.io.InputStream;
|
|
||||||
|
|
||||||
import org.jdom.Document;
|
|
||||||
import org.jdom.input.SAXBuilder;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author pat, tucu
|
* @author pat, tucu
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public abstract class FeedTest extends TestCase {
|
public abstract class FeedTest extends TestCase {
|
||||||
private String _feedFileName;
|
private final String _feedFileName;
|
||||||
private Document _jDomDoc = null;
|
private Document _jDomDoc = null;
|
||||||
private WireFeed _wireFeed = null;
|
private WireFeed _wireFeed = null;
|
||||||
private SyndFeed _syndFeed = null;
|
private SyndFeed _syndFeed = null;
|
||||||
|
|
||||||
protected FeedTest(String feedFileName) {
|
protected FeedTest(final String feedFileName) {
|
||||||
_feedFileName = feedFileName;
|
_feedFileName = feedFileName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,43 +33,42 @@ public abstract class FeedTest extends TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Reader getFeedReader() throws Exception {
|
protected Reader getFeedReader() throws Exception {
|
||||||
InputStream resource = Thread.currentThread().
|
final InputStream resource = Thread.currentThread().getContextClassLoader().getResourceAsStream(getFeedFileName());
|
||||||
getContextClassLoader().getResourceAsStream(getFeedFileName());
|
assertNotNull("Could not find resource " + getFeedFileName(), resource);
|
||||||
assertNotNull("Could not find resource " + getFeedFileName(), resource);
|
return new InputStreamReader(resource);
|
||||||
return new InputStreamReader(resource);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Document getJDomDoc() throws Exception {
|
protected Document getJDomDoc() throws Exception {
|
||||||
SAXBuilder saxBuilder = new SAXBuilder(false);
|
final SAXBuilder saxBuilder = new SAXBuilder(false);
|
||||||
return saxBuilder.build(getFeedReader());
|
return saxBuilder.build(getFeedReader());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected WireFeed getWireFeed() throws Exception {
|
protected WireFeed getWireFeed() throws Exception {
|
||||||
WireFeedInput in = new WireFeedInput();
|
final WireFeedInput in = new WireFeedInput();
|
||||||
return in.build(getFeedReader());
|
return in.build(getFeedReader());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected SyndFeed getSyndFeed() throws Exception {
|
protected SyndFeed getSyndFeed() throws Exception {
|
||||||
SyndFeedInput in = new SyndFeedInput();
|
final SyndFeedInput in = new SyndFeedInput();
|
||||||
return in.build(getFeedReader());
|
return in.build(getFeedReader());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Document getCachedJDomDoc() throws Exception {
|
protected Document getCachedJDomDoc() throws Exception {
|
||||||
if (_jDomDoc==null) {
|
if (_jDomDoc == null) {
|
||||||
_jDomDoc = getJDomDoc();
|
_jDomDoc = getJDomDoc();
|
||||||
}
|
}
|
||||||
return _jDomDoc;
|
return _jDomDoc;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected WireFeed getCachedWireFeed() throws Exception {
|
protected WireFeed getCachedWireFeed() throws Exception {
|
||||||
if (_wireFeed==null) {
|
if (_wireFeed == null) {
|
||||||
_wireFeed = getWireFeed();
|
_wireFeed = getWireFeed();
|
||||||
}
|
}
|
||||||
return _wireFeed;
|
return _wireFeed;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected SyndFeed getCachedSyndFeed() throws Exception {
|
protected SyndFeed getCachedSyndFeed() throws Exception {
|
||||||
if (_syndFeed==null) {
|
if (_syndFeed == null) {
|
||||||
_syndFeed = getSyndFeed();
|
_syndFeed = getSyndFeed();
|
||||||
}
|
}
|
||||||
return _syndFeed;
|
return _syndFeed;
|
||||||
|
|
|
@ -6,21 +6,18 @@
|
||||||
*/
|
*/
|
||||||
package org.rometools.unittest;
|
package org.rometools.unittest;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author pat
|
* @author pat
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public abstract class SyndFeedTest extends FeedTest {
|
public abstract class SyndFeedTest extends FeedTest {
|
||||||
private String _prefix = null;
|
private String _prefix = null;
|
||||||
|
|
||||||
protected SyndFeedTest(String feedType) {
|
protected SyndFeedTest(String feedType) {
|
||||||
this(feedType,feedType+".xml");
|
this(feedType, feedType + ".xml");
|
||||||
}
|
}
|
||||||
|
|
||||||
protected SyndFeedTest(String feedType,String feedFileName) {
|
protected SyndFeedTest(String feedType, String feedFileName) {
|
||||||
super(feedFileName);
|
super(feedFileName);
|
||||||
_prefix = feedType;
|
_prefix = feedType;
|
||||||
}
|
}
|
||||||
|
@ -29,239 +26,117 @@ public abstract class SyndFeedTest extends FeedTest {
|
||||||
return _prefix;
|
return _prefix;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void assertProperty(String property, String value) {
|
protected void assertProperty(String property, String value) {
|
||||||
assertEquals(property,getPrefix() + "." + value);
|
assertEquals(property, getPrefix() + "." + value);
|
||||||
}
|
|
||||||
|
|
||||||
public void testType() throws Exception {
|
|
||||||
assertEquals(getCachedSyndFeed().getFeedType(),getPrefix());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testType() throws Exception {
|
||||||
|
assertEquals(getCachedSyndFeed().getFeedType(), getPrefix());
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
public void testType() throws Exception {
|
* public void testType() throws Exception { assertEquals(getPrefix(), getCachedSyndFeed().getFeedType()); }
|
||||||
assertEquals(getPrefix(), getCachedSyndFeed().getFeedType());
|
*
|
||||||
}
|
* public void testTitle() throws Exception { assertEqualsStr("channel.title", getCachedSyndFeed().getTitle()); }
|
||||||
|
*
|
||||||
public void testTitle() throws Exception {
|
* public void testLink() throws Exception { assertEqualsStr("channel.link", getCachedSyndFeed().getLink()); }
|
||||||
assertEqualsStr("channel.title", getCachedSyndFeed().getTitle());
|
*
|
||||||
}
|
* public void testDescription() throws Exception { assertEqualsStr("channel.description", getCachedSyndFeed().getDescription()); }
|
||||||
|
*
|
||||||
public void testLink() throws Exception {
|
* public void testLanguage() throws Exception { assertEqualsStr("channel.language", getCachedSyndFeed().getLanguage()); }
|
||||||
assertEqualsStr("channel.link", getCachedSyndFeed().getLink());
|
*
|
||||||
}
|
* public void testCategories() throws Exception { List catlist = getCachedSyndFeed().getCategories(); //don't understand why this one fails assertEquals(2,
|
||||||
|
* catlist.size()); SyndCategory cat = (SyndCategory)catlist.get(0); assertEqualsStr("channel.category[0]", cat.getName());
|
||||||
public void testDescription() throws Exception {
|
* assertEqualsStr("channel.category[0]^domain", cat.getTaxonomyUri()); cat = (SyndCategory)catlist.get(1); assertEqualsStr("channel.category[1]",
|
||||||
assertEqualsStr("channel.description", getCachedSyndFeed().getDescription());
|
* cat.getName()); assertEqualsStr("channel.category[1]^domain", cat.getTaxonomyUri()); }
|
||||||
}
|
*
|
||||||
|
* public void testPublishedDate() throws Exception { assertEquals(DateParser.parseRFC822("Mon, 01 Jan 2001 00:00:00 GMT"),
|
||||||
public void testLanguage() throws Exception {
|
* getCachedSyndFeed().getPublishedDate()); }
|
||||||
assertEqualsStr("channel.language", getCachedSyndFeed().getLanguage());
|
*
|
||||||
}
|
* //how do i get height and width? public void testImage() throws Exception { SyndImage img = getCachedSyndFeed().getImage();
|
||||||
|
* assertEqualsStr("channel.image.description", img.getDescription()); assertEqualsStr("channel.image.link", img.getLink());
|
||||||
public void testCategories() throws Exception {
|
* assertEqualsStr("channel.image.title", img.getTitle()); assertEqualsStr("channel.image.url", img.getUrl()); }
|
||||||
List catlist = getCachedSyndFeed().getCategories();
|
*
|
||||||
//don't understand why this one fails
|
* public void testEntries() throws Exception { List entrylist = getCachedSyndFeed().getEntries(); assertEquals(2, entrylist.size()); }
|
||||||
assertEquals(2, catlist.size());
|
*
|
||||||
SyndCategory cat = (SyndCategory)catlist.get(0);
|
* public void testEntryTitle() throws Exception { assertEqualsStr("channel.item[0].title", getEntryTitle(getCachedSyndFeed().getEntries().get(0)));
|
||||||
assertEqualsStr("channel.category[0]", cat.getName());
|
* assertEqualsStr("channel.item[1].title", getEntryTitle(getCachedSyndFeed().getEntries().get(1))); }
|
||||||
assertEqualsStr("channel.category[0]^domain", cat.getTaxonomyUri());
|
*
|
||||||
cat = (SyndCategory)catlist.get(1);
|
* public String getEntryTitle(Object o) throws Exception { SyndEntry e = (SyndEntry) o; return e.getTitle(); }
|
||||||
assertEqualsStr("channel.category[1]", cat.getName());
|
*
|
||||||
assertEqualsStr("channel.category[1]^domain", cat.getTaxonomyUri());
|
* public void testEntryDescription() throws Exception { assertEqualsStr("channel.item[0].description",
|
||||||
}
|
* getEntryDescription(getCachedSyndFeed().getEntries().get(0))); assertEqualsStr("channel.item[1].description",
|
||||||
|
* getEntryDescription(getCachedSyndFeed().getEntries().get(1))); }
|
||||||
public void testPublishedDate() throws Exception {
|
*
|
||||||
assertEquals(DateParser.parseRFC822("Mon, 01 Jan 2001 00:00:00 GMT"), getCachedSyndFeed().getPublishedDate());
|
* public String getEntryDescription(Object o) throws Exception { SyndEntry e = (SyndEntry) o; return e.getDescription().getValue(); }
|
||||||
}
|
*
|
||||||
|
* public void testEntryLink() throws Exception { assertEqualsStr("channel.item[0].link", getEntryLink(getCachedSyndFeed().getEntries().get(0)));
|
||||||
//how do i get height and width?
|
* assertEqualsStr("channel.item[1].link", getEntryLink(getCachedSyndFeed().getEntries().get(1))); }
|
||||||
public void testImage() throws Exception {
|
*
|
||||||
SyndImage img = getCachedSyndFeed().getImage();
|
* public String getEntryLink(Object o) { SyndEntry e = (SyndEntry) o; return e.getLink(); }
|
||||||
assertEqualsStr("channel.image.description", img.getDescription());
|
*
|
||||||
assertEqualsStr("channel.image.link", img.getLink());
|
* public void testEntryPublishedDate() throws Exception { assertEquals(DateParser.parseRFC822("Mon, 01 Jan 2001 00:00:00 GMT"),
|
||||||
assertEqualsStr("channel.image.title", img.getTitle());
|
* getEntryPublishedDate(getCachedSyndFeed().getEntries().get(0))); assertEquals(DateParser.parseRFC822("Mon, 01 Jan 2001 00:00:00 GMT"),
|
||||||
assertEqualsStr("channel.image.url", img.getUrl());
|
* getEntryPublishedDate(getCachedSyndFeed().getEntries().get(1))); }
|
||||||
}
|
*
|
||||||
|
* public Date getEntryPublishedDate(Object o) { SyndEntry e = (SyndEntry) o; return e.getPublishedDate(); }
|
||||||
public void testEntries() throws Exception {
|
*
|
||||||
List entrylist = getCachedSyndFeed().getEntries();
|
* public void testEntryCategories() throws Exception { SyndEntry e = (SyndEntry)getCachedSyndFeed().getEntries().get(0); List catlist = e.getCategories();
|
||||||
assertEquals(2, entrylist.size());
|
* //don't understand why this one fails assertEquals(2, catlist.size()); SyndCategory cat = (SyndCategory)catlist.get(0);
|
||||||
}
|
* assertEqualsStr("channel.item[0].category[0]", cat.getName()); assertEqualsStr("channel.item[0].category[0]^domain", cat.getTaxonomyUri()); cat =
|
||||||
|
* (SyndCategory)catlist.get(1); assertEqualsStr("channel.item[0].category[1]", cat.getName()); assertEqualsStr("channel.item[0].category[1]^domain",
|
||||||
public void testEntryTitle() throws Exception {
|
* cat.getTaxonomyUri()); //DO 2nd set of items }
|
||||||
assertEqualsStr("channel.item[0].title", getEntryTitle(getCachedSyndFeed().getEntries().get(0)));
|
*
|
||||||
assertEqualsStr("channel.item[1].title", getEntryTitle(getCachedSyndFeed().getEntries().get(1)));
|
* public void testEntryAuthor() throws Exception { assertEqualsStr("channel.item[0].author", getEntryAuthor(getCachedSyndFeed().getEntries().get(0)));
|
||||||
}
|
* assertEqualsStr("channel.item[1].author", getEntryAuthor(getCachedSyndFeed().getEntries().get(1))); }
|
||||||
|
*
|
||||||
public String getEntryTitle(Object o) throws Exception {
|
* public String getEntryAuthor(Object o) { SyndEntry e = (SyndEntry) o; return e.getAuthor(); }
|
||||||
SyndEntry e = (SyndEntry) o;
|
*/
|
||||||
return e.getTitle();
|
/*
|
||||||
}
|
* //things you cannot get from SyndEntryImpl // <source url="http://localhost:8080/item0/source.url">item[0].source</source> // <enclosure
|
||||||
|
* url="http://localhost:8080/item0/enclosure0.url" length="100" type="audio/mpeg"/> // <enclosure url="http://localhost:8080/item0/enclosure1.url"
|
||||||
public void testEntryDescription() throws Exception {
|
* length="1000" type="audio/mpeg"/> <category domain="item0.domain0">item0.category0</category> <category domain="item0.domain1">item0.category1</category>
|
||||||
assertEqualsStr("channel.item[0].description", getEntryDescription(getCachedSyndFeed().getEntries().get(0)));
|
* <pubDate>Thu, 08 Jul 1999 08:00:00 GMT</pubDate> <expirationDate>Thu, 08 Jul 1999 09:00:00 GMT</.expirationDate> <author>item0.author</author>
|
||||||
assertEqualsStr("channel.item[1].description", getEntryDescription(getCachedSyndFeed().getEntries().get(1)));
|
* <comments>http://localhost:8080/item0/comments</comments> <guid isPermaLink="true">http://localhost:8080/item0/guid</guid> //TODO: I still have the
|
||||||
}
|
* elements to test
|
||||||
|
*/
|
||||||
public String getEntryDescription(Object o) throws Exception {
|
/*
|
||||||
SyndEntry e = (SyndEntry) o;
|
* public void test() { assertEqualsStr(feed, ""); }
|
||||||
return e.getDescription().getValue();
|
*
|
||||||
}
|
* public void test() { assertEqualsStr(feed, ""); }
|
||||||
|
*/
|
||||||
public void testEntryLink() throws Exception {
|
// Things that you cannot get form a SyndFeedImpl today
|
||||||
assertEqualsStr("channel.item[0].link", getEntryLink(getCachedSyndFeed().getEntries().get(0)));
|
// these need to be put in a RSS 2.0 module
|
||||||
assertEqualsStr("channel.item[1].link", getEntryLink(getCachedSyndFeed().getEntries().get(1)));
|
// or is a roundtrip to wirefeed the right way to do this?
|
||||||
}
|
/*
|
||||||
|
* <textInput> <title>Search</title> <description>Search this site:</description> <name>q</name> <link>http://example.org/mt/mt-search.cgi</link>
|
||||||
public String getEntryLink(Object o) {
|
* </textInput>
|
||||||
SyndEntry e = (SyndEntry) o;
|
*
|
||||||
return e.getLink();
|
* image height and width
|
||||||
}
|
*
|
||||||
|
* //<copyright>Copyright 2004, Mark Pilgrim</copyright> public void test() { assertEqualsStr(getCachedSyndFeed()., ""); }
|
||||||
public void testEntryPublishedDate() throws Exception {
|
*
|
||||||
assertEquals(DateParser.parseRFC822("Mon, 01 Jan 2001 00:00:00 GMT"), getEntryPublishedDate(getCachedSyndFeed().getEntries().get(0)));
|
* //<generator>Sample Toolkit</generator> public void test() { assertEqualsStr(feed, ""); }
|
||||||
assertEquals(DateParser.parseRFC822("Mon, 01 Jan 2001 00:00:00 GMT"), getEntryPublishedDate(getCachedSyndFeed().getEntries().get(1)));
|
*
|
||||||
}
|
* // <managingEditor>editor@example.org</managingEditor> public void test() { assertEqualsStr(feed, ""); }
|
||||||
|
*
|
||||||
public Date getEntryPublishedDate(Object o) {
|
* // <webMaster>webmaster@example.org</webMaster> public void test() { assertEqualsStr(feed, ""); }
|
||||||
SyndEntry e = (SyndEntry) o;
|
*
|
||||||
return e.getPublishedDate();
|
* <docs>http://blogs.law.harvard.edu/tech/rss</docs> <cloud domain="rpc.sys.com" port="80" path="/RPC2" registerProcedure="pingMe" protocol="soap"/>
|
||||||
}
|
* <ttl>60</ttl> <rating></rating>
|
||||||
|
*
|
||||||
public void testEntryCategories() throws Exception {
|
* <skiphours> <hour>0</hour> <hour>1</hour> <hour>2</hour> <hour>3</hour> <hour>4</hour> <hour>5</hour> <hour>6</hour> <hour>7</hour> <hour>8</hour>
|
||||||
SyndEntry e = (SyndEntry)getCachedSyndFeed().getEntries().get(0);
|
* <hour>9.5</hour> <hour>10</hour> <hour>11</hour> <hour>12</hour> <hour>13</hour> <hour>14</hour> <hour>15</hour> <hour>16</hour> <hour>17</hour>
|
||||||
List catlist = e.getCategories();
|
* <hour>18</hour> <hour>19</hour> <hour>20</hour> <hour>21</hour> <hour>22</hour> <hour>23</hour> </skiphours> <skipdays> <day>Monday</day>
|
||||||
//don't understand why this one fails
|
* <day>Tuesday</day> <day>Wednesday</day> <day>Thursday</day> <day>Friday</day> <day>Saturday</day> <day>Sunday</day> </skipdays>
|
||||||
assertEquals(2, catlist.size());
|
*/
|
||||||
SyndCategory cat = (SyndCategory)catlist.get(0);
|
|
||||||
assertEqualsStr("channel.item[0].category[0]", cat.getName());
|
|
||||||
assertEqualsStr("channel.item[0].category[0]^domain", cat.getTaxonomyUri());
|
|
||||||
cat = (SyndCategory)catlist.get(1);
|
|
||||||
assertEqualsStr("channel.item[0].category[1]", cat.getName());
|
|
||||||
assertEqualsStr("channel.item[0].category[1]^domain", cat.getTaxonomyUri());
|
|
||||||
//DO 2nd set of items
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testEntryAuthor() throws Exception {
|
|
||||||
assertEqualsStr("channel.item[0].author", getEntryAuthor(getCachedSyndFeed().getEntries().get(0)));
|
|
||||||
assertEqualsStr("channel.item[1].author", getEntryAuthor(getCachedSyndFeed().getEntries().get(1)));
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getEntryAuthor(Object o) {
|
|
||||||
SyndEntry e = (SyndEntry) o;
|
|
||||||
return e.getAuthor();
|
|
||||||
}
|
|
||||||
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
//things you cannot get from SyndEntryImpl
|
|
||||||
// <source url="http://localhost:8080/item0/source.url">item[0].source</source>
|
|
||||||
// <enclosure url="http://localhost:8080/item0/enclosure0.url" length="100" type="audio/mpeg"/>
|
|
||||||
// <enclosure url="http://localhost:8080/item0/enclosure1.url" length="1000" type="audio/mpeg"/>
|
|
||||||
<category domain="item0.domain0">item0.category0</category>
|
|
||||||
<category domain="item0.domain1">item0.category1</category>
|
|
||||||
<pubDate>Thu, 08 Jul 1999 08:00:00 GMT</pubDate>
|
|
||||||
<expirationDate>Thu, 08 Jul 1999 09:00:00 GMT</.expirationDate>
|
|
||||||
<author>item0.author</author>
|
|
||||||
<comments>http://localhost:8080/item0/comments</comments>
|
|
||||||
<guid isPermaLink="true">http://localhost:8080/item0/guid</guid>
|
|
||||||
//TODO: I still have the elements to test
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
public void test() {
|
|
||||||
assertEqualsStr(feed, "");
|
|
||||||
}
|
|
||||||
|
|
||||||
public void test() {
|
|
||||||
assertEqualsStr(feed, "");
|
|
||||||
}
|
|
||||||
|
|
||||||
*/
|
|
||||||
//Things that you cannot get form a SyndFeedImpl today
|
|
||||||
//these need to be put in a RSS 2.0 module
|
|
||||||
//or is a roundtrip to wirefeed the right way to do this?
|
|
||||||
/*
|
|
||||||
* <textInput>
|
|
||||||
<title>Search</title>
|
|
||||||
<description>Search this site:</description>
|
|
||||||
<name>q</name>
|
|
||||||
<link>http://example.org/mt/mt-search.cgi</link>
|
|
||||||
</textInput>
|
|
||||||
|
|
||||||
image height and width
|
|
||||||
*
|
|
||||||
//<copyright>Copyright 2004, Mark Pilgrim</copyright>
|
|
||||||
public void test() {
|
|
||||||
assertEqualsStr(getCachedSyndFeed()., "");
|
|
||||||
}
|
|
||||||
|
|
||||||
//<generator>Sample Toolkit</generator>
|
|
||||||
public void test() {
|
|
||||||
assertEqualsStr(feed, "");
|
|
||||||
}
|
|
||||||
|
|
||||||
// <managingEditor>editor@example.org</managingEditor>
|
|
||||||
public void test() {
|
|
||||||
assertEqualsStr(feed, "");
|
|
||||||
}
|
|
||||||
|
|
||||||
// <webMaster>webmaster@example.org</webMaster>
|
|
||||||
public void test() {
|
|
||||||
assertEqualsStr(feed, "");
|
|
||||||
}
|
|
||||||
|
|
||||||
<docs>http://blogs.law.harvard.edu/tech/rss</docs>
|
|
||||||
<cloud domain="rpc.sys.com" port="80" path="/RPC2" registerProcedure="pingMe" protocol="soap"/>
|
|
||||||
<ttl>60</ttl>
|
|
||||||
<rating></rating>
|
|
||||||
|
|
||||||
<skiphours>
|
|
||||||
<hour>0</hour>
|
|
||||||
<hour>1</hour>
|
|
||||||
<hour>2</hour>
|
|
||||||
<hour>3</hour>
|
|
||||||
<hour>4</hour>
|
|
||||||
<hour>5</hour>
|
|
||||||
<hour>6</hour>
|
|
||||||
<hour>7</hour>
|
|
||||||
<hour>8</hour>
|
|
||||||
<hour>9.5</hour>
|
|
||||||
<hour>10</hour>
|
|
||||||
<hour>11</hour>
|
|
||||||
<hour>12</hour>
|
|
||||||
<hour>13</hour>
|
|
||||||
<hour>14</hour>
|
|
||||||
<hour>15</hour>
|
|
||||||
<hour>16</hour>
|
|
||||||
<hour>17</hour>
|
|
||||||
<hour>18</hour>
|
|
||||||
<hour>19</hour>
|
|
||||||
<hour>20</hour>
|
|
||||||
<hour>21</hour>
|
|
||||||
<hour>22</hour>
|
|
||||||
<hour>23</hour>
|
|
||||||
</skiphours>
|
|
||||||
<skipdays>
|
|
||||||
<day>Monday</day>
|
|
||||||
<day>Tuesday</day>
|
|
||||||
<day>Wednesday</day>
|
|
||||||
<day>Thursday</day>
|
|
||||||
<day>Friday</day>
|
|
||||||
<day>Saturday</day>
|
|
||||||
<day>Sunday</day>
|
|
||||||
</skipdays>
|
|
||||||
|
|
||||||
**/
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* @see TestCase#tearDown()
|
|
||||||
*/
|
|
||||||
protected void tearDown() throws Exception {
|
|
||||||
super.tearDown();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @see TestCase#tearDown()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected void tearDown() throws Exception {
|
||||||
|
super.tearDown();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,17 +9,18 @@
|
||||||
|
|
||||||
package org.rometools.unittest;
|
package org.rometools.unittest;
|
||||||
|
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.PrintWriter;
|
||||||
|
|
||||||
import com.sun.syndication.feed.WireFeed;
|
import com.sun.syndication.feed.WireFeed;
|
||||||
import com.sun.syndication.feed.synd.SyndFeed;
|
import com.sun.syndication.feed.synd.SyndFeed;
|
||||||
import com.sun.syndication.feed.synd.SyndFeedImpl;
|
import com.sun.syndication.feed.synd.SyndFeedImpl;
|
||||||
import java.io.FileOutputStream;
|
|
||||||
import java.io.PrintWriter;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author cooper
|
* @author cooper
|
||||||
*/
|
*/
|
||||||
public class TestOpsOPML10 extends FeedOpsTest{
|
public class TestOpsOPML10 extends FeedOpsTest {
|
||||||
|
|
||||||
/** Creates a new instance of TestOpsOPML10 */
|
/** Creates a new instance of TestOpsOPML10 */
|
||||||
public TestOpsOPML10() {
|
public TestOpsOPML10() {
|
||||||
|
@ -27,21 +28,19 @@ public class TestOpsOPML10 extends FeedOpsTest{
|
||||||
}
|
}
|
||||||
|
|
||||||
// 1.6
|
// 1.6
|
||||||
|
@Override
|
||||||
public void testWireFeedSyndFeedConversion() throws Exception {
|
public void testWireFeedSyndFeedConversion() throws Exception {
|
||||||
SyndFeed sFeed1 = getCachedSyndFeed();
|
final SyndFeed sFeed1 = getCachedSyndFeed();
|
||||||
WireFeed wFeed1 = sFeed1.createWireFeed();
|
final WireFeed wFeed1 = sFeed1.createWireFeed();
|
||||||
SyndFeed sFeed2 = new SyndFeedImpl(wFeed1);
|
final SyndFeed sFeed2 = new SyndFeedImpl(wFeed1);
|
||||||
PrintWriter w = new PrintWriter( new FileOutputStream( "target/test-reports/1") );
|
PrintWriter w = new PrintWriter(new FileOutputStream("target/test-reports/1"));
|
||||||
w.println( sFeed1.toString() );
|
w.println(sFeed1.toString());
|
||||||
w.close();
|
w.close();
|
||||||
w = new PrintWriter( new FileOutputStream( "target/test-reports/2") );
|
w = new PrintWriter(new FileOutputStream("target/test-reports/2"));
|
||||||
w.println( sFeed2.toString() );
|
w.println(sFeed2.toString());
|
||||||
w.close();
|
w.close();
|
||||||
|
|
||||||
assertEquals(sFeed1, sFeed2);
|
assertEquals(sFeed1, sFeed2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,20 +9,21 @@
|
||||||
|
|
||||||
package org.rometools.unittest;
|
package org.rometools.unittest;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.PrintWriter;
|
||||||
|
|
||||||
import com.sun.syndication.feed.WireFeed;
|
import com.sun.syndication.feed.WireFeed;
|
||||||
import com.sun.syndication.feed.synd.SyndFeed;
|
import com.sun.syndication.feed.synd.SyndFeed;
|
||||||
import com.sun.syndication.feed.synd.SyndFeedImpl;
|
import com.sun.syndication.feed.synd.SyndFeedImpl;
|
||||||
import com.sun.syndication.io.WireFeedInput;
|
import com.sun.syndication.io.WireFeedInput;
|
||||||
import com.sun.syndication.io.WireFeedOutput;
|
import com.sun.syndication.io.WireFeedOutput;
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileOutputStream;
|
|
||||||
import java.io.PrintWriter;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author cooper
|
* @author cooper
|
||||||
*/
|
*/
|
||||||
public class TestOpsOPML10links extends FeedOpsTest{
|
public class TestOpsOPML10links extends FeedOpsTest {
|
||||||
|
|
||||||
/** Creates a new instance of TestOpsOPML10 */
|
/** Creates a new instance of TestOpsOPML10 */
|
||||||
public TestOpsOPML10links() {
|
public TestOpsOPML10links() {
|
||||||
|
@ -30,38 +31,32 @@ public class TestOpsOPML10links extends FeedOpsTest{
|
||||||
}
|
}
|
||||||
|
|
||||||
// 1.6
|
// 1.6
|
||||||
|
@Override
|
||||||
public void testWireFeedSyndFeedConversion() throws Exception {
|
public void testWireFeedSyndFeedConversion() throws Exception {
|
||||||
SyndFeed sFeed1 = getCachedSyndFeed();
|
final SyndFeed sFeed1 = getCachedSyndFeed();
|
||||||
WireFeed wFeed1 = sFeed1.createWireFeed();
|
final WireFeed wFeed1 = sFeed1.createWireFeed();
|
||||||
//System.out.println( wFeed1 );
|
final SyndFeed sFeed2 = new SyndFeedImpl(wFeed1);
|
||||||
SyndFeed sFeed2 = new SyndFeedImpl(wFeed1);
|
PrintWriter w = new PrintWriter(new FileOutputStream("target/test-reports/1"));
|
||||||
PrintWriter w = new PrintWriter( new FileOutputStream( "target/test-reports/1") );
|
w.println(sFeed1.toString());
|
||||||
w.println( sFeed1.toString() );
|
|
||||||
w.close();
|
w.close();
|
||||||
w = new PrintWriter( new FileOutputStream( "target/test-reports/2") );
|
w = new PrintWriter(new FileOutputStream("target/test-reports/2"));
|
||||||
w.println( sFeed2.toString() );
|
w.println(sFeed2.toString());
|
||||||
w.close();
|
w.close();
|
||||||
|
|
||||||
assertEquals(sFeed2.createWireFeed(), sFeed1.createWireFeed());
|
assertEquals(sFeed2.createWireFeed(), sFeed1.createWireFeed());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public void testTemp() throws Exception {
|
public void testTemp() throws Exception {
|
||||||
WireFeedInput input = new WireFeedInput();
|
final WireFeedInput input = new WireFeedInput();
|
||||||
WireFeed wf = input.build( new File( System.getProperty("basedir")+ "/src/test/resources/opml_1.0_links.xml"));
|
final WireFeed wf = input.build(new File(System.getProperty("basedir") + "/src/test/resources/opml_1.0_links.xml"));
|
||||||
WireFeedOutput output = new WireFeedOutput();
|
final WireFeedOutput output = new WireFeedOutput();
|
||||||
//System.out.println( wf );
|
|
||||||
|
|
||||||
//System.out.println( "=================================");
|
final SyndFeedImpl sf = new SyndFeedImpl(wf);
|
||||||
//System.out.println( new SyndFeedImpl( wf) );
|
|
||||||
SyndFeedImpl sf = new SyndFeedImpl( wf);
|
|
||||||
sf.setFeedType("rss_2.0");
|
sf.setFeedType("rss_2.0");
|
||||||
sf.setDescription("");
|
sf.setDescription("");
|
||||||
sf.setLink("http://foo.com");
|
sf.setLink("http://foo.com");
|
||||||
//output.output( sf.createWireFeed() , new PrintWriter( System.out ) );
|
|
||||||
sf.setFeedType("opml_1.0");
|
sf.setFeedType("opml_1.0");
|
||||||
output.output( sf.createWireFeed() , new File( System.getProperty("basedir")+ "/target/test-reports/1.xml") );
|
output.output(sf.createWireFeed(), new File(System.getProperty("basedir") + "/target/test-reports/1.xml"));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,11 +9,12 @@
|
||||||
|
|
||||||
package org.rometools.unittest;
|
package org.rometools.unittest;
|
||||||
|
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.PrintWriter;
|
||||||
|
|
||||||
import com.sun.syndication.feed.WireFeed;
|
import com.sun.syndication.feed.WireFeed;
|
||||||
import com.sun.syndication.feed.synd.SyndFeed;
|
import com.sun.syndication.feed.synd.SyndFeed;
|
||||||
import com.sun.syndication.feed.synd.SyndFeedImpl;
|
import com.sun.syndication.feed.synd.SyndFeedImpl;
|
||||||
import java.io.FileOutputStream;
|
|
||||||
import java.io.PrintWriter;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -26,18 +27,18 @@ public class TestOpsOPML20 extends FeedOpsTest {
|
||||||
super("opml_2.0");
|
super("opml_2.0");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void testWireFeedSyndFeedConversion() throws Exception {
|
public void testWireFeedSyndFeedConversion() throws Exception {
|
||||||
SyndFeed sFeed1 = getCachedSyndFeed();
|
final SyndFeed sFeed1 = getCachedSyndFeed();
|
||||||
WireFeed wFeed1 = sFeed1.createWireFeed();
|
final WireFeed wFeed1 = sFeed1.createWireFeed();
|
||||||
SyndFeed sFeed2 = new SyndFeedImpl(wFeed1);
|
final SyndFeed sFeed2 = new SyndFeedImpl(wFeed1);
|
||||||
PrintWriter w = new PrintWriter( new FileOutputStream( "target/test-reports/3") );
|
PrintWriter w = new PrintWriter(new FileOutputStream("target/test-reports/3"));
|
||||||
w.println( sFeed1.toString() );
|
w.println(sFeed1.toString());
|
||||||
w.close();
|
w.close();
|
||||||
w = new PrintWriter( new FileOutputStream( "target/test-reports/4") );
|
w = new PrintWriter(new FileOutputStream("target/test-reports/4"));
|
||||||
w.println( sFeed2.toString() );
|
w.println(sFeed2.toString());
|
||||||
w.close();
|
w.close();
|
||||||
assertEquals(sFeed1, sFeed2 );
|
assertEquals(sFeed1, sFeed2);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,12 +16,20 @@
|
||||||
*/
|
*/
|
||||||
package org.rometools.unittest;
|
package org.rometools.unittest;
|
||||||
|
|
||||||
|
import java.io.ByteArrayInputStream;
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.OutputStreamWriter;
|
||||||
|
import java.io.Reader;
|
||||||
|
import java.io.Writer;
|
||||||
|
|
||||||
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
|
import org.jdom2.input.SAXBuilder;
|
||||||
|
|
||||||
import com.sun.syndication.io.XmlReader;
|
import com.sun.syndication.io.XmlReader;
|
||||||
import com.sun.syndication.io.impl.XmlFixerReader;
|
import com.sun.syndication.io.impl.XmlFixerReader;
|
||||||
import junit.framework.TestCase;
|
|
||||||
import org.jdom.input.SAXBuilder;
|
|
||||||
|
|
||||||
import java.io.*;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author pat, tucu
|
* @author pat, tucu
|
||||||
|
@ -31,104 +39,101 @@ public class TestXmlFixerReader extends TestCase {
|
||||||
private static final String XML_PROLOG = "<?xml version=\"1.0\" ?>";
|
private static final String XML_PROLOG = "<?xml version=\"1.0\" ?>";
|
||||||
|
|
||||||
public void testTrim() throws Exception {
|
public void testTrim() throws Exception {
|
||||||
_testValidTrim("","<hello></hello>");
|
_testValidTrim("", "<hello></hello>");
|
||||||
_testValidTrim("",XML_PROLOG+"<hello></hello>");
|
_testValidTrim("", XML_PROLOG + "<hello></hello>");
|
||||||
_testValidTrim(" ","<hello></hello>");
|
_testValidTrim(" ", "<hello></hello>");
|
||||||
_testValidTrim(" ",XML_PROLOG+"<hello></hello>");
|
_testValidTrim(" ", XML_PROLOG + "<hello></hello>");
|
||||||
_testValidTrim(" \n","<hello></hello>");
|
_testValidTrim(" \n", "<hello></hello>");
|
||||||
_testValidTrim(" \n",XML_PROLOG+"<hello></hello>");
|
_testValidTrim(" \n", XML_PROLOG + "<hello></hello>");
|
||||||
_testValidTrim("<!-- - -- -->","<hello></hello>");
|
_testValidTrim("<!-- - -- -->", "<hello></hello>");
|
||||||
_testValidTrim("<!-- - -- -->",XML_PROLOG+"<hello></hello>");
|
_testValidTrim("<!-- - -- -->", XML_PROLOG + "<hello></hello>");
|
||||||
_testValidTrim(" <!-- - -- -->","<hello></hello>");
|
_testValidTrim(" <!-- - -- -->", "<hello></hello>");
|
||||||
_testValidTrim(" <!-- - -- -->",XML_PROLOG+"<hello></hello>");
|
_testValidTrim(" <!-- - -- -->", XML_PROLOG + "<hello></hello>");
|
||||||
_testValidTrim(" <!-- - -- --> ","<hello></hello>");
|
_testValidTrim(" <!-- - -- --> ", "<hello></hello>");
|
||||||
_testValidTrim(" <!-- - -- --> ",XML_PROLOG+"<hello></hello>");
|
_testValidTrim(" <!-- - -- --> ", XML_PROLOG + "<hello></hello>");
|
||||||
_testValidTrim(" <!-- - -- --> <!-- - -- --> ","<hello></hello>");
|
_testValidTrim(" <!-- - -- --> <!-- - -- --> ", "<hello></hello>");
|
||||||
_testValidTrim(" <!-- - -- --> <!-- - -- --> ",XML_PROLOG+"<hello></hello>");
|
_testValidTrim(" <!-- - -- --> <!-- - -- --> ", XML_PROLOG + "<hello></hello>");
|
||||||
_testValidTrim(" <!-- - -- --> \n <!-- - -- --> ","<hello></hello>");
|
_testValidTrim(" <!-- - -- --> \n <!-- - -- --> ", "<hello></hello>");
|
||||||
_testValidTrim(" <!-- - -- --> \n <!-- - -- --> ",XML_PROLOG+"<hello></hello>");
|
_testValidTrim(" <!-- - -- --> \n <!-- - -- --> ", XML_PROLOG + "<hello></hello>");
|
||||||
|
|
||||||
_testInvalidTrim("x","<hello></hello>");
|
_testInvalidTrim("x", "<hello></hello>");
|
||||||
_testInvalidTrim("x",XML_PROLOG+"<hello></hello>");
|
_testInvalidTrim("x", XML_PROLOG + "<hello></hello>");
|
||||||
_testInvalidTrim(" x","<hello></hello>");
|
_testInvalidTrim(" x", "<hello></hello>");
|
||||||
_testInvalidTrim(" x",XML_PROLOG+"<hello></hello>");
|
_testInvalidTrim(" x", XML_PROLOG + "<hello></hello>");
|
||||||
_testInvalidTrim(" x\n","<hello></hello>");
|
_testInvalidTrim(" x\n", "<hello></hello>");
|
||||||
_testInvalidTrim(" x\n",XML_PROLOG+"<hello></hello>");
|
_testInvalidTrim(" x\n", XML_PROLOG + "<hello></hello>");
|
||||||
_testInvalidTrim("<!-- - -- - ->","<hello></hello>");
|
_testInvalidTrim("<!-- - -- - ->", "<hello></hello>");
|
||||||
_testInvalidTrim("<!-- - -- - ->",XML_PROLOG+"<hello></hello>");
|
_testInvalidTrim("<!-- - -- - ->", XML_PROLOG + "<hello></hello>");
|
||||||
_testInvalidTrim(" <!-- - -- -- >","<hello></hello>");
|
_testInvalidTrim(" <!-- - -- -- >", "<hello></hello>");
|
||||||
_testInvalidTrim(" <!-- - -- -- >",XML_PROLOG+"<hello></hello>");
|
_testInvalidTrim(" <!-- - -- -- >", XML_PROLOG + "<hello></hello>");
|
||||||
_testInvalidTrim(" <!-- - -- -->x ","<hello></hello>");
|
_testInvalidTrim(" <!-- - -- -->x ", "<hello></hello>");
|
||||||
_testInvalidTrim(" <!-- - -- -->x ",XML_PROLOG+"<hello></hello>");
|
_testInvalidTrim(" <!-- - -- -->x ", XML_PROLOG + "<hello></hello>");
|
||||||
_testInvalidTrim(" <!-- - -- --> x <!-- - -- --> ","<hello></hello>");
|
_testInvalidTrim(" <!-- - -- --> x <!-- - -- --> ", "<hello></hello>");
|
||||||
_testInvalidTrim(" <!-- - -- --> x <!-- - -- --> ",XML_PROLOG+"<hello></hello>");
|
_testInvalidTrim(" <!-- - -- --> x <!-- - -- --> ", XML_PROLOG + "<hello></hello>");
|
||||||
_testInvalidTrim(" <!-- - -- --> x\n <!-- - -- --> ","<hello></hello>");
|
_testInvalidTrim(" <!-- - -- --> x\n <!-- - -- --> ", "<hello></hello>");
|
||||||
_testInvalidTrim(" <!-- - -- --> x\n <!-- - -- --> ",XML_PROLOG+"<hello></hello>");
|
_testInvalidTrim(" <!-- - -- --> x\n <!-- - -- --> ", XML_PROLOG + "<hello></hello>");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testHtmlEntities() throws Exception {
|
public void testHtmlEntities() throws Exception {
|
||||||
_testValidEntities("<hello></hello>");
|
_testValidEntities("<hello></hello>");
|
||||||
_testValidEntities(XML_PROLOG+"<hello></hello>");
|
_testValidEntities(XML_PROLOG + "<hello></hello>");
|
||||||
_testValidEntities(" <!-- just in case -->\n"+XML_PROLOG+"<hello></hello>");
|
_testValidEntities(" <!-- just in case -->\n" + XML_PROLOG + "<hello></hello>");
|
||||||
|
|
||||||
_testValidEntities("<hello>'¥ú¥</hello>");
|
_testValidEntities("<hello>'¥ú¥</hello>");
|
||||||
_testValidEntities(XML_PROLOG+"<hello>'¥ú¥</hello>");
|
_testValidEntities(XML_PROLOG + "<hello>'¥ú¥</hello>");
|
||||||
_testValidEntities(" <!-- just in case -->\n"+XML_PROLOG+"<hello>'¥ú¥</hello>");
|
_testValidEntities(" <!-- just in case -->\n" + XML_PROLOG + "<hello>'¥ú¥</hello>");
|
||||||
|
|
||||||
_testInvalidEntities("<hello>'&yexn;ú¥</hello>");
|
_testInvalidEntities("<hello>'&yexn;ú¥</hello>");
|
||||||
_testInvalidEntities(XML_PROLOG+"<hello>'&yexn;ú¥</hello>");
|
_testInvalidEntities(XML_PROLOG + "<hello>'&yexn;ú¥</hello>");
|
||||||
_testInvalidEntities(" <!-- just in case -->\n"+XML_PROLOG+"<hello>'&yexn;ú¥</hello>");
|
_testInvalidEntities(" <!-- just in case -->\n" + XML_PROLOG + "<hello>'&yexn;ú¥</hello>");
|
||||||
|
|
||||||
_testInvalidEntities("<hello>'¥x50;¥</hello>");
|
_testInvalidEntities("<hello>'¥x50;¥</hello>");
|
||||||
_testInvalidEntities(XML_PROLOG+"<hello>'¥x50;¥</hello>");
|
_testInvalidEntities(XML_PROLOG + "<hello>'¥x50;¥</hello>");
|
||||||
_testInvalidEntities(" <!-- just in case -->\n"+XML_PROLOG+"<hello>'¥x50;¥</hello>");
|
_testInvalidEntities(" <!-- just in case -->\n" + XML_PROLOG + "<hello>'¥x50;¥</hello>");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void _testXmlParse(String garbish,String xmlDoc) throws Exception {
|
protected void _testXmlParse(final String garbish, final String xmlDoc) throws Exception {
|
||||||
InputStream is = getStream(garbish,xmlDoc);
|
final InputStream is = getStream(garbish, xmlDoc);
|
||||||
Reader reader = new XmlReader(is);
|
Reader reader = new XmlReader(is);
|
||||||
reader = new XmlFixerReader(reader);
|
reader = new XmlFixerReader(reader);
|
||||||
SAXBuilder saxBuilder = new SAXBuilder();
|
final SAXBuilder saxBuilder = new SAXBuilder();
|
||||||
saxBuilder.build(reader);
|
saxBuilder.build(reader);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void _testValidTrim(String garbish,String xmlDoc) throws Exception {
|
protected void _testValidTrim(final String garbish, final String xmlDoc) throws Exception {
|
||||||
_testXmlParse(garbish,xmlDoc);
|
_testXmlParse(garbish, xmlDoc);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void _testInvalidTrim(String garbish,String xmlDoc) throws Exception {
|
protected void _testInvalidTrim(final String garbish, final String xmlDoc) throws Exception {
|
||||||
try {
|
try {
|
||||||
_testXmlParse(garbish,xmlDoc);
|
_testXmlParse(garbish, xmlDoc);
|
||||||
assertTrue(false);
|
assertTrue(false);
|
||||||
}
|
} catch (final Exception ex) {
|
||||||
catch (Exception ex) {
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void _testValidEntities(String xmlDoc) throws Exception {
|
protected void _testValidEntities(final String xmlDoc) throws Exception {
|
||||||
_testXmlParse("",xmlDoc);
|
_testXmlParse("", xmlDoc);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void _testInvalidEntities(String xmlDoc) throws Exception {
|
protected void _testInvalidEntities(final String xmlDoc) throws Exception {
|
||||||
try {
|
try {
|
||||||
_testXmlParse("",xmlDoc);
|
_testXmlParse("", xmlDoc);
|
||||||
assertTrue(false);
|
assertTrue(false);
|
||||||
}
|
} catch (final Exception ex) {
|
||||||
catch (Exception ex) {
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// XML Stream generator
|
// XML Stream generator
|
||||||
|
|
||||||
protected InputStream getStream(String garbish,String xmlDoc) throws IOException {
|
protected InputStream getStream(final String garbish, final String xmlDoc) throws IOException {
|
||||||
ByteArrayOutputStream baos = new ByteArrayOutputStream(1024);
|
final ByteArrayOutputStream baos = new ByteArrayOutputStream(1024);
|
||||||
Writer writer = new OutputStreamWriter(baos);
|
final Writer writer = new OutputStreamWriter(baos);
|
||||||
writer.write(garbish);
|
writer.write(garbish);
|
||||||
writer.write(xmlDoc);
|
writer.write(xmlDoc);
|
||||||
writer.close();
|
writer.close();
|
||||||
return new ByteArrayInputStream(baos.toByteArray());
|
return new ByteArrayInputStream(baos.toByteArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,51 +16,56 @@
|
||||||
*/
|
*/
|
||||||
package org.rometools.unittest;
|
package org.rometools.unittest;
|
||||||
|
|
||||||
import com.sun.syndication.io.XmlReader;
|
import java.io.ByteArrayInputStream;
|
||||||
import junit.framework.TestCase;
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
import java.io.*;
|
import java.io.InputStream;
|
||||||
|
import java.io.OutputStreamWriter;
|
||||||
|
import java.io.Writer;
|
||||||
import java.text.MessageFormat;
|
import java.text.MessageFormat;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
|
import com.sun.syndication.io.XmlReader;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author pat, tucu
|
* @author pat, tucu
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class TestXmlReader extends TestCase {
|
public class TestXmlReader extends TestCase {
|
||||||
|
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(final String[] args) throws Exception {
|
||||||
TestXmlReader test = new TestXmlReader();
|
final TestXmlReader test = new TestXmlReader();
|
||||||
test.testRawBom();
|
test.testRawBom();
|
||||||
test.testRawNoBom();
|
test.testRawNoBom();
|
||||||
test.testHttp();
|
test.testHttp();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void _testRawNoBomValid(String encoding) throws Exception {
|
protected void _testRawNoBomValid(final String encoding) throws Exception {
|
||||||
InputStream is = getXmlStream("no-bom","xml",encoding,encoding);
|
InputStream is = getXmlStream("no-bom", "xml", encoding, encoding);
|
||||||
XmlReader xmlReader = new XmlReader(is,false);
|
XmlReader xmlReader = new XmlReader(is, false);
|
||||||
assertEquals(xmlReader.getEncoding(),"UTF-8");
|
assertEquals(xmlReader.getEncoding(), "UTF-8");
|
||||||
|
|
||||||
is = getXmlStream("no-bom","xml-prolog",encoding,encoding);
|
is = getXmlStream("no-bom", "xml-prolog", encoding, encoding);
|
||||||
xmlReader = new XmlReader(is);
|
xmlReader = new XmlReader(is);
|
||||||
assertEquals(xmlReader.getEncoding(),"UTF-8");
|
assertEquals(xmlReader.getEncoding(), "UTF-8");
|
||||||
|
|
||||||
is = getXmlStream("no-bom","xml-prolog-encoding",encoding,encoding);
|
is = getXmlStream("no-bom", "xml-prolog-encoding", encoding, encoding);
|
||||||
xmlReader = new XmlReader(is);
|
xmlReader = new XmlReader(is);
|
||||||
assertEquals(xmlReader.getEncoding(),encoding);
|
assertEquals(xmlReader.getEncoding(), encoding);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void _testRawNoBomInvalid(String encoding) throws Exception {
|
protected void _testRawNoBomInvalid(final String encoding) throws Exception {
|
||||||
InputStream is = getXmlStream("no-bom","xml-prolog-encoding",encoding,encoding);
|
final InputStream is = getXmlStream("no-bom", "xml-prolog-encoding", encoding, encoding);
|
||||||
try {
|
try {
|
||||||
XmlReader xmlReader = new XmlReader(is,false);
|
final XmlReader xmlReader = new XmlReader(is, false);
|
||||||
fail("It should have failed");
|
fail("It should have failed");
|
||||||
|
} catch (final IOException ex) {
|
||||||
|
assertTrue(ex.getMessage().indexOf("Invalid encoding,") > -1);
|
||||||
}
|
}
|
||||||
catch (IOException ex) {
|
}
|
||||||
assertTrue(ex.getMessage().indexOf("Invalid encoding,")>-1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testRawNoBom() throws Exception {
|
public void testRawNoBom() throws Exception {
|
||||||
_testRawNoBomValid("US-ASCII");
|
_testRawNoBomValid("US-ASCII");
|
||||||
|
@ -68,27 +73,25 @@ public class TestXmlReader extends TestCase {
|
||||||
_testRawNoBomValid("ISO-8859-1");
|
_testRawNoBomValid("ISO-8859-1");
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void _testRawBomValid(String encoding) throws Exception {
|
protected void _testRawBomValid(final String encoding) throws Exception {
|
||||||
InputStream is = getXmlStream(encoding+"-bom","xml-prolog-encoding",encoding,encoding);
|
final InputStream is = getXmlStream(encoding + "-bom", "xml-prolog-encoding", encoding, encoding);
|
||||||
XmlReader xmlReader = new XmlReader(is,false);
|
final XmlReader xmlReader = new XmlReader(is, false);
|
||||||
if (!encoding.equals("UTF-16")) {
|
if (!encoding.equals("UTF-16")) {
|
||||||
assertEquals(xmlReader.getEncoding(),encoding);
|
assertEquals(xmlReader.getEncoding(), encoding);
|
||||||
}
|
} else {
|
||||||
else {
|
assertEquals(xmlReader.getEncoding().substring(0, encoding.length()), encoding);
|
||||||
assertEquals(xmlReader.getEncoding().substring(0,encoding.length()),encoding);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void _testRawBomInvalid(String bomEnc,String streamEnc,String prologEnc) throws Exception {
|
protected void _testRawBomInvalid(final String bomEnc, final String streamEnc, final String prologEnc) throws Exception {
|
||||||
InputStream is = getXmlStream(bomEnc,"xml-prolog-encoding",streamEnc,prologEnc);
|
final InputStream is = getXmlStream(bomEnc, "xml-prolog-encoding", streamEnc, prologEnc);
|
||||||
try {
|
try {
|
||||||
XmlReader xmlReader = new XmlReader(is,false);
|
final XmlReader xmlReader = new XmlReader(is, false);
|
||||||
fail("It should have failed for BOM "+bomEnc+", streamEnc "+streamEnc+" and prologEnc "+prologEnc);
|
fail("It should have failed for BOM " + bomEnc + ", streamEnc " + streamEnc + " and prologEnc " + prologEnc);
|
||||||
|
} catch (final IOException ex) {
|
||||||
|
assertTrue(ex.getMessage().indexOf("Invalid encoding,") > -1);
|
||||||
}
|
}
|
||||||
catch (IOException ex) {
|
}
|
||||||
assertTrue(ex.getMessage().indexOf("Invalid encoding,")>-1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testRawBom() throws Exception {
|
public void testRawBom() throws Exception {
|
||||||
_testRawBomValid("UTF-8");
|
_testRawBomValid("UTF-8");
|
||||||
|
@ -96,129 +99,124 @@ public class TestXmlReader extends TestCase {
|
||||||
_testRawBomValid("UTF-16LE");
|
_testRawBomValid("UTF-16LE");
|
||||||
_testRawBomValid("UTF-16");
|
_testRawBomValid("UTF-16");
|
||||||
|
|
||||||
_testRawBomInvalid("UTF-8-bom","US-ASCII","US-ASCII");
|
_testRawBomInvalid("UTF-8-bom", "US-ASCII", "US-ASCII");
|
||||||
_testRawBomInvalid("UTF-8-bom","ISO-8859-1","ISO-8859-1");
|
_testRawBomInvalid("UTF-8-bom", "ISO-8859-1", "ISO-8859-1");
|
||||||
_testRawBomInvalid("UTF-8-bom","UTF-8","UTF-16");
|
_testRawBomInvalid("UTF-8-bom", "UTF-8", "UTF-16");
|
||||||
_testRawBomInvalid("UTF-8-bom","UTF-8","UTF-16BE");
|
_testRawBomInvalid("UTF-8-bom", "UTF-8", "UTF-16BE");
|
||||||
_testRawBomInvalid("UTF-8-bom","UTF-8","UTF-16LE");
|
_testRawBomInvalid("UTF-8-bom", "UTF-8", "UTF-16LE");
|
||||||
_testRawBomInvalid("UTF-16BE-bom","UTF-16BE","UTF-16LE");
|
_testRawBomInvalid("UTF-16BE-bom", "UTF-16BE", "UTF-16LE");
|
||||||
_testRawBomInvalid("UTF-16LE-bom","UTF-16LE","UTF-16BE");
|
_testRawBomInvalid("UTF-16LE-bom", "UTF-16LE", "UTF-16BE");
|
||||||
_testRawBomInvalid("UTF-16LE-bom","UTF-16LE","UTF-8");
|
_testRawBomInvalid("UTF-16LE-bom", "UTF-16LE", "UTF-8");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testHttp() throws Exception {
|
public void testHttp() throws Exception {
|
||||||
_testHttpValid("application/xml","no-bom","US-ASCII",null);
|
_testHttpValid("application/xml", "no-bom", "US-ASCII", null);
|
||||||
_testHttpValid("application/xml","UTF-8-bom","US-ASCII",null);
|
_testHttpValid("application/xml", "UTF-8-bom", "US-ASCII", null);
|
||||||
_testHttpValid("application/xml","UTF-8-bom","UTF-8",null);
|
_testHttpValid("application/xml", "UTF-8-bom", "UTF-8", null);
|
||||||
_testHttpValid("application/xml","UTF-8-bom","UTF-8","UTF-8");
|
_testHttpValid("application/xml", "UTF-8-bom", "UTF-8", "UTF-8");
|
||||||
_testHttpValid("application/xml;charset=UTF-8","UTF-8-bom","UTF-8",null);
|
_testHttpValid("application/xml;charset=UTF-8", "UTF-8-bom", "UTF-8", null);
|
||||||
_testHttpValid("application/xml;charset=UTF-8","UTF-8-bom","UTF-8","UTF-8");
|
_testHttpValid("application/xml;charset=UTF-8", "UTF-8-bom", "UTF-8", "UTF-8");
|
||||||
_testHttpValid("application/xml;charset=UTF-16","UTF-16BE-bom","UTF-16BE",null);
|
_testHttpValid("application/xml;charset=UTF-16", "UTF-16BE-bom", "UTF-16BE", null);
|
||||||
_testHttpValid("application/xml;charset=UTF-16","UTF-16BE-bom","UTF-16BE","UTF-16");
|
_testHttpValid("application/xml;charset=UTF-16", "UTF-16BE-bom", "UTF-16BE", "UTF-16");
|
||||||
_testHttpValid("application/xml;charset=UTF-16","UTF-16BE-bom","UTF-16BE","UTF-16BE");
|
_testHttpValid("application/xml;charset=UTF-16", "UTF-16BE-bom", "UTF-16BE", "UTF-16BE");
|
||||||
|
|
||||||
_testHttpInvalid("application/xml;charset=UTF-16BE","UTF-16BE-bom","UTF-16BE",null);
|
_testHttpInvalid("application/xml;charset=UTF-16BE", "UTF-16BE-bom", "UTF-16BE", null);
|
||||||
_testHttpInvalid("application/xml;charset=UTF-16BE","UTF-16BE-bom","UTF-16BE","UTF-16");
|
_testHttpInvalid("application/xml;charset=UTF-16BE", "UTF-16BE-bom", "UTF-16BE", "UTF-16");
|
||||||
_testHttpInvalid("application/xml;charset=UTF-16BE","UTF-16BE-bom","UTF-16BE","UTF-16BE");
|
_testHttpInvalid("application/xml;charset=UTF-16BE", "UTF-16BE-bom", "UTF-16BE", "UTF-16BE");
|
||||||
_testHttpInvalid("application/xml","UTF-8-bom","US-ASCII","US-ASCII");
|
_testHttpInvalid("application/xml", "UTF-8-bom", "US-ASCII", "US-ASCII");
|
||||||
_testHttpInvalid("application/xml;charset=UTF-16","UTF-16LE","UTF-8","UTF-8");
|
_testHttpInvalid("application/xml;charset=UTF-16", "UTF-16LE", "UTF-8", "UTF-8");
|
||||||
_testHttpInvalid("application/xml;charset=UTF-16","no-bom","UTF-16BE","UTF-16BE");
|
_testHttpInvalid("application/xml;charset=UTF-16", "no-bom", "UTF-16BE", "UTF-16BE");
|
||||||
|
|
||||||
_testHttpValid("text/xml","no-bom","US-ASCII",null);
|
_testHttpValid("text/xml", "no-bom", "US-ASCII", null);
|
||||||
_testHttpValid("text/xml;charset=UTF-8","UTF-8-bom","UTF-8","UTF-8");
|
_testHttpValid("text/xml;charset=UTF-8", "UTF-8-bom", "UTF-8", "UTF-8");
|
||||||
_testHttpValid("text/xml;charset=UTF-8","UTF-8-bom","UTF-8",null);
|
_testHttpValid("text/xml;charset=UTF-8", "UTF-8-bom", "UTF-8", null);
|
||||||
_testHttpValid("text/xml;charset=UTF-16","UTF-16BE-bom","UTF-16BE",null);
|
_testHttpValid("text/xml;charset=UTF-16", "UTF-16BE-bom", "UTF-16BE", null);
|
||||||
_testHttpValid("text/xml;charset=UTF-16","UTF-16BE-bom","UTF-16BE","UTF-16");
|
_testHttpValid("text/xml;charset=UTF-16", "UTF-16BE-bom", "UTF-16BE", "UTF-16");
|
||||||
_testHttpValid("text/xml;charset=UTF-16","UTF-16BE-bom","UTF-16BE","UTF-16BE");
|
_testHttpValid("text/xml;charset=UTF-16", "UTF-16BE-bom", "UTF-16BE", "UTF-16BE");
|
||||||
_testHttpValid("text/xml","UTF-8-bom","US-ASCII",null);
|
_testHttpValid("text/xml", "UTF-8-bom", "US-ASCII", null);
|
||||||
|
|
||||||
_testHttpInvalid("text/xml;charset=UTF-16BE","UTF-16BE-bom","UTF-16BE",null);
|
_testHttpInvalid("text/xml;charset=UTF-16BE", "UTF-16BE-bom", "UTF-16BE", null);
|
||||||
_testHttpInvalid("text/xml;charset=UTF-16BE","UTF-16BE-bom","UTF-16BE","UTF-16");
|
_testHttpInvalid("text/xml;charset=UTF-16BE", "UTF-16BE-bom", "UTF-16BE", "UTF-16");
|
||||||
_testHttpInvalid("text/xml;charset=UTF-16BE","UTF-16BE-bom","UTF-16BE","UTF-16BE");
|
_testHttpInvalid("text/xml;charset=UTF-16BE", "UTF-16BE-bom", "UTF-16BE", "UTF-16BE");
|
||||||
_testHttpInvalid("text/xml;charset=UTF-16","no-bom","UTF-16BE","UTF-16BE");
|
_testHttpInvalid("text/xml;charset=UTF-16", "no-bom", "UTF-16BE", "UTF-16BE");
|
||||||
_testHttpInvalid("text/xml;charset=UTF-16","no-bom","UTF-16BE",null);
|
_testHttpInvalid("text/xml;charset=UTF-16", "no-bom", "UTF-16BE", null);
|
||||||
|
|
||||||
_testHttpLenient("text/xml","no-bom","US-ASCII",null, "US-ASCII");
|
_testHttpLenient("text/xml", "no-bom", "US-ASCII", null, "US-ASCII");
|
||||||
_testHttpLenient("text/xml;charset=UTF-8","UTF-8-bom","UTF-8","UTF-8", "UTF-8");
|
_testHttpLenient("text/xml;charset=UTF-8", "UTF-8-bom", "UTF-8", "UTF-8", "UTF-8");
|
||||||
_testHttpLenient("text/xml;charset=UTF-8","UTF-8-bom","UTF-8",null, "UTF-8");
|
_testHttpLenient("text/xml;charset=UTF-8", "UTF-8-bom", "UTF-8", null, "UTF-8");
|
||||||
_testHttpLenient("text/xml;charset=UTF-16","UTF-16BE-bom","UTF-16BE",null, "UTF-16BE");
|
_testHttpLenient("text/xml;charset=UTF-16", "UTF-16BE-bom", "UTF-16BE", null, "UTF-16BE");
|
||||||
_testHttpLenient("text/xml;charset=UTF-16","UTF-16BE-bom","UTF-16BE","UTF-16", "UTF-16");
|
_testHttpLenient("text/xml;charset=UTF-16", "UTF-16BE-bom", "UTF-16BE", "UTF-16", "UTF-16");
|
||||||
_testHttpLenient("text/xml;charset=UTF-16","UTF-16BE-bom","UTF-16BE","UTF-16BE", "UTF-16BE");
|
_testHttpLenient("text/xml;charset=UTF-16", "UTF-16BE-bom", "UTF-16BE", "UTF-16BE", "UTF-16BE");
|
||||||
_testHttpLenient("text/xml","UTF-8-bom","US-ASCII",null, "US-ASCII");
|
_testHttpLenient("text/xml", "UTF-8-bom", "US-ASCII", null, "US-ASCII");
|
||||||
|
|
||||||
_testHttpLenient("text/xml;charset=UTF-16BE","UTF-16BE-bom","UTF-16BE",null, "UTF-16BE");
|
_testHttpLenient("text/xml;charset=UTF-16BE", "UTF-16BE-bom", "UTF-16BE", null, "UTF-16BE");
|
||||||
_testHttpLenient("text/xml;charset=UTF-16BE","UTF-16BE-bom","UTF-16BE","UTF-16", "UTF-16");
|
_testHttpLenient("text/xml;charset=UTF-16BE", "UTF-16BE-bom", "UTF-16BE", "UTF-16", "UTF-16");
|
||||||
_testHttpLenient("text/xml;charset=UTF-16BE","UTF-16BE-bom","UTF-16BE","UTF-16BE", "UTF-16BE");
|
_testHttpLenient("text/xml;charset=UTF-16BE", "UTF-16BE-bom", "UTF-16BE", "UTF-16BE", "UTF-16BE");
|
||||||
_testHttpLenient("text/xml;charset=UTF-16","no-bom","UTF-16BE","UTF-16BE", "UTF-16BE");
|
_testHttpLenient("text/xml;charset=UTF-16", "no-bom", "UTF-16BE", "UTF-16BE", "UTF-16BE");
|
||||||
_testHttpLenient("text/xml;charset=UTF-16","no-bom","UTF-16BE",null, "UTF-16");
|
_testHttpLenient("text/xml;charset=UTF-16", "no-bom", "UTF-16BE", null, "UTF-16");
|
||||||
|
|
||||||
_testHttpLenient("text/html","no-bom","US-ASCII","US-ASCII", "US-ASCII");
|
_testHttpLenient("text/html", "no-bom", "US-ASCII", "US-ASCII", "US-ASCII");
|
||||||
_testHttpLenient("text/html","no-bom","US-ASCII",null, "US-ASCII");
|
_testHttpLenient("text/html", "no-bom", "US-ASCII", null, "US-ASCII");
|
||||||
_testHttpLenient("text/html;charset=UTF-8","no-bom","US-ASCII","UTF-8", "UTF-8");
|
_testHttpLenient("text/html;charset=UTF-8", "no-bom", "US-ASCII", "UTF-8", "UTF-8");
|
||||||
_testHttpLenient("text/html;charset=UTF-16BE","no-bom","US-ASCII","UTF-8", "UTF-8");
|
_testHttpLenient("text/html;charset=UTF-16BE", "no-bom", "US-ASCII", "UTF-8", "UTF-8");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void _testHttpValid(String cT,String bomEnc,String streamEnc,String prologEnc) throws Exception {
|
public void _testHttpValid(final String cT, final String bomEnc, final String streamEnc, final String prologEnc) throws Exception {
|
||||||
InputStream is = getXmlStream(bomEnc,(prologEnc==null)?"xml":"xml-prolog-encoding",streamEnc,prologEnc);
|
final InputStream is = getXmlStream(bomEnc, prologEnc == null ? "xml" : "xml-prolog-encoding", streamEnc, prologEnc);
|
||||||
XmlReader xmlReader = new XmlReader(is,cT,false);
|
final XmlReader xmlReader = new XmlReader(is, cT, false);
|
||||||
if (!streamEnc.equals("UTF-16")) {
|
if (!streamEnc.equals("UTF-16")) {
|
||||||
// we can not assert things here becuase UTF-8, US-ASCII and ISO-8859-1 look alike for the chars used for detection
|
// we can not assert things here becuase UTF-8, US-ASCII and ISO-8859-1 look alike for the chars used for detection
|
||||||
}
|
} else {
|
||||||
else {
|
assertEquals(xmlReader.getEncoding().substring(0, streamEnc.length()), streamEnc);
|
||||||
assertEquals(xmlReader.getEncoding().substring(0,streamEnc.length()),streamEnc);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void _testHttpInvalid(String cT,String bomEnc,String streamEnc,String prologEnc) throws Exception {
|
protected void _testHttpInvalid(final String cT, final String bomEnc, final String streamEnc, final String prologEnc) throws Exception {
|
||||||
InputStream is = getXmlStream(bomEnc,(prologEnc==null)?"xml-prolog":"xml-prolog-encoding",streamEnc,prologEnc);
|
final InputStream is = getXmlStream(bomEnc, prologEnc == null ? "xml-prolog" : "xml-prolog-encoding", streamEnc, prologEnc);
|
||||||
try {
|
try {
|
||||||
XmlReader xmlReader = new XmlReader(is,cT,false);
|
final XmlReader xmlReader = new XmlReader(is, cT, false);
|
||||||
fail("It should have failed for HTTP Content-type "+cT+", BOM "+bomEnc+", streamEnc "+streamEnc+" and prologEnc "+prologEnc);
|
fail("It should have failed for HTTP Content-type " + cT + ", BOM " + bomEnc + ", streamEnc " + streamEnc + " and prologEnc " + prologEnc);
|
||||||
|
} catch (final IOException ex) {
|
||||||
|
assertTrue(ex.getMessage().indexOf("Invalid encoding,") > -1);
|
||||||
}
|
}
|
||||||
catch (IOException ex) {
|
}
|
||||||
assertTrue(ex.getMessage().indexOf("Invalid encoding,")>-1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void _testHttpLenient(String cT, String bomEnc, String streamEnc, String prologEnc, String shouldbe) throws Exception {
|
protected void _testHttpLenient(final String cT, final String bomEnc, final String streamEnc, final String prologEnc, final String shouldbe)
|
||||||
InputStream is = getXmlStream(bomEnc,(prologEnc==null)?"xml-prolog":"xml-prolog-encoding",streamEnc,prologEnc);
|
throws Exception {
|
||||||
XmlReader xmlReader = new XmlReader(is,cT,true);
|
final InputStream is = getXmlStream(bomEnc, prologEnc == null ? "xml-prolog" : "xml-prolog-encoding", streamEnc, prologEnc);
|
||||||
assertEquals(xmlReader.getEncoding(),shouldbe);
|
final XmlReader xmlReader = new XmlReader(is, cT, true);
|
||||||
|
assertEquals(xmlReader.getEncoding(), shouldbe);
|
||||||
}
|
}
|
||||||
|
|
||||||
// XML Stream generator
|
// XML Stream generator
|
||||||
|
|
||||||
private static final int[] NO_BOM_BYTES = {};
|
private static final int[] NO_BOM_BYTES = {};
|
||||||
private static final int[] UTF_16BE_BOM_BYTES = {0xFE,0xFF};
|
private static final int[] UTF_16BE_BOM_BYTES = { 0xFE, 0xFF };
|
||||||
private static final int[] UTF_16LE_BOM_BYTES = {0xFF,0XFE};
|
private static final int[] UTF_16LE_BOM_BYTES = { 0xFF, 0XFE };
|
||||||
private static final int[] UTF_8_BOM_BYTES = {0xEF,0xBB,0xBF};
|
private static final int[] UTF_8_BOM_BYTES = { 0xEF, 0xBB, 0xBF };
|
||||||
|
|
||||||
private static final Map BOMs = new HashMap();
|
private static final Map BOMs = new HashMap();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
BOMs.put("no-bom",NO_BOM_BYTES);
|
BOMs.put("no-bom", NO_BOM_BYTES);
|
||||||
BOMs.put("UTF-16BE-bom",UTF_16BE_BOM_BYTES);
|
BOMs.put("UTF-16BE-bom", UTF_16BE_BOM_BYTES);
|
||||||
BOMs.put("UTF-16LE-bom",UTF_16LE_BOM_BYTES);
|
BOMs.put("UTF-16LE-bom", UTF_16LE_BOM_BYTES);
|
||||||
BOMs.put("UTF-16-bom",NO_BOM_BYTES); // it's added by the writer
|
BOMs.put("UTF-16-bom", NO_BOM_BYTES); // it's added by the writer
|
||||||
BOMs.put("UTF-8-bom",UTF_8_BOM_BYTES);
|
BOMs.put("UTF-8-bom", UTF_8_BOM_BYTES);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final MessageFormat XML = new MessageFormat(
|
private static final MessageFormat XML = new MessageFormat("<root>{2}</root>");
|
||||||
"<root>{2}</root>");
|
private static final MessageFormat XML_WITH_PROLOG = new MessageFormat("<?xml version=\"1.0\"?>\n<root>{2}</root>");
|
||||||
private static final MessageFormat XML_WITH_PROLOG = new MessageFormat(
|
private static final MessageFormat XML_WITH_PROLOG_AND_ENCODING = new MessageFormat("<?xml version=\"1.0\" encoding=\"{1}\"?>\n<root>{2}</root>");
|
||||||
"<?xml version=\"1.0\"?>\n<root>{2}</root>");
|
|
||||||
private static final MessageFormat XML_WITH_PROLOG_AND_ENCODING = new MessageFormat(
|
|
||||||
"<?xml version=\"1.0\" encoding=\"{1}\"?>\n<root>{2}</root>");
|
|
||||||
|
|
||||||
private static final MessageFormat INFO = new MessageFormat(
|
private static final MessageFormat INFO = new MessageFormat("\nBOM : {0}\nDoc : {1}\nStream Enc : {2}\nProlog Enc : {3}\n");
|
||||||
"\nBOM : {0}\nDoc : {1}\nStream Enc : {2}\nProlog Enc : {3}\n");
|
|
||||||
|
|
||||||
private static final Map XMLs = new HashMap();
|
private static final Map XMLs = new HashMap();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
XMLs.put("xml",XML);
|
XMLs.put("xml", XML);
|
||||||
XMLs.put("xml-prolog",XML_WITH_PROLOG);
|
XMLs.put("xml-prolog", XML_WITH_PROLOG);
|
||||||
XMLs.put("xml-prolog-encoding",XML_WITH_PROLOG_AND_ENCODING);
|
XMLs.put("xml-prolog-encoding", XML_WITH_PROLOG_AND_ENCODING);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -227,24 +225,24 @@ public class TestXmlReader extends TestCase {
|
||||||
* @param xmlType xml, xml-prolog, xml-prolog-charset
|
* @param xmlType xml, xml-prolog, xml-prolog-charset
|
||||||
* @return XML stream
|
* @return XML stream
|
||||||
*/
|
*/
|
||||||
protected InputStream getXmlStream(String bomType,String xmlType,String streamEnc,String prologEnc) throws IOException {
|
protected InputStream getXmlStream(final String bomType, final String xmlType, final String streamEnc, final String prologEnc) throws IOException {
|
||||||
ByteArrayOutputStream baos = new ByteArrayOutputStream(1024);
|
final ByteArrayOutputStream baos = new ByteArrayOutputStream(1024);
|
||||||
int[] bom = (int[]) BOMs.get(bomType);
|
int[] bom = (int[]) BOMs.get(bomType);
|
||||||
if (bom==null) {
|
if (bom == null) {
|
||||||
bom = new int[0];
|
bom = new int[0];
|
||||||
}
|
}
|
||||||
MessageFormat xml = (MessageFormat) XMLs.get(xmlType);
|
final MessageFormat xml = (MessageFormat) XMLs.get(xmlType);
|
||||||
for (int i=0;i<bom.length;i++) {
|
for (final int element : bom) {
|
||||||
baos.write(bom[i]);
|
baos.write(element);
|
||||||
}
|
}
|
||||||
Writer writer = new OutputStreamWriter(baos,streamEnc);
|
final Writer writer = new OutputStreamWriter(baos, streamEnc);
|
||||||
String info = INFO.format(new Object[]{bomType,xmlType,prologEnc});
|
final String info = INFO.format(new Object[] { bomType, xmlType, prologEnc });
|
||||||
String xmlDoc = xml.format(new Object[]{streamEnc,prologEnc,info});
|
final String xmlDoc = xml.format(new Object[] { streamEnc, prologEnc, info });
|
||||||
writer.write(xmlDoc);
|
writer.write(xmlDoc);
|
||||||
|
|
||||||
// PADDDING TO TEST THINGS WORK BEYOND PUSHBACK_SIZE
|
// PADDDING TO TEST THINGS WORK BEYOND PUSHBACK_SIZE
|
||||||
writer.write("<da>\n");
|
writer.write("<da>\n");
|
||||||
for (int i=0;i<10000;i++) {
|
for (int i = 0; i < 10000; i++) {
|
||||||
writer.write("<do/>\n");
|
writer.write("<do/>\n");
|
||||||
}
|
}
|
||||||
writer.write("</da>\n");
|
writer.write("</da>\n");
|
||||||
|
@ -253,5 +251,4 @@ public class TestXmlReader extends TestCase {
|
||||||
return new ByteArrayInputStream(baos.toByteArray());
|
return new ByteArrayInputStream(baos.toByteArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue