DNA SVN: r378 - in trunk/docs: reference and 2 other directories.
by dna-commits@lists.jboss.org
Author: rhauch
Date: 2008-08-05 14:09:39 -0400 (Tue, 05 Aug 2008)
New Revision: 378
Added:
trunk/docs/reference/
trunk/docs/reference/.project
trunk/docs/reference/en/
trunk/docs/reference/en/Author_Group.xml
trunk/docs/reference/en/Legal_Notice.xml
trunk/docs/reference/en/images/
trunk/docs/reference/en/images/dna-logo.png
trunk/docs/reference/en/master.xml
trunk/docs/reference/pom.xml
Modified:
trunk/docs/pom.xml
Log:
Added Reference Guide project and initial content (i.e., outline) for the document
Modified: trunk/docs/pom.xml
===================================================================
--- trunk/docs/pom.xml 2008-08-04 19:59:20 UTC (rev 377)
+++ trunk/docs/pom.xml 2008-08-05 18:09:39 UTC (rev 378)
@@ -13,5 +13,6 @@
<description>JBoss DNA Documentation</description>
<modules>
<module>gettingstarted</module>
+ <module>reference</module>
</modules>
</project>
\ No newline at end of file
Property changes on: trunk/docs/reference
___________________________________________________________________
Name: svn:ignore
+ target
Added: trunk/docs/reference/.project
===================================================================
--- trunk/docs/reference/.project (rev 0)
+++ trunk/docs/reference/.project 2008-08-05 18:09:39 UTC (rev 378)
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>docs-reference-guide</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ </buildSpec>
+ <natures>
+ </natures>
+</projectDescription>
Added: trunk/docs/reference/en/Author_Group.xml
===================================================================
--- trunk/docs/reference/en/Author_Group.xml (rev 0)
+++ trunk/docs/reference/en/Author_Group.xml 2008-08-05 18:09:39 UTC (rev 378)
@@ -0,0 +1,28 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!--
+ ~ JBoss, Home of Professional Open Source.
+ ~
+ ~ Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ ~ indicated by the @author tags or express copyright attribution
+ ~ statements applied by the authors. All third-party contributions are
+ ~ distributed under license by Red Hat Middleware LLC.
+ ~
+ ~ This copyrighted material is made available to anyone wishing to use, modify,
+ ~ copy, or redistribute it subject to the terms and conditions of the GNU
+ ~ Lesser General Public License, as published by the Free Software Foundation.
+ ~
+ ~ This program is distributed in the hope that it will be useful,
+ ~ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ ~ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ ~ for more details.
+ ~
+ ~ You should have received a copy of the GNU Lesser General Public License
+ ~ along with this distribution; if not, write to:
+ ~ Free Software Foundation, Inc.
+ ~ 51 Franklin Street, Fifth Floor
+ ~ Boston, MA 02110-1301 USA
+ -->
+<!DOCTYPE authorgroup PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
+<authorgroup>
+ <corpauthor>Randall Hauch</corpauthor>
+</authorgroup>
\ No newline at end of file
Added: trunk/docs/reference/en/Legal_Notice.xml
===================================================================
--- trunk/docs/reference/en/Legal_Notice.xml (rev 0)
+++ trunk/docs/reference/en/Legal_Notice.xml 2008-08-05 18:09:39 UTC (rev 378)
@@ -0,0 +1,56 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!--
+ ~ JBoss, Home of Professional Open Source.
+ ~
+ ~ Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ ~ indicated by the @author tags or express copyright attribution
+ ~ statements applied by the authors. All third-party contributions are
+ ~ distributed under license by Red Hat Middleware LLC.
+ ~
+ ~ This copyrighted material is made available to anyone wishing to use, modify,
+ ~ copy, or redistribute it subject to the terms and conditions of the GNU
+ ~ Lesser General Public License, as published by the Free Software Foundation.
+ ~
+ ~ This program is distributed in the hope that it will be useful,
+ ~ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ ~ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ ~ for more details.
+ ~
+ ~ You should have received a copy of the GNU Lesser General Public License
+ ~ along with this distribution; if not, write to:
+ ~ Free Software Foundation, Inc.
+ ~ 51 Franklin Street, Fifth Floor
+ ~ Boston, MA 02110-1301 USA
+ -->
+<!DOCTYPE legalnotice PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
+<legalnotice id="Legal_Notice">
+ <title>Legal Notice</title>
+ <para>
+ <address>
+ <street>1801 Varsity Drive</street>
+ <city>Raleigh</city>, <state>NC</state><postcode>27606-2072</postcode><country>USA</country>
+ <phone>Phone: +1 919 754 3700</phone>
+ <phone>Phone: 888 733 4281</phone>
+ <fax>Fax: +1 919 754 3701</fax>
+ <pob>PO Box 13588</pob><city>Research Triangle Park</city>, <state>NC</state><postcode>27709</postcode><country>USA</country>
+ </address>
+ </para>
+ <para>
+ Copyright <trademark class="copyright"/> 2008 by Red Hat, Inc. This copyrighted material is made available to
+ anyone wishing to use, modify, copy, or redistribute it subject to the terms and conditions of the
+ GNU <ulink url="http://www.gnu.org/licenses/lgpl-2.1.html">Lesser General Public License</ulink>, as published
+ by the Free Software Foundation.
+ </para>
+ <para>
+ Red Hat and the Red Hat "Shadow Man" logo are registered trademarks of Red Hat, Inc. in the United States and other countries.
+ </para>
+ <para>
+ All other trademarks referenced herein are the property of their respective owners.
+ </para>
+ <para>
+ The GPG fingerprint of the security(a)redhat.com key is:
+ </para>
+ <para>
+ CA 20 86 86 2B D6 9D FC 65 F6 EC C4 21 91 80 CD DB 42 A6 0E
+ </para>
+</legalnotice>
Added: trunk/docs/reference/en/images/dna-logo.png
===================================================================
(Binary files differ)
Property changes on: trunk/docs/reference/en/images/dna-logo.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/docs/reference/en/master.xml
===================================================================
--- trunk/docs/reference/en/master.xml (rev 0)
+++ trunk/docs/reference/en/master.xml 2008-08-05 18:09:39 UTC (rev 378)
@@ -0,0 +1,553 @@
+<!--
+ ~ JBoss, Home of Professional Open Source.
+ ~
+ ~ Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ ~ indicated by the @author tags or express copyright attribution
+ ~ statements applied by the authors. All third-party contributions are
+ ~ distributed under license by Red Hat Middleware LLC.
+ ~
+ ~ This copyrighted material is made available to anyone wishing to use, modify,
+ ~ copy, or redistribute it subject to the terms and conditions of the GNU
+ ~ Lesser General Public License, as published by the Free Software Foundation.
+ ~
+ ~ This program is distributed in the hope that it will be useful,
+ ~ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ ~ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ ~ for more details.
+ ~
+ ~ You should have received a copy of the GNU Lesser General Public License
+ ~ along with this distribution; if not, write to:
+ ~ Free Software Foundation, Inc.
+ ~ 51 Franklin Street, Fifth Floor
+ ~ Boston, MA 02110-1301 USA
+ -->
+<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN" "http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd" [
+<!ENTITY % RH-ENTITIES SYSTEM "Common_Config/rh-entities.ent">
+<!ENTITY versionNumber "0.2">
+<!ENTITY copyrightYear "2008">
+<!ENTITY copyrightHolder "Red Hat Middleware, LLC.">]>
+<book>
+ <bookinfo>
+ <title>JBoss DNA</title>
+ <subtitle>Reference Guide</subtitle>
+ <releaseinfo>&versionNumber;
+ </releaseinfo>
+ <productnumber>&versionNumber;
+ </productnumber>
+ <issuenum>1</issuenum>
+ <mediaobject>
+ <imageobject role="fo">
+ <imagedata fileref="images/dna-logo.png" align="center" />
+ </imageobject>
+ <imageobject role="pdf">
+ <imagedata fileref="images/dna-logo.png" scale="75" align="center" />
+ </imageobject>
+ <imageobject role="html">
+ <imagedata fileref="images/dna-logo.png" depth="3cm" />
+ </imageobject>
+ <imageobject role="xhtml">
+ <imagedata fileref="images/dna-logo.png" depth="3cm" />
+ </imageobject>
+ <imageobject role="xhtml_single">
+ <imagedata fileref="images/dna-logo.png" depth="3cm" />
+ </imageobject>
+ </mediaobject>
+ <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="Author_Group.xml" />
+ <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="Legal_Notice.xml" />
+ </bookinfo>
+ <preface id="preface" revision="1">
+ <title>Target audience</title>
+ <para>This guide is for the developers of JBoss DNA and those users that want to have a better understanding of
+ how JBoss DNA works or how to extend the functionality. For a higher-level introduction to JBoss DNA, see
+ the <ulink url="http://www.jboss.org/file-access/default/members/dna/freezone/docs/0.2/ma...">Getting Started</ulink> document.</para>
+ <para>
+ If you have any questions or comments, please feel free to contact JBoss DNA's
+ <ulink url="mailto:dna-users@jboss.org">user mailing list</ulink>
+ or use the
+ <ulink url="http://www.jboss.com/index.html?module=bb&op=viewforum&f=272">user forums</ulink>
+ . If you'd like to get involved on the project, join the
+ <ulink url="http://www.jboss.org/dna/lists.html">mailing lists</ulink>
+ ,
+ <ulink url="http://www.jboss.org/dna/subversion.html">download the code</ulink>
+ and get it building, and visit our
+ <ulink url="http://jira.jboss.org/jira/browse/DNA">JIRA issue management system</ulink>
+ . If there's something in particular you're interested in, talk with the community - there may be others interested in the
+ same thing.
+ </para>
+ </preface>
+ <!-- ====================================================================================================
+ Chapter
+ ==================================================================================================== -->
+ <chapter id="introduction">
+ <title>Introduction to JBoss DNA</title>
+ <para>There are a lot of choices for how applications can store information persistently so that it can be accessed at a
+ later time and by other processes. The challenge developers face is how to use an approach that most closely matches the
+ needs of their application. This choice becomes more important as developers choose to focus their efforts on
+ application-specific logic, delegating much of the responsibilities for persistence to libraries and frameworks.</para>
+ <para>
+ Perhaps one of the easiest techniques is to simply store information in
+ <emphasis>files</emphasis>
+ . The Java language makes working with files relatively easy, but Java really doesn't provide many bells and whistles. So
+ using files is an easy choice when the information is either not complicated (for example property files), or when users may
+ need to read or change the information outside of the application (for example log files or configuration files). But using
+ files to persist information becomes more difficult as the information becomes more complex, as the volume of it increases,
+ or if it needs to be accessed by multiple processes. For these situations, other techniques often offer better choices.
+ </para>
+ <para>
+ Another technique built into the Java language is
+ <emphasis>Java serialization</emphasis>
+ , which is capable of persisting the state of an object graph so that it can be read back in at a later time. However, Java
+ serialization can quickly become tricky if the classes are changed, and so it's beneficial usually when the information is
+ persisted for a very short period of time. For example, serialization is sometimes used to send an object graph from one
+ process to another.
+ </para>
+ <para>
+ One of the more popular persistence technologies is the
+ <emphasis>relational database</emphasis>
+ . Relational database management systems have been around for decades and are very capable. The Java Database Connectivity
+ (JDBC) API provides a standard interface for connecting to and interacting with relational databases. However, it is a
+ low-level API that requires a lot of code to use correctly, and it still doesn't abstract away the DBMS-specific SQL
+ grammar. Also, working with relational data in an object-oriented language can feel somewhat unnatural, so many developers
+ map this data to classes that fit much more cleanly into their application. The problem is that manually creating this
+ mapping layer requires a lot of repetitive and non-trivial JDBC code.
+ </para>
+ <para>
+ <emphasis>Object-relational mapping</emphasis>
+ libraries automate the creation of this mapping layer and result in far less code that is much more maintainable with
+ performance that is often as good as (if not better than) handwritten JDBC code. The new
+ <ulink url="http://java.sun.com/developer/technicalArticles/J2EE/jpa/">Java Persistence API (JPA)</ulink>
+ provide a standard mechanism for defining the mappings (through annotations) and working with these entity objects. Several
+ commercial and open-source libraries implement JPA, and some even offer additional capabilities and features that go beyond
+ JPA. For example,
+ <ulink url="http://www.hibernate.org">Hibernate</ulink>
+ is one of the most feature-rich JPA implementations and offers object caching, statement caching, extra association
+ mappings, and other features that help to improve performance and usefulness.
+ </para>
+ <para>
+ While relational databases and JPA are solutions that work for many applications, they become more limited in cases when the
+ information structure is highly flexible, is not known
+ <emphasis>a priori</emphasis>
+ , or is subject to frequent change and customization. In these situations,
+ <emphasis>content repositories</emphasis>
+ may offer a better choice for persistence. Content repositories are almost a hybrid between relational databases and file
+ systems, and typically provide other capabilities as well, including versioning, indexing, search, access control,
+ transactions, and observation. Because of this, content repositories are used by content management systems (CMS), document
+ management systems (DMS), and other applications that manage electronic files (e.g., documents, images, multi-media, web
+ content, etc.) and metadata associated with them (e.g., author, date, status, security information, etc.). The
+ <ulink url="http://www.jcp.org/en/jsr/detail?id=170">Content Repository for Java technology API</ulink>
+ provides a standard Java API for working with content repositories. Abbreviated "JCR", this API was developed as part of the
+ Java Community Process under
+ <ulink url="http://www.jcp.org/en/jsr/detail?id=170">JSR-170</ulink>
+ and is being revised under
+ <ulink url="http://www.jcp.org/en/jsr/detail?id=283">JSR-283</ulink>
+ .
+ </para>
+ <para>
+ The
+ <emphasis>JBoss DNA project</emphasis>
+ is building the tools and services that surround content repositories. Nearly all of these capabilities are to be hidden
+ below the JCR API and involve automated processing of the information in the repository. Thus, JBoss DNA can add value to
+ existing repository implementations. For example, JCR repositories offer the ability to upload files into the repository and
+ have the file content indexed for search purposes. JBoss DNA also defines a library for "sequencing" content - to extract
+ meaningful information from that content and store it in the repository, where it can then be searched, accessed, and
+ analyzed using the JCR API.
+ </para>
+ <para> JBoss DNA is building other features as well. One goal of JBoss DNA is to create federated repositories that
+ dynamically merge the information from multiple databases, services, applications, and other JCR repositories. Another is to
+ create customized views based upon the type of data and the role of the user that is accessing the data. And yet another is
+ to create a REST-ful API to allow the JCR content to be accessed easily by other applications written in other languages.
+ </para>
+ <sect1 id="roadmap">
+ <title>Project roadmap</title>
+ <para>The roadmap for JBoss DNA is managed in the project's <ulink url="https://jira.jboss.org/jira/browse/DNA">JIRA instance</ulink>.
+ The roadmap shows the different tasks, requirements, issues and other activities that have been targeted to each of the upcoming releases.
+ (The <ulink url="https://jira.jboss.org/jira/browse/DNA?report=com.atlassian.jira.plugin.s...">roadmap report</ulink>
+ always shows the next three releases.)</para>
+ <para>By convention, JIRA issues not immediately targeted to a release will be reviewed periodically to determine the appropriate release
+ where they can be targeted. Any issue that is reviewed and that does not fit in a known release will be targeted to the
+ <ulink url="https://jira.jboss.org/jira/browse/DNA?report=com.atlassian.jira.plugin.s...">Future Releases</ulink>
+ bucket. This should be reviewed periodically and at least at the beginning of each release cycle, with the goal of targeting most
+ of the issues to specific releases.</para>
+ </sect1>
+ <sect1 id="modules">
+ <title>JBoss DNA modules</title>
+ <para>JBoss DNA consists of the following modules:
+ <itemizedlist>
+ <listitem>
+ <para>
+ <emphasis role="strong">dna-common</emphasis>
+ is a low-level library of common utilities and frameworks, including logging, progress monitoring, internationalization/localization,
+ text translators, component management, and class loader factories.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <emphasis role="strong">dna-spi</emphasis>
+ defines the Service Provider Interface (SPI) for DNA, including the repository connectors, sequencers, graph interfaces, and MIME type detectors.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <emphasis role="strong">dna-repository</emphasis>
+ is the main module and provides the repository-oriented services, including the Repository Service, Sequencing Service, Observation Service, and Rules Service.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <emphasis role="strong">dna-jcr</emphasis>
+ provides the JBoss DNA implementation of the JCR API, which relies upon a repository connector, such as the Federation Connector
+ (see <code>dna-connector-federation</code>).
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <emphasis role="strong">dna-integration-tests</emphasis>
+ provides a home for all of the integration tests that involve more components that just unit tests. Integration tests
+ are often more complicated, take longer, and involve testing the integration and functionality of many components
+ (whereas unit tests focus on testing a single class or component and may use stubs or mock objects for other components).
+ </para>
+ </listitem>
+ </itemizedlist>
+ The following modules are optional extensions that may be used selectively and as needed
+ (and are located in the source under the <code>extensions</code> directory):
+ <itemizedlist>
+ <listitem>
+ <para>
+ <emphasis role="strong">dna-maven-classloader</emphasis>
+ is a small library that provides a <code>ClassLoaderFactory</code> implementation that can create <code>java.lang.ClassLoader</code> instances capable of loading
+ classes given a Maven Repository and a list of Maven coordinates. The Maven Repository can be managed within a JCR repository.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <emphasis role="strong">dna-connector-federation</emphasis>
+ is a DNA repository connector that federates, integrates and caches information from multiple sources (via other repository connectors).
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <emphasis role="strong">dna-connector-inmemory</emphasis>
+ is a simple DNA repository connector that manages content within memory. This can be used as a simple cache or as a transient
+ repository.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <emphasis role="strong">dna-connector-jbosscache</emphasis>
+ is a DNA repository connector that manages content within a <ulink url="http://www.jboss.org/jbosscache/">JBoss Cache</ulink> instance. JBoss Cache is a powerful cache implementation
+ that can serve as a distributed cache and that can persist information. The cache instance can be found via JNDI or created and managed
+ by the connector.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <emphasis role="strong">dna-sequencer-zip</emphasis>
+ is a DNA sequencer that extracts from ZIP archives the files (with content) and folders.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <emphasis role="strong">dna-sequencer-images</emphasis>
+ is a DNA sequencer that extracts the image metadata (e.g., size, date, etc.) from PNG, JPEG, GIF, BMP, PCS, IFF, RAS, PBM, PGM, and PPM image files.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <emphasis role="strong">dna-sequencer-mp3</emphasis>
+ is a DNA sequencer that extracts metadata (e.g., author, album name, etc.) from MP3 audio files.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <emphasis role="strong">dna-sequencer-java</emphasis>
+ is a DNA sequencer that extracts the package, class/type, member, documentation, annotations, and other information from
+ Java source files.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <emphasis role="strong">dna-sequencer-msoffice</emphasis>
+ is a DNA sequencer that extracts metadata and summary information from <ulink url="http://office.microsoft.com/en-us/">Microsoft Office</ulink> documents. For example, the sequencer
+ extracts from a PowerPoint presentation the outline as well as thumbnails of each slide. Microsoft Word and Excel files are also supported.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <emphasis role="strong">dna-sequencer-cnd</emphasis>
+ is a DNA sequencer that extracts JCR node definitions from JCR Compact Node Definition (CND) files.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <emphasis role="strong">dna-mimetype-detector-aperture</emphasis>
+ is a DNA MIME type detector that uses the <ulink url="http://aperture.sourceforge.net/">Aperture</ulink> library to determine the best MIME type
+ from the filename and file contents.
+ </para>
+ </listitem>
+ </itemizedlist>
+ There are also documentation modules
+ (located in the source under the <code>docs</code> directory):
+ <itemizedlist>
+ <listitem>
+ <para>
+ <emphasis role="strong">docs-getting-started</emphasis>
+ is the project with the <ulink url="http://www.docbook.org/">DocBook</ulink> source for the JBoss DNA Getting Started document.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <emphasis role="strong">docs-getting-started-examples</emphasis>
+ is the project with the Java source for the example application used in the JBoss DNA Getting Started document.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <emphasis role="strong">docs-reference-guide</emphasis>
+ is the project with the <ulink url="http://www.docbook.org/">DocBook</ulink> source for this document, the JBoss DNA Reference Guide document.
+ </para>
+ </listitem>
+ </itemizedlist>
+ Finally, there is a module that represents the whole JBoss DNA project:
+ <itemizedlist>
+ <listitem>
+ <para>
+ <emphasis role="strong">dna</emphasis>
+ is the parent project that aggregates all of the other projects and that contains some asset files to create the necessary Maven artifacts during a build.
+ </para>
+ </listitem>
+ </itemizedlist>
+ Each of these modules is a Maven project with a group ID of <code>org.jboss.dna</code>. All of these projects correspond to artifacts in the
+ <ulink url="http://repository.jboss.com/maven2/">JBoss Maven 2 Repository</ulink>.</para>
+ </sect1>
+ </chapter>
+ <!-- ====================================================================================================
+ Chapter
+ ==================================================================================================== -->
+ <chapter id="classloaders">
+ <title>Class loaders</title>
+ <para></para>
+ <sect1 id="dna-maven-classloader">
+ <title>Maven Repository class loader</title>
+ <para></para>
+ </sect1>
+ </chapter>
+ <!-- ====================================================================================================
+ Chapter
+ ==================================================================================================== -->
+ <chapter id="security">
+ <title>Security</title>
+ <para>JBoss DNA uses the <ulink url="http://java.sun.com/javase/technologies/security/">Java Authentication and Authorization Service (JAAS)</ulink>
+ for its security mechanism. This offers the greatest flexibility and power for integrating JBoss DNA into other applications.
+ </para>
+ <sect1 id="jboss-security">
+ <title>JBoss Security</title>
+ <para>The <ulink url="http://www.jboss.org/jbosssecurity/">JBoss Security</ulink> provides one of the best and most powerful
+ implementations of the JAAS specification - plus it's open source. JBoss Security offers a number of login modules, including:
+ <itemizedlist>
+ <listitem>
+ <para>
+ <emphasis role="strong">User-Roles Login Module</emphasis>
+ is a simple <code>javax.security.auth.login.LoginContext</code> implementation that uses usernames and passwords stored
+ in a properties file.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <emphasis role="strong">Client Login Module</emphasis>
+ prompts the user for their username and password.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <emphasis role="strong">Database Server Login Module</emphasis>
+ uses a JDBC database to authenticate principals and associate them with roles.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <emphasis role="strong">LDAP Login Module</emphasis>
+ uses an LDAP directory to authenticate principals. Two implementations are available.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <emphasis role="strong">Certificate Login Module</emphasis>
+ authenticates using X509 certificates, obtaining roles from either property files or a JDBC database.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <emphasis role="strong">Operating System Login Module</emphasis>
+ authenticates using the operating system's mechanism.
+ </para>
+ </listitem>
+ </itemizedlist>
+ and many others.
+ </para>
+ <para>JBoss Security also provides other capabilities, such as using XACML policies or using federated single sign-on.
+ For more detail, see the <ulink url="http://www.jboss.org/jbosssecurity/">JBoss Security</ulink> project.
+ </para>
+ </sect1>
+ </chapter>
+ <!-- ====================================================================================================
+ Chapter
+ ==================================================================================================== -->
+ <chapter id="repositories">
+ <title>Repositories</title>
+ <para></para>
+ <sect1 id="repository-service">
+ <title>Repository Service</title>
+ <para></para>
+ </sect1>
+ <sect1 id="connectors">
+ <title>Repository connectors and sources</title>
+ <para></para>
+ <sect2 id="dna-connector-inmemory">
+ <title>In-memory connector</title>
+ <para></para>
+ </sect2>
+ <sect2 id="dna-connector-jbosscache">
+ <title>JBoss Cache connector</title>
+ <para></para>
+ </sect2>
+ <sect2 id="dna-connector-federation">
+ <title>Federating connector</title>
+ <para></para>
+ </sect2>
+ </sect1>
+ <sect1 id="custom-connectors">
+ <title>Writing custom connectors</title>
+ <para></para>
+ </sect1>
+ </chapter>
+ <!-- ====================================================================================================
+ Chapter
+ ==================================================================================================== -->
+ <chapter id="jcr">
+ <title>Content Repositories for Java (JCR)</title>
+ <para></para>
+ <sect1 id="jcr-repositories">
+ <title>Obtaining JCR repositories</title>
+ <para>Discuss how to obtain JCR repository instances (from the Repository Service).
+ </para>
+ </sect1>
+ <sect1 id="jcr-sessions">
+ <title>Creating JCR sessions</title>
+ <para>Discuss how to obtain JCR sessions and how the credentials work.
+ Also discuss that sessions should be created, used, and closed.
+ </para>
+ </sect1>
+ </chapter>
+ <!-- ====================================================================================================
+ Chapter
+ ==================================================================================================== -->
+ <chapter id="sequencing">
+ <title>Sequencing content</title>
+ <para></para>
+ <sect1 id="sequencing-service">
+ <title>Sequencing Service</title>
+ <para></para>
+ </sect1>
+ <sect1 id="sequencers">
+ <title>JBoss DNA Sequencers</title>
+ <para></para>
+ <sect2 id="dna-sequencer-images">
+ <title>Image sequencer</title>
+ <para></para>
+ </sect2>
+ <sect2 id="dna-sequencer-msoffice">
+ <title>Microsoft Office document sequencer</title>
+ <para></para>
+ </sect2>
+ <sect2 id="dna-sequencer-zip">
+ <title>ZIP archive sequencer</title>
+ <para></para>
+ </sect2>
+ <sect2 id="dna-sequencer-java">
+ <title>Java source sequencer</title>
+ <para></para>
+ </sect2>
+ <sect2 id="dna-sequencer-mp3">
+ <title>MP3 audio file sequencer</title>
+ <para></para>
+ </sect2>
+ <sect2 id="dna-sequencer-cnd">
+ <title>JCR Compact Node Definition (CND) file sequencer</title>
+ <para></para>
+ </sect2>
+ </sect1>
+ <sect1 id="custom-sequencers">
+ <title>Writing custom sequencers</title>
+ <para></para>
+ </sect1>
+ </chapter>
+ <!-- ====================================================================================================
+ Chapter
+ ==================================================================================================== -->
+ <chapter id="mimetypes">
+ <title>MIME types</title>
+ <para></para>
+ <sect1 id="detectors">
+ <title>JBoss DNA MIME type detectors</title>
+ <para></para>
+ <sect2 id="dna-mimetype-detector-aperture">
+ <title>Aperture MIME type detector</title>
+ <para></para>
+ </sect2>
+ </sect1>
+ <sect1 id="custom-detectors">
+ <title>Writing custom detectors</title>
+ <para></para>
+ </sect1>
+ </chapter>
+ <!-- ====================================================================================================
+ Chapter
+ ==================================================================================================== -->
+ <chapter id="configuration">
+ <title>Configuration</title>
+ <para>Discuss how to configure JBoss DNA and how configuration repositories are used to bootstrap the
+ various services and components. Describe how the next release will focus on making this easier
+ and will detail configuration using the <ulink url="http://www.jboss.org/jbossmc/">JBoss Microcontainer</ulink>.</para>
+ </chapter>
+ <!-- ====================================================================================================
+ Chapter
+ ==================================================================================================== -->
+ <chapter id="testing">
+ <title>Testing</title>
+ <para></para>
+ <sect1 id="unit-tests">
+ <title>Unit tests</title>
+ <para></para>
+ </sect1>
+ <sect1 id="integration-tests">
+ <title>Integration tests</title>
+ <para></para>
+ </sect1>
+ </chapter>
+
+
+ <!-- ====================================================================================================
+ Chapter
+ ==================================================================================================== -->
+ <chapter id="future_directions">
+ <title>Looking to the future</title>
+ <para>What's next for JBoss DNA? Well, the sequencing system is just the beginning. With this release, the sequencing system
+ is stable enough so that more <link linkend="sequencers">sequencers</link> can be developed and used within your own applications.
+ If you're interested in getting involved with the JBoss DNA project, consider picking up one of the sequencers on our
+ <ulink url="http://jira.jboss.org/jira/browse/DNA?report=com.atlassian.jira.plugin.sy...">roadmap</ulink>.
+ Or, check out <ulink url="http://jira.jboss.org/jira/secure/IssueNavigator.jspa?reset=true&mode...">JIRA</ulink>
+ for the list of sequencers we've thought of. If you think of one that's not there, please add it to JIRA!
+ </para>
+ <para>
+ The next release will focus on creating the <link linkend="federation">federation engine</link> and connectors
+ for several popular and ubiquitous systems. The 0.2 release will likely only federate information in a read-only manner,
+ but updates will soon follow. Also, during the early part of the next release, the JBoss DNA project will switch to use JDK 6.
+ Java 5 is being end-of-lifed, so we want to move to a supported JDK. However, a number of JBoss projects and products continue to
+ require Java 5, so our next release will most likely use JDK 6 with Java 5 compatibility.</para>
+ <para>
+ Other components on our roadmap include a web user interface, a REST-ful server, and a view system that allows domain-specific
+ views of information in the repository. These components are farther out on our roadmap, and at this time have not been
+ targeted to a particular release. If any of these are of interest to you, please <link linkend="preface">get involved</link> in the community.
+ </para>
+ </chapter>
+</book>
\ No newline at end of file
Added: trunk/docs/reference/pom.xml
===================================================================
--- trunk/docs/reference/pom.xml (rev 0)
+++ trunk/docs/reference/pom.xml 2008-08-05 18:09:39 UTC (rev 378)
@@ -0,0 +1,17 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.jboss</groupId>
+ <artifactId>documentation</artifactId>
+ <version>1.0</version>
+ </parent>
+
+ <groupId>org.jboss.dna</groupId>
+ <artifactId>reference-guide-${translation}</artifactId>
+ <version>0.2-SNAPSHOT</version>
+ <packaging>jdocbook</packaging>
+ <name>JBoss DNA Reference Guide (${translation})</name>
+
+</project>
\ No newline at end of file
15 years, 9 months
DNA SVN: r377 - in trunk: connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/contribution and 8 other directories.
by dna-commits@lists.jboss.org
Author: rhauch
Date: 2008-08-04 15:59:20 -0400 (Mon, 04 Aug 2008)
New Revision: 377
Added:
trunk/connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/contribution/ContributionStatistics.java
trunk/connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/contribution/TwoChildContribution.java
trunk/connectors/dna-connector-federation/src/test/java/org/jboss/dna/connector/federation/contribution/
trunk/connectors/dna-connector-federation/src/test/java/org/jboss/dna/connector/federation/contribution/ContributionStatisticsTest.java
trunk/connectors/dna-connector-federation/src/test/java/org/jboss/dna/connector/federation/contribution/EmptyContributionTest.java
trunk/connectors/dna-connector-federation/src/test/java/org/jboss/dna/connector/federation/contribution/MultiChildContributionTest.java
trunk/connectors/dna-connector-federation/src/test/java/org/jboss/dna/connector/federation/contribution/MultiPropertyContributionTest.java
trunk/connectors/dna-connector-federation/src/test/java/org/jboss/dna/connector/federation/contribution/NodeContributionTest.java
trunk/connectors/dna-connector-federation/src/test/java/org/jboss/dna/connector/federation/contribution/OneChildContributionTest.java
trunk/connectors/dna-connector-federation/src/test/java/org/jboss/dna/connector/federation/contribution/OnePropertyContributionTest.java
trunk/connectors/dna-connector-federation/src/test/java/org/jboss/dna/connector/federation/contribution/ThreePropertyContributionTest.java
trunk/connectors/dna-connector-federation/src/test/java/org/jboss/dna/connector/federation/contribution/TwoChildContributionTest.java
trunk/connectors/dna-connector-federation/src/test/java/org/jboss/dna/connector/federation/contribution/TwoPropertyContributionTest.java
Modified:
trunk/connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/FederatedRepository.java
trunk/connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/FederatedRepositorySource.java
trunk/connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/FederationI18n.java
trunk/connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/contribution/Contribution.java
trunk/connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/contribution/EmptyContribution.java
trunk/connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/contribution/MultiChildContribution.java
trunk/connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/contribution/MultiPropertyContribution.java
trunk/connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/contribution/NodeContribution.java
trunk/connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/contribution/NonEmptyContribution.java
trunk/connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/contribution/OneChildContribution.java
trunk/connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/contribution/OnePropertyContribution.java
trunk/connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/contribution/ThreePropertyContribution.java
trunk/connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/contribution/TwoPropertyContribution.java
trunk/connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/executor/FederatingCommandExecutor.java
trunk/connectors/dna-connector-federation/src/main/resources/org/jboss/dna/connector/federation/FederationI18n.properties
trunk/dna-repository/src/main/java/org/jboss/dna/repository/RepositoryService.java
trunk/dna-spi/src/main/java/org/jboss/dna/spi/cache/BasicCachePolicy.java
trunk/dna-spi/src/main/java/org/jboss/dna/spi/cache/CachePolicy.java
trunk/dna-spi/src/main/java/org/jboss/dna/spi/cache/ImmutableCachePolicy.java
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/DateTimeFactory.java
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/JodaDateTime.java
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/JodaDateTimeValueFactory.java
Log:
DNA-115 - Create federation service
http://jira.jboss.com/jira/browse/DNA-115
Added some methods to the DateTimeFactory to create DateTime by offsetting. Removed some excess I18n messages. Added more Contribution subclasses and tests for all the Contribution classes.
Modified: trunk/connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/FederatedRepository.java
===================================================================
--- trunk/connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/FederatedRepository.java 2008-07-29 21:15:51 UTC (rev 376)
+++ trunk/connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/FederatedRepository.java 2008-08-04 19:59:20 UTC (rev 377)
@@ -231,8 +231,8 @@
protected CommandExecutor getExecutor( ExecutionContext context,
String sourceName ) {
FederatedRepositoryConfig config = this.getConfiguration();
- return new FederatingCommandExecutor(context, sourceName, config.getCacheProjection(), config.getSourceProjections(),
- getConnectionFactories());
+ return new FederatingCommandExecutor(context, sourceName, config.getCacheProjection(), config.getDefaultCachePolicy(),
+ config.getSourceProjections(), getConnectionFactories());
}
/**
Modified: trunk/connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/FederatedRepositorySource.java
===================================================================
--- trunk/connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/FederatedRepositorySource.java 2008-07-29 21:15:51 UTC (rev 376)
+++ trunk/connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/FederatedRepositorySource.java 2008-08-04 19:59:20 UTC (rev 377)
@@ -98,8 +98,7 @@
protected static final String RETRY_LIMIT = "retryLimit";
protected static final String PROJECTION_RULES_CONFIG_PROPERTY_NAME = "dna:projectionRules";
- protected static final String CACHE_POLICY_TIME_TO_EXPIRE_CONFIG_PROPERTY_NAME = "dna:timeToExpire";
- protected static final String CACHE_POLICY_TIME_TO_CACHE_CONFIG_PROPERTY_NAME = "dna:timeToCache";
+ protected static final String CACHE_POLICY_TIME_TO_LIVE_CONFIG_PROPERTY_NAME = "dna:timeToLive";
private String repositoryName;
private String sourceName;
@@ -698,7 +697,7 @@
executor = new NoOpCommandExecutor(context, configurationSourceName);
} else {
// The configuration repository has more than one projection, so we need to merge the results
- executor = new FederatingCommandExecutor(context, configurationSourceName, null, projections, factories);
+ executor = new FederatingCommandExecutor(context, configurationSourceName, projections, factories);
}
// Wrap the executor with a logging executor ...
executor = new LoggingCommandExecutor(executor, Logger.getLogger(getClass()), Logger.Level.INFO);
@@ -767,14 +766,10 @@
// Look for the default cache policy ...
BasicCachePolicy cachePolicy = new BasicCachePolicy();
- Property timeToExpireProperty = getRepository.getProperties().get(nameFactory.create(CACHE_POLICY_TIME_TO_EXPIRE_CONFIG_PROPERTY_NAME));
- Property timeToCacheProperty = getRepository.getProperties().get(nameFactory.create(CACHE_POLICY_TIME_TO_CACHE_CONFIG_PROPERTY_NAME));
- if (timeToCacheProperty != null && !timeToCacheProperty.isEmpty()) {
- cachePolicy.setTimeToCache(longFactory.create(timeToCacheProperty.getValues().next()));
+ Property timeToLiveProperty = getRepository.getProperties().get(nameFactory.create(CACHE_POLICY_TIME_TO_LIVE_CONFIG_PROPERTY_NAME));
+ if (timeToLiveProperty != null && !timeToLiveProperty.isEmpty()) {
+ cachePolicy.setTimeToLive(longFactory.create(timeToLiveProperty.getValues().next()));
}
- if (timeToExpireProperty != null && !timeToExpireProperty.isEmpty()) {
- cachePolicy.setTimeToExpire(longFactory.create(timeToExpireProperty.getValues().next()));
- }
CachePolicy defaultCachePolicy = cachePolicy.isEmpty() ? null : cachePolicy.getUnmodifiable();
return new FederatedRepositoryConfig(repositoryName, cacheProjection, sourceProjections, defaultCachePolicy);
} catch (InvalidPathException err) {
Modified: trunk/connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/FederationI18n.java
===================================================================
--- trunk/connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/FederationI18n.java 2008-07-29 21:15:51 UTC (rev 376)
+++ trunk/connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/FederationI18n.java 2008-08-04 19:59:20 UTC (rev 377)
@@ -40,12 +40,8 @@
public static I18n unableToFindRepositoryConnectionFactoriesInJndi;
public static I18n noRepositoryConnectionFactories;
public static I18n federatedRepositoryCannotBeFound;
- public static I18n unableToFindRepositorySourceByName;
- public static I18n unableToCreateConnectionToFederatedRepository;
public static I18n unableToAuthenticateConnectionToFederatedRepository;
public static I18n repositoryHasBeenShutDown;
- public static I18n repositoryPathInFederationBindingIsNotAbsolute;
- public static I18n errorReadingMergePlan;
public static I18n errorAddingProjectionRuleParseMethod;
static {
Modified: trunk/connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/contribution/Contribution.java
===================================================================
--- trunk/connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/contribution/Contribution.java 2008-07-29 21:15:51 UTC (rev 376)
+++ trunk/connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/contribution/Contribution.java 2008-08-04 19:59:20 UTC (rev 377)
@@ -47,10 +47,13 @@
* Create an empty contribution from the named source.
*
* @param sourceName the name of the source, which may not be null or blank
+ * @param expirationTime the time (in UTC) after which this contribution should be considered expired, or null if there is no
+ * expiration time
* @return the contribution
*/
- public static Contribution create( String sourceName ) {
- return new EmptyContribution(sourceName);
+ public static Contribution create( String sourceName,
+ DateTime expirationTime ) {
+ return new EmptyContribution(sourceName, expirationTime);
}
/**
@@ -58,16 +61,19 @@
*
* @param sourceName the name of the source, which may not be null or blank
* @param pathInSource the path in the source for this contributed information; may not be null
+ * @param expirationTime the time (in UTC) after which this contribution should be considered expired, or null if there is no
+ * expiration time
* @param property the property from the source; may not be null
* @return the contribution
*/
public static Contribution create( String sourceName,
Path pathInSource,
+ DateTime expirationTime,
Property property ) {
if (property == null) {
- return new EmptyContribution(sourceName);
+ return new EmptyContribution(sourceName, expirationTime);
}
- return new OnePropertyContribution(sourceName, pathInSource, property);
+ return new OnePropertyContribution(sourceName, pathInSource, expirationTime, property);
}
/**
@@ -75,58 +81,98 @@
*
* @param sourceName the name of the source, which may not be null or blank
* @param pathInSource the path in the source for this contributed information; may not be null
+ * @param expirationTime the time (in UTC) after which this contribution should be considered expired, or null if there is no
+ * expiration time
* @param child the child from the source; may not be null or empty
* @return the contribution
*/
public static Contribution create( String sourceName,
Path pathInSource,
+ DateTime expirationTime,
Segment child ) {
if (child == null) {
- return new EmptyContribution(sourceName);
+ return new EmptyContribution(sourceName, expirationTime);
}
- return new OneChildContribution(sourceName, pathInSource, child);
+ return new OneChildContribution(sourceName, pathInSource, expirationTime, child);
}
/**
+ * Create a contribution of a single child from the named source.
+ *
+ * @param sourceName the name of the source, which may not be null or blank
+ * @param pathInSource the path in the source for this contributed information; may not be null
+ * @param expirationTime the time (in UTC) after which this contribution should be considered expired, or null if there is no
+ * expiration time
+ * @param child1 the first child from the source; may not be null or empty
+ * @param child2 the second child from the source; may not be null or empty
+ * @return the contribution
+ */
+ public static Contribution create( String sourceName,
+ Path pathInSource,
+ DateTime expirationTime,
+ Segment child1,
+ Segment child2 ) {
+ if (child1 != null) {
+ if (child2 != null) {
+ return new TwoChildContribution(sourceName, pathInSource, expirationTime, child1, child2);
+ }
+ return new OneChildContribution(sourceName, pathInSource, expirationTime, child1);
+ }
+ if (child2 != null) {
+ return new OneChildContribution(sourceName, pathInSource, expirationTime, child2);
+ }
+ return new EmptyContribution(sourceName, expirationTime);
+ }
+
+ /**
* Create a contribution of the supplied properties and children from the named source.
*
* @param sourceName the name of the source, which may not be null or blank
* @param pathInSource the path in the source for this contributed information; may not be null
+ * @param expirationTime the time (in UTC) after which this contribution should be considered expired, or null if there is no
+ * expiration time
* @param properties the properties from the source; may not be null
* @param children the children from the source; may not be null or empty
* @return the contribution
*/
public static Contribution create( String sourceName,
Path pathInSource,
+ DateTime expirationTime,
Collection<Property> properties,
Collection<Segment> children ) {
if (properties == null || properties.isEmpty()) {
// There are no properties ...
if (children == null || children.isEmpty()) {
- return new EmptyContribution(sourceName);
+ return new EmptyContribution(sourceName, expirationTime);
}
if (children.size() == 1) {
- return new OneChildContribution(sourceName, pathInSource, children.iterator().next());
+ return new OneChildContribution(sourceName, pathInSource, expirationTime, children.iterator().next());
}
- return new MultiChildContribution(sourceName, pathInSource, children);
+ if (children.size() == 2) {
+ Iterator<Segment> iter = children.iterator();
+ return new TwoChildContribution(sourceName, pathInSource, expirationTime, iter.next(), iter.next());
+ }
+ return new MultiChildContribution(sourceName, pathInSource, expirationTime, children);
}
// There are some properties ...
if (children == null || children.isEmpty()) {
// There are no children ...
- switch (properties.size()) {
- case 1:
- return new OnePropertyContribution(sourceName, pathInSource, properties.iterator().next());
- case 2:
- Iterator<Property> iter = properties.iterator();
- return new TwoPropertyContribution(sourceName, pathInSource, iter.next(), iter.next());
- case 3:
- Iterator<Property> iter3 = properties.iterator();
- return new ThreePropertyContribution(sourceName, pathInSource, iter3.next(), iter3.next(), iter3.next());
+ if (properties.size() == 1) {
+ return new OnePropertyContribution(sourceName, pathInSource, expirationTime, properties.iterator().next());
}
- return new MultiPropertyContribution(sourceName, pathInSource, properties);
+ if (properties.size() == 2) {
+ Iterator<Property> iter = properties.iterator();
+ return new TwoPropertyContribution(sourceName, pathInSource, expirationTime, iter.next(), iter.next());
+ }
+ if (properties.size() == 3) {
+ Iterator<Property> iter = properties.iterator();
+ return new ThreePropertyContribution(sourceName, pathInSource, expirationTime, iter.next(), iter.next(),
+ iter.next());
+ }
+ return new MultiPropertyContribution(sourceName, pathInSource, expirationTime, properties);
}
// There are some properties AND some children ...
- return new NodeContribution(sourceName, pathInSource, properties, children);
+ return new NodeContribution(sourceName, pathInSource, expirationTime, properties, children);
}
/**
@@ -144,10 +190,15 @@
* Create a contribution for the source with the supplied name and path.
*
* @param sourceName the name of the source, which may not be null or blank
+ * @param expirationTime the time (in UTC) after which this contribution should be considered expired, or null if there is no
+ * expiration time
*/
- protected Contribution( String sourceName ) {
+ protected Contribution( String sourceName,
+ DateTime expirationTime ) {
assert sourceName != null && sourceName.trim().length() != 0;
+ assert expirationTime == null || expirationTime.equals(expirationTime.toUtcTimeZone());
this.sourceName = sourceName;
+ this.expirationTimeInUtc = expirationTime;
}
/**
@@ -336,6 +387,7 @@
private boolean next = true;
protected OneValueIterator( T value ) {
+ assert value != null;
this.value = value;
}
@@ -354,7 +406,7 @@
* @see java.util.Iterator#next()
*/
public T next() {
- if (!next) {
+ if (next) {
next = false;
return value;
}
Added: trunk/connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/contribution/ContributionStatistics.java
===================================================================
--- trunk/connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/contribution/ContributionStatistics.java (rev 0)
+++ trunk/connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/contribution/ContributionStatistics.java 2008-08-04 19:59:20 UTC (rev 377)
@@ -0,0 +1,234 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.dna.connector.federation.contribution;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.atomic.AtomicLong;
+import org.jboss.dna.common.util.ArgCheck;
+import org.jboss.dna.common.util.HashCode;
+
+/**
+ * Simple utility class to record the distribution of contributions.
+ *
+ * @author Randall Hauch
+ */
+public class ContributionStatistics {
+
+ /**
+ * This should only be enabled when attempting to accumulate the distribution, and should <i>never</i> be enabled in a
+ * release.
+ */
+ /*package*/static final boolean RECORD = false;
+
+ private static final ConcurrentMap<Stats, AtomicLong> DATA = new ConcurrentHashMap<Stats, AtomicLong>();
+
+ /**
+ * Record a {@link Contribution} was created for the supplied number of properties and children. {@link #RECORD} should be
+ * checked <i>before</i> this method is called.
+ *
+ * @param propertyCount the number of properties
+ * @param childrenCount the number of children
+ */
+ /*package*/static void record( int propertyCount,
+ int childrenCount ) {
+ Stats key = new Stats(propertyCount, childrenCount);
+ AtomicLong existing = DATA.putIfAbsent(key, new AtomicLong(1l));
+ if (existing != null) existing.incrementAndGet();
+ }
+
+ public boolean isRecording() {
+ return RECORD;
+ }
+
+ /**
+ * Get a copy of the raw statistics data.
+ *
+ * @return a copy of the data; never null
+ */
+ public static Map<Stats, AtomicLong> getData() {
+ return new HashMap<Stats, AtomicLong>(DATA);
+ }
+
+ /**
+ * Get the N most populous combinations of properties and children counts.
+ *
+ * @param n the maximum number of data objects to find and return in the raw data; must be positive
+ * @return the list of N (or fewer)
+ */
+ public static List<Data> getTop( int n ) {
+ ArgCheck.isPositive(n, "n");
+ LinkedList<Data> results = new LinkedList<Data>();
+ for (Map.Entry<Stats, AtomicLong> entry : DATA.entrySet()) {
+ long value = entry.getValue().get();
+ if (results.size() >= n) {
+ Data last = results.getLast();
+ if (value <= last.getInstanceCount()) continue;
+ // The new count is larger than the smallest, so pop the smallest and add the newest ...
+ results.removeLast();
+ }
+ results.add(new Data(entry.getKey(), value));
+ Collections.sort(results);
+ }
+ return results;
+ }
+
+ public static final class Data implements Comparable<Data> {
+ private final int propertyCount;
+ private final int childrenCount;
+ private final long instanceCount;
+
+ protected Data( Stats stats,
+ long instanceCount ) {
+ this.propertyCount = stats.getPropertyCount();
+ this.childrenCount = stats.getChildrenCount();
+ this.instanceCount = instanceCount;
+ }
+
+ /**
+ * @return childrenCount
+ */
+ public int getChildrenCount() {
+ return childrenCount;
+ }
+
+ /**
+ * @return propertyCount
+ */
+ public int getPropertyCount() {
+ return propertyCount;
+ }
+
+ /**
+ * @return instanceCount
+ */
+ public long getInstanceCount() {
+ return instanceCount;
+ }
+
+ /**
+ * {@inheritDoc} This orders the values in the opposite order, so that those with larger numbers of instances appear
+ * first.
+ *
+ * @see java.lang.Comparable#compareTo(java.lang.Object)
+ */
+ public int compareTo( Data that ) {
+ long diff = that.getInstanceCount() - this.getInstanceCount(); // backwards
+ return diff < 0l ? -1 : diff > 0 ? 1 : 0;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ return HashCode.compute(this.propertyCount, this.childrenCount, this.instanceCount);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals( Object obj ) {
+ if (obj instanceof Data) {
+ Data that = (Data)obj;
+ if (this.propertyCount != that.propertyCount) return false;
+ if (this.childrenCount != that.childrenCount) return false;
+ if (this.instanceCount != that.instanceCount) return false;
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see java.lang.Object#toString()
+ */
+ @Override
+ public String toString() {
+ return "(# props=" + this.getPropertyCount() + ", # children=" + this.getChildrenCount() + ") => "
+ + this.getInstanceCount();
+ }
+ }
+
+ public static final class Stats {
+ private final int propertyCount;
+ private final int childrenCount;
+
+ protected Stats( int propertyCount,
+ int childrenCount ) {
+ this.propertyCount = propertyCount;
+ this.childrenCount = childrenCount;
+ }
+
+ /**
+ * @return childrenCount
+ */
+ public int getChildrenCount() {
+ return childrenCount;
+ }
+
+ /**
+ * @return propertyCount
+ */
+ public int getPropertyCount() {
+ return propertyCount;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ return HashCode.compute(this.propertyCount, this.childrenCount);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals( Object obj ) {
+ if (obj instanceof Stats) {
+ Stats that = (Stats)obj;
+ if (this.propertyCount != that.propertyCount) return false;
+ if (this.childrenCount != that.childrenCount) return false;
+ return true;
+ }
+ return false;
+ }
+ }
+
+}
Property changes on: trunk/connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/contribution/ContributionStatistics.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/contribution/EmptyContribution.java
===================================================================
--- trunk/connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/contribution/EmptyContribution.java 2008-07-29 21:15:51 UTC (rev 376)
+++ trunk/connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/contribution/EmptyContribution.java 2008-08-04 19:59:20 UTC (rev 377)
@@ -22,6 +22,7 @@
package org.jboss.dna.connector.federation.contribution;
import net.jcip.annotations.Immutable;
+import org.jboss.dna.spi.graph.DateTime;
import org.jboss.dna.spi.graph.Path;
/**
@@ -46,9 +47,13 @@
* Create a contribution for the source with the supplied name.
*
* @param sourceName the name of the source, which may not be null or blank
+ * @param expirationTime the time (in UTC) after which this contribution should be considered expired, or null if there is no
+ * expiration time
*/
- public EmptyContribution( String sourceName ) {
- super(sourceName);
+ public EmptyContribution( String sourceName,
+ DateTime expirationTime ) {
+ super(sourceName, expirationTime);
+ if (ContributionStatistics.RECORD) ContributionStatistics.record(0, 0);
}
/**
Modified: trunk/connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/contribution/MultiChildContribution.java
===================================================================
--- trunk/connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/contribution/MultiChildContribution.java 2008-07-29 21:15:51 UTC (rev 376)
+++ trunk/connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/contribution/MultiChildContribution.java 2008-08-04 19:59:20 UTC (rev 377)
@@ -25,6 +25,7 @@
import java.util.LinkedList;
import java.util.List;
import net.jcip.annotations.Immutable;
+import org.jboss.dna.spi.graph.DateTime;
import org.jboss.dna.spi.graph.Path;
import org.jboss.dna.spi.graph.Path.Segment;
@@ -48,16 +49,22 @@
*
* @param sourceName the name of the source, which may not be null or blank
* @param pathInSource the path in the source for this contributed information; may not be null
+ * @param expirationTime the time (in UTC) after which this contribution should be considered expired, or null if there is no
+ * expiration time
* @param children the children from the source; may not be null or empty
*/
public MultiChildContribution( String sourceName,
Path pathInSource,
+ DateTime expirationTime,
Iterable<Segment> children ) {
- super(sourceName, pathInSource);
+ super(sourceName, pathInSource, expirationTime);
+ assert children != null;
this.children = new LinkedList<Segment>();
for (Segment child : children) {
if (child != null) this.children.add(child);
}
+ assert this.children.isEmpty() == false;
+ if (ContributionStatistics.RECORD) ContributionStatistics.record(0, this.children.size());
}
/**
Modified: trunk/connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/contribution/MultiPropertyContribution.java
===================================================================
--- trunk/connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/contribution/MultiPropertyContribution.java 2008-07-29 21:15:51 UTC (rev 376)
+++ trunk/connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/contribution/MultiPropertyContribution.java 2008-08-04 19:59:20 UTC (rev 377)
@@ -25,6 +25,7 @@
import java.util.Iterator;
import java.util.Map;
import net.jcip.annotations.Immutable;
+import org.jboss.dna.spi.graph.DateTime;
import org.jboss.dna.spi.graph.Name;
import org.jboss.dna.spi.graph.Path;
import org.jboss.dna.spi.graph.Property;
@@ -42,23 +43,29 @@
*/
private static final long serialVersionUID = 1L;
- private final Map<Name, Property> properties;
+ protected final Map<Name, Property> properties;
/**
* Create a contribution of node properties from the source with the supplied name.
*
* @param sourceName the name of the source, which may not be null or blank
* @param pathInSource the path in the source for this contributed information; may not be null
+ * @param expirationTime the time (in UTC) after which this contribution should be considered expired, or null if there is no
+ * expiration time
* @param properties the properties from the source; may not be null
*/
public MultiPropertyContribution( String sourceName,
Path pathInSource,
+ DateTime expirationTime,
Iterable<Property> properties ) {
- super(sourceName, pathInSource);
+ super(sourceName, pathInSource, expirationTime);
+ assert properties != null;
this.properties = new HashMap<Name, Property>();
for (Property property : properties) {
if (property != null) this.properties.put(property.getName(), property);
}
+ assert this.properties.isEmpty() == false;
+ if (ContributionStatistics.RECORD) ContributionStatistics.record(this.properties.size(), 0);
}
/**
Modified: trunk/connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/contribution/NodeContribution.java
===================================================================
--- trunk/connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/contribution/NodeContribution.java 2008-07-29 21:15:51 UTC (rev 376)
+++ trunk/connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/contribution/NodeContribution.java 2008-08-04 19:59:20 UTC (rev 377)
@@ -25,6 +25,7 @@
import java.util.LinkedList;
import java.util.List;
import net.jcip.annotations.Immutable;
+import org.jboss.dna.spi.graph.DateTime;
import org.jboss.dna.spi.graph.Path;
import org.jboss.dna.spi.graph.Property;
import org.jboss.dna.spi.graph.Path.Segment;
@@ -49,18 +50,24 @@
*
* @param sourceName the name of the source, which may not be null or blank
* @param pathInSource the path in the source for this contributed information; may not be null
+ * @param expirationTime the time (in UTC) after which this contribution should be considered expired, or null if there is no
+ * expiration time
* @param properties the properties from the source; may not be null
* @param children the children from the source; may not be null or empty
*/
public NodeContribution( String sourceName,
Path pathInSource,
+ DateTime expirationTime,
Iterable<Property> properties,
Iterable<Segment> children ) {
- super(sourceName, pathInSource, properties);
+ super(sourceName, pathInSource, expirationTime, properties);
+ assert children != null;
this.children = new LinkedList<Segment>();
for (Segment child : children) {
if (child != null) this.children.add(child);
}
+ assert this.children.isEmpty() == false;
+ if (ContributionStatistics.RECORD) ContributionStatistics.record(this.properties.size(), this.children.size());
}
/**
Modified: trunk/connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/contribution/NonEmptyContribution.java
===================================================================
--- trunk/connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/contribution/NonEmptyContribution.java 2008-07-29 21:15:51 UTC (rev 376)
+++ trunk/connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/contribution/NonEmptyContribution.java 2008-08-04 19:59:20 UTC (rev 377)
@@ -23,6 +23,7 @@
import net.jcip.annotations.Immutable;
import org.jboss.dna.common.util.HashCode;
+import org.jboss.dna.spi.graph.DateTime;
import org.jboss.dna.spi.graph.Path;
/**
@@ -45,10 +46,13 @@
*
* @param sourceName the name of the source, which may not be null or blank
* @param pathInSource the path in the source for this contributed information; may not be null
+ * @param expirationTime the time (in UTC) after which this contribution should be considered expired, or null if there is no
+ * expiration time
*/
protected NonEmptyContribution( String sourceName,
- Path pathInSource ) {
- super(sourceName);
+ Path pathInSource,
+ DateTime expirationTime ) {
+ super(sourceName, expirationTime);
assert pathInSource != null;
this.pathInSource = pathInSource;
}
Modified: trunk/connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/contribution/OneChildContribution.java
===================================================================
--- trunk/connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/contribution/OneChildContribution.java 2008-07-29 21:15:51 UTC (rev 376)
+++ trunk/connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/contribution/OneChildContribution.java 2008-08-04 19:59:20 UTC (rev 377)
@@ -23,11 +23,12 @@
import java.util.Iterator;
import net.jcip.annotations.Immutable;
+import org.jboss.dna.spi.graph.DateTime;
import org.jboss.dna.spi.graph.Path;
import org.jboss.dna.spi.graph.Path.Segment;
/**
- * The record of a source contributing only properties to a node.
+ * The record of a source contributing only a single child to a node.
*
* @author Randall Hauch
*/
@@ -42,18 +43,22 @@
private final Segment child;
/**
- * Create a contribution of node properties from the source with the supplied name.
+ * Create a contribution of a single child from the source with the supplied name.
*
* @param sourceName the name of the source, which may not be null or blank
* @param pathInSource the path in the source for this contributed information; may not be null
+ * @param expirationTime the time (in UTC) after which this contribution should be considered expired, or null if there is no
+ * expiration time
* @param child the child contributed from the source; may not be null
*/
public OneChildContribution( String sourceName,
Path pathInSource,
+ DateTime expirationTime,
Segment child ) {
- super(sourceName, pathInSource);
+ super(sourceName, pathInSource, expirationTime);
assert child != null;
this.child = child;
+ if (ContributionStatistics.RECORD) ContributionStatistics.record(0, 1);
}
/**
Modified: trunk/connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/contribution/OnePropertyContribution.java
===================================================================
--- trunk/connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/contribution/OnePropertyContribution.java 2008-07-29 21:15:51 UTC (rev 376)
+++ trunk/connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/contribution/OnePropertyContribution.java 2008-08-04 19:59:20 UTC (rev 377)
@@ -23,6 +23,7 @@
import java.util.Iterator;
import net.jcip.annotations.Immutable;
+import org.jboss.dna.spi.graph.DateTime;
import org.jboss.dna.spi.graph.Name;
import org.jboss.dna.spi.graph.Path;
import org.jboss.dna.spi.graph.Property;
@@ -47,15 +48,19 @@
*
* @param sourceName the name of the source, which may not be null or blank
* @param pathInSource the path in the source for this contributed information; may not be null
+ * @param expirationTime the time (in UTC) after which this contribution should be considered expired, or null if there is no
+ * expiration time
* @param property the property from the source; may not be null
*/
public OnePropertyContribution( String sourceName,
Path pathInSource,
+ DateTime expirationTime,
Property property ) {
- super(sourceName, pathInSource);
+ super(sourceName, pathInSource, expirationTime);
assert property != null;
assert property.isEmpty() == false;
this.property = property;
+ if (ContributionStatistics.RECORD) ContributionStatistics.record(1, 0);
}
/**
Modified: trunk/connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/contribution/ThreePropertyContribution.java
===================================================================
--- trunk/connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/contribution/ThreePropertyContribution.java 2008-07-29 21:15:51 UTC (rev 376)
+++ trunk/connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/contribution/ThreePropertyContribution.java 2008-08-04 19:59:20 UTC (rev 377)
@@ -23,6 +23,7 @@
import java.util.Iterator;
import net.jcip.annotations.Immutable;
+import org.jboss.dna.spi.graph.DateTime;
import org.jboss.dna.spi.graph.Name;
import org.jboss.dna.spi.graph.Path;
import org.jboss.dna.spi.graph.Property;
@@ -49,16 +50,19 @@
*
* @param sourceName the name of the source, which may not be null or blank
* @param pathInSource the path in the source for this contributed information; may not be null
+ * @param expirationTime the time (in UTC) after which this contribution should be considered expired, or null if there is no
+ * expiration time
* @param property1 the first property from the source; may not be null
* @param property2 the second property from the source; may not be null
* @param property3 the third property from the source; may not be null
*/
public ThreePropertyContribution( String sourceName,
Path pathInSource,
+ DateTime expirationTime,
Property property1,
Property property2,
Property property3 ) {
- super(sourceName, pathInSource);
+ super(sourceName, pathInSource, expirationTime);
assert property1 != null;
assert property1.isEmpty() == false;
assert property2 != null;
@@ -68,6 +72,7 @@
this.property1 = property1;
this.property2 = property2;
this.property3 = property3;
+ if (ContributionStatistics.RECORD) ContributionStatistics.record(3, 0);
}
/**
Added: trunk/connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/contribution/TwoChildContribution.java
===================================================================
--- trunk/connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/contribution/TwoChildContribution.java (rev 0)
+++ trunk/connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/contribution/TwoChildContribution.java 2008-08-04 19:59:20 UTC (rev 377)
@@ -0,0 +1,89 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.dna.connector.federation.contribution;
+
+import java.util.Iterator;
+import net.jcip.annotations.Immutable;
+import org.jboss.dna.spi.graph.DateTime;
+import org.jboss.dna.spi.graph.Path;
+import org.jboss.dna.spi.graph.Path.Segment;
+
+/**
+ * The record of a source contributing only two children to a node.
+ *
+ * @author Randall Hauch
+ */
+@Immutable
+public class TwoChildContribution extends NonEmptyContribution {
+
+ /**
+ * This is the first version of this class. See the documentation of MergePlan.serialVersionUID.
+ */
+ private static final long serialVersionUID = 1L;
+
+ private final Segment child1;
+ private final Segment child2;
+
+ /**
+ * Create a contribution of two children from the source with the supplied name.
+ *
+ * @param sourceName the name of the source, which may not be null or blank
+ * @param pathInSource the path in the source for this contributed information; may not be null
+ * @param expirationTime the time (in UTC) after which this contribution should be considered expired, or null if there is no
+ * expiration time
+ * @param child1 the first child contributed from the source; may not be null
+ * @param child2 the second child contributed from the source; may not be null
+ */
+ public TwoChildContribution( String sourceName,
+ Path pathInSource,
+ DateTime expirationTime,
+ Segment child1,
+ Segment child2 ) {
+ super(sourceName, pathInSource, expirationTime);
+ assert child1 != null;
+ assert child2 != null;
+ this.child1 = child1;
+ this.child2 = child2;
+ if (ContributionStatistics.RECORD) ContributionStatistics.record(0, 2);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.connector.federation.contribution.Contribution#getChildren()
+ */
+ @Override
+ public Iterator<Segment> getChildren() {
+ return new TwoValueIterator<Segment>(child1, child2);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.connector.federation.contribution.Contribution#getChildrenCount()
+ */
+ @Override
+ public int getChildrenCount() {
+ return 2;
+ }
+
+}
Property changes on: trunk/connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/contribution/TwoChildContribution.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/contribution/TwoPropertyContribution.java
===================================================================
--- trunk/connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/contribution/TwoPropertyContribution.java 2008-07-29 21:15:51 UTC (rev 376)
+++ trunk/connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/contribution/TwoPropertyContribution.java 2008-08-04 19:59:20 UTC (rev 377)
@@ -23,6 +23,7 @@
import java.util.Iterator;
import net.jcip.annotations.Immutable;
+import org.jboss.dna.spi.graph.DateTime;
import org.jboss.dna.spi.graph.Name;
import org.jboss.dna.spi.graph.Path;
import org.jboss.dna.spi.graph.Property;
@@ -48,20 +49,24 @@
*
* @param sourceName the name of the source, which may not be null or blank
* @param pathInSource the path in the source for this contributed information; may not be null
+ * @param expirationTime the time (in UTC) after which this contribution should be considered expired, or null if there is no
+ * expiration time
* @param property1 the first property from the source; may not be null
* @param property2 the first property from the source; may not be null
*/
public TwoPropertyContribution( String sourceName,
Path pathInSource,
+ DateTime expirationTime,
Property property1,
Property property2 ) {
- super(sourceName, pathInSource);
+ super(sourceName, pathInSource, expirationTime);
assert property1 != null;
assert property1.isEmpty() == false;
assert property2 != null;
assert property2.isEmpty() == false;
this.property1 = property1;
this.property2 = property2;
+ if (ContributionStatistics.RECORD) ContributionStatistics.record(2, 0);
}
/**
Modified: trunk/connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/executor/FederatingCommandExecutor.java
===================================================================
--- trunk/connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/executor/FederatingCommandExecutor.java 2008-07-29 21:15:51 UTC (rev 376)
+++ trunk/connectors/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/executor/FederatingCommandExecutor.java 2008-08-04 19:59:20 UTC (rev 377)
@@ -35,7 +35,9 @@
import org.jboss.dna.connector.federation.contribution.Contribution;
import org.jboss.dna.connector.federation.merge.MergePlan;
import org.jboss.dna.spi.ExecutionContext;
+import org.jboss.dna.spi.cache.CachePolicy;
import org.jboss.dna.spi.graph.DateTime;
+import org.jboss.dna.spi.graph.DateTimeFactory;
import org.jboss.dna.spi.graph.Name;
import org.jboss.dna.spi.graph.Path;
import org.jboss.dna.spi.graph.PathFactory;
@@ -64,6 +66,7 @@
public class FederatingCommandExecutor extends AbstractCommandExecutor {
private final Name mergePlanPropertyName;
+ private final CachePolicy defaultCachePolicy;
private final Projection cacheProjection;
private final List<Projection> sourceProjections;
private final Set<String> sourceNames;
@@ -76,7 +79,8 @@
/**
* Create a command executor that federates (merges) the information from multiple sources described by the source
* projections. The resulting command executor does not first consult a cache for the merged information; if a cache is
- * desired, see {@link #FederatingCommandExecutor(ExecutionContext, String, Projection, List, RepositoryConnectionFactories)
+ * desired, see
+ * {@link #FederatingCommandExecutor(ExecutionContext, String, Projection, CachePolicy, List, RepositoryConnectionFactories)
* constructor} that takes a {@link Projection cache projection}.
*
* @param context the execution context in which the executor will be run; may not be null
@@ -88,7 +92,7 @@
String sourceName,
List<Projection> sourceProjections,
RepositoryConnectionFactories connectionFactories ) {
- this(context, sourceName, null, sourceProjections, connectionFactories);
+ this(context, sourceName, null, null, sourceProjections, connectionFactories);
}
/**
@@ -101,18 +105,23 @@
* @param context the execution context in which the executor will be run; may not be null
* @param sourceName the name of the {@link RepositorySource} that is making use of this executor; may not be null or empty
* @param cacheProjection the projection used for the cached information; may be null if there is no cache
+ * @param defaultCachePolicy the default caching policy that outlines the length of time that information should be cached, or
+ * null if there is no cache or no specific cache policy
* @param sourceProjections the source projections; may not be null
* @param connectionFactories the factory for connection factory instances
*/
public FederatingCommandExecutor( ExecutionContext context,
String sourceName,
Projection cacheProjection,
+ CachePolicy defaultCachePolicy,
List<Projection> sourceProjections,
RepositoryConnectionFactories connectionFactories ) {
super(context, sourceName);
assert sourceProjections != null;
assert connectionFactories != null;
+ assert cacheProjection != null ? defaultCachePolicy != null : defaultCachePolicy == null;
this.cacheProjection = cacheProjection;
+ this.defaultCachePolicy = defaultCachePolicy;
this.sourceProjections = sourceProjections;
this.connectionFactories = connectionFactories;
this.connectionsBySourceName = new HashMap<String, RepositoryConnection>();
@@ -219,9 +228,10 @@
*/
protected BasicGetNodeCommand getNode( Path path ) throws RepositorySourceException, InterruptedException {
// Check the cache first ...
+ final ExecutionContext context = getEnvironment();
RepositoryConnection cacheConnection = getConnectionToCache();
BasicGetNodeCommand fromCache = new BasicGetNodeCommand(path);
- cacheConnection.execute(getEnvironment(), fromCache);
+ cacheConnection.execute(context, fromCache);
if (fromCache.hasError()) {
if (fromCache.getError() instanceof PathNotFoundException) {
// Start at the root and populate the cache down to this node ...
@@ -259,46 +269,70 @@
// What about other (new) regions?
} else {
// At this point, there is no merge plan, so read information from the sources ...
- PathFactory pathFactory = getEnvironment().getValueFactories().getPathFactory();
+ PathFactory pathFactory = context.getValueFactories().getPathFactory();
+ DateTimeFactory timeFactory = context.getValueFactories().getDateFactory();
List<Contribution> contributions = new LinkedList<Contribution>();
for (Projection projection : this.sourceProjections) {
final String source = projection.getSourceName();
- // Get the paths-in-source where we should fetch node contributions ...
- Set<Path> pathsInSource = projection.getPathsInSource(path, pathFactory);
- if (pathsInSource.isEmpty()) {
- // The source has no contributions ...
- contributions.add(Contribution.create(source));
- } else {
- // There is at least one contribution ...
- RepositoryConnection sourceConnection = getConnection(projection);
+ final RepositoryConnection sourceConnection = getConnection(projection);
+ try {
+ // Get the cached information ...
+ CachePolicy cachePolicy = sourceConnection.getDefaultCachePolicy();
+ if (cachePolicy == null) cachePolicy = this.defaultCachePolicy;
+ DateTime expirationTime = null;
+ if (cachePolicy != null) {
+ expirationTime = timeFactory.create(getCurrentTimeInUtc(), cachePolicy.getTimeToLive());
+ }
+ // Get the paths-in-source where we should fetch node contributions ...
+ Set<Path> pathsInSource = projection.getPathsInSource(path, pathFactory);
+ if (pathsInSource.isEmpty()) {
+ // The source has no contributions ...
+ contributions.add(Contribution.create(source, expirationTime));
+ } else {
+ // There is at least one contribution ...
- // Get the contributions ...
- final int numPaths = pathsInSource.size();
- if (numPaths == 1) {
- Path pathInSource = pathsInSource.iterator().next();
- BasicGetNodeCommand fromSource = new BasicGetNodeCommand(pathInSource);
- sourceConnection.execute(getEnvironment(), fromSource);
- if (!fromSource.hasError()) {
- Collection<Property> properties = fromSource.getProperties().values();
- Collection<Segment> children = fromSource.getChildren();
- Contribution contribution = Contribution.create(source, pathInSource, properties, children);
- contributions.add(contribution);
+ // Get the contributions ...
+ final int numPaths = pathsInSource.size();
+ if (numPaths == 1) {
+ Path pathInSource = pathsInSource.iterator().next();
+ BasicGetNodeCommand fromSource = new BasicGetNodeCommand(pathInSource);
+ sourceConnection.execute(getEnvironment(), fromSource);
+ if (!fromSource.hasError()) {
+ Collection<Property> properties = fromSource.getProperties().values();
+ Collection<Segment> children = fromSource.getChildren();
+ DateTime expTime = fromSource.getCachePolicy() == null ? expirationTime : timeFactory.create(getCurrentTimeInUtc(),
+ fromSource.getCachePolicy().getTimeToLive());
+ Contribution contribution = Contribution.create(source,
+ pathInSource,
+ expTime,
+ properties,
+ children);
+ contributions.add(contribution);
+ }
+ } else {
+ BasicGetNodeCommand[] fromSourceCommands = new BasicGetNodeCommand[numPaths];
+ int i = 0;
+ for (Path pathInSource : pathsInSource) {
+ fromSourceCommands[i++] = new BasicGetNodeCommand(pathInSource);
+ }
+ sourceConnection.execute(getEnvironment(), fromSourceCommands);
+ for (BasicGetNodeCommand fromSource : fromSourceCommands) {
+ if (fromSource.hasError()) continue;
+ Collection<Property> properties = fromSource.getProperties().values();
+ Collection<Segment> children = fromSource.getChildren();
+ DateTime expTime = fromSource.getCachePolicy() == null ? expirationTime : timeFactory.create(getCurrentTimeInUtc(),
+ fromSource.getCachePolicy().getTimeToLive());
+ Contribution contribution = Contribution.create(source,
+ fromSource.getPath(),
+ expTime,
+ properties,
+ children);
+ contributions.add(contribution);
+ }
}
- } else {
- BasicGetNodeCommand[] fromSourceCommands = new BasicGetNodeCommand[numPaths];
- int i = 0;
- for (Path pathInSource : pathsInSource) {
- fromSourceCommands[i++] = new BasicGetNodeCommand(pathInSource);
- }
- sourceConnection.execute(getEnvironment(), fromSourceCommands);
- for (BasicGetNodeCommand fromSource : fromSourceCommands) {
- if (fromSource.hasError()) continue;
- Collection<Property> properties = fromSource.getProperties().values();
- Collection<Segment> children = fromSource.getChildren();
- Contribution contribution = Contribution.create(source, fromSource.getPath(), properties, children);
- contributions.add(contribution);
- }
}
+ } finally {
+ sourceConnection.close();
}
}
// Merge the results into a single set of results ...
@@ -326,19 +360,6 @@
return null;
}
- protected Contribution getContribution( RepositoryConnection connection,
- String sourceName,
- Path path ) throws RepositorySourceException, InterruptedException {
- BasicGetNodeCommand fromSource = new BasicGetNodeCommand(path);
- connection.execute(getEnvironment(), fromSource);
- if (fromSource.hasError()) return null;
-
- Collection<Property> properties = fromSource.getProperties().values();
- Collection<Segment> children = fromSource.getChildren();
- Contribution contribution = Contribution.create(sourceName, path, properties, children);
- return contribution;
- }
-
protected MergePlan getMergePlan( BasicGetPropertiesCommand command ) {
Property mergePlanProperty = command.getProperties().get(mergePlanPropertyName);
if (mergePlanProperty == null || mergePlanProperty.isEmpty()) {
Modified: trunk/connectors/dna-connector-federation/src/main/resources/org/jboss/dna/connector/federation/FederationI18n.properties
===================================================================
--- trunk/connectors/dna-connector-federation/src/main/resources/org/jboss/dna/connector/federation/FederationI18n.properties 2008-07-29 21:15:51 UTC (rev 376)
+++ trunk/connectors/dna-connector-federation/src/main/resources/org/jboss/dna/connector/federation/FederationI18n.properties 2008-08-04 19:59:20 UTC (rev 377)
@@ -29,10 +29,6 @@
unableToFindRepositoryConnectionFactoriesInJndi = Unable to find an RepositoryConnectionFactories instance in JNDI under "{1}" when creating connection to federated source "{0}"
noRepositoryConnectionFactories = No RepositoryConnectionFactories instance was specified directly or indirectly found in JNDI when creating connection to federated source "{0}"
federatedRepositoryCannotBeFound = The federated repository "{0}" cannot be found
-unableToFindRepositorySourceByName = Unable to find the repository source "{0}"
-unableToCreateConnectionToFederatedRepository = Unable to connect to the repository "{0}". Check the Federation Service configuration.
unableToAuthenticateConnectionToFederatedRepository = Unable to authenticate "{1}" for repository "{0}"
repositoryHasBeenShutDown = The "{0}" repository has been shut down and may no longer be used.
-repositoryPathInFederationBindingIsNotAbsolute = The repository path in a federation binding must be absolute, but was "{0}"
-errorReadingMergePlan = Error while reading merge plan for {0}
errorAddingProjectionRuleParseMethod = Error while adding a parsing method for a federation projection rule
\ No newline at end of file
Added: trunk/connectors/dna-connector-federation/src/test/java/org/jboss/dna/connector/federation/contribution/ContributionStatisticsTest.java
===================================================================
--- trunk/connectors/dna-connector-federation/src/test/java/org/jboss/dna/connector/federation/contribution/ContributionStatisticsTest.java (rev 0)
+++ trunk/connectors/dna-connector-federation/src/test/java/org/jboss/dna/connector/federation/contribution/ContributionStatisticsTest.java 2008-08-04 19:59:20 UTC (rev 377)
@@ -0,0 +1,63 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.dna.connector.federation.contribution;
+
+import static org.hamcrest.core.Is.is;
+import static org.junit.Assert.assertThat;
+import java.util.List;
+import org.junit.Test;
+
+/**
+ * @author Randall Hauch
+ */
+public class ContributionStatisticsTest {
+
+ /**
+ * Statistics should be recorded ONLY during testing within an IDE, and should <i>never</i> be committed to SVN with the
+ * {@link ContributionStatistics#RECORD} set to <code>true</code>. This test verifies this, and thus will fail only during IDE
+ * testing.
+ */
+ @Test
+ public void shouldNotRecordStatisticsUnlessMeasuringStatisticsInLocalTests() {
+ assertThat(ContributionStatistics.RECORD, is(false));
+ }
+
+ @Test
+ public void shouldRecordTopFiveStatistics() {
+ if (!ContributionStatistics.RECORD) return;
+ for (int j = 0; j != 10; ++j) {
+ for (int i = 0; i != j; ++i)
+ ContributionStatistics.record(i, 1);
+ }
+ List<ContributionStatistics.Data> topData = ContributionStatistics.getTop(5);
+ for (ContributionStatistics.Data data : topData) {
+ System.out.println(data);
+ }
+ assertThat(topData.size(), is(5));
+ assertThat(topData.get(0).getInstanceCount(), is(9l));
+ assertThat(topData.get(1).getInstanceCount(), is(8l));
+ assertThat(topData.get(2).getInstanceCount(), is(7l));
+ assertThat(topData.get(3).getInstanceCount(), is(6l));
+ assertThat(topData.get(4).getInstanceCount(), is(5l));
+ }
+
+}
Property changes on: trunk/connectors/dna-connector-federation/src/test/java/org/jboss/dna/connector/federation/contribution/ContributionStatisticsTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/connectors/dna-connector-federation/src/test/java/org/jboss/dna/connector/federation/contribution/EmptyContributionTest.java
===================================================================
--- trunk/connectors/dna-connector-federation/src/test/java/org/jboss/dna/connector/federation/contribution/EmptyContributionTest.java (rev 0)
+++ trunk/connectors/dna-connector-federation/src/test/java/org/jboss/dna/connector/federation/contribution/EmptyContributionTest.java 2008-08-04 19:59:20 UTC (rev 377)
@@ -0,0 +1,98 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.dna.connector.federation.contribution;
+
+import static org.hamcrest.core.Is.is;
+import static org.hamcrest.core.IsNull.nullValue;
+import static org.hamcrest.core.IsSame.sameInstance;
+import static org.junit.Assert.assertThat;
+import static org.mockito.Mockito.mock;
+import org.jboss.dna.spi.graph.DateTime;
+import org.jboss.dna.spi.graph.Name;
+import org.jboss.dna.spi.graph.impl.JodaDateTime;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * @author Randall Hauch
+ */
+public class EmptyContributionTest {
+
+ private static final long TWENTY_FOUR_HOURS_IN_MILLISECONDS = 24 * 60 * 60 * 1000;
+ public static final DateTime NOW = new JodaDateTime(System.currentTimeMillis()).toUtcTimeZone();
+ public static final DateTime YESTERDAY = new JodaDateTime(NOW.getMilliseconds() - TWENTY_FOUR_HOURS_IN_MILLISECONDS).toUtcTimeZone();
+ public static final DateTime TOMORROW = new JodaDateTime(NOW.getMilliseconds() + TWENTY_FOUR_HOURS_IN_MILLISECONDS).toUtcTimeZone();
+
+ private String sourceName;
+ private EmptyContribution contribution;
+ private DateTime expiration;
+
+ @Before
+ public void beforeEach() throws Exception {
+ sourceName = "some source";
+ expiration = TOMORROW;
+ contribution = new EmptyContribution(sourceName, expiration);
+ }
+
+ @Test
+ public void shouldAllowNullExpiration() {
+ expiration = null;
+ contribution = new EmptyContribution(sourceName, expiration);
+ assertThat(contribution.getExpirationTimeInUtc(), is(nullValue()));
+ }
+
+ @Test( expected = IllegalArgumentException.class )
+ public void shouldNotAllowExpirationTimeIfNotInUtcTime() {
+ new EmptyContribution(sourceName, new JodaDateTime(System.currentTimeMillis(), "CST"));
+ }
+
+ @Test
+ public void shouldHaveSameExpirationTimeSetInConstructor() {
+ assertThat(contribution.getExpirationTimeInUtc(), is(sameInstance(expiration)));
+ }
+
+ @Test
+ public void shouldHaveSameSourceNameSetInConstructor() {
+ assertThat(contribution.getSourceName(), is(sourceName));
+ }
+
+ @Test
+ public void shouldNotBeExpiredIfExpirationIsInTheFuture() {
+ contribution = new EmptyContribution(sourceName, NOW);
+ assertThat(contribution.isExpired(YESTERDAY), is(false));
+ assertThat(contribution.isExpired(TOMORROW), is(true));
+ }
+
+ @Test
+ public void shouldHaveNoChildren() {
+ assertThat(contribution.getChildrenCount(), is(0));
+ assertThat(contribution.getChildren().hasNext(), is(false));
+ }
+
+ @Test
+ public void shouldHaveNoProperties() {
+ assertThat(contribution.getPropertyCount(), is(0));
+ assertThat(contribution.getProperties().hasNext(), is(false));
+ Name propertyName = mock(Name.class); // doesn't matter what the name instance is
+ assertThat(contribution.getProperty(propertyName), is(nullValue()));
+ }
+}
Property changes on: trunk/connectors/dna-connector-federation/src/test/java/org/jboss/dna/connector/federation/contribution/EmptyContributionTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/connectors/dna-connector-federation/src/test/java/org/jboss/dna/connector/federation/contribution/MultiChildContributionTest.java
===================================================================
--- trunk/connectors/dna-connector-federation/src/test/java/org/jboss/dna/connector/federation/contribution/MultiChildContributionTest.java (rev 0)
+++ trunk/connectors/dna-connector-federation/src/test/java/org/jboss/dna/connector/federation/contribution/MultiChildContributionTest.java 2008-08-04 19:59:20 UTC (rev 377)
@@ -0,0 +1,135 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.dna.connector.federation.contribution;
+
+import static org.hamcrest.core.Is.is;
+import static org.hamcrest.core.IsNull.nullValue;
+import static org.hamcrest.core.IsSame.sameInstance;
+import static org.junit.Assert.assertThat;
+import static org.mockito.Mockito.mock;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import org.jboss.dna.spi.graph.DateTime;
+import org.jboss.dna.spi.graph.Name;
+import org.jboss.dna.spi.graph.Path;
+import org.jboss.dna.spi.graph.Path.Segment;
+import org.jboss.dna.spi.graph.impl.BasicName;
+import org.jboss.dna.spi.graph.impl.BasicPath;
+import org.jboss.dna.spi.graph.impl.BasicPathSegment;
+import org.jboss.dna.spi.graph.impl.JodaDateTime;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * @author Randall Hauch
+ */
+public class MultiChildContributionTest {
+
+ private static final long TWENTY_FOUR_HOURS_IN_MILLISECONDS = 24 * 60 * 60 * 1000;
+ public static final DateTime NOW = new JodaDateTime(System.currentTimeMillis()).toUtcTimeZone();
+ public static final DateTime YESTERDAY = new JodaDateTime(NOW.getMilliseconds() - TWENTY_FOUR_HOURS_IN_MILLISECONDS).toUtcTimeZone();
+ public static final DateTime TOMORROW = new JodaDateTime(NOW.getMilliseconds() + TWENTY_FOUR_HOURS_IN_MILLISECONDS).toUtcTimeZone();
+
+ private String sourceName;
+ private Path pathInSource;
+ private MultiChildContribution contribution;
+ private DateTime expiration;
+ private List<Segment> children;
+ private Segment child1;
+ private Segment child2;
+ private Segment child3;
+
+ @Before
+ public void beforeEach() throws Exception {
+ sourceName = "some source";
+ pathInSource = BasicPath.ROOT;
+ expiration = TOMORROW;
+ String nsUri = "http://www.jboss.org/default";
+ child1 = new BasicPathSegment(new BasicName(nsUri, "child1"));
+ child2 = new BasicPathSegment(new BasicName(nsUri, "child2"));
+ child3 = new BasicPathSegment(new BasicName(nsUri, "child3"));
+ children = Arrays.asList(child1, child2, child3);
+ contribution = new MultiChildContribution(sourceName, pathInSource, expiration, children);
+ }
+
+ @Test
+ public void shouldAllowNullExpiration() {
+ expiration = null;
+ contribution = new MultiChildContribution(sourceName, pathInSource, expiration, children);
+ assertThat(contribution.getExpirationTimeInUtc(), is(nullValue()));
+ }
+
+ @Test( expected = IllegalArgumentException.class )
+ public void shouldNotAllowExpirationTimeIfNotInUtcTime() {
+ expiration = new JodaDateTime(System.currentTimeMillis(), "CST");
+ contribution = new MultiChildContribution(sourceName, pathInSource, expiration, children);
+ }
+
+ @Test( expected = AssertionError.class )
+ public void shouldNotAllowNullChildren() {
+ children = null;
+ contribution = new MultiChildContribution(sourceName, pathInSource, expiration, children);
+ }
+
+ @Test( expected = AssertionError.class )
+ public void shouldNotAllowEmptyChildren() {
+ children = Collections.emptyList();
+ contribution = new MultiChildContribution(sourceName, pathInSource, expiration, children);
+ }
+
+ @Test
+ public void shouldHaveSameExpirationTimeSetInConstructor() {
+ assertThat(contribution.getExpirationTimeInUtc(), is(sameInstance(expiration)));
+ }
+
+ @Test
+ public void shouldHaveSameSourceNameSetInConstructor() {
+ assertThat(contribution.getSourceName(), is(sourceName));
+ }
+
+ @Test
+ public void shouldNotBeExpiredIfExpirationIsInTheFuture() {
+ contribution = new MultiChildContribution(sourceName, pathInSource, NOW, children);
+ assertThat(contribution.isExpired(YESTERDAY), is(false));
+ assertThat(contribution.isExpired(TOMORROW), is(true));
+ }
+
+ @Test
+ public void shouldHaveChildren() {
+ assertThat(contribution.getChildrenCount(), is(3));
+ Iterator<Segment> iter = contribution.getChildren();
+ assertThat(iter.next(), is(child1));
+ assertThat(iter.next(), is(child2));
+ assertThat(iter.next(), is(child3));
+ assertThat(iter.hasNext(), is(false));
+ }
+
+ @Test
+ public void shouldHaveNoProperties() {
+ assertThat(contribution.getPropertyCount(), is(0));
+ assertThat(contribution.getProperties().hasNext(), is(false));
+ Name propertyName = mock(Name.class); // doesn't matter what the name instance is
+ assertThat(contribution.getProperty(propertyName), is(nullValue()));
+ }
+}
Property changes on: trunk/connectors/dna-connector-federation/src/test/java/org/jboss/dna/connector/federation/contribution/MultiChildContributionTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/connectors/dna-connector-federation/src/test/java/org/jboss/dna/connector/federation/contribution/MultiPropertyContributionTest.java
===================================================================
--- trunk/connectors/dna-connector-federation/src/test/java/org/jboss/dna/connector/federation/contribution/MultiPropertyContributionTest.java (rev 0)
+++ trunk/connectors/dna-connector-federation/src/test/java/org/jboss/dna/connector/federation/contribution/MultiPropertyContributionTest.java 2008-08-04 19:59:20 UTC (rev 377)
@@ -0,0 +1,138 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.dna.connector.federation.contribution;
+
+import static org.hamcrest.core.Is.is;
+import static org.hamcrest.core.IsNull.nullValue;
+import static org.hamcrest.core.IsSame.sameInstance;
+import static org.junit.Assert.assertThat;
+import static org.junit.matchers.JUnitMatchers.hasItems;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import org.jboss.dna.spi.graph.DateTime;
+import org.jboss.dna.spi.graph.Path;
+import org.jboss.dna.spi.graph.Property;
+import org.jboss.dna.spi.graph.impl.BasicName;
+import org.jboss.dna.spi.graph.impl.BasicPath;
+import org.jboss.dna.spi.graph.impl.BasicSingleValueProperty;
+import org.jboss.dna.spi.graph.impl.JodaDateTime;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * @author Randall Hauch
+ */
+public class MultiPropertyContributionTest {
+
+ private static final long TWENTY_FOUR_HOURS_IN_MILLISECONDS = 24 * 60 * 60 * 1000;
+ public static final DateTime NOW = new JodaDateTime(System.currentTimeMillis()).toUtcTimeZone();
+ public static final DateTime YESTERDAY = new JodaDateTime(NOW.getMilliseconds() - TWENTY_FOUR_HOURS_IN_MILLISECONDS).toUtcTimeZone();
+ public static final DateTime TOMORROW = new JodaDateTime(NOW.getMilliseconds() + TWENTY_FOUR_HOURS_IN_MILLISECONDS).toUtcTimeZone();
+
+ private String sourceName;
+ private Path pathInSource;
+ private MultiPropertyContribution contribution;
+ private DateTime expiration;
+ private List<Property> properties;
+ private Property property1;
+ private Property property2;
+ private Property property3;
+
+ @Before
+ public void beforeEach() throws Exception {
+ sourceName = "some source";
+ pathInSource = BasicPath.ROOT;
+ expiration = TOMORROW;
+ String nsUri = "http://www.jboss.org/default";
+ property1 = new BasicSingleValueProperty(new BasicName(nsUri, "property1"), "value1");
+ property2 = new BasicSingleValueProperty(new BasicName(nsUri, "property2"), "value2");
+ property3 = new BasicSingleValueProperty(new BasicName(nsUri, "property3"), "value3");
+ properties = Arrays.asList(property1, property2, property3);
+ contribution = new MultiPropertyContribution(sourceName, pathInSource, expiration, properties);
+ }
+
+ @Test
+ public void shouldAllowNullExpiration() {
+ expiration = null;
+ contribution = new MultiPropertyContribution(sourceName, pathInSource, expiration, properties);
+ assertThat(contribution.getExpirationTimeInUtc(), is(nullValue()));
+ }
+
+ @Test( expected = IllegalArgumentException.class )
+ public void shouldNotAllowExpirationTimeIfNotInUtcTime() {
+ expiration = new JodaDateTime(System.currentTimeMillis(), "CST");
+ contribution = new MultiPropertyContribution(sourceName, pathInSource, expiration, properties);
+ }
+
+ @Test( expected = AssertionError.class )
+ public void shouldNotAllowNullProperties() {
+ properties = null;
+ contribution = new MultiPropertyContribution(sourceName, pathInSource, expiration, properties);
+ }
+
+ @Test( expected = AssertionError.class )
+ public void shouldNotAllowEmptyProperties() {
+ properties = Collections.emptyList();
+ contribution = new MultiPropertyContribution(sourceName, pathInSource, expiration, properties);
+ }
+
+ @Test
+ public void shouldHaveSameExpirationTimeSetInConstructor() {
+ assertThat(contribution.getExpirationTimeInUtc(), is(sameInstance(expiration)));
+ }
+
+ @Test
+ public void shouldHaveSameSourceNameSetInConstructor() {
+ assertThat(contribution.getSourceName(), is(sourceName));
+ }
+
+ @Test
+ public void shouldNotBeExpiredIfExpirationIsInTheFuture() {
+ contribution = new MultiPropertyContribution(sourceName, pathInSource, NOW, properties);
+ assertThat(contribution.isExpired(YESTERDAY), is(false));
+ assertThat(contribution.isExpired(TOMORROW), is(true));
+ }
+
+ @Test
+ public void shouldHaveNoChildren() {
+ assertThat(contribution.getChildrenCount(), is(0));
+ assertThat(contribution.getChildren().hasNext(), is(false));
+ }
+
+ @Test
+ public void shouldHaveProperties() {
+ assertThat(contribution.getPropertyCount(), is(3));
+ assertThat(contribution.getProperty(property1.getName()), is(sameInstance(property1)));
+ assertThat(contribution.getProperty(property2.getName()), is(sameInstance(property2)));
+ assertThat(contribution.getProperty(property3.getName()), is(sameInstance(property3)));
+ assertThat(contribution.getProperty(new BasicName("http://www.jboss.org/x", "propertyX")), is(nullValue()));
+ List<Property> properties = new ArrayList<Property>();
+ for (Iterator<Property> iter = contribution.getProperties(); iter.hasNext();) {
+ properties.add(iter.next());
+ }
+ assertThat(properties, hasItems(property1, property2, property3));
+ }
+
+}
Property changes on: trunk/connectors/dna-connector-federation/src/test/java/org/jboss/dna/connector/federation/contribution/MultiPropertyContributionTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/connectors/dna-connector-federation/src/test/java/org/jboss/dna/connector/federation/contribution/NodeContributionTest.java
===================================================================
--- trunk/connectors/dna-connector-federation/src/test/java/org/jboss/dna/connector/federation/contribution/NodeContributionTest.java (rev 0)
+++ trunk/connectors/dna-connector-federation/src/test/java/org/jboss/dna/connector/federation/contribution/NodeContributionTest.java 2008-08-04 19:59:20 UTC (rev 377)
@@ -0,0 +1,164 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.dna.connector.federation.contribution;
+
+import static org.hamcrest.core.Is.is;
+import static org.hamcrest.core.IsNull.nullValue;
+import static org.hamcrest.core.IsSame.sameInstance;
+import static org.junit.Assert.assertThat;
+import static org.junit.matchers.JUnitMatchers.hasItems;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import org.jboss.dna.spi.graph.DateTime;
+import org.jboss.dna.spi.graph.Path;
+import org.jboss.dna.spi.graph.Property;
+import org.jboss.dna.spi.graph.Path.Segment;
+import org.jboss.dna.spi.graph.impl.BasicName;
+import org.jboss.dna.spi.graph.impl.BasicPath;
+import org.jboss.dna.spi.graph.impl.BasicPathSegment;
+import org.jboss.dna.spi.graph.impl.BasicSingleValueProperty;
+import org.jboss.dna.spi.graph.impl.JodaDateTime;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * @author Randall Hauch
+ */
+public class NodeContributionTest {
+
+ private static final long TWENTY_FOUR_HOURS_IN_MILLISECONDS = 24 * 60 * 60 * 1000;
+ public static final DateTime NOW = new JodaDateTime(System.currentTimeMillis()).toUtcTimeZone();
+ public static final DateTime YESTERDAY = new JodaDateTime(NOW.getMilliseconds() - TWENTY_FOUR_HOURS_IN_MILLISECONDS).toUtcTimeZone();
+ public static final DateTime TOMORROW = new JodaDateTime(NOW.getMilliseconds() + TWENTY_FOUR_HOURS_IN_MILLISECONDS).toUtcTimeZone();
+
+ private String sourceName;
+ private Path pathInSource;
+ private NodeContribution contribution;
+ private DateTime expiration;
+ private List<Property> properties;
+ private Property property1;
+ private Property property2;
+ private Property property3;
+ private List<Segment> children;
+ private Segment child1;
+ private Segment child2;
+ private Segment child3;
+
+ @Before
+ public void beforeEach() throws Exception {
+ sourceName = "some source";
+ pathInSource = BasicPath.ROOT;
+ expiration = TOMORROW;
+ String nsUri = "http://www.jboss.org/default";
+ property1 = new BasicSingleValueProperty(new BasicName(nsUri, "property1"), "value1");
+ property2 = new BasicSingleValueProperty(new BasicName(nsUri, "property2"), "value2");
+ property3 = new BasicSingleValueProperty(new BasicName(nsUri, "property3"), "value3");
+ properties = Arrays.asList(property1, property2, property3);
+ child1 = new BasicPathSegment(new BasicName(nsUri, "child1"));
+ child2 = new BasicPathSegment(new BasicName(nsUri, "child2"));
+ child3 = new BasicPathSegment(new BasicName(nsUri, "child3"));
+ children = Arrays.asList(child1, child2, child3);
+ contribution = new NodeContribution(sourceName, pathInSource, expiration, properties, children);
+ }
+
+ @Test
+ public void shouldAllowNullExpiration() {
+ expiration = null;
+ contribution = new NodeContribution(sourceName, pathInSource, expiration, properties, children);
+ assertThat(contribution.getExpirationTimeInUtc(), is(nullValue()));
+ }
+
+ @Test( expected = IllegalArgumentException.class )
+ public void shouldNotAllowExpirationTimeIfNotInUtcTime() {
+ expiration = new JodaDateTime(System.currentTimeMillis(), "CST");
+ contribution = new NodeContribution(sourceName, pathInSource, expiration, properties, children);
+ }
+
+ @Test( expected = AssertionError.class )
+ public void shouldNotAllowNullProperties() {
+ properties = null;
+ contribution = new NodeContribution(sourceName, pathInSource, expiration, properties, children);
+ }
+
+ @Test( expected = AssertionError.class )
+ public void shouldNotAllowEmptyProperties() {
+ properties = Collections.emptyList();
+ contribution = new NodeContribution(sourceName, pathInSource, expiration, properties, children);
+ }
+
+ @Test( expected = AssertionError.class )
+ public void shouldNotAllowNullChildren() {
+ children = null;
+ contribution = new NodeContribution(sourceName, pathInSource, expiration, properties, children);
+ }
+
+ @Test( expected = AssertionError.class )
+ public void shouldNotAllowEmptyChildren() {
+ children = Collections.emptyList();
+ contribution = new NodeContribution(sourceName, pathInSource, expiration, properties, children);
+ }
+
+ @Test
+ public void shouldHaveSameExpirationTimeSetInConstructor() {
+ assertThat(contribution.getExpirationTimeInUtc(), is(sameInstance(expiration)));
+ }
+
+ @Test
+ public void shouldHaveSameSourceNameSetInConstructor() {
+ assertThat(contribution.getSourceName(), is(sourceName));
+ }
+
+ @Test
+ public void shouldNotBeExpiredIfExpirationIsInTheFuture() {
+ contribution = new NodeContribution(sourceName, pathInSource, NOW, properties, children);
+ assertThat(contribution.isExpired(YESTERDAY), is(false));
+ assertThat(contribution.isExpired(TOMORROW), is(true));
+ }
+
+ @Test
+ public void shouldHaveChildren() {
+ assertThat(contribution.getChildrenCount(), is(3));
+ Iterator<Segment> iter = contribution.getChildren();
+ assertThat(iter.next(), is(child1));
+ assertThat(iter.next(), is(child2));
+ assertThat(iter.next(), is(child3));
+ assertThat(iter.hasNext(), is(false));
+ }
+
+ @Test
+ public void shouldHaveProperties() {
+ assertThat(contribution.getPropertyCount(), is(3));
+ assertThat(contribution.getProperty(property1.getName()), is(sameInstance(property1)));
+ assertThat(contribution.getProperty(property2.getName()), is(sameInstance(property2)));
+ assertThat(contribution.getProperty(property3.getName()), is(sameInstance(property3)));
+ assertThat(contribution.getProperty(new BasicName("http://www.jboss.org/x", "propertyX")), is(nullValue()));
+ List<Property> properties = new ArrayList<Property>();
+ for (Iterator<Property> iter = contribution.getProperties(); iter.hasNext();) {
+ properties.add(iter.next());
+ }
+ assertThat(properties, hasItems(property1, property2, property3));
+ }
+
+}
Property changes on: trunk/connectors/dna-connector-federation/src/test/java/org/jboss/dna/connector/federation/contribution/NodeContributionTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/connectors/dna-connector-federation/src/test/java/org/jboss/dna/connector/federation/contribution/OneChildContributionTest.java
===================================================================
--- trunk/connectors/dna-connector-federation/src/test/java/org/jboss/dna/connector/federation/contribution/OneChildContributionTest.java (rev 0)
+++ trunk/connectors/dna-connector-federation/src/test/java/org/jboss/dna/connector/federation/contribution/OneChildContributionTest.java 2008-08-04 19:59:20 UTC (rev 377)
@@ -0,0 +1,118 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.dna.connector.federation.contribution;
+
+import static org.hamcrest.core.Is.is;
+import static org.hamcrest.core.IsNull.nullValue;
+import static org.hamcrest.core.IsSame.sameInstance;
+import static org.junit.Assert.assertThat;
+import static org.mockito.Mockito.mock;
+import java.util.Iterator;
+import org.jboss.dna.spi.graph.DateTime;
+import org.jboss.dna.spi.graph.Name;
+import org.jboss.dna.spi.graph.Path;
+import org.jboss.dna.spi.graph.Path.Segment;
+import org.jboss.dna.spi.graph.impl.BasicName;
+import org.jboss.dna.spi.graph.impl.BasicPath;
+import org.jboss.dna.spi.graph.impl.BasicPathSegment;
+import org.jboss.dna.spi.graph.impl.JodaDateTime;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * @author Randall Hauch
+ */
+public class OneChildContributionTest {
+
+ private static final long TWENTY_FOUR_HOURS_IN_MILLISECONDS = 24 * 60 * 60 * 1000;
+ public static final DateTime NOW = new JodaDateTime(System.currentTimeMillis()).toUtcTimeZone();
+ public static final DateTime YESTERDAY = new JodaDateTime(NOW.getMilliseconds() - TWENTY_FOUR_HOURS_IN_MILLISECONDS).toUtcTimeZone();
+ public static final DateTime TOMORROW = new JodaDateTime(NOW.getMilliseconds() + TWENTY_FOUR_HOURS_IN_MILLISECONDS).toUtcTimeZone();
+
+ private String sourceName;
+ private Path pathInSource;
+ private OneChildContribution contribution;
+ private DateTime expiration;
+ private Segment child1;
+
+ @Before
+ public void beforeEach() throws Exception {
+ sourceName = "some source";
+ pathInSource = BasicPath.ROOT;
+ expiration = TOMORROW;
+ String nsUri = "http://www.jboss.org/default";
+ child1 = new BasicPathSegment(new BasicName(nsUri, "child1"));
+ contribution = new OneChildContribution(sourceName, pathInSource, expiration, child1);
+ }
+
+ @Test
+ public void shouldAllowNullExpiration() {
+ expiration = null;
+ contribution = new OneChildContribution(sourceName, pathInSource, expiration, child1);
+ assertThat(contribution.getExpirationTimeInUtc(), is(nullValue()));
+ }
+
+ @Test( expected = IllegalArgumentException.class )
+ public void shouldNotAllowExpirationTimeIfNotInUtcTime() {
+ expiration = new JodaDateTime(System.currentTimeMillis(), "CST");
+ contribution = new OneChildContribution(sourceName, pathInSource, expiration, child1);
+ }
+
+ @Test( expected = AssertionError.class )
+ public void shouldNotAllowNullChildren() {
+ child1 = null;
+ contribution = new OneChildContribution(sourceName, pathInSource, expiration, child1);
+ }
+
+ @Test
+ public void shouldHaveSameExpirationTimeSetInConstructor() {
+ assertThat(contribution.getExpirationTimeInUtc(), is(sameInstance(expiration)));
+ }
+
+ @Test
+ public void shouldHaveSameSourceNameSetInConstructor() {
+ assertThat(contribution.getSourceName(), is(sourceName));
+ }
+
+ @Test
+ public void shouldNotBeExpiredIfExpirationIsInTheFuture() {
+ contribution = new OneChildContribution(sourceName, pathInSource, NOW, child1);
+ assertThat(contribution.isExpired(YESTERDAY), is(false));
+ assertThat(contribution.isExpired(TOMORROW), is(true));
+ }
+
+ @Test
+ public void shouldHaveChildren() {
+ assertThat(contribution.getChildrenCount(), is(1));
+ Iterator<Segment> iter = contribution.getChildren();
+ assertThat(iter.next(), is(child1));
+ assertThat(iter.hasNext(), is(false));
+ }
+
+ @Test
+ public void shouldHaveNoProperties() {
+ assertThat(contribution.getPropertyCount(), is(0));
+ assertThat(contribution.getProperties().hasNext(), is(false));
+ Name propertyName = mock(Name.class); // doesn't matter what the name instance is
+ assertThat(contribution.getProperty(propertyName), is(nullValue()));
+ }
+}
Property changes on: trunk/connectors/dna-connector-federation/src/test/java/org/jboss/dna/connector/federation/contribution/OneChildContributionTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/connectors/dna-connector-federation/src/test/java/org/jboss/dna/connector/federation/contribution/OnePropertyContributionTest.java
===================================================================
--- trunk/connectors/dna-connector-federation/src/test/java/org/jboss/dna/connector/federation/contribution/OnePropertyContributionTest.java (rev 0)
+++ trunk/connectors/dna-connector-federation/src/test/java/org/jboss/dna/connector/federation/contribution/OnePropertyContributionTest.java 2008-08-04 19:59:20 UTC (rev 377)
@@ -0,0 +1,122 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.dna.connector.federation.contribution;
+
+import static org.hamcrest.core.Is.is;
+import static org.hamcrest.core.IsNull.nullValue;
+import static org.hamcrest.core.IsSame.sameInstance;
+import static org.junit.Assert.assertThat;
+import static org.junit.matchers.JUnitMatchers.hasItems;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import org.jboss.dna.spi.graph.DateTime;
+import org.jboss.dna.spi.graph.Path;
+import org.jboss.dna.spi.graph.Property;
+import org.jboss.dna.spi.graph.impl.BasicName;
+import org.jboss.dna.spi.graph.impl.BasicPath;
+import org.jboss.dna.spi.graph.impl.BasicSingleValueProperty;
+import org.jboss.dna.spi.graph.impl.JodaDateTime;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * @author Randall Hauch
+ */
+public class OnePropertyContributionTest {
+
+ private static final long TWENTY_FOUR_HOURS_IN_MILLISECONDS = 24 * 60 * 60 * 1000;
+ public static final DateTime NOW = new JodaDateTime(System.currentTimeMillis()).toUtcTimeZone();
+ public static final DateTime YESTERDAY = new JodaDateTime(NOW.getMilliseconds() - TWENTY_FOUR_HOURS_IN_MILLISECONDS).toUtcTimeZone();
+ public static final DateTime TOMORROW = new JodaDateTime(NOW.getMilliseconds() + TWENTY_FOUR_HOURS_IN_MILLISECONDS).toUtcTimeZone();
+
+ private String sourceName;
+ private Path pathInSource;
+ private OnePropertyContribution contribution;
+ private DateTime expiration;
+ private Property property1;
+
+ @Before
+ public void beforeEach() throws Exception {
+ sourceName = "some source";
+ pathInSource = BasicPath.ROOT;
+ expiration = TOMORROW;
+ String nsUri = "http://www.jboss.org/default";
+ property1 = new BasicSingleValueProperty(new BasicName(nsUri, "property1"), "value1");
+ contribution = new OnePropertyContribution(sourceName, pathInSource, expiration, property1);
+ }
+
+ @Test
+ public void shouldAllowNullExpiration() {
+ expiration = null;
+ contribution = new OnePropertyContribution(sourceName, pathInSource, expiration, property1);
+ assertThat(contribution.getExpirationTimeInUtc(), is(nullValue()));
+ }
+
+ @Test( expected = IllegalArgumentException.class )
+ public void shouldNotAllowExpirationTimeIfNotInUtcTime() {
+ expiration = new JodaDateTime(System.currentTimeMillis(), "CST");
+ contribution = new OnePropertyContribution(sourceName, pathInSource, expiration, property1);
+ }
+
+ @Test( expected = AssertionError.class )
+ public void shouldNotAllowNullFirstProperty() {
+ property1 = null;
+ contribution = new OnePropertyContribution(sourceName, pathInSource, expiration, property1);
+ }
+
+ @Test
+ public void shouldHaveSameExpirationTimeSetInConstructor() {
+ assertThat(contribution.getExpirationTimeInUtc(), is(sameInstance(expiration)));
+ }
+
+ @Test
+ public void shouldHaveSameSourceNameSetInConstructor() {
+ assertThat(contribution.getSourceName(), is(sourceName));
+ }
+
+ @Test
+ public void shouldNotBeExpiredIfExpirationIsInTheFuture() {
+ contribution = new OnePropertyContribution(sourceName, pathInSource, NOW, property1);
+ assertThat(contribution.isExpired(YESTERDAY), is(false));
+ assertThat(contribution.isExpired(TOMORROW), is(true));
+ }
+
+ @Test
+ public void shouldHaveNoChildren() {
+ assertThat(contribution.getChildrenCount(), is(0));
+ assertThat(contribution.getChildren().hasNext(), is(false));
+ }
+
+ @Test
+ public void shouldHaveProperties() {
+ assertThat(contribution.getPropertyCount(), is(1));
+ assertThat(contribution.getProperty(property1.getName()), is(sameInstance(property1)));
+ assertThat(contribution.getProperty(new BasicName("http://www.jboss.org/x", "propertyX")), is(nullValue()));
+ List<Property> properties = new ArrayList<Property>();
+ for (Iterator<Property> iter = contribution.getProperties(); iter.hasNext();) {
+ properties.add(iter.next());
+ }
+ assertThat(properties, hasItems(property1));
+ }
+
+}
Property changes on: trunk/connectors/dna-connector-federation/src/test/java/org/jboss/dna/connector/federation/contribution/OnePropertyContributionTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/connectors/dna-connector-federation/src/test/java/org/jboss/dna/connector/federation/contribution/ThreePropertyContributionTest.java
===================================================================
--- trunk/connectors/dna-connector-federation/src/test/java/org/jboss/dna/connector/federation/contribution/ThreePropertyContributionTest.java (rev 0)
+++ trunk/connectors/dna-connector-federation/src/test/java/org/jboss/dna/connector/federation/contribution/ThreePropertyContributionTest.java 2008-08-04 19:59:20 UTC (rev 377)
@@ -0,0 +1,140 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.dna.connector.federation.contribution;
+
+import static org.hamcrest.core.Is.is;
+import static org.hamcrest.core.IsNull.nullValue;
+import static org.hamcrest.core.IsSame.sameInstance;
+import static org.junit.Assert.assertThat;
+import static org.junit.matchers.JUnitMatchers.hasItems;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import org.jboss.dna.spi.graph.DateTime;
+import org.jboss.dna.spi.graph.Path;
+import org.jboss.dna.spi.graph.Property;
+import org.jboss.dna.spi.graph.impl.BasicName;
+import org.jboss.dna.spi.graph.impl.BasicPath;
+import org.jboss.dna.spi.graph.impl.BasicSingleValueProperty;
+import org.jboss.dna.spi.graph.impl.JodaDateTime;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * @author Randall Hauch
+ */
+public class ThreePropertyContributionTest {
+
+ private static final long TWENTY_FOUR_HOURS_IN_MILLISECONDS = 24 * 60 * 60 * 1000;
+ public static final DateTime NOW = new JodaDateTime(System.currentTimeMillis()).toUtcTimeZone();
+ public static final DateTime YESTERDAY = new JodaDateTime(NOW.getMilliseconds() - TWENTY_FOUR_HOURS_IN_MILLISECONDS).toUtcTimeZone();
+ public static final DateTime TOMORROW = new JodaDateTime(NOW.getMilliseconds() + TWENTY_FOUR_HOURS_IN_MILLISECONDS).toUtcTimeZone();
+
+ private String sourceName;
+ private Path pathInSource;
+ private ThreePropertyContribution contribution;
+ private DateTime expiration;
+ private Property property1;
+ private Property property2;
+ private Property property3;
+
+ @Before
+ public void beforeEach() throws Exception {
+ sourceName = "some source";
+ pathInSource = BasicPath.ROOT;
+ expiration = TOMORROW;
+ String nsUri = "http://www.jboss.org/default";
+ property1 = new BasicSingleValueProperty(new BasicName(nsUri, "property1"), "value1");
+ property2 = new BasicSingleValueProperty(new BasicName(nsUri, "property2"), "value2");
+ property3 = new BasicSingleValueProperty(new BasicName(nsUri, "property3"), "value3");
+ contribution = new ThreePropertyContribution(sourceName, pathInSource, expiration, property1, property2, property3);
+ }
+
+ @Test
+ public void shouldAllowNullExpiration() {
+ expiration = null;
+ contribution = new ThreePropertyContribution(sourceName, pathInSource, expiration, property1, property2, property3);
+ assertThat(contribution.getExpirationTimeInUtc(), is(nullValue()));
+ }
+
+ @Test( expected = IllegalArgumentException.class )
+ public void shouldNotAllowExpirationTimeIfNotInUtcTime() {
+ expiration = new JodaDateTime(System.currentTimeMillis(), "CST");
+ contribution = new ThreePropertyContribution(sourceName, pathInSource, expiration, property1, property2, property3);
+ }
+
+ @Test( expected = AssertionError.class )
+ public void shouldNotAllowNullFirstProperty() {
+ property1 = null;
+ contribution = new ThreePropertyContribution(sourceName, pathInSource, expiration, property1, property2, property3);
+ }
+
+ @Test( expected = AssertionError.class )
+ public void shouldNotAllowNullSecondProperty() {
+ property2 = null;
+ contribution = new ThreePropertyContribution(sourceName, pathInSource, expiration, property1, property2, property3);
+ }
+
+ @Test( expected = AssertionError.class )
+ public void shouldNotAllowNullThirdProperty() {
+ property3 = null;
+ contribution = new ThreePropertyContribution(sourceName, pathInSource, expiration, property1, property2, property3);
+ }
+
+ @Test
+ public void shouldHaveSameExpirationTimeSetInConstructor() {
+ assertThat(contribution.getExpirationTimeInUtc(), is(sameInstance(expiration)));
+ }
+
+ @Test
+ public void shouldHaveSameSourceNameSetInConstructor() {
+ assertThat(contribution.getSourceName(), is(sourceName));
+ }
+
+ @Test
+ public void shouldNotBeExpiredIfExpirationIsInTheFuture() {
+ contribution = new ThreePropertyContribution(sourceName, pathInSource, NOW, property1, property2, property3);
+ assertThat(contribution.isExpired(YESTERDAY), is(false));
+ assertThat(contribution.isExpired(TOMORROW), is(true));
+ }
+
+ @Test
+ public void shouldHaveNoChildren() {
+ assertThat(contribution.getChildrenCount(), is(0));
+ assertThat(contribution.getChildren().hasNext(), is(false));
+ }
+
+ @Test
+ public void shouldHaveProperties() {
+ assertThat(contribution.getPropertyCount(), is(3));
+ assertThat(contribution.getProperty(property1.getName()), is(sameInstance(property1)));
+ assertThat(contribution.getProperty(property2.getName()), is(sameInstance(property2)));
+ assertThat(contribution.getProperty(property3.getName()), is(sameInstance(property3)));
+ assertThat(contribution.getProperty(new BasicName("http://www.jboss.org/x", "propertyX")), is(nullValue()));
+ List<Property> properties = new ArrayList<Property>();
+ for (Iterator<Property> iter = contribution.getProperties(); iter.hasNext();) {
+ properties.add(iter.next());
+ }
+ assertThat(properties, hasItems(property1, property2, property3));
+ }
+
+}
Property changes on: trunk/connectors/dna-connector-federation/src/test/java/org/jboss/dna/connector/federation/contribution/ThreePropertyContributionTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/connectors/dna-connector-federation/src/test/java/org/jboss/dna/connector/federation/contribution/TwoChildContributionTest.java
===================================================================
--- trunk/connectors/dna-connector-federation/src/test/java/org/jboss/dna/connector/federation/contribution/TwoChildContributionTest.java (rev 0)
+++ trunk/connectors/dna-connector-federation/src/test/java/org/jboss/dna/connector/federation/contribution/TwoChildContributionTest.java 2008-08-04 19:59:20 UTC (rev 377)
@@ -0,0 +1,127 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.dna.connector.federation.contribution;
+
+import static org.hamcrest.core.Is.is;
+import static org.hamcrest.core.IsNull.nullValue;
+import static org.hamcrest.core.IsSame.sameInstance;
+import static org.junit.Assert.assertThat;
+import static org.mockito.Mockito.mock;
+import java.util.Iterator;
+import org.jboss.dna.spi.graph.DateTime;
+import org.jboss.dna.spi.graph.Name;
+import org.jboss.dna.spi.graph.Path;
+import org.jboss.dna.spi.graph.Path.Segment;
+import org.jboss.dna.spi.graph.impl.BasicName;
+import org.jboss.dna.spi.graph.impl.BasicPath;
+import org.jboss.dna.spi.graph.impl.BasicPathSegment;
+import org.jboss.dna.spi.graph.impl.JodaDateTime;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * @author Randall Hauch
+ */
+public class TwoChildContributionTest {
+
+ private static final long TWENTY_FOUR_HOURS_IN_MILLISECONDS = 24 * 60 * 60 * 1000;
+ public static final DateTime NOW = new JodaDateTime(System.currentTimeMillis()).toUtcTimeZone();
+ public static final DateTime YESTERDAY = new JodaDateTime(NOW.getMilliseconds() - TWENTY_FOUR_HOURS_IN_MILLISECONDS).toUtcTimeZone();
+ public static final DateTime TOMORROW = new JodaDateTime(NOW.getMilliseconds() + TWENTY_FOUR_HOURS_IN_MILLISECONDS).toUtcTimeZone();
+
+ private String sourceName;
+ private Path pathInSource;
+ private TwoChildContribution contribution;
+ private DateTime expiration;
+ private Segment child1;
+ private Segment child2;
+
+ @Before
+ public void beforeEach() throws Exception {
+ sourceName = "some source";
+ pathInSource = BasicPath.ROOT;
+ expiration = TOMORROW;
+ String nsUri = "http://www.jboss.org/default";
+ child1 = new BasicPathSegment(new BasicName(nsUri, "child1"));
+ child2 = new BasicPathSegment(new BasicName(nsUri, "child1"));
+ contribution = new TwoChildContribution(sourceName, pathInSource, expiration, child1, child2);
+ }
+
+ @Test
+ public void shouldAllowNullExpiration() {
+ expiration = null;
+ contribution = new TwoChildContribution(sourceName, pathInSource, expiration, child1, child2);
+ assertThat(contribution.getExpirationTimeInUtc(), is(nullValue()));
+ }
+
+ @Test( expected = IllegalArgumentException.class )
+ public void shouldNotAllowExpirationTimeIfNotInUtcTime() {
+ expiration = new JodaDateTime(System.currentTimeMillis(), "CST");
+ contribution = new TwoChildContribution(sourceName, pathInSource, expiration, child1, child2);
+ }
+
+ @Test( expected = AssertionError.class )
+ public void shouldNotAllowNullFirstChild() {
+ child1 = null;
+ contribution = new TwoChildContribution(sourceName, pathInSource, expiration, child1, child2);
+ }
+
+ @Test( expected = AssertionError.class )
+ public void shouldNotAllowNullSecondChild() {
+ child2 = null;
+ contribution = new TwoChildContribution(sourceName, pathInSource, expiration, child1, child2);
+ }
+
+ @Test
+ public void shouldHaveSameExpirationTimeSetInConstructor() {
+ assertThat(contribution.getExpirationTimeInUtc(), is(sameInstance(expiration)));
+ }
+
+ @Test
+ public void shouldHaveSameSourceNameSetInConstructor() {
+ assertThat(contribution.getSourceName(), is(sourceName));
+ }
+
+ @Test
+ public void shouldNotBeExpiredIfExpirationIsInTheFuture() {
+ contribution = new TwoChildContribution(sourceName, pathInSource, NOW, child1, child2);
+ assertThat(contribution.isExpired(YESTERDAY), is(false));
+ assertThat(contribution.isExpired(TOMORROW), is(true));
+ }
+
+ @Test
+ public void shouldHaveChildren() {
+ assertThat(contribution.getChildrenCount(), is(2));
+ Iterator<Segment> iter = contribution.getChildren();
+ assertThat(iter.next(), is(child1));
+ assertThat(iter.next(), is(child2));
+ assertThat(iter.hasNext(), is(false));
+ }
+
+ @Test
+ public void shouldHaveNoProperties() {
+ assertThat(contribution.getPropertyCount(), is(0));
+ assertThat(contribution.getProperties().hasNext(), is(false));
+ Name propertyName = mock(Name.class); // doesn't matter what the name instance is
+ assertThat(contribution.getProperty(propertyName), is(nullValue()));
+ }
+}
Property changes on: trunk/connectors/dna-connector-federation/src/test/java/org/jboss/dna/connector/federation/contribution/TwoChildContributionTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/connectors/dna-connector-federation/src/test/java/org/jboss/dna/connector/federation/contribution/TwoPropertyContributionTest.java
===================================================================
--- trunk/connectors/dna-connector-federation/src/test/java/org/jboss/dna/connector/federation/contribution/TwoPropertyContributionTest.java (rev 0)
+++ trunk/connectors/dna-connector-federation/src/test/java/org/jboss/dna/connector/federation/contribution/TwoPropertyContributionTest.java 2008-08-04 19:59:20 UTC (rev 377)
@@ -0,0 +1,131 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.dna.connector.federation.contribution;
+
+import static org.hamcrest.core.Is.is;
+import static org.hamcrest.core.IsNull.nullValue;
+import static org.hamcrest.core.IsSame.sameInstance;
+import static org.junit.Assert.assertThat;
+import static org.junit.matchers.JUnitMatchers.hasItems;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import org.jboss.dna.spi.graph.DateTime;
+import org.jboss.dna.spi.graph.Path;
+import org.jboss.dna.spi.graph.Property;
+import org.jboss.dna.spi.graph.impl.BasicName;
+import org.jboss.dna.spi.graph.impl.BasicPath;
+import org.jboss.dna.spi.graph.impl.BasicSingleValueProperty;
+import org.jboss.dna.spi.graph.impl.JodaDateTime;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * @author Randall Hauch
+ */
+public class TwoPropertyContributionTest {
+
+ private static final long TWENTY_FOUR_HOURS_IN_MILLISECONDS = 24 * 60 * 60 * 1000;
+ public static final DateTime NOW = new JodaDateTime(System.currentTimeMillis()).toUtcTimeZone();
+ public static final DateTime YESTERDAY = new JodaDateTime(NOW.getMilliseconds() - TWENTY_FOUR_HOURS_IN_MILLISECONDS).toUtcTimeZone();
+ public static final DateTime TOMORROW = new JodaDateTime(NOW.getMilliseconds() + TWENTY_FOUR_HOURS_IN_MILLISECONDS).toUtcTimeZone();
+
+ private String sourceName;
+ private Path pathInSource;
+ private TwoPropertyContribution contribution;
+ private DateTime expiration;
+ private Property property1;
+ private Property property2;
+
+ @Before
+ public void beforeEach() throws Exception {
+ sourceName = "some source";
+ pathInSource = BasicPath.ROOT;
+ expiration = TOMORROW;
+ String nsUri = "http://www.jboss.org/default";
+ property1 = new BasicSingleValueProperty(new BasicName(nsUri, "property1"), "value1");
+ property2 = new BasicSingleValueProperty(new BasicName(nsUri, "property2"), "value2");
+ contribution = new TwoPropertyContribution(sourceName, pathInSource, expiration, property1, property2);
+ }
+
+ @Test
+ public void shouldAllowNullExpiration() {
+ expiration = null;
+ contribution = new TwoPropertyContribution(sourceName, pathInSource, expiration, property1, property2);
+ assertThat(contribution.getExpirationTimeInUtc(), is(nullValue()));
+ }
+
+ @Test( expected = IllegalArgumentException.class )
+ public void shouldNotAllowExpirationTimeIfNotInUtcTime() {
+ expiration = new JodaDateTime(System.currentTimeMillis(), "CST");
+ contribution = new TwoPropertyContribution(sourceName, pathInSource, expiration, property1, property2);
+ }
+
+ @Test( expected = AssertionError.class )
+ public void shouldNotAllowNullFirstProperty() {
+ property1 = null;
+ contribution = new TwoPropertyContribution(sourceName, pathInSource, expiration, property1, property2);
+ }
+
+ @Test( expected = AssertionError.class )
+ public void shouldNotAllowNullSecondProperty() {
+ property2 = null;
+ contribution = new TwoPropertyContribution(sourceName, pathInSource, expiration, property1, property2);
+ }
+
+ @Test
+ public void shouldHaveSameExpirationTimeSetInConstructor() {
+ assertThat(contribution.getExpirationTimeInUtc(), is(sameInstance(expiration)));
+ }
+
+ @Test
+ public void shouldHaveSameSourceNameSetInConstructor() {
+ assertThat(contribution.getSourceName(), is(sourceName));
+ }
+
+ @Test
+ public void shouldNotBeExpiredIfExpirationIsInTheFuture() {
+ contribution = new TwoPropertyContribution(sourceName, pathInSource, NOW, property1, property2);
+ assertThat(contribution.isExpired(YESTERDAY), is(false));
+ assertThat(contribution.isExpired(TOMORROW), is(true));
+ }
+
+ @Test
+ public void shouldHaveNoChildren() {
+ assertThat(contribution.getChildrenCount(), is(0));
+ assertThat(contribution.getChildren().hasNext(), is(false));
+ }
+
+ @Test
+ public void shouldHaveProperties() {
+ assertThat(contribution.getPropertyCount(), is(2));
+ assertThat(contribution.getProperty(property1.getName()), is(sameInstance(property1)));
+ assertThat(contribution.getProperty(property2.getName()), is(sameInstance(property2)));
+ assertThat(contribution.getProperty(new BasicName("http://www.jboss.org/x", "propertyX")), is(nullValue()));
+ List<Property> properties = new ArrayList<Property>();
+ for (Iterator<Property> iter = contribution.getProperties(); iter.hasNext();) {
+ properties.add(iter.next());
+ }
+ assertThat(properties, hasItems(property1, property2));
+ }
+
+}
Property changes on: trunk/connectors/dna-connector-federation/src/test/java/org/jboss/dna/connector/federation/contribution/TwoPropertyContributionTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/dna-repository/src/main/java/org/jboss/dna/repository/RepositoryService.java
===================================================================
--- trunk/dna-repository/src/main/java/org/jboss/dna/repository/RepositoryService.java 2008-07-29 21:15:51 UTC (rev 376)
+++ trunk/dna-repository/src/main/java/org/jboss/dna/repository/RepositoryService.java 2008-08-04 19:59:20 UTC (rev 377)
@@ -215,7 +215,7 @@
executor = new NoOpCommandExecutor(context, configurationSourceName);
} else {
// The configuration repository has more than one projection, so we need to merge the results
- executor = new FederatingCommandExecutor(context, configurationSourceName, null, projections, sources);
+ executor = new FederatingCommandExecutor(context, configurationSourceName, projections, sources);
}
// Read the configuration and the repository sources, located as child nodes/branches under "/dna:sources",
Modified: trunk/dna-spi/src/main/java/org/jboss/dna/spi/cache/BasicCachePolicy.java
===================================================================
--- trunk/dna-spi/src/main/java/org/jboss/dna/spi/cache/BasicCachePolicy.java 2008-07-29 21:15:51 UTC (rev 376)
+++ trunk/dna-spi/src/main/java/org/jboss/dna/spi/cache/BasicCachePolicy.java 2008-08-04 19:59:20 UTC (rev 377)
@@ -27,56 +27,37 @@
public class BasicCachePolicy implements CachePolicy {
private static final long serialVersionUID = 1L;
- private long timeToCache;
- private long timeToExpire;
+ private long timeToLive;
public BasicCachePolicy() {
}
- public BasicCachePolicy( long timeToCache,
- long timeToExpire ) {
- this.timeToCache = timeToCache;
- this.timeToExpire = timeToExpire;
+ public BasicCachePolicy( long timeToCache ) {
+ this.timeToLive = timeToCache;
}
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.spi.cache.CachePolicy#getTimeToCache()
+ * @see org.jboss.dna.spi.cache.CachePolicy#getTimeToLive()
*/
- public long getTimeToCache() {
- return this.timeToCache;
+ public long getTimeToLive() {
+ return this.timeToLive;
}
/**
- * @param timeToCache Sets timeToCache to the specified value.
+ * @param timeToLive Sets timeToLive to the specified value.
*/
- public void setTimeToCache( long timeToCache ) {
- this.timeToCache = timeToCache;
+ public void setTimeToLive( long timeToLive ) {
+ this.timeToLive = timeToLive;
}
- /**
- * {@inheritDoc}
- *
- * @see org.jboss.dna.spi.cache.CachePolicy#getTimeToExpire()
- */
- public long getTimeToExpire() {
- return this.timeToExpire;
- }
-
- /**
- * @param timeToExpire Sets timeToExpire to the specified value.
- */
- public void setTimeToExpire( long timeToExpire ) {
- this.timeToExpire = timeToExpire;
- }
-
public boolean isEmpty() {
- return this.timeToCache == 0 && this.timeToExpire == 0;
+ return this.timeToLive == 0;
}
public CachePolicy getUnmodifiable() {
- return new ImmutableCachePolicy(this.getTimeToCache(), this.getTimeToExpire());
+ return new ImmutableCachePolicy(this.getTimeToLive());
}
}
Modified: trunk/dna-spi/src/main/java/org/jboss/dna/spi/cache/CachePolicy.java
===================================================================
--- trunk/dna-spi/src/main/java/org/jboss/dna/spi/cache/CachePolicy.java 2008-07-29 21:15:51 UTC (rev 376)
+++ trunk/dna-spi/src/main/java/org/jboss/dna/spi/cache/CachePolicy.java 2008-08-04 19:59:20 UTC (rev 377)
@@ -27,6 +27,7 @@
/**
* The specification of how node data is to be cached. The time values provided are relative, allowing the same cache policy
* instance to be shared among multiple {@link Cacheable} objects.
+ *
* @author Randall Hauch
*/
@Immutable
@@ -34,14 +35,9 @@
/**
* Get the system time in milliseconds before which the node data remains valid.
+ *
* @return the number of milliseconds that the cached data should be used before consulting the original source.
*/
- public long getTimeToCache();
+ public long getTimeToLive();
- /**
- * Get the relative time after which the cached data should expire and no longer be used.
- * @return the number of milliseconds until the cached data expires
- */
- public long getTimeToExpire();
-
}
Modified: trunk/dna-spi/src/main/java/org/jboss/dna/spi/cache/ImmutableCachePolicy.java
===================================================================
--- trunk/dna-spi/src/main/java/org/jboss/dna/spi/cache/ImmutableCachePolicy.java 2008-07-29 21:15:51 UTC (rev 376)
+++ trunk/dna-spi/src/main/java/org/jboss/dna/spi/cache/ImmutableCachePolicy.java 2008-08-04 19:59:20 UTC (rev 377)
@@ -28,32 +28,20 @@
private static final long serialVersionUID = 1L;
private final long timeToCache;
- private final long timeToExpire;
- public ImmutableCachePolicy( long timeToCache,
- long timeToExpire ) {
+ public ImmutableCachePolicy( long timeToCache ) {
this.timeToCache = timeToCache;
- this.timeToExpire = timeToExpire;
}
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.spi.cache.CachePolicy#getTimeToCache()
+ * @see org.jboss.dna.spi.cache.CachePolicy#getTimeToLive()
*/
- public long getTimeToCache() {
+ public long getTimeToLive() {
return this.timeToCache;
}
- /**
- * {@inheritDoc}
- *
- * @see org.jboss.dna.spi.cache.CachePolicy#getTimeToExpire()
- */
- public long getTimeToExpire() {
- return this.timeToExpire;
- }
-
public CachePolicy getUnmodifiable() {
return this;
}
Modified: trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/DateTimeFactory.java
===================================================================
--- trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/DateTimeFactory.java 2008-07-29 21:15:51 UTC (rev 376)
+++ trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/DateTimeFactory.java 2008-08-04 19:59:20 UTC (rev 377)
@@ -21,6 +21,7 @@
*/
package org.jboss.dna.spi.graph;
+
/**
* A factory for creating {@link DateTime date-time instants}. This interface extends the {@link ValueFactory} generic interface
* and adds specific methods for creating instants for the current time (and time zone) as well as various combinations of
@@ -117,6 +118,16 @@
DateTime createUtc();
/**
+ * Create a date-time instance that is offset from the original by the specified amount.
+ *
+ * @param original
+ * @param offsetInMillis the offset in milliseconds (positive or negative)
+ * @return the offset date-time instance
+ */
+ DateTime create( DateTime original,
+ long offsetInMillis );
+
+ /**
* Create a date-time instance given the individual values for the fields
*
* @param year the year of the era
Modified: trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/JodaDateTime.java
===================================================================
--- trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/JodaDateTime.java 2008-07-29 21:15:51 UTC (rev 376)
+++ trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/JodaDateTime.java 2008-08-04 19:59:20 UTC (rev 377)
@@ -70,6 +70,11 @@
this.instance = new DateTime(milliseconds, chronology);
}
+ public JodaDateTime( long milliseconds,
+ String timeZoneId ) {
+ this.instance = new DateTime(milliseconds, DateTimeZone.forID(timeZoneId));
+ }
+
public JodaDateTime( DateTimeZone dateTimeZone ) {
this.instance = new DateTime(dateTimeZone);
}
Modified: trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/JodaDateTimeValueFactory.java
===================================================================
--- trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/JodaDateTimeValueFactory.java 2008-07-29 21:15:51 UTC (rev 376)
+++ trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/JodaDateTimeValueFactory.java 2008-08-04 19:59:20 UTC (rev 377)
@@ -260,7 +260,20 @@
/**
* {@inheritDoc}
+ *
+ * @see org.jboss.dna.spi.graph.DateTimeFactory#create(org.jboss.dna.spi.graph.DateTime, long)
*/
+ public DateTime create( DateTime original,
+ long offsetInMillis ) {
+ assert original != null;
+ if (offsetInMillis == 0l) return original;
+ long newMillis = original.getMilliseconds() + offsetInMillis;
+ return new JodaDateTime(newMillis, original.getTimeZoneId());
+ }
+
+ /**
+ * {@inheritDoc}
+ */
@Override
protected DateTime[] createEmptyArray( int length ) {
return new DateTime[length];
15 years, 9 months