Formatted code
Updated POM
This commit is contained in:
parent
9e24592ef3
commit
14696ebed0
19 changed files with 803 additions and 887 deletions
137
pom.xml
137
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"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>org.rometools</groupId>
|
||||
<artifactId>rome-opml</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<version>1.5-SNAPSHOT</version>
|
||||
<version>2.0.0-SNAPSHOT</version>
|
||||
|
||||
<name>rome-opml</name>
|
||||
|
||||
<url>http://rometools.github.io/rome-opml/</url>
|
||||
|
||||
<description>Support for OPML 1 and OPML 2 in ROME</description>
|
||||
|
||||
<organization>
|
||||
<name>ROME Project</name>
|
||||
<url>https://github.com/rometools/</url>
|
||||
</organization>
|
||||
|
||||
<issueManagement>
|
||||
<url>https://github.com/rometools/rome-opml/issues</url>
|
||||
</issueManagement>
|
||||
|
||||
<scm>
|
||||
<connection>scm:git:git@github.com:rometools/rome-opml.git</connection>
|
||||
<developerConnection>scm:git:git@github.com:rometools/rome-opml.git</developerConnection>
|
||||
<url>https://github.com/rometools/rome-opml/</url>
|
||||
</scm>
|
||||
|
||||
<developers>
|
||||
<developer>
|
||||
<id>kebernet</id>
|
||||
|
@ -28,6 +36,7 @@
|
|||
<name>Robert Cooper</name>
|
||||
</developer>
|
||||
</developers>
|
||||
|
||||
<licenses>
|
||||
<license>
|
||||
<name>The Apache Software License, Version 2.0</name>
|
||||
|
@ -35,53 +44,45 @@
|
|||
<distribution>repo</distribution>
|
||||
</license>
|
||||
</licenses>
|
||||
<repositories>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<distributionManagement>
|
||||
<repository>
|
||||
<id>maven2-repository.dev.java.net</id>
|
||||
<url>http://download.java.net/maven/2</url>
|
||||
<id>central.staging</id>
|
||||
<url>http://oss.sonatype.org/service/local/staging/deploy/maven2</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<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>
|
||||
<snapshotRepository>
|
||||
<id>sonatype.snapshots</id>
|
||||
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
|
||||
</snapshotRepository>
|
||||
</distributionManagement>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-scm-plugin</artifactId>
|
||||
<version>1.0</version>
|
||||
<configuration>
|
||||
<goals>install</goals>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<!-- <plugin> -->
|
||||
<!-- <groupId>org.apache.maven.plugins</groupId> -->
|
||||
<!-- <artifactId>maven-scm-plugin</artifactId> -->
|
||||
<!-- <version>1.8.1</version> -->
|
||||
<!-- <configuration> -->
|
||||
<!-- <goals>install</goals> -->
|
||||
<!-- </configuration> -->
|
||||
<!-- </plugin> -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>2.0.2</version>
|
||||
<version>3.1</version>
|
||||
<configuration>
|
||||
<source>1.4</source>
|
||||
<target>1.4</target>
|
||||
<encoding>${project.build.sourceEncoding}</encoding>
|
||||
<source>1.6</source>
|
||||
<target>1.6</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-resources-plugin</artifactId>
|
||||
<version>2.6</version>
|
||||
<configuration>
|
||||
<encoding>${project.build.sourceEncoding}</encoding>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
|
@ -102,47 +103,10 @@
|
|||
<content>${project.build.directory}/site</content>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>release</id>
|
||||
<activation>
|
||||
<property>
|
||||
<name>performRelease</name>
|
||||
<value>true</value>
|
||||
</property>
|
||||
</activation>
|
||||
<distributionManagement>
|
||||
<repository>
|
||||
<id>central.staging</id>
|
||||
<name>Nexus Release Repository</name>
|
||||
<url>http://oss.sonatype.org/service/local/staging/deploy/maven2</url>
|
||||
</repository>
|
||||
<snapshotRepository>
|
||||
<id>sonatype.snapshots</id>
|
||||
<name>My Nexus Snapshots Repository</name>
|
||||
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
|
||||
</snapshotRepository>
|
||||
</distributionManagement>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-gpg-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>sign-artifacts</id>
|
||||
<phase>verify</phase>
|
||||
<goals>
|
||||
<goal>sign</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-source-plugin</artifactId>
|
||||
<version>2.2.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-sources</id>
|
||||
|
@ -155,6 +119,7 @@
|
|||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<version>2.9.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-javadocs</id>
|
||||
|
@ -166,22 +131,18 @@
|
|||
</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>
|
||||
<version>2.7</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<version>2.9</version>
|
||||
<version>2.9.1</version>
|
||||
<reportSets>
|
||||
<reportSet>
|
||||
<reports>
|
||||
|
@ -200,4 +161,20 @@
|
|||
</plugin>
|
||||
</plugins>
|
||||
</reporting>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.11</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.rometools</groupId>
|
||||
<artifactId>rome</artifactId>
|
||||
<version>2.0.0-SNAPSHOT</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
|
|
|
@ -22,7 +22,6 @@ import com.sun.syndication.feed.impl.ToStringBean;
|
|||
|
||||
import java.io.Serializable;
|
||||
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @param name name of the attribute.
|
||||
* @param value value of the attribute.
|
||||
*/
|
||||
|
@ -53,6 +53,7 @@ public class Attribute implements Cloneable, Serializable {
|
|||
|
||||
/**
|
||||
* name of the attribute.
|
||||
*
|
||||
* @param name name of the attribute.
|
||||
*/
|
||||
public void setName(String name) {
|
||||
|
@ -61,6 +62,7 @@ public class Attribute implements Cloneable, Serializable {
|
|||
|
||||
/**
|
||||
* name of the attribute.
|
||||
*
|
||||
* @return name of the attribute.
|
||||
*/
|
||||
public String getName() {
|
||||
|
@ -69,6 +71,7 @@ public class Attribute implements Cloneable, Serializable {
|
|||
|
||||
/**
|
||||
* value of the attribute.
|
||||
*
|
||||
* @param value value of the attribute.
|
||||
*/
|
||||
public void setValue(String value) {
|
||||
|
@ -77,28 +80,33 @@ public class Attribute implements Cloneable, Serializable {
|
|||
|
||||
/**
|
||||
* value of the attribute.
|
||||
*
|
||||
* @return value of the attribute.
|
||||
*/
|
||||
public String getValue() {
|
||||
return _value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object clone() {
|
||||
return new Attribute(this._name, this._value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
EqualsBean eBean = new EqualsBean(Attribute.class, this);
|
||||
|
||||
return eBean.beanEquals(obj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
EqualsBean equals = new EqualsBean(Attribute.class, this);
|
||||
|
||||
return equals.beanHashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
ToStringBean tsBean = new ToStringBean(Attribute.class, this);
|
||||
|
||||
|
|
|
@ -23,10 +23,9 @@ import java.util.ArrayList;
|
|||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* 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.
|
||||
*
|
||||
* @author <a href="mailto:cooper@screaming-penguin.com"> Robert "kebernet" Cooper</a>
|
||||
*/
|
||||
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.
|
||||
*
|
||||
* @param created date-time, indicating when the document was 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.
|
||||
*
|
||||
* @return date-time, indicating when the document was created.
|
||||
*/
|
||||
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
|
||||
*/
|
||||
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
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
public int[] getExpansionState() {
|
||||
|
@ -100,6 +111,7 @@ public class Opml extends WireFeed {
|
|||
|
||||
/**
|
||||
* <dateModified> is a 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) {
|
||||
|
@ -108,6 +120,7 @@ public class Opml extends WireFeed {
|
|||
|
||||
/**
|
||||
* <dateModified> is a date-time, indicating when the document was last modified.
|
||||
*
|
||||
* @return date-time, indicating when the document was last modified.
|
||||
*/
|
||||
public Date getModified() {
|
||||
|
@ -116,6 +129,7 @@ public class Opml extends WireFeed {
|
|||
|
||||
/**
|
||||
* 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) {
|
||||
|
@ -124,6 +138,7 @@ public class Opml extends WireFeed {
|
|||
|
||||
/**
|
||||
* Root level Outline object that should appear in the <body>
|
||||
*
|
||||
* @return Root level Outline object that should appear in the <body>
|
||||
*/
|
||||
public List getOutlines() {
|
||||
|
@ -136,6 +151,7 @@ public class Opml extends WireFeed {
|
|||
|
||||
/**
|
||||
* <ownerEmail> is a string, 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) {
|
||||
|
@ -144,6 +160,7 @@ public class Opml extends WireFeed {
|
|||
|
||||
/**
|
||||
* <ownerEmail> is a string, the email address of the owner of the document.
|
||||
*
|
||||
* @return the email address of the owner of the document.
|
||||
*/
|
||||
public String getOwnerEmail() {
|
||||
|
@ -151,16 +168,22 @@ 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.
|
||||
* @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.
|
||||
* (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.
|
||||
*
|
||||
* @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) {
|
||||
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.
|
||||
* @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.
|
||||
* (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.
|
||||
*
|
||||
* @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() {
|
||||
return _ownerId;
|
||||
|
@ -168,6 +191,7 @@ public class Opml extends WireFeed {
|
|||
|
||||
/**
|
||||
* <ownerName> is a string, the owner of the document.
|
||||
*
|
||||
* @param ownerName the owner of the document.
|
||||
*/
|
||||
public void setOwnerName(String ownerName) {
|
||||
|
@ -176,6 +200,7 @@ public class Opml extends WireFeed {
|
|||
|
||||
/**
|
||||
* <ownerName> is a string, the owner of the document.
|
||||
*
|
||||
* @return the owner of the document.
|
||||
*/
|
||||
public String getOwnerName() {
|
||||
|
@ -184,6 +209,7 @@ public class Opml extends WireFeed {
|
|||
|
||||
/**
|
||||
* <title> is the title of the document.
|
||||
*
|
||||
* @param title title of the document.
|
||||
*/
|
||||
public void setTitle(String title) {
|
||||
|
@ -192,6 +218,7 @@ public class Opml extends WireFeed {
|
|||
|
||||
/**
|
||||
* <title> is the title of the document.
|
||||
*
|
||||
* @return title of the document.
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
public void setVerticalScrollState(Integer verticalScrollState) {
|
||||
|
@ -207,7 +236,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.
|
||||
*
|
||||
* @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() {
|
||||
|
@ -216,6 +247,7 @@ public class Opml extends WireFeed {
|
|||
|
||||
/**
|
||||
* <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.
|
||||
*/
|
||||
public void setWindowBottom(Integer windowBottom) {
|
||||
|
@ -224,6 +256,7 @@ public class Opml extends WireFeed {
|
|||
|
||||
/**
|
||||
* <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.
|
||||
*/
|
||||
public Integer getWindowBottom() {
|
||||
|
@ -232,6 +265,7 @@ public class Opml extends WireFeed {
|
|||
|
||||
/**
|
||||
* <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.
|
||||
*/
|
||||
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.
|
||||
*
|
||||
* @return the pixel location of the left edge of the window.
|
||||
*/
|
||||
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.
|
||||
*
|
||||
* @param windowRight the pixel location of the right edge of the window.
|
||||
*/
|
||||
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.
|
||||
*
|
||||
* @return the pixel location of the right edge of the window.
|
||||
*/
|
||||
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.
|
||||
*
|
||||
* @param windowTop the pixel location of the top edge of the window.
|
||||
*/
|
||||
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.
|
||||
*
|
||||
* @return the pixel location of the top edge of the window.
|
||||
*/
|
||||
public Integer getWindowTop() {
|
||||
|
|
|
@ -29,9 +29,9 @@ import java.util.Collections;
|
|||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* This class represents an OPML outline element.
|
||||
*
|
||||
* @author <a href="mailto:cooper@screaming-penguin.com">Robert "kebernet" Cooper</a>
|
||||
*/
|
||||
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.
|
||||
*
|
||||
* @param type type 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
|
||||
* used for aggregator feed lists and will get a type of "rss".
|
||||
* 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".
|
||||
*
|
||||
* @param title Title of the entry.
|
||||
* @param xmlUrl link to XML file.
|
||||
* @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.
|
||||
*
|
||||
* @param attributes List of attributes on this outline.
|
||||
*/
|
||||
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.
|
||||
*
|
||||
* @return List of attributes on this outline.
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
public void setBreakpoint(boolean breakpoint) {
|
||||
|
@ -113,7 +118,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.
|
||||
*
|
||||
* @return whether a breakpoint is set on this outline
|
||||
*/
|
||||
public boolean isBreakpoint() {
|
||||
|
@ -122,6 +129,7 @@ public class Outline implements Cloneable, Serializable {
|
|||
|
||||
/**
|
||||
* (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) {
|
||||
|
@ -130,6 +138,7 @@ public class Outline implements Cloneable, Serializable {
|
|||
|
||||
/**
|
||||
* (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() {
|
||||
|
@ -142,6 +151,7 @@ public class Outline implements Cloneable, Serializable {
|
|||
|
||||
/**
|
||||
* A list of sub-outlines for this entry.
|
||||
*
|
||||
* @param children A list of sub-outlines for this entry.
|
||||
*/
|
||||
public void setChildren(List children) {
|
||||
|
@ -150,6 +160,7 @@ public class Outline implements Cloneable, Serializable {
|
|||
|
||||
/**
|
||||
* A list of sub-outlines for this entry.
|
||||
*
|
||||
* @return A list of sub-outlines for this entry.
|
||||
*/
|
||||
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
|
||||
*/
|
||||
public void setComment(boolean comment) {
|
||||
|
@ -169,7 +182,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.
|
||||
*
|
||||
* @return whether the outline is commented
|
||||
*/
|
||||
public boolean isComment() {
|
||||
|
@ -178,6 +193,7 @@ public class Outline implements Cloneable, Serializable {
|
|||
|
||||
/**
|
||||
* (OPML 2) created is the date-time that the outline node was created.
|
||||
*
|
||||
* @param created date-time that the outline node was 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.
|
||||
*
|
||||
* @return date-time that the outline node was created.
|
||||
*/
|
||||
public Date getCreated() {
|
||||
|
@ -194,6 +211,7 @@ public class Outline implements Cloneable, Serializable {
|
|||
|
||||
/**
|
||||
* A convenience method to return the value of the url attribute.
|
||||
*
|
||||
* @return value of the htmlUrl attribute.
|
||||
*/
|
||||
public String getUrl() {
|
||||
|
@ -202,6 +220,7 @@ public class Outline implements Cloneable, Serializable {
|
|||
|
||||
/**
|
||||
* A convenience method to return the value of the htmlUrl attribute.
|
||||
*
|
||||
* @return value of the htmlUrl attribute.
|
||||
*/
|
||||
public String getHtmlUrl() {
|
||||
|
@ -222,6 +241,7 @@ public class Outline implements Cloneable, Serializable {
|
|||
|
||||
/**
|
||||
* The "text" attribute of the outline.
|
||||
*
|
||||
* @param text The "text" attribute of the outline.
|
||||
*/
|
||||
public void setText(String text) {
|
||||
|
@ -230,6 +250,7 @@ public class Outline implements Cloneable, Serializable {
|
|||
|
||||
/**
|
||||
* The "text" attribute of the outline.
|
||||
*
|
||||
* @return The "text" attribute of the outline.
|
||||
*/
|
||||
public String getText() {
|
||||
|
@ -238,6 +259,7 @@ public class Outline implements Cloneable, Serializable {
|
|||
|
||||
/**
|
||||
* The "title" attribute of the outline.
|
||||
*
|
||||
* @param title The "title" attribute of the outline.
|
||||
*/
|
||||
public void setTitle(String title) {
|
||||
|
@ -246,6 +268,7 @@ public class Outline implements Cloneable, Serializable {
|
|||
|
||||
/**
|
||||
* The "title" attribute of the outline.
|
||||
*
|
||||
* @return The "title" attribute of the outline.
|
||||
*/
|
||||
public String getTitle() {
|
||||
|
@ -254,6 +277,7 @@ public class Outline implements Cloneable, Serializable {
|
|||
|
||||
/**
|
||||
* The "type" attribute of the outline.
|
||||
*
|
||||
* @param type The "type" attribute of the outline.
|
||||
*/
|
||||
public void setType(String type) {
|
||||
|
@ -262,6 +286,7 @@ public class Outline implements Cloneable, Serializable {
|
|||
|
||||
/**
|
||||
* The "type" attribute of the outline.
|
||||
*
|
||||
* @return The "type" attribute of the outline.
|
||||
*/
|
||||
public String getType() {
|
||||
|
@ -270,13 +295,16 @@ public class Outline implements Cloneable, Serializable {
|
|||
|
||||
/**
|
||||
* A convenience method to return the value of the xmlUrl attribute.
|
||||
*
|
||||
* @return value of the xmlUrl attribute.
|
||||
*/
|
||||
public String getXmlUrl() {
|
||||
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.
|
||||
*/
|
||||
public String getAttributeValue(String name) {
|
||||
|
@ -293,6 +321,7 @@ public class Outline implements Cloneable, Serializable {
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object clone() {
|
||||
Outline o = new Outline();
|
||||
o.setBreakpoint(this.isBreakpoint());
|
||||
|
@ -323,18 +352,21 @@ public class Outline implements Cloneable, Serializable {
|
|||
return o;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
EqualsBean eBean = new EqualsBean(Outline.class, this);
|
||||
|
||||
return eBean.beanEquals(obj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
EqualsBean equals = new EqualsBean(Outline.class, this);
|
||||
|
||||
return equals.beanHashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
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.SyndPersonImpl;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author cooper
|
||||
*/
|
||||
public class ConverterForOPML10 implements Converter {
|
||||
private static final Logger LOG = Logger.getLogger(ConverterForOPML10.class.getName()
|
||||
.toString());
|
||||
private static final Logger LOG = Logger.getLogger(ConverterForOPML10.class.getName().toString());
|
||||
public static final String URI_TREE = "urn:rome.tree";
|
||||
public static final String URI_ATTRIBUTE = "urn:rome.attribute#";
|
||||
|
||||
|
@ -77,23 +75,21 @@ public class ConverterForOPML10 implements Converter {
|
|||
* @param feed real feed to copy/convert.
|
||||
* @param syndFeed the SyndFeedImpl that will contain the copied/converted values of the real feed.
|
||||
*/
|
||||
@Override
|
||||
public void copyInto(WireFeed feed, SyndFeed syndFeed) {
|
||||
Opml opml = (Opml) feed;
|
||||
syndFeed.setTitle(opml.getTitle());
|
||||
addOwner(opml, syndFeed);
|
||||
syndFeed.setPublishedDate((opml.getModified() != null)
|
||||
? opml.getModified() : opml.getCreated());
|
||||
syndFeed.setPublishedDate((opml.getModified() != null) ? opml.getModified() : opml.getCreated());
|
||||
syndFeed.setFeedType(opml.getFeedType());
|
||||
syndFeed.setModules(opml.getModules());
|
||||
syndFeed.setFeedType(this.getType());
|
||||
|
||||
ArrayList entries = new ArrayList();
|
||||
createEntries(new TreeContext(), syndFeed.getEntries(),
|
||||
opml.getOutlines());
|
||||
createEntries(new TreeContext(), syndFeed.getEntries(), opml.getOutlines());
|
||||
}
|
||||
|
||||
protected void createEntries(TreeContext context, List allEntries,
|
||||
List outlines) {
|
||||
protected void createEntries(TreeContext context, List allEntries, List outlines) {
|
||||
List so = Collections.synchronizedList(outlines);
|
||||
|
||||
for (int i = 0; i < so.size(); i++) {
|
||||
|
@ -101,15 +97,12 @@ public class ConverterForOPML10 implements Converter {
|
|||
}
|
||||
}
|
||||
|
||||
protected SyndEntry createEntry(TreeContext context, List allEntries,
|
||||
Outline outline) {
|
||||
protected SyndEntry createEntry(TreeContext context, List allEntries, Outline outline) {
|
||||
SyndEntry entry = new SyndEntryImpl();
|
||||
|
||||
if ((outline.getType() != null) && outline.getType().equals("rss")) {
|
||||
entry.setLink((outline.getHtmlUrl() != null) ? outline.getHtmlUrl()
|
||||
: outline.getXmlUrl());
|
||||
} else if((outline.getType() != null) &&
|
||||
outline.getType().equals("link")) {
|
||||
entry.setLink((outline.getHtmlUrl() != null) ? outline.getHtmlUrl() : outline.getXmlUrl());
|
||||
} else if ((outline.getType() != null) && outline.getType().equals("link")) {
|
||||
entry.setLink(outline.getUrl());
|
||||
}
|
||||
|
||||
|
@ -122,8 +115,7 @@ public class ConverterForOPML10 implements Converter {
|
|||
entry.setLink(outline.getHtmlUrl());
|
||||
}
|
||||
|
||||
if((outline.getXmlUrl() != null) && (outline.getType() != null) &&
|
||||
outline.getType().equalsIgnoreCase("rss")) {
|
||||
if ((outline.getXmlUrl() != null) && (outline.getType() != null) && outline.getType().equalsIgnoreCase("rss")) {
|
||||
SyndLink link = new SyndLinkImpl();
|
||||
link.setRel("alternate");
|
||||
link.setType("application/rss+xml");
|
||||
|
@ -135,8 +127,7 @@ public class ConverterForOPML10 implements Converter {
|
|||
}
|
||||
}
|
||||
|
||||
if((outline.getXmlUrl() != null) && (outline.getType() != null) &&
|
||||
outline.getType().equalsIgnoreCase("atom")) {
|
||||
if ((outline.getXmlUrl() != null) && (outline.getType() != null) && outline.getType().equalsIgnoreCase("atom")) {
|
||||
SyndLink link = new SyndLinkImpl();
|
||||
link.setRel("alternate");
|
||||
link.setType("application/atom+xml");
|
||||
|
@ -204,6 +195,7 @@ public class ConverterForOPML10 implements Converter {
|
|||
* @return a real feed with copied/converted values of the SyndFeedImpl.
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public WireFeed createRealFeed(SyndFeed syndFeed) {
|
||||
List entries = Collections.synchronizedList(syndFeed.getEntries());
|
||||
|
||||
|
@ -222,11 +214,8 @@ public class ConverterForOPML10 implements Converter {
|
|||
for (int j = 0; j < cats.size(); j++) {
|
||||
SyndCategory cat = (SyndCategory) cats.get(j);
|
||||
|
||||
if((cat.getTaxonomyUri() != null) &&
|
||||
cat.getTaxonomyUri().equals(URI_TREE)) {
|
||||
String nodeVal = cat.getName()
|
||||
.substring(cat.getName().lastIndexOf("."),
|
||||
cat.getName().length());
|
||||
if ((cat.getTaxonomyUri() != null) && cat.getTaxonomyUri().equals(URI_TREE)) {
|
||||
String nodeVal = cat.getName().substring(cat.getName().lastIndexOf("."), cat.getName().length());
|
||||
|
||||
if (cat.getName().startsWith("node.")) {
|
||||
entriesByNode.put(nodeVal, o);
|
||||
|
@ -241,11 +230,8 @@ public class ConverterForOPML10 implements Converter {
|
|||
doAfterPass.add(new OutlineHolder(o, nodeVal));
|
||||
}
|
||||
}
|
||||
} else if((cat.getTaxonomyUri() != null) &&
|
||||
cat.getTaxonomyUri().startsWith(URI_ATTRIBUTE)) {
|
||||
String name = cat.getTaxonomyUri()
|
||||
.substring(cat.getTaxonomyUri().indexOf("#") +
|
||||
1, cat.getTaxonomyUri().length());
|
||||
} else if ((cat.getTaxonomyUri() != null) && cat.getTaxonomyUri().startsWith(URI_ATTRIBUTE)) {
|
||||
String name = cat.getTaxonomyUri().substring(cat.getTaxonomyUri().indexOf("#") + 1, cat.getTaxonomyUri().length());
|
||||
o.getAttributes().add(new Attribute(name, cat.getName()));
|
||||
} else {
|
||||
if (category.length() > 0) {
|
||||
|
@ -261,8 +247,7 @@ public class ConverterForOPML10 implements Converter {
|
|||
}
|
||||
|
||||
if (category.length() > 0) {
|
||||
o.getAttributes()
|
||||
.add(new Attribute("category", category.toString()));
|
||||
o.getAttributes().add(new Attribute("category", category.toString()));
|
||||
}
|
||||
|
||||
List links = Collections.synchronizedList(entry.getLinks());
|
||||
|
@ -272,21 +257,16 @@ public class ConverterForOPML10 implements Converter {
|
|||
SyndLink link = (SyndLink) links.get(j);
|
||||
|
||||
// if(link.getHref().equals(entryLink)) {
|
||||
if(((link.getType() != null) && (link.getRel() != null) &&
|
||||
link.getRel().equals("alternate")) &&
|
||||
(link.getType().equals("application/rss+xml") ||
|
||||
link.getType().equals("application/atom+xml"))) {
|
||||
if (((link.getType() != null) && (link.getRel() != null) && link.getRel().equals("alternate"))
|
||||
&& (link.getType().equals("application/rss+xml") || link.getType().equals("application/atom+xml"))) {
|
||||
o.setType("rss");
|
||||
|
||||
if (o.getXmlUrl() == null) {
|
||||
o.getAttributes()
|
||||
.add(new Attribute("xmlUrl", link.getHref()));
|
||||
o.getAttributes().add(new Attribute("xmlUrl", link.getHref()));
|
||||
}
|
||||
} else if((link.getType() != null) &&
|
||||
(link.getType().equals("text/html"))) {
|
||||
} else if ((link.getType() != null) && (link.getType().equals("text/html"))) {
|
||||
if (o.getHtmlUrl() == null) {
|
||||
o.getAttributes()
|
||||
.add(new Attribute("htmlUrl", link.getHref()));
|
||||
o.getAttributes().add(new Attribute("htmlUrl", link.getHref()));
|
||||
}
|
||||
} else {
|
||||
o.setType(link.getType());
|
||||
|
@ -298,7 +278,6 @@ public class ConverterForOPML10 implements Converter {
|
|||
if ((o.getType() == null) || o.getType().equals("link")) {
|
||||
o.setText(entry.getTitle());
|
||||
|
||||
|
||||
} else {
|
||||
o.setTitle(entry.getTitle());
|
||||
}
|
||||
|
@ -331,8 +310,7 @@ public class ConverterForOPML10 implements Converter {
|
|||
for (int i = 0; i < authors.size(); i++) {
|
||||
SyndPerson p = (SyndPerson) authors.get(i);
|
||||
|
||||
if((syndFeed.getAuthor() == null) ||
|
||||
syndFeed.getAuthor().equals(p.getName())) {
|
||||
if ((syndFeed.getAuthor() == null) || syndFeed.getAuthor().equals(p.getName())) {
|
||||
opml.setOwnerName(p.getName());
|
||||
opml.setOwnerEmail(p.getEmail());
|
||||
opml.setOwnerId(p.getUri());
|
||||
|
@ -352,6 +330,7 @@ public class ConverterForOPML10 implements Converter {
|
|||
* @see WireFeed for details on the format of this string.
|
||||
* <p>
|
||||
*/
|
||||
@Override
|
||||
public String getType() {
|
||||
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.synd.SyndFeed;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author cooper
|
||||
|
@ -30,6 +29,7 @@ public class ConverterForOPML20 extends ConverterForOPML10 {
|
|||
* @see WireFeed for details on the format of this string.
|
||||
* <p>
|
||||
*/
|
||||
@Override
|
||||
public String getType() {
|
||||
return "opml_2.0";
|
||||
}
|
||||
|
@ -43,6 +43,7 @@ public class ConverterForOPML20 extends ConverterForOPML10 {
|
|||
* @param feed real feed to copy/convert.
|
||||
* @param syndFeed the SyndFeedImpl that will contain the copied/converted values of the real feed.
|
||||
*/
|
||||
@Override
|
||||
public void copyInto(WireFeed feed, SyndFeed syndFeed) {
|
||||
super.copyInto(feed, syndFeed);
|
||||
}
|
||||
|
@ -54,6 +55,7 @@ public class ConverterForOPML20 extends ConverterForOPML10 {
|
|||
* @param syndFeed SyndFeedImpl to copy/convert value from.
|
||||
* @return a real feed with copied/converted values of the SyndFeedImpl.
|
||||
*/
|
||||
@Override
|
||||
public WireFeed createRealFeed(SyndFeed syndFeed) {
|
||||
WireFeed retValue;
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@ public class TreeCategoryImpl extends SyndCategoryImpl {
|
|||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
SyndCategory c = (SyndCategory) o;
|
||||
if (c.getTaxonomyUri() != null && c.getTaxonomyUri().equals(this.getTaxonomyUri()))
|
||||
|
|
|
@ -26,14 +26,13 @@ import com.sun.syndication.io.WireFeedGenerator;
|
|||
import com.sun.syndication.io.impl.BaseWireFeedGenerator;
|
||||
import com.sun.syndication.io.impl.DateParser;
|
||||
|
||||
import org.jdom.Document;
|
||||
import org.jdom.Element;
|
||||
import org.jdom2.Document;
|
||||
import org.jdom2.Element;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @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.
|
||||
* @return the generated XML document (JDOM).
|
||||
* @throws IllegalArgumentException thrown if the type of the given feed bean does not
|
||||
* match with the type of the WireFeedGenerator.
|
||||
* @throws IllegalArgumentException thrown if the type of the given feed bean does not match with the type of the WireFeedGenerator.
|
||||
* @throws FeedException thrown if the XML Document could not be created.
|
||||
*/
|
||||
@Override
|
||||
public Document generate(WireFeed feed) throws IllegalArgumentException, FeedException {
|
||||
if (!(feed instanceof Opml)) {
|
||||
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.DateParser;
|
||||
|
||||
import org.jdom.Document;
|
||||
import org.jdom.Element;
|
||||
import org.jdom2.Document;
|
||||
import org.jdom2.Element;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
@ -35,7 +35,6 @@ import java.util.StringTokenizer;
|
|||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author <a href="mailto:cooper@screaming-penguin.com">Robert "kebernet" Cooper</a>
|
||||
|
@ -61,11 +60,11 @@ public class OPML10Parser extends BaseWireFeedParser implements WireFeedParser {
|
|||
* @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.
|
||||
*/
|
||||
@Override
|
||||
public boolean isMyType(Document document) {
|
||||
Element e = document.getRootElement();
|
||||
|
||||
if (e.getName().equals("opml")
|
||||
&& ( e.getChild("head") == null || e.getChild("head").getChild("docs") == null)
|
||||
if (e.getName().equals("opml") && (e.getChild("head") == null || e.getChild("head").getChild("docs") == null)
|
||||
&& (e.getAttributeValue("version") == null || e.getAttributeValue("version").equals("1.0"))) {
|
||||
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 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 {
|
||||
Opml opml = new Opml();
|
||||
opml.setFeedType("opml_1.0");
|
||||
|
@ -182,9 +182,10 @@ public class OPML10Parser extends BaseWireFeedParser implements WireFeedParser {
|
|||
ArrayList attributes = new ArrayList();
|
||||
|
||||
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()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,9 +14,8 @@ import org.rometools.feed.opml.Outline;
|
|||
import com.sun.syndication.io.FeedException;
|
||||
import com.sun.syndication.io.impl.DateParser;
|
||||
|
||||
import org.jdom.Document;
|
||||
import org.jdom.Element;
|
||||
|
||||
import org.jdom2.Document;
|
||||
import org.jdom2.Element;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -35,6 +34,7 @@ public class OPML20Generator extends OPML10Generator {
|
|||
* @see WireFeed for details on the format of this string.
|
||||
* <p>
|
||||
*/
|
||||
@Override
|
||||
public String getType() {
|
||||
return "opml_2.0";
|
||||
}
|
||||
|
@ -45,10 +45,10 @@ public class OPML20Generator extends OPML10Generator {
|
|||
*
|
||||
* @param feed the feed bean to generate the XML document from.
|
||||
* @return the generated XML document (JDOM).
|
||||
* @throws IllegalArgumentException thrown if the type of the given feed bean does not
|
||||
* match with the type of the WireFeedGenerator.
|
||||
* @throws IllegalArgumentException thrown if the type of the given feed bean does not match with the type of the WireFeedGenerator.
|
||||
* @throws FeedException thrown if the XML Document could not be created.
|
||||
*/
|
||||
@Override
|
||||
public Document generate(WireFeed feed) throws IllegalArgumentException, FeedException {
|
||||
Document retValue;
|
||||
|
||||
|
@ -58,6 +58,7 @@ public class OPML20Generator extends OPML10Generator {
|
|||
return retValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Element generateHead(Opml opml) {
|
||||
Element retValue;
|
||||
|
||||
|
@ -69,6 +70,7 @@ public class OPML20Generator extends OPML10Generator {
|
|||
return retValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Element generateOutline(Outline outline) {
|
||||
Element retValue;
|
||||
|
||||
|
|
|
@ -24,13 +24,10 @@ import org.rometools.feed.opml.Outline;
|
|||
import com.sun.syndication.io.FeedException;
|
||||
import com.sun.syndication.io.impl.DateParser;
|
||||
|
||||
import org.jdom.Document;
|
||||
import org.jdom.Element;
|
||||
import org.jdom2.Document;
|
||||
import org.jdom2.Element;
|
||||
|
||||
import java.util.ArrayList;
|
||||
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.
|
||||
* @return <b>true</b> if the parser know how to parser this feed, <b>false</b> otherwise.
|
||||
*/
|
||||
@Override
|
||||
public boolean isMyType(Document document) {
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -71,6 +72,7 @@ public class OPML20Parser extends OPML10Parser {
|
|||
* @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).
|
||||
*/
|
||||
@Override
|
||||
public WireFeed parse(Document document, boolean validate) throws IllegalArgumentException, FeedException {
|
||||
Opml opml;
|
||||
opml = (Opml) super.parse(document, validate);
|
||||
|
@ -91,6 +93,7 @@ public class OPML20Parser extends OPML10Parser {
|
|||
return opml;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Outline parseOutline(Element e, boolean validate) throws FeedException {
|
||||
Outline retValue;
|
||||
|
||||
|
|
|
@ -1,63 +1,64 @@
|
|||
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.synd.SyndFeed;
|
||||
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>
|
||||
*
|
||||
* @author Alejandro Abdelnur
|
||||
*
|
||||
*/
|
||||
public abstract class FeedOpsTest extends FeedTest {
|
||||
|
||||
protected FeedOpsTest(String feedType) {
|
||||
protected FeedOpsTest(final String feedType) {
|
||||
super(feedType + ".xml");
|
||||
System.out.println("Testing "+feedType+".xml");
|
||||
new File("target/test-reports").mkdirs();
|
||||
}
|
||||
|
||||
// 1.2a
|
||||
public void testWireFeedEquals() throws Exception {
|
||||
WireFeed feed1 = getCachedWireFeed();
|
||||
WireFeed feed2 = getWireFeed();
|
||||
final WireFeed feed1 = getCachedWireFeed();
|
||||
final WireFeed feed2 = getWireFeed();
|
||||
assertTrue(feed1.equals(feed2));
|
||||
}
|
||||
|
||||
// 1.2b
|
||||
public void testWireFeedNotEqual() throws Exception {
|
||||
WireFeed feed1 = getCachedWireFeed();
|
||||
WireFeed feed2 = getWireFeed();
|
||||
final WireFeed feed1 = getCachedWireFeed();
|
||||
final WireFeed feed2 = getWireFeed();
|
||||
feed2.setFeedType("dummy");
|
||||
assertFalse(feed1.equals(feed2));
|
||||
}
|
||||
|
||||
// 1.3
|
||||
public void testWireFeedCloning() throws Exception {
|
||||
WireFeed feed1 = getCachedWireFeed();
|
||||
WireFeed feed2 = (WireFeed) feed1.clone();;
|
||||
final WireFeed feed1 = getCachedWireFeed();
|
||||
final WireFeed feed2 = (WireFeed) feed1.clone();
|
||||
;
|
||||
assertTrue(feed1.equals(feed2));
|
||||
}
|
||||
|
||||
// 1.4
|
||||
public void testWireFeedSerialization() throws Exception {
|
||||
WireFeed feed1 = getCachedWireFeed();
|
||||
final WireFeed feed1 = getCachedWireFeed();
|
||||
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
ObjectOutputStream oos = new ObjectOutputStream(baos);
|
||||
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
final ObjectOutputStream oos = new ObjectOutputStream(baos);
|
||||
oos.writeObject(feed1);
|
||||
oos.close();
|
||||
|
||||
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
|
||||
ObjectInputStream ois = new ObjectInputStream(bais);
|
||||
WireFeed feed2 = (WireFeed) ois.readObject();
|
||||
final ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
|
||||
final ObjectInputStream ois = new ObjectInputStream(bais);
|
||||
final WireFeed feed2 = (WireFeed) ois.readObject();
|
||||
ois.close();
|
||||
|
||||
assertTrue(feed1.equals(feed2));
|
||||
|
@ -65,47 +66,48 @@ public abstract class FeedOpsTest extends FeedTest {
|
|||
|
||||
// 1.6
|
||||
public void testWireFeedSyndFeedConversion() throws Exception {
|
||||
SyndFeed sFeed1 = getCachedSyndFeed();
|
||||
WireFeed wFeed1 = sFeed1.createWireFeed();
|
||||
SyndFeed sFeed2 = new SyndFeedImpl(wFeed1);
|
||||
final SyndFeed sFeed1 = getCachedSyndFeed();
|
||||
final WireFeed wFeed1 = sFeed1.createWireFeed();
|
||||
final SyndFeed sFeed2 = new SyndFeedImpl(wFeed1);
|
||||
|
||||
assertEquals(sFeed1, sFeed2);
|
||||
}
|
||||
|
||||
// 1.7a
|
||||
public void testSyndFeedEquals() throws Exception {
|
||||
SyndFeed feed1 = getCachedSyndFeed();
|
||||
SyndFeed feed2 = getSyndFeed();
|
||||
final SyndFeed feed1 = getCachedSyndFeed();
|
||||
final SyndFeed feed2 = getSyndFeed();
|
||||
assertTrue(feed1.equals(feed2));
|
||||
}
|
||||
|
||||
// 1.7b
|
||||
public void testSyndFeedNotEqual() throws Exception {
|
||||
SyndFeed feed1 = getCachedSyndFeed();
|
||||
SyndFeed feed2 = getSyndFeed();
|
||||
final SyndFeed feed1 = getCachedSyndFeed();
|
||||
final SyndFeed feed2 = getSyndFeed();
|
||||
feed2.setFeedType("dummy");
|
||||
assertFalse(feed1.equals(feed2));
|
||||
}
|
||||
|
||||
// 1.8
|
||||
public void testSyndFeedCloning() throws Exception {
|
||||
SyndFeed feed1 = getCachedSyndFeed();
|
||||
SyndFeed feed2 = (SyndFeed) feed1.clone();;
|
||||
final SyndFeed feed1 = getCachedSyndFeed();
|
||||
final SyndFeed feed2 = (SyndFeed) feed1.clone();
|
||||
;
|
||||
assertTrue(feed1.equals(feed2));
|
||||
}
|
||||
|
||||
// 1.9
|
||||
public void testSyndFeedSerialization() throws Exception {
|
||||
SyndFeed feed1 = getCachedSyndFeed();
|
||||
final SyndFeed feed1 = getCachedSyndFeed();
|
||||
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
ObjectOutputStream oos = new ObjectOutputStream(baos);
|
||||
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
final ObjectOutputStream oos = new ObjectOutputStream(baos);
|
||||
oos.writeObject(feed1);
|
||||
oos.close();
|
||||
|
||||
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
|
||||
ObjectInputStream ois = new ObjectInputStream(bais);
|
||||
SyndFeed feed2 = (SyndFeed) ois.readObject();
|
||||
final ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
|
||||
final ObjectInputStream ois = new ObjectInputStream(bais);
|
||||
final SyndFeed feed2 = (SyndFeed) ois.readObject();
|
||||
ois.close();
|
||||
|
||||
assertTrue(feed1.equals(feed2));
|
||||
|
|
|
@ -1,30 +1,30 @@
|
|||
package org.rometools.unittest;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.Reader;
|
||||
|
||||
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.synd.SyndFeed;
|
||||
import com.sun.syndication.io.SyndFeedInput;
|
||||
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
|
||||
*
|
||||
*/
|
||||
public abstract class FeedTest extends TestCase {
|
||||
private String _feedFileName;
|
||||
private final String _feedFileName;
|
||||
private Document _jDomDoc = null;
|
||||
private WireFeed _wireFeed = null;
|
||||
private SyndFeed _syndFeed = null;
|
||||
|
||||
protected FeedTest(String feedFileName) {
|
||||
protected FeedTest(final String feedFileName) {
|
||||
_feedFileName = feedFileName;
|
||||
}
|
||||
|
||||
|
@ -33,24 +33,23 @@ public abstract class FeedTest extends TestCase {
|
|||
}
|
||||
|
||||
protected Reader getFeedReader() throws Exception {
|
||||
InputStream resource = Thread.currentThread().
|
||||
getContextClassLoader().getResourceAsStream(getFeedFileName());
|
||||
final InputStream resource = Thread.currentThread().getContextClassLoader().getResourceAsStream(getFeedFileName());
|
||||
assertNotNull("Could not find resource " + getFeedFileName(), resource);
|
||||
return new InputStreamReader(resource);
|
||||
}
|
||||
|
||||
protected Document getJDomDoc() throws Exception {
|
||||
SAXBuilder saxBuilder = new SAXBuilder(false);
|
||||
final SAXBuilder saxBuilder = new SAXBuilder(false);
|
||||
return saxBuilder.build(getFeedReader());
|
||||
}
|
||||
|
||||
protected WireFeed getWireFeed() throws Exception {
|
||||
WireFeedInput in = new WireFeedInput();
|
||||
final WireFeedInput in = new WireFeedInput();
|
||||
return in.build(getFeedReader());
|
||||
}
|
||||
|
||||
protected SyndFeed getSyndFeed() throws Exception {
|
||||
SyndFeedInput in = new SyndFeedInput();
|
||||
final SyndFeedInput in = new SyndFeedInput();
|
||||
return in.build(getFeedReader());
|
||||
}
|
||||
|
||||
|
|
|
@ -6,9 +6,6 @@
|
|||
*/
|
||||
package org.rometools.unittest;
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @author pat
|
||||
*
|
||||
|
@ -37,231 +34,109 @@ public abstract class SyndFeedTest extends FeedTest {
|
|||
assertEquals(getCachedSyndFeed().getFeedType(), getPrefix());
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
public void testType() throws Exception {
|
||||
assertEquals(getPrefix(), getCachedSyndFeed().getFeedType());
|
||||
}
|
||||
|
||||
public void testTitle() throws Exception {
|
||||
assertEqualsStr("channel.title", getCachedSyndFeed().getTitle());
|
||||
}
|
||||
|
||||
public void testLink() throws Exception {
|
||||
assertEqualsStr("channel.link", getCachedSyndFeed().getLink());
|
||||
}
|
||||
|
||||
public void testDescription() throws Exception {
|
||||
assertEqualsStr("channel.description", getCachedSyndFeed().getDescription());
|
||||
}
|
||||
|
||||
public void testLanguage() throws Exception {
|
||||
assertEqualsStr("channel.language", getCachedSyndFeed().getLanguage());
|
||||
}
|
||||
|
||||
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());
|
||||
assertEqualsStr("channel.category[0]^domain", cat.getTaxonomyUri());
|
||||
cat = (SyndCategory)catlist.get(1);
|
||||
assertEqualsStr("channel.category[1]", 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"), getCachedSyndFeed().getPublishedDate());
|
||||
}
|
||||
|
||||
//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());
|
||||
assertEqualsStr("channel.image.title", img.getTitle());
|
||||
assertEqualsStr("channel.image.url", img.getUrl());
|
||||
}
|
||||
|
||||
public void testEntries() throws Exception {
|
||||
List entrylist = getCachedSyndFeed().getEntries();
|
||||
assertEquals(2, entrylist.size());
|
||||
}
|
||||
|
||||
public void testEntryTitle() throws Exception {
|
||||
assertEqualsStr("channel.item[0].title", getEntryTitle(getCachedSyndFeed().getEntries().get(0)));
|
||||
assertEqualsStr("channel.item[1].title", getEntryTitle(getCachedSyndFeed().getEntries().get(1)));
|
||||
}
|
||||
|
||||
public String getEntryTitle(Object o) throws Exception {
|
||||
SyndEntry e = (SyndEntry) o;
|
||||
return e.getTitle();
|
||||
}
|
||||
|
||||
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 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)));
|
||||
assertEqualsStr("channel.item[1].link", getEntryLink(getCachedSyndFeed().getEntries().get(1)));
|
||||
}
|
||||
|
||||
public String getEntryLink(Object o) {
|
||||
SyndEntry e = (SyndEntry) o;
|
||||
return e.getLink();
|
||||
}
|
||||
|
||||
public void testEntryPublishedDate() throws Exception {
|
||||
assertEquals(DateParser.parseRFC822("Mon, 01 Jan 2001 00:00:00 GMT"), getEntryPublishedDate(getCachedSyndFeed().getEntries().get(0)));
|
||||
assertEquals(DateParser.parseRFC822("Mon, 01 Jan 2001 00:00:00 GMT"), getEntryPublishedDate(getCachedSyndFeed().getEntries().get(1)));
|
||||
}
|
||||
|
||||
public Date getEntryPublishedDate(Object o) {
|
||||
SyndEntry e = (SyndEntry) o;
|
||||
return e.getPublishedDate();
|
||||
}
|
||||
|
||||
public void testEntryCategories() throws Exception {
|
||||
SyndEntry e = (SyndEntry)getCachedSyndFeed().getEntries().get(0);
|
||||
List catlist = e.getCategories();
|
||||
//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", 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();
|
||||
}
|
||||
|
||||
* public void testType() throws Exception { assertEquals(getPrefix(), getCachedSyndFeed().getFeedType()); }
|
||||
*
|
||||
* public void testTitle() throws Exception { assertEqualsStr("channel.title", getCachedSyndFeed().getTitle()); }
|
||||
*
|
||||
* public void testLink() throws Exception { assertEqualsStr("channel.link", getCachedSyndFeed().getLink()); }
|
||||
*
|
||||
* public void testDescription() throws Exception { assertEqualsStr("channel.description", getCachedSyndFeed().getDescription()); }
|
||||
*
|
||||
* public void testLanguage() throws Exception { assertEqualsStr("channel.language", getCachedSyndFeed().getLanguage()); }
|
||||
*
|
||||
* 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());
|
||||
* assertEqualsStr("channel.category[0]^domain", cat.getTaxonomyUri()); cat = (SyndCategory)catlist.get(1); assertEqualsStr("channel.category[1]",
|
||||
* 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"),
|
||||
* getCachedSyndFeed().getPublishedDate()); }
|
||||
*
|
||||
* //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());
|
||||
* assertEqualsStr("channel.image.title", img.getTitle()); assertEqualsStr("channel.image.url", img.getUrl()); }
|
||||
*
|
||||
* public void testEntries() throws Exception { List entrylist = getCachedSyndFeed().getEntries(); assertEquals(2, entrylist.size()); }
|
||||
*
|
||||
* public void testEntryTitle() throws Exception { assertEqualsStr("channel.item[0].title", getEntryTitle(getCachedSyndFeed().getEntries().get(0)));
|
||||
* assertEqualsStr("channel.item[1].title", getEntryTitle(getCachedSyndFeed().getEntries().get(1))); }
|
||||
*
|
||||
* public String getEntryTitle(Object o) throws Exception { SyndEntry e = (SyndEntry) o; return e.getTitle(); }
|
||||
*
|
||||
* 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 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)));
|
||||
* assertEqualsStr("channel.item[1].link", getEntryLink(getCachedSyndFeed().getEntries().get(1))); }
|
||||
*
|
||||
* public String getEntryLink(Object o) { SyndEntry e = (SyndEntry) o; return e.getLink(); }
|
||||
*
|
||||
* public void testEntryPublishedDate() throws Exception { assertEquals(DateParser.parseRFC822("Mon, 01 Jan 2001 00:00:00 GMT"),
|
||||
* getEntryPublishedDate(getCachedSyndFeed().getEntries().get(0))); assertEquals(DateParser.parseRFC822("Mon, 01 Jan 2001 00:00:00 GMT"),
|
||||
* getEntryPublishedDate(getCachedSyndFeed().getEntries().get(1))); }
|
||||
*
|
||||
* public Date getEntryPublishedDate(Object o) { SyndEntry e = (SyndEntry) o; return e.getPublishedDate(); }
|
||||
*
|
||||
* public void testEntryCategories() throws Exception { SyndEntry e = (SyndEntry)getCachedSyndFeed().getEntries().get(0); List catlist = e.getCategories();
|
||||
* //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",
|
||||
* 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
|
||||
* //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, "");
|
||||
}
|
||||
|
||||
* 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
|
||||
* <textInput> <title>Search</title> <description>Search this site:</description> <name>q</name> <link>http://example.org/mt/mt-search.cgi</link>
|
||||
* </textInput>
|
||||
*
|
||||
//<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>
|
||||
|
||||
**/
|
||||
|
||||
* 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()
|
||||
*/
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
super.tearDown();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -9,11 +9,12 @@
|
|||
|
||||
package org.rometools.unittest;
|
||||
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.PrintWriter;
|
||||
|
||||
import com.sun.syndication.feed.WireFeed;
|
||||
import com.sun.syndication.feed.synd.SyndFeed;
|
||||
import com.sun.syndication.feed.synd.SyndFeedImpl;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.PrintWriter;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -27,10 +28,11 @@ public class TestOpsOPML10 extends FeedOpsTest{
|
|||
}
|
||||
|
||||
// 1.6
|
||||
@Override
|
||||
public void testWireFeedSyndFeedConversion() throws Exception {
|
||||
SyndFeed sFeed1 = getCachedSyndFeed();
|
||||
WireFeed wFeed1 = sFeed1.createWireFeed();
|
||||
SyndFeed sFeed2 = new SyndFeedImpl(wFeed1);
|
||||
final SyndFeed sFeed1 = getCachedSyndFeed();
|
||||
final WireFeed wFeed1 = sFeed1.createWireFeed();
|
||||
final SyndFeed sFeed2 = new SyndFeedImpl(wFeed1);
|
||||
PrintWriter w = new PrintWriter(new FileOutputStream("target/test-reports/1"));
|
||||
w.println(sFeed1.toString());
|
||||
w.close();
|
||||
|
@ -41,7 +43,4 @@ public class TestOpsOPML10 extends FeedOpsTest{
|
|||
assertEquals(sFeed1, sFeed2);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -9,14 +9,15 @@
|
|||
|
||||
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.synd.SyndFeed;
|
||||
import com.sun.syndication.feed.synd.SyndFeedImpl;
|
||||
import com.sun.syndication.io.WireFeedInput;
|
||||
import com.sun.syndication.io.WireFeedOutput;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.PrintWriter;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -30,11 +31,11 @@ public class TestOpsOPML10links extends FeedOpsTest{
|
|||
}
|
||||
|
||||
// 1.6
|
||||
@Override
|
||||
public void testWireFeedSyndFeedConversion() throws Exception {
|
||||
SyndFeed sFeed1 = getCachedSyndFeed();
|
||||
WireFeed wFeed1 = sFeed1.createWireFeed();
|
||||
//System.out.println( wFeed1 );
|
||||
SyndFeed sFeed2 = new SyndFeedImpl(wFeed1);
|
||||
final SyndFeed sFeed1 = getCachedSyndFeed();
|
||||
final WireFeed wFeed1 = sFeed1.createWireFeed();
|
||||
final SyndFeed sFeed2 = new SyndFeedImpl(wFeed1);
|
||||
PrintWriter w = new PrintWriter(new FileOutputStream("target/test-reports/1"));
|
||||
w.println(sFeed1.toString());
|
||||
w.close();
|
||||
|
@ -45,21 +46,15 @@ public class TestOpsOPML10links extends FeedOpsTest{
|
|||
assertEquals(sFeed2.createWireFeed(), sFeed1.createWireFeed());
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void testTemp() throws Exception {
|
||||
WireFeedInput input = new WireFeedInput();
|
||||
WireFeed wf = input.build( new File( System.getProperty("basedir")+ "/src/test/resources/opml_1.0_links.xml"));
|
||||
WireFeedOutput output = new WireFeedOutput();
|
||||
//System.out.println( wf );
|
||||
final WireFeedInput input = new WireFeedInput();
|
||||
final WireFeed wf = input.build(new File(System.getProperty("basedir") + "/src/test/resources/opml_1.0_links.xml"));
|
||||
final WireFeedOutput output = new WireFeedOutput();
|
||||
|
||||
//System.out.println( "=================================");
|
||||
//System.out.println( new SyndFeedImpl( wf) );
|
||||
SyndFeedImpl sf = new SyndFeedImpl( wf);
|
||||
final SyndFeedImpl sf = new SyndFeedImpl(wf);
|
||||
sf.setFeedType("rss_2.0");
|
||||
sf.setDescription("");
|
||||
sf.setLink("http://foo.com");
|
||||
//output.output( sf.createWireFeed() , new PrintWriter( System.out ) );
|
||||
sf.setFeedType("opml_1.0");
|
||||
output.output(sf.createWireFeed(), new File(System.getProperty("basedir") + "/target/test-reports/1.xml"));
|
||||
}
|
||||
|
|
|
@ -9,11 +9,12 @@
|
|||
|
||||
package org.rometools.unittest;
|
||||
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.PrintWriter;
|
||||
|
||||
import com.sun.syndication.feed.WireFeed;
|
||||
import com.sun.syndication.feed.synd.SyndFeed;
|
||||
import com.sun.syndication.feed.synd.SyndFeedImpl;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.PrintWriter;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -26,11 +27,11 @@ public class TestOpsOPML20 extends FeedOpsTest {
|
|||
super("opml_2.0");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void testWireFeedSyndFeedConversion() throws Exception {
|
||||
SyndFeed sFeed1 = getCachedSyndFeed();
|
||||
WireFeed wFeed1 = sFeed1.createWireFeed();
|
||||
SyndFeed sFeed2 = new SyndFeedImpl(wFeed1);
|
||||
final SyndFeed sFeed1 = getCachedSyndFeed();
|
||||
final WireFeed wFeed1 = sFeed1.createWireFeed();
|
||||
final SyndFeed sFeed2 = new SyndFeedImpl(wFeed1);
|
||||
PrintWriter w = new PrintWriter(new FileOutputStream("target/test-reports/3"));
|
||||
w.println(sFeed1.toString());
|
||||
w.close();
|
||||
|
|
|
@ -16,12 +16,20 @@
|
|||
*/
|
||||
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.impl.XmlFixerReader;
|
||||
import junit.framework.TestCase;
|
||||
import org.jdom.input.SAXBuilder;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
/**
|
||||
* @author pat, tucu
|
||||
|
@ -85,50 +93,47 @@ public class TestXmlFixerReader extends TestCase {
|
|||
|
||||
}
|
||||
|
||||
protected void _testXmlParse(String garbish,String xmlDoc) throws Exception {
|
||||
InputStream is = getStream(garbish,xmlDoc);
|
||||
protected void _testXmlParse(final String garbish, final String xmlDoc) throws Exception {
|
||||
final InputStream is = getStream(garbish, xmlDoc);
|
||||
Reader reader = new XmlReader(is);
|
||||
reader = new XmlFixerReader(reader);
|
||||
SAXBuilder saxBuilder = new SAXBuilder();
|
||||
final SAXBuilder saxBuilder = new SAXBuilder();
|
||||
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);
|
||||
}
|
||||
|
||||
protected void _testInvalidTrim(String garbish,String xmlDoc) throws Exception {
|
||||
protected void _testInvalidTrim(final String garbish, final String xmlDoc) throws Exception {
|
||||
try {
|
||||
_testXmlParse(garbish, xmlDoc);
|
||||
assertTrue(false);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
} catch (final Exception ex) {
|
||||
}
|
||||
}
|
||||
|
||||
protected void _testValidEntities(String xmlDoc) throws Exception {
|
||||
protected void _testValidEntities(final String xmlDoc) throws Exception {
|
||||
_testXmlParse("", xmlDoc);
|
||||
}
|
||||
|
||||
protected void _testInvalidEntities(String xmlDoc) throws Exception {
|
||||
protected void _testInvalidEntities(final String xmlDoc) throws Exception {
|
||||
try {
|
||||
_testXmlParse("", xmlDoc);
|
||||
assertTrue(false);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
} catch (final Exception ex) {
|
||||
}
|
||||
}
|
||||
|
||||
// XML Stream generator
|
||||
|
||||
protected InputStream getStream(String garbish,String xmlDoc) throws IOException {
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream(1024);
|
||||
Writer writer = new OutputStreamWriter(baos);
|
||||
protected InputStream getStream(final String garbish, final String xmlDoc) throws IOException {
|
||||
final ByteArrayOutputStream baos = new ByteArrayOutputStream(1024);
|
||||
final Writer writer = new OutputStreamWriter(baos);
|
||||
writer.write(garbish);
|
||||
writer.write(xmlDoc);
|
||||
writer.close();
|
||||
return new ByteArrayInputStream(baos.toByteArray());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -16,28 +16,34 @@
|
|||
*/
|
||||
package org.rometools.unittest;
|
||||
|
||||
import com.sun.syndication.io.XmlReader;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import java.io.*;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.io.Writer;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import com.sun.syndication.io.XmlReader;
|
||||
|
||||
/**
|
||||
* @author pat, tucu
|
||||
*
|
||||
*/
|
||||
public class TestXmlReader extends TestCase {
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
TestXmlReader test = new TestXmlReader();
|
||||
public static void main(final String[] args) throws Exception {
|
||||
final TestXmlReader test = new TestXmlReader();
|
||||
test.testRawBom();
|
||||
test.testRawNoBom();
|
||||
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);
|
||||
XmlReader xmlReader = new XmlReader(is, false);
|
||||
assertEquals(xmlReader.getEncoding(), "UTF-8");
|
||||
|
@ -51,13 +57,12 @@ public class TestXmlReader extends TestCase {
|
|||
assertEquals(xmlReader.getEncoding(), encoding);
|
||||
}
|
||||
|
||||
protected void _testRawNoBomInvalid(String encoding) throws Exception {
|
||||
InputStream is = getXmlStream("no-bom","xml-prolog-encoding",encoding,encoding);
|
||||
protected void _testRawNoBomInvalid(final String encoding) throws Exception {
|
||||
final InputStream is = getXmlStream("no-bom", "xml-prolog-encoding", encoding, encoding);
|
||||
try {
|
||||
XmlReader xmlReader = new XmlReader(is,false);
|
||||
final XmlReader xmlReader = new XmlReader(is, false);
|
||||
fail("It should have failed");
|
||||
}
|
||||
catch (IOException ex) {
|
||||
} catch (final IOException ex) {
|
||||
assertTrue(ex.getMessage().indexOf("Invalid encoding,") > -1);
|
||||
}
|
||||
}
|
||||
|
@ -68,24 +73,22 @@ public class TestXmlReader extends TestCase {
|
|||
_testRawNoBomValid("ISO-8859-1");
|
||||
}
|
||||
|
||||
protected void _testRawBomValid(String encoding) throws Exception {
|
||||
InputStream is = getXmlStream(encoding+"-bom","xml-prolog-encoding",encoding,encoding);
|
||||
XmlReader xmlReader = new XmlReader(is,false);
|
||||
protected void _testRawBomValid(final String encoding) throws Exception {
|
||||
final InputStream is = getXmlStream(encoding + "-bom", "xml-prolog-encoding", encoding, encoding);
|
||||
final XmlReader xmlReader = new XmlReader(is, false);
|
||||
if (!encoding.equals("UTF-16")) {
|
||||
assertEquals(xmlReader.getEncoding(), encoding);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
assertEquals(xmlReader.getEncoding().substring(0, encoding.length()), encoding);
|
||||
}
|
||||
}
|
||||
|
||||
protected void _testRawBomInvalid(String bomEnc,String streamEnc,String prologEnc) throws Exception {
|
||||
InputStream is = getXmlStream(bomEnc,"xml-prolog-encoding",streamEnc,prologEnc);
|
||||
protected void _testRawBomInvalid(final String bomEnc, final String streamEnc, final String prologEnc) throws Exception {
|
||||
final InputStream is = getXmlStream(bomEnc, "xml-prolog-encoding", streamEnc, prologEnc);
|
||||
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);
|
||||
}
|
||||
catch (IOException ex) {
|
||||
} catch (final IOException ex) {
|
||||
assertTrue(ex.getMessage().indexOf("Invalid encoding,") > -1);
|
||||
}
|
||||
}
|
||||
|
@ -158,31 +161,30 @@ public class TestXmlReader extends TestCase {
|
|||
_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 {
|
||||
InputStream is = getXmlStream(bomEnc,(prologEnc==null)?"xml":"xml-prolog-encoding",streamEnc,prologEnc);
|
||||
XmlReader xmlReader = new XmlReader(is,cT,false);
|
||||
public void _testHttpValid(final String cT, final String bomEnc, final String streamEnc, final String prologEnc) throws Exception {
|
||||
final InputStream is = getXmlStream(bomEnc, prologEnc == null ? "xml" : "xml-prolog-encoding", streamEnc, prologEnc);
|
||||
final XmlReader xmlReader = new XmlReader(is, cT, false);
|
||||
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
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
assertEquals(xmlReader.getEncoding().substring(0, streamEnc.length()), streamEnc);
|
||||
}
|
||||
}
|
||||
|
||||
protected void _testHttpInvalid(String cT,String bomEnc,String streamEnc,String prologEnc) throws Exception {
|
||||
InputStream is = getXmlStream(bomEnc,(prologEnc==null)?"xml-prolog":"xml-prolog-encoding",streamEnc,prologEnc);
|
||||
protected void _testHttpInvalid(final String cT, final String bomEnc, final String streamEnc, final String prologEnc) throws Exception {
|
||||
final InputStream is = getXmlStream(bomEnc, prologEnc == null ? "xml-prolog" : "xml-prolog-encoding", streamEnc, prologEnc);
|
||||
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);
|
||||
}
|
||||
catch (IOException ex) {
|
||||
} catch (final IOException ex) {
|
||||
assertTrue(ex.getMessage().indexOf("Invalid encoding,") > -1);
|
||||
}
|
||||
}
|
||||
|
||||
protected void _testHttpLenient(String cT, String bomEnc, String streamEnc, String prologEnc, String shouldbe) throws Exception {
|
||||
InputStream is = getXmlStream(bomEnc,(prologEnc==null)?"xml-prolog":"xml-prolog-encoding",streamEnc,prologEnc);
|
||||
XmlReader xmlReader = new XmlReader(is,cT,true);
|
||||
protected void _testHttpLenient(final String cT, final String bomEnc, final String streamEnc, final String prologEnc, final String shouldbe)
|
||||
throws Exception {
|
||||
final InputStream is = getXmlStream(bomEnc, prologEnc == null ? "xml-prolog" : "xml-prolog-encoding", streamEnc, prologEnc);
|
||||
final XmlReader xmlReader = new XmlReader(is, cT, true);
|
||||
assertEquals(xmlReader.getEncoding(), shouldbe);
|
||||
}
|
||||
|
||||
|
@ -203,15 +205,11 @@ public class TestXmlReader extends TestCase {
|
|||
BOMs.put("UTF-8-bom", UTF_8_BOM_BYTES);
|
||||
}
|
||||
|
||||
private static final MessageFormat XML = new MessageFormat(
|
||||
"<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_AND_ENCODING = new MessageFormat(
|
||||
"<?xml version=\"1.0\" encoding=\"{1}\"?>\n<root>{2}</root>");
|
||||
private static final MessageFormat XML = new MessageFormat("<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_AND_ENCODING = new MessageFormat("<?xml version=\"1.0\" encoding=\"{1}\"?>\n<root>{2}</root>");
|
||||
|
||||
private static final MessageFormat INFO = new MessageFormat(
|
||||
"\nBOM : {0}\nDoc : {1}\nStream Enc : {2}\nProlog Enc : {3}\n");
|
||||
private static final MessageFormat INFO = new MessageFormat("\nBOM : {0}\nDoc : {1}\nStream Enc : {2}\nProlog Enc : {3}\n");
|
||||
|
||||
private static final Map XMLs = new HashMap();
|
||||
|
||||
|
@ -227,19 +225,19 @@ public class TestXmlReader extends TestCase {
|
|||
* @param xmlType xml, xml-prolog, xml-prolog-charset
|
||||
* @return XML stream
|
||||
*/
|
||||
protected InputStream getXmlStream(String bomType,String xmlType,String streamEnc,String prologEnc) throws IOException {
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream(1024);
|
||||
protected InputStream getXmlStream(final String bomType, final String xmlType, final String streamEnc, final String prologEnc) throws IOException {
|
||||
final ByteArrayOutputStream baos = new ByteArrayOutputStream(1024);
|
||||
int[] bom = (int[]) BOMs.get(bomType);
|
||||
if (bom == null) {
|
||||
bom = new int[0];
|
||||
}
|
||||
MessageFormat xml = (MessageFormat) XMLs.get(xmlType);
|
||||
for (int i=0;i<bom.length;i++) {
|
||||
baos.write(bom[i]);
|
||||
final MessageFormat xml = (MessageFormat) XMLs.get(xmlType);
|
||||
for (final int element : bom) {
|
||||
baos.write(element);
|
||||
}
|
||||
Writer writer = new OutputStreamWriter(baos,streamEnc);
|
||||
String info = INFO.format(new Object[]{bomType,xmlType,prologEnc});
|
||||
String xmlDoc = xml.format(new Object[]{streamEnc,prologEnc,info});
|
||||
final Writer writer = new OutputStreamWriter(baos, streamEnc);
|
||||
final String info = INFO.format(new Object[] { bomType, xmlType, prologEnc });
|
||||
final String xmlDoc = xml.format(new Object[] { streamEnc, prologEnc, info });
|
||||
writer.write(xmlDoc);
|
||||
|
||||
// PADDDING TO TEST THINGS WORK BEYOND PUSHBACK_SIZE
|
||||
|
@ -253,5 +251,4 @@ public class TestXmlReader extends TestCase {
|
|||
return new ByteArrayInputStream(baos.toByteArray());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue