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"
|
||||
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>
|
||||
|
||||
<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,169 +44,137 @@
|
|||
<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>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-site-plugin</artifactId>
|
||||
<version>3.3</version>
|
||||
<configuration>
|
||||
<encoding>${project.build.sourceEncoding}</encoding>
|
||||
<port>9000</port>
|
||||
<tempWebappDirectory>${basedir}/target/site/tempdir</tempWebappDirectory>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-site-plugin</artifactId>
|
||||
<version>3.3</version>
|
||||
<configuration>
|
||||
<port>9000</port>
|
||||
<tempWebappDirectory>${basedir}/target/site/tempdir</tempWebappDirectory>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-scm-publish-plugin</artifactId>
|
||||
<version>1.0-beta-2</version>
|
||||
<configuration>
|
||||
<scmBranch>gh-pages</scmBranch>
|
||||
<pubScmUrl>scm:git:git@github.com:rometools/rome-opml.git</pubScmUrl>
|
||||
<content>${project.build.directory}/site</content>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-scm-publish-plugin</artifactId>
|
||||
<version>1.0-beta-2</version>
|
||||
<configuration>
|
||||
<scmBranch>gh-pages</scmBranch>
|
||||
<pubScmUrl>scm:git:git@github.com:rometools/rome-opml.git</pubScmUrl>
|
||||
<content>${project.build.directory}/site</content>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-source-plugin</artifactId>
|
||||
<version>2.2.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-sources</id>
|
||||
<goals>
|
||||
<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>
|
||||
</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>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-sources</id>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
</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>
|
||||
|
||||
<reporting>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-project-info-reports-plugin</artifactId>
|
||||
<version>2.7</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<version>2.9.1</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>
|
||||
|
||||
<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() {
|
||||
|
@ -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.
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
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.
|
||||
* @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;
|
||||
}
|
||||
|
||||
/**
|
||||
* <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.
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
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,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.
|
||||
* @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.
|
||||
* <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() {
|
||||
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.
|
||||
*
|
||||
* @param windowBottom the pixel location of the bottom edge of the window.
|
||||
*/
|
||||
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.
|
||||
* @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() {
|
||||
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.
|
||||
*
|
||||
* @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,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.
|
||||
* @return whether a breakpoint is set on this outline
|
||||
* 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() {
|
||||
return _breakpoint;
|
||||
|
@ -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,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.
|
||||
* @return whether the outline is commented
|
||||
* 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() {
|
||||
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.
|
||||
*
|
||||
* @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,14 +211,16 @@ 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() {
|
||||
return getAttributeValue("url");
|
||||
return getAttributeValue("url");
|
||||
}
|
||||
|
||||
/**
|
||||
* 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,16 +295,19 @@ public class Outline implements Cloneable, Serializable {
|
|||
|
||||
/**
|
||||
* 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() {
|
||||
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.
|
||||
*/
|
||||
public String getAttributeValue(String name ){
|
||||
public String getAttributeValue(String name) {
|
||||
List attributes = Collections.synchronizedList(this.getAttributes());
|
||||
|
||||
for (int i = 0; i < attributes.size(); i++) {
|
||||
|
@ -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#";
|
||||
|
||||
|
@ -58,7 +56,7 @@ public class ConverterForOPML10 implements Converter {
|
|||
}
|
||||
|
||||
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();
|
||||
SyndPerson person = new SyndPersonImpl();
|
||||
person.setEmail(opml.getOwnerEmail());
|
||||
|
@ -77,43 +75,38 @@ 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++) {
|
||||
for (int i = 0; i < so.size(); i++) {
|
||||
createEntry(context, allEntries, (Outline) so.get(i));
|
||||
}
|
||||
}
|
||||
|
||||
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")) {
|
||||
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.getUrl());
|
||||
}
|
||||
|
||||
if(outline.getHtmlUrl() != null) {
|
||||
if (outline.getHtmlUrl() != null) {
|
||||
SyndLink link = new SyndLinkImpl();
|
||||
link.setRel("alternate");
|
||||
link.setType("text/html");
|
||||
|
@ -122,39 +115,37 @@ 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");
|
||||
link.setHref(outline.getXmlUrl());
|
||||
entry.getLinks().add(link);
|
||||
|
||||
if(entry.getLink() == null) {
|
||||
if (entry.getLink() == null) {
|
||||
entry.setLink(outline.getXmlUrl());
|
||||
}
|
||||
}
|
||||
|
||||
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");
|
||||
link.setHref(outline.getXmlUrl());
|
||||
entry.getLinks().add(link);
|
||||
|
||||
if(entry.getLink() == null) {
|
||||
if (entry.getLink() == null) {
|
||||
entry.setLink(outline.getXmlUrl());
|
||||
}
|
||||
}
|
||||
|
||||
if((outline.getType() != null) && outline.getType().equals("rss")) {
|
||||
if ((outline.getType() != null) && outline.getType().equals("rss")) {
|
||||
entry.setTitle(outline.getTitle());
|
||||
} else {
|
||||
entry.setTitle(outline.getText());
|
||||
}
|
||||
|
||||
if((outline.getText() == null) && (entry.getTitle() != null)) {
|
||||
if ((outline.getText() == null) && (entry.getTitle() != null)) {
|
||||
SyndContent c = new SyndContentImpl();
|
||||
c.setValue(outline.getText());
|
||||
entry.setDescription(c);
|
||||
|
@ -169,7 +160,7 @@ public class ConverterForOPML10 implements Converter {
|
|||
cat.setName(nodeName);
|
||||
entry.getCategories().add(cat);
|
||||
|
||||
if(context.size() > 0) {
|
||||
if (context.size() > 0) {
|
||||
Integer parent = (Integer) context.peek();
|
||||
SyndCategory pcat = new TreeCategoryImpl();
|
||||
pcat.setTaxonomyUri(URI_TREE);
|
||||
|
@ -179,7 +170,7 @@ public class ConverterForOPML10 implements Converter {
|
|||
|
||||
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);
|
||||
SyndCategory acat = new SyndCategoryImpl();
|
||||
acat.setName(a.getValue());
|
||||
|
@ -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());
|
||||
|
||||
|
@ -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 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);
|
||||
Outline o = new Outline();
|
||||
|
||||
|
@ -219,36 +211,30 @@ public class ConverterForOPML10 implements Converter {
|
|||
boolean parentFound = false;
|
||||
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);
|
||||
|
||||
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.")) {
|
||||
if (cat.getName().startsWith("node.")) {
|
||||
entriesByNode.put(nodeVal, o);
|
||||
} else if(cat.getName().startsWith("parent.")) {
|
||||
} else if (cat.getName().startsWith("parent.")) {
|
||||
parentFound = true;
|
||||
|
||||
Outline parent = (Outline) entriesByNode.get(nodeVal);
|
||||
|
||||
if(parent != null) {
|
||||
if (parent != null) {
|
||||
parent.getChildren().add(o);
|
||||
} else {
|
||||
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) {
|
||||
if (category.length() > 0) {
|
||||
category.append(", ");
|
||||
}
|
||||
|
||||
|
@ -256,64 +242,57 @@ public class ConverterForOPML10 implements Converter {
|
|||
}
|
||||
}
|
||||
|
||||
if(!parentFound) {
|
||||
if (!parentFound) {
|
||||
root.add(o);
|
||||
}
|
||||
|
||||
if(category.length() > 0) {
|
||||
o.getAttributes()
|
||||
.add(new Attribute("category", category.toString()));
|
||||
if (category.length() > 0) {
|
||||
o.getAttributes().add(new Attribute("category", category.toString()));
|
||||
}
|
||||
|
||||
List links = Collections.synchronizedList(entry.getLinks());
|
||||
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);
|
||||
|
||||
//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.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"))) {
|
||||
o.setType("rss");
|
||||
|
||||
if(o.getXmlUrl() == null) {
|
||||
o.getAttributes()
|
||||
.add(new Attribute("xmlUrl", link.getHref()));
|
||||
if (o.getXmlUrl() == null) {
|
||||
o.getAttributes().add(new Attribute("xmlUrl", link.getHref()));
|
||||
}
|
||||
} else if((link.getType() != null) &&
|
||||
(link.getType().equals("text/html"))) {
|
||||
if(o.getHtmlUrl() == null) {
|
||||
o.getAttributes()
|
||||
.add(new Attribute("htmlUrl", link.getHref()));
|
||||
} else if ((link.getType() != null) && (link.getType().equals("text/html"))) {
|
||||
if (o.getHtmlUrl() == null) {
|
||||
o.getAttributes().add(new Attribute("htmlUrl", link.getHref()));
|
||||
}
|
||||
} else {
|
||||
o.setType(link.getType());
|
||||
}
|
||||
|
||||
//}
|
||||
// }
|
||||
}
|
||||
|
||||
if((o.getType() == null) || o.getType().equals("link")) {
|
||||
if ((o.getType() == null) || o.getType().equals("link")) {
|
||||
o.setText(entry.getTitle());
|
||||
|
||||
|
||||
} else {
|
||||
o.setTitle(entry.getTitle());
|
||||
}
|
||||
|
||||
if((o.getText() == null) && (entry.getDescription() != null)) {
|
||||
if ((o.getText() == null) && (entry.getDescription() != null)) {
|
||||
o.setText(entry.getDescription().getValue());
|
||||
}
|
||||
}
|
||||
|
||||
// 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);
|
||||
Outline parent = (Outline) entriesByNode.get(o.parent);
|
||||
|
||||
if(parent == null) {
|
||||
if (parent == null) {
|
||||
root.add(o.outline);
|
||||
LOG.warning("Unable to find parent node :" + o.parent);
|
||||
} else {
|
||||
|
@ -328,11 +307,10 @@ public class ConverterForOPML10 implements Converter {
|
|||
|
||||
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);
|
||||
|
||||
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());
|
||||
|
@ -350,8 +328,9 @@ public class ConverterForOPML10 implements Converter {
|
|||
*
|
||||
* @return the real feed type.
|
||||
* @see WireFeed for details on the format of this string.
|
||||
* <p>
|
||||
* <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
|
||||
|
@ -28,8 +27,9 @@ public class ConverterForOPML20 extends ConverterForOPML10 {
|
|||
*
|
||||
* @return the real feed type.
|
||||
* @see WireFeed for details on the format of this string.
|
||||
* <p>
|
||||
* <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,9 +23,10 @@ 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() ) )
|
||||
if (c.getTaxonomyUri() != null && c.getTaxonomyUri().equals(this.getTaxonomyUri()))
|
||||
return true;
|
||||
else
|
||||
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.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,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.
|
||||
* @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("1.0"))) {
|
||||
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;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -33,8 +32,9 @@ public class OPML20Generator extends OPML10Generator {
|
|||
*
|
||||
* @return the type of feed the generator creates.
|
||||
* @see WireFeed for details on the format of this string.
|
||||
* <p>
|
||||
* <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) {
|
||||
super(feedType+".xml");
|
||||
System.out.println("Testing "+feedType+".xml");
|
||||
protected FeedOpsTest(final String feedType) {
|
||||
super(feedType + ".xml");
|
||||
new File("target/test-reports").mkdirs();
|
||||
}
|
||||
|
||||
//1.2a
|
||||
// 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
|
||||
// 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
|
||||
// 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 );
|
||||
assertEquals(sFeed1, sFeed2);
|
||||
}
|
||||
|
||||
//1.7a
|
||||
// 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
|
||||
// 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
|
||||
// 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
|
||||
// 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 Document _jDomDoc = null;
|
||||
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,43 +33,42 @@ public abstract class FeedTest extends TestCase {
|
|||
}
|
||||
|
||||
protected Reader getFeedReader() throws Exception {
|
||||
InputStream resource = Thread.currentThread().
|
||||
getContextClassLoader().getResourceAsStream(getFeedFileName());
|
||||
assertNotNull("Could not find resource " + getFeedFileName(), resource);
|
||||
return new InputStreamReader(resource);
|
||||
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());
|
||||
}
|
||||
|
||||
protected Document getCachedJDomDoc() throws Exception {
|
||||
if (_jDomDoc==null) {
|
||||
if (_jDomDoc == null) {
|
||||
_jDomDoc = getJDomDoc();
|
||||
}
|
||||
return _jDomDoc;
|
||||
}
|
||||
|
||||
protected WireFeed getCachedWireFeed() throws Exception {
|
||||
if (_wireFeed==null) {
|
||||
if (_wireFeed == null) {
|
||||
_wireFeed = getWireFeed();
|
||||
}
|
||||
return _wireFeed;
|
||||
}
|
||||
|
||||
protected SyndFeed getCachedSyndFeed() throws Exception {
|
||||
if (_syndFeed==null) {
|
||||
if (_syndFeed == null) {
|
||||
_syndFeed = getSyndFeed();
|
||||
}
|
||||
return _syndFeed;
|
||||
|
|
|
@ -6,21 +6,18 @@
|
|||
*/
|
||||
package org.rometools.unittest;
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @author pat
|
||||
*
|
||||
*/
|
||||
public abstract class SyndFeedTest extends FeedTest {
|
||||
private String _prefix = null;
|
||||
private String _prefix = null;
|
||||
|
||||
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);
|
||||
_prefix = feedType;
|
||||
}
|
||||
|
@ -29,239 +26,117 @@ public abstract class SyndFeedTest extends FeedTest {
|
|||
return _prefix;
|
||||
}
|
||||
|
||||
protected void assertProperty(String property, String value) {
|
||||
assertEquals(property,getPrefix() + "." + value);
|
||||
}
|
||||
|
||||
public void testType() throws Exception {
|
||||
assertEquals(getCachedSyndFeed().getFeedType(),getPrefix());
|
||||
protected void assertProperty(String property, String value) {
|
||||
assertEquals(property, getPrefix() + "." + value);
|
||||
}
|
||||
|
||||
public void testType() throws Exception {
|
||||
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();
|
||||
}
|
||||
|
||||
*/
|
||||
/*
|
||||
//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();
|
||||
}
|
||||
|
||||
/*
|
||||
* 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
|
||||
*/
|
||||
/*
|
||||
* 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()
|
||||
*/
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
super.tearDown();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -9,17 +9,18 @@
|
|||
|
||||
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;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author cooper
|
||||
*/
|
||||
public class TestOpsOPML10 extends FeedOpsTest{
|
||||
public class TestOpsOPML10 extends FeedOpsTest {
|
||||
|
||||
/** Creates a new instance of TestOpsOPML10 */
|
||||
public TestOpsOPML10() {
|
||||
|
@ -27,21 +28,19 @@ 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);
|
||||
PrintWriter w = new PrintWriter( new FileOutputStream( "target/test-reports/1") );
|
||||
w.println( sFeed1.toString() );
|
||||
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();
|
||||
w = new PrintWriter( new FileOutputStream( "target/test-reports/2") );
|
||||
w.println( sFeed2.toString() );
|
||||
w = new PrintWriter(new FileOutputStream("target/test-reports/2"));
|
||||
w.println(sFeed2.toString());
|
||||
w.close();
|
||||
|
||||
assertEquals(sFeed1, sFeed2);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -9,20 +9,21 @@
|
|||
|
||||
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;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author cooper
|
||||
*/
|
||||
public class TestOpsOPML10links extends FeedOpsTest{
|
||||
public class TestOpsOPML10links extends FeedOpsTest {
|
||||
|
||||
/** Creates a new instance of TestOpsOPML10 */
|
||||
public TestOpsOPML10links() {
|
||||
|
@ -30,38 +31,32 @@ 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);
|
||||
PrintWriter w = new PrintWriter( new FileOutputStream( "target/test-reports/1") );
|
||||
w.println( sFeed1.toString() );
|
||||
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();
|
||||
w = new PrintWriter( new FileOutputStream( "target/test-reports/2") );
|
||||
w.println( sFeed2.toString() );
|
||||
w = new PrintWriter(new FileOutputStream("target/test-reports/2"));
|
||||
w.println(sFeed2.toString());
|
||||
w.close();
|
||||
|
||||
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") );
|
||||
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,18 +27,18 @@ 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);
|
||||
PrintWriter w = new PrintWriter( new FileOutputStream( "target/test-reports/3") );
|
||||
w.println( sFeed1.toString() );
|
||||
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();
|
||||
w = new PrintWriter( new FileOutputStream( "target/test-reports/4") );
|
||||
w.println( sFeed2.toString() );
|
||||
w = new PrintWriter(new FileOutputStream("target/test-reports/4"));
|
||||
w.println(sFeed2.toString());
|
||||
w.close();
|
||||
assertEquals(sFeed1, sFeed2 );
|
||||
assertEquals(sFeed1, sFeed2);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
@ -31,104 +39,101 @@ public class TestXmlFixerReader extends TestCase {
|
|||
private static final String XML_PROLOG = "<?xml version=\"1.0\" ?>";
|
||||
|
||||
public void testTrim() throws Exception {
|
||||
_testValidTrim("","<hello></hello>");
|
||||
_testValidTrim("",XML_PROLOG+"<hello></hello>");
|
||||
_testValidTrim(" ","<hello></hello>");
|
||||
_testValidTrim(" ",XML_PROLOG+"<hello></hello>");
|
||||
_testValidTrim(" \n","<hello></hello>");
|
||||
_testValidTrim(" \n",XML_PROLOG+"<hello></hello>");
|
||||
_testValidTrim("<!-- - -- -->","<hello></hello>");
|
||||
_testValidTrim("<!-- - -- -->",XML_PROLOG+"<hello></hello>");
|
||||
_testValidTrim(" <!-- - -- -->","<hello></hello>");
|
||||
_testValidTrim(" <!-- - -- -->",XML_PROLOG+"<hello></hello>");
|
||||
_testValidTrim(" <!-- - -- --> ","<hello></hello>");
|
||||
_testValidTrim(" <!-- - -- --> ",XML_PROLOG+"<hello></hello>");
|
||||
_testValidTrim(" <!-- - -- --> <!-- - -- --> ","<hello></hello>");
|
||||
_testValidTrim(" <!-- - -- --> <!-- - -- --> ",XML_PROLOG+"<hello></hello>");
|
||||
_testValidTrim(" <!-- - -- --> \n <!-- - -- --> ","<hello></hello>");
|
||||
_testValidTrim(" <!-- - -- --> \n <!-- - -- --> ",XML_PROLOG+"<hello></hello>");
|
||||
_testValidTrim("", "<hello></hello>");
|
||||
_testValidTrim("", XML_PROLOG + "<hello></hello>");
|
||||
_testValidTrim(" ", "<hello></hello>");
|
||||
_testValidTrim(" ", XML_PROLOG + "<hello></hello>");
|
||||
_testValidTrim(" \n", "<hello></hello>");
|
||||
_testValidTrim(" \n", XML_PROLOG + "<hello></hello>");
|
||||
_testValidTrim("<!-- - -- -->", "<hello></hello>");
|
||||
_testValidTrim("<!-- - -- -->", XML_PROLOG + "<hello></hello>");
|
||||
_testValidTrim(" <!-- - -- -->", "<hello></hello>");
|
||||
_testValidTrim(" <!-- - -- -->", XML_PROLOG + "<hello></hello>");
|
||||
_testValidTrim(" <!-- - -- --> ", "<hello></hello>");
|
||||
_testValidTrim(" <!-- - -- --> ", XML_PROLOG + "<hello></hello>");
|
||||
_testValidTrim(" <!-- - -- --> <!-- - -- --> ", "<hello></hello>");
|
||||
_testValidTrim(" <!-- - -- --> <!-- - -- --> ", XML_PROLOG + "<hello></hello>");
|
||||
_testValidTrim(" <!-- - -- --> \n <!-- - -- --> ", "<hello></hello>");
|
||||
_testValidTrim(" <!-- - -- --> \n <!-- - -- --> ", XML_PROLOG + "<hello></hello>");
|
||||
|
||||
_testInvalidTrim("x","<hello></hello>");
|
||||
_testInvalidTrim("x",XML_PROLOG+"<hello></hello>");
|
||||
_testInvalidTrim(" x","<hello></hello>");
|
||||
_testInvalidTrim(" x",XML_PROLOG+"<hello></hello>");
|
||||
_testInvalidTrim(" x\n","<hello></hello>");
|
||||
_testInvalidTrim(" x\n",XML_PROLOG+"<hello></hello>");
|
||||
_testInvalidTrim("<!-- - -- - ->","<hello></hello>");
|
||||
_testInvalidTrim("<!-- - -- - ->",XML_PROLOG+"<hello></hello>");
|
||||
_testInvalidTrim(" <!-- - -- -- >","<hello></hello>");
|
||||
_testInvalidTrim(" <!-- - -- -- >",XML_PROLOG+"<hello></hello>");
|
||||
_testInvalidTrim(" <!-- - -- -->x ","<hello></hello>");
|
||||
_testInvalidTrim(" <!-- - -- -->x ",XML_PROLOG+"<hello></hello>");
|
||||
_testInvalidTrim(" <!-- - -- --> x <!-- - -- --> ","<hello></hello>");
|
||||
_testInvalidTrim(" <!-- - -- --> x <!-- - -- --> ",XML_PROLOG+"<hello></hello>");
|
||||
_testInvalidTrim(" <!-- - -- --> x\n <!-- - -- --> ","<hello></hello>");
|
||||
_testInvalidTrim(" <!-- - -- --> x\n <!-- - -- --> ",XML_PROLOG+"<hello></hello>");
|
||||
_testInvalidTrim("x", "<hello></hello>");
|
||||
_testInvalidTrim("x", XML_PROLOG + "<hello></hello>");
|
||||
_testInvalidTrim(" x", "<hello></hello>");
|
||||
_testInvalidTrim(" x", XML_PROLOG + "<hello></hello>");
|
||||
_testInvalidTrim(" x\n", "<hello></hello>");
|
||||
_testInvalidTrim(" x\n", XML_PROLOG + "<hello></hello>");
|
||||
_testInvalidTrim("<!-- - -- - ->", "<hello></hello>");
|
||||
_testInvalidTrim("<!-- - -- - ->", XML_PROLOG + "<hello></hello>");
|
||||
_testInvalidTrim(" <!-- - -- -- >", "<hello></hello>");
|
||||
_testInvalidTrim(" <!-- - -- -- >", XML_PROLOG + "<hello></hello>");
|
||||
_testInvalidTrim(" <!-- - -- -->x ", "<hello></hello>");
|
||||
_testInvalidTrim(" <!-- - -- -->x ", XML_PROLOG + "<hello></hello>");
|
||||
_testInvalidTrim(" <!-- - -- --> x <!-- - -- --> ", "<hello></hello>");
|
||||
_testInvalidTrim(" <!-- - -- --> x <!-- - -- --> ", XML_PROLOG + "<hello></hello>");
|
||||
_testInvalidTrim(" <!-- - -- --> x\n <!-- - -- --> ", "<hello></hello>");
|
||||
_testInvalidTrim(" <!-- - -- --> x\n <!-- - -- --> ", XML_PROLOG + "<hello></hello>");
|
||||
}
|
||||
|
||||
public void testHtmlEntities() throws Exception {
|
||||
_testValidEntities("<hello></hello>");
|
||||
_testValidEntities(XML_PROLOG+"<hello></hello>");
|
||||
_testValidEntities(" <!-- just in case -->\n"+XML_PROLOG+"<hello></hello>");
|
||||
_testValidEntities(XML_PROLOG + "<hello></hello>");
|
||||
_testValidEntities(" <!-- just in case -->\n" + XML_PROLOG + "<hello></hello>");
|
||||
|
||||
_testValidEntities("<hello>'¥ú¥</hello>");
|
||||
_testValidEntities(XML_PROLOG+"<hello>'¥ú¥</hello>");
|
||||
_testValidEntities(" <!-- just in case -->\n"+XML_PROLOG+"<hello>'¥ú¥</hello>");
|
||||
_testValidEntities(XML_PROLOG + "<hello>'¥ú¥</hello>");
|
||||
_testValidEntities(" <!-- just in case -->\n" + XML_PROLOG + "<hello>'¥ú¥</hello>");
|
||||
|
||||
_testInvalidEntities("<hello>'&yexn;ú¥</hello>");
|
||||
_testInvalidEntities(XML_PROLOG+"<hello>'&yexn;ú¥</hello>");
|
||||
_testInvalidEntities(" <!-- just in case -->\n"+XML_PROLOG+"<hello>'&yexn;ú¥</hello>");
|
||||
_testInvalidEntities(XML_PROLOG + "<hello>'&yexn;ú¥</hello>");
|
||||
_testInvalidEntities(" <!-- just in case -->\n" + XML_PROLOG + "<hello>'&yexn;ú¥</hello>");
|
||||
|
||||
_testInvalidEntities("<hello>'¥x50;¥</hello>");
|
||||
_testInvalidEntities(XML_PROLOG+"<hello>'¥x50;¥</hello>");
|
||||
_testInvalidEntities(" <!-- just in case -->\n"+XML_PROLOG+"<hello>'¥x50;¥</hello>");
|
||||
_testInvalidEntities(XML_PROLOG + "<hello>'¥x50;¥</hello>");
|
||||
_testInvalidEntities(" <!-- just in case -->\n" + XML_PROLOG + "<hello>'¥x50;¥</hello>");
|
||||
|
||||
}
|
||||
|
||||
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 {
|
||||
_testXmlParse(garbish,xmlDoc);
|
||||
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);
|
||||
_testXmlParse(garbish, xmlDoc);
|
||||
assertTrue(false);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
} catch (final Exception ex) {
|
||||
}
|
||||
}
|
||||
|
||||
protected void _testValidEntities(String xmlDoc) throws Exception {
|
||||
_testXmlParse("",xmlDoc);
|
||||
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);
|
||||
_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,51 +16,56 @@
|
|||
*/
|
||||
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 {
|
||||
InputStream is = getXmlStream("no-bom","xml",encoding,encoding);
|
||||
XmlReader xmlReader = new XmlReader(is,false);
|
||||
assertEquals(xmlReader.getEncoding(),"UTF-8");
|
||||
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");
|
||||
|
||||
is = getXmlStream("no-bom","xml-prolog",encoding,encoding);
|
||||
is = getXmlStream("no-bom", "xml-prolog", encoding, encoding);
|
||||
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);
|
||||
assertEquals(xmlReader.getEncoding(),encoding);
|
||||
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 (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 {
|
||||
_testRawNoBomValid("US-ASCII");
|
||||
|
@ -68,27 +73,25 @@ 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 {
|
||||
assertEquals(xmlReader.getEncoding().substring(0,encoding.length()),encoding);
|
||||
assertEquals(xmlReader.getEncoding(), encoding);
|
||||
} 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);
|
||||
fail("It should have failed for BOM "+bomEnc+", streamEnc "+streamEnc+" and prologEnc "+prologEnc);
|
||||
final XmlReader xmlReader = new XmlReader(is, false);
|
||||
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 {
|
||||
_testRawBomValid("UTF-8");
|
||||
|
@ -96,129 +99,124 @@ public class TestXmlReader extends TestCase {
|
|||
_testRawBomValid("UTF-16LE");
|
||||
_testRawBomValid("UTF-16");
|
||||
|
||||
_testRawBomInvalid("UTF-8-bom","US-ASCII","US-ASCII");
|
||||
_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-16BE");
|
||||
_testRawBomInvalid("UTF-8-bom","UTF-8","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-8");
|
||||
_testRawBomInvalid("UTF-8-bom", "US-ASCII", "US-ASCII");
|
||||
_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-16BE");
|
||||
_testRawBomInvalid("UTF-8-bom", "UTF-8", "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-8");
|
||||
}
|
||||
|
||||
public void testHttp() throws Exception {
|
||||
_testHttpValid("application/xml","no-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","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","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","UTF-16");
|
||||
_testHttpValid("application/xml;charset=UTF-16","UTF-16BE-bom","UTF-16BE","UTF-16BE");
|
||||
_testHttpValid("application/xml", "no-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", "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", "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", "UTF-16");
|
||||
_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","UTF-16");
|
||||
_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;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-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-16BE");
|
||||
_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", "no-bom", "UTF-16BE", "UTF-16BE");
|
||||
|
||||
_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",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-16BE");
|
||||
_testHttpValid("text/xml","UTF-8-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", 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-16BE");
|
||||
_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","UTF-16");
|
||||
_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",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-16BE");
|
||||
_testHttpInvalid("text/xml;charset=UTF-16", "no-bom", "UTF-16BE", "UTF-16BE");
|
||||
_testHttpInvalid("text/xml;charset=UTF-16", "no-bom", "UTF-16BE", null);
|
||||
|
||||
_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",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","UTF-16", "UTF-16");
|
||||
_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", "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", 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", "UTF-16", "UTF-16");
|
||||
_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;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-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-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-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/html","no-bom","US-ASCII","US-ASCII", "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-16BE","no-bom","US-ASCII","UTF-8", "UTF-8");
|
||||
_testHttpLenient("text/html", "no-bom", "US-ASCII", "US-ASCII", "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-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 {
|
||||
assertEquals(xmlReader.getEncoding().substring(0,streamEnc.length()),streamEnc);
|
||||
} 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);
|
||||
fail("It should have failed for HTTP Content-type "+cT+", BOM "+bomEnc+", streamEnc "+streamEnc+" and prologEnc "+prologEnc);
|
||||
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 (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 {
|
||||
InputStream is = getXmlStream(bomEnc,(prologEnc==null)?"xml-prolog":"xml-prolog-encoding",streamEnc,prologEnc);
|
||||
XmlReader xmlReader = new XmlReader(is,cT,true);
|
||||
assertEquals(xmlReader.getEncoding(),shouldbe);
|
||||
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);
|
||||
}
|
||||
|
||||
// XML Stream generator
|
||||
|
||||
private static final int[] NO_BOM_BYTES = {};
|
||||
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_8_BOM_BYTES = {0xEF,0xBB,0xBF};
|
||||
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_8_BOM_BYTES = { 0xEF, 0xBB, 0xBF };
|
||||
|
||||
private static final Map BOMs = new HashMap();
|
||||
|
||||
static {
|
||||
BOMs.put("no-bom",NO_BOM_BYTES);
|
||||
BOMs.put("UTF-16BE-bom",UTF_16BE_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-8-bom",UTF_8_BOM_BYTES);
|
||||
BOMs.put("no-bom", NO_BOM_BYTES);
|
||||
BOMs.put("UTF-16BE-bom", UTF_16BE_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-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();
|
||||
|
||||
static {
|
||||
XMLs.put("xml",XML);
|
||||
XMLs.put("xml-prolog",XML_WITH_PROLOG);
|
||||
XMLs.put("xml-prolog-encoding",XML_WITH_PROLOG_AND_ENCODING);
|
||||
XMLs.put("xml", XML);
|
||||
XMLs.put("xml-prolog", XML_WITH_PROLOG);
|
||||
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
|
||||
* @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) {
|
||||
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
|
||||
writer.write("<da>\n");
|
||||
for (int i=0;i<10000;i++) {
|
||||
for (int i = 0; i < 10000; i++) {
|
||||
writer.write("<do/>\n");
|
||||
}
|
||||
writer.write("</da>\n");
|
||||
|
@ -253,5 +251,4 @@ public class TestXmlReader extends TestCase {
|
|||
return new ByteArrayInputStream(baos.toByteArray());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue