DNA SVN: r269 - branches/maeste.
by dna-commits@lists.jboss.org
Author: maeste
Date: 2008-06-11 12:13:44 -0400 (Wed, 11 Jun 2008)
New Revision: 269
Modified:
branches/maeste/
Log:
Removed merge tracking for "svnmerge" for
https://svn.jboss.org/repos/dna/trunk
Property changes on: branches/maeste
___________________________________________________________________
Name: svnmerge-integrated
- /trunk:1-267
17 years, 6 months
DNA SVN: r268 - in branches/maeste: dna-repository/src/main/java/org/jboss/dna/repository and 2 other directories.
by dna-commits@lists.jboss.org
Author: maeste
Date: 2008-06-11 12:12:21 -0400 (Wed, 11 Jun 2008)
New Revision: 268
Modified:
branches/maeste/
branches/maeste/dna-repository/src/main/java/org/jboss/dna/repository/RepositoryI18n.java
branches/maeste/dna-repository/src/main/java/org/jboss/dna/repository/sequencers/xml/XmlSequencer.java
branches/maeste/dna-repository/src/main/resources/org/jboss/dna/repository/RepositoryI18n.properties
Log:
Merged revisions 265-267 via svnmerge from
https://svn.jboss.org/repos/dna/trunk
........
r267 | jverhaeg(a)redhat.com | 2008-06-11 16:39:43 +0200 (Wed, 11 Jun 2008) | 1 line
DNA-123: Changed XML sequencer to add a problem to the monitor everywhere that the logger was used, and changed the i18n messages to be a bit more precise.
........
Property changes on: branches/maeste
___________________________________________________________________
Name: svnmerge-integrated
- /trunk:1-264
+ /trunk:1-267
Modified: branches/maeste/dna-repository/src/main/java/org/jboss/dna/repository/RepositoryI18n.java
===================================================================
--- branches/maeste/dna-repository/src/main/java/org/jboss/dna/repository/RepositoryI18n.java 2008-06-11 14:39:43 UTC (rev 267)
+++ branches/maeste/dna-repository/src/main/java/org/jboss/dna/repository/RepositoryI18n.java 2008-06-11 16:12:21 UTC (rev 268)
@@ -106,8 +106,10 @@
// XML Sequencer
public static I18n errorSequencingXmlDocument;
+ public static I18n fatalErrorSequencingXmlDocument;
public static I18n sequencingXmlDocument;
public static I18n canceledSequencingXmlDocument;
+ public static I18n warningSequencingXmlDocument;
public static I18n interruptedWhileConnectingToFederationConfigurationRepository;
public static I18n interruptedWhileClosingConnectionToFederationConfigurationRepository;
Modified: branches/maeste/dna-repository/src/main/java/org/jboss/dna/repository/sequencers/xml/XmlSequencer.java
===================================================================
--- branches/maeste/dna-repository/src/main/java/org/jboss/dna/repository/sequencers/xml/XmlSequencer.java 2008-06-11 14:39:43 UTC (rev 267)
+++ branches/maeste/dna-repository/src/main/java/org/jboss/dna/repository/sequencers/xml/XmlSequencer.java 2008-06-11 16:12:21 UTC (rev 268)
@@ -105,8 +105,9 @@
reader.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);
// Parse XML document
reader.parse(new InputSource(stream));
- } catch (Exception err) {
- LOGGER.error(err, RepositoryI18n.errorSequencingXmlDocument);
+ } catch (Exception error) {
+ LOGGER.error(error, RepositoryI18n.fatalErrorSequencingXmlDocument, error);
+ monitor.getProblems().addError(error, RepositoryI18n.fatalErrorSequencingXmlDocument, error);
} finally {
monitor.done();
}
@@ -353,7 +354,8 @@
*/
@Override
public void error( SAXParseException error ) {
- LOGGER.error(error, RepositoryI18n.errorSequencingXmlDocument);
+ LOGGER.error(error, RepositoryI18n.errorSequencingXmlDocument, error);
+ monitor.getProblems().addError(error, RepositoryI18n.errorSequencingXmlDocument, error);
}
/**
@@ -388,7 +390,8 @@
*/
@Override
public void fatalError( SAXParseException error ) {
- LOGGER.error(error, RepositoryI18n.errorSequencingXmlDocument);
+ LOGGER.error(error, RepositoryI18n.fatalErrorSequencingXmlDocument);
+ monitor.getProblems().addError(error, RepositoryI18n.fatalErrorSequencingXmlDocument, error);
}
private Name getCommentContentName() {
@@ -684,8 +687,9 @@
* @see org.xml.sax.helpers.DefaultHandler#warning(org.xml.sax.SAXParseException)
*/
@Override
- public void warning( SAXParseException error ) {
- LOGGER.warn(error, RepositoryI18n.errorSequencingXmlDocument);
+ public void warning( SAXParseException warning ) {
+ LOGGER.warn(warning, RepositoryI18n.warningSequencingXmlDocument);
+ monitor.getProblems().addWarning(warning, RepositoryI18n.warningSequencingXmlDocument, warning);
}
}
Modified: branches/maeste/dna-repository/src/main/resources/org/jboss/dna/repository/RepositoryI18n.properties
===================================================================
--- branches/maeste/dna-repository/src/main/resources/org/jboss/dna/repository/RepositoryI18n.properties 2008-06-11 14:39:43 UTC (rev 267)
+++ branches/maeste/dna-repository/src/main/resources/org/jboss/dna/repository/RepositoryI18n.properties 2008-06-11 16:12:21 UTC (rev 268)
@@ -92,9 +92,11 @@
invalidRepositoryNodePath = The repository node path "{0}" is not valid: {1}
-errorSequencingXmlDocument = An error occurred while sequencing XML:
+errorSequencingXmlDocument = An error was received while sequencing XML: {0}
+fatalErrorSequencingXmlDocument = A fatal error was received while sequencing XML: {0}
sequencingXmlDocument = Sequencing XML
canceledSequencingXmlDocument = Canceled sequencing XML
+warningSequencingXmlDocument = A warning was received while sequencing XML: {0}
interruptedWhileConnectingToFederationConfigurationRepository = Interrupted while connecting to federation configuration repository for "{0}" repository
interruptedWhileClosingConnectionToFederationConfigurationRepository = Interrupted while closing connection to federation configuration repository for "{0}" repository
17 years, 6 months
DNA SVN: r267 - in trunk/dna-repository/src/main: java/org/jboss/dna/repository/sequencers/xml and 1 other directories.
by dna-commits@lists.jboss.org
Author: jverhaeg(a)redhat.com
Date: 2008-06-11 10:39:43 -0400 (Wed, 11 Jun 2008)
New Revision: 267
Modified:
trunk/dna-repository/src/main/java/org/jboss/dna/repository/RepositoryI18n.java
trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencers/xml/XmlSequencer.java
trunk/dna-repository/src/main/resources/org/jboss/dna/repository/RepositoryI18n.properties
Log:
DNA-123: Changed XML sequencer to add a problem to the monitor everywhere that the logger was used, and changed the i18n messages to be a bit more precise.
Modified: trunk/dna-repository/src/main/java/org/jboss/dna/repository/RepositoryI18n.java
===================================================================
--- trunk/dna-repository/src/main/java/org/jboss/dna/repository/RepositoryI18n.java 2008-06-11 09:14:08 UTC (rev 266)
+++ trunk/dna-repository/src/main/java/org/jboss/dna/repository/RepositoryI18n.java 2008-06-11 14:39:43 UTC (rev 267)
@@ -106,8 +106,10 @@
// XML Sequencer
public static I18n errorSequencingXmlDocument;
+ public static I18n fatalErrorSequencingXmlDocument;
public static I18n sequencingXmlDocument;
public static I18n canceledSequencingXmlDocument;
+ public static I18n warningSequencingXmlDocument;
public static I18n interruptedWhileConnectingToFederationConfigurationRepository;
public static I18n interruptedWhileClosingConnectionToFederationConfigurationRepository;
Modified: trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencers/xml/XmlSequencer.java
===================================================================
--- trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencers/xml/XmlSequencer.java 2008-06-11 09:14:08 UTC (rev 266)
+++ trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencers/xml/XmlSequencer.java 2008-06-11 14:39:43 UTC (rev 267)
@@ -105,8 +105,9 @@
reader.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);
// Parse XML document
reader.parse(new InputSource(stream));
- } catch (Exception err) {
- LOGGER.error(err, RepositoryI18n.errorSequencingXmlDocument);
+ } catch (Exception error) {
+ LOGGER.error(error, RepositoryI18n.fatalErrorSequencingXmlDocument, error);
+ monitor.getProblems().addError(error, RepositoryI18n.fatalErrorSequencingXmlDocument, error);
} finally {
monitor.done();
}
@@ -353,7 +354,8 @@
*/
@Override
public void error( SAXParseException error ) {
- LOGGER.error(error, RepositoryI18n.errorSequencingXmlDocument);
+ LOGGER.error(error, RepositoryI18n.errorSequencingXmlDocument, error);
+ monitor.getProblems().addError(error, RepositoryI18n.errorSequencingXmlDocument, error);
}
/**
@@ -388,7 +390,8 @@
*/
@Override
public void fatalError( SAXParseException error ) {
- LOGGER.error(error, RepositoryI18n.errorSequencingXmlDocument);
+ LOGGER.error(error, RepositoryI18n.fatalErrorSequencingXmlDocument);
+ monitor.getProblems().addError(error, RepositoryI18n.fatalErrorSequencingXmlDocument, error);
}
private Name getCommentContentName() {
@@ -684,8 +687,9 @@
* @see org.xml.sax.helpers.DefaultHandler#warning(org.xml.sax.SAXParseException)
*/
@Override
- public void warning( SAXParseException error ) {
- LOGGER.warn(error, RepositoryI18n.errorSequencingXmlDocument);
+ public void warning( SAXParseException warning ) {
+ LOGGER.warn(warning, RepositoryI18n.warningSequencingXmlDocument);
+ monitor.getProblems().addWarning(warning, RepositoryI18n.warningSequencingXmlDocument, warning);
}
}
Modified: trunk/dna-repository/src/main/resources/org/jboss/dna/repository/RepositoryI18n.properties
===================================================================
--- trunk/dna-repository/src/main/resources/org/jboss/dna/repository/RepositoryI18n.properties 2008-06-11 09:14:08 UTC (rev 266)
+++ trunk/dna-repository/src/main/resources/org/jboss/dna/repository/RepositoryI18n.properties 2008-06-11 14:39:43 UTC (rev 267)
@@ -92,9 +92,11 @@
invalidRepositoryNodePath = The repository node path "{0}" is not valid: {1}
-errorSequencingXmlDocument = An error occurred while sequencing XML:
+errorSequencingXmlDocument = An error was received while sequencing XML: {0}
+fatalErrorSequencingXmlDocument = A fatal error was received while sequencing XML: {0}
sequencingXmlDocument = Sequencing XML
canceledSequencingXmlDocument = Canceled sequencing XML
+warningSequencingXmlDocument = A warning was received while sequencing XML: {0}
interruptedWhileConnectingToFederationConfigurationRepository = Interrupted while connecting to federation configuration repository for "{0}" repository
interruptedWhileClosingConnectionToFederationConfigurationRepository = Interrupted while closing connection to federation configuration repository for "{0}" repository
17 years, 6 months
DNA SVN: r266 - branches/maeste/sequencers/dna-sequencer-esbMessage/src/main/java/org/jboss/dna/sequencer/esbMessage.
by dna-commits@lists.jboss.org
Author: maeste
Date: 2008-06-11 05:14:08 -0400 (Wed, 11 Jun 2008)
New Revision: 266
Modified:
branches/maeste/sequencers/dna-sequencer-esbMessage/src/main/java/org/jboss/dna/sequencer/esbMessage/ESBMessageMetaData.java
branches/maeste/sequencers/dna-sequencer-esbMessage/src/main/java/org/jboss/dna/sequencer/esbMessage/ESBMessageSequencer.java
Log:
fixed some imports
Modified: branches/maeste/sequencers/dna-sequencer-esbMessage/src/main/java/org/jboss/dna/sequencer/esbMessage/ESBMessageMetaData.java
===================================================================
--- branches/maeste/sequencers/dna-sequencer-esbMessage/src/main/java/org/jboss/dna/sequencer/esbMessage/ESBMessageMetaData.java 2008-06-11 08:45:51 UTC (rev 265)
+++ branches/maeste/sequencers/dna-sequencer-esbMessage/src/main/java/org/jboss/dna/sequencer/esbMessage/ESBMessageMetaData.java 2008-06-11 09:14:08 UTC (rev 266)
@@ -28,7 +28,6 @@
import java.util.Map;
import org.jboss.dna.common.monitor.ProgressMonitor;
import org.jboss.dna.common.util.StringUtil;
-import org.jboss.dna.sequencer.images.ImageSequencerI18n;
import org.jboss.internal.soa.esb.util.Encoding;
import org.jboss.soa.esb.addressing.EPR;
import org.jboss.soa.esb.message.Message;
@@ -65,7 +64,7 @@
ESBMessageMetaData me = null;
Message message = null;
- progressMonitor.beginTask(10, ImageSequencerI18n.sequencerTaskName);
+ progressMonitor.beginTask(10, ESBMessageSequencerI18n.sequencerTaskName);
try {
me = new ESBMessageMetaData();
message = Util.deserialize((Serializable)Encoding.decodeToObject(StringUtil.read(stream)));
Modified: branches/maeste/sequencers/dna-sequencer-esbMessage/src/main/java/org/jboss/dna/sequencer/esbMessage/ESBMessageSequencer.java
===================================================================
--- branches/maeste/sequencers/dna-sequencer-esbMessage/src/main/java/org/jboss/dna/sequencer/esbMessage/ESBMessageSequencer.java 2008-06-11 08:45:51 UTC (rev 265)
+++ branches/maeste/sequencers/dna-sequencer-esbMessage/src/main/java/org/jboss/dna/sequencer/esbMessage/ESBMessageSequencer.java 2008-06-11 09:14:08 UTC (rev 266)
@@ -24,7 +24,6 @@
import java.io.InputStream;
import java.util.Map.Entry;
import org.jboss.dna.common.monitor.ProgressMonitor;
-import org.jboss.dna.sequencer.images.ImageSequencerI18n;
import org.jboss.dna.spi.graph.NameFactory;
import org.jboss.dna.spi.graph.Path;
import org.jboss.dna.spi.graph.PathFactory;
@@ -88,7 +87,7 @@
SequencerOutput output,
ProgressMonitor progressMonitor ) {
- progressMonitor.beginTask(20, ImageSequencerI18n.sequencerTaskName);
+ progressMonitor.beginTask(20, ESBMessageSequencerI18n.sequencerTaskName);
ESBMessageMetaData metadata = ESBMessageMetaData.instance(stream, progressMonitor.createSubtask(10));
if (progressMonitor.isCancelled()) return;
17 years, 6 months
DNA SVN: r265 - in branches/maeste: connectors/dna-connector-jbosscache/src/main/java/org/jboss/dna/connector/jbosscache and 48 other directories.
by dna-commits@lists.jboss.org
Author: maeste
Date: 2008-06-11 04:45:51 -0400 (Wed, 11 Jun 2008)
New Revision: 265
Added:
branches/maeste/dna-common/src/main/java/org/jboss/dna/common/collection/Problems.java
branches/maeste/dna-common/src/main/java/org/jboss/dna/common/collection/SimpleProblems.java
branches/maeste/dna-common/src/test/java/org/jboss/dna/common/text/StringMatcher.java
branches/maeste/dna-repository/src/test/java/org/jboss/dna/repository/federation/FederatedRepositoryTest.java
branches/maeste/dna-spi/src/main/java/org/jboss/dna/spi/graph/IoException.java
branches/maeste/dna-spi/src/main/java/org/jboss/dna/spi/graph/connection/RepositoryOperations.java
branches/maeste/dna-spi/src/test/java/org/jboss/dna/spi/graph/connection/TimeDelayingRepositorySource.java
Removed:
branches/maeste/dna-common/src/main/java/org/jboss/dna/common/collection/Problems.java
branches/maeste/dna-common/src/main/java/org/jboss/dna/common/monitor/NullProgressMonitor.java
branches/maeste/dna-spi/src/main/java/org/jboss/dna/spi/graph/ValueFormatException.java
branches/maeste/dna-spi/src/test/java/org/jboss/dna/spi/graph/connection/MockRepositorySource.java
branches/maeste/dna-spi/src/test/java/org/jboss/dna/spi/graph/connection/RepositoryTestOperations.java
Modified:
branches/maeste/
branches/maeste/connectors/dna-connector-jbosscache/src/main/java/org/jboss/dna/connector/jbosscache/JBossCacheConnection.java
branches/maeste/connectors/dna-connector-jbosscache/src/main/java/org/jboss/dna/connector/jbosscache/JBossCacheSource.java
branches/maeste/dna-common/pom.xml
branches/maeste/dna-common/src/main/java/org/jboss/dna/common/collection/UnmodifiableProperties.java
branches/maeste/dna-common/src/main/java/org/jboss/dna/common/monitor/ProgressMonitor.java
branches/maeste/dna-common/src/main/java/org/jboss/dna/common/monitor/ProgressMonitorWrapper.java
branches/maeste/dna-common/src/main/java/org/jboss/dna/common/monitor/SimpleProgressMonitor.java
branches/maeste/dna-common/src/main/java/org/jboss/dna/common/monitor/SubProgressMonitor.java
branches/maeste/dna-common/src/test/java/org/jboss/dna/common/AbstractI18nTest.java
branches/maeste/dna-common/src/test/java/org/jboss/dna/common/CommonI18nTest.java
branches/maeste/dna-common/src/test/java/org/jboss/dna/common/component/ComponentConfigTest.java
branches/maeste/dna-common/src/test/java/org/jboss/dna/common/component/ComponentLibraryTest.java
branches/maeste/dna-common/src/test/java/org/jboss/dna/common/i18n/I18nTest.java
branches/maeste/dna-common/src/test/java/org/jboss/dna/common/jcr/AbstractJcrRepositoryTest.java
branches/maeste/dna-common/src/test/java/org/jboss/dna/common/math/DoubleOperationsTest.java
branches/maeste/dna-common/src/test/java/org/jboss/dna/common/math/DurationTest.java
branches/maeste/dna-common/src/test/java/org/jboss/dna/common/math/FloatOperationsTest.java
branches/maeste/dna-common/src/test/java/org/jboss/dna/common/math/IntegerOperationsTest.java
branches/maeste/dna-common/src/test/java/org/jboss/dna/common/math/LongOperationsTest.java
branches/maeste/dna-common/src/test/java/org/jboss/dna/common/monitor/ProgressStatusTest.java
branches/maeste/dna-common/src/test/java/org/jboss/dna/common/monitor/SimpleProgressMonitorTest.java
branches/maeste/dna-common/src/test/java/org/jboss/dna/common/naming/MockInitialContextTest.java
branches/maeste/dna-common/src/test/java/org/jboss/dna/common/stats/DetailedStatisticsTest.java
branches/maeste/dna-common/src/test/java/org/jboss/dna/common/stats/HistogramTest.java
branches/maeste/dna-common/src/test/java/org/jboss/dna/common/stats/SimpleStatisticsTest.java
branches/maeste/dna-common/src/test/java/org/jboss/dna/common/stats/StopwatchTest.java
branches/maeste/dna-common/src/test/java/org/jboss/dna/common/text/InflectorTest.java
branches/maeste/dna-common/src/test/java/org/jboss/dna/common/util/HashCodeTest.java
branches/maeste/dna-common/src/test/java/org/jboss/dna/common/util/IoUtilTest.java
branches/maeste/dna-common/src/test/java/org/jboss/dna/common/util/LoggerTest.java
branches/maeste/dna-common/src/test/java/org/jboss/dna/common/util/StringUtilTest.java
branches/maeste/dna-integration-tests/pom.xml
branches/maeste/dna-integration-tests/src/test/java/org/jboss/dna/tests/integration/jackrabbit/JackrabbitBasicFunctionTest.java
branches/maeste/dna-integration-tests/src/test/java/org/jboss/dna/tests/integration/jackrabbit/JackrabbitDerbyStressTest.java
branches/maeste/dna-integration-tests/src/test/java/org/jboss/dna/tests/integration/jackrabbit/JackrabbitInMemoryTest.java
branches/maeste/dna-maven-classloader/pom.xml
branches/maeste/dna-maven-classloader/src/test/java/org/jboss/dna/maven/MavenIdTest.java
branches/maeste/dna-repository/pom.xml
branches/maeste/dna-repository/src/main/java/org/jboss/dna/repository/RepositoryI18n.java
branches/maeste/dna-repository/src/main/java/org/jboss/dna/repository/federation/FederatedRepository.java
branches/maeste/dna-repository/src/main/java/org/jboss/dna/repository/federation/FederatedRepositoryConnection.java
branches/maeste/dna-repository/src/main/java/org/jboss/dna/repository/federation/FederatedSource.java
branches/maeste/dna-repository/src/main/java/org/jboss/dna/repository/federation/FederationService.java
branches/maeste/dna-repository/src/main/java/org/jboss/dna/repository/observation/ObservationService.java
branches/maeste/dna-repository/src/main/java/org/jboss/dna/repository/rules/RuleService.java
branches/maeste/dna-repository/src/main/java/org/jboss/dna/repository/rules/RuleSetRepositoryMonitor.java
branches/maeste/dna-repository/src/main/java/org/jboss/dna/repository/sequencers/SequencingService.java
branches/maeste/dna-repository/src/main/java/org/jboss/dna/repository/sequencers/xml/XmlSequencer.java
branches/maeste/dna-repository/src/main/java/org/jboss/dna/repository/services/AbstractServiceAdministrator.java
branches/maeste/dna-repository/src/main/java/org/jboss/dna/repository/services/ServiceAdministrator.java
branches/maeste/dna-repository/src/main/java/org/jboss/dna/repository/util/SimpleSessionFactory.java
branches/maeste/dna-repository/src/main/resources/org/jboss/dna/repository/RepositoryI18n.properties
branches/maeste/dna-repository/src/test/java/org/jboss/dna/repository/RepositoryI18nTest.java
branches/maeste/dna-repository/src/test/java/org/jboss/dna/repository/federation/FederatedRepositoryConnectionTest.java
branches/maeste/dna-repository/src/test/java/org/jboss/dna/repository/federation/FederatedRepositorySourceTest.java
branches/maeste/dna-repository/src/test/java/org/jboss/dna/repository/federation/FederatedSourceTest.java
branches/maeste/dna-repository/src/test/java/org/jboss/dna/repository/observation/NodeChangeTest.java
branches/maeste/dna-repository/src/test/java/org/jboss/dna/repository/rules/RuleServiceTest.java
branches/maeste/dna-repository/src/test/java/org/jboss/dna/repository/rules/RuleSetTest.java
branches/maeste/dna-repository/src/test/java/org/jboss/dna/repository/sequencers/SequencerConfigTest.java
branches/maeste/dna-repository/src/test/java/org/jboss/dna/repository/sequencers/SequencingServiceTest.java
branches/maeste/dna-repository/src/test/java/org/jboss/dna/repository/sequencers/StreamSequencerAdapterTest.java
branches/maeste/dna-repository/src/test/java/org/jboss/dna/repository/sequencers/xml/XmlSequencerTest.java
branches/maeste/dna-repository/src/test/java/org/jboss/dna/repository/util/JndiSessionFactoryTest.java
branches/maeste/dna-repository/src/test/resources/log4j.properties
branches/maeste/dna-spi/pom.xml
branches/maeste/dna-spi/src/main/java/org/jboss/dna/spi/SpiI18n.java
branches/maeste/dna-spi/src/main/java/org/jboss/dna/spi/graph/PropertyType.java
branches/maeste/dna-spi/src/main/java/org/jboss/dna/spi/graph/ValueComparators.java
branches/maeste/dna-spi/src/main/java/org/jboss/dna/spi/graph/ValueFactory.java
branches/maeste/dna-spi/src/main/java/org/jboss/dna/spi/graph/connection/RepositoryConnectionPool.java
branches/maeste/dna-spi/src/main/java/org/jboss/dna/spi/graph/connection/RepositoryOperation.java
branches/maeste/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/AbstractValueFactory.java
branches/maeste/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/BooleanValueFactory.java
branches/maeste/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/DecimalValueFactory.java
branches/maeste/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/DoubleValueFactory.java
branches/maeste/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/InMemoryBinaryValueFactory.java
branches/maeste/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/JodaDateTimeValueFactory.java
branches/maeste/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/LongValueFactory.java
branches/maeste/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/NameValueFactory.java
branches/maeste/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/ObjectValueFactory.java
branches/maeste/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/PathValueFactory.java
branches/maeste/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/StringValueFactory.java
branches/maeste/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/UriValueFactory.java
branches/maeste/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/UuidReferenceValueFactory.java
branches/maeste/dna-spi/src/main/resources/org/jboss/dna/spi/SpiI18n.properties
branches/maeste/dna-spi/src/test/java/org/jboss/dna/spi/graph/connection/RepositoryConnectionPoolTest.java
branches/maeste/dna-spi/src/test/java/org/jboss/dna/spi/graph/connection/RepositorySourceLoadHarness.java
branches/maeste/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/AbstractValueFactoryTest.java
branches/maeste/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/BasicNameTest.java
branches/maeste/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/BasicNamespaceRegistryTest.java
branches/maeste/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/BasicPathSegmentTest.java
branches/maeste/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/BasicPathTest.java
branches/maeste/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/BooleanValueFactoryTest.java
branches/maeste/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/DecimalValueFactoryTest.java
branches/maeste/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/DoubleValueFactoryTest.java
branches/maeste/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/JodaDateTimeTest.java
branches/maeste/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/JodaDateTimeValueFactoryTest.java
branches/maeste/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/LongValueFactoryTest.java
branches/maeste/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/NameValueFactoryTest.java
branches/maeste/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/PathValueFactoryTest.java
branches/maeste/docs/examples/gettingstarted/sequencers/src/main/java/org/jboss/example/dna/sequencers/SequencingClient.java
branches/maeste/docs/examples/gettingstarted/sequencers/src/test/java/org/jboss/example/dna/sequencers/MockUserInterface.java
branches/maeste/docs/examples/gettingstarted/sequencers/src/test/java/org/jboss/example/dna/sequencers/SequencingClientTest.java
branches/maeste/eclipse-preferences.epf
branches/maeste/pom.xml
branches/maeste/sequencers/dna-sequencer-images/src/test/java/org/jboss/dna/sequencer/images/ImageMetadataSequencerTest.java
branches/maeste/sequencers/dna-sequencer-images/src/test/java/org/jboss/dna/sequencer/images/ImageMetadataTest.java
branches/maeste/sequencers/dna-sequencer-mp3/src/main/java/org/jboss/dna/sequencer/mp3/Mp3Metadata.java
branches/maeste/sequencers/dna-sequencer-mp3/src/test/java/org/jboss/dna/sequencer/mp3/Mp3MetadataTest.java
Log:
Merged revisions 246-264 via svnmerge from
https://svn.jboss.org/repos/dna/trunk
........
r247 | maeste | 2008-06-07 15:13:35 +0200 (Sat, 07 Jun 2008) | 1 line
removed files committed for error
........
r248 | maeste | 2008-06-07 22:29:57 +0200 (Sat, 07 Jun 2008) | 1 line
reverted my last wrong *stupid* commit :(
........
r250 | jverhaeg(a)redhat.com | 2008-06-09 16:44:48 +0200 (Mon, 09 Jun 2008) | 1 line
DNA-96: Replaced ValueFormatException with IllegalArgumentException, UnsupportedOperationException, and a new IoException (a runtime exception that replaces IOException), and changed exceptions thrown to be more consistent across value factory implementations.
........
r251 | rhauch | 2008-06-09 17:36:52 +0200 (Mon, 09 Jun 2008) | 1 line
Corrected build problem with parent POM
........
r252 | rhauch | 2008-06-10 22:18:05 +0200 (Tue, 10 Jun 2008) | 1 line
Added StringMatcher utility for use with JUnit tests. The old matcher came with JMock, which we're trying to replace with Mockito, which doesn't have a "startsWith" matcher.
........
r253 | rhauch | 2008-06-10 22:19:15 +0200 (Tue, 10 Jun 2008) | 4 lines
DNA-117: Create a FederatedRepository class that manages multiple sources
http://jira.jboss.org/jira/browse/DNA-117
More fully implemented FederatedRepository and added unit tests that cover mode code and cases.
........
r254 | rhauch | 2008-06-10 23:08:58 +0200 (Tue, 10 Jun 2008) | 1 line
DNA-121 Remove dependency on JMock and use Mockito instead
........
r255 | rhauch | 2008-06-10 23:15:46 +0200 (Tue, 10 Jun 2008) | 1 line
Cleaned up usage of Mockito.
........
r256 | rhauch | 2008-06-10 23:50:33 +0200 (Tue, 10 Jun 2008) | 1 line
Removed unused exceptions in signatures.
........
r257 | rhauch | 2008-06-10 23:53:59 +0200 (Tue, 10 Jun 2008) | 1 line
Added the required JBoss and copyright header.
........
r258 | rhauch | 2008-06-11 00:01:20 +0200 (Wed, 11 Jun 2008) | 1 line
Added the required JBoss and copyright header.
........
r259 | rhauch | 2008-06-11 00:05:23 +0200 (Wed, 11 Jun 2008) | 1 line
Fixed parent POM
........
r260 | jverhaeg(a)redhat.com | 2008-06-11 00:16:01 +0200 (Wed, 11 Jun 2008) | 1 line
DNA-75: Added ability to add problems to a progress monitor. Also clarified some documentation and removed NullProgressMonitor (used only for testing) in lieu of using a mock object.
........
r261 | jverhaeg(a)redhat.com | 2008-06-11 01:13:20 +0200 (Wed, 11 Jun 2008) | 1 line
DNA-75: Added ability to add problems to a progress monitor. Also clarified some documentation and removed NullProgressMonitor (used only for testing) in lieu of using a mock object.
........
r262 | jverhaeg(a)redhat.com | 2008-06-11 01:32:20 +0200 (Wed, 11 Jun 2008) | 1 line
Removed unnecessary throws clauses
........
r263 | jverhaeg(a)redhat.com | 2008-06-11 03:10:40 +0200 (Wed, 11 Jun 2008) | 1 line
Updated code templates to eliminate some html, to include the JBoss copyright notice in file comments, and to add a compiler setting to warn about unnecessary throws clauses
........
Property changes on: branches/maeste
___________________________________________________________________
Name: svnmerge-integrated
- /trunk:1-245
+ /trunk:1-264
Modified: branches/maeste/connectors/dna-connector-jbosscache/src/main/java/org/jboss/dna/connector/jbosscache/JBossCacheConnection.java
===================================================================
--- branches/maeste/connectors/dna-connector-jbosscache/src/main/java/org/jboss/dna/connector/jbosscache/JBossCacheConnection.java 2008-06-11 08:35:21 UTC (rev 264)
+++ branches/maeste/connectors/dna-connector-jbosscache/src/main/java/org/jboss/dna/connector/jbosscache/JBossCacheConnection.java 2008-06-11 08:45:51 UTC (rev 265)
@@ -60,7 +60,8 @@
/**
* {@inheritDoc}
*/
- public void notify( String sourceName, Object... events ) {
+ public void notify( String sourceName,
+ Object... events ) {
// do nothing
}
};
@@ -74,7 +75,8 @@
/**
*
*/
- /* package */JBossCacheConnection( JBossCacheSource source, Cache<Name, Object> cache ) {
+ /* package */JBossCacheConnection( JBossCacheSource source,
+ Cache<Name, Object> cache ) {
assert source != null;
assert cache != null;
this.source = source;
@@ -112,7 +114,8 @@
/**
* {@inheritDoc}
*/
- public boolean ping( long time, TimeUnit unit ) {
+ public boolean ping( long time,
+ TimeUnit unit ) {
this.cache.getRoot();
return true;
}
@@ -134,7 +137,8 @@
/**
* {@inheritDoc}
*/
- public void execute( ExecutionEnvironment env, GraphCommand... commands ) throws RepositorySourceException {
+ public void execute( ExecutionEnvironment env,
+ GraphCommand... commands ) {
// Set up the workspace ...
// Now execute the commands ...
@@ -292,7 +296,8 @@
return Fqn.fromElements(pathSegment);
}
- protected Node<Name, Object> getNode( ExecutionEnvironment env, Path path ) {
+ protected Node<Name, Object> getNode( ExecutionEnvironment env,
+ Path path ) {
// Look up the node with the supplied path ...
Fqn<Segment> fqn = getFullyQualifiedName(path);
Node<Name, Object> node = cache.getNode(fqn);
@@ -308,7 +313,10 @@
return UUID.randomUUID();
}
- protected int copyNode( Node<Name, Object> original, Node<Name, Object> newParent, boolean recursive, Name uuidProperty ) {
+ protected int copyNode( Node<Name, Object> original,
+ Node<Name, Object> newParent,
+ boolean recursive,
+ Name uuidProperty ) {
// Get or create the new node ...
Segment name = (Segment)original.getFqn().getLastElement();
Node<Name, Object> copy = newParent.addChild(getFullyQualifiedName(name));
Modified: branches/maeste/connectors/dna-connector-jbosscache/src/main/java/org/jboss/dna/connector/jbosscache/JBossCacheSource.java
===================================================================
--- branches/maeste/connectors/dna-connector-jbosscache/src/main/java/org/jboss/dna/connector/jbosscache/JBossCacheSource.java 2008-06-11 08:35:21 UTC (rev 264)
+++ branches/maeste/connectors/dna-connector-jbosscache/src/main/java/org/jboss/dna/connector/jbosscache/JBossCacheSource.java 2008-06-11 08:45:51 UTC (rev 265)
@@ -49,7 +49,6 @@
import org.jboss.dna.spi.graph.NameFactory;
import org.jboss.dna.spi.graph.connection.RepositoryConnection;
import org.jboss.dna.spi.graph.connection.RepositorySource;
-import org.jboss.dna.spi.graph.connection.RepositorySourceException;
/**
* @author Randall Hauch
@@ -192,7 +191,8 @@
* @throws NamingException if there is a problem registering this object
* @see #getJndiName()
*/
- public synchronized void setJndiName( String name, Context context ) throws NamingException {
+ public synchronized void setJndiName( String name,
+ Context context ) throws NamingException {
ArgCheck.isNotNull(name, "name");
if (context == null) context = new InitialContext();
@@ -272,7 +272,7 @@
/**
* {@inheritDoc}
*/
- public synchronized RepositoryConnection getConnection() throws RepositorySourceException {
+ public synchronized RepositoryConnection getConnection() {
if (this.cache == null) {
CacheFactory<Name, Object> factory = new DefaultCacheFactory<Name, Object>();
cache = factory.createCache(cacheConfigurationName);
@@ -304,7 +304,10 @@
/**
* {@inheritDoc}
*/
- public Object getObjectInstance( Object obj, javax.naming.Name name, Context nameCtx, Hashtable<?, ?> environment ) throws Exception {
+ public Object getObjectInstance( Object obj,
+ javax.naming.Name name,
+ Context nameCtx,
+ Hashtable<?, ?> environment ) {
if (obj instanceof Reference) {
Reference ref = (Reference)obj;
if (ref.getClassName().equals(getClass().getName())) {
Modified: branches/maeste/dna-common/pom.xml
===================================================================
--- branches/maeste/dna-common/pom.xml 2008-06-11 08:35:21 UTC (rev 264)
+++ branches/maeste/dna-common/pom.xml 2008-06-11 08:45:51 UTC (rev 265)
@@ -28,13 +28,10 @@
<artifactId>hamcrest-library</artifactId>
</dependency>
<dependency>
- <groupId>org.jmock</groupId>
- <artifactId>jmock</artifactId>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-all</artifactId>
+ <scope>test</scope>
</dependency>
- <dependency>
- <groupId>org.jmock</groupId>
- <artifactId>jmock-junit4</artifactId>
- </dependency>
<!--
Logging (require SLF4J API for compiling, but use Log4J and its SLF4J binding for testing)
-->
Deleted: branches/maeste/dna-common/src/main/java/org/jboss/dna/common/collection/Problems.java
===================================================================
--- branches/maeste/dna-common/src/main/java/org/jboss/dna/common/collection/Problems.java 2008-06-11 08:35:21 UTC (rev 264)
+++ branches/maeste/dna-common/src/main/java/org/jboss/dna/common/collection/Problems.java 2008-06-11 08:45:51 UTC (rev 265)
@@ -1,187 +0,0 @@
-/*
- * 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.common.collection;
-
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import net.jcip.annotations.NotThreadSafe;
-import org.jboss.dna.common.i18n.I18n;
-
-/**
- * @author Randall Hauch
- */
-@NotThreadSafe
-public class Problems implements Iterable<Problem> {
-
- private List<Problem> problems;
-
- public Problems() {
- }
-
- public void addError( I18n message, Object... params ) {
- addProblem(new Problem(Problem.Status.ERROR, Problem.DEFAULT_CODE, message, params));
- }
-
- public void addError( Throwable throwable, I18n message, Object... params ) {
- addProblem(new Problem(Problem.Status.ERROR, Problem.DEFAULT_CODE, message, null, null, throwable));
- }
-
- public void addError( I18n message, String resource, String location, Object... params ) {
- addProblem(new Problem(Problem.Status.ERROR, Problem.DEFAULT_CODE, message, resource, location));
- }
-
- public void addError( Throwable throwable, I18n message, String resource, String location, Object... params ) {
- addProblem(new Problem(Problem.Status.ERROR, Problem.DEFAULT_CODE, message, resource, location, throwable));
- }
-
- public void addError( int code, I18n message, Object... params ) {
- addProblem(new Problem(Problem.Status.ERROR, code, message));
- }
-
- public void addError( Throwable throwable, int code, I18n message, Object... params ) {
- addProblem(new Problem(Problem.Status.ERROR, code, message, null, null, throwable));
- }
-
- public void addError( int code, I18n message, String resource, String location, Object... params ) {
- addProblem(new Problem(Problem.Status.ERROR, code, message, resource, location));
- }
-
- public void addError( Throwable throwable, int code, I18n message, String resource, String location, Object... params ) {
- addProblem(new Problem(Problem.Status.ERROR, code, message, resource, location, throwable));
- }
-
- public void addWarning( I18n message, Object... params ) {
- addProblem(new Problem(Problem.Status.WARNING, Problem.DEFAULT_CODE, message));
- }
-
- public void addWarning( Throwable throwable, I18n message, Object... params ) {
- addProblem(new Problem(Problem.Status.WARNING, Problem.DEFAULT_CODE, message, null, null, throwable));
- }
-
- public void addWarning( I18n message, String resource, String location, Object... params ) {
- addProblem(new Problem(Problem.Status.WARNING, Problem.DEFAULT_CODE, message, resource, location));
- }
-
- public void addWarning( Throwable throwable, I18n message, String resource, String location, Object... params ) {
- addProblem(new Problem(Problem.Status.WARNING, Problem.DEFAULT_CODE, message, resource, location, throwable));
- }
-
- public void addWarning( int code, I18n message, Object... params ) {
- addProblem(new Problem(Problem.Status.WARNING, code, message));
- }
-
- public void addWarning( Throwable throwable, int code, I18n message, Object... params ) {
- addProblem(new Problem(Problem.Status.WARNING, code, message, null, null, throwable));
- }
-
- public void addWarning( int code, I18n message, String resource, String location, Object... params ) {
- addProblem(new Problem(Problem.Status.WARNING, code, message, resource, location));
- }
-
- public void addWarning( Throwable throwable, int code, I18n message, String resource, String location, Object... params ) {
- addProblem(new Problem(Problem.Status.WARNING, code, message, resource, location, throwable));
- }
-
- public void addInfo( I18n message, Object... params ) {
- addProblem(new Problem(Problem.Status.INFO, Problem.DEFAULT_CODE, message));
- }
-
- public void addInfo( Throwable throwable, I18n message, Object... params ) {
- addProblem(new Problem(Problem.Status.INFO, Problem.DEFAULT_CODE, message, null, null, throwable));
- }
-
- public void addInfo( I18n message, String resource, String location, Object... params ) {
- addProblem(new Problem(Problem.Status.INFO, Problem.DEFAULT_CODE, message, resource, location));
- }
-
- public void addInfo( Throwable throwable, I18n message, String resource, String location, Object... params ) {
- addProblem(new Problem(Problem.Status.INFO, Problem.DEFAULT_CODE, message, resource, location, throwable));
- }
-
- public void addInfo( int code, I18n message, Object... params ) {
- addProblem(new Problem(Problem.Status.INFO, code, message));
- }
-
- public void addInfo( Throwable throwable, int code, I18n message, Object... params ) {
- addProblem(new Problem(Problem.Status.INFO, code, message, null, null, throwable));
- }
-
- public void addInfo( int code, I18n message, String resource, String location, Object... params ) {
- addProblem(new Problem(Problem.Status.INFO, code, message, resource, location));
- }
-
- public void addInfo( Throwable throwable, int code, I18n message, String resource, String location, Object... params ) {
- addProblem(new Problem(Problem.Status.INFO, code, message, resource, location, throwable));
- }
-
- public boolean hasProblems() {
- return this.problems != null && this.problems.size() > 0;
- }
-
- public boolean hasErrors() {
- if (this.problems == null) return false;
- for (Problem problem : this.problems) {
- if (problem.getStatus() == Problem.Status.ERROR) return true;
- }
- return false;
- }
-
- public boolean hasWarnings() {
- if (this.problems == null) return false;
- for (Problem problem : this.problems) {
- if (problem.getStatus() == Problem.Status.WARNING) return true;
- }
- return false;
- }
-
- public boolean hasInfo() {
- if (this.problems == null) return false;
- for (Problem problem : this.problems) {
- if (problem.getStatus() == Problem.Status.INFO) return true;
- }
- return false;
- }
-
- public boolean isEmpty() {
- return this.problems == null || this.problems.isEmpty();
- }
-
- public int size() {
- if (this.problems == null) return 0;
- return this.problems.size();
- }
-
- /**
- * {@inheritDoc}
- */
- public Iterator<Problem> iterator() {
- return problems.iterator();
- }
-
- protected void addProblem( Problem problem ) {
- if (problem == null) return;
- if (problems == null) problems = new LinkedList<Problem>();
- problems.add(problem);
- }
-
-}
Copied: branches/maeste/dna-common/src/main/java/org/jboss/dna/common/collection/Problems.java (from rev 263, trunk/dna-common/src/main/java/org/jboss/dna/common/collection/Problems.java)
===================================================================
--- branches/maeste/dna-common/src/main/java/org/jboss/dna/common/collection/Problems.java (rev 0)
+++ branches/maeste/dna-common/src/main/java/org/jboss/dna/common/collection/Problems.java 2008-06-11 08:45:51 UTC (rev 265)
@@ -0,0 +1,154 @@
+/*
+ *
+ */
+package org.jboss.dna.common.collection;
+
+import java.util.Iterator;
+import org.jboss.dna.common.i18n.I18n;
+
+/**
+ * @author John Verhaeg
+ */
+public interface Problems extends Iterable<Problem> {
+
+ void addError( I18n message,
+ Object... params );
+
+ void addError( Throwable throwable,
+ I18n message,
+ Object... params );
+
+ void addError( I18n message,
+ String resource,
+ String location,
+ Object... params );
+
+ void addError( Throwable throwable,
+ I18n message,
+ String resource,
+ String location,
+ Object... params );
+
+ void addError( int code,
+ I18n message,
+ Object... params );
+
+ void addError( Throwable throwable,
+ int code,
+ I18n message,
+ Object... params );
+
+ void addError( int code,
+ I18n message,
+ String resource,
+ String location,
+ Object... params );
+
+ void addError( Throwable throwable,
+ int code,
+ I18n message,
+ String resource,
+ String location,
+ Object... params );
+
+ void addWarning( I18n message,
+ Object... params );
+
+ void addWarning( Throwable throwable,
+ I18n message,
+ Object... params );
+
+ void addWarning( I18n message,
+ String resource,
+ String location,
+ Object... params );
+
+ void addWarning( Throwable throwable,
+ I18n message,
+ String resource,
+ String location,
+ Object... params );
+
+ void addWarning( int code,
+ I18n message,
+ Object... params );
+
+ void addWarning( Throwable throwable,
+ int code,
+ I18n message,
+ Object... params );
+
+ void addWarning( int code,
+ I18n message,
+ String resource,
+ String location,
+ Object... params );
+
+ void addWarning( Throwable throwable,
+ int code,
+ I18n message,
+ String resource,
+ String location,
+ Object... params );
+
+ void addInfo( I18n message,
+ Object... params );
+
+ void addInfo( Throwable throwable,
+ I18n message,
+ Object... params );
+
+ void addInfo( I18n message,
+ String resource,
+ String location,
+ Object... params );
+
+ void addInfo( Throwable throwable,
+ I18n message,
+ String resource,
+ String location,
+ Object... params );
+
+ void addInfo( int code,
+ I18n message,
+ Object... params );
+
+ void addInfo( Throwable throwable,
+ int code,
+ I18n message,
+ Object... params );
+
+ void addInfo( int code,
+ I18n message,
+ String resource,
+ String location,
+ Object... params );
+
+ void addInfo( Throwable throwable,
+ int code,
+ I18n message,
+ String resource,
+ String location,
+ Object... params );
+
+ boolean hasProblems();
+
+ boolean hasErrors();
+
+ boolean hasWarnings();
+
+ boolean hasInfo();
+
+ boolean isEmpty();
+
+ int size();
+
+ /**
+ * <p>
+ * {@inheritDoc}
+ * </p>
+ *
+ * @see java.lang.Iterable#iterator()
+ */
+ Iterator<Problem> iterator();
+}
Copied: branches/maeste/dna-common/src/main/java/org/jboss/dna/common/collection/SimpleProblems.java (from rev 263, trunk/dna-common/src/main/java/org/jboss/dna/common/collection/SimpleProblems.java)
===================================================================
--- branches/maeste/dna-common/src/main/java/org/jboss/dna/common/collection/SimpleProblems.java (rev 0)
+++ branches/maeste/dna-common/src/main/java/org/jboss/dna/common/collection/SimpleProblems.java 2008-06-11 08:45:51 UTC (rev 265)
@@ -0,0 +1,263 @@
+/*
+ * 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.common.collection;
+
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import net.jcip.annotations.NotThreadSafe;
+import org.jboss.dna.common.i18n.I18n;
+
+/**
+ * A list of problems for some execution context. The problems will be {@link #iterator() returned} in the order in which they
+ * were encountered (although this cannot be guaranteed in contexts involving multiple threads or processes).
+ *
+ * @author Randall Hauch
+ * @author John Verhaeg
+ */
+@NotThreadSafe
+public class SimpleProblems implements Problems {
+
+ private List<Problem> problems;
+
+ public void addError( I18n message,
+ Object... params ) {
+ addProblem(new Problem(Problem.Status.ERROR, Problem.DEFAULT_CODE, message, params));
+ }
+
+ public void addError( Throwable throwable,
+ I18n message,
+ Object... params ) {
+ addProblem(new Problem(Problem.Status.ERROR, Problem.DEFAULT_CODE, message, null, null, throwable));
+ }
+
+ public void addError( I18n message,
+ String resource,
+ String location,
+ Object... params ) {
+ addProblem(new Problem(Problem.Status.ERROR, Problem.DEFAULT_CODE, message, resource, location));
+ }
+
+ public void addError( Throwable throwable,
+ I18n message,
+ String resource,
+ String location,
+ Object... params ) {
+ addProblem(new Problem(Problem.Status.ERROR, Problem.DEFAULT_CODE, message, resource, location, throwable));
+ }
+
+ public void addError( int code,
+ I18n message,
+ Object... params ) {
+ addProblem(new Problem(Problem.Status.ERROR, code, message));
+ }
+
+ public void addError( Throwable throwable,
+ int code,
+ I18n message,
+ Object... params ) {
+ addProblem(new Problem(Problem.Status.ERROR, code, message, null, null, throwable));
+ }
+
+ public void addError( int code,
+ I18n message,
+ String resource,
+ String location,
+ Object... params ) {
+ addProblem(new Problem(Problem.Status.ERROR, code, message, resource, location));
+ }
+
+ public void addError( Throwable throwable,
+ int code,
+ I18n message,
+ String resource,
+ String location,
+ Object... params ) {
+ addProblem(new Problem(Problem.Status.ERROR, code, message, resource, location, throwable));
+ }
+
+ public void addWarning( I18n message,
+ Object... params ) {
+ addProblem(new Problem(Problem.Status.WARNING, Problem.DEFAULT_CODE, message));
+ }
+
+ public void addWarning( Throwable throwable,
+ I18n message,
+ Object... params ) {
+ addProblem(new Problem(Problem.Status.WARNING, Problem.DEFAULT_CODE, message, null, null, throwable));
+ }
+
+ public void addWarning( I18n message,
+ String resource,
+ String location,
+ Object... params ) {
+ addProblem(new Problem(Problem.Status.WARNING, Problem.DEFAULT_CODE, message, resource, location));
+ }
+
+ public void addWarning( Throwable throwable,
+ I18n message,
+ String resource,
+ String location,
+ Object... params ) {
+ addProblem(new Problem(Problem.Status.WARNING, Problem.DEFAULT_CODE, message, resource, location, throwable));
+ }
+
+ public void addWarning( int code,
+ I18n message,
+ Object... params ) {
+ addProblem(new Problem(Problem.Status.WARNING, code, message));
+ }
+
+ public void addWarning( Throwable throwable,
+ int code,
+ I18n message,
+ Object... params ) {
+ addProblem(new Problem(Problem.Status.WARNING, code, message, null, null, throwable));
+ }
+
+ public void addWarning( int code,
+ I18n message,
+ String resource,
+ String location,
+ Object... params ) {
+ addProblem(new Problem(Problem.Status.WARNING, code, message, resource, location));
+ }
+
+ public void addWarning( Throwable throwable,
+ int code,
+ I18n message,
+ String resource,
+ String location,
+ Object... params ) {
+ addProblem(new Problem(Problem.Status.WARNING, code, message, resource, location, throwable));
+ }
+
+ public void addInfo( I18n message,
+ Object... params ) {
+ addProblem(new Problem(Problem.Status.INFO, Problem.DEFAULT_CODE, message));
+ }
+
+ public void addInfo( Throwable throwable,
+ I18n message,
+ Object... params ) {
+ addProblem(new Problem(Problem.Status.INFO, Problem.DEFAULT_CODE, message, null, null, throwable));
+ }
+
+ public void addInfo( I18n message,
+ String resource,
+ String location,
+ Object... params ) {
+ addProblem(new Problem(Problem.Status.INFO, Problem.DEFAULT_CODE, message, resource, location));
+ }
+
+ public void addInfo( Throwable throwable,
+ I18n message,
+ String resource,
+ String location,
+ Object... params ) {
+ addProblem(new Problem(Problem.Status.INFO, Problem.DEFAULT_CODE, message, resource, location, throwable));
+ }
+
+ public void addInfo( int code,
+ I18n message,
+ Object... params ) {
+ addProblem(new Problem(Problem.Status.INFO, code, message));
+ }
+
+ public void addInfo( Throwable throwable,
+ int code,
+ I18n message,
+ Object... params ) {
+ addProblem(new Problem(Problem.Status.INFO, code, message, null, null, throwable));
+ }
+
+ public void addInfo( int code,
+ I18n message,
+ String resource,
+ String location,
+ Object... params ) {
+ addProblem(new Problem(Problem.Status.INFO, code, message, resource, location));
+ }
+
+ public void addInfo( Throwable throwable,
+ int code,
+ I18n message,
+ String resource,
+ String location,
+ Object... params ) {
+ addProblem(new Problem(Problem.Status.INFO, code, message, resource, location, throwable));
+ }
+
+ public boolean hasProblems() {
+ return this.problems != null && this.problems.size() > 0;
+ }
+
+ public boolean hasErrors() {
+ if (this.problems == null) return false;
+ for (Problem problem : this.problems) {
+ if (problem.getStatus() == Problem.Status.ERROR) return true;
+ }
+ return false;
+ }
+
+ public boolean hasWarnings() {
+ if (this.problems == null) return false;
+ for (Problem problem : this.problems) {
+ if (problem.getStatus() == Problem.Status.WARNING) return true;
+ }
+ return false;
+ }
+
+ public boolean hasInfo() {
+ if (this.problems == null) return false;
+ for (Problem problem : this.problems) {
+ if (problem.getStatus() == Problem.Status.INFO) return true;
+ }
+ return false;
+ }
+
+ public boolean isEmpty() {
+ return this.problems == null || this.problems.isEmpty();
+ }
+
+ public int size() {
+ if (this.problems == null) return 0;
+ return this.problems.size();
+ }
+
+ /**
+ * <p>
+ * {@inheritDoc}
+ * </p>
+ *
+ * @see org.jboss.dna.common.collection.Problems#iterator()
+ */
+ public Iterator<Problem> iterator() {
+ return problems.iterator();
+ }
+
+ protected void addProblem( Problem problem ) {
+ if (problem == null) return;
+ if (problems == null) problems = new LinkedList<Problem>();
+ problems.add(problem);
+ }
+}
Modified: branches/maeste/dna-common/src/main/java/org/jboss/dna/common/collection/UnmodifiableProperties.java
===================================================================
--- branches/maeste/dna-common/src/main/java/org/jboss/dna/common/collection/UnmodifiableProperties.java 2008-06-11 08:35:21 UTC (rev 264)
+++ branches/maeste/dna-common/src/main/java/org/jboss/dna/common/collection/UnmodifiableProperties.java 2008-06-11 08:45:51 UTC (rev 265)
@@ -106,7 +106,8 @@
* {@inheritDoc}
*/
@Override
- public String getProperty( String key, String defaultValue ) {
+ public String getProperty( String key,
+ String defaultValue ) {
return this.delegate.getProperty(key, defaultValue);
}
@@ -168,11 +169,13 @@
/**
* {@inheritDoc}
+ *
* @deprecated
*/
@Deprecated
@Override
- public void save( OutputStream out, String comments ) {
+ public void save( OutputStream out,
+ String comments ) {
this.delegate.save(out, comments);
}
@@ -188,7 +191,8 @@
* {@inheritDoc}
*/
@Override
- public void store( OutputStream out, String comments ) throws IOException {
+ public void store( OutputStream out,
+ String comments ) throws IOException {
this.delegate.store(out, comments);
}
@@ -196,7 +200,9 @@
* {@inheritDoc}
*/
@Override
- public void storeToXML( OutputStream os, String comment, String encoding ) throws IOException {
+ public void storeToXML( OutputStream os,
+ String comment,
+ String encoding ) throws IOException {
this.delegate.storeToXML(os, comment, encoding);
}
@@ -204,7 +210,8 @@
* {@inheritDoc}
*/
@Override
- public void storeToXML( OutputStream os, String comment ) throws IOException {
+ public void storeToXML( OutputStream os,
+ String comment ) throws IOException {
this.delegate.storeToXML(os, comment);
}
@@ -268,7 +275,8 @@
* {@inheritDoc}
*/
@Override
- public synchronized Object put( Object key, Object value ) {
+ public synchronized Object put( Object key,
+ Object value ) {
throw new UnsupportedOperationException();
}
@@ -292,7 +300,8 @@
* {@inheritDoc}
*/
@Override
- public synchronized Object setProperty( String key, String value ) {
+ public synchronized Object setProperty( String key,
+ String value ) {
throw new UnsupportedOperationException();
}
Deleted: branches/maeste/dna-common/src/main/java/org/jboss/dna/common/monitor/NullProgressMonitor.java
===================================================================
--- branches/maeste/dna-common/src/main/java/org/jboss/dna/common/monitor/NullProgressMonitor.java 2008-06-11 08:35:21 UTC (rev 264)
+++ branches/maeste/dna-common/src/main/java/org/jboss/dna/common/monitor/NullProgressMonitor.java 2008-06-11 08:45:51 UTC (rev 265)
@@ -1,100 +0,0 @@
-/*
- * 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.common.monitor;
-
-import java.util.Locale;
-import java.util.concurrent.atomic.AtomicBoolean;
-import org.jboss.dna.common.CommonI18n;
-import org.jboss.dna.common.i18n.I18n;
-import net.jcip.annotations.ThreadSafe;
-
-/**
- * Progress monitor that records nothing.
- * @author Randall Hauch
- */
-@ThreadSafe
-public class NullProgressMonitor implements ProgressMonitor {
-
- private final AtomicBoolean cancelled = new AtomicBoolean(false);
- private final String activityName;
-
- public NullProgressMonitor( String activityName ) {
- this.activityName = activityName;
- }
-
- /**
- * {@inheritDoc}
- */
- public String getActivityName() {
- return this.activityName;
- }
-
- /**
- * {@inheritDoc}
- */
- public void beginTask( double totalWork, I18n name, Object... params ) {
- // do nothing
- }
-
- /**
- * {@inheritDoc}
- */
- public ProgressMonitor createSubtask( double subtaskWork ) {
- return this;
- }
-
- /**
- * {@inheritDoc}
- */
- public void done() {
- // do nothing
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean isCancelled() {
- return cancelled.get();
- }
-
- /**
- * {@inheritDoc}
- */
- public void setCancelled( boolean value ) {
- cancelled.set(value);
- }
-
- /**
- * {@inheritDoc}
- */
- public void worked( double work ) {
- // do nothing
- }
-
- /**
- * {@inheritDoc}
- */
- public ProgressStatus getStatus( Locale locale ) {
- return new ProgressStatus(this.activityName, CommonI18n.nullProgressMonitorTaskName.text(locale), 0.0d, cancelled.get());
- }
-}
Modified: branches/maeste/dna-common/src/main/java/org/jboss/dna/common/monitor/ProgressMonitor.java
===================================================================
--- branches/maeste/dna-common/src/main/java/org/jboss/dna/common/monitor/ProgressMonitor.java 2008-06-11 08:35:21 UTC (rev 264)
+++ branches/maeste/dna-common/src/main/java/org/jboss/dna/common/monitor/ProgressMonitor.java 2008-06-11 08:45:51 UTC (rev 265)
@@ -23,63 +23,92 @@
package org.jboss.dna.common.monitor;
import java.util.Locale;
+import org.jboss.dna.common.collection.Problems;
import org.jboss.dna.common.i18n.I18n;
/**
- * A basic progress monitor that facilitates the monitoring of an activity.
+ * A basic progress monitor that facilitates the updating and monitoring of progress towards the completion of an activity.
+ * Documentation hereafter will refer to the code in an application that updates progress as the <strong>Updater</strong>, and
+ * code that monitors progress as an <strong>Observer</strong>.
* <p>
- * The progress of each activity is started when {@link #beginTask(double, I18n, Object...)} is called, continues with a mixture
- * of work ({@link #worked(double)}) and subtasks ({@link #createSubtask(double)}), and finishes when the activity is
- * completed ({@link #done()}) or cancelled ({@link #setCancelled(boolean)}).
+ * The progress of each {@link #getActivityName() activity} is started when the <strong>Updater</strong> calls
+ * {@link #beginTask(double, I18n, Object...)}, continues with a mixture of work ({@link #worked(double)}) and subtasks ({@link #createSubtask(double)}),
+ * and finishes when the activity is completed ({@link #done()}) or cancelled ({@link #setCancelled(boolean)}).
* </p>
+ * <p>
+ * If an activity is interrupted before its normal completion due to a cancellation request by an <strong>Observer</strong>, it
+ * is still the responsibility of the <strong>Updater</strong> to mark the activity as completed. Similarly, if an activity
+ * cannot be cancelled before its normal completion, the <strong>Updater</strong> must deny any previous cancellation request by
+ * calling {@link #setCancelled(boolean) setCancelled(false)}.
+ * </p>
+ *
* @author Randall Hauch
+ * @author John Verhaeg
*/
public interface ProgressMonitor {
/**
* Get the name of the activity. This should never change for a progress monitor, and all
* {@link #createSubtask(double) subtasks} should have the same name.
+ *
* @return the activity's name
*/
String getActivityName();
/**
- * Start work on the task, specifying the total amount of work that this task constitutes.
+ * Called by the <strong>Updater</strong> to indicate work has started on the task, specifying the total amount of work that
+ * this task constitutes.
+ *
* @param totalWork the total number of work units for the task
* @param name the name of the task
* @param params the parameters for localization
*/
- void beginTask( double totalWork, I18n name, Object... params );
+ void beginTask( double totalWork,
+ I18n name,
+ Object... params );
/**
- * Report work completed for this task.
+ * Called by the <strong>Updater</strong> to report work completed for this task.
+ *
* @param work the number of work units that have been worked
*/
void worked( double work );
/**
- * Create a subtask with the given about of work. The resulting monitor must be started ({@link #beginTask(double, I18n, Object...)})
- * and finished ({@link #done()}).
+ * Called by the <strong>Updater</strong> to create a subtask with the given about of work. The resulting progress monitor
+ * must be started ({@link #beginTask(double, I18n, Object...)}) and finished ({@link #done()}).
+ *
* @param subtaskWork the number of work units for this subtask
* @return the progress monitor for the subtask
*/
ProgressMonitor createSubtask( double subtaskWork );
/**
- * Mark this task as being completed. This method must be called for the task to be properly completed.
+ * Called by the <strong>Updater</strong> to mark this activity as complete. This method must be called, even if the activity
+ * has been cancelled.
*/
void done();
/**
- * Set the cancelled state of this activity. Cancelling the activity must be considered a request that can be denied by
- * setting the cancelled state to <code>false</code>.
- * @param value true if requesting the activity be cancelled.
+ * Return whether this activity has completed.
+ *
+ * @return <code>true</code> if this activity has completed.
*/
+ boolean isDone();
+
+ /**
+ * Called by an <strong>Observer</strong> to request the cancellation of this activity, or by the <strong>Updater</strong>
+ * to deny a prior cancellation request (i.e., when the activity {@link #done() completes} before the <strong>Updater</strong>
+ * recognizes a cancellation request by an <strong>Observer</strong>).
+ *
+ * @param value <code>true</code> if requesting the activity be cancelled.
+ */
void setCancelled( boolean value );
/**
- * Returned whether this activity has been {@link #setCancelled(boolean) cancelled}.
- * @return true if this activity has been requested to be cancelled, or false otherwise.
+ * Return whether a request was made by an <strong>Observer</strong> to {@link #setCancelled(boolean) cancel} this activity.
+ *
+ * @return <code>true</code> if this activity has been requested to be cancelled.
*/
boolean isCancelled();
@@ -87,9 +116,18 @@
* Return the current status of this activity, localized to the specified locale. This method returns an immutable but
* consistent snapshot of the status for this activity. Note that if this instance is a {@link #createSubtask(double) subtask},
* this method returns the status of the subtask.
+ *
* @param locale the locale in which the status is to be represented; if null, the {@link Locale#getDefault() default locale}
- * will be used
+ * will be used
* @return the status of this activity
*/
ProgressStatus getStatus( Locale locale );
+
+ /**
+ * Return the problems encountered during the {@link #getStatus(Locale) progress} made towards completing the associated
+ * {@link #getActivityName() activity}.
+ *
+ * @return the list of problems
+ */
+ Problems getProblems();
}
Modified: branches/maeste/dna-common/src/main/java/org/jboss/dna/common/monitor/ProgressMonitorWrapper.java
===================================================================
--- branches/maeste/dna-common/src/main/java/org/jboss/dna/common/monitor/ProgressMonitorWrapper.java 2008-06-11 08:35:21 UTC (rev 264)
+++ branches/maeste/dna-common/src/main/java/org/jboss/dna/common/monitor/ProgressMonitorWrapper.java 2008-06-11 08:45:51 UTC (rev 265)
@@ -23,10 +23,14 @@
package org.jboss.dna.common.monitor;
import java.util.Locale;
+import org.jboss.dna.common.collection.Problems;
import org.jboss.dna.common.i18n.I18n;
/**
+ * The thread safety of this class is determined by the delegate.
+ *
* @author Randall Hauch
+ * @author John Verhaeg
*/
public class ProgressMonitorWrapper implements ProgressMonitor {
@@ -36,67 +40,61 @@
this.delegate = delegate;
}
- /**
- * @return the wrapped progress monitor
- */
public ProgressMonitor getWrappedMonitor() {
return this.delegate;
}
- /**
- * {@inheritDoc}
- */
- public void beginTask( double totalWork, I18n name, Object... params ) {
+ public void beginTask( double totalWork,
+ I18n name,
+ Object... params ) {
this.delegate.beginTask(totalWork, name, params);
}
- /**
- * {@inheritDoc}
- */
public ProgressMonitor createSubtask( double subtaskWork ) {
return this.delegate.createSubtask(subtaskWork);
}
- /**
- * {@inheritDoc}
- */
public void done() {
this.delegate.done();
}
- /**
- * {@inheritDoc}
- */
public String getActivityName() {
return this.delegate.getActivityName();
}
- /**
- * {@inheritDoc}
- */
public ProgressStatus getStatus( Locale locale ) {
return this.delegate.getStatus(locale);
}
/**
+ * <p>
* {@inheritDoc}
+ * </p>
+ *
+ * @see org.jboss.dna.common.monitor.ProgressMonitor#getProblems()
*/
+ public Problems getProblems() {
+ return delegate.getProblems();
+ }
+
public boolean isCancelled() {
return this.delegate.isCancelled();
}
/**
* {@inheritDoc}
+ *
+ * @see org.jboss.dna.common.monitor.ProgressMonitor#isDone()
*/
+ public boolean isDone() {
+ return delegate.isDone();
+ }
+
public void setCancelled( boolean value ) {
this.delegate.setCancelled(value);
}
- /**
- * {@inheritDoc}
- */
public void worked( double work ) {
this.delegate.worked(work);
}
-
}
Modified: branches/maeste/dna-common/src/main/java/org/jboss/dna/common/monitor/SimpleProgressMonitor.java
===================================================================
--- branches/maeste/dna-common/src/main/java/org/jboss/dna/common/monitor/SimpleProgressMonitor.java 2008-06-11 08:35:21 UTC (rev 264)
+++ branches/maeste/dna-common/src/main/java/org/jboss/dna/common/monitor/SimpleProgressMonitor.java 2008-06-11 08:45:51 UTC (rev 265)
@@ -27,14 +27,21 @@
import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
import net.jcip.annotations.GuardedBy;
-import net.jcip.annotations.ThreadSafe;
+import org.jboss.dna.common.collection.Problems;
+import org.jboss.dna.common.collection.SimpleProblems;
import org.jboss.dna.common.i18n.I18n;
/**
- * A basic progress monitor
+ * A basic progress monitor.
+ * <p>
+ * This class is thread-safe except when accessing or adding {@link #getProblems() problems}. Problems must only be added by the
+ * {@link ProgressMonitor <strong>Updater</strong>}, and accessed by {@link ProgressMonitor Observers} only after the activity
+ * has been {@link #done() completed}.
+ * </p>
+ *
* @author Randall Hauch
+ * @author John Verhaeg
*/
-@ThreadSafe
public class SimpleProgressMonitor implements ProgressMonitor {
@GuardedBy( "lock" )
@@ -45,12 +52,11 @@
private double totalWork;
@GuardedBy( "lock" )
private double worked;
- @GuardedBy( "lock" )
- private boolean done;
private final String activityName;
private final ReadWriteLock lock = new ReentrantReadWriteLock();
private final AtomicBoolean cancelled = new AtomicBoolean(false);
+ private final Problems problems = new SimpleProblems();
public SimpleProgressMonitor( String activityName ) {
this.activityName = activityName != null ? activityName.trim() : "";
@@ -68,7 +74,9 @@
/**
* {@inheritDoc}
*/
- public void beginTask( double totalWork, I18n name, Object... params ) {
+ public void beginTask( double totalWork,
+ I18n name,
+ Object... params ) {
assert totalWork > 0;
try {
this.lock.writeLock().lock();
@@ -89,13 +97,17 @@
}
/**
+ * <p>
* {@inheritDoc}
+ * </p>
+ *
+ * @see org.jboss.dna.common.monitor.ProgressMonitor#done()
*/
public void done() {
boolean alreadyDone = false;
try {
this.lock.writeLock().lock();
- if (!this.done) {
+ if (this.worked < this.totalWork) {
this.worked = this.totalWork;
} else {
alreadyDone = true;
@@ -115,7 +127,21 @@
/**
* {@inheritDoc}
+ *
+ * @see org.jboss.dna.common.monitor.ProgressMonitor#isDone()
*/
+ public boolean isDone() {
+ lock.readLock().lock();
+ try {
+ return worked >= totalWork;
+ } finally {
+ lock.readLock().unlock();
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
public void setCancelled( boolean value ) {
this.cancelled.set(value);
}
@@ -162,4 +188,17 @@
protected void notifyProgress() {
// do nothing
}
+
+ /**
+ * {@inheritDoc}
+ * <p>
+ * Problems must only be added by the {@link ProgressMonitor <strong>Updater</strong>}, and accessed by
+ * {@link ProgressMonitor Observers} only after the activity has been {@link #done() completed}.
+ * </p>
+ *
+ * @see org.jboss.dna.common.monitor.ProgressMonitor#getProblems()
+ */
+ public Problems getProblems() {
+ return problems;
+ }
}
Modified: branches/maeste/dna-common/src/main/java/org/jboss/dna/common/monitor/SubProgressMonitor.java
===================================================================
--- branches/maeste/dna-common/src/main/java/org/jboss/dna/common/monitor/SubProgressMonitor.java 2008-06-11 08:35:21 UTC (rev 264)
+++ branches/maeste/dna-common/src/main/java/org/jboss/dna/common/monitor/SubProgressMonitor.java 2008-06-11 08:45:51 UTC (rev 265)
@@ -25,14 +25,17 @@
import java.util.Locale;
import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
+import net.jcip.annotations.GuardedBy;
+import org.jboss.dna.common.collection.Problems;
import org.jboss.dna.common.i18n.I18n;
-import net.jcip.annotations.GuardedBy;
-import net.jcip.annotations.NotThreadSafe;
/**
+ * This class is thread-safe except when accessing or adding {@link #getProblems() problems}. Problems must only be added by the
+ * {@link ProgressMonitor <strong>Updater</strong>}, and accessed by {@link ProgressMonitor Observers} only after the activity
+ * has been {@link #done() completed}.
+ *
* @author Randall Hauch
*/
-@NotThreadSafe
public class SubProgressMonitor implements ProgressMonitor {
@GuardedBy( "lock" )
@@ -50,7 +53,8 @@
private final ProgressMonitor parent;
private final ReadWriteLock lock = new ReentrantReadWriteLock();
- public SubProgressMonitor( final ProgressMonitor parent, final double subtaskTotalInParent ) {
+ public SubProgressMonitor( final ProgressMonitor parent,
+ final double subtaskTotalInParent ) {
assert subtaskTotalInParent > 0;
assert parent != null;
this.parent = parent;
@@ -74,7 +78,9 @@
/**
* {@inheritDoc}
*/
- public void beginTask( double totalWork, I18n name, Object... params ) {
+ public void beginTask( double totalWork,
+ I18n name,
+ Object... params ) {
assert totalWork > 0;
try {
this.lock.writeLock().lock();
@@ -120,7 +126,16 @@
/**
* {@inheritDoc}
+ *
+ * @see org.jboss.dna.common.monitor.ProgressMonitor#isDone()
*/
+ public boolean isDone() {
+ return parent.isDone();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
public void setCancelled( boolean value ) {
this.parent.setCancelled(value);
}
@@ -150,9 +165,19 @@
public ProgressStatus getStatus( Locale locale ) {
try {
this.lock.readLock().lock();
- return new ProgressStatus(this.getActivityName(), this.taskName.text(locale, this.params), this.submittedToParent, this.subtaskTotalInParent, this.isCancelled());
+ return new ProgressStatus(this.getActivityName(), this.taskName.text(locale, this.params), this.submittedToParent,
+ this.subtaskTotalInParent, this.isCancelled());
} finally {
this.lock.readLock().unlock();
}
}
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.common.monitor.ProgressMonitor#getProblems()
+ */
+ public Problems getProblems() {
+ return parent.getProblems();
+ }
}
Modified: branches/maeste/dna-common/src/test/java/org/jboss/dna/common/AbstractI18nTest.java
===================================================================
--- branches/maeste/dna-common/src/test/java/org/jboss/dna/common/AbstractI18nTest.java 2008-06-11 08:35:21 UTC (rev 264)
+++ branches/maeste/dna-common/src/test/java/org/jboss/dna/common/AbstractI18nTest.java 2008-06-11 08:45:51 UTC (rev 265)
@@ -1,5 +1,23 @@
/*
+ * 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.common;
@@ -39,7 +57,8 @@
@Test
public void shouldNotHaveProblems() throws IllegalAccessException {
for (Field fld : i18nClass.getDeclaredFields()) {
- if (fld.getType() == I18n.class && (fld.getModifiers() & Modifier.PUBLIC) == Modifier.PUBLIC && (fld.getModifiers() & Modifier.STATIC) == Modifier.STATIC
+ if (fld.getType() == I18n.class && (fld.getModifiers() & Modifier.PUBLIC) == Modifier.PUBLIC
+ && (fld.getModifiers() & Modifier.STATIC) == Modifier.STATIC
&& (fld.getModifiers() & Modifier.FINAL) != Modifier.FINAL) {
I18n i18n = (I18n)fld.get(null);
if (i18n.hasProblem()) {
Modified: branches/maeste/dna-common/src/test/java/org/jboss/dna/common/CommonI18nTest.java
===================================================================
--- branches/maeste/dna-common/src/test/java/org/jboss/dna/common/CommonI18nTest.java 2008-06-11 08:35:21 UTC (rev 264)
+++ branches/maeste/dna-common/src/test/java/org/jboss/dna/common/CommonI18nTest.java 2008-06-11 08:45:51 UTC (rev 265)
@@ -1,5 +1,23 @@
/*
+ * 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.common;
@@ -8,7 +26,7 @@
*/
public class CommonI18nTest extends AbstractI18nTest {
- public CommonI18nTest() {
- super(CommonI18n.class);
- }
+ public CommonI18nTest() {
+ super(CommonI18n.class);
+ }
}
Modified: branches/maeste/dna-common/src/test/java/org/jboss/dna/common/component/ComponentConfigTest.java
===================================================================
--- branches/maeste/dna-common/src/test/java/org/jboss/dna/common/component/ComponentConfigTest.java 2008-06-11 08:35:21 UTC (rev 264)
+++ branches/maeste/dna-common/src/test/java/org/jboss/dna/common/component/ComponentConfigTest.java 2008-06-11 08:45:51 UTC (rev 265)
@@ -41,7 +41,7 @@
private String[] validClasspath;
@Before
- public void beforeEach() throws Exception {
+ public void beforeEach() {
this.validName = "valid configuration name";
this.validDescription = "a Component";
this.validClassname = "org.jboss.dna.acme.GenericComponent";
Modified: branches/maeste/dna-common/src/test/java/org/jboss/dna/common/component/ComponentLibraryTest.java
===================================================================
--- branches/maeste/dna-common/src/test/java/org/jboss/dna/common/component/ComponentLibraryTest.java 2008-06-11 08:35:21 UTC (rev 264)
+++ branches/maeste/dna-common/src/test/java/org/jboss/dna/common/component/ComponentLibraryTest.java 2008-06-11 08:45:51 UTC (rev 265)
@@ -28,13 +28,15 @@
import static org.hamcrest.core.IsSame.sameInstance;
import static org.junit.Assert.assertThat;
import java.util.List;
-import org.jboss.dna.common.monitor.NullProgressMonitor;
import org.jboss.dna.common.monitor.ProgressMonitor;
import org.junit.Before;
import org.junit.Test;
+import org.mockito.MockitoAnnotations;
+import org.mockito.MockitoAnnotations.Mock;
/**
* @author Randall Hauch
+ * @author John Verhaeg
*/
public class ComponentLibraryTest {
@@ -44,10 +46,12 @@
private SampleComponentConfig configA2;
private String validDescription;
private String[] validClasspath;
- private ProgressMonitor nullMonitor = new NullProgressMonitor(ComponentLibraryTest.class.getName());
+ @Mock
+ private ProgressMonitor nullMonitor;
@Before
- public void beforeEach() throws Exception {
+ public void beforeEach() {
+ MockitoAnnotations.initMocks(this);
this.library = new ComponentLibrary<SampleComponent, SampleComponentConfig>();
this.validDescription = "a Component";
this.validClasspath = new String[] {"com.acme:configA:1.0,com.acme:configB:1.0"};
Modified: branches/maeste/dna-common/src/test/java/org/jboss/dna/common/i18n/I18nTest.java
===================================================================
--- branches/maeste/dna-common/src/test/java/org/jboss/dna/common/i18n/I18nTest.java 2008-06-11 08:35:21 UTC (rev 264)
+++ branches/maeste/dna-common/src/test/java/org/jboss/dna/common/i18n/I18nTest.java 2008-06-11 08:45:51 UTC (rev 265)
@@ -46,406 +46,406 @@
*/
public final class I18nTest {
- @Before
- public void beforeEach() throws Exception {
- clearFields(TestI18n.class);
- clearFields(TestI18nDuplicateProperty.class);
- clearFields(TestI18nFinal.class);
- clearFields(TestI18nFinalField.class);
- clearFields(TestI18nInterface.class);
- clearFields(TestI18nMissingLocalization.class);
- clearFields(TestI18nMissingProperty.class);
- clearFields(TestI18nNotPublicField.class);
- clearFields(TestI18nNotStaticField.class);
- clearFields(TestI18nPrivate.class);
- clearFields(TestI18nUnusedProperty.class);
- for (Entry<Locale, Map<Class, Set<String>>> localeToMapEntry : I18n.LOCALE_TO_CLASS_TO_PROBLEMS_MAP.entrySet()) {
- for (Iterator<Entry<Class, Set<String>>> iter = localeToMapEntry.getValue().entrySet().iterator(); iter.hasNext();) {
- if (iter.next().getKey() != CommonI18n.class) {
- iter.remove();
- }
- }
- }
- }
+ @Before
+ public void beforeEach() throws Exception {
+ clearFields(TestI18n.class);
+ clearFields(TestI18nDuplicateProperty.class);
+ clearFields(TestI18nFinal.class);
+ clearFields(TestI18nFinalField.class);
+ clearFields(TestI18nInterface.class);
+ clearFields(TestI18nMissingLocalization.class);
+ clearFields(TestI18nMissingProperty.class);
+ clearFields(TestI18nNotPublicField.class);
+ clearFields(TestI18nNotStaticField.class);
+ clearFields(TestI18nPrivate.class);
+ clearFields(TestI18nUnusedProperty.class);
+ for (Entry<Locale, Map<Class, Set<String>>> localeToMapEntry : I18n.LOCALE_TO_CLASS_TO_PROBLEMS_MAP.entrySet()) {
+ for (Iterator<Entry<Class, Set<String>>> iter = localeToMapEntry.getValue().entrySet().iterator(); iter.hasNext();) {
+ if (iter.next().getKey() != CommonI18n.class) {
+ iter.remove();
+ }
+ }
+ }
+ }
- private void clearFields( Class i18nClass ) throws Exception {
- for (Field fld : i18nClass.getDeclaredFields()) {
- if (fld.getType() == I18n.class && (fld.getModifiers() & Modifier.PUBLIC) == Modifier.PUBLIC
- && (fld.getModifiers() & Modifier.STATIC) == Modifier.STATIC
- && (fld.getModifiers() & Modifier.FINAL) != Modifier.FINAL) {
- fld.set(null, null);
- }
- }
- }
+ private void clearFields( Class i18nClass ) throws Exception {
+ for (Field fld : i18nClass.getDeclaredFields()) {
+ if (fld.getType() == I18n.class && (fld.getModifiers() & Modifier.PUBLIC) == Modifier.PUBLIC
+ && (fld.getModifiers() & Modifier.STATIC) == Modifier.STATIC
+ && (fld.getModifiers() & Modifier.FINAL) != Modifier.FINAL) {
+ fld.set(null, null);
+ }
+ }
+ }
- @Test( expected = IllegalArgumentException.class )
- public void shouldFailToGetLocalizationProblemLocalesIfNoClassSupplied() {
- I18n.getLocalizationProblemLocales(null);
- }
+ @Test( expected = IllegalArgumentException.class )
+ public void shouldFailToGetLocalizationProblemLocalesIfNoClassSupplied() {
+ I18n.getLocalizationProblemLocales(null);
+ }
- @Test
- public void shouldNeverReturnNullWhenGettingLocalizationProblemLocales() {
- assertThat(I18n.getLocalizationProblemLocales(TestI18n.class), notNullValue());
- }
+ @Test
+ public void shouldNeverReturnNullWhenGettingLocalizationProblemLocales() {
+ assertThat(I18n.getLocalizationProblemLocales(TestI18n.class), notNullValue());
+ }
- @Test( expected = IllegalArgumentException.class )
- public void shouldFailToGetLocalizationProblemsForDefaultLocaleIfNoClassSupplied() {
- I18n.getLocalizationProblems(null);
- }
+ @Test( expected = IllegalArgumentException.class )
+ public void shouldFailToGetLocalizationProblemsForDefaultLocaleIfNoClassSupplied() {
+ I18n.getLocalizationProblems(null);
+ }
- @Test( expected = IllegalArgumentException.class )
- public void shouldFailToGetLocalizationProblemsForSuppliedLocaleIfNoClassSupplied() {
- I18n.getLocalizationProblems(null, Locale.US);
- }
+ @Test( expected = IllegalArgumentException.class )
+ public void shouldFailToGetLocalizationProblemsForSuppliedLocaleIfNoClassSupplied() {
+ I18n.getLocalizationProblems(null, Locale.US);
+ }
- @Test
- public void shouldNeverReturnNullWhenGettingLocalizationProblemsForDefaultLocale() {
- assertThat(I18n.getLocalizationProblems(TestI18n.class), notNullValue());
- }
+ @Test
+ public void shouldNeverReturnNullWhenGettingLocalizationProblemsForDefaultLocale() {
+ assertThat(I18n.getLocalizationProblems(TestI18n.class), notNullValue());
+ }
- @Test
- public void shouldNeverReturnNullWhenGettingLocalizationProblemsForSuppliedLocale() {
- assertThat(I18n.getLocalizationProblems(TestI18n.class, Locale.US), notNullValue());
- }
+ @Test
+ public void shouldNeverReturnNullWhenGettingLocalizationProblemsForSuppliedLocale() {
+ assertThat(I18n.getLocalizationProblems(TestI18n.class, Locale.US), notNullValue());
+ }
- @Test
- public void shouldNotHaveLocalizationProblemsAfterInitializationButBeforeLocalization() {
- I18n.initialize(TestI18nUnusedProperty.class);
- assertThat(I18n.getLocalizationProblems(TestI18nUnusedProperty.class, null).isEmpty(), is(true));
- assertThat(I18n.getLocalizationProblemLocales(TestI18nUnusedProperty.class).isEmpty(), is(true));
- }
+ @Test
+ public void shouldNotHaveLocalizationProblemsAfterInitializationButBeforeLocalization() {
+ I18n.initialize(TestI18nUnusedProperty.class);
+ assertThat(I18n.getLocalizationProblems(TestI18nUnusedProperty.class, null).isEmpty(), is(true));
+ assertThat(I18n.getLocalizationProblemLocales(TestI18nUnusedProperty.class).isEmpty(), is(true));
+ }
- @Test
- public void shouldGetLocalizationProblemsForDefaultLocaleIfNoLocaleSupplied() {
- I18n.initialize(TestI18nUnusedProperty.class);
- TestI18nUnusedProperty.testMessage.text("test");
- assertThat(I18n.getLocalizationProblems(TestI18nUnusedProperty.class, null).isEmpty(), is(false));
- }
+ @Test
+ public void shouldGetLocalizationProblemsForDefaultLocaleIfNoLocaleSupplied() {
+ I18n.initialize(TestI18nUnusedProperty.class);
+ TestI18nUnusedProperty.testMessage.text("test");
+ assertThat(I18n.getLocalizationProblems(TestI18nUnusedProperty.class, null).isEmpty(), is(false));
+ }
- @Test( expected = IllegalArgumentException.class )
- public void shouldFailToInitializeIfNoClassSupplied() {
- I18n.initialize(null);
- }
+ @Test( expected = IllegalArgumentException.class )
+ public void shouldFailToInitializeIfNoClassSupplied() {
+ I18n.initialize(null);
+ }
- @Test( expected = SystemFailureException.class )
- public void shouldFailToInitializeFinalI18nField() {
- try {
- I18n.initialize(TestI18nFinalField.class);
- } catch (SystemFailureException err) {
- assertThat(err.getMessage(), is(CommonI18n.i18nFieldFinal.text("testMessage", TestI18nFinalField.class)));
- System.err.println(err);
- throw err;
- }
- }
+ @Test( expected = SystemFailureException.class )
+ public void shouldFailToInitializeFinalI18nField() {
+ try {
+ I18n.initialize(TestI18nFinalField.class);
+ } catch (SystemFailureException err) {
+ assertThat(err.getMessage(), is(CommonI18n.i18nFieldFinal.text("testMessage", TestI18nFinalField.class)));
+ System.err.println(err);
+ throw err;
+ }
+ }
- @Test( expected = SystemFailureException.class )
- public void shouldFailToInitializeNonPublicI18nField() {
- try {
- I18n.initialize(TestI18nNotPublicField.class);
- } catch (SystemFailureException err) {
- assertThat(err.getMessage(), is(CommonI18n.i18nFieldNotPublic.text("testMessage", TestI18nNotPublicField.class)));
- System.err.println(err);
- throw err;
- }
- }
+ @Test( expected = SystemFailureException.class )
+ public void shouldFailToInitializeNonPublicI18nField() {
+ try {
+ I18n.initialize(TestI18nNotPublicField.class);
+ } catch (SystemFailureException err) {
+ assertThat(err.getMessage(), is(CommonI18n.i18nFieldNotPublic.text("testMessage", TestI18nNotPublicField.class)));
+ System.err.println(err);
+ throw err;
+ }
+ }
- @Test( expected = SystemFailureException.class )
- public void shouldFailToInitializeNonStaticI18nField() {
- try {
- I18n.initialize(TestI18nNotStaticField.class);
- } catch (SystemFailureException err) {
- assertThat(err.getMessage(), is(CommonI18n.i18nFieldNotStatic.text("testMessage", TestI18nNotStaticField.class)));
- System.err.println(err);
- throw err;
- }
- }
+ @Test( expected = SystemFailureException.class )
+ public void shouldFailToInitializeNonStaticI18nField() {
+ try {
+ I18n.initialize(TestI18nNotStaticField.class);
+ } catch (SystemFailureException err) {
+ assertThat(err.getMessage(), is(CommonI18n.i18nFieldNotStatic.text("testMessage", TestI18nNotStaticField.class)));
+ System.err.println(err);
+ throw err;
+ }
+ }
- @Test
- public void shouldInitializeFinalClasses() {
- I18n.initialize(TestI18nFinal.class);
- assertThat(TestI18nFinal.testMessage, instanceOf(I18n.class));
- }
+ @Test
+ public void shouldInitializeFinalClasses() {
+ I18n.initialize(TestI18nFinal.class);
+ assertThat(TestI18nFinal.testMessage, instanceOf(I18n.class));
+ }
- @Test
- public void shouldInitializePrivateClasses() {
- I18n.initialize(TestI18nPrivate.class);
- assertThat(TestI18nPrivate.testMessage, instanceOf(I18n.class));
- }
+ @Test
+ public void shouldInitializePrivateClasses() {
+ I18n.initialize(TestI18nPrivate.class);
+ assertThat(TestI18nPrivate.testMessage, instanceOf(I18n.class));
+ }
- @Test
- public void shouldInitializeI18nFields() {
- I18n.initialize(TestI18n.class);
- assertThat(TestI18n.testMessage, instanceOf(I18n.class));
- }
+ @Test
+ public void shouldInitializeI18nFields() {
+ I18n.initialize(TestI18n.class);
+ assertThat(TestI18n.testMessage, instanceOf(I18n.class));
+ }
- @Test
- public void shouldNotInitializeNonI18nFields() {
- I18n.initialize(TestI18n.class);
- assertThat(TestI18n.nonI18n, nullValue());
- }
+ @Test
+ public void shouldNotInitializeNonI18nFields() {
+ I18n.initialize(TestI18n.class);
+ assertThat(TestI18n.nonI18n, nullValue());
+ }
- @Test( expected = IllegalArgumentException.class )
- public void shouldFailToInitializeInterfaces() {
- try {
- I18n.initialize(TestI18nInterface.class);
- } catch (IllegalArgumentException err) {
- assertThat(err.getMessage(), is(CommonI18n.i18nClassInterface.text(TestI18nInterface.class.getName())));
- System.err.println(err);
- throw err;
- }
- }
+ @Test( expected = IllegalArgumentException.class )
+ public void shouldFailToInitializeInterfaces() {
+ try {
+ I18n.initialize(TestI18nInterface.class);
+ } catch (IllegalArgumentException err) {
+ assertThat(err.getMessage(), is(CommonI18n.i18nClassInterface.text(TestI18nInterface.class.getName())));
+ System.err.println(err);
+ throw err;
+ }
+ }
- @Test
- public void shouldProvideIdempotentInitialization() {
- I18n.initialize(TestI18n.class);
- assertThat(TestI18n.testMessage1.text("test"), is("test"));
- I18n.initialize(TestI18n.class);
- assertThat(TestI18n.testMessage1.text("test"), is("test"));
- }
+ @Test
+ public void shouldProvideIdempotentInitialization() {
+ I18n.initialize(TestI18n.class);
+ assertThat(TestI18n.testMessage1.text("test"), is("test"));
+ I18n.initialize(TestI18n.class);
+ assertThat(TestI18n.testMessage1.text("test"), is("test"));
+ }
- @Test
- public void shouldNotBeLocalizedAfterInitialization() {
- I18n.initialize(TestI18nDuplicateProperty.class);
- assertThat(TestI18nDuplicateProperty.testMessage.localeToTextMap.get(Locale.getDefault()), nullValue());
- assertThat(TestI18nDuplicateProperty.testMessage.localeToProblemMap.get(Locale.getDefault()), nullValue());
- }
+ @Test
+ public void shouldNotBeLocalizedAfterInitialization() {
+ I18n.initialize(TestI18nDuplicateProperty.class);
+ assertThat(TestI18nDuplicateProperty.testMessage.localeToTextMap.get(Locale.getDefault()), nullValue());
+ assertThat(TestI18nDuplicateProperty.testMessage.localeToProblemMap.get(Locale.getDefault()), nullValue());
+ }
- @Test
- public void shouldHaveIdThatMatchesFieldName() throws Exception {
- I18n.initialize(TestI18n.class);
- assertThat(TestI18n.testMessage.id(), is("testMessage"));
- }
+ @Test
+ public void shouldHaveIdThatMatchesFieldName() {
+ I18n.initialize(TestI18n.class);
+ assertThat(TestI18n.testMessage.id(), is("testMessage"));
+ }
- @Test
- public void shouldNotBeLocalizedIfAskedForId() {
- I18n.initialize(TestI18nDuplicateProperty.class);
- TestI18nDuplicateProperty.testMessage.id();
- assertThat(TestI18nDuplicateProperty.testMessage.localeToTextMap.get(Locale.getDefault()), nullValue());
- assertThat(TestI18nDuplicateProperty.testMessage.localeToProblemMap.get(Locale.getDefault()), nullValue());
- }
+ @Test
+ public void shouldNotBeLocalizedIfAskedForId() {
+ I18n.initialize(TestI18nDuplicateProperty.class);
+ TestI18nDuplicateProperty.testMessage.id();
+ assertThat(TestI18nDuplicateProperty.testMessage.localeToTextMap.get(Locale.getDefault()), nullValue());
+ assertThat(TestI18nDuplicateProperty.testMessage.localeToProblemMap.get(Locale.getDefault()), nullValue());
+ }
- @Test
- public void shouldBeLocalizedIfAskedIfHasProblem() {
- I18n.initialize(TestI18nDuplicateProperty.class);
- TestI18nDuplicateProperty.testMessage.hasProblem();
- assertThat(TestI18nDuplicateProperty.testMessage.localeToTextMap.get(Locale.getDefault()), notNullValue());
- assertThat(TestI18nDuplicateProperty.testMessage.localeToProblemMap.get(Locale.getDefault()), notNullValue());
- }
+ @Test
+ public void shouldBeLocalizedIfAskedIfHasProblem() {
+ I18n.initialize(TestI18nDuplicateProperty.class);
+ TestI18nDuplicateProperty.testMessage.hasProblem();
+ assertThat(TestI18nDuplicateProperty.testMessage.localeToTextMap.get(Locale.getDefault()), notNullValue());
+ assertThat(TestI18nDuplicateProperty.testMessage.localeToProblemMap.get(Locale.getDefault()), notNullValue());
+ }
- @Test
- public void shouldBeLocalizedIfAskedForProblem() {
- I18n.initialize(TestI18nDuplicateProperty.class);
- TestI18nDuplicateProperty.testMessage.problem();
- assertThat(TestI18nDuplicateProperty.testMessage.localeToTextMap.get(Locale.getDefault()), notNullValue());
- assertThat(TestI18nDuplicateProperty.testMessage.localeToProblemMap.get(Locale.getDefault()), notNullValue());
- }
+ @Test
+ public void shouldBeLocalizedIfAskedForProblem() {
+ I18n.initialize(TestI18nDuplicateProperty.class);
+ TestI18nDuplicateProperty.testMessage.problem();
+ assertThat(TestI18nDuplicateProperty.testMessage.localeToTextMap.get(Locale.getDefault()), notNullValue());
+ assertThat(TestI18nDuplicateProperty.testMessage.localeToProblemMap.get(Locale.getDefault()), notNullValue());
+ }
- @Test
- public void shouldBeLocalizedIfConvertedToString() {
- I18n.initialize(TestI18nDuplicateProperty.class);
- TestI18nDuplicateProperty.testMessage.toString();
- assertThat(TestI18nDuplicateProperty.testMessage.localeToTextMap.get(Locale.getDefault()), notNullValue());
- assertThat(TestI18nDuplicateProperty.testMessage.localeToProblemMap.get(Locale.getDefault()), notNullValue());
- }
+ @Test
+ public void shouldBeLocalizedIfConvertedToString() {
+ I18n.initialize(TestI18nDuplicateProperty.class);
+ TestI18nDuplicateProperty.testMessage.toString();
+ assertThat(TestI18nDuplicateProperty.testMessage.localeToTextMap.get(Locale.getDefault()), notNullValue());
+ assertThat(TestI18nDuplicateProperty.testMessage.localeToProblemMap.get(Locale.getDefault()), notNullValue());
+ }
- @Test
- public void shouldContainAngleBracketedProblemInTextIfMissingLocalization() throws Exception {
- I18n.initialize(TestI18nMissingLocalization.class);
- String text = TestI18nMissingLocalization.testMessage.text();
- assertThat(text,
- is('<' + CommonI18n.i18nLocalizationProblems.text(TestI18nMissingLocalization.class, Locale.getDefault()) + '>'));
- System.out.println("Text: " + text);
- }
+ @Test
+ public void shouldContainAngleBracketedProblemInTextIfMissingLocalization() {
+ I18n.initialize(TestI18nMissingLocalization.class);
+ String text = TestI18nMissingLocalization.testMessage.text();
+ assertThat(text,
+ is('<' + CommonI18n.i18nLocalizationProblems.text(TestI18nMissingLocalization.class, Locale.getDefault()) + '>'));
+ System.out.println("Text: " + text);
+ }
- @Test
- public void shouldHaveProblemIfMissingLocalization() throws Exception {
- I18n.initialize(TestI18nMissingLocalization.class);
- assertThat(TestI18nMissingLocalization.testMessage.hasProblem(), is(true));
- String problem = TestI18nMissingLocalization.testMessage.problem();
- assertThat(problem, is(CommonI18n.i18nLocalizationProblems.text(TestI18nMissingLocalization.class, Locale.getDefault())));
- System.out.println("Problem: " + problem);
- }
+ @Test
+ public void shouldHaveProblemIfMissingLocalization() {
+ I18n.initialize(TestI18nMissingLocalization.class);
+ assertThat(TestI18nMissingLocalization.testMessage.hasProblem(), is(true));
+ String problem = TestI18nMissingLocalization.testMessage.problem();
+ assertThat(problem, is(CommonI18n.i18nLocalizationProblems.text(TestI18nMissingLocalization.class, Locale.getDefault())));
+ System.out.println("Problem: " + problem);
+ }
- @Test
- public void shouldHaveLocalicationProblemIfMissingLocalization() throws Exception {
- I18n.initialize(TestI18nMissingLocalization.class);
- TestI18nMissingLocalization.testMessage.text();
- assertThat(I18n.getLocalizationProblems(TestI18nMissingLocalization.class).size(), is(1));
- assertThat(I18n.getLocalizationProblems(TestI18nMissingLocalization.class).iterator().next(),
- is(CommonI18n.i18nLocalizationFileNotFound.text(TestI18nMissingLocalization.class.getName())));
- assertThat(I18n.getLocalizationProblemLocales(TestI18nMissingLocalization.class).size(), is(1));
- assertThat(I18n.getLocalizationProblemLocales(TestI18nMissingLocalization.class).iterator().next(),
- is(Locale.getDefault()));
- }
+ @Test
+ public void shouldHaveLocalicationProblemIfMissingLocalization() {
+ I18n.initialize(TestI18nMissingLocalization.class);
+ TestI18nMissingLocalization.testMessage.text();
+ assertThat(I18n.getLocalizationProblems(TestI18nMissingLocalization.class).size(), is(1));
+ assertThat(I18n.getLocalizationProblems(TestI18nMissingLocalization.class).iterator().next(),
+ is(CommonI18n.i18nLocalizationFileNotFound.text(TestI18nMissingLocalization.class.getName())));
+ assertThat(I18n.getLocalizationProblemLocales(TestI18nMissingLocalization.class).size(), is(1));
+ assertThat(I18n.getLocalizationProblemLocales(TestI18nMissingLocalization.class).iterator().next(),
+ is(Locale.getDefault()));
+ }
- @Test
- public void shouldHaveTextIfPropertyDuplicate() throws Exception {
- I18n.initialize(TestI18nDuplicateProperty.class);
- String text = TestI18nDuplicateProperty.testMessage.text("test");
- assertThat(text.charAt(0), not('<'));
- System.out.println("Text: " + text);
- }
+ @Test
+ public void shouldHaveTextIfPropertyDuplicate() {
+ I18n.initialize(TestI18nDuplicateProperty.class);
+ String text = TestI18nDuplicateProperty.testMessage.text("test");
+ assertThat(text.charAt(0), not('<'));
+ System.out.println("Text: " + text);
+ }
- @Test
- public void shouldHaveProblemIfPropertyDuplicate() throws Exception {
- I18n.initialize(TestI18nDuplicateProperty.class);
- assertThat(TestI18nDuplicateProperty.testMessage.hasProblem(), is(true));
- String problem = TestI18nDuplicateProperty.testMessage.problem();
- assertThat(problem, notNullValue());
- System.out.println("Problem: " + problem);
- }
+ @Test
+ public void shouldHaveProblemIfPropertyDuplicate() {
+ I18n.initialize(TestI18nDuplicateProperty.class);
+ assertThat(TestI18nDuplicateProperty.testMessage.hasProblem(), is(true));
+ String problem = TestI18nDuplicateProperty.testMessage.problem();
+ assertThat(problem, notNullValue());
+ System.out.println("Problem: " + problem);
+ }
- @Test
- public void shouldNotHaveLocalicationProblemIfPropertyDuplicate() throws Exception {
- I18n.initialize(TestI18nDuplicateProperty.class);
- TestI18nDuplicateProperty.testMessage.text("test");
- assertThat(I18n.getLocalizationProblems(TestI18nDuplicateProperty.class).isEmpty(), is(true));
- assertThat(I18n.getLocalizationProblemLocales(TestI18nDuplicateProperty.class).isEmpty(), is(true));
- }
+ @Test
+ public void shouldNotHaveLocalicationProblemIfPropertyDuplicate() {
+ I18n.initialize(TestI18nDuplicateProperty.class);
+ TestI18nDuplicateProperty.testMessage.text("test");
+ assertThat(I18n.getLocalizationProblems(TestI18nDuplicateProperty.class).isEmpty(), is(true));
+ assertThat(I18n.getLocalizationProblemLocales(TestI18nDuplicateProperty.class).isEmpty(), is(true));
+ }
- @Test
- public void shouldContainAngleBracketedProblemInTextIfPropertyMissing() throws Exception {
- I18n.initialize(TestI18nMissingProperty.class);
- String text = TestI18nMissingProperty.testMessage1.text("test");
- assertThat(text.charAt(0), is('<'));
- System.out.println("Text: " + text);
- }
+ @Test
+ public void shouldContainAngleBracketedProblemInTextIfPropertyMissing() {
+ I18n.initialize(TestI18nMissingProperty.class);
+ String text = TestI18nMissingProperty.testMessage1.text("test");
+ assertThat(text.charAt(0), is('<'));
+ System.out.println("Text: " + text);
+ }
- @Test
- public void shouldHaveProblemIfPropertyMissing() throws Exception {
- I18n.initialize(TestI18nMissingProperty.class);
- assertThat(TestI18nMissingProperty.testMessage1.hasProblem(), is(true));
- String problem = TestI18nMissingProperty.testMessage1.problem();
- assertThat(problem, notNullValue());
- System.out.println("Problem: " + problem);
- }
+ @Test
+ public void shouldHaveProblemIfPropertyMissing() {
+ I18n.initialize(TestI18nMissingProperty.class);
+ assertThat(TestI18nMissingProperty.testMessage1.hasProblem(), is(true));
+ String problem = TestI18nMissingProperty.testMessage1.problem();
+ assertThat(problem, notNullValue());
+ System.out.println("Problem: " + problem);
+ }
- @Test
- public void shouldNotHaveLocalicationProblemIfPropertyMissing() throws Exception {
- I18n.initialize(TestI18nMissingProperty.class);
- TestI18nMissingProperty.testMessage1.text("test");
- assertThat(I18n.getLocalizationProblems(TestI18nMissingProperty.class).isEmpty(), is(true));
- assertThat(I18n.getLocalizationProblemLocales(TestI18nMissingProperty.class).isEmpty(), is(true));
- }
+ @Test
+ public void shouldNotHaveLocalicationProblemIfPropertyMissing() {
+ I18n.initialize(TestI18nMissingProperty.class);
+ TestI18nMissingProperty.testMessage1.text("test");
+ assertThat(I18n.getLocalizationProblems(TestI18nMissingProperty.class).isEmpty(), is(true));
+ assertThat(I18n.getLocalizationProblemLocales(TestI18nMissingProperty.class).isEmpty(), is(true));
+ }
- @Test
- public void shouldHaveLocalicationProblemIfPropertyUnused() throws Exception {
- I18n.initialize(TestI18nUnusedProperty.class);
- TestI18nUnusedProperty.testMessage.text("test");
- assertThat(I18n.getLocalizationProblems(TestI18nUnusedProperty.class).size(), is(1));
- assertThat(I18n.getLocalizationProblemLocales(TestI18nUnusedProperty.class).size(), is(1));
- assertThat(I18n.getLocalizationProblemLocales(TestI18nUnusedProperty.class).iterator().next(), is(Locale.getDefault()));
- }
+ @Test
+ public void shouldHaveLocalicationProblemIfPropertyUnused() {
+ I18n.initialize(TestI18nUnusedProperty.class);
+ TestI18nUnusedProperty.testMessage.text("test");
+ assertThat(I18n.getLocalizationProblems(TestI18nUnusedProperty.class).size(), is(1));
+ assertThat(I18n.getLocalizationProblemLocales(TestI18nUnusedProperty.class).size(), is(1));
+ assertThat(I18n.getLocalizationProblemLocales(TestI18nUnusedProperty.class).iterator().next(), is(Locale.getDefault()));
+ }
- @Test
- public void shouldHaveTextMatchingLocalizationFilePropertyValue() throws Exception {
- I18n.initialize(TestI18n.class);
- assertThat(TestI18n.testMessage.text(), is("Test Message"));
- }
+ @Test
+ public void shouldHaveTextMatchingLocalizationFilePropertyValue() {
+ I18n.initialize(TestI18n.class);
+ assertThat(TestI18n.testMessage.text(), is("Test Message"));
+ }
- @Test( expected = IllegalArgumentException.class )
- public void shouldFailIfTooFewArgumentsSuppliedToText() throws Exception {
- I18n.initialize(TestI18n.class);
- try {
- TestI18n.testMessage1.text();
- } catch (IllegalArgumentException err) {
- System.err.println(err);
- throw err;
- }
- }
+ @Test( expected = IllegalArgumentException.class )
+ public void shouldFailIfTooFewArgumentsSuppliedToText() {
+ I18n.initialize(TestI18n.class);
+ try {
+ TestI18n.testMessage1.text();
+ } catch (IllegalArgumentException err) {
+ System.err.println(err);
+ throw err;
+ }
+ }
- @Test( expected = IllegalArgumentException.class )
- public void shouldFailIfTooManyArgumentsSuppliedToText() throws Exception {
- I18n.initialize(TestI18n.class);
- try {
- TestI18n.testMessage1.text("Test", "Message");
- } catch (IllegalArgumentException err) {
- System.err.println(err);
- throw err;
- }
- }
+ @Test( expected = IllegalArgumentException.class )
+ public void shouldFailIfTooManyArgumentsSuppliedToText() {
+ I18n.initialize(TestI18n.class);
+ try {
+ TestI18n.testMessage1.text("Test", "Message");
+ } catch (IllegalArgumentException err) {
+ System.err.println(err);
+ throw err;
+ }
+ }
- @Test
- public void shouldContainArgumentsInRightOrderInText() throws Exception {
- I18n.initialize(TestI18n.class);
- assertThat(TestI18n.testMessage2.text("Test", "Message"), is("Message Test"));
- }
+ @Test
+ public void shouldContainArgumentsInRightOrderInText() {
+ I18n.initialize(TestI18n.class);
+ assertThat(TestI18n.testMessage2.text("Test", "Message"), is("Message Test"));
+ }
- @Test
- public void shouldAllowReuseOfArgumentsInText() throws Exception {
- I18n.initialize(TestI18n.class);
- assertThat(TestI18n.testMessage3.text("Test", "Message"), is("Message Test Message"));
- }
+ @Test
+ public void shouldAllowReuseOfArgumentsInText() {
+ I18n.initialize(TestI18n.class);
+ assertThat(TestI18n.testMessage3.text("Test", "Message"), is("Message Test Message"));
+ }
- @Test
- public void shouldContainLocaleSpecificText() {
- I18n.initialize(TestI18n.class);
- assertThat(TestI18n.testMessage.text(Locale.FRENCH), is("Message de Test"));
- }
+ @Test
+ public void shouldContainLocaleSpecificText() {
+ I18n.initialize(TestI18n.class);
+ assertThat(TestI18n.testMessage.text(Locale.FRENCH), is("Message de Test"));
+ }
- @Test
- public void shouldContainTextForDefaultLocaleIfMissingLocalizationForSuppliedLocale() {
- I18n.initialize(TestI18n.class);
- assertThat(TestI18n.testMessage.text(Locale.CHINESE), is("Test Message"));
- }
+ @Test
+ public void shouldContainTextForDefaultLocaleIfMissingLocalizationForSuppliedLocale() {
+ I18n.initialize(TestI18n.class);
+ assertThat(TestI18n.testMessage.text(Locale.CHINESE), is("Test Message"));
+ }
- public static class TestI18n {
+ public static class TestI18n {
- public static I18n testMessage;
- public static I18n testMessage1;
- public static I18n testMessage2;
- public static I18n testMessage3;
- public static Object nonI18n;
- }
+ public static I18n testMessage;
+ public static I18n testMessage1;
+ public static I18n testMessage2;
+ public static I18n testMessage3;
+ public static Object nonI18n;
+ }
- private static class TestI18nDuplicateProperty {
+ private static class TestI18nDuplicateProperty {
- public static I18n testMessage;
- }
+ public static I18n testMessage;
+ }
- public static final class TestI18nFinal {
+ public static final class TestI18nFinal {
- public static I18n testMessage;
- }
+ public static I18n testMessage;
+ }
- public static class TestI18nFinalField {
+ public static class TestI18nFinalField {
- public static final I18n testMessage = null;
- }
+ public static final I18n testMessage = null;
+ }
- public static interface TestI18nInterface {
+ public static interface TestI18nInterface {
- I18n testMessage = null;
- }
+ I18n testMessage = null;
+ }
- private static class TestI18nMissingProperty {
+ private static class TestI18nMissingProperty {
- public static I18n testMessage;
- public static I18n testMessage1;
- }
+ public static I18n testMessage;
+ public static I18n testMessage1;
+ }
- public static class TestI18nNotPublicField {
+ public static class TestI18nNotPublicField {
- static I18n testMessage;
- }
+ static I18n testMessage;
+ }
- public static class TestI18nNotStaticField {
+ public static class TestI18nNotStaticField {
- public I18n testMessage;
- }
+ public I18n testMessage;
+ }
- private static class TestI18nPrivate {
+ private static class TestI18nPrivate {
- public static I18n testMessage;
- }
+ public static I18n testMessage;
+ }
- private static class TestI18nUnusedProperty {
+ private static class TestI18nUnusedProperty {
- public static I18n testMessage;
- }
+ public static I18n testMessage;
+ }
- private static class TestI18nMissingLocalization {
+ private static class TestI18nMissingLocalization {
- public static I18n testMessage;
- }
+ public static I18n testMessage;
+ }
}
Modified: branches/maeste/dna-common/src/test/java/org/jboss/dna/common/jcr/AbstractJcrRepositoryTest.java
===================================================================
--- branches/maeste/dna-common/src/test/java/org/jboss/dna/common/jcr/AbstractJcrRepositoryTest.java 2008-06-11 08:35:21 UTC (rev 264)
+++ branches/maeste/dna-common/src/test/java/org/jboss/dna/common/jcr/AbstractJcrRepositoryTest.java 2008-06-11 08:45:51 UTC (rev 265)
@@ -54,6 +54,7 @@
* whenever all {@link Session sessions} are closed, this class maintains an open session between the time the repository is
* started and stopped. Therefore, unit tests can persist information in one session and see the information in other sessions.
* </p>
+ *
* @author Randall Hauch
*/
public abstract class AbstractJcrRepositoryTest {
@@ -77,7 +78,7 @@
}
@AfterClass
- public static void afterAll() throws Exception {
+ public static void afterAll() {
if (repository != null) {
try {
JackrabbitRepository jackrabbit = (JackrabbitRepository)repository;
@@ -101,6 +102,7 @@
* <p>
* The repository can be started and {@link #shutdownRepository() shutdown} repeatedly during a single test.
* </p>
+ *
* @throws RepositoryException if there is a problem starting the repository
* @throws IOException if there's a problem reading the repository configuration
* @see #shutdownRepository()
@@ -151,10 +153,11 @@
/**
* Get the repository. This will start the repository if necessary.
+ *
* @return repository
* @throws RepositoryException if there is a problem obtaining the repository
* @throws IOException if the repository has not yet been {@link #startRepository() started} and there's a problem reading the
- * repository configuration
+ * repository configuration
*/
public Repository getRepository() throws RepositoryException, IOException {
startRepository();
@@ -163,6 +166,7 @@
/**
* Get credentials that can be used to log into the repository.
+ *
* @return credentials
*/
public Credentials getTestCredentials() {
Modified: branches/maeste/dna-common/src/test/java/org/jboss/dna/common/math/DoubleOperationsTest.java
===================================================================
--- branches/maeste/dna-common/src/test/java/org/jboss/dna/common/math/DoubleOperationsTest.java 2008-06-11 08:35:21 UTC (rev 264)
+++ branches/maeste/dna-common/src/test/java/org/jboss/dna/common/math/DoubleOperationsTest.java 2008-06-11 08:45:51 UTC (rev 265)
@@ -22,19 +22,13 @@
package org.jboss.dna.common.math;
-import static org.junit.Assert.*;
-import org.jboss.dna.common.math.DoubleOperations;
-import org.junit.Before;
+import static org.junit.Assert.assertEquals;
import org.junit.Test;
public class DoubleOperationsTest {
private DoubleOperations ops = new DoubleOperations();
- @Before
- public void beforeEach() throws Exception {
- }
-
@Test
public void shouldReturnProperExponenentInScientificNotation() {
assertEquals(-3, ops.getExponentInScientificNotation(0.0010d));
Modified: branches/maeste/dna-common/src/test/java/org/jboss/dna/common/math/DurationTest.java
===================================================================
--- branches/maeste/dna-common/src/test/java/org/jboss/dna/common/math/DurationTest.java 2008-06-11 08:35:21 UTC (rev 264)
+++ branches/maeste/dna-common/src/test/java/org/jboss/dna/common/math/DurationTest.java 2008-06-11 08:45:51 UTC (rev 265)
@@ -22,9 +22,9 @@
package org.jboss.dna.common.math;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
import java.util.concurrent.TimeUnit;
-import org.jboss.dna.common.math.Duration;
import org.junit.Before;
import org.junit.Test;
@@ -33,7 +33,7 @@
private Duration duration;
@Before
- public void beforeEach() throws Exception {
+ public void beforeEach() {
this.duration = new Duration(0);
}
Modified: branches/maeste/dna-common/src/test/java/org/jboss/dna/common/math/FloatOperationsTest.java
===================================================================
--- branches/maeste/dna-common/src/test/java/org/jboss/dna/common/math/FloatOperationsTest.java 2008-06-11 08:35:21 UTC (rev 264)
+++ branches/maeste/dna-common/src/test/java/org/jboss/dna/common/math/FloatOperationsTest.java 2008-06-11 08:45:51 UTC (rev 265)
@@ -22,19 +22,13 @@
package org.jboss.dna.common.math;
-import static org.junit.Assert.*;
-import org.jboss.dna.common.math.FloatOperations;
-import org.junit.Before;
+import static org.junit.Assert.assertEquals;
import org.junit.Test;
public class FloatOperationsTest {
private FloatOperations ops = new FloatOperations();
- @Before
- public void beforeEach() throws Exception {
- }
-
@Test
public void shouldReturnProperExponenentInScientificNotation() {
assertEquals(-3, ops.getExponentInScientificNotation(0.0010f));
Modified: branches/maeste/dna-common/src/test/java/org/jboss/dna/common/math/IntegerOperationsTest.java
===================================================================
--- branches/maeste/dna-common/src/test/java/org/jboss/dna/common/math/IntegerOperationsTest.java 2008-06-11 08:35:21 UTC (rev 264)
+++ branches/maeste/dna-common/src/test/java/org/jboss/dna/common/math/IntegerOperationsTest.java 2008-06-11 08:45:51 UTC (rev 265)
@@ -22,20 +22,15 @@
package org.jboss.dna.common.math;
-import static org.hamcrest.core.Is.*;
-import static org.junit.Assert.*;
-import org.jboss.dna.common.math.IntegerOperations;
-import org.junit.Before;
+import static org.hamcrest.core.Is.is;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertThat;
import org.junit.Test;
public class IntegerOperationsTest {
private IntegerOperations ops = new IntegerOperations();
- @Before
- public void beforeEach() throws Exception {
- }
-
@Test
public void shouldReturnProperExponenentInScientificNotation() {
assertEquals(0, ops.getExponentInScientificNotation(0));
Modified: branches/maeste/dna-common/src/test/java/org/jboss/dna/common/math/LongOperationsTest.java
===================================================================
--- branches/maeste/dna-common/src/test/java/org/jboss/dna/common/math/LongOperationsTest.java 2008-06-11 08:35:21 UTC (rev 264)
+++ branches/maeste/dna-common/src/test/java/org/jboss/dna/common/math/LongOperationsTest.java 2008-06-11 08:45:51 UTC (rev 265)
@@ -22,20 +22,15 @@
package org.jboss.dna.common.math;
-import static org.hamcrest.core.Is.*;
-import static org.junit.Assert.*;
-import org.jboss.dna.common.math.LongOperations;
-import org.junit.Before;
+import static org.hamcrest.core.Is.is;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertThat;
import org.junit.Test;
public class LongOperationsTest {
private LongOperations ops = new LongOperations();
- @Before
- public void beforeEach() throws Exception {
- }
-
@Test
public void shouldReturnProperExponenentInScientificNotation() {
assertEquals(0l, ops.getExponentInScientificNotation(0l));
Modified: branches/maeste/dna-common/src/test/java/org/jboss/dna/common/monitor/ProgressStatusTest.java
===================================================================
--- branches/maeste/dna-common/src/test/java/org/jboss/dna/common/monitor/ProgressStatusTest.java 2008-06-11 08:35:21 UTC (rev 264)
+++ branches/maeste/dna-common/src/test/java/org/jboss/dna/common/monitor/ProgressStatusTest.java 2008-06-11 08:45:51 UTC (rev 265)
@@ -38,7 +38,7 @@
private String validTaskName;
@Before
- public void beforeEach() throws Exception {
+ public void beforeEach() {
this.validActivityName = "Reading from file X";
this.validTaskName = "Checking for file";
this.status = new ProgressStatus(this.validActivityName, this.validTaskName, 10.0d, false);
@@ -46,7 +46,8 @@
@Test
public void shouldComputePercentageAs100PercentIfWithinPrecision() {
- assertThat(ProgressStatus.computePercentage(100.0d - (ProgressStatus.PERCENT_PRECISION / 2.0d), 100.0d), is(closeTo(100.0d, ProgressStatus.PERCENT_PRECISION)));
+ assertThat(ProgressStatus.computePercentage(100.0d - (ProgressStatus.PERCENT_PRECISION / 2.0d), 100.0d),
+ is(closeTo(100.0d, ProgressStatus.PERCENT_PRECISION)));
}
@Test
Modified: branches/maeste/dna-common/src/test/java/org/jboss/dna/common/monitor/SimpleProgressMonitorTest.java
===================================================================
--- branches/maeste/dna-common/src/test/java/org/jboss/dna/common/monitor/SimpleProgressMonitorTest.java 2008-06-11 08:35:21 UTC (rev 264)
+++ branches/maeste/dna-common/src/test/java/org/jboss/dna/common/monitor/SimpleProgressMonitorTest.java 2008-06-11 08:45:51 UTC (rev 265)
@@ -22,14 +22,14 @@
package org.jboss.dna.common.monitor;
-import java.util.Locale;
-import java.util.Set;
import static org.hamcrest.core.Is.is;
import static org.hamcrest.core.IsInstanceOf.instanceOf;
import static org.hamcrest.core.IsNull.notNullValue;
import static org.hamcrest.core.IsSame.sameInstance;
import static org.hamcrest.number.IsCloseTo.closeTo;
import static org.junit.Assert.assertThat;
+import java.util.Locale;
+import java.util.Set;
import org.jboss.dna.common.CommonI18n;
import org.jboss.dna.common.i18n.I18n;
import org.jboss.dna.common.i18n.MockI18n;
@@ -38,6 +38,7 @@
/**
* @author Randall Hauch
+ * @author John Verhaeg
*/
public class SimpleProgressMonitorTest {
@@ -46,7 +47,7 @@
private String validTaskName;
@Before
- public void beforeEach() throws Exception {
+ public void beforeEach() {
this.validActivityName = "Reading from file X";
this.validTaskName = "Checking for file";
this.monitor = new SimpleProgressMonitor(this.validActivityName);
@@ -246,7 +247,10 @@
@Test
public void shouldNotBeMarkedAsDoneAfterCancel() {
-
+ monitor.beginTask(100, MockI18n.passthrough, validTaskName);
+ monitor.setCancelled(true);
+ assertThat(monitor.isCancelled(), is(true));
+ assertThat(monitor.isDone(), is(false));
}
@Test
@@ -317,6 +321,14 @@
assertThat(monitor.isCancelled(), is(true));
}
+ @Test
+ public void shouldRecordProblems() {
+ monitor.beginTask(1000, MockI18n.passthrough, validTaskName);
+ monitor.getProblems().addWarning(MockI18n.passthrough);
+ monitor.done();
+ assertThat(monitor.getProblems().hasWarnings(), is(true));
+ }
+
public static class I18nMessages {
public static I18n testTaskName;
Modified: branches/maeste/dna-common/src/test/java/org/jboss/dna/common/naming/MockInitialContextTest.java
===================================================================
--- branches/maeste/dna-common/src/test/java/org/jboss/dna/common/naming/MockInitialContextTest.java 2008-06-11 08:35:21 UTC (rev 264)
+++ branches/maeste/dna-common/src/test/java/org/jboss/dna/common/naming/MockInitialContextTest.java 2008-06-11 08:45:51 UTC (rev 265)
@@ -40,13 +40,13 @@
private Object registeredObject;
@Before
- public void beforeEach() throws Exception {
+ public void beforeEach() {
this.validName = "java:jboss/unit/test/name";
this.registeredObject = "This is the registered object";
}
@After
- public void afterEach() throws Exception {
+ public void afterEach() {
MockInitialContext.tearDown();
}
Modified: branches/maeste/dna-common/src/test/java/org/jboss/dna/common/stats/DetailedStatisticsTest.java
===================================================================
--- branches/maeste/dna-common/src/test/java/org/jboss/dna/common/stats/DetailedStatisticsTest.java 2008-06-11 08:35:21 UTC (rev 264)
+++ branches/maeste/dna-common/src/test/java/org/jboss/dna/common/stats/DetailedStatisticsTest.java 2008-06-11 08:45:51 UTC (rev 265)
@@ -21,13 +21,13 @@
*/
package org.jboss.dna.common.stats;
-import static org.hamcrest.core.Is.*;
-import static org.junit.Assert.*;
+import static org.hamcrest.core.Is.is;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
import org.jboss.dna.common.math.FloatOperations;
import org.jboss.dna.common.math.IntegerOperations;
-import org.jboss.dna.common.stats.DetailedStatistics;
import org.jboss.dna.common.util.Logger;
-import org.junit.Before;
import org.junit.Test;
public class DetailedStatisticsTest {
@@ -36,10 +36,6 @@
private DetailedStatistics<Float> floatStats = new DetailedStatistics<Float>(new FloatOperations());
private Logger logger = Logger.getLogger(DetailedStatisticsTest.class);
- @Before
- public void beforeEach() throws Exception {
- }
-
@Test
public void shouldHaveValidValuesWhenUnused() {
assertThat(this.intStats.getCount(), is(0));
@@ -128,7 +124,10 @@
assertEquals(23.70675d, this.intStats.getStandardDeviation(), 0.0001d);
HistogramTest.writeHistogramToLog(this.logger, this.intStats.getHistogram(), 20, "Histogram of 10 integer values: ");
- HistogramTest.writeHistogramToLog(this.logger, this.intStats.getHistogram().setBucketCount(7), 20, "Histogram of 10 integer values: ");
+ HistogramTest.writeHistogramToLog(this.logger,
+ this.intStats.getHistogram().setBucketCount(7),
+ 20,
+ "Histogram of 10 integer values: ");
}
@Test
@@ -152,7 +151,10 @@
assertEquals(2.370675f, this.floatStats.getStandardDeviation(), 0.0001f);
HistogramTest.writeHistogramToLog(this.logger, this.floatStats.getHistogram(), 20, "Histogram of 10 float values: ");
- HistogramTest.writeHistogramToLog(this.logger, this.floatStats.getHistogram().setBucketCount(7), 20, "Histogram of 10 float values: ");
+ HistogramTest.writeHistogramToLog(this.logger,
+ this.floatStats.getHistogram().setBucketCount(7),
+ 20,
+ "Histogram of 10 float values: ");
}
@Test
Modified: branches/maeste/dna-common/src/test/java/org/jboss/dna/common/stats/HistogramTest.java
===================================================================
--- branches/maeste/dna-common/src/test/java/org/jboss/dna/common/stats/HistogramTest.java 2008-06-11 08:35:21 UTC (rev 264)
+++ branches/maeste/dna-common/src/test/java/org/jboss/dna/common/stats/HistogramTest.java 2008-06-11 08:45:51 UTC (rev 265)
@@ -34,7 +34,6 @@
import org.jboss.dna.common.math.MathOperations;
import org.jboss.dna.common.text.Inflector;
import org.jboss.dna.common.util.Logger;
-import org.junit.Before;
import org.junit.Test;
public class HistogramTest {
@@ -42,11 +41,10 @@
private Logger logger = Logger.getLogger(HistogramTest.class);
private Inflector inflector = Inflector.getInstance();
- @Before
- public void beforeEach() throws Exception {
- }
-
- public static <T extends Number> Histogram<T> createRandomHistogram( T minimum, T maximum, int numberOfValues, MathOperations<T> ops ) {
+ public static <T extends Number> Histogram<T> createRandomHistogram( T minimum,
+ T maximum,
+ int numberOfValues,
+ MathOperations<T> ops ) {
List<T> values = new ArrayList<T>();
Random rng = new Random();
for (int i = 0; i != numberOfValues; ++i) {
@@ -56,7 +54,10 @@
return new Histogram<T>(ops, values);
}
- public static <T extends Number> void writeHistogramToLog( Logger logger, Histogram<T> histogram, int barLength, String description ) {
+ public static <T extends Number> void writeHistogramToLog( Logger logger,
+ Histogram<T> histogram,
+ int barLength,
+ String description ) {
logger.info(MockI18n.passthrough, description != null ? description : "Histogram:");
List<String> barGraph = histogram.getTextGraph(barLength);
for (String line : barGraph) {
@@ -64,13 +65,16 @@
}
}
- public <T extends Number> void assertBucketValueCount( Histogram<T> histogram, long... values ) {
+ public <T extends Number> void assertBucketValueCount( Histogram<T> histogram,
+ long... values ) {
List<Histogram<T>.Bucket> buckets = histogram.getBuckets();
// Check the number of buckets ...
assertEquals("The number of buckets didn't match expected number", values.length, buckets.size());
// Check the number of values ...
for (int i = 0; i != buckets.size(); ++i) {
- assertEquals("The " + inflector.ordinalize(i + 1) + " bucket didn't have the expected number of values", values[i], buckets.get(i).getNumberOfValues());
+ assertEquals("The " + inflector.ordinalize(i + 1) + " bucket didn't have the expected number of values",
+ values[i],
+ buckets.get(i).getNumberOfValues());
}
}
@@ -160,7 +164,8 @@
public void shouldCorrectlyPlace1000RandomFloatValues() {
Histogram<Float> gram = createRandomHistogram(10.0f, 100.0f, 1000, new FloatOperations());
// gram.setDesiredRange(0.0f,100.0f);
- HistogramTest.writeHistogramToLog(this.logger, gram, 0, "Histogram of 1000 random float values in " + gram.getBucketCount() + " buckets: ");
+ HistogramTest.writeHistogramToLog(this.logger, gram, 0, "Histogram of 1000 random float values in "
+ + gram.getBucketCount() + " buckets: ");
}
@Test
@@ -174,7 +179,13 @@
@Test
public void shouldCorrectlyConstructBoundariesWithWindowSmallerThanActualNarrowlyVaryingFloats() {
- List<Float> boundaries = Histogram.getBucketBoundaries(new FloatOperations(), 10.00020f, 10.00030f, 10.00011f, 10.00050f, 12, 3);
+ List<Float> boundaries = Histogram.getBucketBoundaries(new FloatOperations(),
+ 10.00020f,
+ 10.00030f,
+ 10.00011f,
+ 10.00050f,
+ 12,
+ 3);
assertNotNull(boundaries);
assertEquals(13, boundaries.size());
assertEquals(10.00011f, boundaries.get(0), 0.00001f);
Modified: branches/maeste/dna-common/src/test/java/org/jboss/dna/common/stats/SimpleStatisticsTest.java
===================================================================
--- branches/maeste/dna-common/src/test/java/org/jboss/dna/common/stats/SimpleStatisticsTest.java 2008-06-11 08:35:21 UTC (rev 264)
+++ branches/maeste/dna-common/src/test/java/org/jboss/dna/common/stats/SimpleStatisticsTest.java 2008-06-11 08:45:51 UTC (rev 265)
@@ -21,12 +21,12 @@
*/
package org.jboss.dna.common.stats;
-import static org.hamcrest.core.Is.*;
-import static org.junit.Assert.*;
+import static org.hamcrest.core.Is.is;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
import org.jboss.dna.common.math.FloatOperations;
import org.jboss.dna.common.math.IntegerOperations;
-import org.jboss.dna.common.stats.SimpleStatistics;
-import org.junit.Before;
import org.junit.Test;
public class SimpleStatisticsTest {
@@ -36,10 +36,6 @@
// private Logger logger = Logger.getLogger(SimpleStatisticsTest.class);
- @Before
- public void beforeEach() throws Exception {
- }
-
@Test
public void shouldHaveValidValuesWhenUnused() {
assertThat(this.intStats.getCount(), is(0));
Modified: branches/maeste/dna-common/src/test/java/org/jboss/dna/common/stats/StopwatchTest.java
===================================================================
--- branches/maeste/dna-common/src/test/java/org/jboss/dna/common/stats/StopwatchTest.java 2008-06-11 08:35:21 UTC (rev 264)
+++ branches/maeste/dna-common/src/test/java/org/jboss/dna/common/stats/StopwatchTest.java 2008-06-11 08:45:51 UTC (rev 265)
@@ -39,7 +39,7 @@
private long totalPauseTimeInMillis;
@Before
- public void beforeEach() throws Exception {
+ public void beforeEach() {
this.stopwatch = new Stopwatch();
}
Modified: branches/maeste/dna-common/src/test/java/org/jboss/dna/common/text/InflectorTest.java
===================================================================
--- branches/maeste/dna-common/src/test/java/org/jboss/dna/common/text/InflectorTest.java 2008-06-11 08:35:21 UTC (rev 264)
+++ branches/maeste/dna-common/src/test/java/org/jboss/dna/common/text/InflectorTest.java 2008-06-11 08:45:51 UTC (rev 265)
@@ -22,9 +22,7 @@
package org.jboss.dna.common.text;
-import static org.junit.Assert.*;
-import org.jboss.dna.common.text.Inflector;
-import org.junit.After;
+import static org.junit.Assert.assertEquals;
import org.junit.Before;
import org.junit.Test;
@@ -33,15 +31,12 @@
private Inflector inflector;
@Before
- public void beforeEach() throws Exception {
+ public void beforeEach() {
this.inflector = new Inflector();
}
- @After
- public void afterEach() throws Exception {
- }
-
- public void singularToPlural( Object singular, String expectedPlural ) {
+ public void singularToPlural( Object singular,
+ String expectedPlural ) {
// Test pluralizing the singular string
String actualPlural = inflector.pluralize(singular);
assertEquals(expectedPlural, actualPlural);
@@ -57,7 +52,9 @@
assertEquals(expectedPlural, inflector.pluralize(expectedPlural));
}
- public void upperCamelCase( String word, String expectedCamelized, char... delimiterChars ) {
+ public void upperCamelCase( String word,
+ String expectedCamelized,
+ char... delimiterChars ) {
// Test uppercasing the string
String actualCamelized = inflector.camelCase(word, true, delimiterChars);
assertEquals(expectedCamelized, actualCamelized);
@@ -70,7 +67,9 @@
}
}
- public void lowerCamelCase( String word, String expectedCamelized, char... delimiterChars ) {
+ public void lowerCamelCase( String word,
+ String expectedCamelized,
+ char... delimiterChars ) {
// Test lowercasing the string
String actualCamelized = inflector.camelCase(word, false, delimiterChars);
assertEquals(expectedCamelized, actualCamelized);
@@ -83,31 +82,39 @@
}
}
- public void underscore( String word, String expectedUnderscored, char... delimiterChars ) {
+ public void underscore( String word,
+ String expectedUnderscored,
+ char... delimiterChars ) {
// Test underscoring the word
String actualUnderscored = inflector.underscore(word, delimiterChars);
assertEquals(expectedUnderscored, actualUnderscored);
}
- public void capitalize( String words, String expectedValue ) {
+ public void capitalize( String words,
+ String expectedValue ) {
// Test capitalizing the phrase
String actualValue = inflector.capitalize(words);
assertEquals(expectedValue, actualValue);
}
- public void humanize( String word, String expectedValue, String... removableTokens ) {
+ public void humanize( String word,
+ String expectedValue,
+ String... removableTokens ) {
// Test humanizing the word
String actualValue = inflector.humanize(word, removableTokens);
assertEquals(expectedValue, actualValue);
}
- public void titleCase( String word, String expectedValue, String... removableTokens ) {
+ public void titleCase( String word,
+ String expectedValue,
+ String... removableTokens ) {
// Test title casing the word
String actualValue = inflector.titleCase(word, removableTokens);
assertEquals(expectedValue, actualValue);
}
- public void ordinalize( int number, String expectedValue ) {
+ public void ordinalize( int number,
+ String expectedValue ) {
// Test underscoring the camelized word
String actualValue = inflector.ordinalize(number);
assertEquals(expectedValue, actualValue);
Copied: branches/maeste/dna-common/src/test/java/org/jboss/dna/common/text/StringMatcher.java (from rev 263, trunk/dna-common/src/test/java/org/jboss/dna/common/text/StringMatcher.java)
===================================================================
--- branches/maeste/dna-common/src/test/java/org/jboss/dna/common/text/StringMatcher.java (rev 0)
+++ branches/maeste/dna-common/src/test/java/org/jboss/dna/common/text/StringMatcher.java 2008-06-11 08:45:51 UTC (rev 265)
@@ -0,0 +1,52 @@
+/*
+ * 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.common.text;
+
+import org.hamcrest.Description;
+import org.hamcrest.Matcher;
+import org.junit.matchers.TypeSafeMatcher;
+
+/**
+ * @author Randall Hauch
+ */
+public class StringMatcher extends TypeSafeMatcher<String> {
+
+ protected final String substring;
+
+ protected StringMatcher( final String substring ) {
+ this.substring = substring;
+ }
+
+ @Override
+ public boolean matchesSafely( String item ) {
+ return item.startsWith(item);
+ }
+
+ public void describeTo( Description description ) {
+ description.appendText("a string starts with ").appendValue(substring);
+ }
+
+ public static Matcher<String> startsWith( String prefix ) {
+ return new StringMatcher(prefix);
+ }
+
+}
Modified: branches/maeste/dna-common/src/test/java/org/jboss/dna/common/util/HashCodeTest.java
===================================================================
--- branches/maeste/dna-common/src/test/java/org/jboss/dna/common/util/HashCodeTest.java 2008-06-11 08:35:21 UTC (rev 264)
+++ branches/maeste/dna-common/src/test/java/org/jboss/dna/common/util/HashCodeTest.java 2008-06-11 08:45:51 UTC (rev 265)
@@ -25,9 +25,6 @@
import static org.hamcrest.core.Is.is;
import static org.hamcrest.core.IsNot.not;
import static org.junit.Assert.assertThat;
-import org.jboss.dna.common.util.HashCode;
-import org.junit.After;
-import org.junit.Before;
import org.junit.Test;
/**
@@ -35,14 +32,6 @@
*/
public class HashCodeTest {
- @Before
- public void beforeEach() throws Exception {
- }
-
- @After
- public void afterEach() throws Exception {
- }
-
@Test
public void shouldComputeHashCodeForOnePrimitive() {
assertThat(HashCode.compute(1), is(not(0)));
Modified: branches/maeste/dna-common/src/test/java/org/jboss/dna/common/util/IoUtilTest.java
===================================================================
--- branches/maeste/dna-common/src/test/java/org/jboss/dna/common/util/IoUtilTest.java 2008-06-11 08:35:21 UTC (rev 264)
+++ branches/maeste/dna-common/src/test/java/org/jboss/dna/common/util/IoUtilTest.java 2008-06-11 08:45:51 UTC (rev 265)
@@ -31,15 +31,10 @@
import java.io.Reader;
import java.io.StringReader;
import java.io.Writer;
-import org.junit.Before;
import org.junit.Test;
public class IoUtilTest {
- @Before
- public void beforeEach() throws Exception {
- }
-
@Test
public void readBytesShouldReturnEmptyByteArrayForNullInputStream() throws Exception {
assertThat(IoUtil.readBytes((InputStream)null), is(new byte[] {}));
@@ -168,7 +163,9 @@
}
@Override
- public int read( char[] cbuf, int off, int len ) throws IOException {
+ public int read( char[] cbuf,
+ int off,
+ int len ) throws IOException {
return reader.read(cbuf, off, len);
}
}
@@ -233,7 +230,9 @@
* {@inheritDoc}
*/
@Override
- public void write( char[] cbuf, int off, int len ) throws IOException {
+ public void write( char[] cbuf,
+ int off,
+ int len ) throws IOException {
writer.write(cbuf, off, len);
}
Modified: branches/maeste/dna-common/src/test/java/org/jboss/dna/common/util/LoggerTest.java
===================================================================
--- branches/maeste/dna-common/src/test/java/org/jboss/dna/common/util/LoggerTest.java 2008-06-11 08:35:21 UTC (rev 264)
+++ branches/maeste/dna-common/src/test/java/org/jboss/dna/common/util/LoggerTest.java 2008-06-11 08:45:51 UTC (rev 265)
@@ -22,7 +22,9 @@
package org.jboss.dna.common.util;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.fail;
import java.io.StringWriter;
import java.util.ArrayList;
import java.util.Enumeration;
@@ -37,7 +39,6 @@
import org.apache.log4j.spi.LoggingEvent;
import org.apache.log4j.spi.ThrowableInformation;
import org.jboss.dna.common.i18n.I18n;
-import org.jboss.dna.common.util.Logger;
import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass;
@@ -80,7 +81,7 @@
private Map<String, List<Appender>> existingAppendersByLoggerName = new HashMap<String, List<Appender>>();
@BeforeClass
- public static void beforeAll() throws Exception {
+ public static void beforeAll() {
// Initialize the I18n static fields ...
I18n.initialize(LoggerTest.class);
}
@@ -427,12 +428,15 @@
/**
* Remove the message that is currently at the front of the log, and verify that it contains the supplied information.
+ *
* @param expectedLevel the level that the next log message should have
* @param expectedMessageExpression the message that the next log message should have, or a regular expression that would
- * match the log message
+ * match the log message
* @param expectedExceptionClass the exception class that was expected, or null if there should not be an exception
*/
- public void removeFirst( Logger.Level expectedLevel, String expectedMessageExpression, Class expectedExceptionClass ) {
+ public void removeFirst( Logger.Level expectedLevel,
+ String expectedMessageExpression,
+ Class expectedExceptionClass ) {
if (!hasEvents()) {
fail("Expected log message but found none: " + expectedLevel + " - " + expectedMessageExpression);
}
@@ -447,23 +451,27 @@
String actual = event.getMessage().toString();
// Treat as a regular expression, which works for both regular expressions and strings ...
if (!actual.matches(expectedMessageExpression)) {
- fail("Log line " + lineNumber + " differed: \nwas :\t" + actual + "\nexpected:\t" + expectedMessageExpression);
+ fail("Log line " + lineNumber + " differed: \nwas :\t" + actual + "\nexpected:\t"
+ + expectedMessageExpression);
}
} // else they are both null
// Check the exception ...
ThrowableInformation throwableInfo = event.getThrowableInformation();
if (expectedExceptionClass == null && throwableInfo != null) {
- fail("Log line " + lineNumber + " had unexpected exception: " + event.getThrowableInformation().getThrowableStrRep());
+ fail("Log line " + lineNumber + " had unexpected exception: "
+ + event.getThrowableInformation().getThrowableStrRep());
} else if (expectedExceptionClass != null && throwableInfo == null) {
- fail("Log line " + lineNumber + " was missing expected exception of type " + expectedExceptionClass.getCanonicalName());
+ fail("Log line " + lineNumber + " was missing expected exception of type "
+ + expectedExceptionClass.getCanonicalName());
} else if (expectedExceptionClass != null && throwableInfo != null) {
Throwable actualException = throwableInfo.getThrowable();
assertSame(expectedExceptionClass, actualException.getClass());
} // else they are both null
}
- public void removeFirst( Logger.Level expectedLevel, String expectedMessageExpression ) {
+ public void removeFirst( Logger.Level expectedLevel,
+ String expectedMessageExpression ) {
removeFirst(expectedLevel, expectedMessageExpression, null);
}
}
Modified: branches/maeste/dna-common/src/test/java/org/jboss/dna/common/util/StringUtilTest.java
===================================================================
--- branches/maeste/dna-common/src/test/java/org/jboss/dna/common/util/StringUtilTest.java 2008-06-11 08:35:21 UTC (rev 264)
+++ branches/maeste/dna-common/src/test/java/org/jboss/dna/common/util/StringUtilTest.java 2008-06-11 08:45:51 UTC (rev 265)
@@ -36,456 +36,451 @@
import java.io.StringReader;
import java.util.ArrayList;
import java.util.List;
-import org.junit.Before;
import org.junit.Test;
public class StringUtilTest {
- @Before
- public void beforeEach() throws Exception {
- }
+ public void compareSeparatedLines( Object... lines ) {
+ ByteArrayOutputStream content = new ByteArrayOutputStream();
+ PrintStream stream = new PrintStream(content);
+ for (Object line : lines) {
+ stream.println(line);
+ }
+ List<String> actualLines = StringUtil.splitLines(content.toString());
+ assertArrayEquals(lines, actualLines.toArray());
+ }
- public void compareSeparatedLines( Object... lines ) {
- ByteArrayOutputStream content = new ByteArrayOutputStream();
- PrintStream stream = new PrintStream(content);
- for (Object line : lines) {
- stream.println(line);
- }
- List<String> actualLines = StringUtil.splitLines(content.toString());
- assertArrayEquals(lines, actualLines.toArray());
- }
+ @Test
+ public void splitLinesShouldWorkCorrectly() {
+ compareSeparatedLines("Line 1", "Line 2", "Line 3", "Line 4");
+ }
- @Test
- public void splitLinesShouldWorkCorrectly() {
- compareSeparatedLines("Line 1", "Line 2", "Line 3", "Line 4");
- }
+ @Test( expected = IllegalArgumentException.class )
+ public void createStringShouldFailIfNoPatternSupplied() {
+ StringUtil.createString(null, (Object[])null);
+ }
- @Test( expected = IllegalArgumentException.class )
- public void createStringShouldFailIfNoPatternSupplied() {
- StringUtil.createString(null, (Object[])null);
- }
+ @Test
+ public void createStringShouldAllowNoParametersSupplied() {
+ assertThat(StringUtil.createString("test", (Object[])null), is("test"));
+ }
- @Test
- public void createStringShouldAllowNoParametersSupplied() {
- assertThat(StringUtil.createString("test", (Object[])null), is("test"));
- }
+ @Test
+ public void createStringShouldCreateStringFromPattern() {
+ String pattern = "This {0} is {1} should {2} not {3} last {4}";
+ assertEquals("This one is two should three not four last five", StringUtil.createString(pattern,
+ "one",
+ "two",
+ "three",
+ "four",
+ "five"));
+ }
- @Test
- public void createStringShouldCreateStringFromPattern() {
- String pattern = "This {0} is {1} should {2} not {3} last {4}";
- assertEquals("This one is two should three not four last five", StringUtil.createString(pattern,
- "one",
- "two",
- "three",
- "four",
- "five"));
- }
+ @Test( expected = IllegalArgumentException.class )
+ public void createStringShouldFailIfTooFewArgumentsSupplied() {
+ String pattern = "This {0} is {1} should {2} not {3} last {4}";
+ try {
+ StringUtil.createString(pattern, "one", "two", "three", "four");
+ } catch (IllegalArgumentException err) {
+ System.err.println(err);
+ throw err;
+ }
+ }
- @Test( expected = IllegalArgumentException.class )
- public void createStringShouldFailIfTooFewArgumentsSupplied() {
- String pattern = "This {0} is {1} should {2} not {3} last {4}";
- try {
- StringUtil.createString(pattern, "one", "two", "three", "four");
- } catch (IllegalArgumentException err) {
- System.err.println(err);
- throw err;
- }
- }
+ @Test( expected = IllegalArgumentException.class )
+ public void createStringShouldFailIfTooManyArgumentsSupplied() {
+ String pattern = "This {0} is {1} should {2} not {3} last {4}";
+ try {
+ StringUtil.createString(pattern, "one", "two", "three", "four", "five", "six");
+ } catch (IllegalArgumentException err) {
+ System.err.println(err);
+ throw err;
+ }
+ }
- @Test( expected = IllegalArgumentException.class )
- public void createStringShouldFailIfTooManyArgumentsSupplied() {
- String pattern = "This {0} is {1} should {2} not {3} last {4}";
- try {
- StringUtil.createString(pattern, "one", "two", "three", "four", "five", "six");
- } catch (IllegalArgumentException err) {
- System.err.println(err);
- throw err;
- }
- }
+ @Test
+ public void createStringExceptionMessageShouldbeGrammaticallyCorrect() {
+ String pattern = "One = {0}";
+ try {
+ StringUtil.createString(pattern);
+ } catch (IllegalArgumentException err) {
+ assertThat(err.getMessage().startsWith("0 parameters supplied, but 1 parameter required"), is(true));
+ }
+ pattern = "One";
+ try {
+ StringUtil.createString(pattern, "one");
+ } catch (IllegalArgumentException err) {
+ assertThat(err.getMessage().startsWith("1 parameter supplied, but 0 parameters required"), is(true));
+ }
+ pattern = "One = {0}, Two = {1}";
+ try {
+ StringUtil.createString(pattern);
+ } catch (IllegalArgumentException err) {
+ assertThat(err.getMessage().startsWith("0 parameters supplied, but 2 parameters required"), is(true));
+ }
+ }
- @Test
- public void createStringExceptionMessageShouldbeGrammaticallyCorrect() {
- String pattern = "One = {0}";
- try {
- StringUtil.createString(pattern);
- } catch (IllegalArgumentException err) {
- assertThat(err.getMessage().startsWith("0 parameters supplied, but 1 parameter required"), is(true));
- }
- pattern = "One";
- try {
- StringUtil.createString(pattern, "one");
- } catch (IllegalArgumentException err) {
- assertThat(err.getMessage().startsWith("1 parameter supplied, but 0 parameters required"), is(true));
- }
- pattern = "One = {0}, Two = {1}";
- try {
- StringUtil.createString(pattern);
- } catch (IllegalArgumentException err) {
- assertThat(err.getMessage().startsWith("0 parameters supplied, but 2 parameters required"), is(true));
- }
- }
+ @Test
+ public void setLengthShouldTruncateStringsThatAreTooLong() {
+ assertEquals("This is the st", StringUtil.setLength("This is the string", 14, ' '));
+ }
- @Test
- public void setLengthShouldTruncateStringsThatAreTooLong() {
- assertEquals("This is the st", StringUtil.setLength("This is the string", 14, ' '));
- }
+ @Test
+ public void setLengthShouldAppendCharacterForStringsThatAreTooShort() {
+ assertEquals("This ", StringUtil.setLength("This", 10, ' '));
+ }
- @Test
- public void setLengthShouldAppendCharacterForStringsThatAreTooShort() {
- assertEquals("This ", StringUtil.setLength("This", 10, ' '));
- }
+ @Test
+ public void setLengthShouldNotRemoveLeadingWhitespace() {
+ assertEquals(" This ", StringUtil.setLength(" This", 10, ' '));
+ assertEquals("\tThis ", StringUtil.setLength("\tThis", 10, ' '));
+ }
- @Test
- public void setLengthShouldNotRemoveLeadingWhitespace() {
- assertEquals(" This ", StringUtil.setLength(" This", 10, ' '));
- assertEquals("\tThis ", StringUtil.setLength("\tThis", 10, ' '));
- }
+ @Test
+ public void setLengthShouldAppendCharacterForEmptyStrings() {
+ assertEquals(" ", StringUtil.setLength("", 10, ' '));
+ }
- @Test
- public void setLengthShouldAppendCharacterForEmptyStrings() {
- assertEquals(" ", StringUtil.setLength("", 10, ' '));
- }
+ @Test
+ public void setLengthShouldAppendCharacterForNullStrings() {
+ assertEquals(" ", StringUtil.setLength(null, 10, ' '));
+ }
- @Test
- public void setLengthShouldAppendCharacterForNullStrings() {
- assertEquals(" ", StringUtil.setLength(null, 10, ' '));
- }
+ @Test
+ public void setLengthShouldReturnStringsThatAreTheDesiredLength() {
+ assertEquals("This is the string", StringUtil.setLength("This is the string", 18, ' '));
+ }
- @Test
- public void setLengthShouldReturnStringsThatAreTheDesiredLength() {
- assertEquals("This is the string", StringUtil.setLength("This is the string", 18, ' '));
- }
+ @Test
+ public void justifyLeftShouldTruncateStringsThatAreTooLong() {
+ assertEquals("This is the st", StringUtil.justifyLeft("This is the string", 14, ' '));
+ }
- @Test
- public void justifyLeftShouldTruncateStringsThatAreTooLong() {
- assertEquals("This is the st", StringUtil.justifyLeft("This is the string", 14, ' '));
- }
+ @Test
+ public void justifyLeftShouldAppendCharacterForStringsThatAreTooShort() {
+ assertEquals("This ", StringUtil.justifyLeft("This", 10, ' '));
+ }
- @Test
- public void justifyLeftShouldAppendCharacterForStringsThatAreTooShort() {
- assertEquals("This ", StringUtil.justifyLeft("This", 10, ' '));
- }
+ @Test
+ public void justifyLeftShouldRemoveLeadingWhitespace() {
+ assertEquals("This ", StringUtil.justifyLeft(" This", 10, ' '));
+ assertEquals("This ", StringUtil.justifyLeft("\tThis", 10, ' '));
+ }
- @Test
- public void justifyLeftShouldRemoveLeadingWhitespace() {
- assertEquals("This ", StringUtil.justifyLeft(" This", 10, ' '));
- assertEquals("This ", StringUtil.justifyLeft("\tThis", 10, ' '));
- }
+ @Test
+ public void justifyLeftShouldAppendCharacterForEmptyStrings() {
+ assertEquals(" ", StringUtil.justifyLeft("", 10, ' '));
+ }
- @Test
- public void justifyLeftShouldAppendCharacterForEmptyStrings() {
- assertEquals(" ", StringUtil.justifyLeft("", 10, ' '));
- }
+ @Test
+ public void justifyLeftShouldAppendCharacterForNullStrings() {
+ assertEquals(" ", StringUtil.justifyLeft(null, 10, ' '));
+ }
- @Test
- public void justifyLeftShouldAppendCharacterForNullStrings() {
- assertEquals(" ", StringUtil.justifyLeft(null, 10, ' '));
- }
+ @Test
+ public void justifyLeftShouldReturnStringsThatAreTheDesiredLength() {
+ assertEquals("This is the string", StringUtil.justifyLeft("This is the string", 18, ' '));
+ }
- @Test
- public void justifyLeftShouldReturnStringsThatAreTheDesiredLength() {
- assertEquals("This is the string", StringUtil.justifyLeft("This is the string", 18, ' '));
- }
+ @Test
+ public void justifyRightShouldTruncateStringsThatAreTooLong() {
+ assertEquals(" is the string", StringUtil.justifyRight("This is the string", 14, ' '));
+ }
- @Test
- public void justifyRightShouldTruncateStringsThatAreTooLong() {
- assertEquals(" is the string", StringUtil.justifyRight("This is the string", 14, ' '));
- }
+ @Test
+ public void justifyRightShouldPrependCharacterForStringsThatAreTooShort() {
+ assertEquals(" This", StringUtil.justifyRight("This", 10, ' '));
+ }
- @Test
- public void justifyRightShouldPrependCharacterForStringsThatAreTooShort() {
- assertEquals(" This", StringUtil.justifyRight("This", 10, ' '));
- }
+ @Test
+ public void justifyRightShouldPrependCharacterForEmptyStrings() {
+ assertEquals(" ", StringUtil.justifyRight("", 10, ' '));
+ }
- @Test
- public void justifyRightShouldPrependCharacterForEmptyStrings() {
- assertEquals(" ", StringUtil.justifyRight("", 10, ' '));
- }
+ @Test
+ public void justifyRightShouldPrependCharacterForNullStrings() {
+ assertEquals(" ", StringUtil.justifyRight(null, 10, ' '));
+ }
- @Test
- public void justifyRightShouldPrependCharacterForNullStrings() {
- assertEquals(" ", StringUtil.justifyRight(null, 10, ' '));
- }
+ @Test
+ public void justifyRightShouldReturnStringsThatAreTheDesiredLength() {
+ assertEquals("This is the string", StringUtil.justifyRight("This is the string", 18, ' '));
+ }
- @Test
- public void justifyRightShouldReturnStringsThatAreTheDesiredLength() {
- assertEquals("This is the string", StringUtil.justifyRight("This is the string", 18, ' '));
- }
+ @Test
+ public void justifyCenterShouldTruncateStringsThatAreTooLong() {
+ assertEquals("This is the st", StringUtil.justifyCenter("This is the string", 14, ' '));
+ }
- @Test
- public void justifyCenterShouldTruncateStringsThatAreTooLong() {
- assertEquals("This is the st", StringUtil.justifyCenter("This is the string", 14, ' '));
- }
+ @Test
+ public void justifyCenterShouldPrependAndAppendSameNumberOfCharacterForStringsThatAreTooShortButOfAnEvenLength() {
+ assertEquals(" This ", StringUtil.justifyCenter("This", 10, ' '));
+ }
- @Test
- public void justifyCenterShouldPrependAndAppendSameNumberOfCharacterForStringsThatAreTooShortButOfAnEvenLength() {
- assertEquals(" This ", StringUtil.justifyCenter("This", 10, ' '));
- }
+ @Test
+ public void justifyCenterShouldPrependOneMoreCharacterThanAppendingForStringsThatAreTooShortButOfAnOddLength() {
+ assertEquals(" Thing ", StringUtil.justifyCenter("Thing", 10, ' '));
+ }
- @Test
- public void justifyCenterShouldPrependOneMoreCharacterThanAppendingForStringsThatAreTooShortButOfAnOddLength() {
- assertEquals(" Thing ", StringUtil.justifyCenter("Thing", 10, ' '));
- }
+ @Test
+ public void justifyCenterShouldPrependCharacterForEmptyStrings() {
+ assertEquals(" ", StringUtil.justifyCenter("", 10, ' '));
+ }
- @Test
- public void justifyCenterShouldPrependCharacterForEmptyStrings() {
- assertEquals(" ", StringUtil.justifyCenter("", 10, ' '));
- }
+ @Test
+ public void justifyCenterShouldPrependCharacterForNullStrings() {
+ assertEquals(" ", StringUtil.justifyCenter(null, 10, ' '));
+ }
- @Test
- public void justifyCenterShouldPrependCharacterForNullStrings() {
- assertEquals(" ", StringUtil.justifyCenter(null, 10, ' '));
- }
+ @Test
+ public void justifyCenterShouldReturnStringsThatAreTheDesiredLength() {
+ assertEquals("This is the string", StringUtil.justifyCenter("This is the string", 18, ' '));
+ }
- @Test
- public void justifyCenterShouldReturnStringsThatAreTheDesiredLength() {
- assertEquals("This is the string", StringUtil.justifyCenter("This is the string", 18, ' '));
- }
+ @Test
+ public void truncateShouldReturnEmptyStringIfNullReferenceIsSupplied() {
+ assertThat(StringUtil.truncate(null, 0), is(""));
+ assertThat(StringUtil.truncate(null, 1), is(""));
+ assertThat(StringUtil.truncate(null, 100), is(""));
+ }
- @Test
- public void truncateShouldReturnEmptyStringIfNullReferenceIsSupplied() {
- assertThat(StringUtil.truncate(null, 0), is(""));
- assertThat(StringUtil.truncate(null, 1), is(""));
- assertThat(StringUtil.truncate(null, 100), is(""));
- }
+ @Test( expected = IllegalArgumentException.class )
+ public void truncateShouldNotAllowNegativeLength() {
+ StringUtil.truncate("some string", -1);
+ }
- @Test( expected = IllegalArgumentException.class )
- public void truncateShouldNotAllowNegativeLength() {
- StringUtil.truncate("some string", -1);
- }
+ @Test
+ public void truncateShouldReturnEmptyStringForMaximumLengthOfZero() {
+ String str = "This is the string with some text";
+ assertThat(StringUtil.truncate(str, 0), is(""));
+ assertThat(StringUtil.truncate("", 0), is(""));
+ assertThat(StringUtil.truncate(str, 0, "123"), is(""));
+ assertThat(StringUtil.truncate("", 0, "123"), is(""));
+ }
- @Test
- public void truncateShouldReturnEmptyStringForMaximumLengthOfZero() {
- String str = "This is the string with some text";
- assertThat(StringUtil.truncate(str, 0), is(""));
- assertThat(StringUtil.truncate("", 0), is(""));
- assertThat(StringUtil.truncate(str, 0, "123"), is(""));
- assertThat(StringUtil.truncate("", 0, "123"), is(""));
- }
+ @Test
+ public void truncateShouldNotTruncateStringShorterThanMaximumLength() {
+ String str = "This is the string with some text";
+ assertThat(StringUtil.truncate(str, str.length() + 2), is(str));
+ assertThat(StringUtil.truncate(str, str.length() + 2, null), is(str));
+ assertThat(StringUtil.truncate(str, str.length() + 2, "really long suffix"), is(str));
+ }
- @Test
- public void truncateShouldNotTruncateStringShorterThanMaximumLength() {
- String str = "This is the string with some text";
- assertThat(StringUtil.truncate(str, str.length() + 2), is(str));
- assertThat(StringUtil.truncate(str, str.length() + 2, null), is(str));
- assertThat(StringUtil.truncate(str, str.length() + 2, "really long suffix"), is(str));
- }
+ @Test
+ public void truncateShouldNotTruncateStringWithLengthEqualToMaximumLength() {
+ String str = "This is the string with some text";
+ assertThat(StringUtil.truncate(str, str.length()), is(str));
+ assertThat(StringUtil.truncate(str, str.length(), null), is(str));
+ assertThat(StringUtil.truncate(str, str.length(), "really long suffix"), is(str));
+ }
- @Test
- public void truncateShouldNotTruncateStringWithLengthEqualToMaximumLength() {
- String str = "This is the string with some text";
- assertThat(StringUtil.truncate(str, str.length()), is(str));
- assertThat(StringUtil.truncate(str, str.length(), null), is(str));
- assertThat(StringUtil.truncate(str, str.length(), "really long suffix"), is(str));
- }
+ @Test
+ public void truncateShouldProperlyTruncateStringWithLengthGreaterThanMaximumLength() {
+ String str = "This is the string";
+ assertThat(StringUtil.truncate(str, str.length() - 1), is("This is the st..."));
+ assertThat(StringUtil.truncate(str, str.length() - 1, null), is("This is the st..."));
+ assertThat(StringUtil.truncate(str, str.length() - 1, "X"), is("This is the striX"));
+ }
- @Test
- public void truncateShouldProperlyTruncateStringWithLengthGreaterThanMaximumLength() {
- String str = "This is the string";
- assertThat(StringUtil.truncate(str, str.length() - 1), is("This is the st..."));
- assertThat(StringUtil.truncate(str, str.length() - 1, null), is("This is the st..."));
- assertThat(StringUtil.truncate(str, str.length() - 1, "X"), is("This is the striX"));
- }
+ @Test
+ public void truncateShouldProperlyTruncateStringWithLengthGreaterThanMaximumLengthAndMaximumLengthLongerThanPrefixLength() {
+ String str = "This is the string";
+ assertThat(StringUtil.truncate(str, 2), is(".."));
+ assertThat(StringUtil.truncate(str, 2, null), is(".."));
+ assertThat(StringUtil.truncate(str, 1, "XX"), is("X"));
+ }
- @Test
- public void truncateShouldProperlyTruncateStringWithLengthGreaterThanMaximumLengthAndMaximumLengthLongerThanPrefixLength() {
- String str = "This is the string";
- assertThat(StringUtil.truncate(str, 2), is(".."));
- assertThat(StringUtil.truncate(str, 2, null), is(".."));
- assertThat(StringUtil.truncate(str, 1, "XX"), is("X"));
- }
+ @Test
+ public void readShouldReturnEmptyStringForNullInputStream() throws Exception {
+ assertThat(StringUtil.read((InputStream)null), is(""));
+ }
- @Test
- public void readShouldReturnEmptyStringForNullInputStream() throws Exception {
- assertThat(StringUtil.read((InputStream)null), is(""));
- }
+ @Test
+ public void readShouldReturnEmptyStringForNullReader() throws Exception {
+ assertThat(StringUtil.read((Reader)null), is(""));
+ }
- @Test
- public void readShouldReturnEmptyStringForNullReader() throws Exception {
- assertThat(StringUtil.read((Reader)null), is(""));
- }
+ @Test
+ public void readShouldReadInputStreamCorrectlyAndShouldCloseStream() throws Exception {
+ // Read content shorter than buffer size ...
+ String content = "This is the way to grandma's house.";
+ InputStream stream = new ByteArrayInputStream(content.getBytes());
+ InputStreamWrapper wrapper = new InputStreamWrapper(stream);
+ assertThat(wrapper.isClosed(), is(false));
+ assertThat(StringUtil.read(wrapper), is(content));
+ assertThat(wrapper.isClosed(), is(true));
- @Test
- public void readShouldReadInputStreamCorrectlyAndShouldCloseStream() throws Exception {
- // Read content shorter than buffer size ...
- String content = "This is the way to grandma's house.";
- InputStream stream = new ByteArrayInputStream(content.getBytes());
- InputStreamWrapper wrapper = new InputStreamWrapper(stream);
- assertThat(wrapper.isClosed(), is(false));
- assertThat(StringUtil.read(wrapper), is(content));
- assertThat(wrapper.isClosed(), is(true));
+ // Read content longer than buffer size ...
+ for (int i = 0; i != 10; ++i) {
+ content += content; // note this doubles each time!
+ }
+ stream = new ByteArrayInputStream(content.getBytes());
+ wrapper = new InputStreamWrapper(stream);
+ assertThat(wrapper.isClosed(), is(false));
+ assertThat(StringUtil.read(wrapper), is(content));
+ assertThat(wrapper.isClosed(), is(true));
+ }
- // Read content longer than buffer size ...
- for (int i = 0; i != 10; ++i) {
- content += content; // note this doubles each time!
- }
- stream = new ByteArrayInputStream(content.getBytes());
- wrapper = new InputStreamWrapper(stream);
- assertThat(wrapper.isClosed(), is(false));
- assertThat(StringUtil.read(wrapper), is(content));
- assertThat(wrapper.isClosed(), is(true));
- }
+ @Test
+ public void readShouldReadReaderCorrectlyAndShouldCloseStream() throws Exception {
+ // Read content shorter than buffer size ...
+ String content = "This is the way to grandma's house.";
+ Reader reader = new StringReader(content);
+ ReaderWrapper wrapper = new ReaderWrapper(reader);
+ assertThat(wrapper.isClosed(), is(false));
+ assertThat(StringUtil.read(wrapper), is(content));
+ assertThat(wrapper.isClosed(), is(true));
- @Test
- public void readShouldReadReaderCorrectlyAndShouldCloseStream() throws Exception {
- // Read content shorter than buffer size ...
- String content = "This is the way to grandma's house.";
- Reader reader = new StringReader(content);
- ReaderWrapper wrapper = new ReaderWrapper(reader);
- assertThat(wrapper.isClosed(), is(false));
- assertThat(StringUtil.read(wrapper), is(content));
- assertThat(wrapper.isClosed(), is(true));
+ // Read content longer than buffer size ...
+ for (int i = 0; i != 10; ++i) {
+ content += content; // note this doubles each time!
+ }
+ reader = new StringReader(content);
+ wrapper = new ReaderWrapper(reader);
+ assertThat(wrapper.isClosed(), is(false));
+ assertThat(StringUtil.read(wrapper), is(content));
+ assertThat(wrapper.isClosed(), is(true));
+ }
- // Read content longer than buffer size ...
- for (int i = 0; i != 10; ++i) {
- content += content; // note this doubles each time!
- }
- reader = new StringReader(content);
- wrapper = new ReaderWrapper(reader);
- assertThat(wrapper.isClosed(), is(false));
- assertThat(StringUtil.read(wrapper), is(content));
- assertThat(wrapper.isClosed(), is(true));
- }
+ @Test
+ public void getStackTraceShouldReturnStackTrace() {
+ String msg = "This is the message for a test exception";
+ Throwable t = new IllegalArgumentException(msg);
+ String trace = StringUtil.getStackTrace(t);
+ assertThat(trace, containsString(msg));
+ assertThat(trace, containsString(this.getClass().getName()));
+ }
- @Test
- public void getStackTraceShouldReturnStackTrace() {
- String msg = "This is the message for a test exception";
- Throwable t = new IllegalArgumentException(msg);
- String trace = StringUtil.getStackTrace(t);
- assertThat(trace, containsString(msg));
- assertThat(trace, containsString(this.getClass().getName()));
- }
+ @Test
+ public void readableStringShouldReturnStringForNull() {
+ assertThat(StringUtil.readableString((Object)null), is("null"));
+ }
- @Test
- public void readableStringShouldReturnStringForNull() {
- assertThat(StringUtil.readableString((Object)null), is("null"));
- }
+ @Test
+ public void readableStringShouldReturnStringFormOfBoolean() {
+ assertThat(StringUtil.readableString(true), is(Boolean.TRUE.toString()));
+ assertThat(StringUtil.readableString(false), is(Boolean.FALSE.toString()));
+ assertThat(StringUtil.readableString(Boolean.TRUE), is(Boolean.TRUE.toString()));
+ assertThat(StringUtil.readableString(Boolean.FALSE), is(Boolean.FALSE.toString()));
+ }
- @Test
- public void readableStringShouldReturnStringFormOfBoolean() {
- assertThat(StringUtil.readableString(true), is(Boolean.TRUE.toString()));
- assertThat(StringUtil.readableString(false), is(Boolean.FALSE.toString()));
- assertThat(StringUtil.readableString(Boolean.TRUE), is(Boolean.TRUE.toString()));
- assertThat(StringUtil.readableString(Boolean.FALSE), is(Boolean.FALSE.toString()));
- }
+ @Test
+ public void readableStringShouldReturnStringFormOfNumber() {
+ assertThat(StringUtil.readableString(1), is("1"));
+ assertThat(StringUtil.readableString(-513), is("-513"));
+ assertThat(StringUtil.readableString(-513.3f), is("-513.3"));
+ assertThat(StringUtil.readableString(-513.3d), is("-513.3"));
+ assertThat(StringUtil.readableString(new Short((short)1)), is("1"));
+ assertThat(StringUtil.readableString(new Integer(-513)), is("-513"));
+ assertThat(StringUtil.readableString(new Float(-513.3f)), is("-513.3"));
+ assertThat(StringUtil.readableString(new Double(-513.3d)), is("-513.3"));
+ }
- @Test
- public void readableStringShouldReturnStringFormOfNumber() {
- assertThat(StringUtil.readableString(1), is("1"));
- assertThat(StringUtil.readableString(-513), is("-513"));
- assertThat(StringUtil.readableString(-513.3f), is("-513.3"));
- assertThat(StringUtil.readableString(-513.3d), is("-513.3"));
- assertThat(StringUtil.readableString(new Short((short)1)), is("1"));
- assertThat(StringUtil.readableString(new Integer(-513)), is("-513"));
- assertThat(StringUtil.readableString(new Float(-513.3f)), is("-513.3"));
- assertThat(StringUtil.readableString(new Double(-513.3d)), is("-513.3"));
- }
+ @Test
+ public void readableStringShouldWrapObjectArrayWithSquareBraces() {
+ assertThat(StringUtil.readableString(new int[] {}), is("[]"));
+ assertThat(StringUtil.readableString(new int[] {1}), is("[ 1 ]"));
+ assertThat(StringUtil.readableString(new int[] {1, 2, 3, 4}), is("[ 1, 2, 3, 4 ]"));
+ assertThat(StringUtil.readableString(new short[] {1, 2, 3, 4}), is("[ 1, 2, 3, 4 ]"));
+ assertThat(StringUtil.readableString(new boolean[] {true, false}), is("[ true, false ]"));
+ assertThat(StringUtil.readableString(new long[] {1, 2, 3, 4}), is("[ 1, 2, 3, 4 ]"));
+ assertThat(StringUtil.readableString(new float[] {51.0f, 52.0f, 53.0f, 54.0f}), is("[ 51.0, 52.0, 53.0, 54.0 ]"));
+ assertThat(StringUtil.readableString(new double[] {51.0d, 52.0d, 53.0d, 54.0d}), is("[ 51.0, 52.0, 53.0, 54.0 ]"));
+ }
- @Test
- public void readableStringShouldWrapObjectArrayWithSquareBraces() {
- assertThat(StringUtil.readableString(new int[] {}), is("[]"));
- assertThat(StringUtil.readableString(new int[] {1}), is("[ 1 ]"));
- assertThat(StringUtil.readableString(new int[] {1, 2, 3, 4}), is("[ 1, 2, 3, 4 ]"));
- assertThat(StringUtil.readableString(new short[] {1, 2, 3, 4}), is("[ 1, 2, 3, 4 ]"));
- assertThat(StringUtil.readableString(new boolean[] {true, false}), is("[ true, false ]"));
- assertThat(StringUtil.readableString(new long[] {1, 2, 3, 4}), is("[ 1, 2, 3, 4 ]"));
- assertThat(StringUtil.readableString(new float[] {51.0f, 52.0f, 53.0f, 54.0f}), is("[ 51.0, 52.0, 53.0, 54.0 ]"));
- assertThat(StringUtil.readableString(new double[] {51.0d, 52.0d, 53.0d, 54.0d}), is("[ 51.0, 52.0, 53.0, 54.0 ]"));
- }
+ @Test
+ public void readableStringShouldHandleEmptyArraysOfArrays() {
+ assertThat(StringUtil.readableString(new int[][] {}), is("[[]]"));
+ assertThat(StringUtil.readableString(new boolean[][][][][][] {}), is("[[[[[[]]]]]]"));
+ assertThat(StringUtil.readableString(new ArrayList<List<List<?>>>()), is("[]"));
+ }
- @Test
- public void readableStringShouldHandleEmptyArraysOfArrays() {
- assertThat(StringUtil.readableString(new int[][] {}), is("[[]]"));
- assertThat(StringUtil.readableString(new boolean[][][][][][] {}), is("[[[[[[]]]]]]"));
- assertThat(StringUtil.readableString(new ArrayList<List<List<?>>>()), is("[]"));
- }
+ @Test
+ public void readableStringShouldHandleNestedObjects() {
+ assertThat(StringUtil.readableString(new int[][] {new int[] {1, 2}, new int[] {3, 4}}), is("[ [ 1, 2 ], [ 3, 4 ] ]"));
+ List<String> list1 = new ArrayList<String>();
+ list1.add("a1");
+ list1.add("a2");
+ List<String> list2 = new ArrayList<String>();
+ list2.add("b1");
+ list2.add("b2");
+ List<List<String>> list3 = new ArrayList<List<String>>();
+ list3.add(list1);
+ list3.add(list2);
+ assertThat(StringUtil.readableString(list3), is("[ [ \"a1\", \"a2\" ], [ \"b1\", \"b2\" ] ]"));
+ }
- @Test
- public void readableStringShouldHandleNestedObjects() {
- assertThat(StringUtil.readableString(new int[][] {new int[] {1, 2}, new int[] {3, 4}}), is("[ [ 1, 2 ], [ 3, 4 ] ]"));
- List<String> list1 = new ArrayList<String>();
- list1.add("a1");
- list1.add("a2");
- List<String> list2 = new ArrayList<String>();
- list2.add("b1");
- list2.add("b2");
- List<List<String>> list3 = new ArrayList<List<String>>();
- list3.add(list1);
- list3.add(list2);
- assertThat(StringUtil.readableString(list3), is("[ [ \"a1\", \"a2\" ], [ \"b1\", \"b2\" ] ]"));
- }
+ @Test( expected = IllegalArgumentException.class )
+ public void normalizeShouldFailIfTextNull() {
+ StringUtil.normalize(null);
+ }
- @Test( expected = IllegalArgumentException.class )
- public void normalizeShouldFailIfTextNull() {
- StringUtil.normalize(null);
- }
+ @Test
+ public void normalizeShouldRemoveLeadingTrailingWhitespace() {
+ assertThat(StringUtil.normalize(" \t\n test this \t"), is("test this"));
+ }
- @Test
- public void normalizeShouldRemoveLeadingTrailingWhitespace() {
- assertThat(StringUtil.normalize(" \t\n test this \t"), is("test this"));
- }
+ @Test
+ public void normalizeShouldReduceInternalWhitespace() {
+ assertThat(StringUtil.normalize("test \t\n\r this"), is("test this"));
+ }
- @Test
- public void normalizeShouldReduceInternalWhitespace() {
- assertThat(StringUtil.normalize("test \t\n\r this"), is("test this"));
- }
+ @Test
+ public void normalizeShouldReturnEqualStringIfNothingToNormalize() {
+ assertThat(StringUtil.normalize("test this"), is("test this"));
+ }
- @Test
- public void normalizeShouldReturnEqualStringIfNothingToNormalize() {
- assertThat(StringUtil.normalize("test this"), is("test this"));
- }
+ protected class InputStreamWrapper extends InputStream {
- protected class InputStreamWrapper extends InputStream {
+ private boolean closed = false;
+ private final InputStream stream;
- private boolean closed = false;
- private final InputStream stream;
+ protected InputStreamWrapper( InputStream stream ) {
+ this.stream = stream;
+ }
- protected InputStreamWrapper( InputStream stream ) {
- this.stream = stream;
- }
+ public boolean isClosed() {
+ return closed;
+ }
- public boolean isClosed() {
- return closed;
- }
+ @Override
+ public int read() throws IOException {
+ return stream.read();
+ }
- @Override
- public int read() throws IOException {
- return stream.read();
- }
+ @Override
+ public void close() throws IOException {
+ stream.close();
+ this.closed = true;
+ }
- @Override
- public void close() throws IOException {
- stream.close();
- this.closed = true;
- }
+ }
- }
+ protected class ReaderWrapper extends Reader {
- protected class ReaderWrapper extends Reader {
+ private boolean closed = false;
+ private final Reader reader;
- private boolean closed = false;
- private final Reader reader;
+ protected ReaderWrapper( Reader reader ) {
+ this.reader = reader;
+ }
- protected ReaderWrapper( Reader reader ) {
- this.reader = reader;
- }
+ public boolean isClosed() {
+ return closed;
+ }
- public boolean isClosed() {
- return closed;
- }
+ @Override
+ public void close() throws IOException {
+ reader.close();
+ this.closed = true;
+ }
- @Override
- public void close() throws IOException {
- reader.close();
- this.closed = true;
- }
+ @Override
+ public int read( char[] cbuf,
+ int off,
+ int len ) throws IOException {
+ return reader.read(cbuf, off, len);
+ }
+ }
- @Override
- public int read( char[] cbuf,
- int off,
- int len ) throws IOException {
- return reader.read(cbuf, off, len);
- }
- }
-
}
Modified: branches/maeste/dna-integration-tests/pom.xml
===================================================================
--- branches/maeste/dna-integration-tests/pom.xml 2008-06-11 08:35:21 UTC (rev 264)
+++ branches/maeste/dna-integration-tests/pom.xml 2008-06-11 08:45:51 UTC (rev 265)
@@ -47,13 +47,10 @@
<artifactId>junit</artifactId>
</dependency>
<dependency>
- <groupId>org.jmock</groupId>
- <artifactId>jmock</artifactId>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-all</artifactId>
+ <scope>test</scope>
</dependency>
- <dependency>
- <groupId>org.jmock</groupId>
- <artifactId>jmock-junit4</artifactId>
- </dependency>
<!--
Logging (require SLF4J API for compiling, but use Log4J and its SLF4J binding for testing)
-->
Modified: branches/maeste/dna-integration-tests/src/test/java/org/jboss/dna/tests/integration/jackrabbit/JackrabbitBasicFunctionTest.java
===================================================================
--- branches/maeste/dna-integration-tests/src/test/java/org/jboss/dna/tests/integration/jackrabbit/JackrabbitBasicFunctionTest.java 2008-06-11 08:35:21 UTC (rev 264)
+++ branches/maeste/dna-integration-tests/src/test/java/org/jboss/dna/tests/integration/jackrabbit/JackrabbitBasicFunctionTest.java 2008-06-11 08:45:51 UTC (rev 265)
@@ -63,7 +63,7 @@
}
@After
- public void afterEach() throws Exception {
+ public void afterEach() {
// Clean up the test data ...
FileUtil.delete(JACKRABBIT_DATA_PATH);
}
@@ -151,7 +151,8 @@
// Retrieve content ...
Node node = root.getNode("hello/world");
this.logger.info(MockI18n.passthrough, "Node 'hello/world' has path: " + node.getPath());
- this.logger.info(MockI18n.passthrough, "Node 'hello/world' has 'message' property: " + node.getProperty("message").getString());
+ this.logger.info(MockI18n.passthrough, "Node 'hello/world' has 'message' property: "
+ + node.getProperty("message").getString());
} finally {
if (session != null) session.logout();
}
@@ -164,7 +165,8 @@
// Retrieve content
Node node = root.getNode("hello/world");
this.logger.info(MockI18n.passthrough, "Node 'hello/world' has path: " + node.getPath());
- this.logger.info(MockI18n.passthrough, "Node 'hello/world' has 'message' property: " + node.getProperty("message").getString());
+ this.logger.info(MockI18n.passthrough, "Node 'hello/world' has 'message' property: "
+ + node.getProperty("message").getString());
// Remove content
this.logger.info(MockI18n.passthrough, "Node 'hello' is being removed");
Modified: branches/maeste/dna-integration-tests/src/test/java/org/jboss/dna/tests/integration/jackrabbit/JackrabbitDerbyStressTest.java
===================================================================
--- branches/maeste/dna-integration-tests/src/test/java/org/jboss/dna/tests/integration/jackrabbit/JackrabbitDerbyStressTest.java 2008-06-11 08:35:21 UTC (rev 264)
+++ branches/maeste/dna-integration-tests/src/test/java/org/jboss/dna/tests/integration/jackrabbit/JackrabbitDerbyStressTest.java 2008-06-11 08:45:51 UTC (rev 265)
@@ -74,7 +74,7 @@
}
@After
- public void afterEach() throws Exception {
+ public void afterEach() {
try {
if (session != null) session.logout();
} finally {
@@ -94,7 +94,10 @@
stopwatch.stop();
}
rootNode.save();
- HistogramTest.writeHistogramToLog(logger, stopwatch.getHistogram(3).setBucketCount(50), 80, "create 100 nodes with no children and no properties");
+ HistogramTest.writeHistogramToLog(logger,
+ stopwatch.getHistogram(3).setBucketCount(50),
+ 80,
+ "create 100 nodes with no children and no properties");
this.logger.info(MockI18n.passthrough, stopwatch.toString());
}
@@ -108,7 +111,10 @@
stopwatch.stop();
}
rootNode.save();
- HistogramTest.writeHistogramToLog(logger, stopwatch.getHistogram(1).setBucketCount(50), 80, "create 1000 nodes with no children and no properties");
+ HistogramTest.writeHistogramToLog(logger,
+ stopwatch.getHistogram(1).setBucketCount(50),
+ 80,
+ "create 1000 nodes with no children and no properties");
this.logger.info(MockI18n.passthrough, stopwatch.toString());
}
@@ -122,7 +128,10 @@
stopwatch.stop();
}
rootNode.save();
- HistogramTest.writeHistogramToLog(logger, stopwatch.getHistogram(1).setBucketCount(50), 80, "create 5000 nodes with no children and no properties");
+ HistogramTest.writeHistogramToLog(logger,
+ stopwatch.getHistogram(1).setBucketCount(50),
+ 80,
+ "create 5000 nodes with no children and no properties");
this.logger.info(MockI18n.passthrough, stopwatch.toString());
}
@@ -136,7 +145,10 @@
stopwatch.stop();
}
rootNode.save();
- HistogramTest.writeHistogramToLog(logger, stopwatch.getHistogram(1).setBucketCount(50), 80, "create 10000 nodes with no children and no properties");
+ HistogramTest.writeHistogramToLog(logger,
+ stopwatch.getHistogram(1).setBucketCount(50),
+ 80,
+ "create 10000 nodes with no children and no properties");
this.logger.info(MockI18n.passthrough, stopwatch.toString());
}
@@ -152,7 +164,10 @@
stopwatch.stop();
}
rootNode.save();
- HistogramTest.writeHistogramToLog(logger, stopwatch.getHistogram(3).setBucketCount(50), 80, "create 100 nodes with no children and several properties");
+ HistogramTest.writeHistogramToLog(logger,
+ stopwatch.getHistogram(3).setBucketCount(50),
+ 80,
+ "create 100 nodes with no children and several properties");
this.logger.info(MockI18n.passthrough, stopwatch.toString());
}
//
Modified: branches/maeste/dna-integration-tests/src/test/java/org/jboss/dna/tests/integration/jackrabbit/JackrabbitInMemoryTest.java
===================================================================
--- branches/maeste/dna-integration-tests/src/test/java/org/jboss/dna/tests/integration/jackrabbit/JackrabbitInMemoryTest.java 2008-06-11 08:35:21 UTC (rev 264)
+++ branches/maeste/dna-integration-tests/src/test/java/org/jboss/dna/tests/integration/jackrabbit/JackrabbitInMemoryTest.java 2008-06-11 08:45:51 UTC (rev 265)
@@ -73,7 +73,7 @@
}
@After
- public void afterEach() throws Exception {
+ public void afterEach() {
try {
if (session != null) session.logout();
} finally {
@@ -85,13 +85,16 @@
/**
* Create an evenly distributed tree of nodes, starting with the supplied parent.
+ *
* @param parentNode the parent node of the tree; may not be null
* @param numberOfChildNodes the number of child nodes to create under the parent
* @param levelsToCreate the total number of levels in the tree to create
* @return the total number of child nodes created
* @throws Exception
*/
- public int createNodes( Node parentNode, int numberOfChildNodes, int levelsToCreate ) throws Exception {
+ public int createNodes( Node parentNode,
+ int numberOfChildNodes,
+ int levelsToCreate ) throws Exception {
int numberCreated = 0;
for (int i = 0; i < numberOfChildNodes; ++i) {
nodeStopwatch.start();
@@ -118,7 +121,10 @@
nodeStopwatch.stop();
}
rootNode.save();
- HistogramTest.writeHistogramToLog(logger, nodeStopwatch.getHistogram(3).setBucketCount(50), 80, "create 100 nodes with no children and no properties");
+ HistogramTest.writeHistogramToLog(logger,
+ nodeStopwatch.getHistogram(3).setBucketCount(50),
+ 80,
+ "create 100 nodes with no children and no properties");
this.logger.info(MockI18n.passthrough, nodeStopwatch.toString());
}
@@ -131,8 +137,12 @@
rootNode.save();
saveStopwatch.stop();
- HistogramTest.writeHistogramToLog(logger, nodeStopwatch.getHistogram(3).setBucketCount(50), 80, "create tree of " + numNodes + " nodes (2 deep, 10 children at every node)");
- HistogramTest.writeHistogramToLog(logger, saveStopwatch.getHistogram(3).setBucketCount(50), 80, "1 save of 2x10 tree of " + numNodes + " nodes");
+ HistogramTest.writeHistogramToLog(logger,
+ nodeStopwatch.getHistogram(3).setBucketCount(50),
+ 80,
+ "create tree of " + numNodes + " nodes (2 deep, 10 children at every node)");
+ HistogramTest.writeHistogramToLog(logger, saveStopwatch.getHistogram(3).setBucketCount(50), 80, "1 save of 2x10 tree of "
+ + numNodes + " nodes");
this.logger.info(MockI18n.passthrough, "Node operation times: " + nodeStopwatch.toString());
this.logger.info(MockI18n.passthrough, "Save times: " + saveStopwatch.toString());
}
Modified: branches/maeste/dna-maven-classloader/pom.xml
===================================================================
--- branches/maeste/dna-maven-classloader/pom.xml 2008-06-11 08:35:21 UTC (rev 264)
+++ branches/maeste/dna-maven-classloader/pom.xml 2008-06-11 08:45:51 UTC (rev 265)
@@ -39,13 +39,10 @@
<artifactId>junit</artifactId>
</dependency>
<dependency>
- <groupId>org.jmock</groupId>
- <artifactId>jmock</artifactId>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-all</artifactId>
+ <scope>test</scope>
</dependency>
- <dependency>
- <groupId>org.jmock</groupId>
- <artifactId>jmock-junit4</artifactId>
- </dependency>
<!--
Logging (require SLF4J API for compiling, but use Log4J and its SLF4J binding for testing)
-->
Modified: branches/maeste/dna-maven-classloader/src/test/java/org/jboss/dna/maven/MavenIdTest.java
===================================================================
--- branches/maeste/dna-maven-classloader/src/test/java/org/jboss/dna/maven/MavenIdTest.java 2008-06-11 08:35:21 UTC (rev 264)
+++ branches/maeste/dna-maven-classloader/src/test/java/org/jboss/dna/maven/MavenIdTest.java 2008-06-11 08:45:51 UTC (rev 265)
@@ -21,8 +21,8 @@
*/
package org.jboss.dna.maven;
+import static org.hamcrest.core.Is.is;
import static org.hamcrest.core.IsNull.notNullValue;
-import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertThat;
import org.junit.Before;
@@ -43,15 +43,17 @@
private MavenId validIdWithNullClassifier;
@Before
- public void beforeEach() throws Exception {
+ public void beforeEach() {
this.validGroupId = "org.jboss.dna";
this.validArtifactId = "jboss-dna-core";
this.validClassifier = "jdk1.4";
this.validVersion = "1.0";
this.validId = new MavenId(this.validGroupId, this.validArtifactId, this.validVersion, this.validClassifier);
this.validIdWithNullClassifier = new MavenId(this.validGroupId, this.validArtifactId, this.validVersion, null);
- this.validArtifactIdToString = this.validGroupId + ":" + this.validArtifactId + ":" + this.validVersion + ":" + this.validClassifier;
- this.validArtifactIdWithNullClassifierToString = this.validGroupId + ":" + this.validArtifactId + ":" + this.validVersion + ":";
+ this.validArtifactIdToString = this.validGroupId + ":" + this.validArtifactId + ":" + this.validVersion + ":"
+ + this.validClassifier;
+ this.validArtifactIdWithNullClassifierToString = this.validGroupId + ":" + this.validArtifactId + ":" + this.validVersion
+ + ":";
}
@Test
@@ -149,18 +151,27 @@
assertThat(MavenId.createClasspath(""), is(new MavenId[] {}));
assertThat(MavenId.createClasspath((String)null), is(new MavenId[] {}));
- assertThat(MavenId.createClasspath("org.jboss.dna:dna-maven"), is(new MavenId[] {new MavenId("org.jboss.dna", "dna-maven")}));
- assertThat(MavenId.createClasspath(" org.jboss.dna:dna-maven "), is(new MavenId[] {new MavenId("org.jboss.dna", "dna-maven")}));
- assertThat(MavenId.createClasspath(" org.jboss.dna : dna-maven "), is(new MavenId[] {new MavenId("org.jboss.dna", "dna-maven")}));
- assertThat(MavenId.createClasspath("org.jboss.dna:dna-maven:"), is(new MavenId[] {new MavenId("org.jboss.dna", "dna-maven")}));
- assertThat(MavenId.createClasspath("org.jboss.dna:dna-maven::jdk1.4"), is(new MavenId[] {new MavenId("org.jboss.dna", "dna-maven", null, "jdk1.4")}));
- assertThat(MavenId.createClasspath("org.jboss.dna:dna-maven:1.0:jdk1.4"), is(new MavenId[] {new MavenId("org.jboss.dna", "dna-maven", "1.0", "jdk1.4")}));
- assertThat(MavenId.createClasspath("org.jboss.dna:dna-maven:1.0:jdk1.4,net.jcip:jcip-annotations:1.0"), is(new MavenId[] {new MavenId("org.jboss.dna", "dna-maven", "1.0", "jdk1.4"),
- new MavenId("net.jcip", "jcip-annotations", "1.0")}));
- assertThat(MavenId.createClasspath("org.jboss.dna:dna-maven:1.0:jdk1.4,,net.jcip:jcip-annotations:1.0,"), is(new MavenId[] {new MavenId("org.jboss.dna", "dna-maven", "1.0", "jdk1.4"),
- new MavenId("net.jcip", "jcip-annotations", "1.0")}));
- assertThat(MavenId.createClasspath(",,org.jboss.dna:dna-maven:1.0:jdk1.4,, net.jcip: jcip-annotations:1.0 ,,"), is(new MavenId[] {new MavenId("org.jboss.dna", "dna-maven", "1.0", "jdk1.4"),
- new MavenId("net.jcip", "jcip-annotations", "1.0")}));
+ assertThat(MavenId.createClasspath("org.jboss.dna:dna-maven"),
+ is(new MavenId[] {new MavenId("org.jboss.dna", "dna-maven")}));
+ assertThat(MavenId.createClasspath(" org.jboss.dna:dna-maven "), is(new MavenId[] {new MavenId("org.jboss.dna",
+ "dna-maven")}));
+ assertThat(MavenId.createClasspath(" org.jboss.dna : dna-maven "), is(new MavenId[] {new MavenId("org.jboss.dna",
+ "dna-maven")}));
+ assertThat(MavenId.createClasspath("org.jboss.dna:dna-maven:"), is(new MavenId[] {new MavenId("org.jboss.dna",
+ "dna-maven")}));
+ assertThat(MavenId.createClasspath("org.jboss.dna:dna-maven::jdk1.4"), is(new MavenId[] {new MavenId("org.jboss.dna",
+ "dna-maven", null,
+ "jdk1.4")}));
+ assertThat(MavenId.createClasspath("org.jboss.dna:dna-maven:1.0:jdk1.4"),
+ is(new MavenId[] {new MavenId("org.jboss.dna", "dna-maven", "1.0", "jdk1.4")}));
+ assertThat(MavenId.createClasspath("org.jboss.dna:dna-maven:1.0:jdk1.4,net.jcip:jcip-annotations:1.0"), is(new MavenId[] {
+ new MavenId("org.jboss.dna", "dna-maven", "1.0", "jdk1.4"), new MavenId("net.jcip", "jcip-annotations", "1.0")}));
+ assertThat(MavenId.createClasspath("org.jboss.dna:dna-maven:1.0:jdk1.4,,net.jcip:jcip-annotations:1.0,"),
+ is(new MavenId[] {new MavenId("org.jboss.dna", "dna-maven", "1.0", "jdk1.4"),
+ new MavenId("net.jcip", "jcip-annotations", "1.0")}));
+ assertThat(MavenId.createClasspath(",,org.jboss.dna:dna-maven:1.0:jdk1.4,, net.jcip: jcip-annotations:1.0 ,,"),
+ is(new MavenId[] {new MavenId("org.jboss.dna", "dna-maven", "1.0", "jdk1.4"),
+ new MavenId("net.jcip", "jcip-annotations", "1.0")}));
}
@Test
@@ -169,12 +180,15 @@
assertThat(MavenId.createClasspath((String[])null), is(new MavenId[] {}));
assertThat(MavenId.createClasspath(new String[] {null, null}), is(new MavenId[] {}));
- assertThat(MavenId.createClasspath("org.jboss.dna:dna-maven:1.0:jdk1.4", "net.jcip:jcip-annotations:1.0"), is(new MavenId[] {new MavenId("org.jboss.dna", "dna-maven", "1.0", "jdk1.4"),
- new MavenId("net.jcip", "jcip-annotations", "1.0")}));
+ assertThat(MavenId.createClasspath("org.jboss.dna:dna-maven:1.0:jdk1.4", "net.jcip:jcip-annotations:1.0"),
+ is(new MavenId[] {new MavenId("org.jboss.dna", "dna-maven", "1.0", "jdk1.4"),
+ new MavenId("net.jcip", "jcip-annotations", "1.0")}));
assertThat(MavenId.createClasspath("org.jboss.dna:dna-maven:1.0:jdk1.4", "", "net.jcip:jcip-annotations:1.0", ""),
- is(new MavenId[] {new MavenId("org.jboss.dna", "dna-maven", "1.0", "jdk1.4"), new MavenId("net.jcip", "jcip-annotations", "1.0")}));
- assertThat(MavenId.createClasspath(" org.jboss.dna:dna-maven:1.0:jdk1.4", " net.jcip: jcip-annotations:1.0"), is(new MavenId[] {new MavenId("org.jboss.dna", "dna-maven", "1.0", "jdk1.4"),
- new MavenId("net.jcip", "jcip-annotations", "1.0")}));
+ is(new MavenId[] {new MavenId("org.jboss.dna", "dna-maven", "1.0", "jdk1.4"),
+ new MavenId("net.jcip", "jcip-annotations", "1.0")}));
+ assertThat(MavenId.createClasspath(" org.jboss.dna:dna-maven:1.0:jdk1.4", " net.jcip: jcip-annotations:1.0"),
+ is(new MavenId[] {new MavenId("org.jboss.dna", "dna-maven", "1.0", "jdk1.4"),
+ new MavenId("net.jcip", "jcip-annotations", "1.0")}));
}
@Test
Modified: branches/maeste/dna-repository/pom.xml
===================================================================
--- branches/maeste/dna-repository/pom.xml 2008-06-11 08:35:21 UTC (rev 264)
+++ branches/maeste/dna-repository/pom.xml 2008-06-11 08:45:51 UTC (rev 265)
@@ -69,16 +69,6 @@
<scope>test</scope>
</dependency>
<dependency>
- <groupId>org.jmock</groupId>
- <artifactId>jmock</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.jmock</groupId>
- <artifactId>jmock-junit4</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>1.3</version>
Modified: branches/maeste/dna-repository/src/main/java/org/jboss/dna/repository/RepositoryI18n.java
===================================================================
--- branches/maeste/dna-repository/src/main/java/org/jboss/dna/repository/RepositoryI18n.java 2008-06-11 08:35:21 UTC (rev 264)
+++ branches/maeste/dna-repository/src/main/java/org/jboss/dna/repository/RepositoryI18n.java 2008-06-11 08:45:51 UTC (rev 265)
@@ -34,6 +34,7 @@
public static I18n invalidStateString;
public static I18n serviceShutdowAndMayNotBeStarted;
public static I18n serviceShutdowAndMayNotBePaused;
+ public static I18n serviceNotShutdowAndMayNotBeTerminated;
public static I18n unableToFindRepositoryInJndi;
public static I18n unableToRegisterRepositoryInJndi;
public static I18n unableToUnregisterRepositoryInJndi;
@@ -104,9 +105,9 @@
public static I18n invalidRepositoryNodePath;
// XML Sequencer
- public static I18n errorSequencingXmlDocument;
- public static I18n sequencingXmlDocument;
- public static I18n canceledSequencingXmlDocument;
+ public static I18n errorSequencingXmlDocument;
+ public static I18n sequencingXmlDocument;
+ public static I18n canceledSequencingXmlDocument;
public static I18n interruptedWhileConnectingToFederationConfigurationRepository;
public static I18n interruptedWhileClosingConnectionToFederationConfigurationRepository;
Modified: branches/maeste/dna-repository/src/main/java/org/jboss/dna/repository/federation/FederatedRepository.java
===================================================================
--- branches/maeste/dna-repository/src/main/java/org/jboss/dna/repository/federation/FederatedRepository.java 2008-06-11 08:35:21 UTC (rev 264)
+++ branches/maeste/dna-repository/src/main/java/org/jboss/dna/repository/federation/FederatedRepository.java 2008-06-11 08:45:51 UTC (rev 265)
@@ -33,6 +33,7 @@
import org.jboss.dna.repository.services.AbstractServiceAdministrator;
import org.jboss.dna.repository.services.ServiceAdministrator;
import org.jboss.dna.spi.cache.CachePolicy;
+import org.jboss.dna.spi.graph.connection.RepositoryConnection;
import org.jboss.dna.spi.graph.connection.RepositoryConnectionPool;
import org.jboss.dna.spi.graph.connection.RepositorySourceListener;
@@ -82,6 +83,14 @@
return FederatedRepository.this.awaitTermination(timeout, unit);
}
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected boolean doCheckIsTerminated() {
+ return FederatedRepository.this.isTerminated();
+ }
+
}
private final ServiceAdministrator administrator = new Administrator();
@@ -107,6 +116,13 @@
}
/**
+ * @return service
+ */
+ protected FederationService getService() {
+ return this.service;
+ }
+
+ /**
* Get the name of this repository
*
* @return name
@@ -127,6 +143,7 @@
*/
protected void startRepository() {
// Do not establish connections to the sources; these will be established as needed
+
}
/**
@@ -165,6 +182,50 @@
}
/**
+ * Returns true if this federated repository is in the process of terminating after {@link ServiceAdministrator#shutdown()}
+ * has been called on the {@link #getAdministrator() administrator}, but the federated repository has connections that have
+ * not yet normally been {@link RepositoryConnection#close() closed}. This method may be useful for debugging. A return of
+ * <tt>true</tt> reported a sufficient period after shutdown may indicate that connection users have ignored or suppressed
+ * interruption, causing this repository not to properly terminate.
+ *
+ * @return true if terminating but not yet terminated, or false otherwise
+ * @see #isTerminated()
+ */
+ public boolean isTerminating() {
+ try {
+ this.sourcesWriteLock.lock();
+ for (FederatedSource source : this.sources) {
+ if (source.getConnectionPool().isTerminating()) {
+ return true;
+ }
+ }
+ return false;
+ } finally {
+ this.sourcesWriteLock.unlock();
+ }
+ }
+
+ /**
+ * Return true if this federated repository has completed its termination and no longer has any open connections.
+ *
+ * @return true if terminated, or false otherwise
+ * @see #isTerminating()
+ */
+ public boolean isTerminated() {
+ try {
+ this.sourcesWriteLock.lock();
+ for (FederatedSource source : this.sources) {
+ if (!source.getConnectionPool().isTerminated()) {
+ return false;
+ }
+ }
+ return true;
+ } finally {
+ this.sourcesWriteLock.unlock();
+ }
+ }
+
+ /**
* Get an unmodifiable collection of {@link FederatedSource federated sources}.
* <p>
* This method can safely be called while the federation repository is in use.
@@ -287,10 +348,12 @@
* the supplied listener is null.
*
* @param listener the new listener
+ * @return true if the listener was added, or false if the listener was not added (if reference is null, or if non-null
+ * listener is already an existing listener)
*/
- public void addListener( RepositorySourceListener listener ) {
- if (listener == null) return;
- this.listeners.addIfAbsent(listener);
+ public boolean addListener( RepositorySourceListener listener ) {
+ if (listener == null) return false;
+ return this.listeners.addIfAbsent(listener);
}
/**
@@ -308,6 +371,15 @@
}
/**
+ * Get the list of listeners, which is the actual list used by the repository.
+ *
+ * @return the listeners
+ */
+ public List<RepositorySourceListener> getListeners() {
+ return this.listeners;
+ }
+
+ /**
* Authenticate the supplied username with the supplied credentials, and return whether authentication was successful.
*
* @param username the username
Modified: branches/maeste/dna-repository/src/main/java/org/jboss/dna/repository/federation/FederatedRepositoryConnection.java
===================================================================
--- branches/maeste/dna-repository/src/main/java/org/jboss/dna/repository/federation/FederatedRepositoryConnection.java 2008-06-11 08:35:21 UTC (rev 264)
+++ branches/maeste/dna-repository/src/main/java/org/jboss/dna/repository/federation/FederatedRepositoryConnection.java 2008-06-11 08:45:51 UTC (rev 265)
@@ -117,6 +117,11 @@
if (!this.repository.getAdministrator().isStarted()) {
throw new RepositorySourceException(RepositoryI18n.repositoryHasBeenShutDown.text(this.repository.getName()));
}
+ if (commands == null || commands.length == 0) return;
+
+ for (GraphCommand command : commands) {
+ if (command == null) continue;
+ }
}
/**
Modified: branches/maeste/dna-repository/src/main/java/org/jboss/dna/repository/federation/FederatedSource.java
===================================================================
--- branches/maeste/dna-repository/src/main/java/org/jboss/dna/repository/federation/FederatedSource.java 2008-06-11 08:35:21 UTC (rev 264)
+++ branches/maeste/dna-repository/src/main/java/org/jboss/dna/repository/federation/FederatedSource.java 2008-06-11 08:45:51 UTC (rev 265)
@@ -25,8 +25,10 @@
import net.jcip.annotations.ThreadSafe;
import org.jboss.dna.common.util.ArgCheck;
import org.jboss.dna.spi.graph.connection.RepositoryConnection;
+import org.jboss.dna.spi.graph.connection.RepositoryConnectionFactory;
import org.jboss.dna.spi.graph.connection.RepositoryConnectionPool;
import org.jboss.dna.spi.graph.connection.RepositorySource;
+import org.jboss.dna.spi.graph.connection.RepositorySourceException;
/**
* A component that represents a {@link RepositorySource repository source} (with its state) being federated in a
@@ -35,7 +37,7 @@
* @author Randall Hauch
*/
@ThreadSafe
-public class FederatedSource {
+public class FederatedSource implements RepositoryConnectionFactory {
private final RepositorySource source;
private final RepositoryConnectionPool connectionPool;
@@ -46,6 +48,12 @@
this.connectionPool = new RepositoryConnectionPool(source);
}
+ protected FederatedSource( RepositorySource source, RepositoryConnectionPool connectionPool ) {
+ ArgCheck.isNotNull(source, "source");
+ this.source = source;
+ this.connectionPool = connectionPool;
+ }
+
/**
* Get the name for this federated repository source.
*
@@ -74,6 +82,13 @@
}
/**
+ * {@inheritDoc}
+ */
+ public RepositoryConnection getConnection() throws RepositorySourceException, InterruptedException {
+ return this.connectionPool.getConnection();
+ }
+
+ /**
* Determine whether the federated source is available by attempting to connect to the source and
* {@link RepositoryConnection#ping(long, TimeUnit) pinging} the source.
*
Modified: branches/maeste/dna-repository/src/main/java/org/jboss/dna/repository/federation/FederationService.java
===================================================================
--- branches/maeste/dna-repository/src/main/java/org/jboss/dna/repository/federation/FederationService.java 2008-06-11 08:35:21 UTC (rev 264)
+++ branches/maeste/dna-repository/src/main/java/org/jboss/dna/repository/federation/FederationService.java 2008-06-11 08:45:51 UTC (rev 265)
@@ -72,10 +72,18 @@
/**
* {@inheritDoc}
*/
- public boolean awaitTermination( long timeout, TimeUnit unit ) {
- return true;
+ @Override
+ protected boolean doCheckIsTerminated() {
+ return FederationService.this.isTerminated();
}
+ /**
+ * {@inheritDoc}
+ */
+ public boolean awaitTermination( long timeout, TimeUnit unit ) throws InterruptedException {
+ return FederationService.this.awaitTermination(timeout, unit);
+ }
+
}
private final RepositorySource configurationSource;
@@ -164,6 +172,24 @@
}
}
+ protected boolean isTerminated() {
+ // Now shut down all repositories ...
+ for (String repositoryName : this.repositories.keySet()) {
+ FederatedRepository repository = this.repositories.get(repositoryName);
+ if (!repository.getAdministrator().isTerminated()) return false;
+ }
+ return true;
+ }
+
+ protected boolean awaitTermination( long timeout, TimeUnit unit ) throws InterruptedException {
+ // Now shut down all repositories ...
+ for (String repositoryName : this.repositories.keySet()) {
+ FederatedRepository repository = this.repositories.get(repositoryName);
+ if (repository.getAdministrator().awaitTermination(timeout, unit)) return false;
+ }
+ return true;
+ }
+
/**
* Create a {@link RepositorySource} that can be used to establish connections to the federated repository with the supplied
* name.
Modified: branches/maeste/dna-repository/src/main/java/org/jboss/dna/repository/observation/ObservationService.java
===================================================================
--- branches/maeste/dna-repository/src/main/java/org/jboss/dna/repository/observation/ObservationService.java 2008-06-11 08:35:21 UTC (rev 264)
+++ branches/maeste/dna-repository/src/main/java/org/jboss/dna/repository/observation/ObservationService.java 2008-06-11 08:45:51 UTC (rev 265)
@@ -56,6 +56,7 @@
/**
* Interface to which problems with particular events are logged.
+ *
* @author Randall Hauch
*/
public static interface ProblemLog {
@@ -65,6 +66,7 @@
/**
* Problem log implementation that records problems in the log.
+ *
* @author Randall Hauch
*/
public class DefaultProblemLog implements ProblemLog {
@@ -90,6 +92,7 @@
/**
* The administrative component for this service.
+ *
* @author Randall Hauch
*/
protected class Administrator extends AbstractServiceAdministrator {
@@ -114,6 +117,14 @@
return true;
}
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected boolean doCheckIsTerminated() {
+ return true;
+ }
+
}
private Logger logger = Logger.getLogger(this.getClass());
@@ -146,6 +157,7 @@
/**
* Get the statistics for this system.
+ *
* @return the statistics, which are updated as the system is used
*/
public Statistics getStatistics() {
@@ -154,6 +166,7 @@
/**
* Get the logger for this system
+ *
* @return the logger
*/
public Logger getLogger() {
@@ -162,6 +175,7 @@
/**
* Set the logger for this system.
+ *
* @param logger the logger, or null if the standard logging should be used
*/
public void setLogger( Logger logger ) {
@@ -177,6 +191,7 @@
/**
* Set the problem log that will be notified of problems handling events. By default, such problems are sent to the log.
+ *
* @param problemLog the new problem log implementation; if null, then the default problem log is used
*/
public void setProblemLog( ProblemLog problemLog ) {
@@ -256,6 +271,7 @@
* The filters of an already-registered {@link WorkspaceListener} can be changed at runtime by changing the attributes and
* {@link WorkspaceListener#reregister() registering}.
* </p>
+ *
* @param repositoryWorkspaceName the name to be used with the session factory to obtain a session to the repository and
* workspace that is to be monitored
* @param absolutePath the absolute path of the node at or below which changes are to be monitored; may be null if all nodes
@@ -292,6 +308,7 @@
* needed, it simply must be {@link ObservationManager#removeEventListener(EventListener) removed} as a listener of the
* workspace and garbage collected.
* </p>
+ *
* @param repositoryWorkspaceName the name to be used with the session factory to obtain a session to the repository and
* workspace that is to be monitored
* @param absolutePath the absolute path of the node at or below which changes are to be monitored; may be null if all nodes
@@ -317,6 +334,7 @@
* needed, it simply must be {@link ObservationManager#removeEventListener(EventListener) removed} as a listener of the
* workspace and garbage collected.
* </p>
+ *
* @param repositoryWorkspaceName the name to be used with the session factory to obtain a session to the repository and
* workspace that is to be monitored
* @param eventTypes the bitmask of the {@link Event} types that are to be monitored
@@ -341,6 +359,7 @@
* made but excluding those to which that particular listener is not entitled, according to the listeners access permissions
* and filters.
* </p>
+ *
* @param events
* @param listener
*/
@@ -460,6 +479,7 @@
/**
* Implementation of the {@link EventListener JCR EventListener} interface, returned by the sequencing system.
+ *
* @author Randall Hauch
*/
@ThreadSafe
@@ -617,6 +637,7 @@
/**
* The statistics for the system. Each sequencing system has an instance of this class that is updated.
+ *
* @author Randall Hauch
*/
@ThreadSafe
Modified: branches/maeste/dna-repository/src/main/java/org/jboss/dna/repository/rules/RuleService.java
===================================================================
--- branches/maeste/dna-repository/src/main/java/org/jboss/dna/repository/rules/RuleService.java 2008-06-11 08:35:21 UTC (rev 264)
+++ branches/maeste/dna-repository/src/main/java/org/jboss/dna/repository/rules/RuleService.java 2008-06-11 08:45:51 UTC (rev 265)
@@ -70,6 +70,7 @@
* the same time, all executions will be properly synchronized with methods to {@link #addRuleSet(RuleSet) add},
* {@link #updateRuleSet(RuleSet) update}, and {@link #removeRuleSet(String) remove} rule sets.
* </p>
+ *
* @author Randall Hauch
*/
@ThreadSafe
@@ -79,6 +80,7 @@
/**
* The administrative component for this service.
+ *
* @author Randall Hauch
*/
protected class Administrator extends AbstractServiceAdministrator {
@@ -100,6 +102,14 @@
/**
* {@inheritDoc}
*/
+ @Override
+ protected boolean doCheckIsTerminated() {
+ return RuleService.this.isTerminated();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
public boolean awaitTermination( long timeout, TimeUnit unit ) throws InterruptedException {
return doAwaitTermination(timeout, unit);
}
@@ -124,6 +134,7 @@
/**
* Return the administrative component for this service.
+ *
* @return the administrative component; never null
*/
public ServiceAdministrator getAdministrator() {
@@ -134,6 +145,7 @@
* Get the class loader factory that should be used to load sequencers. By default, this service uses a factory that will
* return either the {@link Thread#getContextClassLoader() current thread's context class loader} (if not null) or the class
* loader that loaded this class.
+ *
* @return the class loader factory; never null
* @see #setClassLoaderFactory(ClassLoaderFactory)
*/
@@ -145,6 +157,7 @@
* Set the Maven Repository that should be used to load the sequencer classes. By default, this service uses a class loader
* factory that will return either the {@link Thread#getContextClassLoader() current thread's context class loader} (if not
* null) or the class loader that loaded this class.
+ *
* @param classLoaderFactory the class loader factory reference, or null if the default class loader factory should be used.
* @see #getClassLoaderFactory()
*/
@@ -154,6 +167,7 @@
/**
* Obtain the rule sets that are currently available in this service.
+ *
* @return an unmodifiable copy of the rule sets; never null, but possibly empty ...
*/
public Collection<RuleSet> getRuleSets() {
@@ -170,6 +184,7 @@
/**
* Add a rule set, or update any existing one that represents the {@link RuleSet#equals(Object) same rule set}
+ *
* @param ruleSet the new rule set
* @return true if the rule set was added, or false if the rule set was not added (because it wasn't necessary)
* @throws IllegalArgumentException if <code>ruleSet</code> is null
@@ -266,6 +281,7 @@
/**
* Update the configuration for a sequencer, or add it if there is no {@link RuleSet#equals(Object) matching configuration}.
+ *
* @param ruleSet the rule set to be updated
* @return true if the rule set was updated, or false if the rule set was not updated (because it wasn't necessary)
* @throws InvalidRuleSetException if the supplied rule set is invalid, incomplete, incorrectly defined, or uses a JSR-94
@@ -279,6 +295,7 @@
/**
* Remove a rule set.
+ *
* @param ruleSetName the name of the rule set to be removed
* @return true if the rule set was removed, or if it was not an existing rule set
* @throws IllegalArgumentException if <code>ruleSetName</code> is null or empty
@@ -310,6 +327,7 @@
/**
* Get the logger for this system
+ *
* @return the logger
*/
public Logger getLogger() {
@@ -318,6 +336,7 @@
/**
* Set the logger for this system.
+ *
* @param logger the logger, or null if the standard logging should be used
*/
public void setLogger( Logger logger ) {
@@ -328,6 +347,7 @@
* Execute the set of rules defined by the supplied rule set name. This method is safe to be concurrently called by multiple
* threads, and is properly synchronized with the methods to {@link #addRuleSet(RuleSet) add},
* {@link #updateRuleSet(RuleSet) update}, and {@link #removeRuleSet(String) remove} rule sets.
+ *
* @param ruleSetName the {@link RuleSet#getName() name} of the {@link RuleSet} that should be used
* @param globals the global variables
* @param facts the facts
@@ -396,8 +416,13 @@
return this.shutdownLatch.await(timeout, unit);
}
+ protected boolean isTerminated() {
+ return this.shutdownLatch.getCount() == 0;
+ }
+
/**
* Finds the JSR-94 service provider instance and returns it. If it could not be found, this method attempts to load it.
+ *
* @param ruleSet the rule set for which the service provider is to be found; may not be null
* @return the rule service provider; never null
* @throws ConfigurationException if there is a problem loading the service provider
@@ -433,6 +458,7 @@
/**
* Deregister the supplied rule set, if it could be found. This method does nothing if any of the service provider components
* could not be found.
+ *
* @param ruleSet the rule set to be deregistered; may not be null
* @return the service provider reference, or null if the service provider could not be found ...
* @throws ConfigurationException
Modified: branches/maeste/dna-repository/src/main/java/org/jboss/dna/repository/rules/RuleSetRepositoryMonitor.java
===================================================================
--- branches/maeste/dna-repository/src/main/java/org/jboss/dna/repository/rules/RuleSetRepositoryMonitor.java 2008-06-11 08:35:21 UTC (rev 264)
+++ branches/maeste/dna-repository/src/main/java/org/jboss/dna/repository/rules/RuleSetRepositoryMonitor.java 2008-06-11 08:45:51 UTC (rev 265)
@@ -34,7 +34,7 @@
import javax.jcr.RepositoryException;
import javax.jcr.Session;
import net.jcip.annotations.ThreadSafe;
-import org.jboss.dna.common.collection.Problems;
+import org.jboss.dna.common.collection.SimpleProblems;
import org.jboss.dna.common.util.ArgCheck;
import org.jboss.dna.common.util.Logger;
import org.jboss.dna.repository.RepositoryI18n;
@@ -228,18 +228,18 @@
protected RuleSet buildRuleSet( String name, Node ruleSetNode, JcrTools tools ) {
if (ruleSetNode == null) return null;
- Problems problems = new Problems();
- String description = tools.getPropertyAsString(ruleSetNode, "jcr:description", false, problems);
- String classname = tools.getPropertyAsString(ruleSetNode, "dna:classname", true, problems);
- String[] classpath = tools.getPropertyAsStringArray(ruleSetNode, "dna:classpath", false, problems);
- String providerUri = tools.getPropertyAsString(ruleSetNode, "dna:serviceProviderUri", true, problems);
- String ruleSetUri = tools.getPropertyAsString(ruleSetNode, "dna:ruleSetUri", true, name, problems);
- String rules = tools.getPropertyAsString(ruleSetNode, "dna:rules", true, problems);
- Map<String, Object> properties = tools.loadProperties(ruleSetNode, problems);
- if (problems.hasProblems()) {
+ SimpleProblems simpleProblems = new SimpleProblems();
+ String description = tools.getPropertyAsString(ruleSetNode, "jcr:description", false, simpleProblems);
+ String classname = tools.getPropertyAsString(ruleSetNode, "dna:classname", true, simpleProblems);
+ String[] classpath = tools.getPropertyAsStringArray(ruleSetNode, "dna:classpath", false, simpleProblems);
+ String providerUri = tools.getPropertyAsString(ruleSetNode, "dna:serviceProviderUri", true, simpleProblems);
+ String ruleSetUri = tools.getPropertyAsString(ruleSetNode, "dna:ruleSetUri", true, name, simpleProblems);
+ String rules = tools.getPropertyAsString(ruleSetNode, "dna:rules", true, simpleProblems);
+ Map<String, Object> properties = tools.loadProperties(ruleSetNode, simpleProblems);
+ if (simpleProblems.hasProblems()) {
// There are problems, so store and save them, and then return null ...
try {
- if (tools.storeProblems(ruleSetNode, problems)) ruleSetNode.save();
+ if (tools.storeProblems(ruleSetNode, simpleProblems)) ruleSetNode.save();
} catch (RepositoryException e) {
this.logger.error(e, RepositoryI18n.errorWritingProblemsOnRuleSet, tools.getReadable(ruleSetNode));
}
Modified: branches/maeste/dna-repository/src/main/java/org/jboss/dna/repository/sequencers/SequencingService.java
===================================================================
--- branches/maeste/dna-repository/src/main/java/org/jboss/dna/repository/sequencers/SequencingService.java 2008-06-11 08:35:21 UTC (rev 264)
+++ branches/maeste/dna-repository/src/main/java/org/jboss/dna/repository/sequencers/SequencingService.java 2008-06-11 08:45:51 UTC (rev 265)
@@ -66,18 +66,21 @@
/**
* A sequencing system is used to monitor changes in the content of {@link Repository JCR repositories} and to sequence the
* content to extract or to generate structured information.
+ *
* @author Randall Hauch
*/
public class SequencingService implements AdministeredService, NodeChangeListener {
/**
* Interface used to select the set of {@link Sequencer} instances that should be run.
+ *
* @author Randall Hauch
*/
public static interface Selector {
/**
* Select the sequencers that should be used to sequence the supplied node.
+ *
* @param sequencers the list of all sequencers available at the moment; never null
* @param node the node to be sequenced; never null
* @param nodeChange the set of node changes; never null
@@ -89,6 +92,7 @@
/**
* The default {@link Selector} implementation that selects every sequencer every time it's called, regardless of the node (or
* logger) supplied.
+ *
* @author Randall Hauch
*/
protected static class DefaultSelector implements Selector {
@@ -100,12 +104,14 @@
/**
* Interface used to determine whether a {@link NodeChange} should be processed.
+ *
* @author Randall Hauch
*/
public static interface NodeFilter {
/**
* Determine whether the node represented by the supplied change should be submitted for sequencing.
+ *
* @param nodeChange the node change event
* @return true if the node should be submitted for sequencing, or false if the change should be ignored
*/
@@ -114,6 +120,7 @@
/**
* The default filter implementation, which accepts only new nodes or nodes that have new or changed properties.
+ *
* @author Randall Hauch
*/
protected static class DefaultNodeFilter implements NodeFilter {
@@ -126,11 +133,13 @@
/**
* The default {@link Selector} that considers every {@link Sequencer} to be used for every node.
+ *
* @see SequencingService#setSequencerSelector(org.jboss.dna.repository.sequencers.SequencingService.Selector)
*/
public static final Selector DEFAULT_SEQUENCER_SELECTOR = new DefaultSelector();
/**
* The default {@link NodeFilter} that accepts new nodes or nodes that have new/changed properties.
+ *
* @see SequencingService#setSequencerSelector(org.jboss.dna.repository.sequencers.SequencingService.Selector)
*/
public static final NodeFilter DEFAULT_NODE_FILTER = new DefaultNodeFilter();
@@ -144,6 +153,7 @@
/**
* The administrative component for this service.
+ *
* @author Randall Hauch
*/
protected class Administrator extends AbstractServiceAdministrator {
@@ -173,6 +183,14 @@
/**
* {@inheritDoc}
*/
+ @Override
+ protected boolean doCheckIsTerminated() {
+ return isServiceTerminated();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
public boolean awaitTermination( long timeout, TimeUnit unit ) throws InterruptedException {
return doAwaitTermination(timeout, unit);
}
@@ -199,6 +217,7 @@
/**
* Return the administrative component for this service.
+ *
* @return the administrative component; never null
*/
public ServiceAdministrator getAdministrator() {
@@ -207,6 +226,7 @@
/**
* Get the statistics for this system.
+ *
* @return statistics
*/
public Statistics getStatistics() {
@@ -224,6 +244,7 @@
* Get the class loader factory that should be used to load sequencers. By default, this service uses a factory that will
* return either the {@link Thread#getContextClassLoader() current thread's context class loader} (if not null) or the class
* loader that loaded this class.
+ *
* @return the class loader factory; never null
* @see #setClassLoaderFactory(ClassLoaderFactory)
*/
@@ -235,6 +256,7 @@
* Set the Maven Repository that should be used to load the sequencer classes. By default, this service uses a class loader
* factory that will return either the {@link Thread#getContextClassLoader() current thread's context class loader} (if not
* null) or the class loader that loaded this class.
+ *
* @param classLoaderFactory the class loader factory reference, or null if the default class loader factory should be used.
* @see #getClassLoaderFactory()
*/
@@ -245,6 +267,7 @@
/**
* Add the configuration for a sequencer, or update any existing one that represents the
* {@link SequencerConfig#equals(Object) same configuration}
+ *
* @param config the new configuration
* @return true if the sequencer was added, or false if there already was an existing and
* {@link SequencerConfig#hasChanged(SequencerConfig) unchanged} sequencer configuration
@@ -259,6 +282,7 @@
/**
* Update the configuration for a sequencer, or add it if there is no
* {@link SequencerConfig#equals(Object) matching configuration}.
+ *
* @param config the updated (or new) configuration
* @return true if the sequencer was updated, or false if there already was an existing and
* {@link SequencerConfig#hasChanged(SequencerConfig) unchanged} sequencer configuration
@@ -272,6 +296,7 @@
/**
* Remove the configuration for a sequencer.
+ *
* @param config the configuration to be removed
* @return true if the sequencer was removed, or false if there was no existing sequencer
* @throws IllegalArgumentException if <code>config</code> is null
@@ -284,6 +309,7 @@
/**
* Get the logger for this system
+ *
* @return the logger
*/
public Logger getLogger() {
@@ -292,6 +318,7 @@
/**
* Set the logger for this system.
+ *
* @param logger the logger, or null if the standard logging should be used
*/
public void setLogger( Logger logger ) {
@@ -318,6 +345,7 @@
/**
* Get the executor service used to run the sequencers.
+ *
* @return the executor service
* @see #setExecutorService(ExecutorService)
*/
@@ -328,6 +356,7 @@
/**
* Set the executor service that should be used by this system. By default, the system is set up with a
* {@link Executors#newSingleThreadExecutor() executor that uses a single thread}.
+ *
* @param executorService the executor service
* @see #getExecutorService()
* @see Executors#newCachedThreadPool()
@@ -355,6 +384,7 @@
* <p>
* This method creates a {@link Executors#newSingleThreadExecutor() single-threaded executor}.
* </p>
+ *
* @return
*/
protected ExecutorService createDefaultExecutorService() {
@@ -380,6 +410,13 @@
}
}
+ protected boolean isServiceTerminated() {
+ if (this.executorService != null) {
+ return this.executorService.isTerminated();
+ }
+ return true;
+ }
+
protected boolean doAwaitTermination( long timeout, TimeUnit unit ) throws InterruptedException {
if (this.executorService == null || this.executorService.isTerminated()) return true;
return this.executorService.awaitTermination(timeout, unit);
@@ -387,6 +424,7 @@
/**
* Get the sequencing selector used by this system.
+ *
* @return the sequencing selector
*/
public Selector getSequencerSelector() {
@@ -395,6 +433,7 @@
/**
* Set the sequencer selector, or null if the {@link #DEFAULT_SEQUENCER_SELECTOR default sequencer selector} should be used.
+ *
* @param sequencerSelector the selector
*/
public void setSequencerSelector( Selector sequencerSelector ) {
@@ -403,6 +442,7 @@
/**
* Get the node filter used by this system.
+ *
* @return the node filter
*/
public NodeFilter getNodeFilter() {
@@ -412,6 +452,7 @@
/**
* Set the filter that checks which nodes are to be sequenced, or null if the {@link #DEFAULT_NODE_FILTER default node filter}
* should be used.
+ *
* @param nodeFilter the new node filter
*/
public void setNodeFilter( NodeFilter nodeFilter ) {
@@ -443,6 +484,7 @@
/**
* Do the work of processing by sequencing the node. This method is called by the {@link #executorService executor service}
* when it performs it's work on the enqueued {@link ChangedNode ChangedNode runnable objects}.
+ *
* @param node the node to be processed.
*/
protected void processChangedNode( NodeChange changedNode ) {
@@ -620,6 +662,7 @@
/**
* The statistics for the system. Each sequencing system has an instance of this class that is updated.
+ *
* @author Randall Hauch
*/
@ThreadSafe
Modified: branches/maeste/dna-repository/src/main/java/org/jboss/dna/repository/sequencers/xml/XmlSequencer.java
===================================================================
--- branches/maeste/dna-repository/src/main/java/org/jboss/dna/repository/sequencers/xml/XmlSequencer.java 2008-06-11 08:35:21 UTC (rev 264)
+++ branches/maeste/dna-repository/src/main/java/org/jboss/dna/repository/sequencers/xml/XmlSequencer.java 2008-06-11 08:45:51 UTC (rev 265)
@@ -1,5 +1,23 @@
/*
+ * 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.repository.sequencers.xml;
@@ -33,649 +51,649 @@
*/
public class XmlSequencer implements StreamSequencer {
- static final Logger LOGGER = Logger.getLogger(XmlSequencer.class);
+ static final Logger LOGGER = Logger.getLogger(XmlSequencer.class);
- static final String CDATA = "dnaxml:cData";
- static final String CDATA_CONTENT = "dnaxml:cDataContent";
- static final String COMMENT = "dnaxml:comment";
- static final String COMMENT_CONTENT = "dnaxml:commentContent";
- static final String DOCUMENT = "dnaxml:document";
- static final String DTD_NAME = "dnadtd:name";
- static final String DTD_PUBLIC_ID = "dnadtd:publicId";
- static final String DTD_SYSTEM_ID = "dnadtd:systemId";
- static final String DTD_VALUE = "dnadtd:value";
- static final String ELEMENT_CONTENT = "dnaxml:elementContent";
- static final String ENTITY = "dnadtd:entity";
- static final String PI = "dnaxml:processingInstruction";
- static final String PI_CONTENT = "dnaxml:processingInstructionContent";
- static final String TARGET = "dnaxml:target";
+ static final String CDATA = "dnaxml:cData";
+ static final String CDATA_CONTENT = "dnaxml:cDataContent";
+ static final String COMMENT = "dnaxml:comment";
+ static final String COMMENT_CONTENT = "dnaxml:commentContent";
+ static final String DOCUMENT = "dnaxml:document";
+ static final String DTD_NAME = "dnadtd:name";
+ static final String DTD_PUBLIC_ID = "dnadtd:publicId";
+ static final String DTD_SYSTEM_ID = "dnadtd:systemId";
+ static final String DTD_VALUE = "dnadtd:value";
+ static final String ELEMENT_CONTENT = "dnaxml:elementContent";
+ static final String ENTITY = "dnadtd:entity";
+ static final String PI = "dnaxml:processingInstruction";
+ static final String PI_CONTENT = "dnaxml:processingInstructionContent";
+ static final String TARGET = "dnaxml:target";
- private static final String DECL_HANDLER_FEATURE = "http://xml.org/sax/properties/declaration-handler";
- private static final String ENTITY_RESOLVER_2_FEATURE = "http://xml.org/sax/features/use-entity-resolver2";
- private static final String LEXICAL_HANDLER_FEATURE = "http://xml.org/sax/properties/lexical-handler";
+ private static final String DECL_HANDLER_FEATURE = "http://xml.org/sax/properties/declaration-handler";
+ private static final String ENTITY_RESOLVER_2_FEATURE = "http://xml.org/sax/features/use-entity-resolver2";
+ private static final String LEXICAL_HANDLER_FEATURE = "http://xml.org/sax/properties/lexical-handler";
- /**
- * <p>
- * {@inheritDoc}
- * </p>
- *
- * @see org.jboss.dna.spi.sequencers.StreamSequencer#sequence(java.io.InputStream,
- * org.jboss.dna.spi.sequencers.SequencerOutput, org.jboss.dna.common.monitor.ProgressMonitor)
- */
- public void sequence( InputStream stream,
- SequencerOutput output,
- ProgressMonitor monitor ) {
- monitor.beginTask(100.0, RepositoryI18n.sequencingXmlDocument);
- XMLReader reader;
- try {
- reader = XMLReaderFactory.createXMLReader();
- Handler handler = new Handler(output, monitor);
- reader.setContentHandler(handler);
- reader.setErrorHandler(handler);
- // Ensure handler acting as entity resolver 2
- reader.setProperty(DECL_HANDLER_FEATURE, handler);
- // Ensure handler acting as lexical handler
- reader.setProperty(LEXICAL_HANDLER_FEATURE, handler);
- // Ensure handler acting as entity resolver 2
- try {
- if (!reader.getFeature(ENTITY_RESOLVER_2_FEATURE)) {
- reader.setFeature(ENTITY_RESOLVER_2_FEATURE, true);
- }
- } catch (SAXNotRecognizedException meansFeatureNotSupported) {
- }
- // Prevent loading of external DTDs
- reader.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);
- // Parse XML document
- reader.parse(new InputSource(stream));
- } catch (Exception err) {
- LOGGER.error(err, RepositoryI18n.errorSequencingXmlDocument);
- } finally {
- monitor.done();
- }
- }
+ /**
+ * <p>
+ * {@inheritDoc}
+ * </p>
+ *
+ * @see org.jboss.dna.spi.sequencers.StreamSequencer#sequence(java.io.InputStream,
+ * org.jboss.dna.spi.sequencers.SequencerOutput, org.jboss.dna.common.monitor.ProgressMonitor)
+ */
+ public void sequence( InputStream stream,
+ SequencerOutput output,
+ ProgressMonitor monitor ) {
+ monitor.beginTask(100.0, RepositoryI18n.sequencingXmlDocument);
+ XMLReader reader;
+ try {
+ reader = XMLReaderFactory.createXMLReader();
+ Handler handler = new Handler(output, monitor);
+ reader.setContentHandler(handler);
+ reader.setErrorHandler(handler);
+ // Ensure handler acting as entity resolver 2
+ reader.setProperty(DECL_HANDLER_FEATURE, handler);
+ // Ensure handler acting as lexical handler
+ reader.setProperty(LEXICAL_HANDLER_FEATURE, handler);
+ // Ensure handler acting as entity resolver 2
+ try {
+ if (!reader.getFeature(ENTITY_RESOLVER_2_FEATURE)) {
+ reader.setFeature(ENTITY_RESOLVER_2_FEATURE, true);
+ }
+ } catch (SAXNotRecognizedException meansFeatureNotSupported) {
+ }
+ // Prevent loading of external DTDs
+ reader.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);
+ // Parse XML document
+ reader.parse(new InputSource(stream));
+ } catch (Exception err) {
+ LOGGER.error(err, RepositoryI18n.errorSequencingXmlDocument);
+ } finally {
+ monitor.done();
+ }
+ }
- private class Handler extends DefaultHandler2 {
+ private class Handler extends DefaultHandler2 {
- private ProgressMonitor monitor;
- private SequencerOutput output;
- private double progress;
+ private ProgressMonitor monitor;
+ private SequencerOutput output;
+ private double progress;
- private Path path; // The DNA path of the node representing the current XML element
+ private Path path; // The DNA path of the node representing the current XML element
- // Cached instances of the name factory and commonly referenced names
- private NameFactory nameFactory;
- private Name commentContentName;
- private Name commentName;
- private Name elementContentName;
- private Name primaryTypeName;
- private Name targetName;
+ // Cached instances of the name factory and commonly referenced names
+ private NameFactory nameFactory;
+ private Name commentContentName;
+ private Name commentName;
+ private Name elementContentName;
+ private Name primaryTypeName;
+ private Name targetName;
- // Recursive map used to track the number of occurrences of names for elements under a particular path
- private Map<Name, List<IndexedName>> nameToIndexedNamesMap = new HashMap<Name, List<IndexedName>>();
+ // Recursive map used to track the number of occurrences of names for elements under a particular path
+ private Map<Name, List<IndexedName>> nameToIndexedNamesMap = new HashMap<Name, List<IndexedName>>();
- // The stack of recursive maps being processed, with the head entry being the map for the current path
- private LinkedList<Map<Name, List<IndexedName>>> nameToIndexedNamesMapStack = new LinkedList<Map<Name, List<IndexedName>>>();
+ // The stack of recursive maps being processed, with the head entry being the map for the current path
+ private LinkedList<Map<Name, List<IndexedName>>> nameToIndexedNamesMapStack = new LinkedList<Map<Name, List<IndexedName>>>();
- // The stack of XML namespace in scope, with the head entry being namespace of the closest ancestor element declaring a
- // namespace.
- private LinkedList<String> nsStack = new LinkedList<String>();
+ // The stack of XML namespace in scope, with the head entry being namespace of the closest ancestor element declaring a
+ // namespace.
+ private LinkedList<String> nsStack = new LinkedList<String>();
- // Builder used to concatenate concurrent lines of CDATA into a single value.
- private StringBuilder cDataBuilder;
+ // Builder used to concatenate concurrent lines of CDATA into a single value.
+ private StringBuilder cDataBuilder;
- // Builder used to concatenate concurrent lines of element content and entity evaluations into a single value.
- private StringBuilder contentBuilder;
+ // Builder used to concatenate concurrent lines of element content and entity evaluations into a single value.
+ private StringBuilder contentBuilder;
- // The entity being processed
- private String entity;
+ // The entity being processed
+ private String entity;
- Handler( SequencerOutput output,
- ProgressMonitor monitor ) {
- this.output = output;
- this.monitor = monitor;
- // Initialize path to a an empty path relative to the SequencerOutput's target path.
- path = output.getFactories().getPathFactory().createRelativePath();
- // Cache name factory since it is frequently used
- nameFactory = output.getFactories().getNameFactory();
- }
+ Handler( SequencerOutput output,
+ ProgressMonitor monitor ) {
+ this.output = output;
+ this.monitor = monitor;
+ // Initialize path to a an empty path relative to the SequencerOutput's target path.
+ path = output.getFactories().getPathFactory().createRelativePath();
+ // Cache name factory since it is frequently used
+ nameFactory = output.getFactories().getNameFactory();
+ }
- /**
- * <p>
- * {@inheritDoc}
- * </p>
- *
- * @see org.xml.sax.ext.DefaultHandler2#attributeDecl(java.lang.String, java.lang.String, java.lang.String,
- * java.lang.String, java.lang.String)
- */
- @Override
- public void attributeDecl( String name,
- String name2,
- String type,
- String mode,
- String value ) throws SAXException {
- stopIfCancelled();
- }
+ /**
+ * <p>
+ * {@inheritDoc}
+ * </p>
+ *
+ * @see org.xml.sax.ext.DefaultHandler2#attributeDecl(java.lang.String, java.lang.String, java.lang.String,
+ * java.lang.String, java.lang.String)
+ */
+ @Override
+ public void attributeDecl( String name,
+ String name2,
+ String type,
+ String mode,
+ String value ) throws SAXException {
+ stopIfCancelled();
+ }
- /**
- * <p>
- * {@inheritDoc}
- * </p>
- *
- * @see org.xml.sax.helpers.DefaultHandler#characters(char[], int, int)
- */
- @Override
- public void characters( char[] ch,
- int start,
- int length ) throws SAXException {
- stopIfCancelled();
- String content = String.valueOf(ch, start, length);
- // Check if data should be appended to previously parsed CDATA
- if (cDataBuilder == null) {
- // If content is for an entity, replace with entity reference
- if (entity != null) {
- content = '&' + entity + ';';
- }
- // Check if first line of content
- if (contentBuilder == null) {
- contentBuilder = new StringBuilder(content);
- } else {
- // Append additional lines or entity evaluations to previous content, separated by a space
- if (entity == null) {
- contentBuilder.append(' ');
- }
- contentBuilder.append(content);
- // Text within builder will be output when another element or CDATA is encountered
- }
- } else {
- cDataBuilder.append(ch, start, length);
- // Text within builder will be output at the end of CDATA
- }
- updateProgress();
- }
+ /**
+ * <p>
+ * {@inheritDoc}
+ * </p>
+ *
+ * @see org.xml.sax.helpers.DefaultHandler#characters(char[], int, int)
+ */
+ @Override
+ public void characters( char[] ch,
+ int start,
+ int length ) throws SAXException {
+ stopIfCancelled();
+ String content = String.valueOf(ch, start, length);
+ // Check if data should be appended to previously parsed CDATA
+ if (cDataBuilder == null) {
+ // If content is for an entity, replace with entity reference
+ if (entity != null) {
+ content = '&' + entity + ';';
+ }
+ // Check if first line of content
+ if (contentBuilder == null) {
+ contentBuilder = new StringBuilder(content);
+ } else {
+ // Append additional lines or entity evaluations to previous content, separated by a space
+ if (entity == null) {
+ contentBuilder.append(' ');
+ }
+ contentBuilder.append(content);
+ // Text within builder will be output when another element or CDATA is encountered
+ }
+ } else {
+ cDataBuilder.append(ch, start, length);
+ // Text within builder will be output at the end of CDATA
+ }
+ updateProgress();
+ }
- /**
- * <p>
- * {@inheritDoc}
- * </p>
- *
- * @see org.xml.sax.ext.DefaultHandler2#comment(char[], int, int)
- */
- @Override
- public void comment( char[] ch,
- int start,
- int length ) throws SAXException {
- stopIfCancelled();
- // Output separate nodes for each comment since multiple are allowed
- startElement(getCommentName());
- output.setProperty(path, getPrimaryTypeName(), getCommentName());
- output.setProperty(path, getCommentContentName(), String.valueOf(ch, start, length));
- endElement();
- updateProgress();
- }
+ /**
+ * <p>
+ * {@inheritDoc}
+ * </p>
+ *
+ * @see org.xml.sax.ext.DefaultHandler2#comment(char[], int, int)
+ */
+ @Override
+ public void comment( char[] ch,
+ int start,
+ int length ) throws SAXException {
+ stopIfCancelled();
+ // Output separate nodes for each comment since multiple are allowed
+ startElement(getCommentName());
+ output.setProperty(path, getPrimaryTypeName(), getCommentName());
+ output.setProperty(path, getCommentContentName(), String.valueOf(ch, start, length));
+ endElement();
+ updateProgress();
+ }
- /**
- * <p>
- * {@inheritDoc}
- * </p>
- *
- * @see org.xml.sax.ext.DefaultHandler2#elementDecl(java.lang.String, java.lang.String)
- */
- @Override
- public void elementDecl( String name,
- String model ) throws SAXException {
- stopIfCancelled();
- }
+ /**
+ * <p>
+ * {@inheritDoc}
+ * </p>
+ *
+ * @see org.xml.sax.ext.DefaultHandler2#elementDecl(java.lang.String, java.lang.String)
+ */
+ @Override
+ public void elementDecl( String name,
+ String model ) throws SAXException {
+ stopIfCancelled();
+ }
- /**
- * <p>
- * {@inheritDoc}
- * </p>
- *
- * @see org.xml.sax.ext.DefaultHandler2#endCDATA()
- */
- @Override
- public void endCDATA() throws SAXException {
- stopIfCancelled();
- // Output CDATA built in characters() method
- output.setProperty(path, nameFactory.create(CDATA_CONTENT), cDataBuilder.toString());
- endElement();
- // Null-out builder to free memory
- cDataBuilder = null;
- updateProgress();
- }
+ /**
+ * <p>
+ * {@inheritDoc}
+ * </p>
+ *
+ * @see org.xml.sax.ext.DefaultHandler2#endCDATA()
+ */
+ @Override
+ public void endCDATA() throws SAXException {
+ stopIfCancelled();
+ // Output CDATA built in characters() method
+ output.setProperty(path, nameFactory.create(CDATA_CONTENT), cDataBuilder.toString());
+ endElement();
+ // Null-out builder to free memory
+ cDataBuilder = null;
+ updateProgress();
+ }
- private void endContent() {
- if (contentBuilder != null) {
- // Normalize content
- String content = StringUtil.normalize(contentBuilder.toString());
- // Null-out builder to setup for subsequent content.
- // Must be done before call to startElement below to prevent infinite loop.
- contentBuilder = null;
- // Skip if nothing in content but whitespace
- if (content.length() > 0) {
- // Create separate node for each content entry since entries can be interspersed amongst child elements
- startElement(getElementContentName());
- output.setProperty(path, getPrimaryTypeName(), getElementContentName());
- output.setProperty(path, getElementContentName(), content);
- endElement();
- }
- }
- }
+ private void endContent() {
+ if (contentBuilder != null) {
+ // Normalize content
+ String content = StringUtil.normalize(contentBuilder.toString());
+ // Null-out builder to setup for subsequent content.
+ // Must be done before call to startElement below to prevent infinite loop.
+ contentBuilder = null;
+ // Skip if nothing in content but whitespace
+ if (content.length() > 0) {
+ // Create separate node for each content entry since entries can be interspersed amongst child elements
+ startElement(getElementContentName());
+ output.setProperty(path, getPrimaryTypeName(), getElementContentName());
+ output.setProperty(path, getElementContentName(), content);
+ endElement();
+ }
+ }
+ }
- /**
- * <p>
- * {@inheritDoc}
- * </p>
- *
- * @see org.xml.sax.helpers.DefaultHandler#endDocument()
- */
- @Override
- public void endDocument() throws SAXException {
- stopIfCancelled();
- }
+ /**
+ * <p>
+ * {@inheritDoc}
+ * </p>
+ *
+ * @see org.xml.sax.helpers.DefaultHandler#endDocument()
+ */
+ @Override
+ public void endDocument() throws SAXException {
+ stopIfCancelled();
+ }
- /**
- * <p>
- * {@inheritDoc}
- * </p>
- *
- * @see org.xml.sax.ext.DefaultHandler2#endDTD()
- */
- @Override
- public void endDTD() throws SAXException {
- stopIfCancelled();
- }
+ /**
+ * <p>
+ * {@inheritDoc}
+ * </p>
+ *
+ * @see org.xml.sax.ext.DefaultHandler2#endDTD()
+ */
+ @Override
+ public void endDTD() throws SAXException {
+ stopIfCancelled();
+ }
- private void endElement() {
- // Recover parent's path, namespace, and indexedName map, clearing the ended element's map to free memory
- path = path.getAncestor();
- nameToIndexedNamesMap.clear();
- nameToIndexedNamesMap = nameToIndexedNamesMapStack.removeFirst();
- nsStack.removeFirst();
- }
+ private void endElement() {
+ // Recover parent's path, namespace, and indexedName map, clearing the ended element's map to free memory
+ path = path.getAncestor();
+ nameToIndexedNamesMap.clear();
+ nameToIndexedNamesMap = nameToIndexedNamesMapStack.removeFirst();
+ nsStack.removeFirst();
+ }
- /**
- * <p>
- * {@inheritDoc}
- * </p>
- *
- * @see org.xml.sax.helpers.DefaultHandler#endElement(java.lang.String, java.lang.String, java.lang.String)
- */
- @Override
- public void endElement( String uri,
- String localName,
- String name ) throws SAXException {
- stopIfCancelled();
- // Check if content still needs to be output
- endContent();
- endElement();
- updateProgress();
- }
+ /**
+ * <p>
+ * {@inheritDoc}
+ * </p>
+ *
+ * @see org.xml.sax.helpers.DefaultHandler#endElement(java.lang.String, java.lang.String, java.lang.String)
+ */
+ @Override
+ public void endElement( String uri,
+ String localName,
+ String name ) throws SAXException {
+ stopIfCancelled();
+ // Check if content still needs to be output
+ endContent();
+ endElement();
+ updateProgress();
+ }
- /**
- * <p>
- * {@inheritDoc}
- * </p>
- *
- * @see org.xml.sax.ext.DefaultHandler2#endEntity(java.lang.String)
- */
- @Override
- public void endEntity( String name ) throws SAXException {
- stopIfCancelled();
- entity = null;
- updateProgress();
- }
+ /**
+ * <p>
+ * {@inheritDoc}
+ * </p>
+ *
+ * @see org.xml.sax.ext.DefaultHandler2#endEntity(java.lang.String)
+ */
+ @Override
+ public void endEntity( String name ) throws SAXException {
+ stopIfCancelled();
+ entity = null;
+ updateProgress();
+ }
- /**
- * <p>
- * {@inheritDoc}
- * </p>
- *
- * @see org.xml.sax.helpers.DefaultHandler#error(org.xml.sax.SAXParseException)
- */
- @Override
- public void error( SAXParseException error ) throws SAXException {
- LOGGER.error(error, RepositoryI18n.errorSequencingXmlDocument);
- }
+ /**
+ * <p>
+ * {@inheritDoc}
+ * </p>
+ *
+ * @see org.xml.sax.helpers.DefaultHandler#error(org.xml.sax.SAXParseException)
+ */
+ @Override
+ public void error( SAXParseException error ) {
+ LOGGER.error(error, RepositoryI18n.errorSequencingXmlDocument);
+ }
- /**
- * <p>
- * {@inheritDoc}
- * </p>
- *
- * @see org.xml.sax.ext.DefaultHandler2#externalEntityDecl(java.lang.String, java.lang.String, java.lang.String)
- */
- @Override
- public void externalEntityDecl( String name,
- String publicId,
- String systemId ) throws SAXException {
- stopIfCancelled();
- // Add "synthetic" entity container to path to help prevent name collisions with XML elements
- Name entityName = nameFactory.create(ENTITY);
- startElement(entityName);
- output.setProperty(path, getPrimaryTypeName(), entityName);
- output.setProperty(path, nameFactory.create(DTD_NAME), name);
- output.setProperty(path, nameFactory.create(DTD_PUBLIC_ID), publicId);
- output.setProperty(path, nameFactory.create(DTD_SYSTEM_ID), systemId);
- endElement();
- updateProgress();
- }
+ /**
+ * <p>
+ * {@inheritDoc}
+ * </p>
+ *
+ * @see org.xml.sax.ext.DefaultHandler2#externalEntityDecl(java.lang.String, java.lang.String, java.lang.String)
+ */
+ @Override
+ public void externalEntityDecl( String name,
+ String publicId,
+ String systemId ) throws SAXException {
+ stopIfCancelled();
+ // Add "synthetic" entity container to path to help prevent name collisions with XML elements
+ Name entityName = nameFactory.create(ENTITY);
+ startElement(entityName);
+ output.setProperty(path, getPrimaryTypeName(), entityName);
+ output.setProperty(path, nameFactory.create(DTD_NAME), name);
+ output.setProperty(path, nameFactory.create(DTD_PUBLIC_ID), publicId);
+ output.setProperty(path, nameFactory.create(DTD_SYSTEM_ID), systemId);
+ endElement();
+ updateProgress();
+ }
- /**
- * <p>
- * {@inheritDoc}
- * </p>
- *
- * @see org.xml.sax.helpers.DefaultHandler#fatalError(org.xml.sax.SAXParseException)
- */
- @Override
- public void fatalError( SAXParseException error ) throws SAXException {
- LOGGER.error(error, RepositoryI18n.errorSequencingXmlDocument);
- }
+ /**
+ * <p>
+ * {@inheritDoc}
+ * </p>
+ *
+ * @see org.xml.sax.helpers.DefaultHandler#fatalError(org.xml.sax.SAXParseException)
+ */
+ @Override
+ public void fatalError( SAXParseException error ) {
+ LOGGER.error(error, RepositoryI18n.errorSequencingXmlDocument);
+ }
- private Name getCommentContentName() {
- if (commentContentName == null) {
- commentContentName = nameFactory.create(COMMENT_CONTENT);
- }
- return commentContentName;
- }
+ private Name getCommentContentName() {
+ if (commentContentName == null) {
+ commentContentName = nameFactory.create(COMMENT_CONTENT);
+ }
+ return commentContentName;
+ }
- private Name getCommentName() {
- if (commentName == null) {
- commentName = nameFactory.create(COMMENT);
- }
- return commentName;
- }
+ private Name getCommentName() {
+ if (commentName == null) {
+ commentName = nameFactory.create(COMMENT);
+ }
+ return commentName;
+ }
- private Name getElementContentName() {
- if (elementContentName == null) {
- elementContentName = nameFactory.create(ELEMENT_CONTENT);
- }
- return elementContentName;
- }
+ private Name getElementContentName() {
+ if (elementContentName == null) {
+ elementContentName = nameFactory.create(ELEMENT_CONTENT);
+ }
+ return elementContentName;
+ }
- private Name getPrimaryTypeName() {
- if (primaryTypeName == null) {
- primaryTypeName = nameFactory.create(NameFactory.JCR_PRIMARY_TYPE);
- }
- return primaryTypeName;
- }
+ private Name getPrimaryTypeName() {
+ if (primaryTypeName == null) {
+ primaryTypeName = nameFactory.create(NameFactory.JCR_PRIMARY_TYPE);
+ }
+ return primaryTypeName;
+ }
- private Name getTargetName() {
- if (targetName == null) {
- targetName = nameFactory.create(TARGET);
- }
- return targetName;
- }
+ private Name getTargetName() {
+ if (targetName == null) {
+ targetName = nameFactory.create(TARGET);
+ }
+ return targetName;
+ }
- /**
- * <p>
- * {@inheritDoc}
- * </p>
- *
- * @see org.xml.sax.helpers.DefaultHandler#ignorableWhitespace(char[], int, int)
- */
- @Override
- public void ignorableWhitespace( char[] ch,
- int start,
- int length ) throws SAXException {
- stopIfCancelled();
- }
+ /**
+ * <p>
+ * {@inheritDoc}
+ * </p>
+ *
+ * @see org.xml.sax.helpers.DefaultHandler#ignorableWhitespace(char[], int, int)
+ */
+ @Override
+ public void ignorableWhitespace( char[] ch,
+ int start,
+ int length ) throws SAXException {
+ stopIfCancelled();
+ }
- /**
- * <p>
- * {@inheritDoc}
- * </p>
- *
- * @see org.xml.sax.ext.DefaultHandler2#internalEntityDecl(java.lang.String, java.lang.String)
- */
- @Override
- public void internalEntityDecl( String name,
- String value ) throws SAXException {
- stopIfCancelled();
- // Add "synthetic" entity container to path to help prevent name collisions with XML elements
- Name entityName = nameFactory.create(ENTITY);
- startElement(entityName);
- output.setProperty(path, getPrimaryTypeName(), entityName);
- output.setProperty(path, nameFactory.create(DTD_NAME), name);
- output.setProperty(path, nameFactory.create(DTD_VALUE), value);
- endElement();
- updateProgress();
- }
+ /**
+ * <p>
+ * {@inheritDoc}
+ * </p>
+ *
+ * @see org.xml.sax.ext.DefaultHandler2#internalEntityDecl(java.lang.String, java.lang.String)
+ */
+ @Override
+ public void internalEntityDecl( String name,
+ String value ) throws SAXException {
+ stopIfCancelled();
+ // Add "synthetic" entity container to path to help prevent name collisions with XML elements
+ Name entityName = nameFactory.create(ENTITY);
+ startElement(entityName);
+ output.setProperty(path, getPrimaryTypeName(), entityName);
+ output.setProperty(path, nameFactory.create(DTD_NAME), name);
+ output.setProperty(path, nameFactory.create(DTD_VALUE), value);
+ endElement();
+ updateProgress();
+ }
- /**
- * <p>
- * {@inheritDoc}
- * </p>
- *
- * @see org.xml.sax.helpers.DefaultHandler#notationDecl(java.lang.String, java.lang.String, java.lang.String)
- */
- @Override
- public void notationDecl( String name,
- String publicId,
- String systemId ) throws SAXException {
- stopIfCancelled();
- }
+ /**
+ * <p>
+ * {@inheritDoc}
+ * </p>
+ *
+ * @see org.xml.sax.helpers.DefaultHandler#notationDecl(java.lang.String, java.lang.String, java.lang.String)
+ */
+ @Override
+ public void notationDecl( String name,
+ String publicId,
+ String systemId ) throws SAXException {
+ stopIfCancelled();
+ }
- /**
- * <p>
- * {@inheritDoc}
- * </p>
- *
- * @see org.xml.sax.helpers.DefaultHandler#processingInstruction(java.lang.String, java.lang.String)
- */
- @Override
- public void processingInstruction( String target,
- String data ) throws SAXException {
- stopIfCancelled();
- // Output separate nodes for each instruction since multiple are allowed
- Name name = nameFactory.create(PI);
- startElement(name);
- output.setProperty(path, getPrimaryTypeName(), name);
- output.setProperty(path, getTargetName(), target);
- output.setProperty(path, nameFactory.create(PI_CONTENT), data);
- endElement();
- updateProgress();
- }
+ /**
+ * <p>
+ * {@inheritDoc}
+ * </p>
+ *
+ * @see org.xml.sax.helpers.DefaultHandler#processingInstruction(java.lang.String, java.lang.String)
+ */
+ @Override
+ public void processingInstruction( String target,
+ String data ) throws SAXException {
+ stopIfCancelled();
+ // Output separate nodes for each instruction since multiple are allowed
+ Name name = nameFactory.create(PI);
+ startElement(name);
+ output.setProperty(path, getPrimaryTypeName(), name);
+ output.setProperty(path, getTargetName(), target);
+ output.setProperty(path, nameFactory.create(PI_CONTENT), data);
+ endElement();
+ updateProgress();
+ }
- /**
- * <p>
- * {@inheritDoc}
- * </p>
- *
- * @see org.xml.sax.helpers.DefaultHandler#skippedEntity(java.lang.String)
- */
- @Override
- public void skippedEntity( String name ) throws SAXException {
- stopIfCancelled();
- }
+ /**
+ * <p>
+ * {@inheritDoc}
+ * </p>
+ *
+ * @see org.xml.sax.helpers.DefaultHandler#skippedEntity(java.lang.String)
+ */
+ @Override
+ public void skippedEntity( String name ) throws SAXException {
+ stopIfCancelled();
+ }
- /**
- * <p>
- * {@inheritDoc}
- * </p>
- *
- * @see org.xml.sax.ext.DefaultHandler2#startCDATA()
- */
- @Override
- public void startCDATA() throws SAXException {
- stopIfCancelled();
- // Output separate nodes for each CDATA since multiple are allowed
- startElement(nameFactory.create(CDATA));
- // Prepare builder for concatenating consecutive lines of CDATA
- cDataBuilder = new StringBuilder();
- updateProgress();
- }
+ /**
+ * <p>
+ * {@inheritDoc}
+ * </p>
+ *
+ * @see org.xml.sax.ext.DefaultHandler2#startCDATA()
+ */
+ @Override
+ public void startCDATA() throws SAXException {
+ stopIfCancelled();
+ // Output separate nodes for each CDATA since multiple are allowed
+ startElement(nameFactory.create(CDATA));
+ // Prepare builder for concatenating consecutive lines of CDATA
+ cDataBuilder = new StringBuilder();
+ updateProgress();
+ }
- /**
- * <p>
- * {@inheritDoc}
- * </p>
- *
- * @see org.xml.sax.helpers.DefaultHandler#startDocument()
- */
- @Override
- public void startDocument() throws SAXException {
- stopIfCancelled();
- output.setProperty(path, getPrimaryTypeName(), nameFactory.create(DOCUMENT));
- updateProgress();
- }
+ /**
+ * <p>
+ * {@inheritDoc}
+ * </p>
+ *
+ * @see org.xml.sax.helpers.DefaultHandler#startDocument()
+ */
+ @Override
+ public void startDocument() throws SAXException {
+ stopIfCancelled();
+ output.setProperty(path, getPrimaryTypeName(), nameFactory.create(DOCUMENT));
+ updateProgress();
+ }
- /**
- * <p>
- * {@inheritDoc}
- * </p>
- *
- * @see org.xml.sax.ext.DefaultHandler2#startDTD(java.lang.String, java.lang.String, java.lang.String)
- */
- @Override
- public void startDTD( String name,
- String publicId,
- String systemId ) throws SAXException {
- stopIfCancelled();
- output.setProperty(path, nameFactory.create(DTD_NAME), name);
- output.setProperty(path, nameFactory.create(DTD_PUBLIC_ID), publicId);
- output.setProperty(path, nameFactory.create(DTD_SYSTEM_ID), systemId);
- updateProgress();
- }
+ /**
+ * <p>
+ * {@inheritDoc}
+ * </p>
+ *
+ * @see org.xml.sax.ext.DefaultHandler2#startDTD(java.lang.String, java.lang.String, java.lang.String)
+ */
+ @Override
+ public void startDTD( String name,
+ String publicId,
+ String systemId ) throws SAXException {
+ stopIfCancelled();
+ output.setProperty(path, nameFactory.create(DTD_NAME), name);
+ output.setProperty(path, nameFactory.create(DTD_PUBLIC_ID), publicId);
+ output.setProperty(path, nameFactory.create(DTD_SYSTEM_ID), systemId);
+ updateProgress();
+ }
- private void startElement( Name name ) {
- // Check if content still needs to be output
- endContent();
- // Add name to list of indexed names for this element to ensure we use the correct index (which is the size of the
- // list)
- List<IndexedName> indexedNames = nameToIndexedNamesMap.get(name);
- if (indexedNames == null) {
- indexedNames = new ArrayList<IndexedName>();
- nameToIndexedNamesMap.put(name, indexedNames);
- }
- IndexedName indexedName = new IndexedName();
- indexedNames.add(indexedName);
- // Add element name and the appropriate index to the path.
- // Per the JCR spec, the index must be relative to same-name sibling nodes
- path = output.getFactories().getPathFactory().create(path, name, indexedNames.size());
- // Add the indexed name map to the stack and set the current map to the new element's map
- nameToIndexedNamesMapStack.addFirst(nameToIndexedNamesMap);
- nameToIndexedNamesMap = indexedName.nameToIndexedNamesMap;
- // Set the current namespace to whatever is declared by this element, or if not declared, to its nearest ancestor that
- // does declare a namespace.
- String ns = name.getNamespaceUri();
- if (ns.length() == 0) {
- nsStack.addFirst(nsStack.isEmpty() ? "" : nsStack.getFirst());
- } else {
- nsStack.addFirst(ns);
- }
- }
+ private void startElement( Name name ) {
+ // Check if content still needs to be output
+ endContent();
+ // Add name to list of indexed names for this element to ensure we use the correct index (which is the size of the
+ // list)
+ List<IndexedName> indexedNames = nameToIndexedNamesMap.get(name);
+ if (indexedNames == null) {
+ indexedNames = new ArrayList<IndexedName>();
+ nameToIndexedNamesMap.put(name, indexedNames);
+ }
+ IndexedName indexedName = new IndexedName();
+ indexedNames.add(indexedName);
+ // Add element name and the appropriate index to the path.
+ // Per the JCR spec, the index must be relative to same-name sibling nodes
+ path = output.getFactories().getPathFactory().create(path, name, indexedNames.size());
+ // Add the indexed name map to the stack and set the current map to the new element's map
+ nameToIndexedNamesMapStack.addFirst(nameToIndexedNamesMap);
+ nameToIndexedNamesMap = indexedName.nameToIndexedNamesMap;
+ // Set the current namespace to whatever is declared by this element, or if not declared, to its nearest ancestor that
+ // does declare a namespace.
+ String ns = name.getNamespaceUri();
+ if (ns.length() == 0) {
+ nsStack.addFirst(nsStack.isEmpty() ? "" : nsStack.getFirst());
+ } else {
+ nsStack.addFirst(ns);
+ }
+ }
- /**
- * <p>
- * {@inheritDoc}
- * </p>
- *
- * @see org.xml.sax.helpers.DefaultHandler#startElement(java.lang.String, java.lang.String, java.lang.String,
- * org.xml.sax.Attributes)
- */
- @Override
- public void startElement( String uri,
- String localName,
- String name,
- Attributes attributes ) throws SAXException {
- stopIfCancelled();
- startElement(nameFactory.create(name));
- output.setProperty(path, getPrimaryTypeName(), nameFactory.create(uri, localName));
- // Output this element's attributes using the attribute's namespace, if supplied, or the current namespace in scope.
- String inheritedNs = nsStack.getFirst();
- for (int ndx = 0, len = attributes.getLength(); ndx < len; ++ndx) {
- String ns = attributes.getURI(ndx);
- output.setProperty(path,
- nameFactory.create(ns.length() == 0 ? inheritedNs : ns, attributes.getLocalName(ndx)),
- attributes.getValue(ndx));
- }
- updateProgress();
- }
+ /**
+ * <p>
+ * {@inheritDoc}
+ * </p>
+ *
+ * @see org.xml.sax.helpers.DefaultHandler#startElement(java.lang.String, java.lang.String, java.lang.String,
+ * org.xml.sax.Attributes)
+ */
+ @Override
+ public void startElement( String uri,
+ String localName,
+ String name,
+ Attributes attributes ) throws SAXException {
+ stopIfCancelled();
+ startElement(nameFactory.create(name));
+ output.setProperty(path, getPrimaryTypeName(), nameFactory.create(uri, localName));
+ // Output this element's attributes using the attribute's namespace, if supplied, or the current namespace in scope.
+ String inheritedNs = nsStack.getFirst();
+ for (int ndx = 0, len = attributes.getLength(); ndx < len; ++ndx) {
+ String ns = attributes.getURI(ndx);
+ output.setProperty(path,
+ nameFactory.create(ns.length() == 0 ? inheritedNs : ns, attributes.getLocalName(ndx)),
+ attributes.getValue(ndx));
+ }
+ updateProgress();
+ }
- /**
- * <p>
- * {@inheritDoc}
- * </p>
- *
- * @see org.xml.sax.ext.DefaultHandler2#startEntity(java.lang.String)
- */
- @Override
- public void startEntity( String name ) throws SAXException {
- stopIfCancelled();
- entity = name;
- updateProgress();
- }
+ /**
+ * <p>
+ * {@inheritDoc}
+ * </p>
+ *
+ * @see org.xml.sax.ext.DefaultHandler2#startEntity(java.lang.String)
+ */
+ @Override
+ public void startEntity( String name ) throws SAXException {
+ stopIfCancelled();
+ entity = name;
+ updateProgress();
+ }
- /**
- * <p>
- * {@inheritDoc}
- * </p>
- *
- * @see org.xml.sax.helpers.DefaultHandler#startPrefixMapping(java.lang.String, java.lang.String)
- */
- @Override
- public void startPrefixMapping( String prefix,
- String uri ) throws SAXException {
- stopIfCancelled();
- // Register any unregistered namespaces
- NamespaceRegistry registry = output.getNamespaceRegistry();
- if (!registry.isRegisteredNamespaceUri(uri)) {
- registry.register(prefix, uri);
- }
- updateProgress();
- }
+ /**
+ * <p>
+ * {@inheritDoc}
+ * </p>
+ *
+ * @see org.xml.sax.helpers.DefaultHandler#startPrefixMapping(java.lang.String, java.lang.String)
+ */
+ @Override
+ public void startPrefixMapping( String prefix,
+ String uri ) throws SAXException {
+ stopIfCancelled();
+ // Register any unregistered namespaces
+ NamespaceRegistry registry = output.getNamespaceRegistry();
+ if (!registry.isRegisteredNamespaceUri(uri)) {
+ registry.register(prefix, uri);
+ }
+ updateProgress();
+ }
- private void stopIfCancelled() throws SAXException {
- if (monitor.isCancelled()) {
- throw new SAXException(RepositoryI18n.canceledSequencingXmlDocument.text());
- }
- }
+ private void stopIfCancelled() throws SAXException {
+ if (monitor.isCancelled()) {
+ throw new SAXException(RepositoryI18n.canceledSequencingXmlDocument.text());
+ }
+ }
- /**
- * <p>
- * {@inheritDoc}
- * </p>
- *
- * @see org.xml.sax.helpers.DefaultHandler#unparsedEntityDecl(java.lang.String, java.lang.String, java.lang.String,
- * java.lang.String)
- */
- @Override
- public void unparsedEntityDecl( String name,
- String publicId,
- String systemId,
- String notationName ) throws SAXException {
- stopIfCancelled();
- }
+ /**
+ * <p>
+ * {@inheritDoc}
+ * </p>
+ *
+ * @see org.xml.sax.helpers.DefaultHandler#unparsedEntityDecl(java.lang.String, java.lang.String, java.lang.String,
+ * java.lang.String)
+ */
+ @Override
+ public void unparsedEntityDecl( String name,
+ String publicId,
+ String systemId,
+ String notationName ) throws SAXException {
+ stopIfCancelled();
+ }
- private void updateProgress() {
- if (progress == 100.0) {
- progress = 1;
- } else {
- progress++;
- }
- monitor.worked(progress);
- }
+ private void updateProgress() {
+ if (progress == 100.0) {
+ progress = 1;
+ } else {
+ progress++;
+ }
+ monitor.worked(progress);
+ }
- /**
- * <p>
- * {@inheritDoc}
- * </p>
- *
- * @see org.xml.sax.helpers.DefaultHandler#warning(org.xml.sax.SAXParseException)
- */
- @Override
- public void warning( SAXParseException error ) throws SAXException {
- LOGGER.warn(error, RepositoryI18n.errorSequencingXmlDocument);
- }
- }
+ /**
+ * <p>
+ * {@inheritDoc}
+ * </p>
+ *
+ * @see org.xml.sax.helpers.DefaultHandler#warning(org.xml.sax.SAXParseException)
+ */
+ @Override
+ public void warning( SAXParseException error ) {
+ LOGGER.warn(error, RepositoryI18n.errorSequencingXmlDocument);
+ }
+ }
- private class IndexedName {
+ private class IndexedName {
- Map<Name, List<IndexedName>> nameToIndexedNamesMap = new HashMap<Name, List<IndexedName>>();
+ Map<Name, List<IndexedName>> nameToIndexedNamesMap = new HashMap<Name, List<IndexedName>>();
- IndexedName() {
- }
- }
+ IndexedName() {
+ }
+ }
}
Modified: branches/maeste/dna-repository/src/main/java/org/jboss/dna/repository/services/AbstractServiceAdministrator.java
===================================================================
--- branches/maeste/dna-repository/src/main/java/org/jboss/dna/repository/services/AbstractServiceAdministrator.java 2008-06-11 08:35:21 UTC (rev 264)
+++ branches/maeste/dna-repository/src/main/java/org/jboss/dna/repository/services/AbstractServiceAdministrator.java 2008-06-11 08:45:51 UTC (rev 265)
@@ -30,6 +30,7 @@
/**
* Simple abstract implementation of the service administrator interface that can be easily subclassed by services that require an
* administrative interface.
+ *
* @author Randall Hauch
*/
@ThreadSafe
@@ -47,6 +48,7 @@
/**
* Return the current state of this service.
+ *
* @return the current state
*/
public State getState() {
@@ -55,6 +57,7 @@
/**
* Set the state of the service. This method does nothing if the desired state matches the current state.
+ *
* @param state the desired state
* @return this object for method chaining purposes
* @see #setState(String)
@@ -72,6 +75,7 @@
pause();
break;
case SHUTDOWN:
+ case TERMINATED:
shutdown();
break;
}
@@ -80,6 +84,7 @@
/**
* Set the state of the service. This method does nothing if the desired state matches the current state.
+ *
* @param state the desired state in string form
* @return this object for method chaining purposes
* @throws IllegalArgumentException if the specified state string is null or does not match one of the predefined
@@ -100,6 +105,7 @@
/**
* Start monitoring and sequence the events. This method can be called multiple times, including after the service is
* {@link #pause() paused}. However, once the service is {@link #shutdown() shutdown}, it cannot be started or paused.
+ *
* @return this object for method chaining purposes
* @throws IllegalStateException if called when the service has been {@link #shutdown() shutdown}.
* @see #pause()
@@ -107,10 +113,16 @@
* @see #isStarted()
*/
public synchronized ServiceAdministrator start() {
- if (isShutdown()) throw new IllegalStateException(RepositoryI18n.serviceShutdowAndMayNotBeStarted.text(getServiceName()));
- if (this.state != State.STARTED) {
- doStart(this.state);
- this.state = State.STARTED;
+ switch (this.state) {
+ case STARTED:
+ break;
+ case PAUSED:
+ doStart(this.state);
+ this.state = State.STARTED;
+ break;
+ case SHUTDOWN:
+ case TERMINATED:
+ throw new IllegalStateException(RepositoryI18n.serviceShutdowAndMayNotBeStarted.text(getServiceName()));
}
return this;
}
@@ -119,6 +131,7 @@
* Implementation of the functionality to switch to the started state. This method is only called if the state from which the
* service is transitioning is appropriate ({@link State#PAUSED}). This method does nothing by default, and should be
* overridden if needed.
+ *
* @param fromState the state from which this service is transitioning; never null
* @throws IllegalStateException if the service is such that it cannot be transitioned from the supplied state
*/
@@ -129,6 +142,7 @@
/**
* Temporarily stop monitoring and sequencing events. This method can be called multiple times, including after the service is
* {@link #start() started}. However, once the service is {@link #shutdown() shutdown}, it cannot be started or paused.
+ *
* @return this object for method chaining purposes
* @throws IllegalStateException if called when the service has been {@link #shutdown() shutdown}.
* @see #start()
@@ -136,10 +150,16 @@
* @see #isPaused()
*/
public synchronized ServiceAdministrator pause() {
- if (isShutdown()) throw new IllegalStateException(RepositoryI18n.serviceShutdowAndMayNotBePaused.text(getServiceName()));
- if (this.state != State.PAUSED) {
- doPause(this.state);
- this.state = State.PAUSED;
+ switch (this.state) {
+ case STARTED:
+ doPause(this.state);
+ this.state = State.PAUSED;
+ break;
+ case PAUSED:
+ break;
+ case SHUTDOWN:
+ case TERMINATED:
+ throw new IllegalStateException(RepositoryI18n.serviceShutdowAndMayNotBePaused.text(getServiceName()));
}
return this;
}
@@ -148,6 +168,7 @@
* Implementation of the functionality to switch to the paused state. This method is only called if the state from which the
* service is transitioning is appropriate ({@link State#STARTED}). This method does nothing by default, and should be
* overridden if needed.
+ *
* @param fromState the state from which this service is transitioning; never null
* @throws IllegalStateException if the service is such that it cannot be transitioned from the supplied state
*/
@@ -158,15 +179,24 @@
/**
* Permanently stop monitoring and sequencing events. This method can be called multiple times, but only the first call has an
* effect. Once the service has been shutdown, it may not be {@link #start() restarted} or {@link #pause() paused}.
+ *
* @return this object for method chaining purposes
* @see #start()
* @see #pause()
* @see #isShutdown()
*/
public synchronized ServiceAdministrator shutdown() {
- if (this.state != State.SHUTDOWN) {
- doShutdown(this.state);
- this.state = State.SHUTDOWN;
+ switch (this.state) {
+ case STARTED:
+ case PAUSED:
+ this.state = State.SHUTDOWN;
+ doShutdown(this.state);
+ isTerminated();
+ break;
+ case SHUTDOWN:
+ case TERMINATED:
+ isTerminated();
+ break;
}
return this;
}
@@ -175,6 +205,7 @@
* Implementation of the functionality to switch to the shutdown state. This method is only called if the state from which the
* service is transitioning is appropriate ({@link State#STARTED} or {@link State#PAUSED}). This method does nothing by
* default, and should be overridden if needed.
+ *
* @param fromState the state from which this service is transitioning; never null
* @throws IllegalStateException if the service is such that it cannot be transitioned from the supplied state
*/
@@ -184,6 +215,7 @@
/**
* Return whether this service has been started and is currently running.
+ *
* @return true if started and currently running, or false otherwise
* @see #start()
* @see #pause()
@@ -196,6 +228,7 @@
/**
* Return whether this service is currently paused.
+ *
* @return true if currently paused, or false otherwise
* @see #pause()
* @see #start()
@@ -208,17 +241,45 @@
/**
* Return whether this service is stopped and unable to be restarted.
+ *
* @return true if currently shutdown, or false otherwise
* @see #shutdown()
* @see #isPaused()
* @see #isStarted()
*/
public boolean isShutdown() {
- return this.state == State.SHUTDOWN;
+ return this.state == State.SHUTDOWN || this.state == State.TERMINATED;
}
/**
+ * {@inheritDoc}
+ */
+ public boolean isTerminated() {
+ switch (this.state) {
+ case PAUSED:
+ case STARTED:
+ case SHUTDOWN:
+ if (doCheckIsTerminated()) {
+ this.state = State.TERMINATED;
+ return true;
+ }
+ return false;
+ case TERMINATED:
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Subclasses should implement this method to determine whether the service has completed shutdown.
+ *
+ * @return true if terminated, or false otherwise
+ */
+ protected abstract boolean doCheckIsTerminated();
+
+ /**
* Get the name of this service in the current locale.
+ *
* @return the service name
*/
public String getServiceName() {
@@ -227,10 +288,12 @@
/**
* Get the name of this service in the specified locale.
+ *
* @param locale the locale in which the service name is to be returned; may be null if the default locale is to be used
* @return the service name
*/
public String getServiceName( Locale locale ) {
return this.serviceName.text(locale);
}
+
}
Modified: branches/maeste/dna-repository/src/main/java/org/jboss/dna/repository/services/ServiceAdministrator.java
===================================================================
--- branches/maeste/dna-repository/src/main/java/org/jboss/dna/repository/services/ServiceAdministrator.java 2008-06-11 08:35:21 UTC (rev 264)
+++ branches/maeste/dna-repository/src/main/java/org/jboss/dna/repository/services/ServiceAdministrator.java 2008-06-11 08:45:51 UTC (rev 265)
@@ -26,6 +26,7 @@
/**
* Contract defining an administrative interface for controlling the running state of a service.
+ *
* @author Randall Hauch
*/
@ThreadSafe
@@ -33,22 +34,26 @@
/**
* The available states.
+ *
* @author Randall Hauch
*/
public static enum State {
STARTED,
PAUSED,
- SHUTDOWN;
+ SHUTDOWN,
+ TERMINATED;
}
/**
* Return the current state of this system.
+ *
* @return the current state
*/
public State getState();
/**
* Set the state of the system. This method does nothing if the desired state matches the current state.
+ *
* @param state the desired state
* @return this object for method chaining purposes
* @see #setState(String)
@@ -60,6 +65,7 @@
/**
* Set the state of the system. This method does nothing if the desired state matches the current state.
+ *
* @param state the desired state in string form
* @return this object for method chaining purposes
* @throws IllegalArgumentException if the specified state string is null or does not match one of the predefined
@@ -74,6 +80,7 @@
/**
* Start monitoring and sequence the events. This method can be called multiple times, including after the system is
* {@link #pause() paused}. However, once the system is {@link #shutdown() shutdown}, it cannot be started or paused.
+ *
* @return this object for method chaining purposes
* @throws IllegalStateException if called when the system has been {@link #shutdown() shutdown}.
* @see #pause()
@@ -85,6 +92,7 @@
/**
* Temporarily stop monitoring and sequencing events. This method can be called multiple times, including after the system is
* {@link #start() started}. However, once the system is {@link #shutdown() shutdown}, it cannot be started or paused.
+ *
* @return this object for method chaining purposes
* @throws IllegalStateException if called when the system has been {@link #shutdown() shutdown}.
* @see #start()
@@ -96,6 +104,7 @@
/**
* Permanently stop monitoring and sequencing events. This method can be called multiple times, but only the first call has an
* effect. Once the system has been shutdown, it may not be {@link #start() restarted} or {@link #pause() paused}.
+ *
* @return this object for method chaining purposes
* @see #start()
* @see #pause()
@@ -104,41 +113,62 @@
public ServiceAdministrator shutdown();
/**
- * Blocks until all work has completed execution after a shutdown request, or the timeout occurs, or the current thread is
- * interrupted, whichever happens first.
+ * Blocks until the shutdown has completed, or the timeout occurs, or the current thread is interrupted, whichever happens
+ * first.
+ *
* @param timeout the maximum time to wait
* @param unit the time unit of the timeout argument
- * @return <tt>true</tt> if this service terminated and <tt>false</tt> if the timeout elapsed before termination
+ * @return <tt>true</tt> if this service complete shut down and <tt>false</tt> if the timeout elapsed before it was shut
+ * down completely
* @throws InterruptedException if interrupted while waiting
*/
boolean awaitTermination( long timeout, TimeUnit unit ) throws InterruptedException;
/**
* Return whether this system has been started and is currently running.
+ *
* @return true if started and currently running, or false otherwise
* @see #start()
* @see #pause()
* @see #isPaused()
* @see #isShutdown()
+ * @see #isTerminated()
*/
public boolean isStarted();
/**
* Return whether this system is currently paused.
+ *
* @return true if currently paused, or false otherwise
* @see #pause()
* @see #start()
* @see #isStarted()
* @see #isShutdown()
+ * @see #isTerminated()
*/
public boolean isPaused();
/**
- * Return whether this system is stopped and unable to be restarted.
- * @return true if currently shutdown, or false otherwise
+ * Return whether this system has been shut down.
+ *
+ * @return true if this service has been shut down, or false otherwise
* @see #shutdown()
* @see #isPaused()
* @see #isStarted()
+ * @see #isTerminated()
*/
public boolean isShutdown();
+
+ /**
+ * Return whether this system has finished {@link #shutdown() shutting down}. Note that <code>isTerminated</code> is never
+ * <code>true</code> unless either {@link #shutdown()} was called first.
+ *
+ * @return true if the system has finished shutting down, or false otherwise
+ * @see #shutdown()
+ * @see #isPaused()
+ * @see #isStarted()
+ * @see #isShutdown()
+ */
+ public boolean isTerminated();
+
}
Modified: branches/maeste/dna-repository/src/main/java/org/jboss/dna/repository/util/SimpleSessionFactory.java
===================================================================
--- branches/maeste/dna-repository/src/main/java/org/jboss/dna/repository/util/SimpleSessionFactory.java 2008-06-11 08:35:21 UTC (rev 264)
+++ branches/maeste/dna-repository/src/main/java/org/jboss/dna/repository/util/SimpleSessionFactory.java 2008-06-11 08:45:51 UTC (rev 265)
@@ -51,6 +51,7 @@
* {@link #registerCredentials(String, Credentials) register} credentials for the appropriate repository/workspace name. For
* security reasons, it is not possible to retrieve the Credentials once registered with this factory.
* </p>
+ *
* @author Randall Hauch
*/
public class SimpleSessionFactory extends AbstractSessionFactory {
@@ -67,6 +68,7 @@
/**
* Create an instance of the factory by supplying the characters that may be used to delimit the workspace name from the
* repository name.
+ *
* @param workspaceDelimiters the delimiters, or null/empty if the default delimiter of '/' should be used.
*/
public SimpleSessionFactory( char... workspaceDelimiters ) {
@@ -77,7 +79,8 @@
* {@inheritDoc}
*/
@Override
- protected void doRegisterRepository( String name, Repository repository ) throws SystemFailureException {
+ protected void doRegisterRepository( String name,
+ Repository repository ) {
this.repositories.put(name, repository);
}
Modified: branches/maeste/dna-repository/src/main/resources/org/jboss/dna/repository/RepositoryI18n.properties
===================================================================
--- branches/maeste/dna-repository/src/main/resources/org/jboss/dna/repository/RepositoryI18n.properties 2008-06-11 08:35:21 UTC (rev 264)
+++ branches/maeste/dna-repository/src/main/resources/org/jboss/dna/repository/RepositoryI18n.properties 2008-06-11 08:45:51 UTC (rev 265)
@@ -22,6 +22,7 @@
invalidStateString = Invalid state parameter "{0}"
serviceShutdowAndMayNotBeStarted = The {0} has been shutdown and may not be (re)started
serviceShutdowAndMayNotBePaused = The {0} has been shutdown and my not be paused
+serviceNotShutdowAndMayNotBeTerminated = The {0} has not been shutdown and may not be terminated
unableToFindRepositoryInJndi = Unable to find a JCR repository in JNDI at "{0}"
unableToRegisterRepositoryInJndi = Unable to register a JCR repository in JNDI at "{0}"
unableToUnregisterRepositoryInJndi = Unable to unregister a JCR repository at JNDI at "{0}"
Modified: branches/maeste/dna-repository/src/test/java/org/jboss/dna/repository/RepositoryI18nTest.java
===================================================================
--- branches/maeste/dna-repository/src/test/java/org/jboss/dna/repository/RepositoryI18nTest.java 2008-06-11 08:35:21 UTC (rev 264)
+++ branches/maeste/dna-repository/src/test/java/org/jboss/dna/repository/RepositoryI18nTest.java 2008-06-11 08:45:51 UTC (rev 265)
@@ -1,3 +1,24 @@
+/*
+ * 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.repository;
import org.jboss.dna.common.AbstractI18nTest;
@@ -7,7 +28,7 @@
*/
public class RepositoryI18nTest extends AbstractI18nTest {
- public RepositoryI18nTest() {
- super(RepositoryI18n.class);
- }
+ public RepositoryI18nTest() {
+ super(RepositoryI18n.class);
+ }
}
Modified: branches/maeste/dna-repository/src/test/java/org/jboss/dna/repository/federation/FederatedRepositoryConnectionTest.java
===================================================================
--- branches/maeste/dna-repository/src/test/java/org/jboss/dna/repository/federation/FederatedRepositoryConnectionTest.java 2008-06-11 08:35:21 UTC (rev 264)
+++ branches/maeste/dna-repository/src/test/java/org/jboss/dna/repository/federation/FederatedRepositoryConnectionTest.java 2008-06-11 08:45:51 UTC (rev 265)
@@ -38,6 +38,8 @@
import org.jboss.dna.spi.graph.connection.RepositorySourceListener;
import org.junit.Before;
import org.junit.Test;
+import org.mockito.MockitoAnnotations;
+import org.mockito.MockitoAnnotations.Mock;
/**
* @author Randall Hauch
@@ -45,21 +47,22 @@
public class FederatedRepositoryConnectionTest {
private FederatedRepositoryConnection connection;
+ private String sourceName;
+ @Mock
private FederatedRepositorySource source;
+ @Mock
private FederatedRepository repository;
- private String sourceName;
+ @Mock
private CachePolicy defaultCachePolicy;
+ @Mock
private ServiceAdministrator repositoryAdmin;
@Before
- public void beforeEach() throws Exception {
+ public void beforeEach() {
+ MockitoAnnotations.initMocks(this);
sourceName = "Source X";
- source = mock(FederatedRepositorySource.class);
stub(source.getName()).toReturn(sourceName);
- repository = mock(FederatedRepository.class);
- defaultCachePolicy = mock(CachePolicy.class);
stub(repository.getDefaultCachePolicy()).toReturn(defaultCachePolicy);
- repositoryAdmin = mock(ServiceAdministrator.class);
stub(repository.getAdministrator()).toReturn(repositoryAdmin);
connection = new FederatedRepositoryConnection(repository, source);
}
@@ -105,6 +108,24 @@
}
@Test
+ public void shouldReturnImmediatelyWhenExecutingNullOrEmptyCommandArray() {
+ stub(repositoryAdmin.isStarted()).toReturn(true);
+ ExecutionEnvironment env = mock(ExecutionEnvironment.class);
+ connection.execute(env, (GraphCommand[])null);
+ verify(repositoryAdmin, times(1)).isStarted();
+ connection.execute(env, new GraphCommand[0]);
+ verify(repositoryAdmin, times(2)).isStarted();
+ }
+
+ @Test
+ public void shouldSkipNullCommandReferencesWhenExecuting() {
+ stub(repositoryAdmin.isStarted()).toReturn(true);
+ ExecutionEnvironment env = mock(ExecutionEnvironment.class);
+ connection.execute(env, new GraphCommand[] {null, null, null});
+ verify(repositoryAdmin, times(1)).isStarted();
+ }
+
+ @Test
public void shouldAddListenerToRepositoryWhenSetOnConnection() {
// Old listener is no-op, so it is not removed from repository ...
RepositorySourceListener listener = mock(RepositorySourceListener.class);
@@ -129,5 +150,4 @@
connection.close();
verify(repository, times(1)).removeListener(listener2);
}
-
}
Modified: branches/maeste/dna-repository/src/test/java/org/jboss/dna/repository/federation/FederatedRepositorySourceTest.java
===================================================================
--- branches/maeste/dna-repository/src/test/java/org/jboss/dna/repository/federation/FederatedRepositorySourceTest.java 2008-06-11 08:35:21 UTC (rev 264)
+++ branches/maeste/dna-repository/src/test/java/org/jboss/dna/repository/federation/FederatedRepositorySourceTest.java 2008-06-11 08:45:51 UTC (rev 265)
@@ -41,6 +41,8 @@
import org.jboss.dna.spi.graph.connection.RepositorySourceException;
import org.junit.Before;
import org.junit.Test;
+import org.mockito.MockitoAnnotations;
+import org.mockito.MockitoAnnotations.Mock;
/**
* @author Randall Hauch
@@ -49,7 +51,9 @@
private FederatedRepositorySource source;
private FederatedRepositoryConnection connection;
+ @Mock
private FederatedRepository repository;
+ @Mock
private FederationService service;
private String repositoryName;
private String username;
@@ -60,10 +64,9 @@
*/
@Before
public void beforeEach() throws Exception {
+ MockitoAnnotations.initMocks(this);
this.repositoryName = "Test Repository";
- this.service = mock(FederationService.class);
this.source = new FederatedRepositorySource(service, repositoryName);
- this.repository = mock(FederatedRepository.class);
this.username = "valid username";
this.credentials = "valid password";
this.source.setUsername(username);
Copied: branches/maeste/dna-repository/src/test/java/org/jboss/dna/repository/federation/FederatedRepositoryTest.java (from rev 263, trunk/dna-repository/src/test/java/org/jboss/dna/repository/federation/FederatedRepositoryTest.java)
===================================================================
--- branches/maeste/dna-repository/src/test/java/org/jboss/dna/repository/federation/FederatedRepositoryTest.java (rev 0)
+++ branches/maeste/dna-repository/src/test/java/org/jboss/dna/repository/federation/FederatedRepositoryTest.java 2008-06-11 08:45:51 UTC (rev 265)
@@ -0,0 +1,222 @@
+/*
+ * 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.repository.federation;
+
+import static org.hamcrest.core.Is.is;
+import static org.hamcrest.core.IsNull.notNullValue;
+import static org.hamcrest.core.IsSame.sameInstance;
+import static org.junit.Assert.assertThat;
+import static org.junit.matchers.JUnitMatchers.hasItems;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.stub;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import java.util.concurrent.TimeUnit;
+import org.jboss.dna.spi.graph.connection.RepositoryConnection;
+import org.jboss.dna.spi.graph.connection.RepositorySourceListener;
+import org.jboss.dna.spi.graph.connection.TimeDelayingRepositorySource;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.MockitoAnnotations;
+import org.mockito.MockitoAnnotations.Mock;
+
+/**
+ * @author Randall Hauch
+ */
+public class FederatedRepositoryTest {
+
+ private FederatedRepository repository;
+ private String name;
+ @Mock
+ private FederationService service;
+ @Mock
+ private RepositorySourceListener listener1;
+ @Mock
+ private RepositorySourceListener listener2;
+ @Mock
+ private FederatedSource source1;
+ @Mock
+ private FederatedSource source2;
+
+ // private RepositoryConnectionPool connectionPool;
+
+ @Before
+ public void beforeEach() {
+ MockitoAnnotations.initMocks(this);
+ name = "Test repository";
+ repository = new FederatedRepository(service, name);
+ stub(source1.getName()).toReturn("soure 1");
+ stub(source2.getName()).toReturn("soure 2");
+ }
+
+ @Test
+ public void shouldHaveNamePassedIntoConstructor() {
+ assertThat(repository.getName(), is(name));
+ }
+
+ @Test
+ public void shouldHaveFederationServicePassedIntoConstructor() {
+ assertThat(repository.getService(), is(sameInstance(service)));
+ }
+
+ @Test
+ public void shouldHaveAdministrator() {
+ assertThat(repository.getAdministrator(), is(notNullValue()));
+ }
+
+ @Test
+ public void shouldHaveNoListenersUponCreation() {
+ assertThat(repository.getListeners(), is(notNullValue()));
+ assertThat(repository.getListeners().isEmpty(), is(true));
+ }
+
+ @Test
+ public void shouldNotAddNullListener() {
+ assertThat(repository.addListener(null), is(false));
+ }
+
+ @Test
+ public void shouldNotAddListenerIfAlreadyInList() {
+ assertThat(repository.getListeners().size(), is(0));
+ assertThat(repository.addListener(listener1), is(true));
+ assertThat(repository.getListeners().size(), is(1));
+ assertThat(repository.addListener(listener1), is(false));
+ assertThat(repository.getListeners().size(), is(1));
+ }
+
+ @Test
+ public void shouldAddDifferentListeners() {
+ assertThat(repository.getListeners().size(), is(0));
+ assertThat(repository.addListener(listener1), is(true));
+ assertThat(repository.getListeners().size(), is(1));
+ assertThat(repository.addListener(listener2), is(true));
+ assertThat(repository.getListeners().size(), is(2));
+ assertThat(repository.getListeners(), hasItems(listener1, listener2));
+ assertThat(repository.getListeners().get(0), is(sameInstance(listener1)));
+ assertThat(repository.getListeners().get(1), is(sameInstance(listener2)));
+ }
+
+ @Test
+ public void shouldAllowReorderingOfListeners() {
+ assertThat(repository.getListeners().size(), is(0));
+ assertThat(repository.addListener(listener1), is(true));
+ assertThat(repository.addListener(listener2), is(true));
+ assertThat(repository.getListeners().size(), is(2));
+ assertThat(repository.getListeners(), hasItems(listener1, listener2));
+ repository.getListeners().remove(0);
+ repository.getListeners().add(1, listener1);
+ assertThat(repository.getListeners(), hasItems(listener2, listener1));
+ assertThat(repository.getListeners().get(0), is(sameInstance(listener2)));
+ assertThat(repository.getListeners().get(1), is(sameInstance(listener1)));
+ }
+
+ @Test
+ public void shouldAllowRemovalOfListeners() {
+ assertThat(repository.getListeners().size(), is(0));
+ assertThat(repository.addListener(listener1), is(true));
+ assertThat(repository.addListener(listener2), is(true));
+ assertThat(repository.getListeners(), hasItems(listener1, listener2));
+ assertThat(repository.removeListener(listener1), is(true));
+ assertThat(repository.getListeners(), hasItems(listener2));
+ assertThat(repository.removeListener(listener2), is(true));
+ assertThat(repository.getListeners(), hasItems(new RepositorySourceListener[] {}));
+ }
+
+ @Test
+ public void shouldNotRemoveListenerThatIsNotAlreadyRegistered() {
+ assertThat(repository.getListeners().size(), is(0));
+ assertThat(repository.addListener(listener1), is(true));
+ assertThat(repository.getListeners().size(), is(1));
+ assertThat(repository.removeListener(listener2), is(false));
+ }
+
+ @Test
+ public void shouldHaveNoSourcesAfterInitialization() {
+ assertThat(repository.getSources(), is(notNullValue()));
+ assertThat(repository.getSources().isEmpty(), is(true));
+ }
+
+ @Test
+ public void shouldAddSourceThatIsNotAlreadyRegistered() {
+ assertThat(repository.getSources(), hasItems(new FederatedSource[] {}));
+ assertThat(repository.addSource(source1), is(true));
+ assertThat(repository.getSources(), hasItems(source1));
+ assertThat(repository.addSource(source2), is(true));
+ assertThat(repository.getSources(), hasItems(source1, source2));
+ }
+
+ @Test
+ public void shouldNotAddSourceThatIsAlreadyRegistered() {
+ String source1Name = source1.getName();
+ FederatedSource source1a = mock(FederatedSource.class);
+ stub(source1a.getName()).toReturn(source1Name);
+
+ assertThat(repository.getSources(), hasItems(new FederatedSource[] {}));
+ assertThat(repository.addSource(source1), is(true));
+ assertThat(repository.getSources(), hasItems(source1));
+ assertThat(repository.addSource(source2), is(true));
+ assertThat(repository.getSources(), hasItems(source1, source2));
+ assertThat(repository.addSource(source1a), is(false));
+ assertThat(repository.getSources(), hasItems(source1, source2));
+ }
+
+ @Test
+ public void shouldShutdownAndRemoveRepositoryFromFederationService() {
+ repository.getAdministrator().shutdown();
+ verify(service, times(1)).removeRepository(repository);
+ }
+
+ @Test
+ public void shouldShutdownAllSourceConnectionPoolsWhenShuttingDownRepository() throws Exception {
+ // Create the source instances that wait during termination ...
+ TimeDelayingRepositorySource timeDelaySource1 = new TimeDelayingRepositorySource("time delay source 1");
+ source1 = new FederatedSource(timeDelaySource1);
+ TimeDelayingRepositorySource timeDelaySource2 = new TimeDelayingRepositorySource("time delay source 2");
+ source2 = new FederatedSource(timeDelaySource2);
+ repository.addSource(source1);
+ repository.addSource(source2);
+ assertThat(repository.getSources(), hasItems(source1, source2));
+
+ // Get a connection from one source ...
+ RepositoryConnection connection = source2.getConnection();
+ assertThat(connection, is(notNullValue()));
+
+ // Shut down the repository, which will shut down each of the sources ...
+ repository.getAdministrator().shutdown();
+ assertThat(repository.getAdministrator().isShutdown(), is(true));
+ assertThat(repository.getAdministrator().isTerminated(), is(false));
+
+ // Source 1 should be shut down AND terminated ...
+ assertThat(source1.getConnectionPool().isShutdown(), is(true));
+ assertThat(source1.getConnectionPool().isTerminated(), is(true));
+
+ // Source 2 should be shutdown but not terminated, since we still have a connection ...
+ assertThat(source2.getConnectionPool().isShutdown(), is(true));
+ assertThat(source2.getConnectionPool().isTerminated(), is(false));
+
+ // Close the connection ...
+ connection.close();
+ assertThat(repository.getAdministrator().awaitTermination(1, TimeUnit.SECONDS), is(true));
+ assertThat(repository.getAdministrator().isShutdown(), is(true));
+ assertThat(repository.getAdministrator().isTerminated(), is(true));
+ }
+}
Modified: branches/maeste/dna-repository/src/test/java/org/jboss/dna/repository/federation/FederatedSourceTest.java
===================================================================
--- branches/maeste/dna-repository/src/test/java/org/jboss/dna/repository/federation/FederatedSourceTest.java 2008-06-11 08:35:21 UTC (rev 264)
+++ branches/maeste/dna-repository/src/test/java/org/jboss/dna/repository/federation/FederatedSourceTest.java 2008-06-11 08:45:51 UTC (rev 265)
@@ -21,7 +21,6 @@
*/
package org.jboss.dna.repository.federation;
-import java.util.concurrent.TimeUnit;
import static org.hamcrest.core.Is.is;
import static org.hamcrest.core.IsNull.notNullValue;
import static org.junit.Assert.assertThat;
@@ -29,6 +28,7 @@
import static org.mockito.Mockito.stub;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
+import java.util.concurrent.TimeUnit;
import org.jboss.dna.spi.graph.connection.RepositoryConnection;
import org.jboss.dna.spi.graph.connection.RepositoryConnectionPool;
import org.jboss.dna.spi.graph.connection.RepositorySource;
@@ -36,14 +36,18 @@
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
+import org.mockito.MockitoAnnotations;
+import org.mockito.MockitoAnnotations.Mock;
/**
* @author Randall Hauch
*/
public class FederatedSourceTest {
+ private FederatedSource source;
+ @Mock
private RepositoryConnection connection;
- private FederatedSource source;
+ @Mock
private RepositorySource repositorySource;
/**
@@ -51,6 +55,7 @@
*/
@Before
public void beforeEach() throws Exception {
+ MockitoAnnotations.initMocks(this);
this.repositorySource = mock(RepositorySource.class);
this.source = new FederatedSource(this.repositorySource);
this.connection = mock(RepositoryConnection.class);
Modified: branches/maeste/dna-repository/src/test/java/org/jboss/dna/repository/observation/NodeChangeTest.java
===================================================================
--- branches/maeste/dna-repository/src/test/java/org/jboss/dna/repository/observation/NodeChangeTest.java 2008-06-11 08:35:21 UTC (rev 264)
+++ branches/maeste/dna-repository/src/test/java/org/jboss/dna/repository/observation/NodeChangeTest.java 2008-06-11 08:45:51 UTC (rev 265)
@@ -24,7 +24,6 @@
import java.util.HashSet;
import java.util.Set;
import javax.jcr.observation.Event;
-import org.jboss.dna.repository.observation.NodeChange;
import org.junit.Before;
import org.junit.Test;
@@ -41,7 +40,7 @@
private NodeChange nodeChange;
@Before
- public void beforeEach() throws Exception {
+ public void beforeEach() {
validRepositoryWorkspaceName = "repositoryX";
validAbsolutePath = "/a/b/c/d";
validEventTypes = Event.NODE_ADDED | Event.PROPERTY_ADDED | Event.PROPERTY_CHANGED | Event.PROPERTY_REMOVED;
@@ -50,7 +49,8 @@
validModifiedProperties.add("jcr:name");
validModifiedProperties.add("jcr:title");
validRemovedProperties.add("jcr:mime");
- nodeChange = new NodeChange(validRepositoryWorkspaceName, validAbsolutePath, validEventTypes, validModifiedProperties, validRemovedProperties);
+ nodeChange = new NodeChange(validRepositoryWorkspaceName, validAbsolutePath, validEventTypes, validModifiedProperties,
+ validRemovedProperties);
}
@Test( expected = UnsupportedOperationException.class )
Modified: branches/maeste/dna-repository/src/test/java/org/jboss/dna/repository/rules/RuleServiceTest.java
===================================================================
--- branches/maeste/dna-repository/src/test/java/org/jboss/dna/repository/rules/RuleServiceTest.java 2008-06-11 08:35:21 UTC (rev 264)
+++ branches/maeste/dna-repository/src/test/java/org/jboss/dna/repository/rules/RuleServiceTest.java 2008-06-11 08:45:51 UTC (rev 265)
@@ -40,9 +40,6 @@
import org.jboss.dna.common.component.StandardClassLoaderFactory;
import org.jboss.dna.common.util.IoUtil;
import org.jboss.dna.common.util.Logger;
-import org.jboss.dna.repository.rules.InvalidRuleSetException;
-import org.jboss.dna.repository.rules.RuleService;
-import org.jboss.dna.repository.rules.RuleSet;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -93,13 +90,13 @@
}
@Before
- public void beforeEach() throws Exception {
+ public void beforeEach() {
this.ruleService = new RuleService();
this.classLoaderFactory = new StandardClassLoaderFactory();
}
@After
- public void afterEach() throws Exception {
+ public void afterEach() {
this.ruleService.getAdministrator().shutdown();
}
Modified: branches/maeste/dna-repository/src/test/java/org/jboss/dna/repository/rules/RuleSetTest.java
===================================================================
--- branches/maeste/dna-repository/src/test/java/org/jboss/dna/repository/rules/RuleSetTest.java 2008-06-11 08:35:21 UTC (rev 264)
+++ branches/maeste/dna-repository/src/test/java/org/jboss/dna/repository/rules/RuleSetTest.java 2008-06-11 08:45:51 UTC (rev 265)
@@ -32,7 +32,6 @@
import java.util.Map;
import java.util.Set;
import org.jboss.dna.common.util.IoUtil;
-import org.jboss.dna.repository.rules.RuleSet;
import org.junit.Before;
import org.junit.Test;
@@ -52,7 +51,7 @@
private Map<String, Object> validProperties;
@Before
- public void beforeEach() throws Exception {
+ public void beforeEach() {
this.validName = "This is a valid name";
this.validDescription = "This is a valid description";
this.validClassname = "com.acme.SuperDuper";
@@ -64,91 +63,109 @@
this.validProperties.put("key1", "value1");
this.validProperties.put("key2", null);
this.validProperties.put("key3", "value3".getBytes());
- this.ruleSet = new RuleSet(validName, validDescription, validClassname, validClasspath, validProviderUri, validRuleSetUri, validRules, validProperties);
+ this.ruleSet = new RuleSet(validName, validDescription, validClassname, validClasspath, validProviderUri,
+ validRuleSetUri, validRules, validProperties);
}
@Test( expected = IllegalArgumentException.class )
public void shouldNotAllowNullName() {
- new RuleSet(null, validDescription, validClassname, validClasspath, validProviderUri, validRuleSetUri, validRules, validProperties);
+ new RuleSet(null, validDescription, validClassname, validClasspath, validProviderUri, validRuleSetUri, validRules,
+ validProperties);
}
@Test( expected = IllegalArgumentException.class )
public void shouldNotAllowEmptyName() {
- new RuleSet("", validDescription, validClassname, validClasspath, validProviderUri, validRuleSetUri, validRules, validProperties);
+ new RuleSet("", validDescription, validClassname, validClasspath, validProviderUri, validRuleSetUri, validRules,
+ validProperties);
}
@Test( expected = IllegalArgumentException.class )
public void shouldNotAllowBlankName() {
- new RuleSet(" \t ", validDescription, validClassname, validClasspath, validProviderUri, validRuleSetUri, validRules, validProperties);
+ new RuleSet(" \t ", validDescription, validClassname, validClasspath, validProviderUri, validRuleSetUri, validRules,
+ validProperties);
}
@Test
public void shouldTrimName() {
validName = " this is a valid name with leading and trailing whitespace ";
- ruleSet = new RuleSet(validName, validDescription, validClassname, validClasspath, validProviderUri, validRuleSetUri, validRules, validProperties);
+ ruleSet = new RuleSet(validName, validDescription, validClassname, validClasspath, validProviderUri, validRuleSetUri,
+ validRules, validProperties);
assertThat(ruleSet.getName(), is(validName.trim()));
}
@Test
public void shouldAllowNullOrEmptyOrBlankDescriptionAndShouldReplaceWithEmptyString() {
- ruleSet = new RuleSet(validName, null, validClassname, validClasspath, validProviderUri, validRuleSetUri, validRules, validProperties);
+ ruleSet = new RuleSet(validName, null, validClassname, validClasspath, validProviderUri, validRuleSetUri, validRules,
+ validProperties);
assertThat(ruleSet.getDescription(), is(""));
- ruleSet = new RuleSet(validName, "", validClassname, validClasspath, validProviderUri, validRuleSetUri, validRules, validProperties);
+ ruleSet = new RuleSet(validName, "", validClassname, validClasspath, validProviderUri, validRuleSetUri, validRules,
+ validProperties);
assertThat(ruleSet.getDescription(), is(""));
- ruleSet = new RuleSet(validName, " \t ", validClassname, validClasspath, validProviderUri, validRuleSetUri, validRules, validProperties);
+ ruleSet = new RuleSet(validName, " \t ", validClassname, validClasspath, validProviderUri, validRuleSetUri, validRules,
+ validProperties);
assertThat(ruleSet.getDescription(), is(""));
}
@Test
public void shouldTrimDescription() {
- ruleSet = new RuleSet(validName, " valid ", validClassname, validClasspath, validProviderUri, validRuleSetUri, validRules, validProperties);
+ ruleSet = new RuleSet(validName, " valid ", validClassname, validClasspath, validProviderUri, validRuleSetUri,
+ validRules, validProperties);
assertThat(ruleSet.getDescription(), is("valid"));
}
@Test( expected = IllegalArgumentException.class )
public void shouldNotAllowNullClassname() {
- new RuleSet(validName, validDescription, null, validClasspath, validProviderUri, validRuleSetUri, validRules, validProperties);
+ new RuleSet(validName, validDescription, null, validClasspath, validProviderUri, validRuleSetUri, validRules,
+ validProperties);
}
@Test( expected = IllegalArgumentException.class )
public void shouldNotAllowEmptyClassname() {
- new RuleSet(validName, validDescription, "", validClasspath, validProviderUri, validRuleSetUri, validRules, validProperties);
+ new RuleSet(validName, validDescription, "", validClasspath, validProviderUri, validRuleSetUri, validRules,
+ validProperties);
}
@Test( expected = IllegalArgumentException.class )
public void shouldNotAllowBlankClassname() {
- new RuleSet(validName, validDescription, " ", validClasspath, validProviderUri, validRuleSetUri, validRules, validProperties);
+ new RuleSet(validName, validDescription, " ", validClasspath, validProviderUri, validRuleSetUri, validRules,
+ validProperties);
}
@Test( expected = IllegalArgumentException.class )
public void shouldNotAllowClassnameThatDoesNotFollowJavaNamingRules() {
- new RuleSet(validName, validDescription, "not a valid classname", validClasspath, validProviderUri, validRuleSetUri, validRules, validProperties);
+ new RuleSet(validName, validDescription, "not a valid classname", validClasspath, validProviderUri, validRuleSetUri,
+ validRules, validProperties);
}
@Test
public void shouldAllowNullOrEmptyClasspath() {
- new RuleSet(validName, validDescription, validClassname, null, validProviderUri, validRuleSetUri, validRules, validProperties);
+ new RuleSet(validName, validDescription, validClassname, null, validProviderUri, validRuleSetUri, validRules,
+ validProperties);
}
@Test
public void shouldRemoveNullOrBlankClasspathItems() {
- new RuleSet(validName, validDescription, validClassname, new String[] {}, validProviderUri, validRuleSetUri, validRules, validProperties);
+ new RuleSet(validName, validDescription, validClassname, new String[] {}, validProviderUri, validRuleSetUri, validRules,
+ validProperties);
}
@Test
public void shouldRemoveDuplicateClasspathItemsInCaseSensitiveManner() {
validClasspath = new String[] {"path1", "path2", "path1", "path3", "path2"};
- ruleSet = new RuleSet(validName, validDescription, validClassname, validClasspath, validProviderUri, validRuleSetUri, validRules, validProperties);
+ ruleSet = new RuleSet(validName, validDescription, validClassname, validClasspath, validProviderUri, validRuleSetUri,
+ validRules, validProperties);
assertThat(ruleSet.getComponentClasspathArray(), is(new String[] {"path1", "path2", "path3"}));
validClasspath = new String[] {"path1", "path2", "path1", "path3", "Path2"};
- ruleSet = new RuleSet(validName, validDescription, validClassname, validClasspath, validProviderUri, validRuleSetUri, validRules, validProperties);
+ ruleSet = new RuleSet(validName, validDescription, validClassname, validClasspath, validProviderUri, validRuleSetUri,
+ validRules, validProperties);
assertThat(ruleSet.getComponentClasspathArray(), is(new String[] {"path1", "path2", "path3", "Path2"}));
}
@Test( expected = IllegalArgumentException.class )
public void shouldNotAllowNullProviderUri() {
- new RuleSet(validName, validDescription, validClassname, validClasspath, null, validRuleSetUri, validRules, validProperties);
+ new RuleSet(validName, validDescription, validClassname, validClasspath, null, validRuleSetUri, validRules,
+ validProperties);
}
@Test( expected = IllegalArgumentException.class )
@@ -158,44 +175,52 @@
@Test( expected = IllegalArgumentException.class )
public void shouldNotAllowBlankProviderUri() {
- new RuleSet(validName, validDescription, validClassname, validClasspath, " \t ", validRuleSetUri, validRules, validProperties);
+ new RuleSet(validName, validDescription, validClassname, validClasspath, " \t ", validRuleSetUri, validRules,
+ validProperties);
}
@Test
public void shouldUseNameInPlaceOfNullRuleSetUri() {
- ruleSet = new RuleSet(validName, validDescription, validClassname, validClasspath, validProviderUri, null, validRules, validProperties);
+ ruleSet = new RuleSet(validName, validDescription, validClassname, validClasspath, validProviderUri, null, validRules,
+ validProperties);
assertThat(ruleSet.getRuleSetUri(), is(ruleSet.getName()));
}
@Test( expected = IllegalArgumentException.class )
public void shouldNotAllowEmptyRuleSetUri() {
- new RuleSet(validName, validDescription, validClassname, validClasspath, validProviderUri, "", validRules, validProperties);
+ new RuleSet(validName, validDescription, validClassname, validClasspath, validProviderUri, "", validRules,
+ validProperties);
}
@Test( expected = IllegalArgumentException.class )
public void shouldNotAllowBlankRuleSetUri() {
- new RuleSet(validName, validDescription, validClassname, validClasspath, validProviderUri, " \t ", validRules, validProperties);
+ new RuleSet(validName, validDescription, validClassname, validClasspath, validProviderUri, " \t ", validRules,
+ validProperties);
}
@Test( expected = IllegalArgumentException.class )
public void shouldNotAllowNullRules() {
- new RuleSet(validName, validDescription, validClassname, validClasspath, validProviderUri, validRuleSetUri, null, validProperties);
+ new RuleSet(validName, validDescription, validClassname, validClasspath, validProviderUri, validRuleSetUri, null,
+ validProperties);
}
@Test( expected = IllegalArgumentException.class )
public void shouldNotAllowEmptyRules() {
- new RuleSet(validName, validDescription, validClassname, validClasspath, validProviderUri, validRuleSetUri, "", validProperties);
+ new RuleSet(validName, validDescription, validClassname, validClasspath, validProviderUri, validRuleSetUri, "",
+ validProperties);
}
@Test( expected = IllegalArgumentException.class )
public void shouldNotAllowBlankRules() {
- new RuleSet(validName, validDescription, validClassname, validClasspath, validProviderUri, validRuleSetUri, " \t ", validProperties);
+ new RuleSet(validName, validDescription, validClassname, validClasspath, validProviderUri, validRuleSetUri, " \t ",
+ validProperties);
}
@Test
public void shouldAllowNullOrEmptyProperties() {
validProperties = null;
- ruleSet = new RuleSet(validName, validDescription, validClassname, validClasspath, validProviderUri, validRuleSetUri, validRules, validProperties);
+ ruleSet = new RuleSet(validName, validDescription, validClassname, validClasspath, validProviderUri, validRuleSetUri,
+ validRules, validProperties);
assertThat(ruleSet.getProperties(), is(notNullValue()));
}
@@ -227,7 +252,8 @@
assertThat(executionSetPropIter.hasNext(), is(false));
assertThat(propIter.hasNext(), is(false));
- new RuleSet(validName, validDescription, validClassname, validClasspath, validProviderUri, validRuleSetUri, validRules, validProperties);
+ new RuleSet(validName, validDescription, validClassname, validClasspath, validProviderUri, validRuleSetUri, validRules,
+ validProperties);
}
@Test
@@ -236,33 +262,40 @@
assertThat(copy.hasChanged(ruleSet), is(false));
assertThat(copy.hasChanged(copy), is(false));
- copy = new RuleSet(validName + "x", validDescription, validClassname, validClasspath, validProviderUri, validRuleSetUri, validRules, validProperties);
+ copy = new RuleSet(validName + "x", validDescription, validClassname, validClasspath, validProviderUri, validRuleSetUri,
+ validRules, validProperties);
assertThat(copy.hasChanged(ruleSet), is(true));
assertThat(copy.hasChanged(copy), is(false));
- copy = new RuleSet(validName, validDescription + "x", validClassname, validClasspath, validProviderUri, validRuleSetUri, validRules, validProperties);
+ copy = new RuleSet(validName, validDescription + "x", validClassname, validClasspath, validProviderUri, validRuleSetUri,
+ validRules, validProperties);
assertThat(copy.hasChanged(ruleSet), is(true));
assertThat(copy.hasChanged(copy), is(false));
- copy = new RuleSet(validName, validDescription, validClassname + "x", validClasspath, validProviderUri, validRuleSetUri, validRules, validProperties);
+ copy = new RuleSet(validName, validDescription, validClassname + "x", validClasspath, validProviderUri, validRuleSetUri,
+ validRules, validProperties);
assertThat(copy.hasChanged(ruleSet), is(true));
assertThat(copy.hasChanged(copy), is(false));
- copy = new RuleSet(validName, validDescription, validClassname, validClasspath, validProviderUri + "x", validRuleSetUri, validRules, validProperties);
+ copy = new RuleSet(validName, validDescription, validClassname, validClasspath, validProviderUri + "x", validRuleSetUri,
+ validRules, validProperties);
assertThat(copy.hasChanged(ruleSet), is(true));
assertThat(copy.hasChanged(copy), is(false));
validClasspath = new String[] {"classpath1", "classpath2x"};
- copy = new RuleSet(validName, validDescription, validClassname, validClasspath, validProviderUri, validRuleSetUri + "x", validRules, validProperties);
+ copy = new RuleSet(validName, validDescription, validClassname, validClasspath, validProviderUri, validRuleSetUri + "x",
+ validRules, validProperties);
assertThat(copy.hasChanged(ruleSet), is(true));
assertThat(copy.hasChanged(copy), is(false));
- copy = new RuleSet(validName, validDescription, validClassname, validClasspath, validProviderUri, validRuleSetUri, validRules + "x", validProperties);
+ copy = new RuleSet(validName, validDescription, validClassname, validClasspath, validProviderUri, validRuleSetUri,
+ validRules + "x", validProperties);
assertThat(copy.hasChanged(ruleSet), is(true));
assertThat(copy.hasChanged(copy), is(false));
validProperties.remove("key1");
- copy = new RuleSet(validName, validDescription, validClassname, validClasspath, validProviderUri, validRuleSetUri, validRules, validProperties);
+ copy = new RuleSet(validName, validDescription, validClassname, validClasspath, validProviderUri, validRuleSetUri,
+ validRules, validProperties);
assertThat(copy.hasChanged(ruleSet), is(true));
assertThat(copy.hasChanged(copy), is(false));
}
@@ -272,27 +305,34 @@
RuleSet copy = ruleSet.clone();
assertThat(copy.equals(ruleSet), is(true));
- copy = new RuleSet(validName + "x", validDescription, validClassname, validClasspath, validProviderUri, validRuleSetUri, validRules, validProperties);
+ copy = new RuleSet(validName + "x", validDescription, validClassname, validClasspath, validProviderUri, validRuleSetUri,
+ validRules, validProperties);
assertThat(copy.equals(ruleSet), is(false));
- copy = new RuleSet(validName, validDescription + "x", validClassname, validClasspath, validProviderUri, validRuleSetUri, validRules, validProperties);
+ copy = new RuleSet(validName, validDescription + "x", validClassname, validClasspath, validProviderUri, validRuleSetUri,
+ validRules, validProperties);
assertThat(copy.equals(ruleSet), is(true));
- copy = new RuleSet(validName, validDescription, validClassname + "x", validClasspath, validProviderUri, validRuleSetUri, validRules, validProperties);
+ copy = new RuleSet(validName, validDescription, validClassname + "x", validClasspath, validProviderUri, validRuleSetUri,
+ validRules, validProperties);
assertThat(copy.equals(ruleSet), is(true));
- copy = new RuleSet(validName, validDescription, validClassname, validClasspath, validProviderUri + "x", validRuleSetUri, validRules, validProperties);
+ copy = new RuleSet(validName, validDescription, validClassname, validClasspath, validProviderUri + "x", validRuleSetUri,
+ validRules, validProperties);
assertThat(copy.equals(ruleSet), is(true));
validClasspath = new String[] {"classpath1", "classpath2x"};
- copy = new RuleSet(validName, validDescription, validClassname, validClasspath, validProviderUri, validRuleSetUri + "x", validRules, validProperties);
+ copy = new RuleSet(validName, validDescription, validClassname, validClasspath, validProviderUri, validRuleSetUri + "x",
+ validRules, validProperties);
assertThat(copy.equals(ruleSet), is(true));
- copy = new RuleSet(validName, validDescription, validClassname, validClasspath, validProviderUri, validRuleSetUri, validRules + "x", validProperties);
+ copy = new RuleSet(validName, validDescription, validClassname, validClasspath, validProviderUri, validRuleSetUri,
+ validRules + "x", validProperties);
assertThat(copy.equals(ruleSet), is(true));
validProperties.remove("key1");
- copy = new RuleSet(validName, validDescription, validClassname, validClasspath, validProviderUri, validRuleSetUri, validRules, validProperties);
+ copy = new RuleSet(validName, validDescription, validClassname, validClasspath, validProviderUri, validRuleSetUri,
+ validRules, validProperties);
assertThat(copy.equals(ruleSet), is(true));
}
Modified: branches/maeste/dna-repository/src/test/java/org/jboss/dna/repository/sequencers/SequencerConfigTest.java
===================================================================
--- branches/maeste/dna-repository/src/test/java/org/jboss/dna/repository/sequencers/SequencerConfigTest.java 2008-06-11 08:35:21 UTC (rev 264)
+++ branches/maeste/dna-repository/src/test/java/org/jboss/dna/repository/sequencers/SequencerConfigTest.java 2008-06-11 08:45:51 UTC (rev 265)
@@ -24,7 +24,6 @@
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
-import org.jboss.dna.repository.sequencers.SequencerConfig;
import org.junit.Before;
import org.junit.Test;
@@ -43,15 +42,18 @@
private String[] validMavenIds;
@Before
- public void beforeEach() throws Exception {
+ public void beforeEach() {
this.validName = "valid configuration name";
this.validDescription = "a sequencer";
this.validClassname = MockSequencerA.class.getName();
this.validPathExpressions = new String[] {"/a/b/c/d[e/@attribute] => ."};
this.validMavenIds = new String[] {"com.acme:configA:1.0,com.acme:configB:1.0"};
- this.configA = new SequencerConfig("configA", validDescription, MockSequencerA.class.getName(), validMavenIds, validPathExpressions);
- this.configB = new SequencerConfig("configB", validDescription, MockSequencerB.class.getName(), validMavenIds, validPathExpressions);
- this.configA2 = new SequencerConfig("conFigA", validDescription, MockSequencerA.class.getName(), validMavenIds, validPathExpressions);
+ this.configA = new SequencerConfig("configA", validDescription, MockSequencerA.class.getName(), validMavenIds,
+ validPathExpressions);
+ this.configB = new SequencerConfig("configB", validDescription, MockSequencerB.class.getName(), validMavenIds,
+ validPathExpressions);
+ this.configA2 = new SequencerConfig("conFigA", validDescription, MockSequencerA.class.getName(), validMavenIds,
+ validPathExpressions);
}
@Test( expected = IllegalArgumentException.class )
@@ -106,7 +108,9 @@
@Test
public void shouldNotAddSamePathExpressionMoreThanOnce() {
- assertThat(SequencerConfig.buildPathExpressionSet(validPathExpressions[0], validPathExpressions[0], validPathExpressions[0]).size(), is(1));
+ assertThat(SequencerConfig.buildPathExpressionSet(validPathExpressions[0],
+ validPathExpressions[0],
+ validPathExpressions[0]).size(), is(1));
}
@Test
Modified: branches/maeste/dna-repository/src/test/java/org/jboss/dna/repository/sequencers/SequencingServiceTest.java
===================================================================
--- branches/maeste/dna-repository/src/test/java/org/jboss/dna/repository/sequencers/SequencingServiceTest.java 2008-06-11 08:35:21 UTC (rev 264)
+++ branches/maeste/dna-repository/src/test/java/org/jboss/dna/repository/sequencers/SequencingServiceTest.java 2008-06-11 08:45:51 UTC (rev 265)
@@ -46,7 +46,8 @@
*/
public class SequencingServiceTest extends AbstractJcrRepositoryTest {
- public static final int ALL_EVENT_TYPES = Event.NODE_ADDED | Event.NODE_REMOVED | Event.PROPERTY_ADDED | Event.PROPERTY_CHANGED | Event.PROPERTY_REMOVED;
+ public static final int ALL_EVENT_TYPES = Event.NODE_ADDED | Event.NODE_REMOVED | Event.PROPERTY_ADDED
+ | Event.PROPERTY_CHANGED | Event.PROPERTY_REMOVED;
public static final String REPOSITORY_WORKSPACE_NAME = "testRepository-Workspace";
private ObservationService observationService;
@@ -54,7 +55,7 @@
private ExecutionContext executionContext;
@Before
- public void beforeEach() throws Exception {
+ public void beforeEach() {
this.executionContext = new MockExecutionContext(this, REPOSITORY_WORKSPACE_NAME);
this.sequencingService = new SequencingService();
this.sequencingService.setExecutionContext(this.executionContext);
@@ -141,7 +142,9 @@
assertThat(sequencingService.getAdministrator().shutdown().isShutdown(), is(true));
assertThat(sequencingService.getAdministrator().isPaused(), is(false));
assertThat(sequencingService.getAdministrator().isStarted(), is(false));
- assertThat(sequencingService.getAdministrator().getState(), is(ServiceAdministrator.State.SHUTDOWN));
+ ServiceAdministrator.State actualState = sequencingService.getAdministrator().getState();
+ assertThat(actualState == ServiceAdministrator.State.SHUTDOWN || actualState == ServiceAdministrator.State.TERMINATED,
+ is(true));
}
}
@@ -170,7 +173,9 @@
assertThat(sequencingService.getAdministrator().shutdown().isShutdown(), is(true));
assertThat(sequencingService.getAdministrator().isPaused(), is(false));
assertThat(sequencingService.getAdministrator().isStarted(), is(false));
- assertThat(sequencingService.getAdministrator().getState(), is(ServiceAdministrator.State.SHUTDOWN));
+ ServiceAdministrator.State actualState = sequencingService.getAdministrator().getState();
+ assertThat(actualState == ServiceAdministrator.State.SHUTDOWN || actualState == ServiceAdministrator.State.TERMINATED,
+ is(true));
// Now start it back up ... this will fail
sequencingService.getAdministrator().start();
Modified: branches/maeste/dna-repository/src/test/java/org/jboss/dna/repository/sequencers/StreamSequencerAdapterTest.java
===================================================================
--- branches/maeste/dna-repository/src/test/java/org/jboss/dna/repository/sequencers/StreamSequencerAdapterTest.java 2008-06-11 08:35:21 UTC (rev 264)
+++ branches/maeste/dna-repository/src/test/java/org/jboss/dna/repository/sequencers/StreamSequencerAdapterTest.java 2008-06-11 08:45:51 UTC (rev 265)
@@ -71,7 +71,7 @@
private String repositoryWorkspaceName = "something";
@Before
- public void beforeEach() throws Exception {
+ public void beforeEach() {
final JcrTools tools = new JcrTools();
this.tools = tools;
final SessionFactory sessionFactory = new SessionFactory() {
@@ -91,7 +91,9 @@
* This method always copies the {@link StreamSequencerAdapterTest#sequencerOutput} data into the output {@inheritDoc},
* and does nothing else with any of the other parameters.
*/
- public void sequence( InputStream stream, SequencerOutput output, ProgressMonitor progressMonitor ) {
+ public void sequence( InputStream stream,
+ SequencerOutput output,
+ ProgressMonitor progressMonitor ) {
for (SequencerOutputMap.Entry entry : finalOutput) {
Path nodePath = entry.getPath();
for (SequencerOutputMap.PropertyValue property : entry.getPropertyValues()) {
@@ -104,7 +106,7 @@
}
@After
- public void afterEach() throws Exception {
+ public void afterEach() {
if (session != null) {
try {
session.logout();
@@ -149,7 +151,8 @@
@Test
public void shouldExtractMixinTypesFromStringArrayWithNullValue() {
- assertThat(sequencer.extractMixinTypes(new String[] {"value1", null, "value2"}), is(new String[] {"value1", null, "value2"}));
+ assertThat(sequencer.extractMixinTypes(new String[] {"value1", null, "value2"}), is(new String[] {"value1", null,
+ "value2"}));
}
@Test
@@ -170,7 +173,8 @@
nodeC.setProperty("sequencedProperty", new ByteArrayInputStream(sampleData.getBytes()));
// Set up the node changes ...
- NodeChange nodeChange = new NodeChange(repositoryWorkspaceName, nodeC.getPath(), Event.PROPERTY_CHANGED, Collections.singleton("sequencedProperty"), null);
+ NodeChange nodeChange = new NodeChange(repositoryWorkspaceName, nodeC.getPath(), Event.PROPERTY_CHANGED,
+ Collections.singleton("sequencedProperty"), null);
// Set up the output directory ...
Set<RepositoryNodePath> outputPaths = new HashSet<RepositoryNodePath>();
@@ -202,7 +206,8 @@
nodeC.setProperty("sequencedProperty", (InputStream)null);
// Set up the node changes ...
- NodeChange nodeChange = new NodeChange(repositoryWorkspaceName, nodeC.getPath(), Event.PROPERTY_CHANGED, Collections.singleton("sequencedProperty"), null);
+ NodeChange nodeChange = new NodeChange(repositoryWorkspaceName, nodeC.getPath(), Event.PROPERTY_CHANGED,
+ Collections.singleton("sequencedProperty"), null);
// Set up the output directory ...
Set<RepositoryNodePath> outputPaths = new HashSet<RepositoryNodePath>();
@@ -233,7 +238,8 @@
nodeC.setProperty("sequencedProperty", new ByteArrayInputStream(sampleData.getBytes()));
// Set up the node changes ...
- NodeChange nodeChange = new NodeChange(repositoryWorkspaceName, nodeC.getPath(), Event.PROPERTY_CHANGED, Collections.singleton("sequencedProperty"), null);
+ NodeChange nodeChange = new NodeChange(repositoryWorkspaceName, nodeC.getPath(), Event.PROPERTY_CHANGED,
+ Collections.singleton("sequencedProperty"), null);
// Set up the output directory ...
Set<RepositoryNodePath> outputPaths = new HashSet<RepositoryNodePath>();
@@ -265,7 +271,8 @@
nodeC.setProperty("sequencedProperty", new ByteArrayInputStream(sampleData.getBytes()));
// Set up the node changes ...
- NodeChange nodeChange = new NodeChange(repositoryWorkspaceName, nodeC.getPath(), Event.PROPERTY_CHANGED, Collections.singleton("sequencedProperty"), null);
+ NodeChange nodeChange = new NodeChange(repositoryWorkspaceName, nodeC.getPath(), Event.PROPERTY_CHANGED,
+ Collections.singleton("sequencedProperty"), null);
// Set up the output directory ...
Set<RepositoryNodePath> outputPaths = new HashSet<RepositoryNodePath>();
@@ -296,7 +303,8 @@
nodeC.setProperty("sequencedProperty", new ByteArrayInputStream(sampleData.getBytes()));
// Set up the node changes ...
- NodeChange nodeChange = new NodeChange(repositoryWorkspaceName, nodeC.getPath(), Event.PROPERTY_CHANGED, Collections.singleton("sequencedProperty"), null);
+ NodeChange nodeChange = new NodeChange(repositoryWorkspaceName, nodeC.getPath(), Event.PROPERTY_CHANGED,
+ Collections.singleton("sequencedProperty"), null);
// Set up the output directory ...
Set<RepositoryNodePath> outputPaths = new HashSet<RepositoryNodePath>();
@@ -327,7 +335,7 @@
}
@Test
- public void shouldSequencerOutputProvideAccessToNamespaceRegistry() {
- assertThat(sequencerOutput.getNamespaceRegistry(), notNullValue());
- }
+ public void shouldSequencerOutputProvideAccessToNamespaceRegistry() {
+ assertThat(sequencerOutput.getNamespaceRegistry(), notNullValue());
+ }
}
Modified: branches/maeste/dna-repository/src/test/java/org/jboss/dna/repository/sequencers/xml/XmlSequencerTest.java
===================================================================
--- branches/maeste/dna-repository/src/test/java/org/jboss/dna/repository/sequencers/xml/XmlSequencerTest.java 2008-06-11 08:35:21 UTC (rev 264)
+++ branches/maeste/dna-repository/src/test/java/org/jboss/dna/repository/sequencers/xml/XmlSequencerTest.java 2008-06-11 08:45:51 UTC (rev 265)
@@ -43,171 +43,171 @@
*/
public class XmlSequencerTest {
- private XmlSequencer sequencer;
- private InputStream stream;
- private MockSequencerOutput output;
- private ProgressMonitor monitor;
- private URL xml1;
- private URL xml2;
- private URL xml3;
- private URL xml4;
- private URL xsd;
+ private XmlSequencer sequencer;
+ private InputStream stream;
+ private MockSequencerOutput output;
+ private ProgressMonitor monitor;
+ private URL xml1;
+ private URL xml2;
+ private URL xml3;
+ private URL xml4;
+ private URL xsd;
- @Before
- public void beforeEach() throws Exception {
- sequencer = new XmlSequencer();
- output = new MockSequencerOutput() {
+ @Before
+ public void beforeEach() {
+ sequencer = new XmlSequencer();
+ output = new MockSequencerOutput() {
- @Override
- public void setProperty( Path nodePath,
- Name propertyName,
- Object... values ) {
- super.setProperty(nodePath, propertyName, values);
- // System.out.println(nodePath + "." + propertyName + " = " + Arrays.asList(values));
- }
- };
- monitor = new SimpleProgressMonitor("Test activity");
- xml1 = this.getClass().getClassLoader().getResource("jackrabbitInMemoryTestRepositoryConfig.xml");
- assertThat(xml1, is(notNullValue()));
- xml2 = this.getClass().getClassLoader().getResource("master.xml");
- assertThat(xml2, is(notNullValue()));
- xml3 = this.getClass().getClassLoader().getResource("CurrencyFormatterExample.mxml");
- assertThat(xml3, is(notNullValue()));
- xml4 = this.getClass().getClassLoader().getResource("plugin.xml");
- assertThat(xml4, is(notNullValue()));
- xsd = this.getClass().getClassLoader().getResource("Descriptor.1.0.xsd");
- assertThat(xsd, is(notNullValue()));
- }
+ @Override
+ public void setProperty( Path nodePath,
+ Name propertyName,
+ Object... values ) {
+ super.setProperty(nodePath, propertyName, values);
+ // System.out.println(nodePath + "." + propertyName + " = " + Arrays.asList(values));
+ }
+ };
+ monitor = new SimpleProgressMonitor("Test activity");
+ xml1 = this.getClass().getClassLoader().getResource("jackrabbitInMemoryTestRepositoryConfig.xml");
+ assertThat(xml1, is(notNullValue()));
+ xml2 = this.getClass().getClassLoader().getResource("master.xml");
+ assertThat(xml2, is(notNullValue()));
+ xml3 = this.getClass().getClassLoader().getResource("CurrencyFormatterExample.mxml");
+ assertThat(xml3, is(notNullValue()));
+ xml4 = this.getClass().getClassLoader().getResource("plugin.xml");
+ assertThat(xml4, is(notNullValue()));
+ xsd = this.getClass().getClassLoader().getResource("Descriptor.1.0.xsd");
+ assertThat(xsd, is(notNullValue()));
+ }
- @After
- public void afterEach() throws Exception {
- if (stream != null) {
- try {
- stream.close();
- } finally {
- stream = null;
- }
- }
- }
+ @After
+ public void afterEach() throws Exception {
+ if (stream != null) {
+ try {
+ stream.close();
+ } finally {
+ stream = null;
+ }
+ }
+ }
- @Test
- public void shouldSequenceXml() throws IOException {
- verifyDocument(xml1);
- verifyName(XmlSequencer.COMMENT + "[1]", NameFactory.JCR_PRIMARY_TYPE, XmlSequencer.COMMENT);
- String text = verify(XmlSequencer.COMMENT + "[1]", XmlSequencer.COMMENT_CONTENT, String.class);
- assertThat(text.startsWith("\n Licensed to the Apache Software Foundation (ASF)"), is(true));
- assertThat(text.endsWith(" limitations under the License.\n"), is(true));
- verifyString("", XmlSequencer.DTD_NAME, "Repository");
- verifyString("", XmlSequencer.DTD_PUBLIC_ID, "-//The Apache Software Foundation//DTD Jackrabbit 1.2//EN");
- verifyString("", XmlSequencer.DTD_SYSTEM_ID, "http://jackrabbit.apache.org/dtd/repository-1.2.dtd");
- verifyName(XmlSequencer.COMMENT + "[2]", NameFactory.JCR_PRIMARY_TYPE, XmlSequencer.COMMENT);
- verifyString(XmlSequencer.COMMENT + "[2]", XmlSequencer.COMMENT_CONTENT, " Example Repository Configuration File ");
- verifyName("Repository[1]", NameFactory.JCR_PRIMARY_TYPE, "Repository");
- verifyName("Repository[1]/" + XmlSequencer.COMMENT + "[1]", NameFactory.JCR_PRIMARY_TYPE, XmlSequencer.COMMENT);
- }
+ @Test
+ public void shouldSequenceXml() throws IOException {
+ verifyDocument(xml1);
+ verifyName(XmlSequencer.COMMENT + "[1]", NameFactory.JCR_PRIMARY_TYPE, XmlSequencer.COMMENT);
+ String text = verify(XmlSequencer.COMMENT + "[1]", XmlSequencer.COMMENT_CONTENT, String.class);
+ assertThat(text.startsWith("\n Licensed to the Apache Software Foundation (ASF)"), is(true));
+ assertThat(text.endsWith(" limitations under the License.\n"), is(true));
+ verifyString("", XmlSequencer.DTD_NAME, "Repository");
+ verifyString("", XmlSequencer.DTD_PUBLIC_ID, "-//The Apache Software Foundation//DTD Jackrabbit 1.2//EN");
+ verifyString("", XmlSequencer.DTD_SYSTEM_ID, "http://jackrabbit.apache.org/dtd/repository-1.2.dtd");
+ verifyName(XmlSequencer.COMMENT + "[2]", NameFactory.JCR_PRIMARY_TYPE, XmlSequencer.COMMENT);
+ verifyString(XmlSequencer.COMMENT + "[2]", XmlSequencer.COMMENT_CONTENT, " Example Repository Configuration File ");
+ verifyName("Repository[1]", NameFactory.JCR_PRIMARY_TYPE, "Repository");
+ verifyName("Repository[1]/" + XmlSequencer.COMMENT + "[1]", NameFactory.JCR_PRIMARY_TYPE, XmlSequencer.COMMENT);
+ }
- @Test
- public void shouldHandleNamespaces() throws IOException {
- verifyDocument(xml2);
- verifyName("book[1]/bookinfo[1]/xi:include[1]", NameFactory.JCR_PRIMARY_TYPE, "xi:include");
- verifyString("book[1]/bookinfo[1]/xi:include[1]", "xi:href", "Author_Group.xml");
- verifyName("book[1]/bookinfo[1]/xi:include[2]", NameFactory.JCR_PRIMARY_TYPE, "xi:include");
- verifyString("book[1]/bookinfo[1]/xi:include[2]", "xi:href", "Legal_Notice.xml");
- }
+ @Test
+ public void shouldHandleNamespaces() throws IOException {
+ verifyDocument(xml2);
+ verifyName("book[1]/bookinfo[1]/xi:include[1]", NameFactory.JCR_PRIMARY_TYPE, "xi:include");
+ verifyString("book[1]/bookinfo[1]/xi:include[1]", "xi:href", "Author_Group.xml");
+ verifyName("book[1]/bookinfo[1]/xi:include[2]", NameFactory.JCR_PRIMARY_TYPE, "xi:include");
+ verifyString("book[1]/bookinfo[1]/xi:include[2]", "xi:href", "Legal_Notice.xml");
+ }
- @Test
- public void shouldSequenceEntityDeclarations() throws IOException {
- verifyDocument(xml2);
- verifyName(XmlSequencer.ENTITY + "[1]", NameFactory.JCR_PRIMARY_TYPE, XmlSequencer.ENTITY);
- verifyString(XmlSequencer.ENTITY + "[1]", XmlSequencer.DTD_NAME, "%RH-ENTITIES");
- verifyString(XmlSequencer.ENTITY + "[1]", XmlSequencer.DTD_SYSTEM_ID, "Common_Config/rh-entities.ent");
- verifyName(XmlSequencer.ENTITY + "[2]", NameFactory.JCR_PRIMARY_TYPE, XmlSequencer.ENTITY);
- verifyString(XmlSequencer.ENTITY + "[2]", XmlSequencer.DTD_NAME, "versionNumber");
- verifyString(XmlSequencer.ENTITY + "[2]", XmlSequencer.DTD_VALUE, "0.1");
- verifyName(XmlSequencer.ENTITY + "[3]", NameFactory.JCR_PRIMARY_TYPE, XmlSequencer.ENTITY);
- verifyString(XmlSequencer.ENTITY + "[3]", XmlSequencer.DTD_NAME, "copyrightYear");
- verifyString(XmlSequencer.ENTITY + "[3]", XmlSequencer.DTD_VALUE, "2008");
- }
+ @Test
+ public void shouldSequenceEntityDeclarations() throws IOException {
+ verifyDocument(xml2);
+ verifyName(XmlSequencer.ENTITY + "[1]", NameFactory.JCR_PRIMARY_TYPE, XmlSequencer.ENTITY);
+ verifyString(XmlSequencer.ENTITY + "[1]", XmlSequencer.DTD_NAME, "%RH-ENTITIES");
+ verifyString(XmlSequencer.ENTITY + "[1]", XmlSequencer.DTD_SYSTEM_ID, "Common_Config/rh-entities.ent");
+ verifyName(XmlSequencer.ENTITY + "[2]", NameFactory.JCR_PRIMARY_TYPE, XmlSequencer.ENTITY);
+ verifyString(XmlSequencer.ENTITY + "[2]", XmlSequencer.DTD_NAME, "versionNumber");
+ verifyString(XmlSequencer.ENTITY + "[2]", XmlSequencer.DTD_VALUE, "0.1");
+ verifyName(XmlSequencer.ENTITY + "[3]", NameFactory.JCR_PRIMARY_TYPE, XmlSequencer.ENTITY);
+ verifyString(XmlSequencer.ENTITY + "[3]", XmlSequencer.DTD_NAME, "copyrightYear");
+ verifyString(XmlSequencer.ENTITY + "[3]", XmlSequencer.DTD_VALUE, "2008");
+ }
- @Test
- public void shouldSequenceElementContent() throws IOException {
- verifyDocument(xml2);
- verifyString("book[1]/chapter[4]/sect1[1]/para[8]/" + XmlSequencer.ELEMENT_CONTENT + "[1]",
- XmlSequencer.ELEMENT_CONTENT,
- "The path expression is more complicated."
- + " Sequencer path expressions are used by the sequencing service to determine whether a particular changed node should be sequenced."
- + " The expressions consist of two parts: a selection criteria and an output expression."
- + " Here's a simple example:");
- verifyString("book[1]/chapter[4]/sect1[1]/para[8]/programlisting[1]/" + XmlSequencer.ELEMENT_CONTENT + "[1]",
- XmlSequencer.ELEMENT_CONTENT,
- "/a/b/c@title => /d/e/f");
- }
+ @Test
+ public void shouldSequenceElementContent() throws IOException {
+ verifyDocument(xml2);
+ verifyString("book[1]/chapter[4]/sect1[1]/para[8]/" + XmlSequencer.ELEMENT_CONTENT + "[1]",
+ XmlSequencer.ELEMENT_CONTENT,
+ "The path expression is more complicated."
+ + " Sequencer path expressions are used by the sequencing service to determine whether a particular changed node should be sequenced."
+ + " The expressions consist of two parts: a selection criteria and an output expression."
+ + " Here's a simple example:");
+ verifyString("book[1]/chapter[4]/sect1[1]/para[8]/programlisting[1]/" + XmlSequencer.ELEMENT_CONTENT + "[1]",
+ XmlSequencer.ELEMENT_CONTENT,
+ "/a/b/c@title => /d/e/f");
+ }
- @Test
- public void shouldSequenceCData() throws IOException {
- verifyDocument(xml3);
- verifyString("mx:Application[1]/mx:Script[1]/" + XmlSequencer.CDATA + "[1]",
- XmlSequencer.CDATA_CONTENT,
- "\n\n" + " import mx.events.ValidationResultEvent;\t\t\t\n"
- + " private var vResult:ValidationResultEvent;\n" + "\t\t\t\n"
- + " // Event handler to validate and format input.\n"
- + " private function Format():void {\n" + " \n"
- + " vResult = numVal.validate();\n\n"
- + " if (vResult.type==ValidationResultEvent.VALID) {\n"
- + " var temp:Number=Number(priceUS.text); \n"
- + " formattedUSPrice.text= usdFormatter.format(temp);\n" + " }\n"
- + " \n" + " else {\n"
- + " formattedUSPrice.text=\"\";\n" + " }\n" + " }\n"
- + " ");
- }
+ @Test
+ public void shouldSequenceCData() throws IOException {
+ verifyDocument(xml3);
+ verifyString("mx:Application[1]/mx:Script[1]/" + XmlSequencer.CDATA + "[1]",
+ XmlSequencer.CDATA_CONTENT,
+ "\n\n" + " import mx.events.ValidationResultEvent;\t\t\t\n"
+ + " private var vResult:ValidationResultEvent;\n" + "\t\t\t\n"
+ + " // Event handler to validate and format input.\n"
+ + " private function Format():void {\n" + " \n"
+ + " vResult = numVal.validate();\n\n"
+ + " if (vResult.type==ValidationResultEvent.VALID) {\n"
+ + " var temp:Number=Number(priceUS.text); \n"
+ + " formattedUSPrice.text= usdFormatter.format(temp);\n" + " }\n"
+ + " \n" + " else {\n"
+ + " formattedUSPrice.text=\"\";\n" + " }\n" + " }\n"
+ + " ");
+ }
- @Test
- public void shouldSequenceProcessingInstructions() throws IOException {
- verifyDocument(xml4);
- verifyName(XmlSequencer.PI + "[1]", NameFactory.JCR_PRIMARY_TYPE, XmlSequencer.PI);
- verifyString(XmlSequencer.PI + "[1]", XmlSequencer.TARGET, "eclipse");
- verifyString(XmlSequencer.PI + "[1]", XmlSequencer.PI_CONTENT, "version=\"3.0\"");
- }
+ @Test
+ public void shouldSequenceProcessingInstructions() throws IOException {
+ verifyDocument(xml4);
+ verifyName(XmlSequencer.PI + "[1]", NameFactory.JCR_PRIMARY_TYPE, XmlSequencer.PI);
+ verifyString(XmlSequencer.PI + "[1]", XmlSequencer.TARGET, "eclipse");
+ verifyString(XmlSequencer.PI + "[1]", XmlSequencer.PI_CONTENT, "version=\"3.0\"");
+ }
- @Test
- public void shouldSequenceXsds() throws IOException {
- verifyDocument(xsd);
- verifyName("xs:schema[1]", NameFactory.JCR_PRIMARY_TYPE, "xs:schema");
- verifyString("xs:schema[1]", "xs:targetNamespace", "http://ns.adobe.com/air/application/1.0");
- verifyString("xs:schema[1]", "xs:elementFormDefault", "qualified");
- verifyName("xs:schema[1]/xs:element[1]", NameFactory.JCR_PRIMARY_TYPE, "xs:element");
- verifyString("xs:schema[1]/xs:element[1]", "xs:name", "application");
- }
+ @Test
+ public void shouldSequenceXsds() throws IOException {
+ verifyDocument(xsd);
+ verifyName("xs:schema[1]", NameFactory.JCR_PRIMARY_TYPE, "xs:schema");
+ verifyString("xs:schema[1]", "xs:targetNamespace", "http://ns.adobe.com/air/application/1.0");
+ verifyString("xs:schema[1]", "xs:elementFormDefault", "qualified");
+ verifyName("xs:schema[1]/xs:element[1]", NameFactory.JCR_PRIMARY_TYPE, "xs:element");
+ verifyString("xs:schema[1]/xs:element[1]", "xs:name", "application");
+ }
- private <T> T verify( String nodePath,
- String property,
- Class<T> expectedClass ) {
- Object[] values = output.getPropertyValues(nodePath.length() == 0 ? "." : "./" + nodePath, property);
- assertThat(values, notNullValue());
- assertThat(values.length, is(1));
- Object value = values[0];
- assertThat(value, instanceOf(expectedClass));
- return expectedClass.cast(value);
- }
+ private <T> T verify( String nodePath,
+ String property,
+ Class<T> expectedClass ) {
+ Object[] values = output.getPropertyValues(nodePath.length() == 0 ? "." : "./" + nodePath, property);
+ assertThat(values, notNullValue());
+ assertThat(values.length, is(1));
+ Object value = values[0];
+ assertThat(value, instanceOf(expectedClass));
+ return expectedClass.cast(value);
+ }
- private void verifyDocument( URL url ) throws IOException {
- stream = url.openStream();
- assertThat(stream, is(notNullValue()));
- sequencer.sequence(stream, output, monitor);
- verifyName("", NameFactory.JCR_PRIMARY_TYPE, XmlSequencer.DOCUMENT);
- }
+ private void verifyDocument( URL url ) throws IOException {
+ stream = url.openStream();
+ assertThat(stream, is(notNullValue()));
+ sequencer.sequence(stream, output, monitor);
+ verifyName("", NameFactory.JCR_PRIMARY_TYPE, XmlSequencer.DOCUMENT);
+ }
- private void verifyName( String nodePath,
- String property,
- String expectedName ) {
- Name name = verify(nodePath, property, Name.class);
- assertThat(name, is(output.getFactories().getNameFactory().create(expectedName)));
- }
+ private void verifyName( String nodePath,
+ String property,
+ String expectedName ) {
+ Name name = verify(nodePath, property, Name.class);
+ assertThat(name, is(output.getFactories().getNameFactory().create(expectedName)));
+ }
- private void verifyString( String nodePath,
- String property,
- String expectedString ) {
- String string = verify(nodePath, property, String.class);
- assertThat(string, is(expectedString));
- }
+ private void verifyString( String nodePath,
+ String property,
+ String expectedString ) {
+ String string = verify(nodePath, property, String.class);
+ assertThat(string, is(expectedString));
+ }
}
Modified: branches/maeste/dna-repository/src/test/java/org/jboss/dna/repository/util/JndiSessionFactoryTest.java
===================================================================
--- branches/maeste/dna-repository/src/test/java/org/jboss/dna/repository/util/JndiSessionFactoryTest.java 2008-06-11 08:35:21 UTC (rev 264)
+++ branches/maeste/dna-repository/src/test/java/org/jboss/dna/repository/util/JndiSessionFactoryTest.java 2008-06-11 08:45:51 UTC (rev 265)
@@ -27,6 +27,7 @@
import static org.hamcrest.core.IsSame.sameInstance;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail;
+import static org.mockito.Mockito.mock;
import javax.jcr.Repository;
import javax.jcr.Session;
import javax.naming.InitialContext;
@@ -34,8 +35,6 @@
import org.jboss.dna.common.SystemFailureException;
import org.jboss.dna.common.jcr.AbstractJcrRepositoryTest;
import org.jboss.dna.common.naming.MockInitialContext;
-import org.jboss.dna.repository.util.JndiSessionFactory;
-import org.jmock.Mockery;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -49,20 +48,18 @@
public static final String MOCK_REPOSITORY_NAME_ALT = "java:jcr/unit/test/repository/2";
private JndiSessionFactory factory;
- private Mockery context;
private Repository mockRepository;
private Session session;
@Before
public void beforeEach() throws Exception {
- this.context = new Mockery();
- this.mockRepository = this.context.mock(Repository.class);
+ this.mockRepository = mock(Repository.class);
MockInitialContext.register(MOCK_REPOSITORY_NAME, this.mockRepository);
this.factory = new JndiSessionFactory();
}
@After
- public void afterEach() throws Exception {
+ public void afterEach() {
if (session != null) {
session.logout();
}
@@ -78,7 +75,8 @@
}
}
- protected void assertRegistered( String name, Object obj ) {
+ protected void assertRegistered( String name,
+ Object obj ) {
try {
assertThat(new InitialContext().lookup(name), is(sameInstance(obj)));
} catch (NamingException e) {
@@ -127,21 +125,21 @@
}
@Test
- public void shouldRegisterSuppliedRepositoryInJndi() throws Exception {
+ public void shouldRegisterSuppliedRepositoryInJndi() {
assertNotRegistered(MOCK_REPOSITORY_NAME_ALT);
factory.registerRepository(MOCK_REPOSITORY_NAME_ALT, mockRepository);
assertRegistered(MOCK_REPOSITORY_NAME_ALT, mockRepository);
}
@Test
- public void shouldUnregisterRepositoryInJndiIfNullRepositoryReference() throws Exception {
+ public void shouldUnregisterRepositoryInJndiIfNullRepositoryReference() {
assertRegistered(MOCK_REPOSITORY_NAME, mockRepository);
factory.registerRepository(MOCK_REPOSITORY_NAME, null);
assertNotRegistered(MOCK_REPOSITORY_NAME);
}
@Test
- public void shouldRemoveAllTrailingDelimitersWhenRegisteringRepository() throws Exception {
+ public void shouldRemoveAllTrailingDelimitersWhenRegisteringRepository() {
assertNotRegistered("java:jcr/unit/test/repository");
factory.registerRepository("java:jcr/unit/test/repository///", mockRepository);
assertRegistered("java:jcr/unit/test/repository", mockRepository);
Modified: branches/maeste/dna-repository/src/test/resources/log4j.properties
===================================================================
--- branches/maeste/dna-repository/src/test/resources/log4j.properties 2008-06-11 08:35:21 UTC (rev 264)
+++ branches/maeste/dna-repository/src/test/resources/log4j.properties 2008-06-11 08:45:51 UTC (rev 265)
@@ -9,7 +9,9 @@
# Set up the default logging to be INFO level, then override specific units
log4j.logger.org.jboss.dna=INFO
-log4j.logger.org.jboss.dna.repository.sequencers=TRACE
+#log4j.logger.org.jboss.dna.repository.sequencers=TRACE
+#log4j.logger.org.jboss.dna.repository.federation=DEBUG
+#log4j.logger.org.jboss.dna.spi=DEBUG
# Jackrabbit logging
log4j.logger.org.apache.jackrabbit=WARN, stdout
Modified: branches/maeste/dna-spi/pom.xml
===================================================================
--- branches/maeste/dna-spi/pom.xml 2008-06-11 08:35:21 UTC (rev 264)
+++ branches/maeste/dna-spi/pom.xml 2008-06-11 08:45:51 UTC (rev 265)
@@ -44,15 +44,10 @@
<scope>test</scope>
</dependency>
<dependency>
- <groupId>org.jmock</groupId>
- <artifactId>jmock</artifactId>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-all</artifactId>
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>org.jmock</groupId>
- <artifactId>jmock-junit4</artifactId>
- <scope>test</scope>
- </dependency>
<!--
Logging (require SLF4J API for compiling, but use Log4J and its SLF4J binding for testing)
-->
Modified: branches/maeste/dna-spi/src/main/java/org/jboss/dna/spi/SpiI18n.java
===================================================================
--- branches/maeste/dna-spi/src/main/java/org/jboss/dna/spi/SpiI18n.java 2008-06-11 08:35:21 UTC (rev 264)
+++ branches/maeste/dna-spi/src/main/java/org/jboss/dna/spi/SpiI18n.java 2008-06-11 08:45:51 UTC (rev 265)
@@ -32,29 +32,28 @@
*/
public final class SpiI18n {
- public static I18n errorConvertingBinaryValueToString;
- public static I18n errorCreatingValue;
+ public static I18n closedConnectionMayNotBeUsed;
+ public static I18n errorConvertingIo;
+ public static I18n errorConvertingType;
public static I18n errorReadingPropertyValueBytes;
- public static I18n invalidIndexInSegmentName;
- public static I18n invalidQualifiedNameString;
- public static I18n missingEndBracketInSegmentName;
+ public static I18n invalidIndexInSegmentName;
+ public static I18n invalidQualifiedNameString;
+ public static I18n maximumPoolSizeMayNotBeSmallerThanCorePoolSize;
+ public static I18n missingEndBracketInSegmentName;
public static I18n noNamespaceRegisteredForPrefix;
public static I18n pathAncestorDegreeIsInvalid;
public static I18n pathCannotBeNormalized;
public static I18n pathIsAlreadyAbsolute;
public static I18n pathIsNotAbsolute;
public static I18n pathIsNotRelative;
+ public static I18n repositoryConnectionPoolIsNotRunning;
public static I18n unableToCreateSubpathBeginIndexGreaterThanOrEqualToEndingIndex;
public static I18n unableToCreateSubpathBeginIndexGreaterThanOrEqualToSize;
public static I18n unableToCreateValue;
- public static I18n unableToDiscoverPropertyTypeForNullValue;
- public static I18n validPathMayNotContainEmptySegment;
- public static I18n valueJavaTypeNotCompatibleWithPropertyType;
-
- public static I18n maximumPoolSizeMayNotBeSmallerThanCorePoolSize;
- public static I18n repositoryConnectionPoolIsNotRunning;
+ public static I18n unableToDiscoverPropertyTypeForNullValue;
public static I18n unableToObtainValidRepositoryAfterAttempts;
- public static I18n closedConnectionMayNotBeUsed;
+ public static I18n validPathMayNotContainEmptySegment;
+ public static I18n valueJavaTypeNotCompatibleWithPropertyType;
static {
try {
Copied: branches/maeste/dna-spi/src/main/java/org/jboss/dna/spi/graph/IoException.java (from rev 263, trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/IoException.java)
===================================================================
--- branches/maeste/dna-spi/src/main/java/org/jboss/dna/spi/graph/IoException.java (rev 0)
+++ branches/maeste/dna-spi/src/main/java/org/jboss/dna/spi/graph/IoException.java 2008-06-11 08:45:51 UTC (rev 265)
@@ -0,0 +1,69 @@
+/*
+ * 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.spi.graph;
+
+/**
+ * @author Randall Hauch
+ * @author John Verhaeg
+ */
+public class IoException extends RuntimeException {
+
+ /**
+ *
+ */
+ public IoException() {
+ }
+
+ /**
+ * @param message
+ */
+ public IoException( String message ) {
+ super(message);
+
+ }
+
+ /**
+ * @param cause
+ */
+ public IoException( Throwable cause ) {
+ super(cause);
+
+ }
+
+ /**
+ * @param message
+ * @param cause
+ */
+ public IoException( String message,
+ Throwable cause ) {
+ super(message, cause);
+
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String toString() {
+ return super.toString();
+ }
+}
Modified: branches/maeste/dna-spi/src/main/java/org/jboss/dna/spi/graph/PropertyType.java
===================================================================
--- branches/maeste/dna-spi/src/main/java/org/jboss/dna/spi/graph/PropertyType.java 2008-06-11 08:35:21 UTC (rev 264)
+++ branches/maeste/dna-spi/src/main/java/org/jboss/dna/spi/graph/PropertyType.java 2008-06-11 08:45:51 UTC (rev 265)
@@ -2,7 +2,7 @@
* 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.
+ * 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
@@ -30,6 +30,7 @@
/**
* @author Randall Hauch
+ * @author John Verhaeg
*/
@Immutable
public enum PropertyType {
@@ -51,7 +52,9 @@
private final Comparator comparator;
private final Class valueClass;
- private PropertyType( String name, Comparator comparator, Class valueClass ) {
+ private PropertyType( String name,
+ Comparator comparator,
+ Class valueClass ) {
this.name = name;
this.comparator = comparator;
this.valueClass = valueClass;
@@ -90,7 +93,7 @@
public static PropertyType discoverType( Object value ) {
if (value == null) {
- throw new ValueFormatException(SpiI18n.unableToDiscoverPropertyTypeForNullValue.text());
+ throw new IllegalArgumentException(SpiI18n.unableToDiscoverPropertyTypeForNullValue.text());
}
for (PropertyType type : PropertyType.values()) {
if (type == OBJECT) continue;
Modified: branches/maeste/dna-spi/src/main/java/org/jboss/dna/spi/graph/ValueComparators.java
===================================================================
--- branches/maeste/dna-spi/src/main/java/org/jboss/dna/spi/graph/ValueComparators.java 2008-06-11 08:35:21 UTC (rev 264)
+++ branches/maeste/dna-spi/src/main/java/org/jboss/dna/spi/graph/ValueComparators.java 2008-06-11 08:45:51 UTC (rev 265)
@@ -116,7 +116,7 @@
if (numRead1 < 0) break;
int numRead2 = stream2.read(buffer2);
if (numRead1 != numRead2) {
- throw new ValueFormatException(SpiI18n.errorReadingPropertyValueBytes.text());
+ throw new IoException(SpiI18n.errorReadingPropertyValueBytes.text());
}
for (int i = 0; i != numRead1; ++i) {
int diff = buffer1[i] - buffer2[i];
@@ -125,7 +125,7 @@
}
return 0;
} catch (IOException e) {
- throw new ValueFormatException(SpiI18n.errorReadingPropertyValueBytes.text());
+ throw new IoException(SpiI18n.errorReadingPropertyValueBytes.text());
} finally {
if (stream1 != null) {
try {
Modified: branches/maeste/dna-spi/src/main/java/org/jboss/dna/spi/graph/ValueFactory.java
===================================================================
--- branches/maeste/dna-spi/src/main/java/org/jboss/dna/spi/graph/ValueFactory.java 2008-06-11 08:35:21 UTC (rev 264)
+++ branches/maeste/dna-spi/src/main/java/org/jboss/dna/spi/graph/ValueFactory.java 2008-06-11 08:45:51 UTC (rev 265)
@@ -32,10 +32,16 @@
import org.jboss.dna.common.text.TextEncoder;
/**
- * A factory for {@link Property} values. Some of the methods may throw a {@link ValueFormatException} if the parameter supplied
- * to the <code>create(...)</code> method cannot be converted to the {@link #getPropertyType() factory's type}.
+ * A factory for {@link Property} values. Each create method may throw one of these exceptions when attempting to convert a
+ * supplied value to the {@link #getPropertyType() factory's type}:
+ * <ul>
+ * <li>{@link IllegalArgumentException} - If the supplied value is invalid in respect to the conversion being attempted.</li>
+ * <li>{@link UnsupportedOperationException} - If a conversion from the supplied value is not supported.</li>
+ * <li>{@link IoException} - If an unexpected problem occurs during the conversion (such as an {@link IOException}).</li>
+ * </ul>
*
* @author Randall Hauch
+ * @author John Verhaeg
* @param <T> the type of value to create
*/
public interface ValueFactory<T> {
@@ -55,10 +61,10 @@
*
* @param value the string from which the value is to be created
* @return the value, or null if the supplied string is null
- * @throws ValueFormatException if the value could not be created from the supplied string
+ * @throws IoException If an unexpected problem occurs during the conversion.
* @see #create(String, TextDecoder)
*/
- T create( String value ) throws ValueFormatException;
+ T create( String value ) throws IoException;
/**
* Create a value from a string, using the supplied decoder.
@@ -66,127 +72,128 @@
* @param value the string from which the value is to be created
* @param decoder the decoder that should be used; if null, the {@link #DEFAULT_DECODER default decoder} is used
* @return the value, or null if the supplied string is null
- * @throws ValueFormatException if the value could not be created from the supplied string
+ * @throws IoException If an unexpected problem occurs during the conversion.
* @see #create(String)
*/
- T create( String value, TextDecoder decoder ) throws ValueFormatException;
+ T create( String value,
+ TextDecoder decoder ) throws IoException;
/**
* Create a value from an integer.
*
* @param value the integer from which the value is to be created
* @return the value; never null
- * @throws ValueFormatException if the value could not be created from the supplied integer
+ * @throws IoException If an unexpected problem occurs during the conversion.
*/
- T create( int value ) throws ValueFormatException;
+ T create( int value ) throws IoException;
/**
* Create a long from a string.
*
* @param value the string from which the long is to be created
* @return the value; never null
- * @throws ValueFormatException if the value could not be created from the supplied long
+ * @throws IoException If an unexpected problem occurs during the conversion.
*/
- T create( long value ) throws ValueFormatException;
+ T create( long value ) throws IoException;
/**
* Create a boolean from a string.
*
* @param value the boolean from which the value is to be created
* @return the value; never null
- * @throws ValueFormatException if the value could not be created from the supplied boolean
+ * @throws IoException If an unexpected problem occurs during the conversion.
*/
- T create( boolean value ) throws ValueFormatException;
+ T create( boolean value ) throws IoException;
/**
* Create a value from a float.
*
* @param value the float from which the value is to be created
* @return the value; never null
- * @throws ValueFormatException if the value could not be created from the supplied float
+ * @throws IoException If an unexpected problem occurs during the conversion.
*/
- T create( float value ) throws ValueFormatException;
+ T create( float value ) throws IoException;
/**
* Create a value from a double.
*
* @param value the double from which the value is to be created
* @return the value; never null
- * @throws ValueFormatException if the value could not be created from the supplied double
+ * @throws IoException If an unexpected problem occurs during the conversion.
*/
- T create( double value ) throws ValueFormatException;
+ T create( double value ) throws IoException;
/**
* Create a value from a decimal.
*
* @param value the decimal from which the value is to be created
* @return the value, or null if the supplied decimal is null
- * @throws ValueFormatException if the value could not be created from the supplied decimal
+ * @throws IoException If an unexpected problem occurs during the conversion.
*/
- T create( BigDecimal value ) throws ValueFormatException;
+ T create( BigDecimal value ) throws IoException;
/**
* Create a value from a Calendar instance.
*
* @param value the Calendar instance from which the value is to be created
* @return the value, or null if the supplied Calendar is null
- * @throws ValueFormatException if the value could not be created from the supplied Calendar object
+ * @throws IoException If an unexpected problem occurs during the conversion.
*/
- T create( Calendar value ) throws ValueFormatException;
+ T create( Calendar value ) throws IoException;
/**
* Create a value from a date.
*
* @param value the date from which the value is to be created
* @return the value, or null if the supplied date is null
- * @throws ValueFormatException if the value could not be created from the supplied date
+ * @throws IoException If an unexpected problem occurs during the conversion.
*/
- T create( Date value ) throws ValueFormatException;
+ T create( Date value ) throws IoException;
/**
* Create a value from a name.
*
* @param value the name from which the value is to be created
* @return the value, or null if the supplied name is null
- * @throws ValueFormatException if the value could not be created from the supplied name
+ * @throws IoException If an unexpected problem occurs during the conversion.
*/
- T create( Name value ) throws ValueFormatException;
+ T create( Name value ) throws IoException;
/**
* Create a value from a path.
*
* @param value the path from which the value is to be created
* @return the value, or null if the supplied path is null
- * @throws ValueFormatException if the value could not be created from the supplied path
+ * @throws IoException If an unexpected problem occurs during the conversion.
*/
- T create( Path value ) throws ValueFormatException;
+ T create( Path value ) throws IoException;
/**
* Create a value from a reference.
*
* @param value the reference from which the value is to be created
* @return the value, or null if the supplied reference is null
- * @throws ValueFormatException if the value could not be created from the supplied reference
+ * @throws IoException If an unexpected problem occurs during the conversion.
*/
- T create( Reference value ) throws ValueFormatException;
+ T create( Reference value ) throws IoException;
/**
* Create a value from a URI.
*
* @param value the URI from which the value is to be created
* @return the value, or null if the supplied URI is null
- * @throws ValueFormatException if the value could not be created from the supplied URI
+ * @throws IoException If an unexpected problem occurs during the conversion.
*/
- T create( URI value ) throws ValueFormatException;
+ T create( URI value ) throws IoException;
/**
* Create a value from the binary content given by the supplied array.
*
* @param value the content to be used to create the value
* @return the value, or null if the supplied stream is null
- * @throws ValueFormatException if the value could not be created from the supplied byte array
+ * @throws IoException If an unexpected problem occurs during the conversion.
*/
- T create( byte[] value ) throws ValueFormatException;
+ T create( byte[] value ) throws IoException;
/**
* Create a value from the binary content given by the supplied stream.
@@ -194,10 +201,10 @@
* @param stream the stream containing the content to be used to create the value
* @param approximateLength the approximate length of the content (in bytes)
* @return the value, or null if the supplied stream is null
- * @throws ValueFormatException if the value could not be created from the supplied stream
- * @throws IOException if there is a problem reading the stream
+ * @throws IoException If an unexpected problem occurs during the conversion (such as an {@link IOException}).
*/
- T create( InputStream stream, int approximateLength ) throws ValueFormatException, IOException;
+ T create( InputStream stream,
+ int approximateLength ) throws IoException;
/**
* Create a value from a the binary content given by the supplied reader.
@@ -205,10 +212,10 @@
* @param reader the reader containing the content to be used to create the value
* @param approximateLength the approximate length of the content (in bytes)
* @return the value, or null if the supplied string is null
- * @throws ValueFormatException if the value could not be created from the supplied reader
- * @throws IOException if there is a problem reading the stream
+ * @throws IoException If an unexpected problem occurs during the conversion (such as an {@link IOException}).
*/
- T create( Reader reader, int approximateLength ) throws ValueFormatException, IOException;
+ T create( Reader reader,
+ int approximateLength ) throws IoException;
/**
* Create a value from the specified information by determining which other <code>create</code> method applies and
@@ -217,8 +224,8 @@
*
* @param value the value
* @return the new value, or null if the supplied parameter is null
- * @throws ValueFormatException if the value could not be created from the supplied stream
+ * @throws IoException If an unexpected problem occurs during the conversion.
*/
- T create( Object value ) throws ValueFormatException;
+ T create( Object value ) throws IoException;
}
Deleted: branches/maeste/dna-spi/src/main/java/org/jboss/dna/spi/graph/ValueFormatException.java
===================================================================
--- branches/maeste/dna-spi/src/main/java/org/jboss/dna/spi/graph/ValueFormatException.java 2008-06-11 08:35:21 UTC (rev 264)
+++ branches/maeste/dna-spi/src/main/java/org/jboss/dna/spi/graph/ValueFormatException.java 2008-06-11 08:45:51 UTC (rev 265)
@@ -1,67 +0,0 @@
-/*
- * 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.spi.graph;
-
-/**
- * @author Randall Hauch
- */
-public class ValueFormatException extends RuntimeException {
-
- /**
- *
- */
- public ValueFormatException() {
- }
-
- /**
- * @param message
- */
- public ValueFormatException( String message ) {
- super(message);
-
- }
-
- /**
- * @param cause
- */
- public ValueFormatException( Throwable cause ) {
- super(cause);
-
- }
-
- /**
- * @param message
- * @param cause
- */
- public ValueFormatException( String message, Throwable cause ) {
- super(message, cause);
-
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String toString() {
- return super.toString();
- }
-}
Modified: branches/maeste/dna-spi/src/main/java/org/jboss/dna/spi/graph/connection/RepositoryConnectionPool.java
===================================================================
--- branches/maeste/dna-spi/src/main/java/org/jboss/dna/spi/graph/connection/RepositoryConnectionPool.java 2008-06-11 08:35:21 UTC (rev 264)
+++ branches/maeste/dna-spi/src/main/java/org/jboss/dna/spi/graph/connection/RepositoryConnectionPool.java 2008-06-11 08:45:51 UTC (rev 265)
@@ -21,14 +21,11 @@
*/
package org.jboss.dna.spi.graph.connection;
-import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.LinkedList;
-import java.util.List;
import java.util.Set;
import java.util.concurrent.BlockingQueue;
-import java.util.concurrent.Callable;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
@@ -40,7 +37,6 @@
import net.jcip.annotations.GuardedBy;
import net.jcip.annotations.ThreadSafe;
import org.jboss.dna.common.util.ArgCheck;
-import org.jboss.dna.common.util.LogContext;
import org.jboss.dna.common.util.Logger;
import org.jboss.dna.spi.SpiI18n;
import org.jboss.dna.spi.cache.CachePolicy;
@@ -405,104 +401,6 @@
}
// -------------------------------------------------
- // Utility methods ...
- // -------------------------------------------------
-
- /**
- * Call the supplied operation, using a connection from this pool.
- *
- * @param <T> the return type for the operation
- * @param operation the operation to be run using a connection in this pool
- * @return the results from the operation
- * @throws RepositorySourceException if there was an error obtaining the new connection
- * @throws InterruptedException if the thread was interrupted during the operation
- * @throws IllegalArgumentException if the operation is null
- * @see #callable(RepositoryOperation)
- * @see #callables(Iterable)
- * @see #callables(RepositoryOperation...)
- */
- public <T> T call( RepositoryOperation<T> operation ) throws RepositorySourceException, InterruptedException {
- ArgCheck.isNotNull(operation, "repository operation");
- // Get a connection ...
- T result = null;
- LogContext.set("context", operation.getName());
- RepositoryConnection conn = this.getConnection();
- try {
- // And run the client with the connection ...
- result = operation.run(conn);
- } finally {
- conn.close();
- }
- LogContext.clear();
- return result;
- }
-
- /**
- * Return a callable object that, when run, performs the supplied repository operation against a connection in this pool.
- *
- * @param <T> the return type for the operation
- * @param operation the operation to be run using a connection in this pool
- * @return the callable
- * @see #call(RepositoryOperation)
- * @see #callables(Iterable)
- * @see #callables(RepositoryOperation...)
- */
- public <T> Callable<T> callable( final RepositoryOperation<T> operation ) {
- ArgCheck.isNotNull(operation, "repository operation");
- final RepositoryConnectionPool pool = this;
- return new Callable<T>() {
-
- /**
- * Execute by getting a connection from this pool, running the client, and return the connection to the pool.
- *
- * @return the operation's result
- * @throws Exception
- */
- public T call() throws Exception {
- return pool.call(operation);
- }
- };
- }
-
- /**
- * Return a collection of callable objects that, when run, perform the supplied repository operations against connections in
- * this pool.
- *
- * @param <T> the return type for the operations
- * @param operations the operations to be run using connection from this pool
- * @return the collection of callables
- * @see #call(RepositoryOperation)
- * @see #callable(RepositoryOperation)
- * @see #callables(Iterable)
- */
- public <T> List<Callable<T>> callables( RepositoryOperation<T>... operations ) {
- List<Callable<T>> callables = new ArrayList<Callable<T>>();
- for (final RepositoryOperation<T> operation : operations) {
- callables.add(callable(operation));
- }
- return callables;
- }
-
- /**
- * Return a collection of callable objects that, when run, perform the supplied repository operations against connections in
- * this pool.
- *
- * @param <T> the return type for the operations
- * @param operations the operations to be run using connection from this pool
- * @return the collection of callables
- * @see #call(RepositoryOperation)
- * @see #callable(RepositoryOperation)
- * @see #callables(RepositoryOperation...)
- */
- public <T> List<Callable<T>> callables( Iterable<RepositoryOperation<T>> operations ) {
- List<Callable<T>> callables = new ArrayList<Callable<T>>();
- for (final RepositoryOperation<T> operation : operations) {
- callables.add(callable(operation));
- }
- return callables;
- }
-
- // -------------------------------------------------
// State management methods ...
// -------------------------------------------------
@@ -956,7 +854,7 @@
@GuardedBy( "mainLock" )
protected int drainUnusedConnections( int count ) {
if (count <= 0) return 0;
- this.logger.trace("Draining up to {} unused repository connections to {0}", count, getName());
+ this.logger.trace("Draining up to {0} unused repository connections to {1}", count, getName());
// Drain the extra connections from those available ...
Collection<ConnectionWrapper> extraConnections = new LinkedList<ConnectionWrapper>();
this.availableConnections.drainTo(extraConnections, count);
Modified: branches/maeste/dna-spi/src/main/java/org/jboss/dna/spi/graph/connection/RepositoryOperation.java
===================================================================
--- branches/maeste/dna-spi/src/main/java/org/jboss/dna/spi/graph/connection/RepositoryOperation.java 2008-06-11 08:35:21 UTC (rev 264)
+++ branches/maeste/dna-spi/src/main/java/org/jboss/dna/spi/graph/connection/RepositoryOperation.java 2008-06-11 08:45:51 UTC (rev 265)
@@ -22,18 +22,43 @@
package org.jboss.dna.spi.graph.connection;
/**
+ * An operation that runs against a repository connection.
+ *
* @author Randall Hauch
* @param <T> the type of result returned by the client
*/
public interface RepositoryOperation<T> {
+ /**
+ * Get the name of this operation.
+ *
+ * @return the operation's name
+ */
String getName();
+ /**
+ * Run the operation using the supplied connection.
+ *
+ * @param connection the connection; may not be null
+ * @return the result of the operation
+ * @throws RepositorySourceException if there is a problem with the connection
+ * @throws InterruptedException if this thread was interrupted
+ */
T run( RepositoryConnection connection ) throws RepositorySourceException, InterruptedException;
+ /**
+ * A factory interface for creating repository operations.
+ *
+ * @param <T> the type of result for the operations
+ * @author Randall Hauch
+ */
public static interface Factory<T> {
+ /**
+ * Create a repository operation that returns the result of type T.
+ *
+ * @return the operation
+ */
RepositoryOperation<T> create();
}
-
}
Copied: branches/maeste/dna-spi/src/main/java/org/jboss/dna/spi/graph/connection/RepositoryOperations.java (from rev 263, trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/connection/RepositoryOperations.java)
===================================================================
--- branches/maeste/dna-spi/src/main/java/org/jboss/dna/spi/graph/connection/RepositoryOperations.java (rev 0)
+++ branches/maeste/dna-spi/src/main/java/org/jboss/dna/spi/graph/connection/RepositoryOperations.java 2008-06-11 08:45:51 UTC (rev 265)
@@ -0,0 +1,155 @@
+/*
+ * 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.spi.graph.connection;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.concurrent.Callable;
+import org.jboss.dna.common.util.ArgCheck;
+import org.jboss.dna.common.util.LogContext;
+
+/**
+ * @author Randall Hauch
+ */
+public class RepositoryOperations {
+
+ /**
+ * Call the supplied operation, using a connection from this pool.
+ *
+ * @param <T> the return type for the operation
+ * @param connectionFactory the factory for the connection to use
+ * @param operation the operation to be run using a new connection obtained from the factory
+ * @return the results from the operation
+ * @throws RepositorySourceException if there was an error obtaining the new connection
+ * @throws InterruptedException if the thread was interrupted during the operation
+ * @throws IllegalArgumentException if the operation is null
+ * @see #createCallable(RepositoryConnectionFactory, RepositoryOperation)
+ * @see #createCallables(RepositoryConnectionFactory, Iterable)
+ * @see #createCallables(RepositoryConnectionFactory, RepositoryOperation...)
+ */
+ public static <T> T call( RepositoryConnectionFactory connectionFactory, RepositoryOperation<T> operation ) throws RepositorySourceException, InterruptedException {
+ ArgCheck.isNotNull(operation, "repository operation");
+ // Get a connection ...
+ T result = null;
+ LogContext.set("context", operation.getName());
+ RepositoryConnection conn = connectionFactory.getConnection();
+ try {
+ // And run the client with the connection ...
+ result = operation.run(conn);
+ } finally {
+ conn.close();
+ }
+ LogContext.clear();
+ return result;
+ }
+
+ /**
+ * Return a callable object that, when run, performs the supplied repository operation against a connection obtained from the
+ * supplied factory.
+ *
+ * @param <T> the return type for the operation
+ * @param connectionFactory the factory for the connection to use
+ * @param operation the operation to be run using a new connection obtained from the factory
+ * @return the callable
+ * @see #call(RepositoryConnectionFactory, RepositoryOperation)
+ * @see #createCallables(RepositoryConnectionFactory, Iterable)
+ * @see #createCallables(RepositoryConnectionFactory, RepositoryOperation...)
+ */
+ public static <T> Callable<T> createCallable( final RepositoryConnectionFactory connectionFactory, final RepositoryOperation<T> operation ) {
+ ArgCheck.isNotNull(operation, "repository operation");
+ return new Callable<T>() {
+
+ /**
+ * Execute by getting a connection from this pool, running the client, and return the connection to the pool.
+ *
+ * @return the operation's result
+ * @throws Exception
+ */
+ public T call() throws Exception {
+ return RepositoryOperations.call(connectionFactory, operation);
+ }
+ };
+ }
+
+ /**
+ * Return a collection of callable objects that, when run, perform the supplied repository operations against connections in
+ * this pool.
+ *
+ * @param <T> the return type for the operations
+ * @param connectionFactory the factory for the connection to use
+ * @param operations the operations to be run using connections from the factory
+ * @return the collection of callables
+ * @see #call(RepositoryConnectionFactory, RepositoryOperation)
+ * @see #createCallable(RepositoryConnectionFactory, RepositoryOperation)
+ * @see #createCallables(RepositoryConnectionFactory, Iterable)
+ */
+ public static <T> List<Callable<T>> createCallables( final RepositoryConnectionFactory connectionFactory, final RepositoryOperation<T>... operations ) {
+ List<Callable<T>> callables = new ArrayList<Callable<T>>();
+ for (final RepositoryOperation<T> operation : operations) {
+ callables.add(createCallable(connectionFactory, operation));
+ }
+ return callables;
+ }
+
+ /**
+ * Return a collection of callable objects that, when run, perform the supplied repository operations against connections in
+ * this pool.
+ *
+ * @param <T> the return type for the operations
+ * @param connectionFactory the factory for the connection to use
+ * @param operations the operations to be run using connections from the factory
+ * @return the collection of callables
+ * @see #call(RepositoryConnectionFactory, RepositoryOperation)
+ * @see #createCallable(RepositoryConnectionFactory, RepositoryOperation)
+ * @see #createCallables(RepositoryConnectionFactory, RepositoryOperation...)
+ */
+ public static <T> List<Callable<T>> createCallables( final RepositoryConnectionFactory connectionFactory, Iterable<RepositoryOperation<T>> operations ) {
+ List<Callable<T>> callables = new ArrayList<Callable<T>>();
+ for (final RepositoryOperation<T> operation : operations) {
+ callables.add(createCallable(connectionFactory, operation));
+ }
+ return callables;
+ }
+
+ /**
+ * Return a collection of callable objects that, when run, perform the supplied repository operations against connections in
+ * this pool.
+ *
+ * @param <T> the return type for the operations
+ * @param connectionFactory the factory for the connection to use
+ * @param operations the operations to be run using connections from the factory
+ * @return the collection of callables
+ * @see #call(RepositoryConnectionFactory, RepositoryOperation)
+ * @see #createCallable(RepositoryConnectionFactory, RepositoryOperation)
+ * @see #createCallables(RepositoryConnectionFactory, RepositoryOperation...)
+ */
+ public static <T> List<Callable<T>> createCallables( final RepositoryConnectionFactory connectionFactory, Iterator<RepositoryOperation<T>> operations ) {
+ List<Callable<T>> callables = new ArrayList<Callable<T>>();
+ while (operations.hasNext()) {
+ final RepositoryOperation<T> operation = operations.next();
+ callables.add(createCallable(connectionFactory, operation));
+ }
+ return callables;
+ }
+
+}
Modified: branches/maeste/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/AbstractValueFactory.java
===================================================================
--- branches/maeste/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/AbstractValueFactory.java 2008-06-11 08:35:21 UTC (rev 264)
+++ branches/maeste/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/AbstractValueFactory.java 2008-06-11 08:45:51 UTC (rev 265)
@@ -21,7 +21,6 @@
*/
package org.jboss.dna.spi.graph.impl;
-import java.io.IOException;
import java.io.InputStream;
import java.io.Reader;
import java.math.BigDecimal;
@@ -36,12 +35,12 @@
import org.jboss.dna.spi.graph.PropertyType;
import org.jboss.dna.spi.graph.Reference;
import org.jboss.dna.spi.graph.ValueFactory;
-import org.jboss.dna.spi.graph.ValueFormatException;
/**
* Abstract {@link ValueFactory}.
*
* @author Randall Hauch
+ * @author John Verhaeg
* @param <T> the property type
*/
@Immutable
@@ -51,7 +50,9 @@
private final PropertyType propertyType;
private final ValueFactory<String> stringValueFactory;
- protected AbstractValueFactory( PropertyType type, TextDecoder decoder, ValueFactory<String> stringValueFactory ) {
+ protected AbstractValueFactory( PropertyType type,
+ TextDecoder decoder,
+ ValueFactory<String> stringValueFactory ) {
ArgCheck.isNotNull(type, "type");
this.propertyType = type;
this.decoder = decoder != null ? decoder : DEFAULT_DECODER;
@@ -94,7 +95,7 @@
/**
* {@inheritDoc}
*/
- public T create( Object value ) throws ValueFormatException {
+ public T create( Object value ) {
if (value == null) return null;
if (value instanceof String) return create((String)value);
if (value instanceof Integer) return create(((Integer)value).intValue());
@@ -110,20 +111,8 @@
if (value instanceof Reference) return create((Reference)value);
if (value instanceof URI) return create((URI)value);
if (value instanceof byte[]) return create((byte[])value);
- if (value instanceof InputStream) {
- try {
- return create((InputStream)value, 0);
- } catch (IOException e) {
- throw new ValueFormatException(e);
- }
- }
- if (value instanceof Reader) {
- try {
- return create((Reader)value, 0);
- } catch (IOException e) {
- throw new ValueFormatException(e);
- }
- }
+ if (value instanceof InputStream) return create((InputStream)value, 0);
+ if (value instanceof Reader) return create((Reader)value, 0);
return create(value.toString());
}
Modified: branches/maeste/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/BooleanValueFactory.java
===================================================================
--- branches/maeste/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/BooleanValueFactory.java 2008-06-11 08:35:21 UTC (rev 264)
+++ branches/maeste/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/BooleanValueFactory.java 2008-06-11 08:45:51 UTC (rev 265)
@@ -2,7 +2,7 @@
* 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.
+ * 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
@@ -21,7 +21,6 @@
*/
package org.jboss.dna.spi.graph.impl;
-import java.io.IOException;
import java.io.InputStream;
import java.io.Reader;
import java.math.BigDecimal;
@@ -36,17 +35,18 @@
import org.jboss.dna.spi.graph.PropertyType;
import org.jboss.dna.spi.graph.Reference;
import org.jboss.dna.spi.graph.ValueFactory;
-import org.jboss.dna.spi.graph.ValueFormatException;
/**
* The standard {@link ValueFactory} for {@link PropertyType#BOOLEAN} values.
*
* @author Randall Hauch
+ * @author John Verhaeg
*/
@Immutable
public class BooleanValueFactory extends AbstractValueFactory<Boolean> {
- public BooleanValueFactory( TextDecoder decoder, ValueFactory<String> stringValueFactory ) {
+ public BooleanValueFactory( TextDecoder decoder,
+ ValueFactory<String> stringValueFactory ) {
super(PropertyType.BOOLEAN, decoder, stringValueFactory);
}
@@ -61,7 +61,8 @@
/**
* {@inheritDoc}
*/
- public Boolean create( String value, TextDecoder decoder ) {
+ public Boolean create( String value,
+ TextDecoder decoder ) {
// this probably doesn't really need to call the decoder, but by doing so then we don't care at all what the decoder does
return create(getDecoder(decoder).decode(value));
}
@@ -69,15 +70,19 @@
/**
* {@inheritDoc}
*/
- public Boolean create( int value ) throws ValueFormatException {
- throw new ValueFormatException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(), Integer.class.getSimpleName(), value));
+ public Boolean create( int value ) {
+ throw new UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+ Integer.class.getSimpleName(),
+ value));
}
/**
* {@inheritDoc}
*/
- public Boolean create( long value ) throws ValueFormatException {
- throw new ValueFormatException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(), Long.class.getSimpleName(), value));
+ public Boolean create( long value ) {
+ throw new UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+ Long.class.getSimpleName(),
+ value));
}
/**
@@ -90,70 +95,88 @@
/**
* {@inheritDoc}
*/
- public Boolean create( float value ) throws ValueFormatException {
- throw new ValueFormatException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(), Float.class.getSimpleName(), value));
+ public Boolean create( float value ) {
+ throw new UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+ Float.class.getSimpleName(),
+ value));
}
/**
* {@inheritDoc}
*/
- public Boolean create( double value ) throws ValueFormatException {
- throw new ValueFormatException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(), Double.class.getSimpleName(), value));
+ public Boolean create( double value ) {
+ throw new UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+ Double.class.getSimpleName(),
+ value));
}
/**
* {@inheritDoc}
*/
- public Boolean create( BigDecimal value ) throws ValueFormatException {
- throw new ValueFormatException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(), BigDecimal.class.getSimpleName(), value));
+ public Boolean create( BigDecimal value ) {
+ throw new UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+ BigDecimal.class.getSimpleName(),
+ value));
}
/**
* {@inheritDoc}
*/
- public Boolean create( Calendar value ) throws ValueFormatException {
- throw new ValueFormatException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(), Calendar.class.getSimpleName(), value));
+ public Boolean create( Calendar value ) {
+ throw new UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+ Calendar.class.getSimpleName(),
+ value));
}
/**
* {@inheritDoc}
*/
- public Boolean create( Date value ) throws ValueFormatException {
- throw new ValueFormatException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(), Date.class.getSimpleName(), value));
+ public Boolean create( Date value ) {
+ throw new UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+ Date.class.getSimpleName(),
+ value));
}
/**
* {@inheritDoc}
*/
- public Boolean create( Name value ) throws ValueFormatException {
- throw new ValueFormatException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(), Name.class.getSimpleName(), value));
+ public Boolean create( Name value ) {
+ throw new UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+ Name.class.getSimpleName(),
+ value));
}
/**
* {@inheritDoc}
*/
- public Boolean create( Path value ) throws ValueFormatException {
- throw new ValueFormatException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(), Path.class.getSimpleName(), value));
+ public Boolean create( Path value ) {
+ throw new UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+ Path.class.getSimpleName(),
+ value));
}
/**
* {@inheritDoc}
*/
- public Boolean create( Reference value ) throws ValueFormatException {
- throw new ValueFormatException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(), Reference.class.getSimpleName(), value));
+ public Boolean create( Reference value ) {
+ throw new UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+ Reference.class.getSimpleName(),
+ value));
}
/**
* {@inheritDoc}
*/
- public Boolean create( URI value ) throws ValueFormatException {
- throw new ValueFormatException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(), URI.class.getSimpleName(), value));
+ public Boolean create( URI value ) {
+ throw new UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+ URI.class.getSimpleName(),
+ value));
}
/**
* {@inheritDoc}
*/
- public Boolean create( byte[] value ) throws ValueFormatException {
+ public Boolean create( byte[] value ) {
// First create a string and then create the boolean from the string value ...
return create(getStringValueFactory().create(value));
}
@@ -161,7 +184,8 @@
/**
* {@inheritDoc}
*/
- public Boolean create( InputStream stream, int approximateLength ) throws IOException, ValueFormatException {
+ public Boolean create( InputStream stream,
+ int approximateLength ) {
// First create a string and then create the boolean from the string value ...
return create(getStringValueFactory().create(stream, approximateLength));
}
@@ -169,7 +193,8 @@
/**
* {@inheritDoc}
*/
- public Boolean create( Reader reader, int approximateLength ) throws IOException, ValueFormatException {
+ public Boolean create( Reader reader,
+ int approximateLength ) {
// First create a string and then create the boolean from the string value ...
return create(getStringValueFactory().create(reader, approximateLength));
}
Modified: branches/maeste/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/DecimalValueFactory.java
===================================================================
--- branches/maeste/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/DecimalValueFactory.java 2008-06-11 08:35:21 UTC (rev 264)
+++ branches/maeste/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/DecimalValueFactory.java 2008-06-11 08:45:51 UTC (rev 265)
@@ -2,7 +2,7 @@
* 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.
+ * 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
@@ -21,7 +21,6 @@
*/
package org.jboss.dna.spi.graph.impl;
-import java.io.IOException;
import java.io.InputStream;
import java.io.Reader;
import java.math.BigDecimal;
@@ -36,36 +35,40 @@
import org.jboss.dna.spi.graph.PropertyType;
import org.jboss.dna.spi.graph.Reference;
import org.jboss.dna.spi.graph.ValueFactory;
-import org.jboss.dna.spi.graph.ValueFormatException;
/**
* The standard {@link ValueFactory} for {@link PropertyType#DECIMAL} values.
*
* @author Randall Hauch
+ * @author John Verhaeg
*/
@Immutable
public class DecimalValueFactory extends AbstractValueFactory<BigDecimal> {
- public DecimalValueFactory( TextDecoder decoder, ValueFactory<String> stringValueFactory ) {
+ public DecimalValueFactory( TextDecoder decoder,
+ ValueFactory<String> stringValueFactory ) {
super(PropertyType.DECIMAL, decoder, stringValueFactory);
}
/**
* {@inheritDoc}
*/
- public BigDecimal create( String value ) throws ValueFormatException {
+ public BigDecimal create( String value ) {
if (value == null) return null;
try {
return new BigDecimal(value.trim());
- } catch (NumberFormatException e) {
- throw new ValueFormatException(SpiI18n.errorCreatingValue.text(getPropertyType().getName(), String.class.getSimpleName(), value), e);
+ } catch (NumberFormatException err) {
+ throw new IllegalArgumentException(SpiI18n.errorConvertingType.text(String.class.getSimpleName(),
+ BigDecimal.class.getSimpleName(),
+ value), err);
}
}
/**
* {@inheritDoc}
*/
- public BigDecimal create( String value, TextDecoder decoder ) {
+ public BigDecimal create( String value,
+ TextDecoder decoder ) {
// this probably doesn't really need to call the decoder, but by doing so then we don't care at all what the decoder does
return create(getDecoder(decoder).decode(value.trim()));
}
@@ -87,8 +90,10 @@
/**
* {@inheritDoc}
*/
- public BigDecimal create( boolean value ) throws ValueFormatException {
- throw new ValueFormatException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(), Boolean.class.getSimpleName(), value));
+ public BigDecimal create( boolean value ) {
+ throw new UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+ Boolean.class.getSimpleName(),
+ value));
}
/**
@@ -131,35 +136,43 @@
/**
* {@inheritDoc}
*/
- public BigDecimal create( Name value ) throws ValueFormatException {
- throw new ValueFormatException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(), Name.class.getSimpleName(), value));
+ public BigDecimal create( Name value ) {
+ throw new UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+ Name.class.getSimpleName(),
+ value));
}
/**
* {@inheritDoc}
*/
- public BigDecimal create( Path value ) throws ValueFormatException {
- throw new ValueFormatException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(), Path.class.getSimpleName(), value));
+ public BigDecimal create( Path value ) {
+ throw new UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+ Path.class.getSimpleName(),
+ value));
}
/**
* {@inheritDoc}
*/
- public BigDecimal create( Reference value ) throws ValueFormatException {
- throw new ValueFormatException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(), Reference.class.getSimpleName(), value));
+ public BigDecimal create( Reference value ) {
+ throw new UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+ Reference.class.getSimpleName(),
+ value));
}
/**
* {@inheritDoc}
*/
- public BigDecimal create( URI value ) throws ValueFormatException {
- throw new ValueFormatException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(), URI.class.getSimpleName(), value));
+ public BigDecimal create( URI value ) {
+ throw new UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+ URI.class.getSimpleName(),
+ value));
}
/**
* {@inheritDoc}
*/
- public BigDecimal create( byte[] value ) throws ValueFormatException {
+ public BigDecimal create( byte[] value ) {
// First attempt to create a string from the value, then a long from the string ...
return create(getStringValueFactory().create(value));
}
@@ -167,7 +180,8 @@
/**
* {@inheritDoc}
*/
- public BigDecimal create( InputStream stream, int approximateLength ) throws IOException, ValueFormatException {
+ public BigDecimal create( InputStream stream,
+ int approximateLength ) {
// First attempt to create a string from the value, then a double from the string ...
return create(getStringValueFactory().create(stream, approximateLength));
}
@@ -175,7 +189,8 @@
/**
* {@inheritDoc}
*/
- public BigDecimal create( Reader reader, int approximateLength ) throws IOException, ValueFormatException {
+ public BigDecimal create( Reader reader,
+ int approximateLength ) {
// First attempt to create a string from the value, then a double from the string ...
return create(getStringValueFactory().create(reader, approximateLength));
}
Modified: branches/maeste/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/DoubleValueFactory.java
===================================================================
--- branches/maeste/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/DoubleValueFactory.java 2008-06-11 08:35:21 UTC (rev 264)
+++ branches/maeste/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/DoubleValueFactory.java 2008-06-11 08:45:51 UTC (rev 265)
@@ -21,7 +21,6 @@
*/
package org.jboss.dna.spi.graph.impl;
-import java.io.IOException;
import java.io.InputStream;
import java.io.Reader;
import java.math.BigDecimal;
@@ -36,36 +35,40 @@
import org.jboss.dna.spi.graph.PropertyType;
import org.jboss.dna.spi.graph.Reference;
import org.jboss.dna.spi.graph.ValueFactory;
-import org.jboss.dna.spi.graph.ValueFormatException;
/**
* The standard {@link ValueFactory} for {@link PropertyType#DOUBLE} values.
*
* @author Randall Hauch
+ * @author John Verhaeg
*/
@Immutable
public class DoubleValueFactory extends AbstractValueFactory<Double> {
- public DoubleValueFactory( TextDecoder decoder, ValueFactory<String> stringValueFactory ) {
+ public DoubleValueFactory( TextDecoder decoder,
+ ValueFactory<String> stringValueFactory ) {
super(PropertyType.DOUBLE, decoder, stringValueFactory);
}
/**
* {@inheritDoc}
*/
- public Double create( String value ) throws ValueFormatException {
+ public Double create( String value ) {
if (value == null) return null;
try {
return Double.valueOf(value.trim());
- } catch (NumberFormatException e) {
- throw new ValueFormatException(SpiI18n.errorCreatingValue.text(getPropertyType().getName(), String.class.getSimpleName(), value), e);
+ } catch (NumberFormatException err) {
+ throw new IllegalArgumentException(SpiI18n.errorConvertingType.text(String.class.getSimpleName(),
+ Double.class.getSimpleName(),
+ value), err);
}
}
/**
* {@inheritDoc}
*/
- public Double create( String value, TextDecoder decoder ) {
+ public Double create( String value,
+ TextDecoder decoder ) {
// this probably doesn't really need to call the decoder, but by doing so then we don't care at all what the decoder does
return create(getDecoder(decoder).decode(value));
}
@@ -87,8 +90,10 @@
/**
* {@inheritDoc}
*/
- public Double create( boolean value ) throws ValueFormatException {
- throw new ValueFormatException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(), Double.class.getSimpleName(), value));
+ public Double create( boolean value ) {
+ throw new UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+ Double.class.getSimpleName(),
+ value));
}
/**
@@ -108,11 +113,13 @@
/**
* {@inheritDoc}
*/
- public Double create( BigDecimal value ) throws ValueFormatException {
+ public Double create( BigDecimal value ) {
if (value == null) return null;
double result = value.doubleValue();
if (result == Double.NEGATIVE_INFINITY || result == Double.POSITIVE_INFINITY) {
- throw new ValueFormatException(SpiI18n.errorCreatingValue.text(getPropertyType().getName(), String.class.getSimpleName(), value));
+ throw new IllegalArgumentException(SpiI18n.errorConvertingType.text(BigDecimal.class.getSimpleName(),
+ Double.class.getSimpleName(),
+ value));
}
return result;
}
@@ -136,35 +143,43 @@
/**
* {@inheritDoc}
*/
- public Double create( Name value ) throws ValueFormatException {
- throw new ValueFormatException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(), Name.class.getSimpleName(), value));
+ public Double create( Name value ) {
+ throw new UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+ Name.class.getSimpleName(),
+ value));
}
/**
* {@inheritDoc}
*/
- public Double create( Path value ) throws ValueFormatException {
- throw new ValueFormatException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(), Path.class.getSimpleName(), value));
+ public Double create( Path value ) {
+ throw new UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+ Path.class.getSimpleName(),
+ value));
}
/**
* {@inheritDoc}
*/
- public Double create( Reference value ) throws ValueFormatException {
- throw new ValueFormatException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(), Reference.class.getSimpleName(), value));
+ public Double create( Reference value ) {
+ throw new UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+ Reference.class.getSimpleName(),
+ value));
}
/**
* {@inheritDoc}
*/
- public Double create( URI value ) throws ValueFormatException {
- throw new ValueFormatException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(), URI.class.getSimpleName(), value));
+ public Double create( URI value ) {
+ throw new UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+ URI.class.getSimpleName(),
+ value));
}
/**
* {@inheritDoc}
*/
- public Double create( byte[] value ) throws ValueFormatException {
+ public Double create( byte[] value ) {
// First attempt to create a string from the value, then a long from the string ...
return create(getStringValueFactory().create(value));
}
@@ -172,7 +187,8 @@
/**
* {@inheritDoc}
*/
- public Double create( InputStream stream, int approximateLength ) throws IOException, ValueFormatException {
+ public Double create( InputStream stream,
+ int approximateLength ) {
// First attempt to create a string from the value, then a double from the string ...
return create(getStringValueFactory().create(stream, approximateLength));
}
@@ -180,7 +196,8 @@
/**
* {@inheritDoc}
*/
- public Double create( Reader reader, int approximateLength ) throws IOException, ValueFormatException {
+ public Double create( Reader reader,
+ int approximateLength ) {
// First attempt to create a string from the value, then a double from the string ...
return create(getStringValueFactory().create(reader, approximateLength));
}
Modified: branches/maeste/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/InMemoryBinaryValueFactory.java
===================================================================
--- branches/maeste/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/InMemoryBinaryValueFactory.java 2008-06-11 08:35:21 UTC (rev 264)
+++ branches/maeste/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/InMemoryBinaryValueFactory.java 2008-06-11 08:45:51 UTC (rev 265)
@@ -39,38 +39,43 @@
import org.jboss.dna.spi.graph.PropertyType;
import org.jboss.dna.spi.graph.Reference;
import org.jboss.dna.spi.graph.ValueFactory;
-import org.jboss.dna.spi.graph.ValueFormatException;
+import org.jboss.dna.spi.graph.IoException;
/**
* Teh standard {@link ValueFactory} for {@link PropertyType#BINARY} values.
*
* @author Randall Hauch
+ * @author John Verhaeg
*/
@Immutable
public class InMemoryBinaryValueFactory extends AbstractValueFactory<Binary> {
private static final String CHAR_SET_NAME = "UTF-8";
- public InMemoryBinaryValueFactory( TextDecoder decoder, ValueFactory<String> stringValueFactory ) {
+ public InMemoryBinaryValueFactory( TextDecoder decoder,
+ ValueFactory<String> stringValueFactory ) {
super(PropertyType.BINARY, decoder, stringValueFactory);
}
/**
* {@inheritDoc}
*/
- public Binary create( String value ) throws ValueFormatException {
+ public Binary create( String value ) {
if (value == null) return null;
try {
return create(value.getBytes(CHAR_SET_NAME));
- } catch (UnsupportedEncodingException e) {
- throw new ValueFormatException(SpiI18n.errorConvertingBinaryValueToString.text());
+ } catch (UnsupportedEncodingException err) {
+ throw new IllegalArgumentException(SpiI18n.errorConvertingType.text(String.class.getSimpleName(),
+ Binary.class.getSimpleName(),
+ value), err);
}
}
/**
* {@inheritDoc}
*/
- public Binary create( String value, TextDecoder decoder ) throws ValueFormatException {
+ public Binary create( String value,
+ TextDecoder decoder ) {
if (value == null) return null;
return create(getDecoder(decoder).decode(value));
}
@@ -78,7 +83,7 @@
/**
* {@inheritDoc}
*/
- public Binary create( int value ) throws ValueFormatException {
+ public Binary create( int value ) {
// Convert the value to a string, then to a binary ...
return create(this.getStringValueFactory().create(value));
}
@@ -86,7 +91,7 @@
/**
* {@inheritDoc}
*/
- public Binary create( long value ) throws ValueFormatException {
+ public Binary create( long value ) {
// Convert the value to a string, then to a binary ...
return create(this.getStringValueFactory().create(value));
}
@@ -94,7 +99,7 @@
/**
* {@inheritDoc}
*/
- public Binary create( boolean value ) throws ValueFormatException {
+ public Binary create( boolean value ) {
// Convert the value to a string, then to a binary ...
return create(this.getStringValueFactory().create(value));
}
@@ -102,7 +107,7 @@
/**
* {@inheritDoc}
*/
- public Binary create( float value ) throws ValueFormatException {
+ public Binary create( float value ) {
// Convert the value to a string, then to a binary ...
return create(this.getStringValueFactory().create(value));
}
@@ -110,7 +115,7 @@
/**
* {@inheritDoc}
*/
- public Binary create( double value ) throws ValueFormatException {
+ public Binary create( double value ) {
// Convert the value to a string, then to a binary ...
return create(this.getStringValueFactory().create(value));
}
@@ -118,7 +123,7 @@
/**
* {@inheritDoc}
*/
- public Binary create( BigDecimal value ) throws ValueFormatException {
+ public Binary create( BigDecimal value ) {
// Convert the value to a string, then to a binary ...
return create(this.getStringValueFactory().create(value));
}
@@ -126,7 +131,7 @@
/**
* {@inheritDoc}
*/
- public Binary create( Calendar value ) throws ValueFormatException {
+ public Binary create( Calendar value ) {
// Convert the value to a string, then to a binary ...
return create(this.getStringValueFactory().create(value));
}
@@ -134,7 +139,7 @@
/**
* {@inheritDoc}
*/
- public Binary create( Date value ) throws ValueFormatException {
+ public Binary create( Date value ) {
// Convert the value to a string, then to a binary ...
return create(this.getStringValueFactory().create(value));
}
@@ -142,7 +147,7 @@
/**
* {@inheritDoc}
*/
- public Binary create( Name value ) throws ValueFormatException {
+ public Binary create( Name value ) {
// Convert the value to a string, then to a binary ...
return create(this.getStringValueFactory().create(value));
}
@@ -150,7 +155,7 @@
/**
* {@inheritDoc}
*/
- public Binary create( Path value ) throws ValueFormatException {
+ public Binary create( Path value ) {
// Convert the value to a string, then to a binary ...
return create(this.getStringValueFactory().create(value));
}
@@ -158,7 +163,7 @@
/**
* {@inheritDoc}
*/
- public Binary create( Reference value ) throws ValueFormatException {
+ public Binary create( Reference value ) {
// Convert the value to a string, then to a binary ...
return create(this.getStringValueFactory().create(value));
}
@@ -166,7 +171,7 @@
/**
* {@inheritDoc}
*/
- public Binary create( URI value ) throws ValueFormatException {
+ public Binary create( URI value ) {
// Convert the value to a string, then to a binary ...
return create(this.getStringValueFactory().create(value));
}
@@ -174,27 +179,38 @@
/**
* {@inheritDoc}
*/
- public Binary create( byte[] value ) throws ValueFormatException {
+ public Binary create( byte[] value ) {
return new InMemoryBinary(value);
}
/**
* {@inheritDoc}
*/
- public Binary create( InputStream stream, int approximateLength ) throws IOException {
+ public Binary create( InputStream stream,
+ int approximateLength ) {
if (stream == null) return null;
- byte[] value = IoUtil.readBytes(stream);
- return create(value);
+ try {
+ byte[] value = IoUtil.readBytes(stream);
+ return create(value);
+ } catch (IOException err) {
+ throw new IoException(SpiI18n.errorConvertingIo.text(InputStream.class.getSimpleName(),
+ Binary.class.getSimpleName()), err);
+ }
}
/**
* {@inheritDoc}
*/
- public Binary create( Reader reader, int approximateLength ) throws IOException {
+ public Binary create( Reader reader,
+ int approximateLength ) {
if (reader == null) return null;
// Convert the value to a string, then to a binary ...
- String value = IoUtil.read(reader);
- return create(this.getStringValueFactory().create(value));
+ try {
+ String value = IoUtil.read(reader);
+ return create(this.getStringValueFactory().create(value));
+ } catch (IOException err) {
+ throw new IoException(SpiI18n.errorConvertingIo.text(Reader.class.getSimpleName(),
+ Binary.class.getSimpleName()), err);
+ }
}
-
}
Modified: branches/maeste/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/JodaDateTimeValueFactory.java
===================================================================
--- branches/maeste/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/JodaDateTimeValueFactory.java 2008-06-11 08:35:21 UTC (rev 264)
+++ branches/maeste/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/JodaDateTimeValueFactory.java 2008-06-11 08:45:51 UTC (rev 265)
@@ -21,7 +21,6 @@
*/
package org.jboss.dna.spi.graph.impl;
-import java.io.IOException;
import java.io.InputStream;
import java.io.Reader;
import java.math.BigDecimal;
@@ -38,36 +37,40 @@
import org.jboss.dna.spi.graph.PropertyType;
import org.jboss.dna.spi.graph.Reference;
import org.jboss.dna.spi.graph.ValueFactory;
-import org.jboss.dna.spi.graph.ValueFormatException;
/**
* The standard {@link ValueFactory} for {@link PropertyType#DATE} values.
*
* @author Randall Hauch
+ * @author John Verhaeg
*/
@Immutable
public class JodaDateTimeValueFactory extends AbstractValueFactory<DateTime> implements DateTimeFactory {
- public JodaDateTimeValueFactory( TextDecoder decoder, ValueFactory<String> stringValueFactory ) {
+ public JodaDateTimeValueFactory( TextDecoder decoder,
+ ValueFactory<String> stringValueFactory ) {
super(PropertyType.DATE, decoder, stringValueFactory);
}
/**
* {@inheritDoc}
*/
- public DateTime create( String value ) throws ValueFormatException {
+ public DateTime create( String value ) {
if (value == null) return null;
try {
return new JodaDateTime(value.trim());
- } catch (IllegalArgumentException e) {
- throw new ValueFormatException(SpiI18n.errorCreatingValue.text(getPropertyType().getName(), String.class.getSimpleName(), value), e);
+ } catch (IllegalArgumentException err) {
+ throw new IllegalArgumentException(SpiI18n.errorConvertingType.text(String.class.getSimpleName(),
+ DateTime.class.getSimpleName(),
+ value), err);
}
}
/**
* {@inheritDoc}
*/
- public DateTime create( String value, TextDecoder decoder ) {
+ public DateTime create( String value,
+ TextDecoder decoder ) {
// this probably doesn't really need to call the decoder, but by doing so then we don't care at all what the decoder does
return create(getDecoder(decoder).decode(value));
}
@@ -89,28 +92,30 @@
/**
* {@inheritDoc}
*/
- public DateTime create( boolean value ) throws ValueFormatException {
- throw new ValueFormatException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(), Date.class.getSimpleName(), value));
+ public DateTime create( boolean value ) {
+ throw new UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+ Date.class.getSimpleName(),
+ value));
}
/**
* {@inheritDoc}
*/
- public DateTime create( float value ) throws ValueFormatException {
+ public DateTime create( float value ) {
return create((long)value);
}
/**
* {@inheritDoc}
*/
- public DateTime create( double value ) throws ValueFormatException {
+ public DateTime create( double value ) {
return create((long)value);
}
/**
* {@inheritDoc}
*/
- public DateTime create( BigDecimal value ) throws ValueFormatException {
+ public DateTime create( BigDecimal value ) {
if (value == null) return null;
return create(value.longValue());
}
@@ -118,7 +123,7 @@
/**
* {@inheritDoc}
*/
- public DateTime create( Calendar value ) throws ValueFormatException {
+ public DateTime create( Calendar value ) {
if (value == null) return null;
return new JodaDateTime(value);
}
@@ -126,7 +131,7 @@
/**
* {@inheritDoc}
*/
- public DateTime create( Date value ) throws ValueFormatException {
+ public DateTime create( Date value ) {
if (value == null) return null;
return new JodaDateTime(value);
}
@@ -134,35 +139,43 @@
/**
* {@inheritDoc}
*/
- public DateTime create( Name value ) throws ValueFormatException {
- throw new ValueFormatException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(), Name.class.getSimpleName(), value));
+ public DateTime create( Name value ) {
+ throw new UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+ Name.class.getSimpleName(),
+ value));
}
/**
* {@inheritDoc}
*/
- public DateTime create( Path value ) throws ValueFormatException {
- throw new ValueFormatException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(), Path.class.getSimpleName(), value));
+ public DateTime create( Path value ) {
+ throw new UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+ Path.class.getSimpleName(),
+ value));
}
/**
* {@inheritDoc}
*/
- public DateTime create( Reference value ) throws ValueFormatException {
- throw new ValueFormatException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(), Reference.class.getSimpleName(), value));
+ public DateTime create( Reference value ) {
+ throw new UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+ Reference.class.getSimpleName(),
+ value));
}
/**
* {@inheritDoc}
*/
- public DateTime create( URI value ) throws ValueFormatException {
- throw new ValueFormatException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(), URI.class.getSimpleName(), value));
+ public DateTime create( URI value ) {
+ throw new UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+ URI.class.getSimpleName(),
+ value));
}
/**
* {@inheritDoc}
*/
- public DateTime create( byte[] value ) throws ValueFormatException {
+ public DateTime create( byte[] value ) {
// First attempt to create a string from the value, then a long from the string ...
return create(getStringValueFactory().create(value));
}
@@ -170,7 +183,8 @@
/**
* {@inheritDoc}
*/
- public DateTime create( InputStream stream, int approximateLength ) throws IOException, ValueFormatException {
+ public DateTime create( InputStream stream,
+ int approximateLength ) {
// First attempt to create a string from the value, then a double from the string ...
return create(getStringValueFactory().create(stream, approximateLength));
}
@@ -178,7 +192,8 @@
/**
* {@inheritDoc}
*/
- public DateTime create( Reader reader, int approximateLength ) throws IOException, ValueFormatException {
+ public DateTime create( Reader reader,
+ int approximateLength ) {
// First attempt to create a string from the value, then a double from the string ...
return create(getStringValueFactory().create(reader, approximateLength));
}
@@ -193,22 +208,43 @@
/**
* {@inheritDoc}
*/
- public DateTime create( int year, int monthOfYear, int dayOfMonth, int hourOfDay, int minuteOfHour, int secondOfMinute, int millisecondsOfSecond ) {
+ public DateTime create( int year,
+ int monthOfYear,
+ int dayOfMonth,
+ int hourOfDay,
+ int minuteOfHour,
+ int secondOfMinute,
+ int millisecondsOfSecond ) {
return new JodaDateTime(year, monthOfYear, dayOfMonth, hourOfDay, minuteOfHour, secondOfMinute, millisecondsOfSecond);
}
/**
* {@inheritDoc}
*/
- public DateTime create( int year, int monthOfYear, int dayOfMonth, int hourOfDay, int minuteOfHour, int secondOfMinute, int millisecondsOfSecond, int timeZoneOffsetHours ) {
- return new JodaDateTime(year, monthOfYear, dayOfMonth, hourOfDay, minuteOfHour, secondOfMinute, millisecondsOfSecond, timeZoneOffsetHours);
+ public DateTime create( int year,
+ int monthOfYear,
+ int dayOfMonth,
+ int hourOfDay,
+ int minuteOfHour,
+ int secondOfMinute,
+ int millisecondsOfSecond,
+ int timeZoneOffsetHours ) {
+ return new JodaDateTime(year, monthOfYear, dayOfMonth, hourOfDay, minuteOfHour, secondOfMinute, millisecondsOfSecond,
+ timeZoneOffsetHours);
}
/**
* {@inheritDoc}
*/
- public DateTime create( int year, int monthOfYear, int dayOfMonth, int hourOfDay, int minuteOfHour, int secondOfMinute, int millisecondsOfSecond, String timeZoneId ) {
- return new JodaDateTime(year, monthOfYear, dayOfMonth, hourOfDay, minuteOfHour, secondOfMinute, millisecondsOfSecond, timeZoneId);
+ public DateTime create( int year,
+ int monthOfYear,
+ int dayOfMonth,
+ int hourOfDay,
+ int minuteOfHour,
+ int secondOfMinute,
+ int millisecondsOfSecond,
+ String timeZoneId ) {
+ return new JodaDateTime(year, monthOfYear, dayOfMonth, hourOfDay, minuteOfHour, secondOfMinute, millisecondsOfSecond,
+ timeZoneId);
}
-
}
Modified: branches/maeste/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/LongValueFactory.java
===================================================================
--- branches/maeste/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/LongValueFactory.java 2008-06-11 08:35:21 UTC (rev 264)
+++ branches/maeste/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/LongValueFactory.java 2008-06-11 08:45:51 UTC (rev 265)
@@ -21,7 +21,6 @@
*/
package org.jboss.dna.spi.graph.impl;
-import java.io.IOException;
import java.io.InputStream;
import java.io.Reader;
import java.math.BigDecimal;
@@ -36,36 +35,40 @@
import org.jboss.dna.spi.graph.PropertyType;
import org.jboss.dna.spi.graph.Reference;
import org.jboss.dna.spi.graph.ValueFactory;
-import org.jboss.dna.spi.graph.ValueFormatException;
/**
* The standard {@link ValueFactory} for {@link PropertyType#LONG} values.
*
* @author Randall Hauch
+ * @author John Verhaeg
*/
@Immutable
public class LongValueFactory extends AbstractValueFactory<Long> {
- public LongValueFactory( TextDecoder decoder, ValueFactory<String> stringValueFactory ) {
+ public LongValueFactory( TextDecoder decoder,
+ ValueFactory<String> stringValueFactory ) {
super(PropertyType.LONG, decoder, stringValueFactory);
}
/**
* {@inheritDoc}
*/
- public Long create( String value ) throws ValueFormatException {
+ public Long create( String value ) {
if (value == null) return null;
try {
return Long.valueOf(value.trim());
- } catch (NumberFormatException e) {
- throw new ValueFormatException(SpiI18n.errorCreatingValue.text(getPropertyType().getName(), String.class.getSimpleName(), value), e);
+ } catch (NumberFormatException err) {
+ throw new IllegalArgumentException(SpiI18n.errorConvertingType.text(String.class.getSimpleName(),
+ Long.class.getSimpleName(),
+ value), err);
}
}
/**
* {@inheritDoc}
*/
- public Long create( String value, TextDecoder decoder ) {
+ public Long create( String value,
+ TextDecoder decoder ) {
// this probably doesn't really need to call the decoder, but by doing so then we don't care at all what the decoder does
return create(getDecoder(decoder).decode(value));
}
@@ -87,28 +90,30 @@
/**
* {@inheritDoc}
*/
- public Long create( boolean value ) throws ValueFormatException {
- throw new ValueFormatException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(), Long.class.getSimpleName(), value));
+ public Long create( boolean value ) {
+ throw new UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+ Long.class.getSimpleName(),
+ value));
}
/**
* {@inheritDoc}
*/
- public Long create( float value ) throws ValueFormatException {
+ public Long create( float value ) {
return (long)value;
}
/**
* {@inheritDoc}
*/
- public Long create( double value ) throws ValueFormatException {
+ public Long create( double value ) {
return (long)value;
}
/**
* {@inheritDoc}
*/
- public Long create( BigDecimal value ) throws ValueFormatException {
+ public Long create( BigDecimal value ) {
if (value == null) return null;
return value.longValue();
}
@@ -116,7 +121,7 @@
/**
* {@inheritDoc}
*/
- public Long create( Calendar value ) throws ValueFormatException {
+ public Long create( Calendar value ) {
if (value == null) return null;
return value.getTimeInMillis();
}
@@ -124,7 +129,7 @@
/**
* {@inheritDoc}
*/
- public Long create( Date value ) throws ValueFormatException {
+ public Long create( Date value ) {
if (value == null) return null;
return value.getTime();
}
@@ -132,35 +137,43 @@
/**
* {@inheritDoc}
*/
- public Long create( Name value ) throws ValueFormatException {
- throw new ValueFormatException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(), Name.class.getSimpleName(), value));
+ public Long create( Name value ) {
+ throw new UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+ Name.class.getSimpleName(),
+ value));
}
/**
* {@inheritDoc}
*/
- public Long create( Path value ) throws ValueFormatException {
- throw new ValueFormatException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(), Path.class.getSimpleName(), value));
+ public Long create( Path value ) {
+ throw new UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+ Path.class.getSimpleName(),
+ value));
}
/**
* {@inheritDoc}
*/
- public Long create( Reference value ) throws ValueFormatException {
- throw new ValueFormatException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(), Reference.class.getSimpleName(), value));
+ public Long create( Reference value ) {
+ throw new UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+ Reference.class.getSimpleName(),
+ value));
}
/**
* {@inheritDoc}
*/
- public Long create( URI value ) throws ValueFormatException {
- throw new ValueFormatException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(), URI.class.getSimpleName(), value));
+ public Long create( URI value ) {
+ throw new UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+ URI.class.getSimpleName(),
+ value));
}
/**
* {@inheritDoc}
*/
- public Long create( byte[] value ) throws ValueFormatException {
+ public Long create( byte[] value ) {
// First attempt to create a string from the value, then a long from the string ...
return create(getStringValueFactory().create(value));
}
@@ -168,7 +181,8 @@
/**
* {@inheritDoc}
*/
- public Long create( InputStream stream, int approximateLength ) throws IOException, ValueFormatException {
+ public Long create( InputStream stream,
+ int approximateLength ) {
// First attempt to create a string from the value, then a long from the string ...
return create(getStringValueFactory().create(stream, approximateLength));
}
@@ -176,7 +190,8 @@
/**
* {@inheritDoc}
*/
- public Long create( Reader reader, int approximateLength ) throws IOException, ValueFormatException {
+ public Long create( Reader reader,
+ int approximateLength ) {
// First attempt to create a string from the value, then a long from the string ...
return create(getStringValueFactory().create(reader, approximateLength));
}
Modified: branches/maeste/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/NameValueFactory.java
===================================================================
--- branches/maeste/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/NameValueFactory.java 2008-06-11 08:35:21 UTC (rev 264)
+++ branches/maeste/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/NameValueFactory.java 2008-06-11 08:45:51 UTC (rev 265)
@@ -21,7 +21,6 @@
*/
package org.jboss.dna.spi.graph.impl;
-import java.io.IOException;
import java.io.InputStream;
import java.io.Reader;
import java.math.BigDecimal;
@@ -42,12 +41,12 @@
import org.jboss.dna.spi.graph.PropertyType;
import org.jboss.dna.spi.graph.Reference;
import org.jboss.dna.spi.graph.ValueFactory;
-import org.jboss.dna.spi.graph.ValueFormatException;
/**
* The standard {@link ValueFactory} for {@link PropertyType#NAME} values.
*
* @author Randall Hauch
+ * @author John Verhaeg
*/
@Immutable
public class NameValueFactory extends AbstractValueFactory<Name> implements NameFactory {
@@ -62,7 +61,9 @@
private final NamespaceRegistry namespaceRegistry;
- public NameValueFactory( NamespaceRegistry namespaceRegistry, TextDecoder decoder, ValueFactory<String> stringValueFactory ) {
+ public NameValueFactory( NamespaceRegistry namespaceRegistry,
+ TextDecoder decoder,
+ ValueFactory<String> stringValueFactory ) {
super(PropertyType.NAME, decoder, stringValueFactory);
ArgCheck.isNotNull(namespaceRegistry, "namespaceRegistry");
this.namespaceRegistry = namespaceRegistry;
@@ -78,7 +79,8 @@
/**
* {@inheritDoc}
*/
- public Name create( String value, TextDecoder decoder ) throws ValueFormatException {
+ public Name create( String value,
+ TextDecoder decoder ) {
if (value == null) return null;
if (decoder == null) decoder = getDecoder();
try {
@@ -108,23 +110,30 @@
}
return new BasicName(namespaceUri, localName);
}
- } catch (Throwable t) {
- throw new ValueFormatException(SpiI18n.errorCreatingValue.text(getPropertyType().getName(), String.class.getSimpleName(), value), t);
+ } catch (NamespaceException err) {
+ throw new IllegalArgumentException(SpiI18n.errorConvertingType.text(String.class.getSimpleName(),
+ Name.class.getSimpleName(),
+ value), err);
}
- throw new ValueFormatException(SpiI18n.errorCreatingValue.text(getPropertyType().getName(), String.class.getSimpleName(), value));
+ throw new IllegalArgumentException(SpiI18n.errorConvertingType.text(String.class.getSimpleName(),
+ Name.class.getSimpleName(),
+ value));
}
/**
* {@inheritDoc}
*/
- public Name create( String namespaceUri, String localName ) {
+ public Name create( String namespaceUri,
+ String localName ) {
return create(namespaceUri, localName, getDecoder());
}
/**
* {@inheritDoc}
*/
- public Name create( String namespaceUri, String localName, TextDecoder decoder ) {
+ public Name create( String namespaceUri,
+ String localName,
+ TextDecoder decoder ) {
ArgCheck.isNotEmpty(localName, "localName");
if (decoder == null) decoder = getDecoder();
namespaceUri = namespaceUri != null ? decoder.decode(namespaceUri.trim()) : null;
@@ -135,57 +144,73 @@
/**
* {@inheritDoc}
*/
- public Name create( int value ) throws ValueFormatException {
- throw new ValueFormatException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(), Date.class.getSimpleName(), value));
+ public Name create( int value ) {
+ throw new UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+ Date.class.getSimpleName(),
+ value));
}
/**
* {@inheritDoc}
*/
- public Name create( long value ) throws ValueFormatException {
- throw new ValueFormatException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(), Date.class.getSimpleName(), value));
+ public Name create( long value ) {
+ throw new UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+ Date.class.getSimpleName(),
+ value));
}
/**
* {@inheritDoc}
*/
- public Name create( boolean value ) throws ValueFormatException {
- throw new ValueFormatException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(), Date.class.getSimpleName(), value));
+ public Name create( boolean value ) {
+ throw new UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+ Date.class.getSimpleName(),
+ value));
}
/**
* {@inheritDoc}
*/
- public Name create( float value ) throws ValueFormatException {
- throw new ValueFormatException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(), Date.class.getSimpleName(), value));
+ public Name create( float value ) {
+ throw new UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+ Date.class.getSimpleName(),
+ value));
}
/**
* {@inheritDoc}
*/
- public Name create( double value ) throws ValueFormatException {
- throw new ValueFormatException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(), Date.class.getSimpleName(), value));
+ public Name create( double value ) {
+ throw new UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+ Date.class.getSimpleName(),
+ value));
}
/**
* {@inheritDoc}
*/
- public Name create( BigDecimal value ) throws ValueFormatException {
- throw new ValueFormatException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(), Date.class.getSimpleName(), value));
+ public Name create( BigDecimal value ) {
+ throw new UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+ Date.class.getSimpleName(),
+ value));
}
/**
* {@inheritDoc}
*/
- public Name create( Calendar value ) throws ValueFormatException {
- throw new ValueFormatException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(), Date.class.getSimpleName(), value));
+ public Name create( Calendar value ) {
+ throw new UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+ Date.class.getSimpleName(),
+ value));
}
/**
* {@inheritDoc}
*/
- public Name create( Date value ) throws ValueFormatException {
- throw new ValueFormatException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(), Date.class.getSimpleName(), value));
+ public Name create( Date value ) {
+ throw new UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+ Date.class.getSimpleName(),
+ value));
}
/**
@@ -198,26 +223,30 @@
/**
* {@inheritDoc}
*/
- public Name create( Path value ) throws ValueFormatException {
+ public Name create( Path value ) {
if (value == null) return null;
if (!value.isAbsolute() && value.size() == 1) {
// A relative name of length 1 is converted to a name
return value.getSegment(0).getName();
}
- throw new ValueFormatException(SpiI18n.errorCreatingValue.text(getPropertyType().getName(), Path.class.getSimpleName(), value));
+ throw new IllegalArgumentException(SpiI18n.errorConvertingType.text(Path.class.getSimpleName(),
+ Name.class.getSimpleName(),
+ value));
}
/**
* {@inheritDoc}
*/
- public Name create( Reference value ) throws ValueFormatException {
- throw new ValueFormatException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(), Reference.class.getSimpleName(), value));
+ public Name create( Reference value ) {
+ throw new UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+ Reference.class.getSimpleName(),
+ value));
}
/**
* {@inheritDoc}
*/
- public Name create( URI value ) throws ValueFormatException {
+ public Name create( URI value ) {
if (value == null) return null;
String asciiString = value.toASCIIString();
// Remove any leading "./" ...
@@ -227,13 +256,15 @@
if (asciiString.indexOf('/') == -1) {
return create(asciiString);
}
- throw new ValueFormatException(SpiI18n.errorCreatingValue.text(getPropertyType().getName(), Path.class.getSimpleName(), value));
+ throw new IllegalArgumentException(SpiI18n.errorConvertingType.text(URI.class.getSimpleName(),
+ Path.class.getSimpleName(),
+ value));
}
/**
* {@inheritDoc}
*/
- public Name create( byte[] value ) throws ValueFormatException {
+ public Name create( byte[] value ) {
// First attempt to create a string from the value, then a long from the string ...
return create(getStringValueFactory().create(value));
}
@@ -241,7 +272,8 @@
/**
* {@inheritDoc}
*/
- public Name create( InputStream stream, int approximateLength ) throws IOException, ValueFormatException {
+ public Name create( InputStream stream,
+ int approximateLength ) {
// First attempt to create a string from the value, then a double from the string ...
return create(getStringValueFactory().create(stream, approximateLength));
}
@@ -249,7 +281,8 @@
/**
* {@inheritDoc}
*/
- public Name create( Reader reader, int approximateLength ) throws IOException, ValueFormatException {
+ public Name create( Reader reader,
+ int approximateLength ) {
// First attempt to create a string from the value, then a double from the string ...
return create(getStringValueFactory().create(reader, approximateLength));
}
Modified: branches/maeste/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/ObjectValueFactory.java
===================================================================
--- branches/maeste/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/ObjectValueFactory.java 2008-06-11 08:35:21 UTC (rev 264)
+++ branches/maeste/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/ObjectValueFactory.java 2008-06-11 08:45:51 UTC (rev 265)
@@ -21,7 +21,6 @@
*/
package org.jboss.dna.spi.graph.impl;
-import java.io.IOException;
import java.io.InputStream;
import java.io.Reader;
import java.math.BigDecimal;
@@ -37,19 +36,21 @@
import org.jboss.dna.spi.graph.PropertyType;
import org.jboss.dna.spi.graph.Reference;
import org.jboss.dna.spi.graph.ValueFactory;
-import org.jboss.dna.spi.graph.ValueFormatException;
/**
* The standard {@link ValueFactory} for {@link PropertyType#OBJECT} values.
*
* @author Randall Hauch
+ * @author John Verhaeg
*/
@Immutable
public class ObjectValueFactory extends AbstractValueFactory<Object> {
private final ValueFactory<Binary> binaryValueFactory;
- public ObjectValueFactory( TextDecoder decoder, ValueFactory<String> stringValueFactory, ValueFactory<Binary> binaryValueFactory ) {
+ public ObjectValueFactory( TextDecoder decoder,
+ ValueFactory<String> stringValueFactory,
+ ValueFactory<Binary> binaryValueFactory ) {
super(PropertyType.OBJECT, decoder, stringValueFactory);
ArgCheck.isNotNull(binaryValueFactory, "binaryValueFactory");
this.binaryValueFactory = binaryValueFactory;
@@ -72,7 +73,8 @@
/**
* {@inheritDoc}
*/
- public Object create( String value, TextDecoder decoder ) {
+ public Object create( String value,
+ TextDecoder decoder ) {
return this.getStringValueFactory().create(value, decoder);
}
@@ -163,21 +165,23 @@
/**
* {@inheritDoc}
*/
- public Object create( byte[] value ) throws ValueFormatException {
+ public Object create( byte[] value ) {
return getBinaryValueFactory().create(value);
}
/**
* {@inheritDoc}
*/
- public Object create( InputStream stream, int approximateLength ) throws IOException {
+ public Object create( InputStream stream,
+ int approximateLength ) {
return getBinaryValueFactory().create(stream, approximateLength);
}
/**
* {@inheritDoc}
*/
- public Object create( Reader reader, int approximateLength ) throws IOException {
+ public Object create( Reader reader,
+ int approximateLength ) {
return getBinaryValueFactory().create(reader, approximateLength);
}
Modified: branches/maeste/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/PathValueFactory.java
===================================================================
--- branches/maeste/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/PathValueFactory.java 2008-06-11 08:35:21 UTC (rev 264)
+++ branches/maeste/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/PathValueFactory.java 2008-06-11 08:45:51 UTC (rev 265)
@@ -21,7 +21,6 @@
*/
package org.jboss.dna.spi.graph.impl;
-import java.io.IOException;
import java.io.InputStream;
import java.io.Reader;
import java.math.BigDecimal;
@@ -41,7 +40,6 @@
import org.jboss.dna.spi.graph.PropertyType;
import org.jboss.dna.spi.graph.Reference;
import org.jboss.dna.spi.graph.ValueFactory;
-import org.jboss.dna.spi.graph.ValueFormatException;
import org.jboss.dna.spi.graph.Path.Segment;
/**
@@ -77,7 +75,9 @@
private final ValueFactory<Name> nameValueFactory;
- public PathValueFactory( TextDecoder decoder, ValueFactory<String> stringValueFactory, ValueFactory<Name> nameValueFactory ) {
+ public PathValueFactory( TextDecoder decoder,
+ ValueFactory<String> stringValueFactory,
+ ValueFactory<Name> nameValueFactory ) {
super(PropertyType.PATH, decoder, stringValueFactory);
ArgCheck.isNotNull(nameValueFactory, "nameValueFactory");
this.nameValueFactory = nameValueFactory;
@@ -111,7 +111,8 @@
/**
* {@inheritDoc}
*/
- public Path create( final String value, TextDecoder decoder ) throws ValueFormatException {
+ public Path create( final String value,
+ TextDecoder decoder ) {
if (value == null) return null;
String trimmedValue = value.trim();
int length = trimmedValue.length();
@@ -139,7 +140,7 @@
List<Segment> segments = new ArrayList<Segment>();
String[] pathSegments = DELIMITER_PATTERN.split(trimmedValue);
if (pathSegments.length == 0) {
- throw new ValueFormatException(SpiI18n.validPathMayNotContainEmptySegment.text(value));
+ throw new IllegalArgumentException(SpiI18n.validPathMayNotContainEmptySegment.text(value));
}
if (decoder == null) decoder = getDecoder();
assert pathSegments.length != 0;
@@ -148,7 +149,7 @@
assert segment != null;
segment = segment.trim();
if (segment.length() == 0) {
- throw new ValueFormatException(SpiI18n.validPathMayNotContainEmptySegment.text(value));
+ throw new IllegalArgumentException(SpiI18n.validPathMayNotContainEmptySegment.text(value));
}
// Create the name and add a segment with it ...
segments.add(createSegment(segment, decoder));
@@ -161,57 +162,73 @@
/**
* {@inheritDoc}
*/
- public Path create( int value ) throws ValueFormatException {
- throw new ValueFormatException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(), Date.class.getSimpleName(), value));
+ public Path create( int value ) {
+ throw new UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+ Date.class.getSimpleName(),
+ value));
}
/**
* {@inheritDoc}
*/
- public Path create( long value ) throws ValueFormatException {
- throw new ValueFormatException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(), Date.class.getSimpleName(), value));
+ public Path create( long value ) {
+ throw new UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+ Date.class.getSimpleName(),
+ value));
}
/**
* {@inheritDoc}
*/
- public Path create( boolean value ) throws ValueFormatException {
- throw new ValueFormatException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(), Date.class.getSimpleName(), value));
+ public Path create( boolean value ) {
+ throw new UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+ Date.class.getSimpleName(),
+ value));
}
/**
* {@inheritDoc}
*/
- public Path create( float value ) throws ValueFormatException {
- throw new ValueFormatException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(), Date.class.getSimpleName(), value));
+ public Path create( float value ) {
+ throw new UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+ Date.class.getSimpleName(),
+ value));
}
/**
* {@inheritDoc}
*/
- public Path create( double value ) throws ValueFormatException {
- throw new ValueFormatException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(), Date.class.getSimpleName(), value));
+ public Path create( double value ) {
+ throw new UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+ Date.class.getSimpleName(),
+ value));
}
/**
* {@inheritDoc}
*/
- public Path create( BigDecimal value ) throws ValueFormatException {
- throw new ValueFormatException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(), Date.class.getSimpleName(), value));
+ public Path create( BigDecimal value ) {
+ throw new UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+ Date.class.getSimpleName(),
+ value));
}
/**
* {@inheritDoc}
*/
- public Path create( Calendar value ) throws ValueFormatException {
- throw new ValueFormatException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(), Date.class.getSimpleName(), value));
+ public Path create( Calendar value ) {
+ throw new UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+ Date.class.getSimpleName(),
+ value));
}
/**
* {@inheritDoc}
*/
- public Path create( Date value ) throws ValueFormatException {
- throw new ValueFormatException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(), Date.class.getSimpleName(), value));
+ public Path create( Date value ) {
+ throw new UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+ Date.class.getSimpleName(),
+ value));
}
/**
@@ -227,7 +244,7 @@
/**
* {@inheritDoc}
*/
- public Path create( Path value ) throws ValueFormatException {
+ public Path create( Path value ) {
return value;
}
@@ -305,7 +322,9 @@
/**
* {@inheritDoc}
*/
- public Path create( Path parentPath, Name segmentName, int index ) {
+ public Path create( Path parentPath,
+ Name segmentName,
+ int index ) {
ArgCheck.isNotNull(parentPath, "parent path");
ArgCheck.isNotNull(segmentName, "segment name");
List<Segment> segments = new ArrayList<Segment>(parentPath.size() + 1);
@@ -317,7 +336,8 @@
/**
* {@inheritDoc}
*/
- public Path create( Path parentPath, Name... segmentNames ) {
+ public Path create( Path parentPath,
+ Name... segmentNames ) {
ArgCheck.isNotNull(parentPath, "parent path");
if (segmentNames == null || segmentNames.length == 0) return parentPath;
@@ -335,7 +355,8 @@
/**
* {@inheritDoc}
*/
- public Path create( Path parentPath, Segment... segments ) {
+ public Path create( Path parentPath,
+ Segment... segments ) {
ArgCheck.isNotNull(parentPath, "parent path");
if (segments == null || segments.length == 0) return BasicPath.ROOT;
@@ -363,7 +384,8 @@
/**
* {@inheritDoc}
*/
- public Segment createSegment( Name segmentName, int index ) {
+ public Segment createSegment( Name segmentName,
+ int index ) {
ArgCheck.isNotNull(segmentName, "segment name");
if (Path.SELF_NAME.equals(segmentName)) return Path.SELF_SEGMENT;
if (Path.PARENT_NAME.equals(segmentName)) return Path.PARENT_SEGMENT;
@@ -386,7 +408,8 @@
*
* @see org.jboss.dna.spi.graph.PathFactory#createSegment(java.lang.String, org.jboss.dna.common.text.TextDecoder)
*/
- public Segment createSegment( String segmentName, TextDecoder decoder ) {
+ public Segment createSegment( String segmentName,
+ TextDecoder decoder ) {
ArgCheck.isNotNull(segmentName, "segment name");
if (Path.SELF.equals(segmentName)) return Path.SELF_SEGMENT;
if (Path.PARENT.equals(segmentName)) return Path.PARENT_SEGMENT;
@@ -400,7 +423,8 @@
}
String ndx = segmentName.substring(startBracketNdx + 1, endBracketNdx);
try {
- return new BasicPathSegment(this.nameValueFactory.create(segmentName.substring(0, startBracketNdx), decoder), Integer.parseInt(ndx));
+ return new BasicPathSegment(this.nameValueFactory.create(segmentName.substring(0, startBracketNdx), decoder),
+ Integer.parseInt(ndx));
} catch (NumberFormatException err) {
throw new IllegalArgumentException(SpiI18n.invalidIndexInSegmentName.text(ndx, segmentName));
}
@@ -409,7 +433,8 @@
/**
* {@inheritDoc}
*/
- public Segment createSegment( String segmentName, int index ) {
+ public Segment createSegment( String segmentName,
+ int index ) {
ArgCheck.isNotNull(segmentName, "segment name");
if (Path.SELF.equals(segmentName)) return Path.SELF_SEGMENT;
if (Path.PARENT.equals(segmentName)) return Path.PARENT_SEGMENT;
@@ -419,14 +444,16 @@
/**
* {@inheritDoc}
*/
- public Path create( Reference value ) throws ValueFormatException {
- throw new ValueFormatException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(), Reference.class.getSimpleName(), value));
+ public Path create( Reference value ) {
+ throw new UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+ Reference.class.getSimpleName(),
+ value));
}
/**
* {@inheritDoc}
*/
- public Path create( URI value ) throws ValueFormatException {
+ public Path create( URI value ) {
if (value == null) return null;
String asciiString = value.toASCIIString();
// Remove any leading "./" ...
@@ -436,13 +463,15 @@
if (asciiString.indexOf('/') == -1) {
return create(asciiString);
}
- throw new ValueFormatException(SpiI18n.errorCreatingValue.text(getPropertyType().getName(), Path.class.getSimpleName(), value));
+ throw new IllegalArgumentException(SpiI18n.errorConvertingType.text(URI.class.getSimpleName(),
+ Path.class.getSimpleName(),
+ value));
}
/**
* {@inheritDoc}
*/
- public Path create( byte[] value ) throws ValueFormatException {
+ public Path create( byte[] value ) {
// First attempt to create a string from the value, then a long from the string ...
return create(getStringValueFactory().create(value));
}
@@ -450,7 +479,8 @@
/**
* {@inheritDoc}
*/
- public Path create( InputStream stream, int approximateLength ) throws IOException, ValueFormatException {
+ public Path create( InputStream stream,
+ int approximateLength ) {
// First attempt to create a string from the value, then a double from the string ...
return create(getStringValueFactory().create(stream, approximateLength));
}
@@ -458,7 +488,8 @@
/**
* {@inheritDoc}
*/
- public Path create( Reader reader, int approximateLength ) throws IOException, ValueFormatException {
+ public Path create( Reader reader,
+ int approximateLength ) {
// First attempt to create a string from the value, then a double from the string ...
return create(getStringValueFactory().create(reader, approximateLength));
}
Modified: branches/maeste/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/StringValueFactory.java
===================================================================
--- branches/maeste/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/StringValueFactory.java 2008-06-11 08:35:21 UTC (rev 264)
+++ branches/maeste/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/StringValueFactory.java 2008-06-11 08:45:51 UTC (rev 265)
@@ -40,19 +40,21 @@
import org.jboss.dna.spi.graph.PropertyType;
import org.jboss.dna.spi.graph.Reference;
import org.jboss.dna.spi.graph.ValueFactory;
-import org.jboss.dna.spi.graph.ValueFormatException;
+import org.jboss.dna.spi.graph.IoException;
/**
* The standard {@link ValueFactory} for {@link PropertyType#STRING} values.
*
* @author Randall Hauch
+ * @author John Verhaeg
*/
@Immutable
public class StringValueFactory extends AbstractValueFactory<String> {
private final TextEncoder encoder;
- public StringValueFactory( TextDecoder decoder, TextEncoder encoder ) {
+ public StringValueFactory( TextDecoder decoder,
+ TextEncoder encoder ) {
super(PropertyType.STRING, decoder, null);
ArgCheck.isNotNull(encoder, "encoder");
this.encoder = encoder;
@@ -83,7 +85,8 @@
/**
* {@inheritDoc}
*/
- public String create( String value, TextDecoder decoder ) {
+ public String create( String value,
+ TextDecoder decoder ) {
if (value == null) return value;
if (decoder == null) decoder = getDecoder();
return decoder.decode(value);
@@ -183,34 +186,49 @@
/**
* {@inheritDoc}
*/
- public String create( byte[] value ) throws ValueFormatException {
+ public String create( byte[] value ) {
if (value == null) return null;
try {
return new String(value, "UTF-8");
- } catch (UnsupportedEncodingException e) {
- throw new ValueFormatException(SpiI18n.errorConvertingBinaryValueToString.text());
+ } catch (UnsupportedEncodingException err) {
+ throw new IllegalArgumentException(SpiI18n.errorConvertingType.text(byte[].class.getSimpleName(),
+ String.class.getSimpleName(),
+ value), err);
}
}
/**
* {@inheritDoc}
*/
- public String create( InputStream stream, int approximateLength ) throws IOException {
+ public String create( InputStream stream,
+ int approximateLength ) {
if (stream == null) return null;
- byte[] value = IoUtil.readBytes(stream);
+ byte[] value = null;
try {
+ value = IoUtil.readBytes(stream);
return new String(value, "UTF-8");
- } catch (UnsupportedEncodingException e) {
- throw new ValueFormatException(SpiI18n.errorConvertingBinaryValueToString.text());
+ } catch (UnsupportedEncodingException err) {
+ throw new IllegalArgumentException(SpiI18n.errorConvertingType.text(InputStream.class.getSimpleName(),
+ String.class.getSimpleName(),
+ value), err);
+ } catch (IOException err) {
+ throw new IoException(SpiI18n.errorConvertingIo.text(InputStream.class.getSimpleName(),
+ String.class.getSimpleName()), err);
}
}
/**
* {@inheritDoc}
*/
- public String create( Reader reader, int approximateLength ) throws IOException {
+ public String create( Reader reader,
+ int approximateLength ) {
if (reader == null) return null;
- return IoUtil.read(reader);
+ try {
+ return IoUtil.read(reader);
+ } catch (IOException err) {
+ throw new IoException(SpiI18n.errorConvertingIo.text(Reader.class.getSimpleName(),
+ String.class.getSimpleName()), err);
+ }
}
}
Modified: branches/maeste/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/UriValueFactory.java
===================================================================
--- branches/maeste/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/UriValueFactory.java 2008-06-11 08:35:21 UTC (rev 264)
+++ branches/maeste/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/UriValueFactory.java 2008-06-11 08:45:51 UTC (rev 265)
@@ -21,7 +21,6 @@
*/
package org.jboss.dna.spi.graph.impl;
-import java.io.IOException;
import java.io.InputStream;
import java.io.Reader;
import java.math.BigDecimal;
@@ -39,19 +38,21 @@
import org.jboss.dna.spi.graph.PropertyType;
import org.jboss.dna.spi.graph.Reference;
import org.jboss.dna.spi.graph.ValueFactory;
-import org.jboss.dna.spi.graph.ValueFormatException;
/**
* The standard {@link ValueFactory} for {@link PropertyType#URI} values.
*
* @author Randall Hauch
+ * @author John Verhaeg
*/
@Immutable
public class UriValueFactory extends AbstractValueFactory<URI> {
private final NamespaceRegistry namespaceRegistry;
- public UriValueFactory( NamespaceRegistry namespaceRegistry, TextDecoder decoder, ValueFactory<String> stringValueFactory ) {
+ public UriValueFactory( NamespaceRegistry namespaceRegistry,
+ TextDecoder decoder,
+ ValueFactory<String> stringValueFactory ) {
super(PropertyType.URI, decoder, stringValueFactory);
ArgCheck.isNotNull(namespaceRegistry, "namespaceRegistry");
this.namespaceRegistry = namespaceRegistry;
@@ -60,19 +61,22 @@
/**
* {@inheritDoc}
*/
- public URI create( String value ) throws ValueFormatException {
+ public URI create( String value ) {
if (value == null) return null;
try {
return new URI(value);
- } catch (URISyntaxException t) {
- throw new ValueFormatException(SpiI18n.errorCreatingValue.text(getPropertyType().getName(), String.class.getSimpleName(), value), t);
+ } catch (URISyntaxException err) {
+ throw new IllegalArgumentException(SpiI18n.errorConvertingType.text(String.class.getSimpleName(),
+ URI.class.getSimpleName(),
+ value), err);
}
}
/**
* {@inheritDoc}
*/
- public URI create( String value, TextDecoder decoder ) {
+ public URI create( String value,
+ TextDecoder decoder ) {
// this probably doesn't really need to call the decoder, but by doing so then we don't care at all what the decoder does
return create(getDecoder(decoder).decode(value));
}
@@ -80,57 +84,73 @@
/**
* {@inheritDoc}
*/
- public URI create( int value ) throws ValueFormatException {
- throw new ValueFormatException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(), Date.class.getSimpleName(), value));
+ public URI create( int value ) {
+ throw new UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+ Date.class.getSimpleName(),
+ value));
}
/**
* {@inheritDoc}
*/
- public URI create( long value ) throws ValueFormatException {
- throw new ValueFormatException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(), Date.class.getSimpleName(), value));
+ public URI create( long value ) {
+ throw new UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+ Date.class.getSimpleName(),
+ value));
}
/**
* {@inheritDoc}
*/
- public URI create( boolean value ) throws ValueFormatException {
- throw new ValueFormatException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(), Date.class.getSimpleName(), value));
+ public URI create( boolean value ) {
+ throw new UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+ Date.class.getSimpleName(),
+ value));
}
/**
* {@inheritDoc}
*/
- public URI create( float value ) throws ValueFormatException {
- throw new ValueFormatException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(), Date.class.getSimpleName(), value));
+ public URI create( float value ) {
+ throw new UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+ Date.class.getSimpleName(),
+ value));
}
/**
* {@inheritDoc}
*/
- public URI create( double value ) throws ValueFormatException {
- throw new ValueFormatException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(), Date.class.getSimpleName(), value));
+ public URI create( double value ) {
+ throw new UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+ Date.class.getSimpleName(),
+ value));
}
/**
* {@inheritDoc}
*/
- public URI create( BigDecimal value ) throws ValueFormatException {
- throw new ValueFormatException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(), Date.class.getSimpleName(), value));
+ public URI create( BigDecimal value ) {
+ throw new UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+ Date.class.getSimpleName(),
+ value));
}
/**
* {@inheritDoc}
*/
- public URI create( Calendar value ) throws ValueFormatException {
- throw new ValueFormatException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(), Date.class.getSimpleName(), value));
+ public URI create( Calendar value ) {
+ throw new UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+ Date.class.getSimpleName(),
+ value));
}
/**
* {@inheritDoc}
*/
- public URI create( Date value ) throws ValueFormatException {
- throw new ValueFormatException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(), Date.class.getSimpleName(), value));
+ public URI create( Date value ) {
+ throw new UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+ Date.class.getSimpleName(),
+ value));
}
/**
@@ -144,7 +164,7 @@
/**
* {@inheritDoc}
*/
- public URI create( Path value ) throws ValueFormatException {
+ public URI create( Path value ) {
if (value == null) return null;
if (value.isAbsolute()) {
return create("/" + value.getString(this.namespaceRegistry));
@@ -155,8 +175,10 @@
/**
* {@inheritDoc}
*/
- public URI create( Reference value ) throws ValueFormatException {
- throw new ValueFormatException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(), Reference.class.getSimpleName(), value));
+ public URI create( Reference value ) {
+ throw new UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+ Reference.class.getSimpleName(),
+ value));
}
/**
@@ -169,7 +191,7 @@
/**
* {@inheritDoc}
*/
- public URI create( byte[] value ) throws ValueFormatException {
+ public URI create( byte[] value ) {
// First attempt to create a string from the value, then a long from the string ...
return create(getStringValueFactory().create(value));
}
@@ -177,7 +199,8 @@
/**
* {@inheritDoc}
*/
- public URI create( InputStream stream, int approximateLength ) throws IOException, ValueFormatException {
+ public URI create( InputStream stream,
+ int approximateLength ) {
// First attempt to create a string from the value, then a double from the string ...
return create(getStringValueFactory().create(stream, approximateLength));
}
@@ -185,7 +208,8 @@
/**
* {@inheritDoc}
*/
- public URI create( Reader reader, int approximateLength ) throws IOException, ValueFormatException {
+ public URI create( Reader reader,
+ int approximateLength ) {
// First attempt to create a string from the value, then a double from the string ...
return create(getStringValueFactory().create(reader, approximateLength));
}
Modified: branches/maeste/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/UuidReferenceValueFactory.java
===================================================================
--- branches/maeste/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/UuidReferenceValueFactory.java 2008-06-11 08:35:21 UTC (rev 264)
+++ branches/maeste/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/UuidReferenceValueFactory.java 2008-06-11 08:45:51 UTC (rev 265)
@@ -21,7 +21,6 @@
*/
package org.jboss.dna.spi.graph.impl;
-import java.io.IOException;
import java.io.InputStream;
import java.io.Reader;
import java.math.BigDecimal;
@@ -37,37 +36,41 @@
import org.jboss.dna.spi.graph.PropertyType;
import org.jboss.dna.spi.graph.Reference;
import org.jboss.dna.spi.graph.ValueFactory;
-import org.jboss.dna.spi.graph.ValueFormatException;
/**
* The standard {@link ValueFactory} for {@link PropertyType#REFERENCE} values.
*
* @author Randall Hauch
+ * @author John Verhaeg
*/
@Immutable
public class UuidReferenceValueFactory extends AbstractValueFactory<Reference> {
- public UuidReferenceValueFactory( TextDecoder decoder, ValueFactory<String> stringValueFactory ) {
+ public UuidReferenceValueFactory( TextDecoder decoder,
+ ValueFactory<String> stringValueFactory ) {
super(PropertyType.REFERENCE, decoder, stringValueFactory);
}
/**
* {@inheritDoc}
*/
- public Reference create( String value ) throws ValueFormatException {
+ public Reference create( String value ) {
if (value == null) return null;
try {
UUID uuid = UUID.fromString(value);
return new UuidReference(uuid);
- } catch (IllegalArgumentException t) {
- throw new ValueFormatException(SpiI18n.errorCreatingValue.text(getPropertyType().getName(), String.class.getSimpleName(), value), t);
+ } catch (IllegalArgumentException err) {
+ throw new IllegalArgumentException(SpiI18n.errorConvertingType.text(String.class.getSimpleName(),
+ Reference.class.getSimpleName(),
+ value), err);
}
}
/**
* {@inheritDoc}
*/
- public Reference create( String value, TextDecoder decoder ) {
+ public Reference create( String value,
+ TextDecoder decoder ) {
// this probably doesn't really need to call the decoder, but by doing so then we don't care at all what the decoder does
return create(getDecoder(decoder).decode(value));
}
@@ -75,71 +78,91 @@
/**
* {@inheritDoc}
*/
- public Reference create( int value ) throws ValueFormatException {
- throw new ValueFormatException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(), Date.class.getSimpleName(), value));
+ public Reference create( int value ) {
+ throw new UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+ Date.class.getSimpleName(),
+ value));
}
/**
* {@inheritDoc}
*/
- public Reference create( long value ) throws ValueFormatException {
- throw new ValueFormatException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(), Date.class.getSimpleName(), value));
+ public Reference create( long value ) {
+ throw new UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+ Date.class.getSimpleName(),
+ value));
}
/**
* {@inheritDoc}
*/
- public Reference create( boolean value ) throws ValueFormatException {
- throw new ValueFormatException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(), Date.class.getSimpleName(), value));
+ public Reference create( boolean value ) {
+ throw new UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+ Date.class.getSimpleName(),
+ value));
}
/**
* {@inheritDoc}
*/
- public Reference create( float value ) throws ValueFormatException {
- throw new ValueFormatException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(), Date.class.getSimpleName(), value));
+ public Reference create( float value ) {
+ throw new UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+ Date.class.getSimpleName(),
+ value));
}
/**
* {@inheritDoc}
*/
- public Reference create( double value ) throws ValueFormatException {
- throw new ValueFormatException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(), Date.class.getSimpleName(), value));
+ public Reference create( double value ) {
+ throw new UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+ Date.class.getSimpleName(),
+ value));
}
/**
* {@inheritDoc}
*/
- public Reference create( BigDecimal value ) throws ValueFormatException {
- throw new ValueFormatException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(), Date.class.getSimpleName(), value));
+ public Reference create( BigDecimal value ) {
+ throw new UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+ Date.class.getSimpleName(),
+ value));
}
/**
* {@inheritDoc}
*/
- public Reference create( Calendar value ) throws ValueFormatException {
- throw new ValueFormatException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(), Date.class.getSimpleName(), value));
+ public Reference create( Calendar value ) {
+ throw new UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+ Date.class.getSimpleName(),
+ value));
}
/**
* {@inheritDoc}
*/
- public Reference create( Date value ) throws ValueFormatException {
- throw new ValueFormatException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(), Date.class.getSimpleName(), value));
+ public Reference create( Date value ) {
+ throw new UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+ Date.class.getSimpleName(),
+ value));
}
/**
* {@inheritDoc}
*/
- public Reference create( Name value ) throws ValueFormatException {
- throw new ValueFormatException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(), Date.class.getSimpleName(), value));
+ public Reference create( Name value ) {
+ throw new UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+ Date.class.getSimpleName(),
+ value));
}
/**
* {@inheritDoc}
*/
- public Reference create( Path value ) throws ValueFormatException {
- throw new ValueFormatException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(), Date.class.getSimpleName(), value));
+ public Reference create( Path value ) {
+ throw new UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+ Date.class.getSimpleName(),
+ value));
}
/**
@@ -152,14 +175,16 @@
/**
* {@inheritDoc}
*/
- public Reference create( URI value ) throws ValueFormatException {
- throw new ValueFormatException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(), Date.class.getSimpleName(), value));
+ public Reference create( URI value ) {
+ throw new UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+ Date.class.getSimpleName(),
+ value));
}
/**
* {@inheritDoc}
*/
- public Reference create( byte[] value ) throws ValueFormatException {
+ public Reference create( byte[] value ) {
// First attempt to create a string from the value, then a long from the string ...
return create(getStringValueFactory().create(value));
}
@@ -167,7 +192,8 @@
/**
* {@inheritDoc}
*/
- public Reference create( InputStream stream, int approximateLength ) throws IOException, ValueFormatException {
+ public Reference create( InputStream stream,
+ int approximateLength ) {
// First attempt to create a string from the value, then a double from the string ...
return create(getStringValueFactory().create(stream, approximateLength));
}
@@ -175,7 +201,8 @@
/**
* {@inheritDoc}
*/
- public Reference create( Reader reader, int approximateLength ) throws IOException, ValueFormatException {
+ public Reference create( Reader reader,
+ int approximateLength ) {
// First attempt to create a string from the value, then a double from the string ...
return create(getStringValueFactory().create(reader, approximateLength));
}
Modified: branches/maeste/dna-spi/src/main/resources/org/jboss/dna/spi/SpiI18n.properties
===================================================================
--- branches/maeste/dna-spi/src/main/resources/org/jboss/dna/spi/SpiI18n.properties 2008-06-11 08:35:21 UTC (rev 264)
+++ branches/maeste/dna-spi/src/main/resources/org/jboss/dna/spi/SpiI18n.properties 2008-06-11 08:45:51 UTC (rev 265)
@@ -20,8 +20,8 @@
# 02110-1301 USA, or see the FSF site: http://www.fsf.org.
#
closedConnectionMayNotBeUsed = The connection has been closed an may not be used
-errorConvertingBinaryValueToString = Error while interpreting binary value as a UTF-8 string
-errorCreatingValue = Error creating {0} value from {1} "{2}"
+errorConvertingIo = Error converting {0} to a {1}
+errorConvertingType = Error converting {0} to a {1}: {2}
errorReadingPropertyValueBytes = Error reading bytes
invalidIndexInSegmentName = Invalid index, "{0}", in segment name: {1}
invalidQualifiedNameString = Unable to parse qualified name from "{0}"
Deleted: branches/maeste/dna-spi/src/test/java/org/jboss/dna/spi/graph/connection/MockRepositorySource.java
===================================================================
--- branches/maeste/dna-spi/src/test/java/org/jboss/dna/spi/graph/connection/MockRepositorySource.java 2008-06-11 08:35:21 UTC (rev 264)
+++ branches/maeste/dna-spi/src/test/java/org/jboss/dna/spi/graph/connection/MockRepositorySource.java 2008-06-11 08:45:51 UTC (rev 265)
@@ -1,238 +0,0 @@
-/*
- * 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.spi.graph.connection;
-
-import java.util.Set;
-import java.util.concurrent.CopyOnWriteArraySet;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.concurrent.atomic.AtomicInteger;
-import java.util.concurrent.atomic.AtomicLong;
-import java.util.concurrent.atomic.AtomicReference;
-import javax.naming.Reference;
-import javax.transaction.xa.XAResource;
-import net.jcip.annotations.ThreadSafe;
-import org.jboss.dna.spi.cache.CachePolicy;
-import org.jboss.dna.spi.graph.commands.GraphCommand;
-import org.jmock.Mockery;
-
-/**
- * @author Randall Hauch
- */
-@ThreadSafe
-public class MockRepositorySource implements RepositorySource {
-
- private final String identifier;
- private final AtomicInteger retryLimit = new AtomicInteger(0);
- private final Mockery context;
- private final AtomicInteger connectionsOpenedCount = new AtomicInteger(0);
- private final AtomicInteger connectionsClosedCount = new AtomicInteger(0);
- private final Set<Connection> openConnections = new CopyOnWriteArraySet<Connection>();
- private CachePolicy defaultCachePolicy;
-
- public MockRepositorySource( String identifier, Mockery context ) {
- this.identifier = identifier;
- this.context = context;
- }
-
- /**
- * {@inheritDoc}
- */
- public String getName() {
- return this.identifier;
- }
-
- /**
- * {@inheritDoc}
- */
- public int getRetryLimit() {
- return this.retryLimit.get();
- }
-
- /**
- * {@inheritDoc}
- */
- public void setRetryLimit( int limit ) {
- this.retryLimit.set(limit);
- }
-
- public CachePolicy getDefaultCachePolicy() {
- return defaultCachePolicy;
- }
-
- public void setDefaultCachePolicy( CachePolicy defaultCachePolicy ) {
- this.defaultCachePolicy = defaultCachePolicy;
- }
-
- /**
- * {@inheritDoc}
- */
- public RepositoryConnection getConnection() throws RepositorySourceException {
- int connectionNumber = this.connectionsOpenedCount.incrementAndGet();
- String connectionName = "Connection " + connectionNumber;
- XAResource xaResource = context != null ? context.mock(XAResource.class, connectionName) : null;
- Connection c = newConnection(connectionName, xaResource);
- this.openConnections.add(c);
- return c;
- }
-
- protected Connection newConnection( String connectionName, XAResource xaResource ) throws RepositorySourceException {
- Connection c = new Connection(connectionName);
- c.setXaResource(xaResource);
- return c;
- }
-
- protected void close( Connection conn ) {
- if (conn != null && this.openConnections.remove(conn)) {
- this.connectionsClosedCount.incrementAndGet();
- }
- }
-
- public int getOpenConnectionCount() {
- return this.openConnections.size();
- }
-
- public int getTotalConnectionsCreated() {
- return this.connectionsOpenedCount.get();
- }
-
- public int getTotalConnectionsClosed() {
- return this.connectionsClosedCount.get();
- }
-
- /**
- * {@inheritDoc}
- */
- public Reference getReference() {
- throw new UnsupportedOperationException();
- }
-
- public class Connection implements RepositoryConnection {
-
- private final String connectionName;
- private final AtomicBoolean closed = new AtomicBoolean(false);
- private final AtomicBoolean loadResponse = new AtomicBoolean(true);
- private final AtomicBoolean pingResponse = new AtomicBoolean(true);
- private final AtomicLong closeCount = new AtomicLong(0);
- private final AtomicLong loadCount = new AtomicLong(0);
- private final AtomicLong loadDelay = new AtomicLong(0);
- private final AtomicLong pingCount = new AtomicLong(0);
- private final AtomicLong pingDelay = new AtomicLong(0);
- private final AtomicReference<XAResource> xaResource = new AtomicReference<XAResource>();
-
- protected Connection( String connectionName ) {
- assert connectionName != null && connectionName.trim().length() != 0;
- this.connectionName = connectionName;
- }
-
- public String getConnectionName() {
- return this.connectionName;
- }
-
- /**
- * {@inheritDoc}
- */
- public void close() {
- this.closeCount.incrementAndGet();
- this.closed.set(true);
- MockRepositorySource.this.close(this);
- }
-
- /**
- * {@inheritDoc}
- */
- public String getSourceName() {
- return MockRepositorySource.this.getName();
- }
-
- /**
- * {@inheritDoc}
- */
- public CachePolicy getDefaultCachePolicy() {
- return MockRepositorySource.this.getDefaultCachePolicy();
- }
-
- /**
- * {@inheritDoc}
- */
- public XAResource getXAResource() {
- return this.xaResource.get();
- }
-
- public void setXaResource( XAResource xaResource ) {
- this.xaResource.set(xaResource);
- }
-
- /**
- * {@inheritDoc}
- */
- public void execute( ExecutionEnvironment env, GraphCommand... commands ) throws RepositorySourceException, InterruptedException {
- long delay = this.loadDelay.get();
- if (delay > 0l) Thread.sleep(delay);
- this.loadCount.incrementAndGet();
- }
-
- public void setLoadResponse( boolean response ) {
- this.loadResponse.set(response);
- }
-
- public void setLoadDelay( long time, TimeUnit unit ) {
- this.loadDelay.set(unit.toMillis(time));
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean ping( long time, TimeUnit unit ) throws InterruptedException {
- Thread.sleep(this.pingDelay.get());
- return this.pingResponse.get();
- }
-
- public void setPingResponse( boolean pingResponse ) {
- this.pingResponse.set(pingResponse);
- }
-
- public void setPingDelay( long time, TimeUnit unit ) {
- this.pingDelay.set(unit.toMillis(time));
- }
-
- public long getPingCount() {
- return this.pingCount.get();
- }
-
- public long getLoadCount() {
- return this.loadCount.get();
- }
-
- public long getCloseCount() {
- return this.closeCount.get();
- }
-
- /**
- * {@inheritDoc}
- */
- public void setListener( RepositorySourceListener listener ) {
- }
-
- }
-
-}
Modified: branches/maeste/dna-spi/src/test/java/org/jboss/dna/spi/graph/connection/RepositoryConnectionPoolTest.java
===================================================================
--- branches/maeste/dna-spi/src/test/java/org/jboss/dna/spi/graph/connection/RepositoryConnectionPoolTest.java 2008-06-11 08:35:21 UTC (rev 264)
+++ branches/maeste/dna-spi/src/test/java/org/jboss/dna/spi/graph/connection/RepositoryConnectionPoolTest.java 2008-06-11 08:45:51 UTC (rev 265)
@@ -23,11 +23,11 @@
import static org.hamcrest.core.Is.is;
import static org.hamcrest.core.IsNull.notNullValue;
+import static org.jboss.dna.spi.graph.connection.RepositorySourceLoadHarness.runLoadTest;
import static org.junit.Assert.assertThat;
-import static org.jboss.dna.spi.graph.connection.RepositorySourceLoadHarness.runLoadTest;
import java.util.List;
+import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
-import org.jmock.Mockery;
import org.junit.After;
import org.junit.Before;
import org.junit.Ignore;
@@ -39,14 +39,12 @@
public class RepositoryConnectionPoolTest {
private RepositoryConnectionPool pool;
- private MockRepositorySource repositorySource;
+ private TimeDelayingRepositorySource repositorySource;
private ExecutionEnvironment env;
- private Mockery context;
@Before
- public void beforeEach() throws Exception {
- this.context = new Mockery();
- this.repositorySource = new MockRepositorySource("source 1", this.context);
+ public void beforeEach() {
+ this.repositorySource = new TimeDelayingRepositorySource("source 1");
this.pool = new RepositoryConnectionPool(this.repositorySource, 1, 1, 100, TimeUnit.SECONDS);
this.env = null;
}
@@ -103,7 +101,8 @@
}
@Test
- public void shouldAllowShutdownToBeCalledMultipleTimesEvenWhenShutdown() throws RepositorySourceException, InterruptedException {
+ public void shouldAllowShutdownToBeCalledMultipleTimesEvenWhenShutdown()
+ throws RepositorySourceException, InterruptedException {
assertThat(pool.getTotalConnectionsCreated(), is(0l));
assertThat(pool.getTotalConnectionsUsed(), is(0l));
@@ -142,7 +141,8 @@
}
@Test
- public void shouldAllowConnectionsToBeClosedMoreThanOnceWithNoIllEffects() throws RepositorySourceException, InterruptedException {
+ public void shouldAllowConnectionsToBeClosedMoreThanOnceWithNoIllEffects()
+ throws RepositorySourceException, InterruptedException {
assertThat(pool.getTotalConnectionsCreated(), is(0l));
assertThat(pool.getTotalConnectionsUsed(), is(0l));
@@ -160,24 +160,42 @@
public void shouldBlockClientsWhenNotEnoughConnections() throws Exception {
int numConnectionsInPool = 1;
int numClients = 2;
- RepositoryOperation.Factory<Integer> operationFactory = RepositoryTestOperations.createMultipleLoadOperationFactory(env, 10);
- runLoadTest(repositorySource, numConnectionsInPool, numClients, 4, TimeUnit.SECONDS, operationFactory);
+ RepositoryConnectionPool pool = new RepositoryConnectionPool(repositorySource);
+ pool.setCorePoolSize(numConnectionsInPool);
+ pool.setMaximumPoolSize(numConnectionsInPool);
+ RepositoryOperation.Factory<Integer> operationFactory = RepositorySourceLoadHarness.createMultipleLoadOperationFactory(env,
+ 10);
+ runLoadTest(pool, numClients, 100, TimeUnit.MILLISECONDS, operationFactory);
+ pool.shutdown();
+ pool.awaitTermination(4, TimeUnit.SECONDS);
}
@Test
public void shouldLimitClientsToRunSequentiallyWithOneConnectionInPool() throws Exception {
int numConnectionsInPool = 1;
int numClients = 3;
- RepositoryOperation.Factory<Integer> operationFactory = RepositoryTestOperations.createMultipleLoadOperationFactory(env, 10);
- runLoadTest(repositorySource, numConnectionsInPool, numClients, 4, TimeUnit.SECONDS, operationFactory);
+ RepositoryConnectionPool pool = new RepositoryConnectionPool(repositorySource);
+ pool.setCorePoolSize(numConnectionsInPool);
+ pool.setMaximumPoolSize(numConnectionsInPool);
+ RepositoryOperation.Factory<Integer> operationFactory = RepositorySourceLoadHarness.createMultipleLoadOperationFactory(env,
+ 10);
+ runLoadTest(pool, numClients, 100, TimeUnit.MILLISECONDS, operationFactory);
+ pool.shutdown();
+ pool.awaitTermination(4, TimeUnit.SECONDS);
}
@Test
public void shouldClientsToRunConncurrentlyWithTwoConnectionsInPool() throws Exception {
int numConnectionsInPool = 2;
int numClients = 10;
- RepositoryOperation.Factory<Integer> operationFactory = RepositoryTestOperations.createMultipleLoadOperationFactory(env, 10);
- runLoadTest(repositorySource, numConnectionsInPool, numClients, 4, TimeUnit.SECONDS, operationFactory);
+ RepositoryConnectionPool pool = new RepositoryConnectionPool(repositorySource);
+ pool.setCorePoolSize(numConnectionsInPool);
+ pool.setMaximumPoolSize(numConnectionsInPool);
+ RepositoryOperation.Factory<Integer> operationFactory = RepositorySourceLoadHarness.createMultipleLoadOperationFactory(env,
+ 10);
+ runLoadTest(pool, numClients, 100, TimeUnit.MILLISECONDS, operationFactory);
+ pool.shutdown();
+ pool.awaitTermination(4, TimeUnit.SECONDS);
}
@Ignore( "doesn't run on hudson" )
@@ -185,13 +203,20 @@
public void shouldClientsToRunConncurrentlyWithMultipleConnectionInPool() throws Exception {
int numConnectionsInPool = 10;
int numClients = 50;
- RepositoryOperation.Factory<Integer> operationFactory = RepositoryTestOperations.createMultipleLoadOperationFactory(env, 20);
- List<Integer> results = runLoadTest(repositorySource, numConnectionsInPool, numClients, 10, TimeUnit.SECONDS, operationFactory);
+ RepositoryConnectionPool pool = new RepositoryConnectionPool(repositorySource);
+ pool.setCorePoolSize(numConnectionsInPool);
+ pool.setMaximumPoolSize(numConnectionsInPool);
+ RepositoryOperation.Factory<Integer> operationFactory = RepositorySourceLoadHarness.createMultipleLoadOperationFactory(env,
+ 20);
+ List<Future<Integer>> results = runLoadTest(pool, numClients, 200, TimeUnit.MILLISECONDS, operationFactory);
int total = 0;
- for (Integer integer : results) {
- if (integer != null) total += integer;
+ for (Future<Integer> result : results) {
+ assertThat(result.isDone(), is(true));
+ if (result.isDone()) total += result.get();
}
assertThat(total, is(20 * numClients));
+ pool.shutdown();
+ pool.awaitTermination(4, TimeUnit.SECONDS);
}
}
Modified: branches/maeste/dna-spi/src/test/java/org/jboss/dna/spi/graph/connection/RepositorySourceLoadHarness.java
===================================================================
--- branches/maeste/dna-spi/src/test/java/org/jboss/dna/spi/graph/connection/RepositorySourceLoadHarness.java 2008-06-11 08:35:21 UTC (rev 264)
+++ branches/maeste/dna-spi/src/test/java/org/jboss/dna/spi/graph/connection/RepositorySourceLoadHarness.java 2008-06-11 08:45:51 UTC (rev 265)
@@ -26,7 +26,6 @@
import java.util.List;
import java.util.concurrent.Callable;
import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
@@ -37,12 +36,21 @@
/**
* A test harness for using repository connections under load.
+ *
* @author Randall Hauch
*/
public class RepositorySourceLoadHarness {
- public static <T> List<T> runLoadTest( RepositoryConnectionFactory connectionFactory, int numConnectionsInPool, int numClients, long maxTime, TimeUnit maxTimeUnit,
- RepositoryOperation.Factory<T> clientFactory ) throws InterruptedException, ExecutionException {
+ public static Future<Integer> execute( RepositoryConnectionFactory connectionFactory, ExecutionEnvironment env, long maxTime, TimeUnit maxTimeUnit ) throws InterruptedException {
+ int numTimes = 1;
+ int numClients = 1;
+ RepositoryOperation.Factory<Integer> operationFactory = RepositorySourceLoadHarness.createMultipleLoadOperationFactory(env, numTimes);
+ List<Future<Integer>> results = runLoadTest(connectionFactory, numClients, maxTime, maxTimeUnit, operationFactory);
+ return results.get(0);
+ }
+
+ public static <T> List<Future<T>> runLoadTest( RepositoryConnectionFactory connectionFactory, int numClients, long maxTime, TimeUnit maxTimeUnit, RepositoryOperation.Factory<T> clientFactory )
+ throws InterruptedException {
// Create the clients ...
Collection<RepositoryOperation<T>> clients = new ArrayList<RepositoryOperation<T>>();
for (int i = 0; i != numClients; ++i) {
@@ -50,71 +58,47 @@
}
// and run the test ...
- return runLoadTest(connectionFactory, numConnectionsInPool, maxTime, maxTimeUnit, clients);
+ return runLoadTest(connectionFactory, maxTime, maxTimeUnit, clients);
}
- public static <T> List<T> runLoadTest( RepositoryConnectionFactory connectionFactory, int numConnectionsInPool, long maxTime, TimeUnit maxTimeUnit, RepositoryOperation<T>... clients )
- throws InterruptedException, ExecutionException {
+ public static <T> List<Future<T>> runLoadTest( RepositoryConnectionFactory connectionFactory, long maxTime, TimeUnit maxTimeUnit, RepositoryOperation<T>... clients ) throws InterruptedException {
// Create the client collection ...
Collection<RepositoryOperation<T>> clientCollection = new ArrayList<RepositoryOperation<T>>();
for (RepositoryOperation<T> client : clients) {
if (client != null) clientCollection.add(client);
}
// and run the test ...
- return runLoadTest(connectionFactory, numConnectionsInPool, maxTime, maxTimeUnit, clientCollection);
+ return runLoadTest(connectionFactory, maxTime, maxTimeUnit, clientCollection);
}
- public static <T> List<T> runLoadTest( RepositoryConnectionFactory connectionFactory, int numConnectionsInPool, long maxTime, TimeUnit maxTimeUnit, Collection<RepositoryOperation<T>> clients )
- throws InterruptedException, ExecutionException {
+ public static <T> List<Future<T>> runLoadTest( RepositoryConnectionFactory connectionFactory, long maxTime, TimeUnit maxTimeUnit, Collection<RepositoryOperation<T>> clients )
+ throws InterruptedException {
assert connectionFactory != null;
- assert numConnectionsInPool > 0;
assert clients != null;
assert clients.size() > 0;
- // Create a connection pool ...
- final RepositoryConnectionPool connectionPool = new RepositoryConnectionPool(connectionFactory, numConnectionsInPool, numConnectionsInPool, 10, TimeUnit.SECONDS);
-
// Create an Executor Service, using a thread factory that makes the first 'n' thread all wait for each other ...
- final ThreadFactory threadFactory = new TestThreadFactory(clients.size(), connectionPool);
- final ExecutorService clientPool = Executors.newFixedThreadPool(clients.size(), threadFactory);
+ ExecutorService clientPool = null;
+ if (clients.size() == 1) {
+ clientPool = Executors.newSingleThreadExecutor();
+ } else {
+ final ThreadFactory threadFactory = new TestThreadFactory(clients.size());
+ clientPool = Executors.newFixedThreadPool(clients.size(), threadFactory);
+ }
try {
// Wrap each client by a callable and by another that uses a latch ...
- List<Callable<T>> callables = connectionPool.callables(clients);
+ List<Callable<T>> callables = RepositoryOperations.createCallables(connectionFactory, clients);
// Run the tests ...
List<Future<T>> futures = clientPool.invokeAll(callables, maxTime, maxTimeUnit);
-
- // Whether or not all clients completed, process the results ...
- List<T> results = new ArrayList<T>();
- for (Future<T> future : futures) {
- if (future.isDone() && !future.isCancelled()) {
- // Record the results ...
- results.add(future.get());
- } else {
- // Record the results as null
- results.add(null);
- // Cancell any operation that is not completed
- future.cancel(true);
- }
- }
- // Return the results ...
- return results;
+ return futures;
} finally {
- try {
- // Shut down the pool of clients ...
- clientPool.shutdown();
- if (!clientPool.awaitTermination(5, TimeUnit.SECONDS)) {
- String msg = "Unable to shutdown clients after 5 seconds";
- Logger.getLogger(RepositorySourceLoadHarness.class).error(MockI18n.passthrough, msg);
- }
- } finally {
- // Shut down the connections ...
- connectionPool.shutdown();
- if (!connectionPool.awaitTermination(5, TimeUnit.SECONDS)) {
- String msg = "Unable to shutdown connections after 5 seconds";
- Logger.getLogger(RepositorySourceLoadHarness.class).error(MockI18n.passthrough, msg);
- }
+ // Shut down the pool of clients ...
+ clientPool.shutdown();
+ if (!clientPool.awaitTermination(5, TimeUnit.SECONDS)) {
+ String msg = "Unable to shutdown clients after 5 seconds";
+ Logger.getLogger(RepositorySourceLoadHarness.class).error(MockI18n.passthrough, msg);
}
}
@@ -123,16 +107,17 @@
/**
* A thread factory that makes an initial set of threads wait until all of those threads are created and ready. This is useful
* in testing to ensure that the first threads created don't get a jump start.
+ *
* @author Randall Hauch
*/
protected static class TestThreadFactory implements ThreadFactory {
+ protected final int totalNumberOfThreads;
protected final CountDownLatch latch;
- protected final RepositoryConnectionPool pool;
- public TestThreadFactory( int numberOfThreadsToWait, RepositoryConnectionPool pool ) {
+ public TestThreadFactory( int numberOfThreadsToWait ) {
this.latch = new CountDownLatch(numberOfThreadsToWait);
- this.pool = pool;
+ this.totalNumberOfThreads = numberOfThreadsToWait;
}
/**
@@ -146,20 +131,95 @@
*/
@Override
public void run() {
- try {
- // Count down the thread count (if 0, this doesn't do anything)
- latch.countDown();
- // Wait for all threads to reach this point ...
- latch.await();
- } catch (InterruptedException e) {
- throw new RuntimeException(e);
+ if (totalNumberOfThreads > 1) {
+ // There are other threads, and we want to synchronize with them ...
+ try {
+ // Count down the number of threads that are to reach this point (if 0, this doesn't do anything)
+ latch.countDown();
+ // Wait for all threads to reach this point ...
+ latch.await();
+ } catch (InterruptedException e) {
+ throw new RuntimeException(e);
+ }
}
- // Check that the number of connections-in-use is smaller than the maximum pool size
- if (pool != null) assert pool.getInUseCount() <= pool.getMaximumPoolSize();
super.run();
}
};
}
}
+ /**
+ * Return an operation factory that produces {@link RepositoryOperation} instances that each call
+ * {@link RepositoryConnection#execute(ExecutionEnvironment, org.jboss.dna.spi.graph.commands.GraphCommand...)} the supplied
+ * number of times, intermixed with random math operations and {@link Thread#yield() yielding}.
+ *
+ * @param env the environment
+ * @param callsPerOperation the number of <code>load</code> calls per RepositoryOperation
+ * @return the factory
+ */
+ public static RepositoryOperation.Factory<Integer> createMultipleLoadOperationFactory( final ExecutionEnvironment env, final int callsPerOperation ) {
+ return new RepositoryOperation.Factory<Integer>() {
+
+ public RepositoryOperation<Integer> create() {
+ return new CallLoadMultipleTimes(env, callsPerOperation);
+ }
+ };
+ }
+
+ public static class CallLoadMultipleTimes implements RepositoryOperation<Integer> {
+
+ private final int count;
+ private final ExecutionEnvironment env;
+
+ public CallLoadMultipleTimes( ExecutionEnvironment env, int count ) {
+ Logger.getLogger(RepositorySourceLoadHarness.class).debug("Creating repository operation to call {0} times", count);
+ this.count = count;
+ this.env = env;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getName() {
+ return Thread.currentThread().getName() + "-CallLoadMultipleTimes";
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Integer run( RepositoryConnection connection ) throws RepositorySourceException, InterruptedException {
+ Logger.getLogger(RepositorySourceLoadHarness.class).debug("Running {0} operation", this.getClass().getSimpleName());
+ int total = count;
+ for (int i = 0; i != count; ++i) {
+ // Add two random numbers ...
+ int int1 = random(this.hashCode() ^ (int)System.nanoTime() * i);
+ if (i % 2 == 0) {
+ Thread.yield();
+ }
+ connection.execute(env);
+ int int2 = random(this.hashCode() ^ (int)System.nanoTime() + i);
+ total += Math.min(Math.abs(Math.max(int1, int2) + int1 * int2 / 3), count);
+ }
+ Logger.getLogger(RepositorySourceLoadHarness.class).debug("Finishing {0} operation", this.getClass().getSimpleName());
+ return total < count ? total : count; // should really always return count
+ }
+ }
+
+ /**
+ * A "random-enough" number generator that is cheap and that has no synchronization issues (like some other random number
+ * generators).
+ * <p>
+ * This was taken from <a href="http://wwww.jcip.org">Java Concurrency In Practice</a> (page 253).
+ * </p>
+ *
+ * @param seed the seed, typically based on a hash code and nanoTime
+ * @return a number that is "random enough"
+ */
+ public static int random( int seed ) {
+ seed ^= (seed << 6);
+ seed ^= (seed >>> 21);
+ seed ^= (seed << 7);
+ return seed;
+ }
+
}
Deleted: branches/maeste/dna-spi/src/test/java/org/jboss/dna/spi/graph/connection/RepositoryTestOperations.java
===================================================================
--- branches/maeste/dna-spi/src/test/java/org/jboss/dna/spi/graph/connection/RepositoryTestOperations.java 2008-06-11 08:35:21 UTC (rev 264)
+++ branches/maeste/dna-spi/src/test/java/org/jboss/dna/spi/graph/connection/RepositoryTestOperations.java 2008-06-11 08:45:51 UTC (rev 265)
@@ -1,102 +0,0 @@
-/*
- * 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.spi.graph.connection;
-
-import org.jboss.dna.common.util.Logger;
-
-/**
- * @author Randall Hauch
- */
-public class RepositoryTestOperations {
-
- /**
- * Return an operation factory that produces {@link RepositoryOperation} instances that each call
- * {@link RepositoryConnection#execute(ExecutionEnvironment, org.jboss.dna.spi.graph.commands.GraphCommand...)} the supplied
- * number of times, intermixed with random math operations and {@link Thread#yield() yielding}.
- * @param env the environment
- * @param callsPerOperation the number of <code>load</code> calls per RepositoryOperation
- * @return the factory
- */
- public static RepositoryOperation.Factory<Integer> createMultipleLoadOperationFactory( final ExecutionEnvironment env, final int callsPerOperation ) {
- return new RepositoryOperation.Factory<Integer>() {
-
- public RepositoryOperation<Integer> create() {
- return new CallLoadMultipleTimes(env, callsPerOperation);
- }
- };
- }
-
- public static class CallLoadMultipleTimes implements RepositoryOperation<Integer> {
-
- private final int count;
- private final ExecutionEnvironment env;
-
- public CallLoadMultipleTimes( ExecutionEnvironment env, int count ) {
- this.count = count;
- this.env = env;
- }
-
- /**
- * {@inheritDoc}
- */
- public String getName() {
- return Thread.currentThread().getName() + "-CallLoadMultipleTimes";
- }
-
- /**
- * {@inheritDoc}
- */
- public Integer run( RepositoryConnection connection ) throws InterruptedException {
- Logger.getLogger(RepositoryTestOperations.class).debug("Running {} operation", this.getClass().getSimpleName());
- int total = count;
- for (int i = 0; i != count; ++i) {
- // Add two random numbers ...
- int int1 = random(this.hashCode() ^ (int)System.nanoTime() * i);
- if (i % 2 == 0) {
- Thread.yield();
- }
- connection.execute(env);
- int int2 = random(this.hashCode() ^ (int)System.nanoTime() + i);
- total += Math.min(Math.abs(Math.max(int1, int2) + int1 * int2 / 3), count);
- }
- Logger.getLogger(RepositoryTestOperations.class).debug("Finishing {} operation", this.getClass().getSimpleName());
- return total < count ? total : count; // should really always return count
- }
- }
-
- /**
- * A "random-enough" number generator that is cheap and that has no synchronization issues (like some other random number
- * generators).
- * <p>
- * This was taken from <a href="http://wwww.jcip.org">Java Concurrency In Practice</a> (page 253).
- * </p>
- * @param seed the seed, typically based on a hash code and nanoTime
- * @return a number that is "random enough"
- */
- public static int random( int seed ) {
- seed ^= (seed << 6);
- seed ^= (seed >>> 21);
- seed ^= (seed << 7);
- return seed;
- }
-
-}
Copied: branches/maeste/dna-spi/src/test/java/org/jboss/dna/spi/graph/connection/TimeDelayingRepositorySource.java (from rev 263, trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/connection/TimeDelayingRepositorySource.java)
===================================================================
--- branches/maeste/dna-spi/src/test/java/org/jboss/dna/spi/graph/connection/TimeDelayingRepositorySource.java (rev 0)
+++ branches/maeste/dna-spi/src/test/java/org/jboss/dna/spi/graph/connection/TimeDelayingRepositorySource.java 2008-06-11 08:45:51 UTC (rev 265)
@@ -0,0 +1,308 @@
+/*
+ * 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.spi.graph.connection;
+
+import static org.mockito.Mockito.mock;
+import java.util.Set;
+import java.util.concurrent.CopyOnWriteArraySet;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.concurrent.atomic.AtomicLong;
+import java.util.concurrent.atomic.AtomicReference;
+import javax.naming.Reference;
+import javax.transaction.xa.XAResource;
+import net.jcip.annotations.ThreadSafe;
+import org.jboss.dna.spi.cache.CachePolicy;
+import org.jboss.dna.spi.graph.commands.GraphCommand;
+
+/**
+ * @author Randall Hauch
+ */
+@ThreadSafe
+public class TimeDelayingRepositorySource implements RepositorySource {
+
+ private final String identifier;
+ private final AtomicInteger retryLimit = new AtomicInteger(0);
+ private final AtomicInteger connectionsOpenedCount = new AtomicInteger(0);
+ private final AtomicInteger connectionsClosedCount = new AtomicInteger(0);
+ private final Set<Connection> openConnections = new CopyOnWriteArraySet<Connection>();
+ private final AtomicLong loadCount = new AtomicLong(0);
+ private final AtomicLong loadDelay = new AtomicLong(0);
+ private final AtomicLong pingCount = new AtomicLong(0);
+ private final AtomicLong pingDelay = new AtomicLong(0);
+ private CachePolicy defaultCachePolicy;
+
+ public TimeDelayingRepositorySource( String identifier ) {
+ this.identifier = identifier;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getName() {
+ return this.identifier;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public int getRetryLimit() {
+ return this.retryLimit.get();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void setRetryLimit( int limit ) {
+ this.retryLimit.set(limit);
+ }
+
+ public CachePolicy getDefaultCachePolicy() {
+ return defaultCachePolicy;
+ }
+
+ public void setDefaultCachePolicy( CachePolicy defaultCachePolicy ) {
+ this.defaultCachePolicy = defaultCachePolicy;
+ }
+
+ /**
+ * @return loadCount
+ */
+ public long getTotalExecuteCount() {
+ return this.loadCount.get();
+ }
+
+ /**
+ * @return pingCount
+ */
+ public long getTotalPingCount() {
+ return this.pingCount.get();
+ }
+
+ /**
+ * @return loadDelay
+ */
+ public long getConnectionExecuteDelayInMillis() {
+ return this.loadDelay.get();
+ }
+
+ public void setConnectionExecuteDelay( long time,
+ TimeUnit unit ) {
+ this.loadDelay.set(unit.toMillis(time));
+ }
+
+ /**
+ * @return pingDelay
+ */
+ public long getConnectionPingDelayInMillis() {
+ return this.pingDelay.get();
+ }
+
+ public void setConnectionPingDelay( long time,
+ TimeUnit unit ) {
+ this.pingDelay.set(unit.toMillis(time));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public RepositoryConnection getConnection() throws RepositorySourceException {
+ int connectionNumber = this.connectionsOpenedCount.incrementAndGet();
+ String connectionName = "Connection " + connectionNumber;
+ XAResource xaResource = newXaResource(connectionName);
+ Connection c = newConnection(connectionName, xaResource);
+ this.openConnections.add(c);
+ return c;
+ }
+
+ /**
+ * Factory method that can be overridden by subclasses. This method implementation simply creates a mock {@link XAResource}.
+ *
+ * @param connectionName the name of the connection
+ * @return the XAResource, or null if this source does not support XA
+ */
+ protected XAResource newXaResource( String connectionName ) {
+ return mock(XAResource.class);
+ }
+
+ /**
+ * Factory method that can be overridden by subclasses. This method implementation creates a new {@link Connection} that uses
+ * standard bean properties for the various delays and counts.
+ *
+ * @param connectionName
+ * @param xaResource
+ * @return
+ * @throws RepositorySourceException
+ */
+ protected Connection newConnection( String connectionName,
+ XAResource xaResource ) throws RepositorySourceException {
+ Connection c = new Connection(connectionName, this.loadDelay.get(), this.pingDelay.get());
+ c.setXaResource(xaResource);
+ return c;
+ }
+
+ protected void close( Connection conn ) {
+ if (conn != null && this.openConnections.remove(conn)) {
+ this.connectionsClosedCount.incrementAndGet();
+ this.loadCount.addAndGet(conn.getLoadCount());
+ this.pingCount.addAndGet(conn.getPingCount());
+ }
+ }
+
+ public int getOpenConnectionCount() {
+ return this.openConnections.size();
+ }
+
+ public int getTotalConnectionsCreated() {
+ return this.connectionsOpenedCount.get();
+ }
+
+ public int getTotalConnectionsClosed() {
+ return this.connectionsClosedCount.get();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Reference getReference() {
+ throw new UnsupportedOperationException();
+ }
+
+ public class Connection implements RepositoryConnection {
+
+ private final String connectionName;
+ private final AtomicBoolean closed = new AtomicBoolean(false);
+ private final AtomicBoolean loadResponse = new AtomicBoolean(true);
+ private final AtomicBoolean pingResponse = new AtomicBoolean(true);
+ private final AtomicLong closeCount = new AtomicLong(0);
+ private final AtomicLong loadCount = new AtomicLong(0);
+ private final AtomicLong loadDelay;
+ private final AtomicLong pingCount = new AtomicLong(0);
+ private final AtomicLong pingDelay;
+ private final AtomicReference<XAResource> xaResource = new AtomicReference<XAResource>();
+
+ protected Connection( String connectionName,
+ long loadDelay,
+ long pingDelay ) {
+ assert connectionName != null && connectionName.trim().length() != 0;
+ this.loadDelay = new AtomicLong(loadDelay);
+ this.pingDelay = new AtomicLong(pingDelay);
+ this.connectionName = connectionName;
+ }
+
+ public String getConnectionName() {
+ return this.connectionName;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void close() {
+ this.closeCount.incrementAndGet();
+ this.closed.set(true);
+ TimeDelayingRepositorySource.this.close(this);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getSourceName() {
+ return TimeDelayingRepositorySource.this.getName();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public CachePolicy getDefaultCachePolicy() {
+ return TimeDelayingRepositorySource.this.getDefaultCachePolicy();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public XAResource getXAResource() {
+ return this.xaResource.get();
+ }
+
+ public void setXaResource( XAResource xaResource ) {
+ this.xaResource.set(xaResource);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void execute( ExecutionEnvironment env,
+ GraphCommand... commands ) throws InterruptedException {
+ long delay = this.loadDelay.get();
+ if (delay > 0l) Thread.sleep(delay);
+ this.loadCount.incrementAndGet();
+ }
+
+ public void setLoadResponse( boolean response ) {
+ this.loadResponse.set(response);
+ }
+
+ public void setLoadDelay( long time,
+ TimeUnit unit ) {
+ this.loadDelay.set(unit.toMillis(time));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean ping( long time,
+ TimeUnit unit ) throws InterruptedException {
+ Thread.sleep(this.pingDelay.get());
+ return this.pingResponse.get();
+ }
+
+ public void setPingResponse( boolean pingResponse ) {
+ this.pingResponse.set(pingResponse);
+ }
+
+ public void setPingDelay( long time,
+ TimeUnit unit ) {
+ this.pingDelay.set(unit.toMillis(time));
+ }
+
+ public long getPingCount() {
+ return this.pingCount.get();
+ }
+
+ public long getLoadCount() {
+ return this.loadCount.get();
+ }
+
+ public long getCloseCount() {
+ return this.closeCount.get();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void setListener( RepositorySourceListener listener ) {
+ }
+
+ }
+
+}
Modified: branches/maeste/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/AbstractValueFactoryTest.java
===================================================================
--- branches/maeste/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/AbstractValueFactoryTest.java 2008-06-11 08:35:21 UTC (rev 264)
+++ branches/maeste/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/AbstractValueFactoryTest.java 2008-06-11 08:45:51 UTC (rev 265)
@@ -39,7 +39,6 @@
import org.jboss.dna.spi.graph.PropertyType;
import org.jboss.dna.spi.graph.Reference;
import org.jboss.dna.spi.graph.ValueFactory;
-import org.jboss.dna.spi.graph.ValueFormatException;
import org.junit.Before;
import org.junit.Test;
@@ -52,75 +51,79 @@
private static class MockFactory extends AbstractValueFactory<String> {
- protected MockFactory( TextDecoder decoder, StringValueFactory stringValueFactory ) {
+ protected MockFactory( TextDecoder decoder,
+ StringValueFactory stringValueFactory ) {
super(PropertyType.STRING, decoder, stringValueFactory);
}
- public String create( String value ) throws ValueFormatException {
+ public String create( String value ) {
return null;
}
- public String create( String value, TextDecoder decoder ) throws ValueFormatException {
+ public String create( String value,
+ TextDecoder decoder ) {
return null;
}
- public String create( int value ) throws ValueFormatException {
+ public String create( int value ) {
return null;
}
- public String create( long value ) throws ValueFormatException {
+ public String create( long value ) {
return null;
}
- public String create( boolean value ) throws ValueFormatException {
+ public String create( boolean value ) {
return null;
}
- public String create( float value ) throws ValueFormatException {
+ public String create( float value ) {
return null;
}
- public String create( double value ) throws ValueFormatException {
+ public String create( double value ) {
return null;
}
- public String create( BigDecimal value ) throws ValueFormatException {
+ public String create( BigDecimal value ) {
return null;
}
- public String create( Calendar value ) throws ValueFormatException {
+ public String create( Calendar value ) {
return null;
}
- public String create( Date value ) throws ValueFormatException {
+ public String create( Date value ) {
return null;
}
- public String create( Name value ) throws ValueFormatException {
+ public String create( Name value ) {
return null;
}
- public String create( Path value ) throws ValueFormatException {
+ public String create( Path value ) {
return null;
}
- public String create( Reference value ) throws ValueFormatException {
+ public String create( Reference value ) {
return null;
}
- public String create( URI value ) throws ValueFormatException {
+ public String create( URI value ) {
return null;
}
- public String create( byte[] value ) throws ValueFormatException {
+ public String create( byte[] value ) {
return null;
}
- public String create( InputStream stream, int approximateLength ) throws ValueFormatException {
+ public String create( InputStream stream,
+ int approximateLength ) {
return null;
}
- public String create( Reader reader, int approximateLength ) throws ValueFormatException {
+ public String create( Reader reader,
+ int approximateLength ) {
return null;
}
}
@@ -128,7 +131,7 @@
private AbstractValueFactory factory;
@Before
- public void beforeEach() throws Exception {
+ public void beforeEach() {
factory = new MockFactory(null, null);
}
Modified: branches/maeste/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/BasicNameTest.java
===================================================================
--- branches/maeste/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/BasicNameTest.java 2008-06-11 08:35:21 UTC (rev 264)
+++ branches/maeste/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/BasicNameTest.java 2008-06-11 08:45:51 UTC (rev 265)
@@ -44,7 +44,7 @@
private String validNamespacePrefix;
@Before
- public void beforeEach() throws Exception {
+ public void beforeEach() {
this.validNamespaceUri = "http://www.jboss.org/dna";
this.validLocalName = "localPart";
this.validNamespacePrefix = "dna";
@@ -76,13 +76,13 @@
}
@Test( expected = IllegalArgumentException.class )
- public void shouldNotAllowNullLocalNameInConstructor() {
- new BasicName(validNamespaceUri, null);
+ public void shouldNotAllowNullLocalNameInConstructor() {
+ new BasicName(validNamespaceUri, null);
}
@Test( expected = IllegalArgumentException.class )
- public void shouldAllowEmptyLocalNameInConstructor() {
- new BasicName(validNamespaceUri, "");
+ public void shouldAllowEmptyLocalNameInConstructor() {
+ new BasicName(validNamespaceUri, "");
}
@Test
Modified: branches/maeste/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/BasicNamespaceRegistryTest.java
===================================================================
--- branches/maeste/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/BasicNamespaceRegistryTest.java 2008-06-11 08:35:21 UTC (rev 264)
+++ branches/maeste/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/BasicNamespaceRegistryTest.java 2008-06-11 08:45:51 UTC (rev 265)
@@ -41,7 +41,7 @@
private BasicNamespaceRegistry namespaceRegistry;
@Before
- public void setUp() throws Exception {
+ public void setUp() {
namespaceRegistry = new BasicNamespaceRegistry();
validNamespaceUri1 = "http://www.jboss.org/dna/2";
validNamespaceUri2 = "http://acme.com/something";
Modified: branches/maeste/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/BasicPathSegmentTest.java
===================================================================
--- branches/maeste/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/BasicPathSegmentTest.java 2008-06-11 08:35:21 UTC (rev 264)
+++ branches/maeste/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/BasicPathSegmentTest.java 2008-06-11 08:45:51 UTC (rev 265)
@@ -46,7 +46,7 @@
private Path.Segment segment2;
@Before
- public void beforeEach() throws Exception {
+ public void beforeEach() {
this.registry = new BasicNamespaceRegistry();
this.registry.register("dna", "http://www.jboss.org/dna/namespace");
this.stringValueFactory = new StringValueFactory(Path.DEFAULT_DECODER, Path.DEFAULT_ENCODER);
Modified: branches/maeste/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/BasicPathTest.java
===================================================================
--- branches/maeste/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/BasicPathTest.java 2008-06-11 08:35:21 UTC (rev 264)
+++ branches/maeste/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/BasicPathTest.java 2008-06-11 08:45:51 UTC (rev 265)
@@ -36,7 +36,6 @@
import org.jboss.dna.spi.graph.Name;
import org.jboss.dna.spi.graph.Path;
import org.jboss.dna.spi.graph.PathNotFoundException;
-import org.jboss.dna.spi.graph.ValueFormatException;
import org.junit.Before;
import org.junit.Test;
@@ -60,11 +59,13 @@
private PathValueFactory pathFactory;
@Before
- public void beforeEach() throws Exception {
+ public void beforeEach() {
validNamespacePrefix = "dna";
validNamespaceUri = "http://www.jboss.org/dna";
- validSegmentNames = new Name[] {new BasicName(validNamespaceUri, "a"), new BasicName(validNamespaceUri, "b"), new BasicName(validNamespaceUri, "c")};
- validSegments = new Path.Segment[] {new BasicPathSegment(validSegmentNames[0]), new BasicPathSegment(validSegmentNames[1]), new BasicPathSegment(validSegmentNames[1])};
+ validSegmentNames = new Name[] {new BasicName(validNamespaceUri, "a"), new BasicName(validNamespaceUri, "b"),
+ new BasicName(validNamespaceUri, "c")};
+ validSegments = new Path.Segment[] {new BasicPathSegment(validSegmentNames[0]),
+ new BasicPathSegment(validSegmentNames[1]), new BasicPathSegment(validSegmentNames[1])};
validSegmentsList = new ArrayList<Path.Segment>();
for (Path.Segment segment : validSegments) {
validSegmentsList.add(segment);
@@ -178,12 +179,12 @@
assertThat(pathFactory.create("/").isRoot(), is(true));
}
- @Test( expected = ValueFormatException.class )
+ @Test( expected = IllegalArgumentException.class )
public void shouldNotConstructPathWithSuccessiveDelimiters() {
pathFactory.create("///a/b///c//d//");
}
- @Test( expected = ValueFormatException.class )
+ @Test( expected = IllegalArgumentException.class )
public void shouldNotConstructPathWithOnlyDelimiters() {
pathFactory.create("///");
}
@@ -525,7 +526,8 @@
testSegmentsByIteratorAndListAndArray(ROOT.getString());
}
- public void testSegmentsByIteratorAndListAndArray( String pathStr, String... expectedSegmentStrings ) {
+ public void testSegmentsByIteratorAndListAndArray( String pathStr,
+ String... expectedSegmentStrings ) {
path = pathFactory.create(pathStr);
assertThat(expectedSegmentStrings.length, is(path.size()));
Path.Segment[] segmentArray = path.getSegmentsArray();
@@ -549,7 +551,8 @@
@Test
public void shouldGetStringWithNamespaceUrisIfNoNamespaceRegistryIsProvided() {
path = pathFactory.create("/dna:a/b/dna:c/../d/./dna:e/../..");
- assertThat(path.getString(NO_OP_ENCODER), is("/{http://www.jboss.org/dna}a/{}b/{http://www.jboss.org/dna}c/../{}d/./{http://www.jboss.org/dna}e/../.."));
+ assertThat(path.getString(NO_OP_ENCODER),
+ is("/{http://www.jboss.org/dna}a/{}b/{http://www.jboss.org/dna}c/../{}d/./{http://www.jboss.org/dna}e/../.."));
}
@Test
@@ -628,7 +631,16 @@
@Test
public void shouldReturnSubpathIfValidStartingIndexAndEndingIndexAreProvided() {
path = pathFactory.create("/dna:a/b/dna:c/../d/./dna:e/../..");
- assertThat(path.subpath(0, path.size()), hasSegments(pathFactory, "dna:a", "b", "dna:c", "..", "d", ".", "dna:e", "..", ".."));
+ assertThat(path.subpath(0, path.size()), hasSegments(pathFactory,
+ "dna:a",
+ "b",
+ "dna:c",
+ "..",
+ "d",
+ ".",
+ "dna:e",
+ "..",
+ ".."));
assertThat(path.subpath(0, path.size()), is(path));
assertThat(path.subpath(0, path.size()), is(sameInstance(path)));
assertThat(path.subpath(1, path.size()), hasSegments(pathFactory, "b", "dna:c", "..", "d", ".", "dna:e", "..", ".."));
Modified: branches/maeste/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/BooleanValueFactoryTest.java
===================================================================
--- branches/maeste/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/BooleanValueFactoryTest.java 2008-06-11 08:35:21 UTC (rev 264)
+++ branches/maeste/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/BooleanValueFactoryTest.java 2008-06-11 08:45:51 UTC (rev 265)
@@ -23,6 +23,7 @@
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
+import static org.mockito.Mockito.mock;
import java.io.ByteArrayInputStream;
import java.io.StringReader;
import java.net.URI;
@@ -31,19 +32,17 @@
import org.jboss.dna.spi.graph.Name;
import org.jboss.dna.spi.graph.Path;
import org.jboss.dna.spi.graph.Reference;
-import org.jboss.dna.spi.graph.ValueFormatException;
-import org.jmock.Mockery;
import org.junit.Before;
import org.junit.Test;
/**
* @author Randall Hauch
+ * @author John Verhaeg
*/
public class BooleanValueFactoryTest {
private BooleanValueFactory factory;
private StringValueFactory stringFactory;
- private Mockery context;
/**
* @throws java.lang.Exception
@@ -52,7 +51,6 @@
public void setUp() throws Exception {
stringFactory = new StringValueFactory(Path.URL_DECODER, Path.DEFAULT_ENCODER);
factory = new BooleanValueFactory(Path.URL_DECODER, stringFactory);
- context = new Mockery();
}
@Test
@@ -85,57 +83,57 @@
assertThat(factory.create(" 1 "), is(false));
}
- @Test( expected = ValueFormatException.class )
+ @Test( expected = UnsupportedOperationException.class )
public void shouldNotCreateBooleanFromIntegerValue() {
factory.create(1);
}
- @Test( expected = ValueFormatException.class )
+ @Test( expected = UnsupportedOperationException.class )
public void shouldNotCreateBooleanFromLongValue() {
factory.create(1l);
}
- @Test( expected = ValueFormatException.class )
+ @Test( expected = UnsupportedOperationException.class )
public void shouldNotCreateBooleanFromFloatValue() {
factory.create(1.0f);
}
- @Test( expected = ValueFormatException.class )
+ @Test( expected = UnsupportedOperationException.class )
public void shouldNotCreateBooleanFromDoubleValue() {
factory.create(1.0d);
}
- @Test( expected = ValueFormatException.class )
+ @Test( expected = UnsupportedOperationException.class )
public void shouldNotCreateBooleanFromBigDecimal() {
factory.create(1.0d);
}
- @Test( expected = ValueFormatException.class )
+ @Test( expected = UnsupportedOperationException.class )
public void shouldNotCreateBooleanFromDate() {
factory.create(new Date());
}
- @Test( expected = ValueFormatException.class )
+ @Test( expected = UnsupportedOperationException.class )
public void shouldNotCreateBooleanFromCalendar() {
factory.create(Calendar.getInstance());
}
- @Test( expected = ValueFormatException.class )
+ @Test( expected = UnsupportedOperationException.class )
public void shouldNotCreateBooleanFromName() {
- factory.create(context.mock(Name.class));
+ factory.create(mock(Name.class));
}
- @Test( expected = ValueFormatException.class )
+ @Test( expected = UnsupportedOperationException.class )
public void shouldNotCreateBooleanFromPath() {
- factory.create(context.mock(Path.class));
+ factory.create(mock(Path.class));
}
- @Test( expected = ValueFormatException.class )
+ @Test( expected = UnsupportedOperationException.class )
public void shouldNotCreateBooleanFromReference() {
- factory.create(context.mock(Reference.class));
+ factory.create(mock(Reference.class));
}
- @Test( expected = ValueFormatException.class )
+ @Test( expected = UnsupportedOperationException.class )
public void shouldNotCreateBooleanFromUri() throws Exception {
factory.create(new URI("http://www.jboss.org"));
}
@@ -159,7 +157,7 @@
}
@Test
- public void shouldCreateBooleanFromReaderContainingTrueOrFalseStringRegardlessOfCase() throws Exception {
+ public void shouldCreateBooleanFromReaderContainingTrueOrFalseStringRegardlessOfCase() {
assertThat(factory.create(new StringReader("true")), is(true));
assertThat(factory.create(new StringReader("false")), is(false));
assertThat(factory.create(new StringReader("TRUE")), is(true));
Modified: branches/maeste/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/DecimalValueFactoryTest.java
===================================================================
--- branches/maeste/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/DecimalValueFactoryTest.java 2008-06-11 08:35:21 UTC (rev 264)
+++ branches/maeste/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/DecimalValueFactoryTest.java 2008-06-11 08:45:51 UTC (rev 265)
@@ -23,6 +23,7 @@
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
+import static org.mockito.Mockito.mock;
import java.io.ByteArrayInputStream;
import java.io.StringReader;
import java.math.BigDecimal;
@@ -32,19 +33,17 @@
import org.jboss.dna.spi.graph.Name;
import org.jboss.dna.spi.graph.Path;
import org.jboss.dna.spi.graph.Reference;
-import org.jboss.dna.spi.graph.ValueFormatException;
-import org.jmock.Mockery;
import org.junit.Before;
import org.junit.Test;
/**
* @author Randall Hauch
+ * @author John Verhaeg
*/
public class DecimalValueFactoryTest {
private DecimalValueFactory factory;
private StringValueFactory stringFactory;
- private Mockery context;
/**
* @throws java.lang.Exception
@@ -53,10 +52,9 @@
public void setUp() throws Exception {
stringFactory = new StringValueFactory(Path.URL_DECODER, Path.DEFAULT_ENCODER);
factory = new DecimalValueFactory(Path.URL_DECODER, stringFactory);
- context = new Mockery();
}
- @Test( expected = ValueFormatException.class )
+ @Test( expected = UnsupportedOperationException.class )
public void shouldNotCreateDecimalFromBooleanValue() {
factory.create(true);
}
@@ -113,22 +111,22 @@
assertThat(factory.create(value), is(BigDecimal.valueOf(value.getTimeInMillis())));
}
- @Test( expected = ValueFormatException.class )
+ @Test( expected = UnsupportedOperationException.class )
public void shouldNotCreateDecimalFromName() {
- factory.create(context.mock(Name.class));
+ factory.create(mock(Name.class));
}
- @Test( expected = ValueFormatException.class )
+ @Test( expected = UnsupportedOperationException.class )
public void shouldNotCreateDecimalFromPath() {
- factory.create(context.mock(Path.class));
+ factory.create(mock(Path.class));
}
- @Test( expected = ValueFormatException.class )
+ @Test( expected = UnsupportedOperationException.class )
public void shouldNotCreateDecimalFromReference() {
- factory.create(context.mock(Reference.class));
+ factory.create(mock(Reference.class));
}
- @Test( expected = ValueFormatException.class )
+ @Test( expected = UnsupportedOperationException.class )
public void shouldNotCreateDecimalFromUri() throws Exception {
factory.create(new URI("http://www.jboss.org"));
}
@@ -148,24 +146,25 @@
}
@Test
- public void shouldCreateDecimalFromReaderContainingStringWithDecimal() throws Exception {
+ public void shouldCreateDecimalFromReaderContainingStringWithDecimal() {
assertThat(factory.create(new StringReader("1")), is(BigDecimal.valueOf(1l)));
assertThat(factory.create(new StringReader("-1.0")), is(BigDecimal.valueOf(-1.d)));
assertThat(factory.create(new StringReader("100.000101")), is(BigDecimal.valueOf(100.000101d)));
}
- @Test( expected = ValueFormatException.class )
+ @Test( expected = IllegalArgumentException.class )
public void shouldNotCreateDecimalFromByteArrayContainingUtf8EncodingOfStringWithContentsOtherThanDecimal() throws Exception {
factory.create("something".getBytes("UTF-8"));
}
- @Test( expected = ValueFormatException.class )
- public void shouldNotCreateDecimalFromInputStreamContainingUtf8EncodingOfStringWithContentsOtherThanDecimal() throws Exception {
+ @Test( expected = IllegalArgumentException.class )
+ public void shouldNotCreateDecimalFromInputStreamContainingUtf8EncodingOfStringWithContentsOtherThanDecimal()
+ throws Exception {
factory.create(new ByteArrayInputStream("something".getBytes("UTF-8")));
}
- @Test( expected = ValueFormatException.class )
- public void shouldNotCreateDecimalFromReaderContainingStringWithContentsOtherThanDecimal() throws Exception {
+ @Test( expected = IllegalArgumentException.class )
+ public void shouldNotCreateDecimalFromReaderContainingStringWithContentsOtherThanDecimal() {
factory.create(new StringReader("something"));
}
}
Modified: branches/maeste/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/DoubleValueFactoryTest.java
===================================================================
--- branches/maeste/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/DoubleValueFactoryTest.java 2008-06-11 08:35:21 UTC (rev 264)
+++ branches/maeste/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/DoubleValueFactoryTest.java 2008-06-11 08:45:51 UTC (rev 265)
@@ -23,6 +23,7 @@
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
+import static org.mockito.Mockito.mock;
import java.io.ByteArrayInputStream;
import java.io.StringReader;
import java.math.BigDecimal;
@@ -32,19 +33,17 @@
import org.jboss.dna.spi.graph.Name;
import org.jboss.dna.spi.graph.Path;
import org.jboss.dna.spi.graph.Reference;
-import org.jboss.dna.spi.graph.ValueFormatException;
-import org.jmock.Mockery;
import org.junit.Before;
import org.junit.Test;
/**
* @author Randall Hauch
+ * @author John Verhaeg
*/
public class DoubleValueFactoryTest {
private DoubleValueFactory factory;
private StringValueFactory stringFactory;
- private Mockery context;
/**
* @throws java.lang.Exception
@@ -53,10 +52,9 @@
public void setUp() throws Exception {
stringFactory = new StringValueFactory(Path.URL_DECODER, Path.URL_ENCODER);
factory = new DoubleValueFactory(Path.URL_DECODER, stringFactory);
- context = new Mockery();
}
- @Test( expected = ValueFormatException.class )
+ @Test( expected = UnsupportedOperationException.class )
public void shouldNotCreateDoubleFromBooleanValue() {
factory.create(true);
}
@@ -113,22 +111,22 @@
assertThat(factory.create(value), is(Double.valueOf(value.getTimeInMillis())));
}
- @Test( expected = ValueFormatException.class )
+ @Test( expected = UnsupportedOperationException.class )
public void shouldNotCreateDoubleFromName() {
- factory.create(context.mock(Name.class));
+ factory.create(mock(Name.class));
}
- @Test( expected = ValueFormatException.class )
+ @Test( expected = UnsupportedOperationException.class )
public void shouldNotCreateDoubleFromPath() {
- factory.create(context.mock(Path.class));
+ factory.create(mock(Path.class));
}
- @Test( expected = ValueFormatException.class )
+ @Test( expected = UnsupportedOperationException.class )
public void shouldNotCreateDoubleFromReference() {
- factory.create(context.mock(Reference.class));
+ factory.create(mock(Reference.class));
}
- @Test( expected = ValueFormatException.class )
+ @Test( expected = UnsupportedOperationException.class )
public void shouldNotCreateDoubleFromUri() throws Exception {
factory.create(new URI("http://www.jboss.org"));
}
@@ -150,24 +148,24 @@
}
@Test
- public void shouldCreateDoubleFromReaderContainingStringWithDouble() throws Exception {
+ public void shouldCreateDoubleFromReaderContainingStringWithDouble() {
assertThat(factory.create(new StringReader("0.1")), is(0.1d));
assertThat(factory.create(new StringReader("1")), is(1.0d));
assertThat(factory.create(new StringReader("-1.03")), is(-1.03));
assertThat(factory.create(new StringReader("1003044")), is(1003044.d));
}
- @Test( expected = ValueFormatException.class )
+ @Test( expected = IllegalArgumentException.class )
public void shouldNotCreateDoubleFromByteArrayContainingUtf8EncodingOfStringWithContentsOtherThanDouble() throws Exception {
factory.create("something".getBytes("UTF-8"));
}
- @Test( expected = ValueFormatException.class )
+ @Test( expected = IllegalArgumentException.class )
public void shouldNotCreateDoubleFromInputStreamContainingUtf8EncodingOfStringWithContentsOtherThanDouble() throws Exception {
factory.create(new ByteArrayInputStream("something".getBytes("UTF-8")));
}
- @Test( expected = ValueFormatException.class )
+ @Test( expected = IllegalArgumentException.class )
public void shouldNotCreateDoubleFromReaderContainingStringWithContentsOtherThanDouble() throws Exception {
factory.create(new ByteArrayInputStream("something".getBytes("UTF-8")));
}
Modified: branches/maeste/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/JodaDateTimeTest.java
===================================================================
--- branches/maeste/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/JodaDateTimeTest.java 2008-06-11 08:35:21 UTC (rev 264)
+++ branches/maeste/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/JodaDateTimeTest.java 2008-06-11 08:45:51 UTC (rev 265)
@@ -22,8 +22,8 @@
package org.jboss.dna.spi.graph.impl;
import static org.hamcrest.core.Is.is;
-import static org.hamcrest.text.StringStartsWith.startsWith;
import static org.junit.Assert.assertThat;
+import static org.jboss.dna.common.text.StringMatcher.startsWith;
import org.junit.Before;
import org.junit.Test;
Modified: branches/maeste/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/JodaDateTimeValueFactoryTest.java
===================================================================
--- branches/maeste/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/JodaDateTimeValueFactoryTest.java 2008-06-11 08:35:21 UTC (rev 264)
+++ branches/maeste/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/JodaDateTimeValueFactoryTest.java 2008-06-11 08:45:51 UTC (rev 265)
@@ -23,6 +23,7 @@
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
+import static org.mockito.Mockito.mock;
import java.io.ByteArrayInputStream;
import java.io.StringReader;
import java.math.BigDecimal;
@@ -32,13 +33,12 @@
import org.jboss.dna.spi.graph.Name;
import org.jboss.dna.spi.graph.Path;
import org.jboss.dna.spi.graph.Reference;
-import org.jboss.dna.spi.graph.ValueFormatException;
-import org.jmock.Mockery;
import org.junit.Before;
import org.junit.Test;
/**
* @author Randall Hauch
+ * @author John Verhaeg
*/
public class JodaDateTimeValueFactoryTest {
@@ -53,7 +53,6 @@
private JodaDateTimeValueFactory factory;
private StringValueFactory stringFactory;
- private Mockery context;
/**
* @throws java.lang.Exception
@@ -62,10 +61,9 @@
public void setUp() throws Exception {
stringFactory = new StringValueFactory(Path.URL_DECODER, Path.URL_ENCODER);
factory = new JodaDateTimeValueFactory(Path.URL_DECODER, stringFactory);
- context = new Mockery();
}
- @Test( expected = ValueFormatException.class )
+ @Test( expected = UnsupportedOperationException.class )
public void shouldNotCreateDateFromBoolean() {
factory.create(true);
}
@@ -82,7 +80,7 @@
assertThat(factory.create(" " + LAST_YEAR.getString() + " "), is(LAST_YEAR));
}
- @Test( expected = ValueFormatException.class )
+ @Test( expected = IllegalArgumentException.class )
public void shouldNotCreateDateFromStringThatIsNotInTheStandardFormat() {
factory.create("something");
}
@@ -125,22 +123,22 @@
assertThat(factory.create(value), is((DateTime)new JodaDateTime(value)));
}
- @Test( expected = ValueFormatException.class )
+ @Test( expected = UnsupportedOperationException.class )
public void shouldNotCreateDateFromName() {
- factory.create(context.mock(Name.class));
+ factory.create(mock(Name.class));
}
- @Test( expected = ValueFormatException.class )
+ @Test( expected = UnsupportedOperationException.class )
public void shouldNotCreateDateFromPath() {
- factory.create(context.mock(Path.class));
+ factory.create(mock(Path.class));
}
- @Test( expected = ValueFormatException.class )
+ @Test( expected = UnsupportedOperationException.class )
public void shouldNotCreateDateFromReference() {
- factory.create(context.mock(Reference.class));
+ factory.create(mock(Reference.class));
}
- @Test( expected = ValueFormatException.class )
+ @Test( expected = UnsupportedOperationException.class )
public void shouldNotCreateDateFromUri() throws Exception {
factory.create(new URI("http://www.jboss.org"));
}
@@ -158,22 +156,24 @@
}
@Test
- public void shouldCreateDateFromReaderContainingStringWithWellFormedDate() throws Exception {
+ public void shouldCreateDateFromReaderContainingStringWithWellFormedDate() {
assertThat(factory.create(new StringReader(TODAY.getString())), is(TODAY));
assertThat(factory.create(new StringReader(LAST_YEAR.getString())), is(LAST_YEAR));
}
- @Test( expected = ValueFormatException.class )
- public void shouldNotCreateDateFromByteArrayContainingUtf8EncodingOfStringWithContentThatIsNotWellFormedDate() throws Exception {
+ @Test( expected = IllegalArgumentException.class )
+ public void shouldNotCreateDateFromByteArrayContainingUtf8EncodingOfStringWithContentThatIsNotWellFormedDate()
+ throws Exception {
factory.create("something".getBytes("UTF-8"));
}
- @Test( expected = ValueFormatException.class )
- public void shouldNotCreateDateFromInputStreamContainingUtf8EncodingOfStringWithContentThatIsNotWellFormedDate() throws Exception {
+ @Test( expected = IllegalArgumentException.class )
+ public void shouldNotCreateDateFromInputStreamContainingUtf8EncodingOfStringWithContentThatIsNotWellFormedDate()
+ throws Exception {
factory.create(new ByteArrayInputStream("something".getBytes("UTF-8")));
}
- @Test( expected = ValueFormatException.class )
+ @Test( expected = IllegalArgumentException.class )
public void shouldNotCreateDateFromReaderContainingStringWithContentThatIsNotWellFormedDate() throws Exception {
factory.create(new ByteArrayInputStream("something".getBytes("UTF-8")));
}
Modified: branches/maeste/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/LongValueFactoryTest.java
===================================================================
--- branches/maeste/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/LongValueFactoryTest.java 2008-06-11 08:35:21 UTC (rev 264)
+++ branches/maeste/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/LongValueFactoryTest.java 2008-06-11 08:45:51 UTC (rev 265)
@@ -23,6 +23,7 @@
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
+import static org.mockito.Mockito.mock;
import java.io.ByteArrayInputStream;
import java.io.StringReader;
import java.math.BigDecimal;
@@ -32,19 +33,17 @@
import org.jboss.dna.spi.graph.Name;
import org.jboss.dna.spi.graph.Path;
import org.jboss.dna.spi.graph.Reference;
-import org.jboss.dna.spi.graph.ValueFormatException;
-import org.jmock.Mockery;
import org.junit.Before;
import org.junit.Test;
/**
* @author Randall Hauch
+ * @author John Verhaeg
*/
public class LongValueFactoryTest {
private LongValueFactory factory;
private StringValueFactory stringFactory;
- private Mockery context;
/**
* @throws java.lang.Exception
@@ -53,10 +52,9 @@
public void setUp() throws Exception {
stringFactory = new StringValueFactory(Path.URL_DECODER, Path.URL_ENCODER);
factory = new LongValueFactory(Path.URL_DECODER, stringFactory);
- context = new Mockery();
}
- @Test( expected = ValueFormatException.class )
+ @Test( expected = UnsupportedOperationException.class )
public void shouldNotCreateDoubleFromBooleanValue() {
factory.create(true);
}
@@ -115,22 +113,22 @@
assertThat(factory.create(value), is(Long.valueOf(value.getTimeInMillis())));
}
- @Test( expected = ValueFormatException.class )
+ @Test( expected = UnsupportedOperationException.class )
public void shouldNotCreateLongFromName() {
- factory.create(context.mock(Name.class));
+ factory.create(mock(Name.class));
}
- @Test( expected = ValueFormatException.class )
+ @Test( expected = UnsupportedOperationException.class )
public void shouldNotCreateLongFromPath() {
- factory.create(context.mock(Path.class));
+ factory.create(mock(Path.class));
}
- @Test( expected = ValueFormatException.class )
+ @Test( expected = UnsupportedOperationException.class )
public void shouldNotCreateLongFromReference() {
- factory.create(context.mock(Reference.class));
+ factory.create(mock(Reference.class));
}
- @Test( expected = ValueFormatException.class )
+ @Test( expected = UnsupportedOperationException.class )
public void shouldNotCreateLongFromUri() throws Exception {
factory.create(new URI("http://www.jboss.org"));
}
@@ -152,24 +150,24 @@
}
@Test
- public void shouldCreateLongFromReaderContainingStringWithLong() throws Exception {
+ public void shouldCreateLongFromReaderContainingStringWithLong() {
assertThat(factory.create(new StringReader("0")), is(0l));
assertThat(factory.create(new StringReader("10")), is(10l));
assertThat(factory.create(new StringReader("-103")), is(-103l));
assertThat(factory.create(new StringReader("1003044")), is(1003044l));
}
- @Test( expected = ValueFormatException.class )
+ @Test( expected = IllegalArgumentException.class )
public void shouldNotCreateLongFromByteArrayContainingUtf8EncodingOfStringWithContentsOtherThanLong() throws Exception {
factory.create("something".getBytes("UTF-8"));
}
- @Test( expected = ValueFormatException.class )
+ @Test( expected = IllegalArgumentException.class )
public void shouldNotCreateLongFromInputStreamContainingUtf8EncodingOfStringWithContentsOtherThanLong() throws Exception {
factory.create(new ByteArrayInputStream("something".getBytes("UTF-8")));
}
- @Test( expected = ValueFormatException.class )
+ @Test( expected = IllegalArgumentException.class )
public void shouldNotCreateLongFromReaderContainingStringWithContentsOtherThanLong() throws Exception {
factory.create(new ByteArrayInputStream("something".getBytes("UTF-8")));
}
Modified: branches/maeste/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/NameValueFactoryTest.java
===================================================================
--- branches/maeste/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/NameValueFactoryTest.java 2008-06-11 08:35:21 UTC (rev 264)
+++ branches/maeste/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/NameValueFactoryTest.java 2008-06-11 08:45:51 UTC (rev 265)
@@ -48,7 +48,7 @@
private Name name;
@Before
- public void beforeEach() throws Exception {
+ public void beforeEach() {
this.registry = new BasicNamespaceRegistry();
this.registry.register("dna", "http://www.jboss.org/dna/namespace");
this.encoder = Path.DEFAULT_ENCODER;
Modified: branches/maeste/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/PathValueFactoryTest.java
===================================================================
--- branches/maeste/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/PathValueFactoryTest.java 2008-06-11 08:35:21 UTC (rev 264)
+++ branches/maeste/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/PathValueFactoryTest.java 2008-06-11 08:45:51 UTC (rev 265)
@@ -48,7 +48,7 @@
private Path path2;
@Before
- public void beforeEach() throws Exception {
+ public void beforeEach() {
this.registry = new BasicNamespaceRegistry();
this.registry.register("dna", "http://www.jboss.org/dna/namespace");
this.stringValueFactory = new StringValueFactory(Path.DEFAULT_DECODER, Path.DEFAULT_ENCODER);
Modified: branches/maeste/docs/examples/gettingstarted/sequencers/src/main/java/org/jboss/example/dna/sequencers/SequencingClient.java
===================================================================
--- branches/maeste/docs/examples/gettingstarted/sequencers/src/main/java/org/jboss/example/dna/sequencers/SequencingClient.java 2008-06-11 08:35:21 UTC (rev 264)
+++ branches/maeste/docs/examples/gettingstarted/sequencers/src/main/java/org/jboss/example/dna/sequencers/SequencingClient.java 2008-06-11 08:45:51 UTC (rev 265)
@@ -65,7 +65,7 @@
public static final String DEFAULT_USERNAME = "jsmith";
public static final char[] DEFAULT_PASSWORD = "secret".toCharArray();
- public static void main( String[] args ) throws Exception {
+ public static void main( String[] args ) {
SequencingClient client = new SequencingClient();
client.setRepositoryInformation(DEFAULT_REPOSITORY_NAME, DEFAULT_WORKSPACE_NAME, DEFAULT_USERNAME, DEFAULT_PASSWORD);
client.setUserInterface(new ConsoleInput(client));
@@ -98,7 +98,10 @@
this.jackrabbitConfigPath = jackrabbitConfigPath != null ? jackrabbitConfigPath : DEFAULT_JACKRABBIT_CONFIG_PATH;
}
- protected void setRepositoryInformation( String repositoryName, String workspaceName, String username, char[] password ) {
+ protected void setRepositoryInformation( String repositoryName,
+ String workspaceName,
+ String username,
+ char[] password ) {
if (this.repository != null) {
throw new IllegalArgumentException("Unable to set repository information when repository is already running");
}
@@ -110,6 +113,7 @@
/**
* Set the user interface that this client should use.
+ *
* @param userInterface
*/
public void setUserInterface( UserInterface userInterface ) {
@@ -118,6 +122,7 @@
/**
* Start up the JCR repository. This method only operates using the JCR API and Jackrabbit-specific API.
+ *
* @throws Exception
*/
public void startRepository() throws Exception {
@@ -127,10 +132,12 @@
// Load the Jackrabbit configuration ...
File configFile = new File(this.jackrabbitConfigPath);
if (!configFile.exists()) {
- throw new SystemFailureException("The Jackrabbit configuration file cannot be found at " + configFile.getAbsoluteFile());
+ throw new SystemFailureException("The Jackrabbit configuration file cannot be found at "
+ + configFile.getAbsoluteFile());
}
if (!configFile.canRead()) {
- throw new SystemFailureException("Unable to read the Jackrabbit configuration file at " + configFile.getAbsoluteFile());
+ throw new SystemFailureException("Unable to read the Jackrabbit configuration file at "
+ + configFile.getAbsoluteFile());
}
String pathToConfig = configFile.getAbsolutePath();
@@ -138,7 +145,8 @@
File workingDirectory = new File(this.workingDirectory);
if (workingDirectory.exists()) {
if (!workingDirectory.isDirectory()) {
- throw new SystemFailureException("Unable to create working directory at " + workingDirectory.getAbsolutePath());
+ throw new SystemFailureException("Unable to create working directory at "
+ + workingDirectory.getAbsolutePath());
}
}
String workingDirectoryPath = workingDirectory.getAbsolutePath();
@@ -173,6 +181,7 @@
/**
* Shutdown the repository. This method only uses the JCR API.
+ *
* @throws Exception
*/
public void shutdownRepository() throws Exception {
@@ -188,6 +197,7 @@
/**
* Start the DNA services.
+ *
* @throws Exception
*/
public void startDnaServices() throws Exception {
@@ -248,7 +258,8 @@
this.observationService = new ObservationService(this.executionContext.getSessionFactory());
this.observationService.getAdministrator().start();
this.observationService.addListener(this.sequencingService);
- this.observationService.monitor(repositoryWorkspaceName, Event.NODE_ADDED | Event.PROPERTY_ADDED | Event.PROPERTY_CHANGED);
+ this.observationService.monitor(repositoryWorkspaceName, Event.NODE_ADDED | Event.PROPERTY_ADDED
+ | Event.PROPERTY_CHANGED);
}
// Start up the sequencing service ...
this.sequencingService.getAdministrator().start();
@@ -256,6 +267,7 @@
/**
* Shut down the DNA services.
+ *
* @throws Exception
*/
public void shutdownDnaServices() throws Exception {
@@ -272,6 +284,7 @@
/**
* Get the sequencing statistics.
+ *
* @return the statistics; never null
*/
public SequencingService.Statistics getStatistics() {
@@ -280,6 +293,7 @@
/**
* Prompt the user interface for the file to upload into the JCR repository, then upload it using the JCR API.
+ *
* @throws Exception
*/
public void uploadFile() throws Exception {
@@ -311,6 +325,7 @@
/**
* Perform a search of the repository for all image metadata automatically created by the image sequencer.
+ *
* @throws Exception
*/
public void search() throws Exception {
@@ -361,7 +376,9 @@
* @throws PathNotFoundException
* @throws ValueFormatException
*/
- private MediaInfo extractMediaInfo( String metadataNodeName, String mediaType, Node mediaNode ) throws RepositoryException, PathNotFoundException, ValueFormatException {
+ private MediaInfo extractMediaInfo( String metadataNodeName,
+ String mediaType,
+ Node mediaNode ) throws RepositoryException, PathNotFoundException, ValueFormatException {
String nodePath = mediaNode.getPath();
String nodeName = mediaNode.getName();
mediaNode = mediaNode.getNode(metadataNodeName);
@@ -394,6 +411,7 @@
/**
* Utility method to create a new JCR session from the execution context's {@link SessionFactory}.
+ *
* @return the session
* @throws RepositoryException
*/
Modified: branches/maeste/docs/examples/gettingstarted/sequencers/src/test/java/org/jboss/example/dna/sequencers/MockUserInterface.java
===================================================================
--- branches/maeste/docs/examples/gettingstarted/sequencers/src/test/java/org/jboss/example/dna/sequencers/MockUserInterface.java 2008-06-11 08:35:21 UTC (rev 264)
+++ branches/maeste/docs/examples/gettingstarted/sequencers/src/test/java/org/jboss/example/dna/sequencers/MockUserInterface.java 2008-06-11 08:45:51 UTC (rev 265)
@@ -35,7 +35,9 @@
private final URL fileToUpload;
private final int numberOfSearchResults;
- public MockUserInterface( URL fileToUpload, String repositoryPath, int numSearchResults ) {
+ public MockUserInterface( URL fileToUpload,
+ String repositoryPath,
+ int numSearchResults ) {
this.repositoryPath = repositoryPath;
this.fileToUpload = fileToUpload;
this.numberOfSearchResults = numSearchResults;
@@ -54,7 +56,7 @@
/**
* {@inheritDoc}
*/
- public URL getFileToUpload() throws IllegalArgumentException {
+ public URL getFileToUpload() {
return this.fileToUpload;
}
Modified: branches/maeste/docs/examples/gettingstarted/sequencers/src/test/java/org/jboss/example/dna/sequencers/SequencingClientTest.java
===================================================================
--- branches/maeste/docs/examples/gettingstarted/sequencers/src/test/java/org/jboss/example/dna/sequencers/SequencingClientTest.java 2008-06-11 08:35:21 UTC (rev 264)
+++ branches/maeste/docs/examples/gettingstarted/sequencers/src/test/java/org/jboss/example/dna/sequencers/SequencingClientTest.java 2008-06-11 08:45:51 UTC (rev 265)
@@ -42,7 +42,7 @@
private SequencingClient client;
@Before
- public void beforeEach() throws Exception {
+ public void beforeEach() {
this.pngImageUrl = Thread.currentThread().getContextClassLoader().getResource("caution.png");
this.pictImageUrl = Thread.currentThread().getContextClassLoader().getResource("caution.pict");
this.jpegImageUrl = Thread.currentThread().getContextClassLoader().getResource("caution.jpg");
Modified: branches/maeste/eclipse-preferences.epf
===================================================================
--- branches/maeste/eclipse-preferences.epf 2008-06-11 08:35:21 UTC (rev 264)
+++ branches/maeste/eclipse-preferences.epf 2008-06-11 08:45:51 UTC (rev 265)
@@ -1,3 +1,14 @@
+/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.codeComplete.argumentPrefixes=
+/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.codeComplete.argumentSuffixes=
+/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.codeComplete.deprecationCheck=enabled
+/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.codeComplete.discouragedReferenceCheck=enabled
+/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.codeComplete.fieldPrefixes=
+/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.codeComplete.fieldSuffixes=
+/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.codeComplete.localPrefixes=
+/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.codeComplete.localSuffixes=
+/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.codeComplete.staticFieldPrefixes=
+/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.codeComplete.staticFieldSuffixes=
+/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.codeComplete.visibilityCheck=enabled
/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.compiler.compliance=1.5
@@ -20,14 +31,15 @@
/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.compiler.problem.invalidJavadoc=error
/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsDeprecatedRef=enabled
/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.compiler.problem.invalidJavadocTags=enabled
-/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsNotVisibleRef=disabled
+/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsNotVisibleRef=enabled
/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=error
/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=warning
/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.compiler.problem.missingJavadocComments=ignore
/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding=enabled
/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility=protected
+/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.compiler.problem.missingJavadocTagDescription=return_tag
/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.compiler.problem.missingJavadocTags=error
-/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding=disabled
+/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding=enabled
/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=warning
/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.compiler.problem.missingSerialVersion=ignore
/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.compiler.problem.noEffectAssignment=error
@@ -48,7 +60,8 @@
/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.compiler.problem.unnecessaryElse=warning
/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning
/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
-/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore
+/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeUncheckedExceptions=enabled
+/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning
/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=enabled
/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.compiler.problem.unusedImport=warning
/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
@@ -59,13 +72,22 @@
/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.compiler.source=1.5
+/instance/org.eclipse.jdt.ui/content_assist_favorite_static_members=org.junit.Assert.*;org.hamcrest.core.Is.is;org.hamcrest.core.IsNot.not;org.hamcrest.core.IsNull.nullValue;org.hamcrest.core.IsNull.notNullValue;org.hamcrest.core.IsSame.sameInstance;org.hamcrest.core.IsInstanceOf.instanceOf;org.hamcrest.core.IsEqual.equalTo;org.hamcrest.core.IsAnything.anything;org.hamcrest.core.IsAnything.any;org.hamcrest.core.DescribedAs.describedAs;org.hamcrest.core.AnyOf.anyOf;org.hamcrest.core.AllOf.allOf;org.junit.matchers.IsCollectionContaining.hasItem;org.junit.matchers.IsCollectionContaining.hasItems;org.junit.matchers.Each.each;org.junit.matchers.JUnitMatchers.hasItem;org.junit.matchers.JUnitMatchers.hasItems;org.junit.matchers.JUnitMatchers.containsString;org.junit.matchers.JUnitMatchers.each;org.junit.matchers.JUnitMatchers.both;org.junit.matchers.JUnitMatchers.either;org.junit.matchers.StringContains.containsString;org.junit.matchers.TypeSafeMatcher.matches
/instance/org.eclipse.jdt.ui/org.eclipse.jdt.ui.gettersetter.use.is=true
/instance/org.eclipse.jdt.ui/org.eclipse.jdt.ui.ignorelowercasenames=true
/instance/org.eclipse.jdt.ui/org.eclipse.jdt.ui.importorder=\#;java;javax;org;com;
+/instance/org.eclipse.jdt.ui/org.eclipse.jdt.ui.javadoclocations.migrated=true
/instance/org.eclipse.jdt.ui/org.eclipse.jdt.ui.javadoc=true
+/instance/org.eclipse.jdt.ui/org.eclipse.jdt.ui.keywordthis=false
+/instance/org.eclipse.jdt.ui/org.eclipse.jdt.ui.methodreturntype=true
/instance/org.eclipse.jdt.ui/org.eclipse.jdt.ui.ondemandthreshold=99
/instance/org.eclipse.jdt.ui/org.eclipse.jdt.ui.overrideannotation=true
+/instance/org.eclipse.jdt.ui/org.eclipse.jdt.ui.packages.cuchildren=false
/instance/org.eclipse.jdt.ui/org.eclipse.jdt.ui.staticondemandthreshold=99
-/instance/org.eclipse.jdt.ui/org.eclipse.jdt.ui.text.custom_code_templates=<?xml version\="1.0" encoding\="UTF-8" standalone\="no"?><templates><template autoinsert\="false" context\="gettercomment_context" deleted\="false" description\="Comment for getter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.gettercomment" name\="gettercomment">/**\n * @return ${bare_field_name}\n */</template><template autoinsert\="false" context\="settercomment_context" deleted\="false" description\="Comment for setter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.settercomment" name\="settercomment">/**\n * @param ${param} Sets ${bare_field_name} to the specified value.\n */</template><template autoinsert\="false" context\="constructorcomment_context" deleted\="false" description\="Comment for created constructors" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorcomment" name\="constructorcomment">/**\n * ${tags}\n */</template><tem!
plate autoinsert\="false" context\="filecomment_context" deleted\="false" description\="Comment for created Java files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.filecomment" name\="filecomment">/*\n *\n */</template><template autoinsert\="false" context\="typecomment_context" deleted\="false" description\="Comment for created types" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.typecomment" name\="typecomment">/**\n * @author John Verhaeg\n * ${tags}\n */</template><template autoinsert\="false" context\="fieldcomment_context" deleted\="false" description\="Comment for fields" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.fieldcomment" name\="fieldcomment">/**\n */</template><template autoinsert\="false" context\="methodcomment_context" deleted\="false" description\="Comment for non-overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodcomment" name\="methodcomment">/**\n * ${tags}\n */</template><tem!
plate autoinsert\="false" context\="overridecomment_context" deleted\=
"false" description\="Comment for overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.overridecomment" name\="overridecomment">/**\n * <p>\n * {@inheritDoc}\n * </p>\n *\n * ${see_to_overridden}\n */</template><template autoinsert\="false" context\="delegatecomment_context" deleted\="false" description\="Comment for delegate methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.delegatecomment" name\="delegatecomment">/**\n * <p>\n * {@inheritDoc}\n * </p>\n *\n * ${see_to_target}\n */</template><template autoinsert\="false" context\="catchblock_context" deleted\="false" description\="Code in new catch blocks" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.catchblock" name\="catchblock"/><template autoinsert\="false" context\="methodbody_context" deleted\="false" description\="Code in created method stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodbody" name\="methodbody">${bo!
dy_statement}</template><template autoinsert\="false" context\="constructorbody_context" deleted\="false" description\="Code in created constructor stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorbody" name\="constructorbody">${body_statement}\n</template><template autoinsert\="false" context\="getterbody_context" deleted\="false" description\="Code in created getters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.getterbody" name\="getterbody">return ${field};</template><template autoinsert\="false" context\="setterbody_context" deleted\="false" description\="Code in created setters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.setterbody" name\="setterbody">${field} \= ${param};</template></templates>
+/instance/org.eclipse.jdt.ui/org.eclipse.jdt.ui.text.code_templates_migrated=true
+/instance/org.eclipse.jdt.ui/org.eclipse.jdt.ui.text.custom_code_templates=<?xml version\="1.0" encoding\="UTF-8"?><templates><template autoinsert\="false" context\="gettercomment_context" deleted\="false" description\="Comment for getter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.gettercomment" name\="gettercomment">/**\n * @return ${bare_field_name}\n */</template><template autoinsert\="false" context\="settercomment_context" deleted\="false" description\="Comment for setter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.settercomment" name\="settercomment">/**\n * @param ${param} Sets ${bare_field_name} to the specified value.\n */</template><template autoinsert\="false" context\="constructorcomment_context" deleted\="false" description\="Comment for created constructors" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorcomment" name\="constructorcomment">/**\n * ${tags}\n */</template><template autoinsert\!
="false" context\="filecomment_context" deleted\="false" description\="Comment for created Java files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.filecomment" name\="filecomment">/*\n * JBoss, Home of Professional Open Source.\n * Copyright 2008, Red Hat Middleware LLC, and individual contributors\n * as indicated by the @author tags. See the copyright.txt file in the\n * distribution for a full listing of individual contributors. \n *\n * This is free software; you can redistribute it and/or modify it\n * under the terms of the GNU Lesser General Public License as\n * published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This software is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Lesser General Public License for more details.\n *\n * You sh!
ould have received a copy of the GNU Lesser General Public\n * License
along with this software; if not, write to the Free\n * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n * 02110-1301 USA, or see the FSF site\: http\://www.fsf.org.\n */</template><template autoinsert\="false" context\="typecomment_context" deleted\="false" description\="Comment for created types" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.typecomment" name\="typecomment">/**\n * @author John Verhaeg\n * ${tags}\n */</template><template autoinsert\="false" context\="fieldcomment_context" deleted\="false" description\="Comment for fields" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.fieldcomment" name\="fieldcomment">/**\n */</template><template autoinsert\="false" context\="methodcomment_context" deleted\="false" description\="Comment for non-overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodcomment" name\="methodcomment">/**\n * ${tags}\n */</template><template autoinsert\="false" context!
\="overridecomment_context" deleted\="false" description\="Comment for overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.overridecomment" name\="overridecomment">/**\n * {@inheritDoc}\n *\n * ${see_to_overridden}\n */</template><template autoinsert\="false" context\="delegatecomment_context" deleted\="false" description\="Comment for delegate methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.delegatecomment" name\="delegatecomment">/**\n * {@inheritDoc}\n *\n * ${see_to_target}\n */</template><template autoinsert\="false" context\="catchblock_context" deleted\="false" description\="Code in new catch blocks" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.catchblock" name\="catchblock"></template><template autoinsert\="false" context\="methodbody_context" deleted\="false" description\="Code in created method stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodbody" name\="methodbody">${body_stateme!
nt}</template><template autoinsert\="false" context\="constructorbody_
context" deleted\="false" description\="Code in created constructor stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorbody" name\="constructorbody">${body_statement}\n</template><template autoinsert\="false" context\="getterbody_context" deleted\="false" description\="Code in created getters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.getterbody" name\="getterbody">return ${field};</template><template autoinsert\="false" context\="setterbody_context" deleted\="false" description\="Code in created setters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.setterbody" name\="setterbody">${field} \= ${param};</template></templates>
/instance/org.eclipse.jdt.ui/outlinesortoption=SF,SI,SM,F,I,C,M,T,
+/instance/org.eclipse.jdt.ui/tabWidthPropagated=true
+/instance/org.eclipse.ui.editors/printMarginColumn=130
+/instance/org.eclipse.ui.editors/printMargin=true
/instance/org.eclipse.ui.editors/spacesForTabs=true
Modified: branches/maeste/pom.xml
===================================================================
--- branches/maeste/pom.xml 2008-06-11 08:35:21 UTC (rev 264)
+++ branches/maeste/pom.xml 2008-06-11 08:45:51 UTC (rev 265)
@@ -316,18 +316,12 @@
<version>1.1</version>
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>org.jmock</groupId>
- <artifactId>jmock</artifactId>
- <version>2.4.0</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.jmock</groupId>
- <artifactId>jmock-junit4</artifactId>
- <version>2.4.0</version>
- <scope>test</scope>
- </dependency>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-all</artifactId>
+ <version>1.3</version>
+ <scope>test</scope>
+ </dependency>
<!-- Logging (require SLF4J API for compiling, but use Log4J and its SLF4J binding for testing) -->
<dependency>
<groupId>org.slf4j</groupId>
@@ -396,6 +390,15 @@
</exclusion>
</exclusions>
</dependency>
+ <!--
+ Apache JCR API unit tests (for any JCR implementation), which is a subset of the official TCK
+ -->
+ <dependency>
+ <groupId>org.apache.jackrabbit</groupId>
+ <artifactId>jackrabbit-jcr-tests</artifactId>
+ <version>1.3.3</version>
+ <scope>test</scope>
+ </dependency>
<!-- Databases and JDBC Drivers -->
<dependency>
<groupId>mysql</groupId>
Modified: branches/maeste/sequencers/dna-sequencer-images/src/test/java/org/jboss/dna/sequencer/images/ImageMetadataSequencerTest.java
===================================================================
--- branches/maeste/sequencers/dna-sequencer-images/src/test/java/org/jboss/dna/sequencer/images/ImageMetadataSequencerTest.java 2008-06-11 08:35:21 UTC (rev 264)
+++ branches/maeste/sequencers/dna-sequencer-images/src/test/java/org/jboss/dna/sequencer/images/ImageMetadataSequencerTest.java 2008-06-11 08:45:51 UTC (rev 265)
@@ -50,10 +50,10 @@
private URL cautionPng;
@Before
- public void beforeEach() throws Exception {
+ public void beforeEach() {
this.sequencer = new ImageMetadataSequencer();
this.output = new MockSequencerOutput();
- output.getNamespaceRegistry().register("image", "http://jboss.org/dna/images/1.0");
+ output.getNamespaceRegistry().register("image", "http://jboss.org/dna/images/1.0");
this.progress = new SimpleProgressMonitor("Test activity");
this.cautionGif = this.getClass().getClassLoader().getResource("caution.gif");
this.cautionJpg = this.getClass().getClassLoader().getResource("caution.jpg");
@@ -89,8 +89,10 @@
assertThat(output.getPropertyValues("image:metadata", "image:numberOfImages"), is(new Object[] {1}));
assertThat(output.getPropertyValues("image:metadata", "image:physicalWidthDpi"), is(new Object[] {72}));
assertThat(output.getPropertyValues("image:metadata", "image:physicalHeightDpi"), is(new Object[] {72}));
- assertThat(((Float)(output.getPropertyValues("image:metadata", "image:physicalWidthInches")[0])).doubleValue(), is(closeTo(0.666667d, 0.0001d)));
- assertThat(((Float)(output.getPropertyValues("image:metadata", "image:physicalHeightInches")[0])).doubleValue(), is(closeTo(0.666667d, 0.0001d)));
+ assertThat(((Float)(output.getPropertyValues("image:metadata", "image:physicalWidthInches")[0])).doubleValue(),
+ is(closeTo(0.666667d, 0.0001d)));
+ assertThat(((Float)(output.getPropertyValues("image:metadata", "image:physicalHeightInches")[0])).doubleValue(),
+ is(closeTo(0.666667d, 0.0001d)));
}
@Test
Modified: branches/maeste/sequencers/dna-sequencer-images/src/test/java/org/jboss/dna/sequencer/images/ImageMetadataTest.java
===================================================================
--- branches/maeste/sequencers/dna-sequencer-images/src/test/java/org/jboss/dna/sequencer/images/ImageMetadataTest.java 2008-06-11 08:35:21 UTC (rev 264)
+++ branches/maeste/sequencers/dna-sequencer-images/src/test/java/org/jboss/dna/sequencer/images/ImageMetadataTest.java 2008-06-11 08:45:51 UTC (rev 265)
@@ -39,7 +39,7 @@
private InputStream imageStream;
@Before
- public void beforeEach() throws Exception {
+ public void beforeEach() {
this.image = new ImageMetadata();
}
Modified: branches/maeste/sequencers/dna-sequencer-mp3/src/main/java/org/jboss/dna/sequencer/mp3/Mp3Metadata.java
===================================================================
--- branches/maeste/sequencers/dna-sequencer-mp3/src/main/java/org/jboss/dna/sequencer/mp3/Mp3Metadata.java 2008-06-11 08:35:21 UTC (rev 264)
+++ branches/maeste/sequencers/dna-sequencer-mp3/src/main/java/org/jboss/dna/sequencer/mp3/Mp3Metadata.java 2008-06-11 08:45:51 UTC (rev 265)
@@ -1,3 +1,24 @@
+/*
+ * 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.sequencer.mp3;
import java.io.File;
@@ -10,6 +31,7 @@
/**
* Utility for extracting metadata from MP3 files.
+ *
* @author Stefano Maestri
*/
public class Mp3Metadata {
Modified: branches/maeste/sequencers/dna-sequencer-mp3/src/test/java/org/jboss/dna/sequencer/mp3/Mp3MetadataTest.java
===================================================================
--- branches/maeste/sequencers/dna-sequencer-mp3/src/test/java/org/jboss/dna/sequencer/mp3/Mp3MetadataTest.java 2008-06-11 08:35:21 UTC (rev 264)
+++ branches/maeste/sequencers/dna-sequencer-mp3/src/test/java/org/jboss/dna/sequencer/mp3/Mp3MetadataTest.java 2008-06-11 08:45:51 UTC (rev 265)
@@ -1,3 +1,24 @@
+/*
+ * 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.sequencer.mp3;
import static org.hamcrest.core.Is.is;
17 years, 6 months
DNA SVN: r264 - in branches/maeste/sequencers/dna-sequencer-esbMessage/src: main/java/org/jboss/dna/sequencer/esbMessage and 1 other directories.
by dna-commits@lists.jboss.org
Author: maeste
Date: 2008-06-11 04:35:21 -0400 (Wed, 11 Jun 2008)
New Revision: 264
Added:
branches/maeste/sequencers/dna-sequencer-esbMessage/src/main/java/org/jboss/dna/sequencer/esbMessage/ESBMessageSequencerI18n.java
branches/maeste/sequencers/dna-sequencer-esbMessage/src/main/resources/
branches/maeste/sequencers/dna-sequencer-esbMessage/src/test/resources/
Modified:
branches/maeste/sequencers/dna-sequencer-esbMessage/src/main/java/org/jboss/dna/sequencer/esbMessage/ESBMessageMetaData.java
branches/maeste/sequencers/dna-sequencer-esbMessage/src/main/java/org/jboss/dna/sequencer/esbMessage/ESBMessageSequencer.java
Log:
[DNA-78 [DNA-108],[DNA-122]]
Modified: branches/maeste/sequencers/dna-sequencer-esbMessage/src/main/java/org/jboss/dna/sequencer/esbMessage/ESBMessageMetaData.java
===================================================================
--- branches/maeste/sequencers/dna-sequencer-esbMessage/src/main/java/org/jboss/dna/sequencer/esbMessage/ESBMessageMetaData.java 2008-06-11 01:10:40 UTC (rev 263)
+++ branches/maeste/sequencers/dna-sequencer-esbMessage/src/main/java/org/jboss/dna/sequencer/esbMessage/ESBMessageMetaData.java 2008-06-11 08:35:21 UTC (rev 264)
@@ -26,7 +26,9 @@
import java.net.URI;
import java.util.HashMap;
import java.util.Map;
+import org.jboss.dna.common.monitor.ProgressMonitor;
import org.jboss.dna.common.util.StringUtil;
+import org.jboss.dna.sequencer.images.ImageSequencerI18n;
import org.jboss.internal.soa.esb.util.Encoding;
import org.jboss.soa.esb.addressing.EPR;
import org.jboss.soa.esb.message.Message;
@@ -58,10 +60,12 @@
}
- public static ESBMessageMetaData instance( InputStream stream ) {
+ public static ESBMessageMetaData instance( InputStream stream,
+ ProgressMonitor progressMonitor ) {
ESBMessageMetaData me = null;
Message message = null;
+ progressMonitor.beginTask(10, ImageSequencerI18n.sequencerTaskName);
try {
me = new ESBMessageMetaData();
message = Util.deserialize((Serializable)Encoding.decodeToObject(StringUtil.read(stream)));
@@ -69,6 +73,8 @@
e.printStackTrace();
return null;
}
+ progressMonitor.worked(2);
+ if (progressMonitor.isCancelled()) return null;
me.messageType = message.getType();
// Context not yet implemented in JBossESB
@@ -81,32 +87,50 @@
me.relatesTo = message.getHeader().getCall().getRelatesTo();
me.action = message.getHeader().getCall().getAction();
me.messageID = message.getHeader().getCall().getMessageID();
+ progressMonitor.worked(1);
+ if (progressMonitor.isCancelled()) return null;
if (message.getBody().getNames().length != 0) {
me.bodyMap = new HashMap<String, Object>();
+ ProgressMonitor subtask = progressMonitor.createSubtask(2);
+ subtask.beginTask(message.getBody().getNames().length, ESBMessageSequencerI18n.sequencerTaskName);
+ for (String name : message.getBody().getNames()) {
+ me.bodyMap.put(name, message.getBody().get(name));
+ subtask.worked(1);
+ if (progressMonitor.isCancelled()) return null;
+ }
+ subtask.done();
}
- for (String name : message.getBody().getNames()) {
- me.bodyMap.put(name, message.getBody().get(name));
- }
if (message.getProperties().getNames().length != 0) {
me.propertiesMap = new HashMap<String, Object>();
+ ProgressMonitor subtask = progressMonitor.createSubtask(2);
+ subtask.beginTask(message.getProperties().getNames().length, ESBMessageSequencerI18n.sequencerTaskName);
+ for (String name : message.getProperties().getNames()) {
+ me.propertiesMap.put(name, message.getProperties().getProperty(name));
+ subtask.worked(1);
+ if (progressMonitor.isCancelled()) return null;
+ }
+ subtask.done();
}
- for (String name : message.getProperties().getNames()) {
- me.propertiesMap.put(name, message.getProperties().getProperty(name));
- }
if (message.getAttachment().getNames().length != 0) {
me.attachmentsMap = new HashMap<String, Object>();
+ ProgressMonitor subtask = progressMonitor.createSubtask(2);
+ subtask.beginTask(message.getAttachment().getNames().length, ESBMessageSequencerI18n.sequencerTaskName);
+ for (String name : message.getAttachment().getNames()) {
+ me.attachmentsMap.put(name, message.getAttachment().get(name));
+ subtask.worked(1);
+ if (progressMonitor.isCancelled()) return null;
+ }
+ subtask.done();
}
- for (String name : message.getAttachment().getNames()) {
- me.attachmentsMap.put(name, message.getAttachment().get(name));
- }
me.faultCause = message.getFault().getCause();
me.faultCode = message.getFault().getCode();
me.faultReason = message.getFault().getReason();
-
+ // do last unit of work implicit in done
+ progressMonitor.done();
return me;
}
Modified: branches/maeste/sequencers/dna-sequencer-esbMessage/src/main/java/org/jboss/dna/sequencer/esbMessage/ESBMessageSequencer.java
===================================================================
--- branches/maeste/sequencers/dna-sequencer-esbMessage/src/main/java/org/jboss/dna/sequencer/esbMessage/ESBMessageSequencer.java 2008-06-11 01:10:40 UTC (rev 263)
+++ branches/maeste/sequencers/dna-sequencer-esbMessage/src/main/java/org/jboss/dna/sequencer/esbMessage/ESBMessageSequencer.java 2008-06-11 08:35:21 UTC (rev 264)
@@ -22,23 +22,41 @@
package org.jboss.dna.sequencer.esbMessage;
import java.io.InputStream;
+import java.util.Map.Entry;
import org.jboss.dna.common.monitor.ProgressMonitor;
+import org.jboss.dna.sequencer.images.ImageSequencerI18n;
+import org.jboss.dna.spi.graph.NameFactory;
+import org.jboss.dna.spi.graph.Path;
+import org.jboss.dna.spi.graph.PathFactory;
import org.jboss.dna.spi.sequencers.SequencerOutput;
import org.jboss.dna.spi.sequencers.StreamSequencer;
/**
- * A sequencer that processes the binary content of an MP3 audio file, extracts the metadata for the file, and then writes that
- * audio metadata to the repository.
+ * A sequencer that processes the binary content of an ESB Message, extracts the metadata for the message, and then writes this
+ * metadata to the repository.
* <p>
* This sequencer produces data that corresponds to the following structure:
* <ul>
- * <li><strong>mp3:metadata</strong> node of type <code>mp3:metadata</code>
+ * <li><strong>esbMessage:metadata</strong> node of type <code>esbMessage:metadata</code>
* <ul>
- * <li><strong>mp3:title</strong> - optional string property for the name of the audio file or recording</li>
- * <li><strong>mp3:author</strong> - optional string property for the author of the recording</li>
- * <li><strong>mp3:album</strong> - optional string property for the name of the album</li>
- * <li><strong>mp3:year</strong> - optional integer property for the year the recording as created</li>
- * <li><strong>mp3:comment</strong> - optional string property specifying a comment</li>
+ * <li><strong>esbMessage:to</strong> - optional property for the destination EPR of the message</li>
+ * <li><strong>esbMessage:from</strong> - optional property for the source EPR of the message</li>
+ * <li><strong>esbMessage:replyTo</strong> - optional property for the reply destination EPR</li>
+ * <li><strong>esbMessage:relatesTo</strong> - optional property for the relatesTo URI</li>
+ * <li><strong>esbMessage:action</strong> - optional property specifying the action URI</li>
+ * <li><strong>esbMessage:messageID</strong> - optional property specifying the messageID URI</li>
+ * <li><strong>esbMessage:body</strong> - optional node specifying the message body. It contains a set of properties
+ * representing Object contained in body. Properties names reflect object names used in message body</li>
+ * <li><strong>esbMessage:properties</strong> - optional node specifying the message properties. It contains a set of properties
+ * representing Object contained in message properties. Properties names reflect object names used in message properties</li>
+ * <li><strong>esbMessage:attachments</strong> - optional node specifying the message attachments. It contains a set of
+ * properties representing Object contained in message attachments. Properties names reflect object names used in message
+ * attachments</li>
+ * <li><strong>esbMessage:faultCode</strong> - optional property specifying the message fault code. As defined in ESB message
+ * it's an URI</li>
+ * <li><strong>esbMessage:faultReason</strong> - optional property containing a String describing the fault in a human readable
+ * form</li>
+ * <li><strong>esbMessage:faultCause</strong> - optional property specifying the Throwable Cause of the fault.</li>
* </ul>
* </li>
* </ul>
@@ -50,20 +68,81 @@
public static final String METADATA_NODE = "esbMessage:metadata";
public static final String ESB_MESSAGE_PRIMARY_TYPE = "jcr:primaryType";
+ public static final String ESB_MESSAGE_TO = "esbMessage:to";
+ public static final String ESB_MESSAGE_FROM = "esbMessage:from";
+ public static final String ESB_MESSAGE_REPLY_TO = "esbMessage:replyTo";
+ public static final String ESB_MESSAGE_RELATES_TO = "esbMessage:relatesTo";
+ public static final String ESB_MESSAGE_ACTION = "esbMessage:action";
+ public static final String ESB_MESSAGE_MESSAGE_ID = "esbMessage:messageID";
+ public static final String ESB_MESSAGE_MESSAGE_TYPE = "esbMessage:messageType";
+ public static final String ESB_MESSAGE_BODY = "esbMessage:metadata/esbMessage:body";
+ public static final String ESB_MESSAGE_PROPERTIES = "esbMessage:metadata/esbMessage:properties";
+ public static final String ESB_MESSAGE_ATTACHMENTS = "esbMessage:metadata/esbMessage:attachments";
+ public static final String ESB_MESSAGE_FAULT_CODE = "esbMessage:faultCode";
+ public static final String ESB_MESSAGE_FAULT_REASON = "esbMessage:faultReason";
+ public static final String ESB_MESSAGE_FAULT_CAUSE = "esbMessage:faultCause";
+ public static final String ESB_MESSAGE_NAMESPACE = "esbMessage";
+
public void sequence( InputStream stream,
SequencerOutput output,
ProgressMonitor progressMonitor ) {
- ESBMessageMetaData metadata = ESBMessageMetaData.instance(stream);
+ progressMonitor.beginTask(20, ImageSequencerI18n.sequencerTaskName);
+ ESBMessageMetaData metadata = ESBMessageMetaData.instance(stream, progressMonitor.createSubtask(10));
+ if (progressMonitor.isCancelled()) return;
+
if (metadata != null) {
- // Place the image metadata into the output map ...
- output.setProperty(METADATA_NODE, ESB_MESSAGE_PRIMARY_TYPE, "esbMessage:metadata");
- // output.setProperty(METADATA_NODE, MP3_TITLE, metadata.getTitle());
- // output.setProperty(METADATA_NODE, MP3_AUTHOR, metadata.getAuthor());
- // output.setProperty(METADATA_NODE, MP3_ALBUM, metadata.getAlbum());
- // output.setProperty(METADATA_NODE, MP3_YEAR, metadata.getYear());
- // output.setProperty(METADATA_NODE, MP3_COMMENT, metadata.getComment());
+ NameFactory nameFactory = output.getFactories().getNameFactory();
+ PathFactory pathFactory = output.getFactories().getPathFactory();
+ Path metadataNode = pathFactory.create(METADATA_NODE);
+
+ output.setProperty(metadataNode, nameFactory.create(ESB_MESSAGE_PRIMARY_TYPE), "esbMessage:metadata");
+ output.setProperty(metadataNode, nameFactory.create(ESB_MESSAGE_TO), metadata.getTo());
+ output.setProperty(metadataNode, nameFactory.create(ESB_MESSAGE_FROM), metadata.getFrom());
+ output.setProperty(metadataNode, nameFactory.create(ESB_MESSAGE_REPLY_TO), metadata.getReplyTo());
+ output.setProperty(metadataNode, nameFactory.create(ESB_MESSAGE_RELATES_TO), metadata.getRelatesTo());
+ output.setProperty(metadataNode, nameFactory.create(ESB_MESSAGE_ACTION), metadata.getAction());
+ output.setProperty(metadataNode, nameFactory.create(ESB_MESSAGE_MESSAGE_ID), metadata.getMessageID());
+ output.setProperty(metadataNode, nameFactory.create(ESB_MESSAGE_MESSAGE_TYPE), metadata.getMessageType());
+ output.setProperty(metadataNode, nameFactory.create(ESB_MESSAGE_FAULT_CODE), metadata.getFaultCode());
+ output.setProperty(metadataNode, nameFactory.create(ESB_MESSAGE_FAULT_REASON), metadata.getFaultReason());
+ output.setProperty(metadataNode, nameFactory.create(ESB_MESSAGE_FAULT_CAUSE), metadata.getFaultCause());
+ progressMonitor.worked(1);
+ if (progressMonitor.isCancelled()) return;
+
+ ProgressMonitor subtask = progressMonitor.createSubtask(3);
+ subtask.beginTask(metadata.getBodyMap().entrySet().size(), ESBMessageSequencerI18n.sequencerTaskName);
+ Path bodyNode = pathFactory.create(metadataNode, nameFactory.create(ESB_MESSAGE_BODY));
+ for (Entry<String, Object> entry : metadata.getBodyMap().entrySet()) {
+ output.setProperty(bodyNode, nameFactory.create(ESB_MESSAGE_NAMESPACE, entry.getKey()), entry.getValue());
+ subtask.worked(1);
+ if (progressMonitor.isCancelled()) return;
+ }
+ subtask.done();
+
+ subtask = progressMonitor.createSubtask(3);
+ subtask.beginTask(metadata.getPropertiesMap().entrySet().size(), ESBMessageSequencerI18n.sequencerTaskName);
+ Path propertiesNode = pathFactory.create(metadataNode, nameFactory.create(ESB_MESSAGE_PROPERTIES));
+ for (Entry<String, Object> entry : metadata.getPropertiesMap().entrySet()) {
+ output.setProperty(propertiesNode, nameFactory.create(ESB_MESSAGE_NAMESPACE, entry.getKey()), entry.getValue());
+ subtask.worked(1);
+ if (progressMonitor.isCancelled()) return;
+ }
+ subtask.done();
+
+ subtask = progressMonitor.createSubtask(3);
+ subtask.beginTask(metadata.getAttachmentsMap().entrySet().size(), ESBMessageSequencerI18n.sequencerTaskName);
+ Path attachmentsNode = pathFactory.create(metadataNode, nameFactory.create(ESB_MESSAGE_ATTACHMENTS));
+ for (Entry<String, Object> entry : metadata.getAttachmentsMap().entrySet()) {
+ output.setProperty(attachmentsNode, nameFactory.create(ESB_MESSAGE_NAMESPACE, entry.getKey()), entry.getValue());
+ subtask.worked(1);
+ if (progressMonitor.isCancelled()) return;
+ }
+ subtask.done();
+
+ progressMonitor.done();
+
}
}
Added: branches/maeste/sequencers/dna-sequencer-esbMessage/src/main/java/org/jboss/dna/sequencer/esbMessage/ESBMessageSequencerI18n.java
===================================================================
--- branches/maeste/sequencers/dna-sequencer-esbMessage/src/main/java/org/jboss/dna/sequencer/esbMessage/ESBMessageSequencerI18n.java (rev 0)
+++ branches/maeste/sequencers/dna-sequencer-esbMessage/src/main/java/org/jboss/dna/sequencer/esbMessage/ESBMessageSequencerI18n.java 2008-06-11 08:35:21 UTC (rev 264)
@@ -0,0 +1,54 @@
+/*
+ * 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.sequencer.esbMessage;
+
+import java.util.Locale;
+import java.util.Set;
+import org.jboss.dna.common.i18n.I18n;
+
+/**
+ * @author Stefano Maestri
+ */
+public final class ESBMessageSequencerI18n {
+
+ public static I18n sequencerTaskName;
+
+ static {
+ try {
+ I18n.initialize(ESBMessageSequencerI18n.class);
+ } catch (final Exception err) {
+ System.err.println(err);
+ }
+ }
+
+ public static Set<Locale> getLocalizationProblemLocales() {
+ return I18n.getLocalizationProblemLocales(ESBMessageSequencerI18n.class);
+ }
+
+ public static Set<String> getLocalizationProblems() {
+ return I18n.getLocalizationProblems(ESBMessageSequencerI18n.class);
+ }
+
+ public static Set<String> getLocalizationProblems( Locale locale ) {
+ return I18n.getLocalizationProblems(ESBMessageSequencerI18n.class, locale);
+ }
+}
17 years, 6 months
DNA SVN: r263 - trunk.
by dna-commits@lists.jboss.org
Author: jverhaeg(a)redhat.com
Date: 2008-06-10 21:10:40 -0400 (Tue, 10 Jun 2008)
New Revision: 263
Modified:
trunk/eclipse-preferences.epf
Log:
Updated code templates to eliminate some html, to include the JBoss copyright notice in file comments, and to add a compiler setting to warn about unnecessary throws clauses
Modified: trunk/eclipse-preferences.epf
===================================================================
--- trunk/eclipse-preferences.epf 2008-06-10 23:32:20 UTC (rev 262)
+++ trunk/eclipse-preferences.epf 2008-06-11 01:10:40 UTC (rev 263)
@@ -1,3 +1,14 @@
+/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.codeComplete.argumentPrefixes=
+/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.codeComplete.argumentSuffixes=
+/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.codeComplete.deprecationCheck=enabled
+/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.codeComplete.discouragedReferenceCheck=enabled
+/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.codeComplete.fieldPrefixes=
+/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.codeComplete.fieldSuffixes=
+/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.codeComplete.localPrefixes=
+/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.codeComplete.localSuffixes=
+/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.codeComplete.staticFieldPrefixes=
+/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.codeComplete.staticFieldSuffixes=
+/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.codeComplete.visibilityCheck=enabled
/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.compiler.compliance=1.5
@@ -20,14 +31,15 @@
/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.compiler.problem.invalidJavadoc=error
/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsDeprecatedRef=enabled
/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.compiler.problem.invalidJavadocTags=enabled
-/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsNotVisibleRef=disabled
+/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsNotVisibleRef=enabled
/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=error
/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=warning
/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.compiler.problem.missingJavadocComments=ignore
/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding=enabled
/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility=protected
+/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.compiler.problem.missingJavadocTagDescription=return_tag
/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.compiler.problem.missingJavadocTags=error
-/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding=disabled
+/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding=enabled
/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=warning
/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.compiler.problem.missingSerialVersion=ignore
/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.compiler.problem.noEffectAssignment=error
@@ -48,7 +60,8 @@
/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.compiler.problem.unnecessaryElse=warning
/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning
/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
-/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore
+/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeUncheckedExceptions=enabled
+/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning
/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=enabled
/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.compiler.problem.unusedImport=warning
/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
@@ -59,13 +72,22 @@
/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.compiler.source=1.5
+/instance/org.eclipse.jdt.ui/content_assist_favorite_static_members=org.junit.Assert.*;org.hamcrest.core.Is.is;org.hamcrest.core.IsNot.not;org.hamcrest.core.IsNull.nullValue;org.hamcrest.core.IsNull.notNullValue;org.hamcrest.core.IsSame.sameInstance;org.hamcrest.core.IsInstanceOf.instanceOf;org.hamcrest.core.IsEqual.equalTo;org.hamcrest.core.IsAnything.anything;org.hamcrest.core.IsAnything.any;org.hamcrest.core.DescribedAs.describedAs;org.hamcrest.core.AnyOf.anyOf;org.hamcrest.core.AllOf.allOf;org.junit.matchers.IsCollectionContaining.hasItem;org.junit.matchers.IsCollectionContaining.hasItems;org.junit.matchers.Each.each;org.junit.matchers.JUnitMatchers.hasItem;org.junit.matchers.JUnitMatchers.hasItems;org.junit.matchers.JUnitMatchers.containsString;org.junit.matchers.JUnitMatchers.each;org.junit.matchers.JUnitMatchers.both;org.junit.matchers.JUnitMatchers.either;org.junit.matchers.StringContains.containsString;org.junit.matchers.TypeSafeMatcher.matches
/instance/org.eclipse.jdt.ui/org.eclipse.jdt.ui.gettersetter.use.is=true
/instance/org.eclipse.jdt.ui/org.eclipse.jdt.ui.ignorelowercasenames=true
/instance/org.eclipse.jdt.ui/org.eclipse.jdt.ui.importorder=\#;java;javax;org;com;
+/instance/org.eclipse.jdt.ui/org.eclipse.jdt.ui.javadoclocations.migrated=true
/instance/org.eclipse.jdt.ui/org.eclipse.jdt.ui.javadoc=true
+/instance/org.eclipse.jdt.ui/org.eclipse.jdt.ui.keywordthis=false
+/instance/org.eclipse.jdt.ui/org.eclipse.jdt.ui.methodreturntype=true
/instance/org.eclipse.jdt.ui/org.eclipse.jdt.ui.ondemandthreshold=99
/instance/org.eclipse.jdt.ui/org.eclipse.jdt.ui.overrideannotation=true
+/instance/org.eclipse.jdt.ui/org.eclipse.jdt.ui.packages.cuchildren=false
/instance/org.eclipse.jdt.ui/org.eclipse.jdt.ui.staticondemandthreshold=99
-/instance/org.eclipse.jdt.ui/org.eclipse.jdt.ui.text.custom_code_templates=<?xml version\="1.0" encoding\="UTF-8" standalone\="no"?><templates><template autoinsert\="false" context\="gettercomment_context" deleted\="false" description\="Comment for getter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.gettercomment" name\="gettercomment">/**\n * @return ${bare_field_name}\n */</template><template autoinsert\="false" context\="settercomment_context" deleted\="false" description\="Comment for setter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.settercomment" name\="settercomment">/**\n * @param ${param} Sets ${bare_field_name} to the specified value.\n */</template><template autoinsert\="false" context\="constructorcomment_context" deleted\="false" description\="Comment for created constructors" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorcomment" name\="constructorcomment">/**\n * ${tags}\n */</template><tem!
plate autoinsert\="false" context\="filecomment_context" deleted\="false" description\="Comment for created Java files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.filecomment" name\="filecomment">/*\n *\n */</template><template autoinsert\="false" context\="typecomment_context" deleted\="false" description\="Comment for created types" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.typecomment" name\="typecomment">/**\n * @author John Verhaeg\n * ${tags}\n */</template><template autoinsert\="false" context\="fieldcomment_context" deleted\="false" description\="Comment for fields" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.fieldcomment" name\="fieldcomment">/**\n */</template><template autoinsert\="false" context\="methodcomment_context" deleted\="false" description\="Comment for non-overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodcomment" name\="methodcomment">/**\n * ${tags}\n */</template><tem!
plate autoinsert\="false" context\="overridecomment_context" deleted\=
"false" description\="Comment for overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.overridecomment" name\="overridecomment">/**\n * <p>\n * {@inheritDoc}\n * </p>\n *\n * ${see_to_overridden}\n */</template><template autoinsert\="false" context\="delegatecomment_context" deleted\="false" description\="Comment for delegate methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.delegatecomment" name\="delegatecomment">/**\n * <p>\n * {@inheritDoc}\n * </p>\n *\n * ${see_to_target}\n */</template><template autoinsert\="false" context\="catchblock_context" deleted\="false" description\="Code in new catch blocks" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.catchblock" name\="catchblock"/><template autoinsert\="false" context\="methodbody_context" deleted\="false" description\="Code in created method stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodbody" name\="methodbody">${bo!
dy_statement}</template><template autoinsert\="false" context\="constructorbody_context" deleted\="false" description\="Code in created constructor stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorbody" name\="constructorbody">${body_statement}\n</template><template autoinsert\="false" context\="getterbody_context" deleted\="false" description\="Code in created getters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.getterbody" name\="getterbody">return ${field};</template><template autoinsert\="false" context\="setterbody_context" deleted\="false" description\="Code in created setters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.setterbody" name\="setterbody">${field} \= ${param};</template></templates>
+/instance/org.eclipse.jdt.ui/org.eclipse.jdt.ui.text.code_templates_migrated=true
+/instance/org.eclipse.jdt.ui/org.eclipse.jdt.ui.text.custom_code_templates=<?xml version\="1.0" encoding\="UTF-8"?><templates><template autoinsert\="false" context\="gettercomment_context" deleted\="false" description\="Comment for getter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.gettercomment" name\="gettercomment">/**\n * @return ${bare_field_name}\n */</template><template autoinsert\="false" context\="settercomment_context" deleted\="false" description\="Comment for setter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.settercomment" name\="settercomment">/**\n * @param ${param} Sets ${bare_field_name} to the specified value.\n */</template><template autoinsert\="false" context\="constructorcomment_context" deleted\="false" description\="Comment for created constructors" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorcomment" name\="constructorcomment">/**\n * ${tags}\n */</template><template autoinsert\!
="false" context\="filecomment_context" deleted\="false" description\="Comment for created Java files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.filecomment" name\="filecomment">/*\n * JBoss, Home of Professional Open Source.\n * Copyright 2008, Red Hat Middleware LLC, and individual contributors\n * as indicated by the @author tags. See the copyright.txt file in the\n * distribution for a full listing of individual contributors. \n *\n * This is free software; you can redistribute it and/or modify it\n * under the terms of the GNU Lesser General Public License as\n * published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This software is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Lesser General Public License for more details.\n *\n * You sh!
ould have received a copy of the GNU Lesser General Public\n * License
along with this software; if not, write to the Free\n * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n * 02110-1301 USA, or see the FSF site\: http\://www.fsf.org.\n */</template><template autoinsert\="false" context\="typecomment_context" deleted\="false" description\="Comment for created types" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.typecomment" name\="typecomment">/**\n * @author John Verhaeg\n * ${tags}\n */</template><template autoinsert\="false" context\="fieldcomment_context" deleted\="false" description\="Comment for fields" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.fieldcomment" name\="fieldcomment">/**\n */</template><template autoinsert\="false" context\="methodcomment_context" deleted\="false" description\="Comment for non-overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodcomment" name\="methodcomment">/**\n * ${tags}\n */</template><template autoinsert\="false" context!
\="overridecomment_context" deleted\="false" description\="Comment for overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.overridecomment" name\="overridecomment">/**\n * {@inheritDoc}\n *\n * ${see_to_overridden}\n */</template><template autoinsert\="false" context\="delegatecomment_context" deleted\="false" description\="Comment for delegate methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.delegatecomment" name\="delegatecomment">/**\n * {@inheritDoc}\n *\n * ${see_to_target}\n */</template><template autoinsert\="false" context\="catchblock_context" deleted\="false" description\="Code in new catch blocks" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.catchblock" name\="catchblock"></template><template autoinsert\="false" context\="methodbody_context" deleted\="false" description\="Code in created method stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodbody" name\="methodbody">${body_stateme!
nt}</template><template autoinsert\="false" context\="constructorbody_
context" deleted\="false" description\="Code in created constructor stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorbody" name\="constructorbody">${body_statement}\n</template><template autoinsert\="false" context\="getterbody_context" deleted\="false" description\="Code in created getters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.getterbody" name\="getterbody">return ${field};</template><template autoinsert\="false" context\="setterbody_context" deleted\="false" description\="Code in created setters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.setterbody" name\="setterbody">${field} \= ${param};</template></templates>
/instance/org.eclipse.jdt.ui/outlinesortoption=SF,SI,SM,F,I,C,M,T,
+/instance/org.eclipse.jdt.ui/tabWidthPropagated=true
+/instance/org.eclipse.ui.editors/printMarginColumn=130
+/instance/org.eclipse.ui.editors/printMargin=true
/instance/org.eclipse.ui.editors/spacesForTabs=true
17 years, 6 months
DNA SVN: r262 - in trunk: dna-common/src/test/java/org/jboss/dna/common/component and 22 other directories.
by dna-commits@lists.jboss.org
Author: jverhaeg(a)redhat.com
Date: 2008-06-10 19:32:20 -0400 (Tue, 10 Jun 2008)
New Revision: 262
Modified:
trunk/connectors/dna-connector-jbosscache/src/main/java/org/jboss/dna/connector/jbosscache/JBossCacheConnection.java
trunk/connectors/dna-connector-jbosscache/src/main/java/org/jboss/dna/connector/jbosscache/JBossCacheSource.java
trunk/dna-common/src/test/java/org/jboss/dna/common/component/ComponentConfigTest.java
trunk/dna-common/src/test/java/org/jboss/dna/common/i18n/I18nTest.java
trunk/dna-common/src/test/java/org/jboss/dna/common/jcr/AbstractJcrRepositoryTest.java
trunk/dna-common/src/test/java/org/jboss/dna/common/math/DoubleOperationsTest.java
trunk/dna-common/src/test/java/org/jboss/dna/common/math/DurationTest.java
trunk/dna-common/src/test/java/org/jboss/dna/common/math/FloatOperationsTest.java
trunk/dna-common/src/test/java/org/jboss/dna/common/math/IntegerOperationsTest.java
trunk/dna-common/src/test/java/org/jboss/dna/common/math/LongOperationsTest.java
trunk/dna-common/src/test/java/org/jboss/dna/common/monitor/ProgressStatusTest.java
trunk/dna-common/src/test/java/org/jboss/dna/common/naming/MockInitialContextTest.java
trunk/dna-common/src/test/java/org/jboss/dna/common/stats/DetailedStatisticsTest.java
trunk/dna-common/src/test/java/org/jboss/dna/common/stats/HistogramTest.java
trunk/dna-common/src/test/java/org/jboss/dna/common/stats/SimpleStatisticsTest.java
trunk/dna-common/src/test/java/org/jboss/dna/common/stats/StopwatchTest.java
trunk/dna-common/src/test/java/org/jboss/dna/common/text/InflectorTest.java
trunk/dna-common/src/test/java/org/jboss/dna/common/util/HashCodeTest.java
trunk/dna-common/src/test/java/org/jboss/dna/common/util/IoUtilTest.java
trunk/dna-common/src/test/java/org/jboss/dna/common/util/LoggerTest.java
trunk/dna-common/src/test/java/org/jboss/dna/common/util/StringUtilTest.java
trunk/dna-integration-tests/src/test/java/org/jboss/dna/tests/integration/jackrabbit/JackrabbitBasicFunctionTest.java
trunk/dna-integration-tests/src/test/java/org/jboss/dna/tests/integration/jackrabbit/JackrabbitDerbyStressTest.java
trunk/dna-integration-tests/src/test/java/org/jboss/dna/tests/integration/jackrabbit/JackrabbitInMemoryTest.java
trunk/dna-maven-classloader/src/test/java/org/jboss/dna/maven/MavenIdTest.java
trunk/dna-repository/src/main/java/org/jboss/dna/repository/util/SimpleSessionFactory.java
trunk/dna-repository/src/test/java/org/jboss/dna/repository/federation/FederatedRepositoryConnectionTest.java
trunk/dna-repository/src/test/java/org/jboss/dna/repository/federation/FederatedRepositoryTest.java
trunk/dna-repository/src/test/java/org/jboss/dna/repository/observation/NodeChangeTest.java
trunk/dna-repository/src/test/java/org/jboss/dna/repository/rules/RuleServiceTest.java
trunk/dna-repository/src/test/java/org/jboss/dna/repository/rules/RuleSetTest.java
trunk/dna-repository/src/test/java/org/jboss/dna/repository/sequencers/SequencerConfigTest.java
trunk/dna-repository/src/test/java/org/jboss/dna/repository/sequencers/SequencingServiceTest.java
trunk/dna-repository/src/test/java/org/jboss/dna/repository/sequencers/StreamSequencerAdapterTest.java
trunk/dna-repository/src/test/java/org/jboss/dna/repository/sequencers/xml/XmlSequencerTest.java
trunk/dna-repository/src/test/java/org/jboss/dna/repository/util/JndiSessionFactoryTest.java
trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/connection/RepositoryConnectionPoolTest.java
trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/connection/TimeDelayingRepositorySource.java
trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/AbstractValueFactoryTest.java
trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/BasicNameTest.java
trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/BasicNamespaceRegistryTest.java
trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/BasicPathSegmentTest.java
trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/BasicPathTest.java
trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/BooleanValueFactoryTest.java
trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/DecimalValueFactoryTest.java
trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/DoubleValueFactoryTest.java
trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/JodaDateTimeValueFactoryTest.java
trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/LongValueFactoryTest.java
trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/NameValueFactoryTest.java
trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/PathValueFactoryTest.java
trunk/docs/examples/gettingstarted/sequencers/src/main/java/org/jboss/example/dna/sequencers/SequencingClient.java
trunk/docs/examples/gettingstarted/sequencers/src/test/java/org/jboss/example/dna/sequencers/MockUserInterface.java
trunk/docs/examples/gettingstarted/sequencers/src/test/java/org/jboss/example/dna/sequencers/SequencingClientTest.java
trunk/sequencers/dna-sequencer-images/src/test/java/org/jboss/dna/sequencer/images/ImageMetadataSequencerTest.java
trunk/sequencers/dna-sequencer-images/src/test/java/org/jboss/dna/sequencer/images/ImageMetadataTest.java
Log:
Removed unnecessary throws clauses
Modified: trunk/connectors/dna-connector-jbosscache/src/main/java/org/jboss/dna/connector/jbosscache/JBossCacheConnection.java
===================================================================
--- trunk/connectors/dna-connector-jbosscache/src/main/java/org/jboss/dna/connector/jbosscache/JBossCacheConnection.java 2008-06-10 23:13:20 UTC (rev 261)
+++ trunk/connectors/dna-connector-jbosscache/src/main/java/org/jboss/dna/connector/jbosscache/JBossCacheConnection.java 2008-06-10 23:32:20 UTC (rev 262)
@@ -60,7 +60,8 @@
/**
* {@inheritDoc}
*/
- public void notify( String sourceName, Object... events ) {
+ public void notify( String sourceName,
+ Object... events ) {
// do nothing
}
};
@@ -74,7 +75,8 @@
/**
*
*/
- /* package */JBossCacheConnection( JBossCacheSource source, Cache<Name, Object> cache ) {
+ /* package */JBossCacheConnection( JBossCacheSource source,
+ Cache<Name, Object> cache ) {
assert source != null;
assert cache != null;
this.source = source;
@@ -112,7 +114,8 @@
/**
* {@inheritDoc}
*/
- public boolean ping( long time, TimeUnit unit ) {
+ public boolean ping( long time,
+ TimeUnit unit ) {
this.cache.getRoot();
return true;
}
@@ -134,7 +137,8 @@
/**
* {@inheritDoc}
*/
- public void execute( ExecutionEnvironment env, GraphCommand... commands ) throws RepositorySourceException {
+ public void execute( ExecutionEnvironment env,
+ GraphCommand... commands ) {
// Set up the workspace ...
// Now execute the commands ...
@@ -292,7 +296,8 @@
return Fqn.fromElements(pathSegment);
}
- protected Node<Name, Object> getNode( ExecutionEnvironment env, Path path ) {
+ protected Node<Name, Object> getNode( ExecutionEnvironment env,
+ Path path ) {
// Look up the node with the supplied path ...
Fqn<Segment> fqn = getFullyQualifiedName(path);
Node<Name, Object> node = cache.getNode(fqn);
@@ -308,7 +313,10 @@
return UUID.randomUUID();
}
- protected int copyNode( Node<Name, Object> original, Node<Name, Object> newParent, boolean recursive, Name uuidProperty ) {
+ protected int copyNode( Node<Name, Object> original,
+ Node<Name, Object> newParent,
+ boolean recursive,
+ Name uuidProperty ) {
// Get or create the new node ...
Segment name = (Segment)original.getFqn().getLastElement();
Node<Name, Object> copy = newParent.addChild(getFullyQualifiedName(name));
Modified: trunk/connectors/dna-connector-jbosscache/src/main/java/org/jboss/dna/connector/jbosscache/JBossCacheSource.java
===================================================================
--- trunk/connectors/dna-connector-jbosscache/src/main/java/org/jboss/dna/connector/jbosscache/JBossCacheSource.java 2008-06-10 23:13:20 UTC (rev 261)
+++ trunk/connectors/dna-connector-jbosscache/src/main/java/org/jboss/dna/connector/jbosscache/JBossCacheSource.java 2008-06-10 23:32:20 UTC (rev 262)
@@ -49,7 +49,6 @@
import org.jboss.dna.spi.graph.NameFactory;
import org.jboss.dna.spi.graph.connection.RepositoryConnection;
import org.jboss.dna.spi.graph.connection.RepositorySource;
-import org.jboss.dna.spi.graph.connection.RepositorySourceException;
/**
* @author Randall Hauch
@@ -192,7 +191,8 @@
* @throws NamingException if there is a problem registering this object
* @see #getJndiName()
*/
- public synchronized void setJndiName( String name, Context context ) throws NamingException {
+ public synchronized void setJndiName( String name,
+ Context context ) throws NamingException {
ArgCheck.isNotNull(name, "name");
if (context == null) context = new InitialContext();
@@ -272,7 +272,7 @@
/**
* {@inheritDoc}
*/
- public synchronized RepositoryConnection getConnection() throws RepositorySourceException {
+ public synchronized RepositoryConnection getConnection() {
if (this.cache == null) {
CacheFactory<Name, Object> factory = new DefaultCacheFactory<Name, Object>();
cache = factory.createCache(cacheConfigurationName);
@@ -304,7 +304,10 @@
/**
* {@inheritDoc}
*/
- public Object getObjectInstance( Object obj, javax.naming.Name name, Context nameCtx, Hashtable<?, ?> environment ) throws Exception {
+ public Object getObjectInstance( Object obj,
+ javax.naming.Name name,
+ Context nameCtx,
+ Hashtable<?, ?> environment ) {
if (obj instanceof Reference) {
Reference ref = (Reference)obj;
if (ref.getClassName().equals(getClass().getName())) {
Modified: trunk/dna-common/src/test/java/org/jboss/dna/common/component/ComponentConfigTest.java
===================================================================
--- trunk/dna-common/src/test/java/org/jboss/dna/common/component/ComponentConfigTest.java 2008-06-10 23:13:20 UTC (rev 261)
+++ trunk/dna-common/src/test/java/org/jboss/dna/common/component/ComponentConfigTest.java 2008-06-10 23:32:20 UTC (rev 262)
@@ -41,7 +41,7 @@
private String[] validClasspath;
@Before
- public void beforeEach() throws Exception {
+ public void beforeEach() {
this.validName = "valid configuration name";
this.validDescription = "a Component";
this.validClassname = "org.jboss.dna.acme.GenericComponent";
Modified: trunk/dna-common/src/test/java/org/jboss/dna/common/i18n/I18nTest.java
===================================================================
--- trunk/dna-common/src/test/java/org/jboss/dna/common/i18n/I18nTest.java 2008-06-10 23:13:20 UTC (rev 261)
+++ trunk/dna-common/src/test/java/org/jboss/dna/common/i18n/I18nTest.java 2008-06-10 23:32:20 UTC (rev 262)
@@ -46,406 +46,406 @@
*/
public final class I18nTest {
- @Before
- public void beforeEach() throws Exception {
- clearFields(TestI18n.class);
- clearFields(TestI18nDuplicateProperty.class);
- clearFields(TestI18nFinal.class);
- clearFields(TestI18nFinalField.class);
- clearFields(TestI18nInterface.class);
- clearFields(TestI18nMissingLocalization.class);
- clearFields(TestI18nMissingProperty.class);
- clearFields(TestI18nNotPublicField.class);
- clearFields(TestI18nNotStaticField.class);
- clearFields(TestI18nPrivate.class);
- clearFields(TestI18nUnusedProperty.class);
- for (Entry<Locale, Map<Class, Set<String>>> localeToMapEntry : I18n.LOCALE_TO_CLASS_TO_PROBLEMS_MAP.entrySet()) {
- for (Iterator<Entry<Class, Set<String>>> iter = localeToMapEntry.getValue().entrySet().iterator(); iter.hasNext();) {
- if (iter.next().getKey() != CommonI18n.class) {
- iter.remove();
- }
- }
- }
- }
+ @Before
+ public void beforeEach() throws Exception {
+ clearFields(TestI18n.class);
+ clearFields(TestI18nDuplicateProperty.class);
+ clearFields(TestI18nFinal.class);
+ clearFields(TestI18nFinalField.class);
+ clearFields(TestI18nInterface.class);
+ clearFields(TestI18nMissingLocalization.class);
+ clearFields(TestI18nMissingProperty.class);
+ clearFields(TestI18nNotPublicField.class);
+ clearFields(TestI18nNotStaticField.class);
+ clearFields(TestI18nPrivate.class);
+ clearFields(TestI18nUnusedProperty.class);
+ for (Entry<Locale, Map<Class, Set<String>>> localeToMapEntry : I18n.LOCALE_TO_CLASS_TO_PROBLEMS_MAP.entrySet()) {
+ for (Iterator<Entry<Class, Set<String>>> iter = localeToMapEntry.getValue().entrySet().iterator(); iter.hasNext();) {
+ if (iter.next().getKey() != CommonI18n.class) {
+ iter.remove();
+ }
+ }
+ }
+ }
- private void clearFields( Class i18nClass ) throws Exception {
- for (Field fld : i18nClass.getDeclaredFields()) {
- if (fld.getType() == I18n.class && (fld.getModifiers() & Modifier.PUBLIC) == Modifier.PUBLIC
- && (fld.getModifiers() & Modifier.STATIC) == Modifier.STATIC
- && (fld.getModifiers() & Modifier.FINAL) != Modifier.FINAL) {
- fld.set(null, null);
- }
- }
- }
+ private void clearFields( Class i18nClass ) throws Exception {
+ for (Field fld : i18nClass.getDeclaredFields()) {
+ if (fld.getType() == I18n.class && (fld.getModifiers() & Modifier.PUBLIC) == Modifier.PUBLIC
+ && (fld.getModifiers() & Modifier.STATIC) == Modifier.STATIC
+ && (fld.getModifiers() & Modifier.FINAL) != Modifier.FINAL) {
+ fld.set(null, null);
+ }
+ }
+ }
- @Test( expected = IllegalArgumentException.class )
- public void shouldFailToGetLocalizationProblemLocalesIfNoClassSupplied() {
- I18n.getLocalizationProblemLocales(null);
- }
+ @Test( expected = IllegalArgumentException.class )
+ public void shouldFailToGetLocalizationProblemLocalesIfNoClassSupplied() {
+ I18n.getLocalizationProblemLocales(null);
+ }
- @Test
- public void shouldNeverReturnNullWhenGettingLocalizationProblemLocales() {
- assertThat(I18n.getLocalizationProblemLocales(TestI18n.class), notNullValue());
- }
+ @Test
+ public void shouldNeverReturnNullWhenGettingLocalizationProblemLocales() {
+ assertThat(I18n.getLocalizationProblemLocales(TestI18n.class), notNullValue());
+ }
- @Test( expected = IllegalArgumentException.class )
- public void shouldFailToGetLocalizationProblemsForDefaultLocaleIfNoClassSupplied() {
- I18n.getLocalizationProblems(null);
- }
+ @Test( expected = IllegalArgumentException.class )
+ public void shouldFailToGetLocalizationProblemsForDefaultLocaleIfNoClassSupplied() {
+ I18n.getLocalizationProblems(null);
+ }
- @Test( expected = IllegalArgumentException.class )
- public void shouldFailToGetLocalizationProblemsForSuppliedLocaleIfNoClassSupplied() {
- I18n.getLocalizationProblems(null, Locale.US);
- }
+ @Test( expected = IllegalArgumentException.class )
+ public void shouldFailToGetLocalizationProblemsForSuppliedLocaleIfNoClassSupplied() {
+ I18n.getLocalizationProblems(null, Locale.US);
+ }
- @Test
- public void shouldNeverReturnNullWhenGettingLocalizationProblemsForDefaultLocale() {
- assertThat(I18n.getLocalizationProblems(TestI18n.class), notNullValue());
- }
+ @Test
+ public void shouldNeverReturnNullWhenGettingLocalizationProblemsForDefaultLocale() {
+ assertThat(I18n.getLocalizationProblems(TestI18n.class), notNullValue());
+ }
- @Test
- public void shouldNeverReturnNullWhenGettingLocalizationProblemsForSuppliedLocale() {
- assertThat(I18n.getLocalizationProblems(TestI18n.class, Locale.US), notNullValue());
- }
+ @Test
+ public void shouldNeverReturnNullWhenGettingLocalizationProblemsForSuppliedLocale() {
+ assertThat(I18n.getLocalizationProblems(TestI18n.class, Locale.US), notNullValue());
+ }
- @Test
- public void shouldNotHaveLocalizationProblemsAfterInitializationButBeforeLocalization() {
- I18n.initialize(TestI18nUnusedProperty.class);
- assertThat(I18n.getLocalizationProblems(TestI18nUnusedProperty.class, null).isEmpty(), is(true));
- assertThat(I18n.getLocalizationProblemLocales(TestI18nUnusedProperty.class).isEmpty(), is(true));
- }
+ @Test
+ public void shouldNotHaveLocalizationProblemsAfterInitializationButBeforeLocalization() {
+ I18n.initialize(TestI18nUnusedProperty.class);
+ assertThat(I18n.getLocalizationProblems(TestI18nUnusedProperty.class, null).isEmpty(), is(true));
+ assertThat(I18n.getLocalizationProblemLocales(TestI18nUnusedProperty.class).isEmpty(), is(true));
+ }
- @Test
- public void shouldGetLocalizationProblemsForDefaultLocaleIfNoLocaleSupplied() {
- I18n.initialize(TestI18nUnusedProperty.class);
- TestI18nUnusedProperty.testMessage.text("test");
- assertThat(I18n.getLocalizationProblems(TestI18nUnusedProperty.class, null).isEmpty(), is(false));
- }
+ @Test
+ public void shouldGetLocalizationProblemsForDefaultLocaleIfNoLocaleSupplied() {
+ I18n.initialize(TestI18nUnusedProperty.class);
+ TestI18nUnusedProperty.testMessage.text("test");
+ assertThat(I18n.getLocalizationProblems(TestI18nUnusedProperty.class, null).isEmpty(), is(false));
+ }
- @Test( expected = IllegalArgumentException.class )
- public void shouldFailToInitializeIfNoClassSupplied() {
- I18n.initialize(null);
- }
+ @Test( expected = IllegalArgumentException.class )
+ public void shouldFailToInitializeIfNoClassSupplied() {
+ I18n.initialize(null);
+ }
- @Test( expected = SystemFailureException.class )
- public void shouldFailToInitializeFinalI18nField() {
- try {
- I18n.initialize(TestI18nFinalField.class);
- } catch (SystemFailureException err) {
- assertThat(err.getMessage(), is(CommonI18n.i18nFieldFinal.text("testMessage", TestI18nFinalField.class)));
- System.err.println(err);
- throw err;
- }
- }
+ @Test( expected = SystemFailureException.class )
+ public void shouldFailToInitializeFinalI18nField() {
+ try {
+ I18n.initialize(TestI18nFinalField.class);
+ } catch (SystemFailureException err) {
+ assertThat(err.getMessage(), is(CommonI18n.i18nFieldFinal.text("testMessage", TestI18nFinalField.class)));
+ System.err.println(err);
+ throw err;
+ }
+ }
- @Test( expected = SystemFailureException.class )
- public void shouldFailToInitializeNonPublicI18nField() {
- try {
- I18n.initialize(TestI18nNotPublicField.class);
- } catch (SystemFailureException err) {
- assertThat(err.getMessage(), is(CommonI18n.i18nFieldNotPublic.text("testMessage", TestI18nNotPublicField.class)));
- System.err.println(err);
- throw err;
- }
- }
+ @Test( expected = SystemFailureException.class )
+ public void shouldFailToInitializeNonPublicI18nField() {
+ try {
+ I18n.initialize(TestI18nNotPublicField.class);
+ } catch (SystemFailureException err) {
+ assertThat(err.getMessage(), is(CommonI18n.i18nFieldNotPublic.text("testMessage", TestI18nNotPublicField.class)));
+ System.err.println(err);
+ throw err;
+ }
+ }
- @Test( expected = SystemFailureException.class )
- public void shouldFailToInitializeNonStaticI18nField() {
- try {
- I18n.initialize(TestI18nNotStaticField.class);
- } catch (SystemFailureException err) {
- assertThat(err.getMessage(), is(CommonI18n.i18nFieldNotStatic.text("testMessage", TestI18nNotStaticField.class)));
- System.err.println(err);
- throw err;
- }
- }
+ @Test( expected = SystemFailureException.class )
+ public void shouldFailToInitializeNonStaticI18nField() {
+ try {
+ I18n.initialize(TestI18nNotStaticField.class);
+ } catch (SystemFailureException err) {
+ assertThat(err.getMessage(), is(CommonI18n.i18nFieldNotStatic.text("testMessage", TestI18nNotStaticField.class)));
+ System.err.println(err);
+ throw err;
+ }
+ }
- @Test
- public void shouldInitializeFinalClasses() {
- I18n.initialize(TestI18nFinal.class);
- assertThat(TestI18nFinal.testMessage, instanceOf(I18n.class));
- }
+ @Test
+ public void shouldInitializeFinalClasses() {
+ I18n.initialize(TestI18nFinal.class);
+ assertThat(TestI18nFinal.testMessage, instanceOf(I18n.class));
+ }
- @Test
- public void shouldInitializePrivateClasses() {
- I18n.initialize(TestI18nPrivate.class);
- assertThat(TestI18nPrivate.testMessage, instanceOf(I18n.class));
- }
+ @Test
+ public void shouldInitializePrivateClasses() {
+ I18n.initialize(TestI18nPrivate.class);
+ assertThat(TestI18nPrivate.testMessage, instanceOf(I18n.class));
+ }
- @Test
- public void shouldInitializeI18nFields() {
- I18n.initialize(TestI18n.class);
- assertThat(TestI18n.testMessage, instanceOf(I18n.class));
- }
+ @Test
+ public void shouldInitializeI18nFields() {
+ I18n.initialize(TestI18n.class);
+ assertThat(TestI18n.testMessage, instanceOf(I18n.class));
+ }
- @Test
- public void shouldNotInitializeNonI18nFields() {
- I18n.initialize(TestI18n.class);
- assertThat(TestI18n.nonI18n, nullValue());
- }
+ @Test
+ public void shouldNotInitializeNonI18nFields() {
+ I18n.initialize(TestI18n.class);
+ assertThat(TestI18n.nonI18n, nullValue());
+ }
- @Test( expected = IllegalArgumentException.class )
- public void shouldFailToInitializeInterfaces() {
- try {
- I18n.initialize(TestI18nInterface.class);
- } catch (IllegalArgumentException err) {
- assertThat(err.getMessage(), is(CommonI18n.i18nClassInterface.text(TestI18nInterface.class.getName())));
- System.err.println(err);
- throw err;
- }
- }
+ @Test( expected = IllegalArgumentException.class )
+ public void shouldFailToInitializeInterfaces() {
+ try {
+ I18n.initialize(TestI18nInterface.class);
+ } catch (IllegalArgumentException err) {
+ assertThat(err.getMessage(), is(CommonI18n.i18nClassInterface.text(TestI18nInterface.class.getName())));
+ System.err.println(err);
+ throw err;
+ }
+ }
- @Test
- public void shouldProvideIdempotentInitialization() {
- I18n.initialize(TestI18n.class);
- assertThat(TestI18n.testMessage1.text("test"), is("test"));
- I18n.initialize(TestI18n.class);
- assertThat(TestI18n.testMessage1.text("test"), is("test"));
- }
+ @Test
+ public void shouldProvideIdempotentInitialization() {
+ I18n.initialize(TestI18n.class);
+ assertThat(TestI18n.testMessage1.text("test"), is("test"));
+ I18n.initialize(TestI18n.class);
+ assertThat(TestI18n.testMessage1.text("test"), is("test"));
+ }
- @Test
- public void shouldNotBeLocalizedAfterInitialization() {
- I18n.initialize(TestI18nDuplicateProperty.class);
- assertThat(TestI18nDuplicateProperty.testMessage.localeToTextMap.get(Locale.getDefault()), nullValue());
- assertThat(TestI18nDuplicateProperty.testMessage.localeToProblemMap.get(Locale.getDefault()), nullValue());
- }
+ @Test
+ public void shouldNotBeLocalizedAfterInitialization() {
+ I18n.initialize(TestI18nDuplicateProperty.class);
+ assertThat(TestI18nDuplicateProperty.testMessage.localeToTextMap.get(Locale.getDefault()), nullValue());
+ assertThat(TestI18nDuplicateProperty.testMessage.localeToProblemMap.get(Locale.getDefault()), nullValue());
+ }
- @Test
- public void shouldHaveIdThatMatchesFieldName() throws Exception {
- I18n.initialize(TestI18n.class);
- assertThat(TestI18n.testMessage.id(), is("testMessage"));
- }
+ @Test
+ public void shouldHaveIdThatMatchesFieldName() {
+ I18n.initialize(TestI18n.class);
+ assertThat(TestI18n.testMessage.id(), is("testMessage"));
+ }
- @Test
- public void shouldNotBeLocalizedIfAskedForId() {
- I18n.initialize(TestI18nDuplicateProperty.class);
- TestI18nDuplicateProperty.testMessage.id();
- assertThat(TestI18nDuplicateProperty.testMessage.localeToTextMap.get(Locale.getDefault()), nullValue());
- assertThat(TestI18nDuplicateProperty.testMessage.localeToProblemMap.get(Locale.getDefault()), nullValue());
- }
+ @Test
+ public void shouldNotBeLocalizedIfAskedForId() {
+ I18n.initialize(TestI18nDuplicateProperty.class);
+ TestI18nDuplicateProperty.testMessage.id();
+ assertThat(TestI18nDuplicateProperty.testMessage.localeToTextMap.get(Locale.getDefault()), nullValue());
+ assertThat(TestI18nDuplicateProperty.testMessage.localeToProblemMap.get(Locale.getDefault()), nullValue());
+ }
- @Test
- public void shouldBeLocalizedIfAskedIfHasProblem() {
- I18n.initialize(TestI18nDuplicateProperty.class);
- TestI18nDuplicateProperty.testMessage.hasProblem();
- assertThat(TestI18nDuplicateProperty.testMessage.localeToTextMap.get(Locale.getDefault()), notNullValue());
- assertThat(TestI18nDuplicateProperty.testMessage.localeToProblemMap.get(Locale.getDefault()), notNullValue());
- }
+ @Test
+ public void shouldBeLocalizedIfAskedIfHasProblem() {
+ I18n.initialize(TestI18nDuplicateProperty.class);
+ TestI18nDuplicateProperty.testMessage.hasProblem();
+ assertThat(TestI18nDuplicateProperty.testMessage.localeToTextMap.get(Locale.getDefault()), notNullValue());
+ assertThat(TestI18nDuplicateProperty.testMessage.localeToProblemMap.get(Locale.getDefault()), notNullValue());
+ }
- @Test
- public void shouldBeLocalizedIfAskedForProblem() {
- I18n.initialize(TestI18nDuplicateProperty.class);
- TestI18nDuplicateProperty.testMessage.problem();
- assertThat(TestI18nDuplicateProperty.testMessage.localeToTextMap.get(Locale.getDefault()), notNullValue());
- assertThat(TestI18nDuplicateProperty.testMessage.localeToProblemMap.get(Locale.getDefault()), notNullValue());
- }
+ @Test
+ public void shouldBeLocalizedIfAskedForProblem() {
+ I18n.initialize(TestI18nDuplicateProperty.class);
+ TestI18nDuplicateProperty.testMessage.problem();
+ assertThat(TestI18nDuplicateProperty.testMessage.localeToTextMap.get(Locale.getDefault()), notNullValue());
+ assertThat(TestI18nDuplicateProperty.testMessage.localeToProblemMap.get(Locale.getDefault()), notNullValue());
+ }
- @Test
- public void shouldBeLocalizedIfConvertedToString() {
- I18n.initialize(TestI18nDuplicateProperty.class);
- TestI18nDuplicateProperty.testMessage.toString();
- assertThat(TestI18nDuplicateProperty.testMessage.localeToTextMap.get(Locale.getDefault()), notNullValue());
- assertThat(TestI18nDuplicateProperty.testMessage.localeToProblemMap.get(Locale.getDefault()), notNullValue());
- }
+ @Test
+ public void shouldBeLocalizedIfConvertedToString() {
+ I18n.initialize(TestI18nDuplicateProperty.class);
+ TestI18nDuplicateProperty.testMessage.toString();
+ assertThat(TestI18nDuplicateProperty.testMessage.localeToTextMap.get(Locale.getDefault()), notNullValue());
+ assertThat(TestI18nDuplicateProperty.testMessage.localeToProblemMap.get(Locale.getDefault()), notNullValue());
+ }
- @Test
- public void shouldContainAngleBracketedProblemInTextIfMissingLocalization() throws Exception {
- I18n.initialize(TestI18nMissingLocalization.class);
- String text = TestI18nMissingLocalization.testMessage.text();
- assertThat(text,
- is('<' + CommonI18n.i18nLocalizationProblems.text(TestI18nMissingLocalization.class, Locale.getDefault()) + '>'));
- System.out.println("Text: " + text);
- }
+ @Test
+ public void shouldContainAngleBracketedProblemInTextIfMissingLocalization() {
+ I18n.initialize(TestI18nMissingLocalization.class);
+ String text = TestI18nMissingLocalization.testMessage.text();
+ assertThat(text,
+ is('<' + CommonI18n.i18nLocalizationProblems.text(TestI18nMissingLocalization.class, Locale.getDefault()) + '>'));
+ System.out.println("Text: " + text);
+ }
- @Test
- public void shouldHaveProblemIfMissingLocalization() throws Exception {
- I18n.initialize(TestI18nMissingLocalization.class);
- assertThat(TestI18nMissingLocalization.testMessage.hasProblem(), is(true));
- String problem = TestI18nMissingLocalization.testMessage.problem();
- assertThat(problem, is(CommonI18n.i18nLocalizationProblems.text(TestI18nMissingLocalization.class, Locale.getDefault())));
- System.out.println("Problem: " + problem);
- }
+ @Test
+ public void shouldHaveProblemIfMissingLocalization() {
+ I18n.initialize(TestI18nMissingLocalization.class);
+ assertThat(TestI18nMissingLocalization.testMessage.hasProblem(), is(true));
+ String problem = TestI18nMissingLocalization.testMessage.problem();
+ assertThat(problem, is(CommonI18n.i18nLocalizationProblems.text(TestI18nMissingLocalization.class, Locale.getDefault())));
+ System.out.println("Problem: " + problem);
+ }
- @Test
- public void shouldHaveLocalicationProblemIfMissingLocalization() throws Exception {
- I18n.initialize(TestI18nMissingLocalization.class);
- TestI18nMissingLocalization.testMessage.text();
- assertThat(I18n.getLocalizationProblems(TestI18nMissingLocalization.class).size(), is(1));
- assertThat(I18n.getLocalizationProblems(TestI18nMissingLocalization.class).iterator().next(),
- is(CommonI18n.i18nLocalizationFileNotFound.text(TestI18nMissingLocalization.class.getName())));
- assertThat(I18n.getLocalizationProblemLocales(TestI18nMissingLocalization.class).size(), is(1));
- assertThat(I18n.getLocalizationProblemLocales(TestI18nMissingLocalization.class).iterator().next(),
- is(Locale.getDefault()));
- }
+ @Test
+ public void shouldHaveLocalicationProblemIfMissingLocalization() {
+ I18n.initialize(TestI18nMissingLocalization.class);
+ TestI18nMissingLocalization.testMessage.text();
+ assertThat(I18n.getLocalizationProblems(TestI18nMissingLocalization.class).size(), is(1));
+ assertThat(I18n.getLocalizationProblems(TestI18nMissingLocalization.class).iterator().next(),
+ is(CommonI18n.i18nLocalizationFileNotFound.text(TestI18nMissingLocalization.class.getName())));
+ assertThat(I18n.getLocalizationProblemLocales(TestI18nMissingLocalization.class).size(), is(1));
+ assertThat(I18n.getLocalizationProblemLocales(TestI18nMissingLocalization.class).iterator().next(),
+ is(Locale.getDefault()));
+ }
- @Test
- public void shouldHaveTextIfPropertyDuplicate() throws Exception {
- I18n.initialize(TestI18nDuplicateProperty.class);
- String text = TestI18nDuplicateProperty.testMessage.text("test");
- assertThat(text.charAt(0), not('<'));
- System.out.println("Text: " + text);
- }
+ @Test
+ public void shouldHaveTextIfPropertyDuplicate() {
+ I18n.initialize(TestI18nDuplicateProperty.class);
+ String text = TestI18nDuplicateProperty.testMessage.text("test");
+ assertThat(text.charAt(0), not('<'));
+ System.out.println("Text: " + text);
+ }
- @Test
- public void shouldHaveProblemIfPropertyDuplicate() throws Exception {
- I18n.initialize(TestI18nDuplicateProperty.class);
- assertThat(TestI18nDuplicateProperty.testMessage.hasProblem(), is(true));
- String problem = TestI18nDuplicateProperty.testMessage.problem();
- assertThat(problem, notNullValue());
- System.out.println("Problem: " + problem);
- }
+ @Test
+ public void shouldHaveProblemIfPropertyDuplicate() {
+ I18n.initialize(TestI18nDuplicateProperty.class);
+ assertThat(TestI18nDuplicateProperty.testMessage.hasProblem(), is(true));
+ String problem = TestI18nDuplicateProperty.testMessage.problem();
+ assertThat(problem, notNullValue());
+ System.out.println("Problem: " + problem);
+ }
- @Test
- public void shouldNotHaveLocalicationProblemIfPropertyDuplicate() throws Exception {
- I18n.initialize(TestI18nDuplicateProperty.class);
- TestI18nDuplicateProperty.testMessage.text("test");
- assertThat(I18n.getLocalizationProblems(TestI18nDuplicateProperty.class).isEmpty(), is(true));
- assertThat(I18n.getLocalizationProblemLocales(TestI18nDuplicateProperty.class).isEmpty(), is(true));
- }
+ @Test
+ public void shouldNotHaveLocalicationProblemIfPropertyDuplicate() {
+ I18n.initialize(TestI18nDuplicateProperty.class);
+ TestI18nDuplicateProperty.testMessage.text("test");
+ assertThat(I18n.getLocalizationProblems(TestI18nDuplicateProperty.class).isEmpty(), is(true));
+ assertThat(I18n.getLocalizationProblemLocales(TestI18nDuplicateProperty.class).isEmpty(), is(true));
+ }
- @Test
- public void shouldContainAngleBracketedProblemInTextIfPropertyMissing() throws Exception {
- I18n.initialize(TestI18nMissingProperty.class);
- String text = TestI18nMissingProperty.testMessage1.text("test");
- assertThat(text.charAt(0), is('<'));
- System.out.println("Text: " + text);
- }
+ @Test
+ public void shouldContainAngleBracketedProblemInTextIfPropertyMissing() {
+ I18n.initialize(TestI18nMissingProperty.class);
+ String text = TestI18nMissingProperty.testMessage1.text("test");
+ assertThat(text.charAt(0), is('<'));
+ System.out.println("Text: " + text);
+ }
- @Test
- public void shouldHaveProblemIfPropertyMissing() throws Exception {
- I18n.initialize(TestI18nMissingProperty.class);
- assertThat(TestI18nMissingProperty.testMessage1.hasProblem(), is(true));
- String problem = TestI18nMissingProperty.testMessage1.problem();
- assertThat(problem, notNullValue());
- System.out.println("Problem: " + problem);
- }
+ @Test
+ public void shouldHaveProblemIfPropertyMissing() {
+ I18n.initialize(TestI18nMissingProperty.class);
+ assertThat(TestI18nMissingProperty.testMessage1.hasProblem(), is(true));
+ String problem = TestI18nMissingProperty.testMessage1.problem();
+ assertThat(problem, notNullValue());
+ System.out.println("Problem: " + problem);
+ }
- @Test
- public void shouldNotHaveLocalicationProblemIfPropertyMissing() throws Exception {
- I18n.initialize(TestI18nMissingProperty.class);
- TestI18nMissingProperty.testMessage1.text("test");
- assertThat(I18n.getLocalizationProblems(TestI18nMissingProperty.class).isEmpty(), is(true));
- assertThat(I18n.getLocalizationProblemLocales(TestI18nMissingProperty.class).isEmpty(), is(true));
- }
+ @Test
+ public void shouldNotHaveLocalicationProblemIfPropertyMissing() {
+ I18n.initialize(TestI18nMissingProperty.class);
+ TestI18nMissingProperty.testMessage1.text("test");
+ assertThat(I18n.getLocalizationProblems(TestI18nMissingProperty.class).isEmpty(), is(true));
+ assertThat(I18n.getLocalizationProblemLocales(TestI18nMissingProperty.class).isEmpty(), is(true));
+ }
- @Test
- public void shouldHaveLocalicationProblemIfPropertyUnused() throws Exception {
- I18n.initialize(TestI18nUnusedProperty.class);
- TestI18nUnusedProperty.testMessage.text("test");
- assertThat(I18n.getLocalizationProblems(TestI18nUnusedProperty.class).size(), is(1));
- assertThat(I18n.getLocalizationProblemLocales(TestI18nUnusedProperty.class).size(), is(1));
- assertThat(I18n.getLocalizationProblemLocales(TestI18nUnusedProperty.class).iterator().next(), is(Locale.getDefault()));
- }
+ @Test
+ public void shouldHaveLocalicationProblemIfPropertyUnused() {
+ I18n.initialize(TestI18nUnusedProperty.class);
+ TestI18nUnusedProperty.testMessage.text("test");
+ assertThat(I18n.getLocalizationProblems(TestI18nUnusedProperty.class).size(), is(1));
+ assertThat(I18n.getLocalizationProblemLocales(TestI18nUnusedProperty.class).size(), is(1));
+ assertThat(I18n.getLocalizationProblemLocales(TestI18nUnusedProperty.class).iterator().next(), is(Locale.getDefault()));
+ }
- @Test
- public void shouldHaveTextMatchingLocalizationFilePropertyValue() throws Exception {
- I18n.initialize(TestI18n.class);
- assertThat(TestI18n.testMessage.text(), is("Test Message"));
- }
+ @Test
+ public void shouldHaveTextMatchingLocalizationFilePropertyValue() {
+ I18n.initialize(TestI18n.class);
+ assertThat(TestI18n.testMessage.text(), is("Test Message"));
+ }
- @Test( expected = IllegalArgumentException.class )
- public void shouldFailIfTooFewArgumentsSuppliedToText() throws Exception {
- I18n.initialize(TestI18n.class);
- try {
- TestI18n.testMessage1.text();
- } catch (IllegalArgumentException err) {
- System.err.println(err);
- throw err;
- }
- }
+ @Test( expected = IllegalArgumentException.class )
+ public void shouldFailIfTooFewArgumentsSuppliedToText() {
+ I18n.initialize(TestI18n.class);
+ try {
+ TestI18n.testMessage1.text();
+ } catch (IllegalArgumentException err) {
+ System.err.println(err);
+ throw err;
+ }
+ }
- @Test( expected = IllegalArgumentException.class )
- public void shouldFailIfTooManyArgumentsSuppliedToText() throws Exception {
- I18n.initialize(TestI18n.class);
- try {
- TestI18n.testMessage1.text("Test", "Message");
- } catch (IllegalArgumentException err) {
- System.err.println(err);
- throw err;
- }
- }
+ @Test( expected = IllegalArgumentException.class )
+ public void shouldFailIfTooManyArgumentsSuppliedToText() {
+ I18n.initialize(TestI18n.class);
+ try {
+ TestI18n.testMessage1.text("Test", "Message");
+ } catch (IllegalArgumentException err) {
+ System.err.println(err);
+ throw err;
+ }
+ }
- @Test
- public void shouldContainArgumentsInRightOrderInText() throws Exception {
- I18n.initialize(TestI18n.class);
- assertThat(TestI18n.testMessage2.text("Test", "Message"), is("Message Test"));
- }
+ @Test
+ public void shouldContainArgumentsInRightOrderInText() {
+ I18n.initialize(TestI18n.class);
+ assertThat(TestI18n.testMessage2.text("Test", "Message"), is("Message Test"));
+ }
- @Test
- public void shouldAllowReuseOfArgumentsInText() throws Exception {
- I18n.initialize(TestI18n.class);
- assertThat(TestI18n.testMessage3.text("Test", "Message"), is("Message Test Message"));
- }
+ @Test
+ public void shouldAllowReuseOfArgumentsInText() {
+ I18n.initialize(TestI18n.class);
+ assertThat(TestI18n.testMessage3.text("Test", "Message"), is("Message Test Message"));
+ }
- @Test
- public void shouldContainLocaleSpecificText() {
- I18n.initialize(TestI18n.class);
- assertThat(TestI18n.testMessage.text(Locale.FRENCH), is("Message de Test"));
- }
+ @Test
+ public void shouldContainLocaleSpecificText() {
+ I18n.initialize(TestI18n.class);
+ assertThat(TestI18n.testMessage.text(Locale.FRENCH), is("Message de Test"));
+ }
- @Test
- public void shouldContainTextForDefaultLocaleIfMissingLocalizationForSuppliedLocale() {
- I18n.initialize(TestI18n.class);
- assertThat(TestI18n.testMessage.text(Locale.CHINESE), is("Test Message"));
- }
+ @Test
+ public void shouldContainTextForDefaultLocaleIfMissingLocalizationForSuppliedLocale() {
+ I18n.initialize(TestI18n.class);
+ assertThat(TestI18n.testMessage.text(Locale.CHINESE), is("Test Message"));
+ }
- public static class TestI18n {
+ public static class TestI18n {
- public static I18n testMessage;
- public static I18n testMessage1;
- public static I18n testMessage2;
- public static I18n testMessage3;
- public static Object nonI18n;
- }
+ public static I18n testMessage;
+ public static I18n testMessage1;
+ public static I18n testMessage2;
+ public static I18n testMessage3;
+ public static Object nonI18n;
+ }
- private static class TestI18nDuplicateProperty {
+ private static class TestI18nDuplicateProperty {
- public static I18n testMessage;
- }
+ public static I18n testMessage;
+ }
- public static final class TestI18nFinal {
+ public static final class TestI18nFinal {
- public static I18n testMessage;
- }
+ public static I18n testMessage;
+ }
- public static class TestI18nFinalField {
+ public static class TestI18nFinalField {
- public static final I18n testMessage = null;
- }
+ public static final I18n testMessage = null;
+ }
- public static interface TestI18nInterface {
+ public static interface TestI18nInterface {
- I18n testMessage = null;
- }
+ I18n testMessage = null;
+ }
- private static class TestI18nMissingProperty {
+ private static class TestI18nMissingProperty {
- public static I18n testMessage;
- public static I18n testMessage1;
- }
+ public static I18n testMessage;
+ public static I18n testMessage1;
+ }
- public static class TestI18nNotPublicField {
+ public static class TestI18nNotPublicField {
- static I18n testMessage;
- }
+ static I18n testMessage;
+ }
- public static class TestI18nNotStaticField {
+ public static class TestI18nNotStaticField {
- public I18n testMessage;
- }
+ public I18n testMessage;
+ }
- private static class TestI18nPrivate {
+ private static class TestI18nPrivate {
- public static I18n testMessage;
- }
+ public static I18n testMessage;
+ }
- private static class TestI18nUnusedProperty {
+ private static class TestI18nUnusedProperty {
- public static I18n testMessage;
- }
+ public static I18n testMessage;
+ }
- private static class TestI18nMissingLocalization {
+ private static class TestI18nMissingLocalization {
- public static I18n testMessage;
- }
+ public static I18n testMessage;
+ }
}
Modified: trunk/dna-common/src/test/java/org/jboss/dna/common/jcr/AbstractJcrRepositoryTest.java
===================================================================
--- trunk/dna-common/src/test/java/org/jboss/dna/common/jcr/AbstractJcrRepositoryTest.java 2008-06-10 23:13:20 UTC (rev 261)
+++ trunk/dna-common/src/test/java/org/jboss/dna/common/jcr/AbstractJcrRepositoryTest.java 2008-06-10 23:32:20 UTC (rev 262)
@@ -54,6 +54,7 @@
* whenever all {@link Session sessions} are closed, this class maintains an open session between the time the repository is
* started and stopped. Therefore, unit tests can persist information in one session and see the information in other sessions.
* </p>
+ *
* @author Randall Hauch
*/
public abstract class AbstractJcrRepositoryTest {
@@ -77,7 +78,7 @@
}
@AfterClass
- public static void afterAll() throws Exception {
+ public static void afterAll() {
if (repository != null) {
try {
JackrabbitRepository jackrabbit = (JackrabbitRepository)repository;
@@ -101,6 +102,7 @@
* <p>
* The repository can be started and {@link #shutdownRepository() shutdown} repeatedly during a single test.
* </p>
+ *
* @throws RepositoryException if there is a problem starting the repository
* @throws IOException if there's a problem reading the repository configuration
* @see #shutdownRepository()
@@ -151,10 +153,11 @@
/**
* Get the repository. This will start the repository if necessary.
+ *
* @return repository
* @throws RepositoryException if there is a problem obtaining the repository
* @throws IOException if the repository has not yet been {@link #startRepository() started} and there's a problem reading the
- * repository configuration
+ * repository configuration
*/
public Repository getRepository() throws RepositoryException, IOException {
startRepository();
@@ -163,6 +166,7 @@
/**
* Get credentials that can be used to log into the repository.
+ *
* @return credentials
*/
public Credentials getTestCredentials() {
Modified: trunk/dna-common/src/test/java/org/jboss/dna/common/math/DoubleOperationsTest.java
===================================================================
--- trunk/dna-common/src/test/java/org/jboss/dna/common/math/DoubleOperationsTest.java 2008-06-10 23:13:20 UTC (rev 261)
+++ trunk/dna-common/src/test/java/org/jboss/dna/common/math/DoubleOperationsTest.java 2008-06-10 23:32:20 UTC (rev 262)
@@ -22,19 +22,13 @@
package org.jboss.dna.common.math;
-import static org.junit.Assert.*;
-import org.jboss.dna.common.math.DoubleOperations;
-import org.junit.Before;
+import static org.junit.Assert.assertEquals;
import org.junit.Test;
public class DoubleOperationsTest {
private DoubleOperations ops = new DoubleOperations();
- @Before
- public void beforeEach() throws Exception {
- }
-
@Test
public void shouldReturnProperExponenentInScientificNotation() {
assertEquals(-3, ops.getExponentInScientificNotation(0.0010d));
Modified: trunk/dna-common/src/test/java/org/jboss/dna/common/math/DurationTest.java
===================================================================
--- trunk/dna-common/src/test/java/org/jboss/dna/common/math/DurationTest.java 2008-06-10 23:13:20 UTC (rev 261)
+++ trunk/dna-common/src/test/java/org/jboss/dna/common/math/DurationTest.java 2008-06-10 23:32:20 UTC (rev 262)
@@ -22,9 +22,9 @@
package org.jboss.dna.common.math;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
import java.util.concurrent.TimeUnit;
-import org.jboss.dna.common.math.Duration;
import org.junit.Before;
import org.junit.Test;
@@ -33,7 +33,7 @@
private Duration duration;
@Before
- public void beforeEach() throws Exception {
+ public void beforeEach() {
this.duration = new Duration(0);
}
Modified: trunk/dna-common/src/test/java/org/jboss/dna/common/math/FloatOperationsTest.java
===================================================================
--- trunk/dna-common/src/test/java/org/jboss/dna/common/math/FloatOperationsTest.java 2008-06-10 23:13:20 UTC (rev 261)
+++ trunk/dna-common/src/test/java/org/jboss/dna/common/math/FloatOperationsTest.java 2008-06-10 23:32:20 UTC (rev 262)
@@ -22,19 +22,13 @@
package org.jboss.dna.common.math;
-import static org.junit.Assert.*;
-import org.jboss.dna.common.math.FloatOperations;
-import org.junit.Before;
+import static org.junit.Assert.assertEquals;
import org.junit.Test;
public class FloatOperationsTest {
private FloatOperations ops = new FloatOperations();
- @Before
- public void beforeEach() throws Exception {
- }
-
@Test
public void shouldReturnProperExponenentInScientificNotation() {
assertEquals(-3, ops.getExponentInScientificNotation(0.0010f));
Modified: trunk/dna-common/src/test/java/org/jboss/dna/common/math/IntegerOperationsTest.java
===================================================================
--- trunk/dna-common/src/test/java/org/jboss/dna/common/math/IntegerOperationsTest.java 2008-06-10 23:13:20 UTC (rev 261)
+++ trunk/dna-common/src/test/java/org/jboss/dna/common/math/IntegerOperationsTest.java 2008-06-10 23:32:20 UTC (rev 262)
@@ -22,20 +22,15 @@
package org.jboss.dna.common.math;
-import static org.hamcrest.core.Is.*;
-import static org.junit.Assert.*;
-import org.jboss.dna.common.math.IntegerOperations;
-import org.junit.Before;
+import static org.hamcrest.core.Is.is;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertThat;
import org.junit.Test;
public class IntegerOperationsTest {
private IntegerOperations ops = new IntegerOperations();
- @Before
- public void beforeEach() throws Exception {
- }
-
@Test
public void shouldReturnProperExponenentInScientificNotation() {
assertEquals(0, ops.getExponentInScientificNotation(0));
Modified: trunk/dna-common/src/test/java/org/jboss/dna/common/math/LongOperationsTest.java
===================================================================
--- trunk/dna-common/src/test/java/org/jboss/dna/common/math/LongOperationsTest.java 2008-06-10 23:13:20 UTC (rev 261)
+++ trunk/dna-common/src/test/java/org/jboss/dna/common/math/LongOperationsTest.java 2008-06-10 23:32:20 UTC (rev 262)
@@ -22,20 +22,15 @@
package org.jboss.dna.common.math;
-import static org.hamcrest.core.Is.*;
-import static org.junit.Assert.*;
-import org.jboss.dna.common.math.LongOperations;
-import org.junit.Before;
+import static org.hamcrest.core.Is.is;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertThat;
import org.junit.Test;
public class LongOperationsTest {
private LongOperations ops = new LongOperations();
- @Before
- public void beforeEach() throws Exception {
- }
-
@Test
public void shouldReturnProperExponenentInScientificNotation() {
assertEquals(0l, ops.getExponentInScientificNotation(0l));
Modified: trunk/dna-common/src/test/java/org/jboss/dna/common/monitor/ProgressStatusTest.java
===================================================================
--- trunk/dna-common/src/test/java/org/jboss/dna/common/monitor/ProgressStatusTest.java 2008-06-10 23:13:20 UTC (rev 261)
+++ trunk/dna-common/src/test/java/org/jboss/dna/common/monitor/ProgressStatusTest.java 2008-06-10 23:32:20 UTC (rev 262)
@@ -38,7 +38,7 @@
private String validTaskName;
@Before
- public void beforeEach() throws Exception {
+ public void beforeEach() {
this.validActivityName = "Reading from file X";
this.validTaskName = "Checking for file";
this.status = new ProgressStatus(this.validActivityName, this.validTaskName, 10.0d, false);
@@ -46,7 +46,8 @@
@Test
public void shouldComputePercentageAs100PercentIfWithinPrecision() {
- assertThat(ProgressStatus.computePercentage(100.0d - (ProgressStatus.PERCENT_PRECISION / 2.0d), 100.0d), is(closeTo(100.0d, ProgressStatus.PERCENT_PRECISION)));
+ assertThat(ProgressStatus.computePercentage(100.0d - (ProgressStatus.PERCENT_PRECISION / 2.0d), 100.0d),
+ is(closeTo(100.0d, ProgressStatus.PERCENT_PRECISION)));
}
@Test
Modified: trunk/dna-common/src/test/java/org/jboss/dna/common/naming/MockInitialContextTest.java
===================================================================
--- trunk/dna-common/src/test/java/org/jboss/dna/common/naming/MockInitialContextTest.java 2008-06-10 23:13:20 UTC (rev 261)
+++ trunk/dna-common/src/test/java/org/jboss/dna/common/naming/MockInitialContextTest.java 2008-06-10 23:32:20 UTC (rev 262)
@@ -40,13 +40,13 @@
private Object registeredObject;
@Before
- public void beforeEach() throws Exception {
+ public void beforeEach() {
this.validName = "java:jboss/unit/test/name";
this.registeredObject = "This is the registered object";
}
@After
- public void afterEach() throws Exception {
+ public void afterEach() {
MockInitialContext.tearDown();
}
Modified: trunk/dna-common/src/test/java/org/jboss/dna/common/stats/DetailedStatisticsTest.java
===================================================================
--- trunk/dna-common/src/test/java/org/jboss/dna/common/stats/DetailedStatisticsTest.java 2008-06-10 23:13:20 UTC (rev 261)
+++ trunk/dna-common/src/test/java/org/jboss/dna/common/stats/DetailedStatisticsTest.java 2008-06-10 23:32:20 UTC (rev 262)
@@ -21,13 +21,13 @@
*/
package org.jboss.dna.common.stats;
-import static org.hamcrest.core.Is.*;
-import static org.junit.Assert.*;
+import static org.hamcrest.core.Is.is;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
import org.jboss.dna.common.math.FloatOperations;
import org.jboss.dna.common.math.IntegerOperations;
-import org.jboss.dna.common.stats.DetailedStatistics;
import org.jboss.dna.common.util.Logger;
-import org.junit.Before;
import org.junit.Test;
public class DetailedStatisticsTest {
@@ -36,10 +36,6 @@
private DetailedStatistics<Float> floatStats = new DetailedStatistics<Float>(new FloatOperations());
private Logger logger = Logger.getLogger(DetailedStatisticsTest.class);
- @Before
- public void beforeEach() throws Exception {
- }
-
@Test
public void shouldHaveValidValuesWhenUnused() {
assertThat(this.intStats.getCount(), is(0));
@@ -128,7 +124,10 @@
assertEquals(23.70675d, this.intStats.getStandardDeviation(), 0.0001d);
HistogramTest.writeHistogramToLog(this.logger, this.intStats.getHistogram(), 20, "Histogram of 10 integer values: ");
- HistogramTest.writeHistogramToLog(this.logger, this.intStats.getHistogram().setBucketCount(7), 20, "Histogram of 10 integer values: ");
+ HistogramTest.writeHistogramToLog(this.logger,
+ this.intStats.getHistogram().setBucketCount(7),
+ 20,
+ "Histogram of 10 integer values: ");
}
@Test
@@ -152,7 +151,10 @@
assertEquals(2.370675f, this.floatStats.getStandardDeviation(), 0.0001f);
HistogramTest.writeHistogramToLog(this.logger, this.floatStats.getHistogram(), 20, "Histogram of 10 float values: ");
- HistogramTest.writeHistogramToLog(this.logger, this.floatStats.getHistogram().setBucketCount(7), 20, "Histogram of 10 float values: ");
+ HistogramTest.writeHistogramToLog(this.logger,
+ this.floatStats.getHistogram().setBucketCount(7),
+ 20,
+ "Histogram of 10 float values: ");
}
@Test
Modified: trunk/dna-common/src/test/java/org/jboss/dna/common/stats/HistogramTest.java
===================================================================
--- trunk/dna-common/src/test/java/org/jboss/dna/common/stats/HistogramTest.java 2008-06-10 23:13:20 UTC (rev 261)
+++ trunk/dna-common/src/test/java/org/jboss/dna/common/stats/HistogramTest.java 2008-06-10 23:32:20 UTC (rev 262)
@@ -34,7 +34,6 @@
import org.jboss.dna.common.math.MathOperations;
import org.jboss.dna.common.text.Inflector;
import org.jboss.dna.common.util.Logger;
-import org.junit.Before;
import org.junit.Test;
public class HistogramTest {
@@ -42,11 +41,10 @@
private Logger logger = Logger.getLogger(HistogramTest.class);
private Inflector inflector = Inflector.getInstance();
- @Before
- public void beforeEach() throws Exception {
- }
-
- public static <T extends Number> Histogram<T> createRandomHistogram( T minimum, T maximum, int numberOfValues, MathOperations<T> ops ) {
+ public static <T extends Number> Histogram<T> createRandomHistogram( T minimum,
+ T maximum,
+ int numberOfValues,
+ MathOperations<T> ops ) {
List<T> values = new ArrayList<T>();
Random rng = new Random();
for (int i = 0; i != numberOfValues; ++i) {
@@ -56,7 +54,10 @@
return new Histogram<T>(ops, values);
}
- public static <T extends Number> void writeHistogramToLog( Logger logger, Histogram<T> histogram, int barLength, String description ) {
+ public static <T extends Number> void writeHistogramToLog( Logger logger,
+ Histogram<T> histogram,
+ int barLength,
+ String description ) {
logger.info(MockI18n.passthrough, description != null ? description : "Histogram:");
List<String> barGraph = histogram.getTextGraph(barLength);
for (String line : barGraph) {
@@ -64,13 +65,16 @@
}
}
- public <T extends Number> void assertBucketValueCount( Histogram<T> histogram, long... values ) {
+ public <T extends Number> void assertBucketValueCount( Histogram<T> histogram,
+ long... values ) {
List<Histogram<T>.Bucket> buckets = histogram.getBuckets();
// Check the number of buckets ...
assertEquals("The number of buckets didn't match expected number", values.length, buckets.size());
// Check the number of values ...
for (int i = 0; i != buckets.size(); ++i) {
- assertEquals("The " + inflector.ordinalize(i + 1) + " bucket didn't have the expected number of values", values[i], buckets.get(i).getNumberOfValues());
+ assertEquals("The " + inflector.ordinalize(i + 1) + " bucket didn't have the expected number of values",
+ values[i],
+ buckets.get(i).getNumberOfValues());
}
}
@@ -160,7 +164,8 @@
public void shouldCorrectlyPlace1000RandomFloatValues() {
Histogram<Float> gram = createRandomHistogram(10.0f, 100.0f, 1000, new FloatOperations());
// gram.setDesiredRange(0.0f,100.0f);
- HistogramTest.writeHistogramToLog(this.logger, gram, 0, "Histogram of 1000 random float values in " + gram.getBucketCount() + " buckets: ");
+ HistogramTest.writeHistogramToLog(this.logger, gram, 0, "Histogram of 1000 random float values in "
+ + gram.getBucketCount() + " buckets: ");
}
@Test
@@ -174,7 +179,13 @@
@Test
public void shouldCorrectlyConstructBoundariesWithWindowSmallerThanActualNarrowlyVaryingFloats() {
- List<Float> boundaries = Histogram.getBucketBoundaries(new FloatOperations(), 10.00020f, 10.00030f, 10.00011f, 10.00050f, 12, 3);
+ List<Float> boundaries = Histogram.getBucketBoundaries(new FloatOperations(),
+ 10.00020f,
+ 10.00030f,
+ 10.00011f,
+ 10.00050f,
+ 12,
+ 3);
assertNotNull(boundaries);
assertEquals(13, boundaries.size());
assertEquals(10.00011f, boundaries.get(0), 0.00001f);
Modified: trunk/dna-common/src/test/java/org/jboss/dna/common/stats/SimpleStatisticsTest.java
===================================================================
--- trunk/dna-common/src/test/java/org/jboss/dna/common/stats/SimpleStatisticsTest.java 2008-06-10 23:13:20 UTC (rev 261)
+++ trunk/dna-common/src/test/java/org/jboss/dna/common/stats/SimpleStatisticsTest.java 2008-06-10 23:32:20 UTC (rev 262)
@@ -21,12 +21,12 @@
*/
package org.jboss.dna.common.stats;
-import static org.hamcrest.core.Is.*;
-import static org.junit.Assert.*;
+import static org.hamcrest.core.Is.is;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
import org.jboss.dna.common.math.FloatOperations;
import org.jboss.dna.common.math.IntegerOperations;
-import org.jboss.dna.common.stats.SimpleStatistics;
-import org.junit.Before;
import org.junit.Test;
public class SimpleStatisticsTest {
@@ -36,10 +36,6 @@
// private Logger logger = Logger.getLogger(SimpleStatisticsTest.class);
- @Before
- public void beforeEach() throws Exception {
- }
-
@Test
public void shouldHaveValidValuesWhenUnused() {
assertThat(this.intStats.getCount(), is(0));
Modified: trunk/dna-common/src/test/java/org/jboss/dna/common/stats/StopwatchTest.java
===================================================================
--- trunk/dna-common/src/test/java/org/jboss/dna/common/stats/StopwatchTest.java 2008-06-10 23:13:20 UTC (rev 261)
+++ trunk/dna-common/src/test/java/org/jboss/dna/common/stats/StopwatchTest.java 2008-06-10 23:32:20 UTC (rev 262)
@@ -39,7 +39,7 @@
private long totalPauseTimeInMillis;
@Before
- public void beforeEach() throws Exception {
+ public void beforeEach() {
this.stopwatch = new Stopwatch();
}
Modified: trunk/dna-common/src/test/java/org/jboss/dna/common/text/InflectorTest.java
===================================================================
--- trunk/dna-common/src/test/java/org/jboss/dna/common/text/InflectorTest.java 2008-06-10 23:13:20 UTC (rev 261)
+++ trunk/dna-common/src/test/java/org/jboss/dna/common/text/InflectorTest.java 2008-06-10 23:32:20 UTC (rev 262)
@@ -22,9 +22,7 @@
package org.jboss.dna.common.text;
-import static org.junit.Assert.*;
-import org.jboss.dna.common.text.Inflector;
-import org.junit.After;
+import static org.junit.Assert.assertEquals;
import org.junit.Before;
import org.junit.Test;
@@ -33,15 +31,12 @@
private Inflector inflector;
@Before
- public void beforeEach() throws Exception {
+ public void beforeEach() {
this.inflector = new Inflector();
}
- @After
- public void afterEach() throws Exception {
- }
-
- public void singularToPlural( Object singular, String expectedPlural ) {
+ public void singularToPlural( Object singular,
+ String expectedPlural ) {
// Test pluralizing the singular string
String actualPlural = inflector.pluralize(singular);
assertEquals(expectedPlural, actualPlural);
@@ -57,7 +52,9 @@
assertEquals(expectedPlural, inflector.pluralize(expectedPlural));
}
- public void upperCamelCase( String word, String expectedCamelized, char... delimiterChars ) {
+ public void upperCamelCase( String word,
+ String expectedCamelized,
+ char... delimiterChars ) {
// Test uppercasing the string
String actualCamelized = inflector.camelCase(word, true, delimiterChars);
assertEquals(expectedCamelized, actualCamelized);
@@ -70,7 +67,9 @@
}
}
- public void lowerCamelCase( String word, String expectedCamelized, char... delimiterChars ) {
+ public void lowerCamelCase( String word,
+ String expectedCamelized,
+ char... delimiterChars ) {
// Test lowercasing the string
String actualCamelized = inflector.camelCase(word, false, delimiterChars);
assertEquals(expectedCamelized, actualCamelized);
@@ -83,31 +82,39 @@
}
}
- public void underscore( String word, String expectedUnderscored, char... delimiterChars ) {
+ public void underscore( String word,
+ String expectedUnderscored,
+ char... delimiterChars ) {
// Test underscoring the word
String actualUnderscored = inflector.underscore(word, delimiterChars);
assertEquals(expectedUnderscored, actualUnderscored);
}
- public void capitalize( String words, String expectedValue ) {
+ public void capitalize( String words,
+ String expectedValue ) {
// Test capitalizing the phrase
String actualValue = inflector.capitalize(words);
assertEquals(expectedValue, actualValue);
}
- public void humanize( String word, String expectedValue, String... removableTokens ) {
+ public void humanize( String word,
+ String expectedValue,
+ String... removableTokens ) {
// Test humanizing the word
String actualValue = inflector.humanize(word, removableTokens);
assertEquals(expectedValue, actualValue);
}
- public void titleCase( String word, String expectedValue, String... removableTokens ) {
+ public void titleCase( String word,
+ String expectedValue,
+ String... removableTokens ) {
// Test title casing the word
String actualValue = inflector.titleCase(word, removableTokens);
assertEquals(expectedValue, actualValue);
}
- public void ordinalize( int number, String expectedValue ) {
+ public void ordinalize( int number,
+ String expectedValue ) {
// Test underscoring the camelized word
String actualValue = inflector.ordinalize(number);
assertEquals(expectedValue, actualValue);
Modified: trunk/dna-common/src/test/java/org/jboss/dna/common/util/HashCodeTest.java
===================================================================
--- trunk/dna-common/src/test/java/org/jboss/dna/common/util/HashCodeTest.java 2008-06-10 23:13:20 UTC (rev 261)
+++ trunk/dna-common/src/test/java/org/jboss/dna/common/util/HashCodeTest.java 2008-06-10 23:32:20 UTC (rev 262)
@@ -25,9 +25,6 @@
import static org.hamcrest.core.Is.is;
import static org.hamcrest.core.IsNot.not;
import static org.junit.Assert.assertThat;
-import org.jboss.dna.common.util.HashCode;
-import org.junit.After;
-import org.junit.Before;
import org.junit.Test;
/**
@@ -35,14 +32,6 @@
*/
public class HashCodeTest {
- @Before
- public void beforeEach() throws Exception {
- }
-
- @After
- public void afterEach() throws Exception {
- }
-
@Test
public void shouldComputeHashCodeForOnePrimitive() {
assertThat(HashCode.compute(1), is(not(0)));
Modified: trunk/dna-common/src/test/java/org/jboss/dna/common/util/IoUtilTest.java
===================================================================
--- trunk/dna-common/src/test/java/org/jboss/dna/common/util/IoUtilTest.java 2008-06-10 23:13:20 UTC (rev 261)
+++ trunk/dna-common/src/test/java/org/jboss/dna/common/util/IoUtilTest.java 2008-06-10 23:32:20 UTC (rev 262)
@@ -31,15 +31,10 @@
import java.io.Reader;
import java.io.StringReader;
import java.io.Writer;
-import org.junit.Before;
import org.junit.Test;
public class IoUtilTest {
- @Before
- public void beforeEach() throws Exception {
- }
-
@Test
public void readBytesShouldReturnEmptyByteArrayForNullInputStream() throws Exception {
assertThat(IoUtil.readBytes((InputStream)null), is(new byte[] {}));
@@ -168,7 +163,9 @@
}
@Override
- public int read( char[] cbuf, int off, int len ) throws IOException {
+ public int read( char[] cbuf,
+ int off,
+ int len ) throws IOException {
return reader.read(cbuf, off, len);
}
}
@@ -233,7 +230,9 @@
* {@inheritDoc}
*/
@Override
- public void write( char[] cbuf, int off, int len ) throws IOException {
+ public void write( char[] cbuf,
+ int off,
+ int len ) throws IOException {
writer.write(cbuf, off, len);
}
Modified: trunk/dna-common/src/test/java/org/jboss/dna/common/util/LoggerTest.java
===================================================================
--- trunk/dna-common/src/test/java/org/jboss/dna/common/util/LoggerTest.java 2008-06-10 23:13:20 UTC (rev 261)
+++ trunk/dna-common/src/test/java/org/jboss/dna/common/util/LoggerTest.java 2008-06-10 23:32:20 UTC (rev 262)
@@ -22,7 +22,9 @@
package org.jboss.dna.common.util;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.fail;
import java.io.StringWriter;
import java.util.ArrayList;
import java.util.Enumeration;
@@ -37,7 +39,6 @@
import org.apache.log4j.spi.LoggingEvent;
import org.apache.log4j.spi.ThrowableInformation;
import org.jboss.dna.common.i18n.I18n;
-import org.jboss.dna.common.util.Logger;
import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass;
@@ -80,7 +81,7 @@
private Map<String, List<Appender>> existingAppendersByLoggerName = new HashMap<String, List<Appender>>();
@BeforeClass
- public static void beforeAll() throws Exception {
+ public static void beforeAll() {
// Initialize the I18n static fields ...
I18n.initialize(LoggerTest.class);
}
@@ -427,12 +428,15 @@
/**
* Remove the message that is currently at the front of the log, and verify that it contains the supplied information.
+ *
* @param expectedLevel the level that the next log message should have
* @param expectedMessageExpression the message that the next log message should have, or a regular expression that would
- * match the log message
+ * match the log message
* @param expectedExceptionClass the exception class that was expected, or null if there should not be an exception
*/
- public void removeFirst( Logger.Level expectedLevel, String expectedMessageExpression, Class expectedExceptionClass ) {
+ public void removeFirst( Logger.Level expectedLevel,
+ String expectedMessageExpression,
+ Class expectedExceptionClass ) {
if (!hasEvents()) {
fail("Expected log message but found none: " + expectedLevel + " - " + expectedMessageExpression);
}
@@ -447,23 +451,27 @@
String actual = event.getMessage().toString();
// Treat as a regular expression, which works for both regular expressions and strings ...
if (!actual.matches(expectedMessageExpression)) {
- fail("Log line " + lineNumber + " differed: \nwas :\t" + actual + "\nexpected:\t" + expectedMessageExpression);
+ fail("Log line " + lineNumber + " differed: \nwas :\t" + actual + "\nexpected:\t"
+ + expectedMessageExpression);
}
} // else they are both null
// Check the exception ...
ThrowableInformation throwableInfo = event.getThrowableInformation();
if (expectedExceptionClass == null && throwableInfo != null) {
- fail("Log line " + lineNumber + " had unexpected exception: " + event.getThrowableInformation().getThrowableStrRep());
+ fail("Log line " + lineNumber + " had unexpected exception: "
+ + event.getThrowableInformation().getThrowableStrRep());
} else if (expectedExceptionClass != null && throwableInfo == null) {
- fail("Log line " + lineNumber + " was missing expected exception of type " + expectedExceptionClass.getCanonicalName());
+ fail("Log line " + lineNumber + " was missing expected exception of type "
+ + expectedExceptionClass.getCanonicalName());
} else if (expectedExceptionClass != null && throwableInfo != null) {
Throwable actualException = throwableInfo.getThrowable();
assertSame(expectedExceptionClass, actualException.getClass());
} // else they are both null
}
- public void removeFirst( Logger.Level expectedLevel, String expectedMessageExpression ) {
+ public void removeFirst( Logger.Level expectedLevel,
+ String expectedMessageExpression ) {
removeFirst(expectedLevel, expectedMessageExpression, null);
}
}
Modified: trunk/dna-common/src/test/java/org/jboss/dna/common/util/StringUtilTest.java
===================================================================
--- trunk/dna-common/src/test/java/org/jboss/dna/common/util/StringUtilTest.java 2008-06-10 23:13:20 UTC (rev 261)
+++ trunk/dna-common/src/test/java/org/jboss/dna/common/util/StringUtilTest.java 2008-06-10 23:32:20 UTC (rev 262)
@@ -36,456 +36,451 @@
import java.io.StringReader;
import java.util.ArrayList;
import java.util.List;
-import org.junit.Before;
import org.junit.Test;
public class StringUtilTest {
- @Before
- public void beforeEach() throws Exception {
- }
+ public void compareSeparatedLines( Object... lines ) {
+ ByteArrayOutputStream content = new ByteArrayOutputStream();
+ PrintStream stream = new PrintStream(content);
+ for (Object line : lines) {
+ stream.println(line);
+ }
+ List<String> actualLines = StringUtil.splitLines(content.toString());
+ assertArrayEquals(lines, actualLines.toArray());
+ }
- public void compareSeparatedLines( Object... lines ) {
- ByteArrayOutputStream content = new ByteArrayOutputStream();
- PrintStream stream = new PrintStream(content);
- for (Object line : lines) {
- stream.println(line);
- }
- List<String> actualLines = StringUtil.splitLines(content.toString());
- assertArrayEquals(lines, actualLines.toArray());
- }
+ @Test
+ public void splitLinesShouldWorkCorrectly() {
+ compareSeparatedLines("Line 1", "Line 2", "Line 3", "Line 4");
+ }
- @Test
- public void splitLinesShouldWorkCorrectly() {
- compareSeparatedLines("Line 1", "Line 2", "Line 3", "Line 4");
- }
+ @Test( expected = IllegalArgumentException.class )
+ public void createStringShouldFailIfNoPatternSupplied() {
+ StringUtil.createString(null, (Object[])null);
+ }
- @Test( expected = IllegalArgumentException.class )
- public void createStringShouldFailIfNoPatternSupplied() {
- StringUtil.createString(null, (Object[])null);
- }
+ @Test
+ public void createStringShouldAllowNoParametersSupplied() {
+ assertThat(StringUtil.createString("test", (Object[])null), is("test"));
+ }
- @Test
- public void createStringShouldAllowNoParametersSupplied() {
- assertThat(StringUtil.createString("test", (Object[])null), is("test"));
- }
+ @Test
+ public void createStringShouldCreateStringFromPattern() {
+ String pattern = "This {0} is {1} should {2} not {3} last {4}";
+ assertEquals("This one is two should three not four last five", StringUtil.createString(pattern,
+ "one",
+ "two",
+ "three",
+ "four",
+ "five"));
+ }
- @Test
- public void createStringShouldCreateStringFromPattern() {
- String pattern = "This {0} is {1} should {2} not {3} last {4}";
- assertEquals("This one is two should three not four last five", StringUtil.createString(pattern,
- "one",
- "two",
- "three",
- "four",
- "five"));
- }
+ @Test( expected = IllegalArgumentException.class )
+ public void createStringShouldFailIfTooFewArgumentsSupplied() {
+ String pattern = "This {0} is {1} should {2} not {3} last {4}";
+ try {
+ StringUtil.createString(pattern, "one", "two", "three", "four");
+ } catch (IllegalArgumentException err) {
+ System.err.println(err);
+ throw err;
+ }
+ }
- @Test( expected = IllegalArgumentException.class )
- public void createStringShouldFailIfTooFewArgumentsSupplied() {
- String pattern = "This {0} is {1} should {2} not {3} last {4}";
- try {
- StringUtil.createString(pattern, "one", "two", "three", "four");
- } catch (IllegalArgumentException err) {
- System.err.println(err);
- throw err;
- }
- }
+ @Test( expected = IllegalArgumentException.class )
+ public void createStringShouldFailIfTooManyArgumentsSupplied() {
+ String pattern = "This {0} is {1} should {2} not {3} last {4}";
+ try {
+ StringUtil.createString(pattern, "one", "two", "three", "four", "five", "six");
+ } catch (IllegalArgumentException err) {
+ System.err.println(err);
+ throw err;
+ }
+ }
- @Test( expected = IllegalArgumentException.class )
- public void createStringShouldFailIfTooManyArgumentsSupplied() {
- String pattern = "This {0} is {1} should {2} not {3} last {4}";
- try {
- StringUtil.createString(pattern, "one", "two", "three", "four", "five", "six");
- } catch (IllegalArgumentException err) {
- System.err.println(err);
- throw err;
- }
- }
+ @Test
+ public void createStringExceptionMessageShouldbeGrammaticallyCorrect() {
+ String pattern = "One = {0}";
+ try {
+ StringUtil.createString(pattern);
+ } catch (IllegalArgumentException err) {
+ assertThat(err.getMessage().startsWith("0 parameters supplied, but 1 parameter required"), is(true));
+ }
+ pattern = "One";
+ try {
+ StringUtil.createString(pattern, "one");
+ } catch (IllegalArgumentException err) {
+ assertThat(err.getMessage().startsWith("1 parameter supplied, but 0 parameters required"), is(true));
+ }
+ pattern = "One = {0}, Two = {1}";
+ try {
+ StringUtil.createString(pattern);
+ } catch (IllegalArgumentException err) {
+ assertThat(err.getMessage().startsWith("0 parameters supplied, but 2 parameters required"), is(true));
+ }
+ }
- @Test
- public void createStringExceptionMessageShouldbeGrammaticallyCorrect() {
- String pattern = "One = {0}";
- try {
- StringUtil.createString(pattern);
- } catch (IllegalArgumentException err) {
- assertThat(err.getMessage().startsWith("0 parameters supplied, but 1 parameter required"), is(true));
- }
- pattern = "One";
- try {
- StringUtil.createString(pattern, "one");
- } catch (IllegalArgumentException err) {
- assertThat(err.getMessage().startsWith("1 parameter supplied, but 0 parameters required"), is(true));
- }
- pattern = "One = {0}, Two = {1}";
- try {
- StringUtil.createString(pattern);
- } catch (IllegalArgumentException err) {
- assertThat(err.getMessage().startsWith("0 parameters supplied, but 2 parameters required"), is(true));
- }
- }
+ @Test
+ public void setLengthShouldTruncateStringsThatAreTooLong() {
+ assertEquals("This is the st", StringUtil.setLength("This is the string", 14, ' '));
+ }
- @Test
- public void setLengthShouldTruncateStringsThatAreTooLong() {
- assertEquals("This is the st", StringUtil.setLength("This is the string", 14, ' '));
- }
+ @Test
+ public void setLengthShouldAppendCharacterForStringsThatAreTooShort() {
+ assertEquals("This ", StringUtil.setLength("This", 10, ' '));
+ }
- @Test
- public void setLengthShouldAppendCharacterForStringsThatAreTooShort() {
- assertEquals("This ", StringUtil.setLength("This", 10, ' '));
- }
+ @Test
+ public void setLengthShouldNotRemoveLeadingWhitespace() {
+ assertEquals(" This ", StringUtil.setLength(" This", 10, ' '));
+ assertEquals("\tThis ", StringUtil.setLength("\tThis", 10, ' '));
+ }
- @Test
- public void setLengthShouldNotRemoveLeadingWhitespace() {
- assertEquals(" This ", StringUtil.setLength(" This", 10, ' '));
- assertEquals("\tThis ", StringUtil.setLength("\tThis", 10, ' '));
- }
+ @Test
+ public void setLengthShouldAppendCharacterForEmptyStrings() {
+ assertEquals(" ", StringUtil.setLength("", 10, ' '));
+ }
- @Test
- public void setLengthShouldAppendCharacterForEmptyStrings() {
- assertEquals(" ", StringUtil.setLength("", 10, ' '));
- }
+ @Test
+ public void setLengthShouldAppendCharacterForNullStrings() {
+ assertEquals(" ", StringUtil.setLength(null, 10, ' '));
+ }
- @Test
- public void setLengthShouldAppendCharacterForNullStrings() {
- assertEquals(" ", StringUtil.setLength(null, 10, ' '));
- }
+ @Test
+ public void setLengthShouldReturnStringsThatAreTheDesiredLength() {
+ assertEquals("This is the string", StringUtil.setLength("This is the string", 18, ' '));
+ }
- @Test
- public void setLengthShouldReturnStringsThatAreTheDesiredLength() {
- assertEquals("This is the string", StringUtil.setLength("This is the string", 18, ' '));
- }
+ @Test
+ public void justifyLeftShouldTruncateStringsThatAreTooLong() {
+ assertEquals("This is the st", StringUtil.justifyLeft("This is the string", 14, ' '));
+ }
- @Test
- public void justifyLeftShouldTruncateStringsThatAreTooLong() {
- assertEquals("This is the st", StringUtil.justifyLeft("This is the string", 14, ' '));
- }
+ @Test
+ public void justifyLeftShouldAppendCharacterForStringsThatAreTooShort() {
+ assertEquals("This ", StringUtil.justifyLeft("This", 10, ' '));
+ }
- @Test
- public void justifyLeftShouldAppendCharacterForStringsThatAreTooShort() {
- assertEquals("This ", StringUtil.justifyLeft("This", 10, ' '));
- }
+ @Test
+ public void justifyLeftShouldRemoveLeadingWhitespace() {
+ assertEquals("This ", StringUtil.justifyLeft(" This", 10, ' '));
+ assertEquals("This ", StringUtil.justifyLeft("\tThis", 10, ' '));
+ }
- @Test
- public void justifyLeftShouldRemoveLeadingWhitespace() {
- assertEquals("This ", StringUtil.justifyLeft(" This", 10, ' '));
- assertEquals("This ", StringUtil.justifyLeft("\tThis", 10, ' '));
- }
+ @Test
+ public void justifyLeftShouldAppendCharacterForEmptyStrings() {
+ assertEquals(" ", StringUtil.justifyLeft("", 10, ' '));
+ }
- @Test
- public void justifyLeftShouldAppendCharacterForEmptyStrings() {
- assertEquals(" ", StringUtil.justifyLeft("", 10, ' '));
- }
+ @Test
+ public void justifyLeftShouldAppendCharacterForNullStrings() {
+ assertEquals(" ", StringUtil.justifyLeft(null, 10, ' '));
+ }
- @Test
- public void justifyLeftShouldAppendCharacterForNullStrings() {
- assertEquals(" ", StringUtil.justifyLeft(null, 10, ' '));
- }
+ @Test
+ public void justifyLeftShouldReturnStringsThatAreTheDesiredLength() {
+ assertEquals("This is the string", StringUtil.justifyLeft("This is the string", 18, ' '));
+ }
- @Test
- public void justifyLeftShouldReturnStringsThatAreTheDesiredLength() {
- assertEquals("This is the string", StringUtil.justifyLeft("This is the string", 18, ' '));
- }
+ @Test
+ public void justifyRightShouldTruncateStringsThatAreTooLong() {
+ assertEquals(" is the string", StringUtil.justifyRight("This is the string", 14, ' '));
+ }
- @Test
- public void justifyRightShouldTruncateStringsThatAreTooLong() {
- assertEquals(" is the string", StringUtil.justifyRight("This is the string", 14, ' '));
- }
+ @Test
+ public void justifyRightShouldPrependCharacterForStringsThatAreTooShort() {
+ assertEquals(" This", StringUtil.justifyRight("This", 10, ' '));
+ }
- @Test
- public void justifyRightShouldPrependCharacterForStringsThatAreTooShort() {
- assertEquals(" This", StringUtil.justifyRight("This", 10, ' '));
- }
+ @Test
+ public void justifyRightShouldPrependCharacterForEmptyStrings() {
+ assertEquals(" ", StringUtil.justifyRight("", 10, ' '));
+ }
- @Test
- public void justifyRightShouldPrependCharacterForEmptyStrings() {
- assertEquals(" ", StringUtil.justifyRight("", 10, ' '));
- }
+ @Test
+ public void justifyRightShouldPrependCharacterForNullStrings() {
+ assertEquals(" ", StringUtil.justifyRight(null, 10, ' '));
+ }
- @Test
- public void justifyRightShouldPrependCharacterForNullStrings() {
- assertEquals(" ", StringUtil.justifyRight(null, 10, ' '));
- }
+ @Test
+ public void justifyRightShouldReturnStringsThatAreTheDesiredLength() {
+ assertEquals("This is the string", StringUtil.justifyRight("This is the string", 18, ' '));
+ }
- @Test
- public void justifyRightShouldReturnStringsThatAreTheDesiredLength() {
- assertEquals("This is the string", StringUtil.justifyRight("This is the string", 18, ' '));
- }
+ @Test
+ public void justifyCenterShouldTruncateStringsThatAreTooLong() {
+ assertEquals("This is the st", StringUtil.justifyCenter("This is the string", 14, ' '));
+ }
- @Test
- public void justifyCenterShouldTruncateStringsThatAreTooLong() {
- assertEquals("This is the st", StringUtil.justifyCenter("This is the string", 14, ' '));
- }
+ @Test
+ public void justifyCenterShouldPrependAndAppendSameNumberOfCharacterForStringsThatAreTooShortButOfAnEvenLength() {
+ assertEquals(" This ", StringUtil.justifyCenter("This", 10, ' '));
+ }
- @Test
- public void justifyCenterShouldPrependAndAppendSameNumberOfCharacterForStringsThatAreTooShortButOfAnEvenLength() {
- assertEquals(" This ", StringUtil.justifyCenter("This", 10, ' '));
- }
+ @Test
+ public void justifyCenterShouldPrependOneMoreCharacterThanAppendingForStringsThatAreTooShortButOfAnOddLength() {
+ assertEquals(" Thing ", StringUtil.justifyCenter("Thing", 10, ' '));
+ }
- @Test
- public void justifyCenterShouldPrependOneMoreCharacterThanAppendingForStringsThatAreTooShortButOfAnOddLength() {
- assertEquals(" Thing ", StringUtil.justifyCenter("Thing", 10, ' '));
- }
+ @Test
+ public void justifyCenterShouldPrependCharacterForEmptyStrings() {
+ assertEquals(" ", StringUtil.justifyCenter("", 10, ' '));
+ }
- @Test
- public void justifyCenterShouldPrependCharacterForEmptyStrings() {
- assertEquals(" ", StringUtil.justifyCenter("", 10, ' '));
- }
+ @Test
+ public void justifyCenterShouldPrependCharacterForNullStrings() {
+ assertEquals(" ", StringUtil.justifyCenter(null, 10, ' '));
+ }
- @Test
- public void justifyCenterShouldPrependCharacterForNullStrings() {
- assertEquals(" ", StringUtil.justifyCenter(null, 10, ' '));
- }
+ @Test
+ public void justifyCenterShouldReturnStringsThatAreTheDesiredLength() {
+ assertEquals("This is the string", StringUtil.justifyCenter("This is the string", 18, ' '));
+ }
- @Test
- public void justifyCenterShouldReturnStringsThatAreTheDesiredLength() {
- assertEquals("This is the string", StringUtil.justifyCenter("This is the string", 18, ' '));
- }
+ @Test
+ public void truncateShouldReturnEmptyStringIfNullReferenceIsSupplied() {
+ assertThat(StringUtil.truncate(null, 0), is(""));
+ assertThat(StringUtil.truncate(null, 1), is(""));
+ assertThat(StringUtil.truncate(null, 100), is(""));
+ }
- @Test
- public void truncateShouldReturnEmptyStringIfNullReferenceIsSupplied() {
- assertThat(StringUtil.truncate(null, 0), is(""));
- assertThat(StringUtil.truncate(null, 1), is(""));
- assertThat(StringUtil.truncate(null, 100), is(""));
- }
+ @Test( expected = IllegalArgumentException.class )
+ public void truncateShouldNotAllowNegativeLength() {
+ StringUtil.truncate("some string", -1);
+ }
- @Test( expected = IllegalArgumentException.class )
- public void truncateShouldNotAllowNegativeLength() {
- StringUtil.truncate("some string", -1);
- }
+ @Test
+ public void truncateShouldReturnEmptyStringForMaximumLengthOfZero() {
+ String str = "This is the string with some text";
+ assertThat(StringUtil.truncate(str, 0), is(""));
+ assertThat(StringUtil.truncate("", 0), is(""));
+ assertThat(StringUtil.truncate(str, 0, "123"), is(""));
+ assertThat(StringUtil.truncate("", 0, "123"), is(""));
+ }
- @Test
- public void truncateShouldReturnEmptyStringForMaximumLengthOfZero() {
- String str = "This is the string with some text";
- assertThat(StringUtil.truncate(str, 0), is(""));
- assertThat(StringUtil.truncate("", 0), is(""));
- assertThat(StringUtil.truncate(str, 0, "123"), is(""));
- assertThat(StringUtil.truncate("", 0, "123"), is(""));
- }
+ @Test
+ public void truncateShouldNotTruncateStringShorterThanMaximumLength() {
+ String str = "This is the string with some text";
+ assertThat(StringUtil.truncate(str, str.length() + 2), is(str));
+ assertThat(StringUtil.truncate(str, str.length() + 2, null), is(str));
+ assertThat(StringUtil.truncate(str, str.length() + 2, "really long suffix"), is(str));
+ }
- @Test
- public void truncateShouldNotTruncateStringShorterThanMaximumLength() {
- String str = "This is the string with some text";
- assertThat(StringUtil.truncate(str, str.length() + 2), is(str));
- assertThat(StringUtil.truncate(str, str.length() + 2, null), is(str));
- assertThat(StringUtil.truncate(str, str.length() + 2, "really long suffix"), is(str));
- }
+ @Test
+ public void truncateShouldNotTruncateStringWithLengthEqualToMaximumLength() {
+ String str = "This is the string with some text";
+ assertThat(StringUtil.truncate(str, str.length()), is(str));
+ assertThat(StringUtil.truncate(str, str.length(), null), is(str));
+ assertThat(StringUtil.truncate(str, str.length(), "really long suffix"), is(str));
+ }
- @Test
- public void truncateShouldNotTruncateStringWithLengthEqualToMaximumLength() {
- String str = "This is the string with some text";
- assertThat(StringUtil.truncate(str, str.length()), is(str));
- assertThat(StringUtil.truncate(str, str.length(), null), is(str));
- assertThat(StringUtil.truncate(str, str.length(), "really long suffix"), is(str));
- }
+ @Test
+ public void truncateShouldProperlyTruncateStringWithLengthGreaterThanMaximumLength() {
+ String str = "This is the string";
+ assertThat(StringUtil.truncate(str, str.length() - 1), is("This is the st..."));
+ assertThat(StringUtil.truncate(str, str.length() - 1, null), is("This is the st..."));
+ assertThat(StringUtil.truncate(str, str.length() - 1, "X"), is("This is the striX"));
+ }
- @Test
- public void truncateShouldProperlyTruncateStringWithLengthGreaterThanMaximumLength() {
- String str = "This is the string";
- assertThat(StringUtil.truncate(str, str.length() - 1), is("This is the st..."));
- assertThat(StringUtil.truncate(str, str.length() - 1, null), is("This is the st..."));
- assertThat(StringUtil.truncate(str, str.length() - 1, "X"), is("This is the striX"));
- }
+ @Test
+ public void truncateShouldProperlyTruncateStringWithLengthGreaterThanMaximumLengthAndMaximumLengthLongerThanPrefixLength() {
+ String str = "This is the string";
+ assertThat(StringUtil.truncate(str, 2), is(".."));
+ assertThat(StringUtil.truncate(str, 2, null), is(".."));
+ assertThat(StringUtil.truncate(str, 1, "XX"), is("X"));
+ }
- @Test
- public void truncateShouldProperlyTruncateStringWithLengthGreaterThanMaximumLengthAndMaximumLengthLongerThanPrefixLength() {
- String str = "This is the string";
- assertThat(StringUtil.truncate(str, 2), is(".."));
- assertThat(StringUtil.truncate(str, 2, null), is(".."));
- assertThat(StringUtil.truncate(str, 1, "XX"), is("X"));
- }
+ @Test
+ public void readShouldReturnEmptyStringForNullInputStream() throws Exception {
+ assertThat(StringUtil.read((InputStream)null), is(""));
+ }
- @Test
- public void readShouldReturnEmptyStringForNullInputStream() throws Exception {
- assertThat(StringUtil.read((InputStream)null), is(""));
- }
+ @Test
+ public void readShouldReturnEmptyStringForNullReader() throws Exception {
+ assertThat(StringUtil.read((Reader)null), is(""));
+ }
- @Test
- public void readShouldReturnEmptyStringForNullReader() throws Exception {
- assertThat(StringUtil.read((Reader)null), is(""));
- }
+ @Test
+ public void readShouldReadInputStreamCorrectlyAndShouldCloseStream() throws Exception {
+ // Read content shorter than buffer size ...
+ String content = "This is the way to grandma's house.";
+ InputStream stream = new ByteArrayInputStream(content.getBytes());
+ InputStreamWrapper wrapper = new InputStreamWrapper(stream);
+ assertThat(wrapper.isClosed(), is(false));
+ assertThat(StringUtil.read(wrapper), is(content));
+ assertThat(wrapper.isClosed(), is(true));
- @Test
- public void readShouldReadInputStreamCorrectlyAndShouldCloseStream() throws Exception {
- // Read content shorter than buffer size ...
- String content = "This is the way to grandma's house.";
- InputStream stream = new ByteArrayInputStream(content.getBytes());
- InputStreamWrapper wrapper = new InputStreamWrapper(stream);
- assertThat(wrapper.isClosed(), is(false));
- assertThat(StringUtil.read(wrapper), is(content));
- assertThat(wrapper.isClosed(), is(true));
+ // Read content longer than buffer size ...
+ for (int i = 0; i != 10; ++i) {
+ content += content; // note this doubles each time!
+ }
+ stream = new ByteArrayInputStream(content.getBytes());
+ wrapper = new InputStreamWrapper(stream);
+ assertThat(wrapper.isClosed(), is(false));
+ assertThat(StringUtil.read(wrapper), is(content));
+ assertThat(wrapper.isClosed(), is(true));
+ }
- // Read content longer than buffer size ...
- for (int i = 0; i != 10; ++i) {
- content += content; // note this doubles each time!
- }
- stream = new ByteArrayInputStream(content.getBytes());
- wrapper = new InputStreamWrapper(stream);
- assertThat(wrapper.isClosed(), is(false));
- assertThat(StringUtil.read(wrapper), is(content));
- assertThat(wrapper.isClosed(), is(true));
- }
+ @Test
+ public void readShouldReadReaderCorrectlyAndShouldCloseStream() throws Exception {
+ // Read content shorter than buffer size ...
+ String content = "This is the way to grandma's house.";
+ Reader reader = new StringReader(content);
+ ReaderWrapper wrapper = new ReaderWrapper(reader);
+ assertThat(wrapper.isClosed(), is(false));
+ assertThat(StringUtil.read(wrapper), is(content));
+ assertThat(wrapper.isClosed(), is(true));
- @Test
- public void readShouldReadReaderCorrectlyAndShouldCloseStream() throws Exception {
- // Read content shorter than buffer size ...
- String content = "This is the way to grandma's house.";
- Reader reader = new StringReader(content);
- ReaderWrapper wrapper = new ReaderWrapper(reader);
- assertThat(wrapper.isClosed(), is(false));
- assertThat(StringUtil.read(wrapper), is(content));
- assertThat(wrapper.isClosed(), is(true));
+ // Read content longer than buffer size ...
+ for (int i = 0; i != 10; ++i) {
+ content += content; // note this doubles each time!
+ }
+ reader = new StringReader(content);
+ wrapper = new ReaderWrapper(reader);
+ assertThat(wrapper.isClosed(), is(false));
+ assertThat(StringUtil.read(wrapper), is(content));
+ assertThat(wrapper.isClosed(), is(true));
+ }
- // Read content longer than buffer size ...
- for (int i = 0; i != 10; ++i) {
- content += content; // note this doubles each time!
- }
- reader = new StringReader(content);
- wrapper = new ReaderWrapper(reader);
- assertThat(wrapper.isClosed(), is(false));
- assertThat(StringUtil.read(wrapper), is(content));
- assertThat(wrapper.isClosed(), is(true));
- }
+ @Test
+ public void getStackTraceShouldReturnStackTrace() {
+ String msg = "This is the message for a test exception";
+ Throwable t = new IllegalArgumentException(msg);
+ String trace = StringUtil.getStackTrace(t);
+ assertThat(trace, containsString(msg));
+ assertThat(trace, containsString(this.getClass().getName()));
+ }
- @Test
- public void getStackTraceShouldReturnStackTrace() {
- String msg = "This is the message for a test exception";
- Throwable t = new IllegalArgumentException(msg);
- String trace = StringUtil.getStackTrace(t);
- assertThat(trace, containsString(msg));
- assertThat(trace, containsString(this.getClass().getName()));
- }
+ @Test
+ public void readableStringShouldReturnStringForNull() {
+ assertThat(StringUtil.readableString((Object)null), is("null"));
+ }
- @Test
- public void readableStringShouldReturnStringForNull() {
- assertThat(StringUtil.readableString((Object)null), is("null"));
- }
+ @Test
+ public void readableStringShouldReturnStringFormOfBoolean() {
+ assertThat(StringUtil.readableString(true), is(Boolean.TRUE.toString()));
+ assertThat(StringUtil.readableString(false), is(Boolean.FALSE.toString()));
+ assertThat(StringUtil.readableString(Boolean.TRUE), is(Boolean.TRUE.toString()));
+ assertThat(StringUtil.readableString(Boolean.FALSE), is(Boolean.FALSE.toString()));
+ }
- @Test
- public void readableStringShouldReturnStringFormOfBoolean() {
- assertThat(StringUtil.readableString(true), is(Boolean.TRUE.toString()));
- assertThat(StringUtil.readableString(false), is(Boolean.FALSE.toString()));
- assertThat(StringUtil.readableString(Boolean.TRUE), is(Boolean.TRUE.toString()));
- assertThat(StringUtil.readableString(Boolean.FALSE), is(Boolean.FALSE.toString()));
- }
+ @Test
+ public void readableStringShouldReturnStringFormOfNumber() {
+ assertThat(StringUtil.readableString(1), is("1"));
+ assertThat(StringUtil.readableString(-513), is("-513"));
+ assertThat(StringUtil.readableString(-513.3f), is("-513.3"));
+ assertThat(StringUtil.readableString(-513.3d), is("-513.3"));
+ assertThat(StringUtil.readableString(new Short((short)1)), is("1"));
+ assertThat(StringUtil.readableString(new Integer(-513)), is("-513"));
+ assertThat(StringUtil.readableString(new Float(-513.3f)), is("-513.3"));
+ assertThat(StringUtil.readableString(new Double(-513.3d)), is("-513.3"));
+ }
- @Test
- public void readableStringShouldReturnStringFormOfNumber() {
- assertThat(StringUtil.readableString(1), is("1"));
- assertThat(StringUtil.readableString(-513), is("-513"));
- assertThat(StringUtil.readableString(-513.3f), is("-513.3"));
- assertThat(StringUtil.readableString(-513.3d), is("-513.3"));
- assertThat(StringUtil.readableString(new Short((short)1)), is("1"));
- assertThat(StringUtil.readableString(new Integer(-513)), is("-513"));
- assertThat(StringUtil.readableString(new Float(-513.3f)), is("-513.3"));
- assertThat(StringUtil.readableString(new Double(-513.3d)), is("-513.3"));
- }
+ @Test
+ public void readableStringShouldWrapObjectArrayWithSquareBraces() {
+ assertThat(StringUtil.readableString(new int[] {}), is("[]"));
+ assertThat(StringUtil.readableString(new int[] {1}), is("[ 1 ]"));
+ assertThat(StringUtil.readableString(new int[] {1, 2, 3, 4}), is("[ 1, 2, 3, 4 ]"));
+ assertThat(StringUtil.readableString(new short[] {1, 2, 3, 4}), is("[ 1, 2, 3, 4 ]"));
+ assertThat(StringUtil.readableString(new boolean[] {true, false}), is("[ true, false ]"));
+ assertThat(StringUtil.readableString(new long[] {1, 2, 3, 4}), is("[ 1, 2, 3, 4 ]"));
+ assertThat(StringUtil.readableString(new float[] {51.0f, 52.0f, 53.0f, 54.0f}), is("[ 51.0, 52.0, 53.0, 54.0 ]"));
+ assertThat(StringUtil.readableString(new double[] {51.0d, 52.0d, 53.0d, 54.0d}), is("[ 51.0, 52.0, 53.0, 54.0 ]"));
+ }
- @Test
- public void readableStringShouldWrapObjectArrayWithSquareBraces() {
- assertThat(StringUtil.readableString(new int[] {}), is("[]"));
- assertThat(StringUtil.readableString(new int[] {1}), is("[ 1 ]"));
- assertThat(StringUtil.readableString(new int[] {1, 2, 3, 4}), is("[ 1, 2, 3, 4 ]"));
- assertThat(StringUtil.readableString(new short[] {1, 2, 3, 4}), is("[ 1, 2, 3, 4 ]"));
- assertThat(StringUtil.readableString(new boolean[] {true, false}), is("[ true, false ]"));
- assertThat(StringUtil.readableString(new long[] {1, 2, 3, 4}), is("[ 1, 2, 3, 4 ]"));
- assertThat(StringUtil.readableString(new float[] {51.0f, 52.0f, 53.0f, 54.0f}), is("[ 51.0, 52.0, 53.0, 54.0 ]"));
- assertThat(StringUtil.readableString(new double[] {51.0d, 52.0d, 53.0d, 54.0d}), is("[ 51.0, 52.0, 53.0, 54.0 ]"));
- }
+ @Test
+ public void readableStringShouldHandleEmptyArraysOfArrays() {
+ assertThat(StringUtil.readableString(new int[][] {}), is("[[]]"));
+ assertThat(StringUtil.readableString(new boolean[][][][][][] {}), is("[[[[[[]]]]]]"));
+ assertThat(StringUtil.readableString(new ArrayList<List<List<?>>>()), is("[]"));
+ }
- @Test
- public void readableStringShouldHandleEmptyArraysOfArrays() {
- assertThat(StringUtil.readableString(new int[][] {}), is("[[]]"));
- assertThat(StringUtil.readableString(new boolean[][][][][][] {}), is("[[[[[[]]]]]]"));
- assertThat(StringUtil.readableString(new ArrayList<List<List<?>>>()), is("[]"));
- }
+ @Test
+ public void readableStringShouldHandleNestedObjects() {
+ assertThat(StringUtil.readableString(new int[][] {new int[] {1, 2}, new int[] {3, 4}}), is("[ [ 1, 2 ], [ 3, 4 ] ]"));
+ List<String> list1 = new ArrayList<String>();
+ list1.add("a1");
+ list1.add("a2");
+ List<String> list2 = new ArrayList<String>();
+ list2.add("b1");
+ list2.add("b2");
+ List<List<String>> list3 = new ArrayList<List<String>>();
+ list3.add(list1);
+ list3.add(list2);
+ assertThat(StringUtil.readableString(list3), is("[ [ \"a1\", \"a2\" ], [ \"b1\", \"b2\" ] ]"));
+ }
- @Test
- public void readableStringShouldHandleNestedObjects() {
- assertThat(StringUtil.readableString(new int[][] {new int[] {1, 2}, new int[] {3, 4}}), is("[ [ 1, 2 ], [ 3, 4 ] ]"));
- List<String> list1 = new ArrayList<String>();
- list1.add("a1");
- list1.add("a2");
- List<String> list2 = new ArrayList<String>();
- list2.add("b1");
- list2.add("b2");
- List<List<String>> list3 = new ArrayList<List<String>>();
- list3.add(list1);
- list3.add(list2);
- assertThat(StringUtil.readableString(list3), is("[ [ \"a1\", \"a2\" ], [ \"b1\", \"b2\" ] ]"));
- }
+ @Test( expected = IllegalArgumentException.class )
+ public void normalizeShouldFailIfTextNull() {
+ StringUtil.normalize(null);
+ }
- @Test( expected = IllegalArgumentException.class )
- public void normalizeShouldFailIfTextNull() {
- StringUtil.normalize(null);
- }
+ @Test
+ public void normalizeShouldRemoveLeadingTrailingWhitespace() {
+ assertThat(StringUtil.normalize(" \t\n test this \t"), is("test this"));
+ }
- @Test
- public void normalizeShouldRemoveLeadingTrailingWhitespace() {
- assertThat(StringUtil.normalize(" \t\n test this \t"), is("test this"));
- }
+ @Test
+ public void normalizeShouldReduceInternalWhitespace() {
+ assertThat(StringUtil.normalize("test \t\n\r this"), is("test this"));
+ }
- @Test
- public void normalizeShouldReduceInternalWhitespace() {
- assertThat(StringUtil.normalize("test \t\n\r this"), is("test this"));
- }
+ @Test
+ public void normalizeShouldReturnEqualStringIfNothingToNormalize() {
+ assertThat(StringUtil.normalize("test this"), is("test this"));
+ }
- @Test
- public void normalizeShouldReturnEqualStringIfNothingToNormalize() {
- assertThat(StringUtil.normalize("test this"), is("test this"));
- }
+ protected class InputStreamWrapper extends InputStream {
- protected class InputStreamWrapper extends InputStream {
+ private boolean closed = false;
+ private final InputStream stream;
- private boolean closed = false;
- private final InputStream stream;
+ protected InputStreamWrapper( InputStream stream ) {
+ this.stream = stream;
+ }
- protected InputStreamWrapper( InputStream stream ) {
- this.stream = stream;
- }
+ public boolean isClosed() {
+ return closed;
+ }
- public boolean isClosed() {
- return closed;
- }
+ @Override
+ public int read() throws IOException {
+ return stream.read();
+ }
- @Override
- public int read() throws IOException {
- return stream.read();
- }
+ @Override
+ public void close() throws IOException {
+ stream.close();
+ this.closed = true;
+ }
- @Override
- public void close() throws IOException {
- stream.close();
- this.closed = true;
- }
+ }
- }
+ protected class ReaderWrapper extends Reader {
- protected class ReaderWrapper extends Reader {
+ private boolean closed = false;
+ private final Reader reader;
- private boolean closed = false;
- private final Reader reader;
+ protected ReaderWrapper( Reader reader ) {
+ this.reader = reader;
+ }
- protected ReaderWrapper( Reader reader ) {
- this.reader = reader;
- }
+ public boolean isClosed() {
+ return closed;
+ }
- public boolean isClosed() {
- return closed;
- }
+ @Override
+ public void close() throws IOException {
+ reader.close();
+ this.closed = true;
+ }
- @Override
- public void close() throws IOException {
- reader.close();
- this.closed = true;
- }
+ @Override
+ public int read( char[] cbuf,
+ int off,
+ int len ) throws IOException {
+ return reader.read(cbuf, off, len);
+ }
+ }
- @Override
- public int read( char[] cbuf,
- int off,
- int len ) throws IOException {
- return reader.read(cbuf, off, len);
- }
- }
-
}
Modified: trunk/dna-integration-tests/src/test/java/org/jboss/dna/tests/integration/jackrabbit/JackrabbitBasicFunctionTest.java
===================================================================
--- trunk/dna-integration-tests/src/test/java/org/jboss/dna/tests/integration/jackrabbit/JackrabbitBasicFunctionTest.java 2008-06-10 23:13:20 UTC (rev 261)
+++ trunk/dna-integration-tests/src/test/java/org/jboss/dna/tests/integration/jackrabbit/JackrabbitBasicFunctionTest.java 2008-06-10 23:32:20 UTC (rev 262)
@@ -63,7 +63,7 @@
}
@After
- public void afterEach() throws Exception {
+ public void afterEach() {
// Clean up the test data ...
FileUtil.delete(JACKRABBIT_DATA_PATH);
}
@@ -151,7 +151,8 @@
// Retrieve content ...
Node node = root.getNode("hello/world");
this.logger.info(MockI18n.passthrough, "Node 'hello/world' has path: " + node.getPath());
- this.logger.info(MockI18n.passthrough, "Node 'hello/world' has 'message' property: " + node.getProperty("message").getString());
+ this.logger.info(MockI18n.passthrough, "Node 'hello/world' has 'message' property: "
+ + node.getProperty("message").getString());
} finally {
if (session != null) session.logout();
}
@@ -164,7 +165,8 @@
// Retrieve content
Node node = root.getNode("hello/world");
this.logger.info(MockI18n.passthrough, "Node 'hello/world' has path: " + node.getPath());
- this.logger.info(MockI18n.passthrough, "Node 'hello/world' has 'message' property: " + node.getProperty("message").getString());
+ this.logger.info(MockI18n.passthrough, "Node 'hello/world' has 'message' property: "
+ + node.getProperty("message").getString());
// Remove content
this.logger.info(MockI18n.passthrough, "Node 'hello' is being removed");
Modified: trunk/dna-integration-tests/src/test/java/org/jboss/dna/tests/integration/jackrabbit/JackrabbitDerbyStressTest.java
===================================================================
--- trunk/dna-integration-tests/src/test/java/org/jboss/dna/tests/integration/jackrabbit/JackrabbitDerbyStressTest.java 2008-06-10 23:13:20 UTC (rev 261)
+++ trunk/dna-integration-tests/src/test/java/org/jboss/dna/tests/integration/jackrabbit/JackrabbitDerbyStressTest.java 2008-06-10 23:32:20 UTC (rev 262)
@@ -74,7 +74,7 @@
}
@After
- public void afterEach() throws Exception {
+ public void afterEach() {
try {
if (session != null) session.logout();
} finally {
@@ -94,7 +94,10 @@
stopwatch.stop();
}
rootNode.save();
- HistogramTest.writeHistogramToLog(logger, stopwatch.getHistogram(3).setBucketCount(50), 80, "create 100 nodes with no children and no properties");
+ HistogramTest.writeHistogramToLog(logger,
+ stopwatch.getHistogram(3).setBucketCount(50),
+ 80,
+ "create 100 nodes with no children and no properties");
this.logger.info(MockI18n.passthrough, stopwatch.toString());
}
@@ -108,7 +111,10 @@
stopwatch.stop();
}
rootNode.save();
- HistogramTest.writeHistogramToLog(logger, stopwatch.getHistogram(1).setBucketCount(50), 80, "create 1000 nodes with no children and no properties");
+ HistogramTest.writeHistogramToLog(logger,
+ stopwatch.getHistogram(1).setBucketCount(50),
+ 80,
+ "create 1000 nodes with no children and no properties");
this.logger.info(MockI18n.passthrough, stopwatch.toString());
}
@@ -122,7 +128,10 @@
stopwatch.stop();
}
rootNode.save();
- HistogramTest.writeHistogramToLog(logger, stopwatch.getHistogram(1).setBucketCount(50), 80, "create 5000 nodes with no children and no properties");
+ HistogramTest.writeHistogramToLog(logger,
+ stopwatch.getHistogram(1).setBucketCount(50),
+ 80,
+ "create 5000 nodes with no children and no properties");
this.logger.info(MockI18n.passthrough, stopwatch.toString());
}
@@ -136,7 +145,10 @@
stopwatch.stop();
}
rootNode.save();
- HistogramTest.writeHistogramToLog(logger, stopwatch.getHistogram(1).setBucketCount(50), 80, "create 10000 nodes with no children and no properties");
+ HistogramTest.writeHistogramToLog(logger,
+ stopwatch.getHistogram(1).setBucketCount(50),
+ 80,
+ "create 10000 nodes with no children and no properties");
this.logger.info(MockI18n.passthrough, stopwatch.toString());
}
@@ -152,7 +164,10 @@
stopwatch.stop();
}
rootNode.save();
- HistogramTest.writeHistogramToLog(logger, stopwatch.getHistogram(3).setBucketCount(50), 80, "create 100 nodes with no children and several properties");
+ HistogramTest.writeHistogramToLog(logger,
+ stopwatch.getHistogram(3).setBucketCount(50),
+ 80,
+ "create 100 nodes with no children and several properties");
this.logger.info(MockI18n.passthrough, stopwatch.toString());
}
//
Modified: trunk/dna-integration-tests/src/test/java/org/jboss/dna/tests/integration/jackrabbit/JackrabbitInMemoryTest.java
===================================================================
--- trunk/dna-integration-tests/src/test/java/org/jboss/dna/tests/integration/jackrabbit/JackrabbitInMemoryTest.java 2008-06-10 23:13:20 UTC (rev 261)
+++ trunk/dna-integration-tests/src/test/java/org/jboss/dna/tests/integration/jackrabbit/JackrabbitInMemoryTest.java 2008-06-10 23:32:20 UTC (rev 262)
@@ -73,7 +73,7 @@
}
@After
- public void afterEach() throws Exception {
+ public void afterEach() {
try {
if (session != null) session.logout();
} finally {
@@ -85,13 +85,16 @@
/**
* Create an evenly distributed tree of nodes, starting with the supplied parent.
+ *
* @param parentNode the parent node of the tree; may not be null
* @param numberOfChildNodes the number of child nodes to create under the parent
* @param levelsToCreate the total number of levels in the tree to create
* @return the total number of child nodes created
* @throws Exception
*/
- public int createNodes( Node parentNode, int numberOfChildNodes, int levelsToCreate ) throws Exception {
+ public int createNodes( Node parentNode,
+ int numberOfChildNodes,
+ int levelsToCreate ) throws Exception {
int numberCreated = 0;
for (int i = 0; i < numberOfChildNodes; ++i) {
nodeStopwatch.start();
@@ -118,7 +121,10 @@
nodeStopwatch.stop();
}
rootNode.save();
- HistogramTest.writeHistogramToLog(logger, nodeStopwatch.getHistogram(3).setBucketCount(50), 80, "create 100 nodes with no children and no properties");
+ HistogramTest.writeHistogramToLog(logger,
+ nodeStopwatch.getHistogram(3).setBucketCount(50),
+ 80,
+ "create 100 nodes with no children and no properties");
this.logger.info(MockI18n.passthrough, nodeStopwatch.toString());
}
@@ -131,8 +137,12 @@
rootNode.save();
saveStopwatch.stop();
- HistogramTest.writeHistogramToLog(logger, nodeStopwatch.getHistogram(3).setBucketCount(50), 80, "create tree of " + numNodes + " nodes (2 deep, 10 children at every node)");
- HistogramTest.writeHistogramToLog(logger, saveStopwatch.getHistogram(3).setBucketCount(50), 80, "1 save of 2x10 tree of " + numNodes + " nodes");
+ HistogramTest.writeHistogramToLog(logger,
+ nodeStopwatch.getHistogram(3).setBucketCount(50),
+ 80,
+ "create tree of " + numNodes + " nodes (2 deep, 10 children at every node)");
+ HistogramTest.writeHistogramToLog(logger, saveStopwatch.getHistogram(3).setBucketCount(50), 80, "1 save of 2x10 tree of "
+ + numNodes + " nodes");
this.logger.info(MockI18n.passthrough, "Node operation times: " + nodeStopwatch.toString());
this.logger.info(MockI18n.passthrough, "Save times: " + saveStopwatch.toString());
}
Modified: trunk/dna-maven-classloader/src/test/java/org/jboss/dna/maven/MavenIdTest.java
===================================================================
--- trunk/dna-maven-classloader/src/test/java/org/jboss/dna/maven/MavenIdTest.java 2008-06-10 23:13:20 UTC (rev 261)
+++ trunk/dna-maven-classloader/src/test/java/org/jboss/dna/maven/MavenIdTest.java 2008-06-10 23:32:20 UTC (rev 262)
@@ -21,8 +21,8 @@
*/
package org.jboss.dna.maven;
+import static org.hamcrest.core.Is.is;
import static org.hamcrest.core.IsNull.notNullValue;
-import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertThat;
import org.junit.Before;
@@ -43,15 +43,17 @@
private MavenId validIdWithNullClassifier;
@Before
- public void beforeEach() throws Exception {
+ public void beforeEach() {
this.validGroupId = "org.jboss.dna";
this.validArtifactId = "jboss-dna-core";
this.validClassifier = "jdk1.4";
this.validVersion = "1.0";
this.validId = new MavenId(this.validGroupId, this.validArtifactId, this.validVersion, this.validClassifier);
this.validIdWithNullClassifier = new MavenId(this.validGroupId, this.validArtifactId, this.validVersion, null);
- this.validArtifactIdToString = this.validGroupId + ":" + this.validArtifactId + ":" + this.validVersion + ":" + this.validClassifier;
- this.validArtifactIdWithNullClassifierToString = this.validGroupId + ":" + this.validArtifactId + ":" + this.validVersion + ":";
+ this.validArtifactIdToString = this.validGroupId + ":" + this.validArtifactId + ":" + this.validVersion + ":"
+ + this.validClassifier;
+ this.validArtifactIdWithNullClassifierToString = this.validGroupId + ":" + this.validArtifactId + ":" + this.validVersion
+ + ":";
}
@Test
@@ -149,18 +151,27 @@
assertThat(MavenId.createClasspath(""), is(new MavenId[] {}));
assertThat(MavenId.createClasspath((String)null), is(new MavenId[] {}));
- assertThat(MavenId.createClasspath("org.jboss.dna:dna-maven"), is(new MavenId[] {new MavenId("org.jboss.dna", "dna-maven")}));
- assertThat(MavenId.createClasspath(" org.jboss.dna:dna-maven "), is(new MavenId[] {new MavenId("org.jboss.dna", "dna-maven")}));
- assertThat(MavenId.createClasspath(" org.jboss.dna : dna-maven "), is(new MavenId[] {new MavenId("org.jboss.dna", "dna-maven")}));
- assertThat(MavenId.createClasspath("org.jboss.dna:dna-maven:"), is(new MavenId[] {new MavenId("org.jboss.dna", "dna-maven")}));
- assertThat(MavenId.createClasspath("org.jboss.dna:dna-maven::jdk1.4"), is(new MavenId[] {new MavenId("org.jboss.dna", "dna-maven", null, "jdk1.4")}));
- assertThat(MavenId.createClasspath("org.jboss.dna:dna-maven:1.0:jdk1.4"), is(new MavenId[] {new MavenId("org.jboss.dna", "dna-maven", "1.0", "jdk1.4")}));
- assertThat(MavenId.createClasspath("org.jboss.dna:dna-maven:1.0:jdk1.4,net.jcip:jcip-annotations:1.0"), is(new MavenId[] {new MavenId("org.jboss.dna", "dna-maven", "1.0", "jdk1.4"),
- new MavenId("net.jcip", "jcip-annotations", "1.0")}));
- assertThat(MavenId.createClasspath("org.jboss.dna:dna-maven:1.0:jdk1.4,,net.jcip:jcip-annotations:1.0,"), is(new MavenId[] {new MavenId("org.jboss.dna", "dna-maven", "1.0", "jdk1.4"),
- new MavenId("net.jcip", "jcip-annotations", "1.0")}));
- assertThat(MavenId.createClasspath(",,org.jboss.dna:dna-maven:1.0:jdk1.4,, net.jcip: jcip-annotations:1.0 ,,"), is(new MavenId[] {new MavenId("org.jboss.dna", "dna-maven", "1.0", "jdk1.4"),
- new MavenId("net.jcip", "jcip-annotations", "1.0")}));
+ assertThat(MavenId.createClasspath("org.jboss.dna:dna-maven"),
+ is(new MavenId[] {new MavenId("org.jboss.dna", "dna-maven")}));
+ assertThat(MavenId.createClasspath(" org.jboss.dna:dna-maven "), is(new MavenId[] {new MavenId("org.jboss.dna",
+ "dna-maven")}));
+ assertThat(MavenId.createClasspath(" org.jboss.dna : dna-maven "), is(new MavenId[] {new MavenId("org.jboss.dna",
+ "dna-maven")}));
+ assertThat(MavenId.createClasspath("org.jboss.dna:dna-maven:"), is(new MavenId[] {new MavenId("org.jboss.dna",
+ "dna-maven")}));
+ assertThat(MavenId.createClasspath("org.jboss.dna:dna-maven::jdk1.4"), is(new MavenId[] {new MavenId("org.jboss.dna",
+ "dna-maven", null,
+ "jdk1.4")}));
+ assertThat(MavenId.createClasspath("org.jboss.dna:dna-maven:1.0:jdk1.4"),
+ is(new MavenId[] {new MavenId("org.jboss.dna", "dna-maven", "1.0", "jdk1.4")}));
+ assertThat(MavenId.createClasspath("org.jboss.dna:dna-maven:1.0:jdk1.4,net.jcip:jcip-annotations:1.0"), is(new MavenId[] {
+ new MavenId("org.jboss.dna", "dna-maven", "1.0", "jdk1.4"), new MavenId("net.jcip", "jcip-annotations", "1.0")}));
+ assertThat(MavenId.createClasspath("org.jboss.dna:dna-maven:1.0:jdk1.4,,net.jcip:jcip-annotations:1.0,"),
+ is(new MavenId[] {new MavenId("org.jboss.dna", "dna-maven", "1.0", "jdk1.4"),
+ new MavenId("net.jcip", "jcip-annotations", "1.0")}));
+ assertThat(MavenId.createClasspath(",,org.jboss.dna:dna-maven:1.0:jdk1.4,, net.jcip: jcip-annotations:1.0 ,,"),
+ is(new MavenId[] {new MavenId("org.jboss.dna", "dna-maven", "1.0", "jdk1.4"),
+ new MavenId("net.jcip", "jcip-annotations", "1.0")}));
}
@Test
@@ -169,12 +180,15 @@
assertThat(MavenId.createClasspath((String[])null), is(new MavenId[] {}));
assertThat(MavenId.createClasspath(new String[] {null, null}), is(new MavenId[] {}));
- assertThat(MavenId.createClasspath("org.jboss.dna:dna-maven:1.0:jdk1.4", "net.jcip:jcip-annotations:1.0"), is(new MavenId[] {new MavenId("org.jboss.dna", "dna-maven", "1.0", "jdk1.4"),
- new MavenId("net.jcip", "jcip-annotations", "1.0")}));
+ assertThat(MavenId.createClasspath("org.jboss.dna:dna-maven:1.0:jdk1.4", "net.jcip:jcip-annotations:1.0"),
+ is(new MavenId[] {new MavenId("org.jboss.dna", "dna-maven", "1.0", "jdk1.4"),
+ new MavenId("net.jcip", "jcip-annotations", "1.0")}));
assertThat(MavenId.createClasspath("org.jboss.dna:dna-maven:1.0:jdk1.4", "", "net.jcip:jcip-annotations:1.0", ""),
- is(new MavenId[] {new MavenId("org.jboss.dna", "dna-maven", "1.0", "jdk1.4"), new MavenId("net.jcip", "jcip-annotations", "1.0")}));
- assertThat(MavenId.createClasspath(" org.jboss.dna:dna-maven:1.0:jdk1.4", " net.jcip: jcip-annotations:1.0"), is(new MavenId[] {new MavenId("org.jboss.dna", "dna-maven", "1.0", "jdk1.4"),
- new MavenId("net.jcip", "jcip-annotations", "1.0")}));
+ is(new MavenId[] {new MavenId("org.jboss.dna", "dna-maven", "1.0", "jdk1.4"),
+ new MavenId("net.jcip", "jcip-annotations", "1.0")}));
+ assertThat(MavenId.createClasspath(" org.jboss.dna:dna-maven:1.0:jdk1.4", " net.jcip: jcip-annotations:1.0"),
+ is(new MavenId[] {new MavenId("org.jboss.dna", "dna-maven", "1.0", "jdk1.4"),
+ new MavenId("net.jcip", "jcip-annotations", "1.0")}));
}
@Test
Modified: trunk/dna-repository/src/main/java/org/jboss/dna/repository/util/SimpleSessionFactory.java
===================================================================
--- trunk/dna-repository/src/main/java/org/jboss/dna/repository/util/SimpleSessionFactory.java 2008-06-10 23:13:20 UTC (rev 261)
+++ trunk/dna-repository/src/main/java/org/jboss/dna/repository/util/SimpleSessionFactory.java 2008-06-10 23:32:20 UTC (rev 262)
@@ -51,6 +51,7 @@
* {@link #registerCredentials(String, Credentials) register} credentials for the appropriate repository/workspace name. For
* security reasons, it is not possible to retrieve the Credentials once registered with this factory.
* </p>
+ *
* @author Randall Hauch
*/
public class SimpleSessionFactory extends AbstractSessionFactory {
@@ -67,6 +68,7 @@
/**
* Create an instance of the factory by supplying the characters that may be used to delimit the workspace name from the
* repository name.
+ *
* @param workspaceDelimiters the delimiters, or null/empty if the default delimiter of '/' should be used.
*/
public SimpleSessionFactory( char... workspaceDelimiters ) {
@@ -77,7 +79,8 @@
* {@inheritDoc}
*/
@Override
- protected void doRegisterRepository( String name, Repository repository ) throws SystemFailureException {
+ protected void doRegisterRepository( String name,
+ Repository repository ) {
this.repositories.put(name, repository);
}
Modified: trunk/dna-repository/src/test/java/org/jboss/dna/repository/federation/FederatedRepositoryConnectionTest.java
===================================================================
--- trunk/dna-repository/src/test/java/org/jboss/dna/repository/federation/FederatedRepositoryConnectionTest.java 2008-06-10 23:13:20 UTC (rev 261)
+++ trunk/dna-repository/src/test/java/org/jboss/dna/repository/federation/FederatedRepositoryConnectionTest.java 2008-06-10 23:32:20 UTC (rev 262)
@@ -58,7 +58,7 @@
private ServiceAdministrator repositoryAdmin;
@Before
- public void beforeEach() throws Exception {
+ public void beforeEach() {
MockitoAnnotations.initMocks(this);
sourceName = "Source X";
stub(source.getName()).toReturn(sourceName);
Modified: trunk/dna-repository/src/test/java/org/jboss/dna/repository/federation/FederatedRepositoryTest.java
===================================================================
--- trunk/dna-repository/src/test/java/org/jboss/dna/repository/federation/FederatedRepositoryTest.java 2008-06-10 23:13:20 UTC (rev 261)
+++ trunk/dna-repository/src/test/java/org/jboss/dna/repository/federation/FederatedRepositoryTest.java 2008-06-10 23:32:20 UTC (rev 262)
@@ -60,7 +60,7 @@
// private RepositoryConnectionPool connectionPool;
@Before
- public void beforeEach() throws Exception {
+ public void beforeEach() {
MockitoAnnotations.initMocks(this);
name = "Test repository";
repository = new FederatedRepository(service, name);
Modified: trunk/dna-repository/src/test/java/org/jboss/dna/repository/observation/NodeChangeTest.java
===================================================================
--- trunk/dna-repository/src/test/java/org/jboss/dna/repository/observation/NodeChangeTest.java 2008-06-10 23:13:20 UTC (rev 261)
+++ trunk/dna-repository/src/test/java/org/jboss/dna/repository/observation/NodeChangeTest.java 2008-06-10 23:32:20 UTC (rev 262)
@@ -24,7 +24,6 @@
import java.util.HashSet;
import java.util.Set;
import javax.jcr.observation.Event;
-import org.jboss.dna.repository.observation.NodeChange;
import org.junit.Before;
import org.junit.Test;
@@ -41,7 +40,7 @@
private NodeChange nodeChange;
@Before
- public void beforeEach() throws Exception {
+ public void beforeEach() {
validRepositoryWorkspaceName = "repositoryX";
validAbsolutePath = "/a/b/c/d";
validEventTypes = Event.NODE_ADDED | Event.PROPERTY_ADDED | Event.PROPERTY_CHANGED | Event.PROPERTY_REMOVED;
@@ -50,7 +49,8 @@
validModifiedProperties.add("jcr:name");
validModifiedProperties.add("jcr:title");
validRemovedProperties.add("jcr:mime");
- nodeChange = new NodeChange(validRepositoryWorkspaceName, validAbsolutePath, validEventTypes, validModifiedProperties, validRemovedProperties);
+ nodeChange = new NodeChange(validRepositoryWorkspaceName, validAbsolutePath, validEventTypes, validModifiedProperties,
+ validRemovedProperties);
}
@Test( expected = UnsupportedOperationException.class )
Modified: trunk/dna-repository/src/test/java/org/jboss/dna/repository/rules/RuleServiceTest.java
===================================================================
--- trunk/dna-repository/src/test/java/org/jboss/dna/repository/rules/RuleServiceTest.java 2008-06-10 23:13:20 UTC (rev 261)
+++ trunk/dna-repository/src/test/java/org/jboss/dna/repository/rules/RuleServiceTest.java 2008-06-10 23:32:20 UTC (rev 262)
@@ -40,9 +40,6 @@
import org.jboss.dna.common.component.StandardClassLoaderFactory;
import org.jboss.dna.common.util.IoUtil;
import org.jboss.dna.common.util.Logger;
-import org.jboss.dna.repository.rules.InvalidRuleSetException;
-import org.jboss.dna.repository.rules.RuleService;
-import org.jboss.dna.repository.rules.RuleSet;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -93,13 +90,13 @@
}
@Before
- public void beforeEach() throws Exception {
+ public void beforeEach() {
this.ruleService = new RuleService();
this.classLoaderFactory = new StandardClassLoaderFactory();
}
@After
- public void afterEach() throws Exception {
+ public void afterEach() {
this.ruleService.getAdministrator().shutdown();
}
Modified: trunk/dna-repository/src/test/java/org/jboss/dna/repository/rules/RuleSetTest.java
===================================================================
--- trunk/dna-repository/src/test/java/org/jboss/dna/repository/rules/RuleSetTest.java 2008-06-10 23:13:20 UTC (rev 261)
+++ trunk/dna-repository/src/test/java/org/jboss/dna/repository/rules/RuleSetTest.java 2008-06-10 23:32:20 UTC (rev 262)
@@ -32,7 +32,6 @@
import java.util.Map;
import java.util.Set;
import org.jboss.dna.common.util.IoUtil;
-import org.jboss.dna.repository.rules.RuleSet;
import org.junit.Before;
import org.junit.Test;
@@ -52,7 +51,7 @@
private Map<String, Object> validProperties;
@Before
- public void beforeEach() throws Exception {
+ public void beforeEach() {
this.validName = "This is a valid name";
this.validDescription = "This is a valid description";
this.validClassname = "com.acme.SuperDuper";
@@ -64,91 +63,109 @@
this.validProperties.put("key1", "value1");
this.validProperties.put("key2", null);
this.validProperties.put("key3", "value3".getBytes());
- this.ruleSet = new RuleSet(validName, validDescription, validClassname, validClasspath, validProviderUri, validRuleSetUri, validRules, validProperties);
+ this.ruleSet = new RuleSet(validName, validDescription, validClassname, validClasspath, validProviderUri,
+ validRuleSetUri, validRules, validProperties);
}
@Test( expected = IllegalArgumentException.class )
public void shouldNotAllowNullName() {
- new RuleSet(null, validDescription, validClassname, validClasspath, validProviderUri, validRuleSetUri, validRules, validProperties);
+ new RuleSet(null, validDescription, validClassname, validClasspath, validProviderUri, validRuleSetUri, validRules,
+ validProperties);
}
@Test( expected = IllegalArgumentException.class )
public void shouldNotAllowEmptyName() {
- new RuleSet("", validDescription, validClassname, validClasspath, validProviderUri, validRuleSetUri, validRules, validProperties);
+ new RuleSet("", validDescription, validClassname, validClasspath, validProviderUri, validRuleSetUri, validRules,
+ validProperties);
}
@Test( expected = IllegalArgumentException.class )
public void shouldNotAllowBlankName() {
- new RuleSet(" \t ", validDescription, validClassname, validClasspath, validProviderUri, validRuleSetUri, validRules, validProperties);
+ new RuleSet(" \t ", validDescription, validClassname, validClasspath, validProviderUri, validRuleSetUri, validRules,
+ validProperties);
}
@Test
public void shouldTrimName() {
validName = " this is a valid name with leading and trailing whitespace ";
- ruleSet = new RuleSet(validName, validDescription, validClassname, validClasspath, validProviderUri, validRuleSetUri, validRules, validProperties);
+ ruleSet = new RuleSet(validName, validDescription, validClassname, validClasspath, validProviderUri, validRuleSetUri,
+ validRules, validProperties);
assertThat(ruleSet.getName(), is(validName.trim()));
}
@Test
public void shouldAllowNullOrEmptyOrBlankDescriptionAndShouldReplaceWithEmptyString() {
- ruleSet = new RuleSet(validName, null, validClassname, validClasspath, validProviderUri, validRuleSetUri, validRules, validProperties);
+ ruleSet = new RuleSet(validName, null, validClassname, validClasspath, validProviderUri, validRuleSetUri, validRules,
+ validProperties);
assertThat(ruleSet.getDescription(), is(""));
- ruleSet = new RuleSet(validName, "", validClassname, validClasspath, validProviderUri, validRuleSetUri, validRules, validProperties);
+ ruleSet = new RuleSet(validName, "", validClassname, validClasspath, validProviderUri, validRuleSetUri, validRules,
+ validProperties);
assertThat(ruleSet.getDescription(), is(""));
- ruleSet = new RuleSet(validName, " \t ", validClassname, validClasspath, validProviderUri, validRuleSetUri, validRules, validProperties);
+ ruleSet = new RuleSet(validName, " \t ", validClassname, validClasspath, validProviderUri, validRuleSetUri, validRules,
+ validProperties);
assertThat(ruleSet.getDescription(), is(""));
}
@Test
public void shouldTrimDescription() {
- ruleSet = new RuleSet(validName, " valid ", validClassname, validClasspath, validProviderUri, validRuleSetUri, validRules, validProperties);
+ ruleSet = new RuleSet(validName, " valid ", validClassname, validClasspath, validProviderUri, validRuleSetUri,
+ validRules, validProperties);
assertThat(ruleSet.getDescription(), is("valid"));
}
@Test( expected = IllegalArgumentException.class )
public void shouldNotAllowNullClassname() {
- new RuleSet(validName, validDescription, null, validClasspath, validProviderUri, validRuleSetUri, validRules, validProperties);
+ new RuleSet(validName, validDescription, null, validClasspath, validProviderUri, validRuleSetUri, validRules,
+ validProperties);
}
@Test( expected = IllegalArgumentException.class )
public void shouldNotAllowEmptyClassname() {
- new RuleSet(validName, validDescription, "", validClasspath, validProviderUri, validRuleSetUri, validRules, validProperties);
+ new RuleSet(validName, validDescription, "", validClasspath, validProviderUri, validRuleSetUri, validRules,
+ validProperties);
}
@Test( expected = IllegalArgumentException.class )
public void shouldNotAllowBlankClassname() {
- new RuleSet(validName, validDescription, " ", validClasspath, validProviderUri, validRuleSetUri, validRules, validProperties);
+ new RuleSet(validName, validDescription, " ", validClasspath, validProviderUri, validRuleSetUri, validRules,
+ validProperties);
}
@Test( expected = IllegalArgumentException.class )
public void shouldNotAllowClassnameThatDoesNotFollowJavaNamingRules() {
- new RuleSet(validName, validDescription, "not a valid classname", validClasspath, validProviderUri, validRuleSetUri, validRules, validProperties);
+ new RuleSet(validName, validDescription, "not a valid classname", validClasspath, validProviderUri, validRuleSetUri,
+ validRules, validProperties);
}
@Test
public void shouldAllowNullOrEmptyClasspath() {
- new RuleSet(validName, validDescription, validClassname, null, validProviderUri, validRuleSetUri, validRules, validProperties);
+ new RuleSet(validName, validDescription, validClassname, null, validProviderUri, validRuleSetUri, validRules,
+ validProperties);
}
@Test
public void shouldRemoveNullOrBlankClasspathItems() {
- new RuleSet(validName, validDescription, validClassname, new String[] {}, validProviderUri, validRuleSetUri, validRules, validProperties);
+ new RuleSet(validName, validDescription, validClassname, new String[] {}, validProviderUri, validRuleSetUri, validRules,
+ validProperties);
}
@Test
public void shouldRemoveDuplicateClasspathItemsInCaseSensitiveManner() {
validClasspath = new String[] {"path1", "path2", "path1", "path3", "path2"};
- ruleSet = new RuleSet(validName, validDescription, validClassname, validClasspath, validProviderUri, validRuleSetUri, validRules, validProperties);
+ ruleSet = new RuleSet(validName, validDescription, validClassname, validClasspath, validProviderUri, validRuleSetUri,
+ validRules, validProperties);
assertThat(ruleSet.getComponentClasspathArray(), is(new String[] {"path1", "path2", "path3"}));
validClasspath = new String[] {"path1", "path2", "path1", "path3", "Path2"};
- ruleSet = new RuleSet(validName, validDescription, validClassname, validClasspath, validProviderUri, validRuleSetUri, validRules, validProperties);
+ ruleSet = new RuleSet(validName, validDescription, validClassname, validClasspath, validProviderUri, validRuleSetUri,
+ validRules, validProperties);
assertThat(ruleSet.getComponentClasspathArray(), is(new String[] {"path1", "path2", "path3", "Path2"}));
}
@Test( expected = IllegalArgumentException.class )
public void shouldNotAllowNullProviderUri() {
- new RuleSet(validName, validDescription, validClassname, validClasspath, null, validRuleSetUri, validRules, validProperties);
+ new RuleSet(validName, validDescription, validClassname, validClasspath, null, validRuleSetUri, validRules,
+ validProperties);
}
@Test( expected = IllegalArgumentException.class )
@@ -158,44 +175,52 @@
@Test( expected = IllegalArgumentException.class )
public void shouldNotAllowBlankProviderUri() {
- new RuleSet(validName, validDescription, validClassname, validClasspath, " \t ", validRuleSetUri, validRules, validProperties);
+ new RuleSet(validName, validDescription, validClassname, validClasspath, " \t ", validRuleSetUri, validRules,
+ validProperties);
}
@Test
public void shouldUseNameInPlaceOfNullRuleSetUri() {
- ruleSet = new RuleSet(validName, validDescription, validClassname, validClasspath, validProviderUri, null, validRules, validProperties);
+ ruleSet = new RuleSet(validName, validDescription, validClassname, validClasspath, validProviderUri, null, validRules,
+ validProperties);
assertThat(ruleSet.getRuleSetUri(), is(ruleSet.getName()));
}
@Test( expected = IllegalArgumentException.class )
public void shouldNotAllowEmptyRuleSetUri() {
- new RuleSet(validName, validDescription, validClassname, validClasspath, validProviderUri, "", validRules, validProperties);
+ new RuleSet(validName, validDescription, validClassname, validClasspath, validProviderUri, "", validRules,
+ validProperties);
}
@Test( expected = IllegalArgumentException.class )
public void shouldNotAllowBlankRuleSetUri() {
- new RuleSet(validName, validDescription, validClassname, validClasspath, validProviderUri, " \t ", validRules, validProperties);
+ new RuleSet(validName, validDescription, validClassname, validClasspath, validProviderUri, " \t ", validRules,
+ validProperties);
}
@Test( expected = IllegalArgumentException.class )
public void shouldNotAllowNullRules() {
- new RuleSet(validName, validDescription, validClassname, validClasspath, validProviderUri, validRuleSetUri, null, validProperties);
+ new RuleSet(validName, validDescription, validClassname, validClasspath, validProviderUri, validRuleSetUri, null,
+ validProperties);
}
@Test( expected = IllegalArgumentException.class )
public void shouldNotAllowEmptyRules() {
- new RuleSet(validName, validDescription, validClassname, validClasspath, validProviderUri, validRuleSetUri, "", validProperties);
+ new RuleSet(validName, validDescription, validClassname, validClasspath, validProviderUri, validRuleSetUri, "",
+ validProperties);
}
@Test( expected = IllegalArgumentException.class )
public void shouldNotAllowBlankRules() {
- new RuleSet(validName, validDescription, validClassname, validClasspath, validProviderUri, validRuleSetUri, " \t ", validProperties);
+ new RuleSet(validName, validDescription, validClassname, validClasspath, validProviderUri, validRuleSetUri, " \t ",
+ validProperties);
}
@Test
public void shouldAllowNullOrEmptyProperties() {
validProperties = null;
- ruleSet = new RuleSet(validName, validDescription, validClassname, validClasspath, validProviderUri, validRuleSetUri, validRules, validProperties);
+ ruleSet = new RuleSet(validName, validDescription, validClassname, validClasspath, validProviderUri, validRuleSetUri,
+ validRules, validProperties);
assertThat(ruleSet.getProperties(), is(notNullValue()));
}
@@ -227,7 +252,8 @@
assertThat(executionSetPropIter.hasNext(), is(false));
assertThat(propIter.hasNext(), is(false));
- new RuleSet(validName, validDescription, validClassname, validClasspath, validProviderUri, validRuleSetUri, validRules, validProperties);
+ new RuleSet(validName, validDescription, validClassname, validClasspath, validProviderUri, validRuleSetUri, validRules,
+ validProperties);
}
@Test
@@ -236,33 +262,40 @@
assertThat(copy.hasChanged(ruleSet), is(false));
assertThat(copy.hasChanged(copy), is(false));
- copy = new RuleSet(validName + "x", validDescription, validClassname, validClasspath, validProviderUri, validRuleSetUri, validRules, validProperties);
+ copy = new RuleSet(validName + "x", validDescription, validClassname, validClasspath, validProviderUri, validRuleSetUri,
+ validRules, validProperties);
assertThat(copy.hasChanged(ruleSet), is(true));
assertThat(copy.hasChanged(copy), is(false));
- copy = new RuleSet(validName, validDescription + "x", validClassname, validClasspath, validProviderUri, validRuleSetUri, validRules, validProperties);
+ copy = new RuleSet(validName, validDescription + "x", validClassname, validClasspath, validProviderUri, validRuleSetUri,
+ validRules, validProperties);
assertThat(copy.hasChanged(ruleSet), is(true));
assertThat(copy.hasChanged(copy), is(false));
- copy = new RuleSet(validName, validDescription, validClassname + "x", validClasspath, validProviderUri, validRuleSetUri, validRules, validProperties);
+ copy = new RuleSet(validName, validDescription, validClassname + "x", validClasspath, validProviderUri, validRuleSetUri,
+ validRules, validProperties);
assertThat(copy.hasChanged(ruleSet), is(true));
assertThat(copy.hasChanged(copy), is(false));
- copy = new RuleSet(validName, validDescription, validClassname, validClasspath, validProviderUri + "x", validRuleSetUri, validRules, validProperties);
+ copy = new RuleSet(validName, validDescription, validClassname, validClasspath, validProviderUri + "x", validRuleSetUri,
+ validRules, validProperties);
assertThat(copy.hasChanged(ruleSet), is(true));
assertThat(copy.hasChanged(copy), is(false));
validClasspath = new String[] {"classpath1", "classpath2x"};
- copy = new RuleSet(validName, validDescription, validClassname, validClasspath, validProviderUri, validRuleSetUri + "x", validRules, validProperties);
+ copy = new RuleSet(validName, validDescription, validClassname, validClasspath, validProviderUri, validRuleSetUri + "x",
+ validRules, validProperties);
assertThat(copy.hasChanged(ruleSet), is(true));
assertThat(copy.hasChanged(copy), is(false));
- copy = new RuleSet(validName, validDescription, validClassname, validClasspath, validProviderUri, validRuleSetUri, validRules + "x", validProperties);
+ copy = new RuleSet(validName, validDescription, validClassname, validClasspath, validProviderUri, validRuleSetUri,
+ validRules + "x", validProperties);
assertThat(copy.hasChanged(ruleSet), is(true));
assertThat(copy.hasChanged(copy), is(false));
validProperties.remove("key1");
- copy = new RuleSet(validName, validDescription, validClassname, validClasspath, validProviderUri, validRuleSetUri, validRules, validProperties);
+ copy = new RuleSet(validName, validDescription, validClassname, validClasspath, validProviderUri, validRuleSetUri,
+ validRules, validProperties);
assertThat(copy.hasChanged(ruleSet), is(true));
assertThat(copy.hasChanged(copy), is(false));
}
@@ -272,27 +305,34 @@
RuleSet copy = ruleSet.clone();
assertThat(copy.equals(ruleSet), is(true));
- copy = new RuleSet(validName + "x", validDescription, validClassname, validClasspath, validProviderUri, validRuleSetUri, validRules, validProperties);
+ copy = new RuleSet(validName + "x", validDescription, validClassname, validClasspath, validProviderUri, validRuleSetUri,
+ validRules, validProperties);
assertThat(copy.equals(ruleSet), is(false));
- copy = new RuleSet(validName, validDescription + "x", validClassname, validClasspath, validProviderUri, validRuleSetUri, validRules, validProperties);
+ copy = new RuleSet(validName, validDescription + "x", validClassname, validClasspath, validProviderUri, validRuleSetUri,
+ validRules, validProperties);
assertThat(copy.equals(ruleSet), is(true));
- copy = new RuleSet(validName, validDescription, validClassname + "x", validClasspath, validProviderUri, validRuleSetUri, validRules, validProperties);
+ copy = new RuleSet(validName, validDescription, validClassname + "x", validClasspath, validProviderUri, validRuleSetUri,
+ validRules, validProperties);
assertThat(copy.equals(ruleSet), is(true));
- copy = new RuleSet(validName, validDescription, validClassname, validClasspath, validProviderUri + "x", validRuleSetUri, validRules, validProperties);
+ copy = new RuleSet(validName, validDescription, validClassname, validClasspath, validProviderUri + "x", validRuleSetUri,
+ validRules, validProperties);
assertThat(copy.equals(ruleSet), is(true));
validClasspath = new String[] {"classpath1", "classpath2x"};
- copy = new RuleSet(validName, validDescription, validClassname, validClasspath, validProviderUri, validRuleSetUri + "x", validRules, validProperties);
+ copy = new RuleSet(validName, validDescription, validClassname, validClasspath, validProviderUri, validRuleSetUri + "x",
+ validRules, validProperties);
assertThat(copy.equals(ruleSet), is(true));
- copy = new RuleSet(validName, validDescription, validClassname, validClasspath, validProviderUri, validRuleSetUri, validRules + "x", validProperties);
+ copy = new RuleSet(validName, validDescription, validClassname, validClasspath, validProviderUri, validRuleSetUri,
+ validRules + "x", validProperties);
assertThat(copy.equals(ruleSet), is(true));
validProperties.remove("key1");
- copy = new RuleSet(validName, validDescription, validClassname, validClasspath, validProviderUri, validRuleSetUri, validRules, validProperties);
+ copy = new RuleSet(validName, validDescription, validClassname, validClasspath, validProviderUri, validRuleSetUri,
+ validRules, validProperties);
assertThat(copy.equals(ruleSet), is(true));
}
Modified: trunk/dna-repository/src/test/java/org/jboss/dna/repository/sequencers/SequencerConfigTest.java
===================================================================
--- trunk/dna-repository/src/test/java/org/jboss/dna/repository/sequencers/SequencerConfigTest.java 2008-06-10 23:13:20 UTC (rev 261)
+++ trunk/dna-repository/src/test/java/org/jboss/dna/repository/sequencers/SequencerConfigTest.java 2008-06-10 23:32:20 UTC (rev 262)
@@ -24,7 +24,6 @@
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
-import org.jboss.dna.repository.sequencers.SequencerConfig;
import org.junit.Before;
import org.junit.Test;
@@ -43,15 +42,18 @@
private String[] validMavenIds;
@Before
- public void beforeEach() throws Exception {
+ public void beforeEach() {
this.validName = "valid configuration name";
this.validDescription = "a sequencer";
this.validClassname = MockSequencerA.class.getName();
this.validPathExpressions = new String[] {"/a/b/c/d[e/@attribute] => ."};
this.validMavenIds = new String[] {"com.acme:configA:1.0,com.acme:configB:1.0"};
- this.configA = new SequencerConfig("configA", validDescription, MockSequencerA.class.getName(), validMavenIds, validPathExpressions);
- this.configB = new SequencerConfig("configB", validDescription, MockSequencerB.class.getName(), validMavenIds, validPathExpressions);
- this.configA2 = new SequencerConfig("conFigA", validDescription, MockSequencerA.class.getName(), validMavenIds, validPathExpressions);
+ this.configA = new SequencerConfig("configA", validDescription, MockSequencerA.class.getName(), validMavenIds,
+ validPathExpressions);
+ this.configB = new SequencerConfig("configB", validDescription, MockSequencerB.class.getName(), validMavenIds,
+ validPathExpressions);
+ this.configA2 = new SequencerConfig("conFigA", validDescription, MockSequencerA.class.getName(), validMavenIds,
+ validPathExpressions);
}
@Test( expected = IllegalArgumentException.class )
@@ -106,7 +108,9 @@
@Test
public void shouldNotAddSamePathExpressionMoreThanOnce() {
- assertThat(SequencerConfig.buildPathExpressionSet(validPathExpressions[0], validPathExpressions[0], validPathExpressions[0]).size(), is(1));
+ assertThat(SequencerConfig.buildPathExpressionSet(validPathExpressions[0],
+ validPathExpressions[0],
+ validPathExpressions[0]).size(), is(1));
}
@Test
Modified: trunk/dna-repository/src/test/java/org/jboss/dna/repository/sequencers/SequencingServiceTest.java
===================================================================
--- trunk/dna-repository/src/test/java/org/jboss/dna/repository/sequencers/SequencingServiceTest.java 2008-06-10 23:13:20 UTC (rev 261)
+++ trunk/dna-repository/src/test/java/org/jboss/dna/repository/sequencers/SequencingServiceTest.java 2008-06-10 23:32:20 UTC (rev 262)
@@ -46,7 +46,8 @@
*/
public class SequencingServiceTest extends AbstractJcrRepositoryTest {
- public static final int ALL_EVENT_TYPES = Event.NODE_ADDED | Event.NODE_REMOVED | Event.PROPERTY_ADDED | Event.PROPERTY_CHANGED | Event.PROPERTY_REMOVED;
+ public static final int ALL_EVENT_TYPES = Event.NODE_ADDED | Event.NODE_REMOVED | Event.PROPERTY_ADDED
+ | Event.PROPERTY_CHANGED | Event.PROPERTY_REMOVED;
public static final String REPOSITORY_WORKSPACE_NAME = "testRepository-Workspace";
private ObservationService observationService;
@@ -54,7 +55,7 @@
private ExecutionContext executionContext;
@Before
- public void beforeEach() throws Exception {
+ public void beforeEach() {
this.executionContext = new MockExecutionContext(this, REPOSITORY_WORKSPACE_NAME);
this.sequencingService = new SequencingService();
this.sequencingService.setExecutionContext(this.executionContext);
@@ -142,7 +143,8 @@
assertThat(sequencingService.getAdministrator().isPaused(), is(false));
assertThat(sequencingService.getAdministrator().isStarted(), is(false));
ServiceAdministrator.State actualState = sequencingService.getAdministrator().getState();
- assertThat(actualState == ServiceAdministrator.State.SHUTDOWN || actualState == ServiceAdministrator.State.TERMINATED, is(true));
+ assertThat(actualState == ServiceAdministrator.State.SHUTDOWN || actualState == ServiceAdministrator.State.TERMINATED,
+ is(true));
}
}
@@ -172,7 +174,8 @@
assertThat(sequencingService.getAdministrator().isPaused(), is(false));
assertThat(sequencingService.getAdministrator().isStarted(), is(false));
ServiceAdministrator.State actualState = sequencingService.getAdministrator().getState();
- assertThat(actualState == ServiceAdministrator.State.SHUTDOWN || actualState == ServiceAdministrator.State.TERMINATED, is(true));
+ assertThat(actualState == ServiceAdministrator.State.SHUTDOWN || actualState == ServiceAdministrator.State.TERMINATED,
+ is(true));
// Now start it back up ... this will fail
sequencingService.getAdministrator().start();
Modified: trunk/dna-repository/src/test/java/org/jboss/dna/repository/sequencers/StreamSequencerAdapterTest.java
===================================================================
--- trunk/dna-repository/src/test/java/org/jboss/dna/repository/sequencers/StreamSequencerAdapterTest.java 2008-06-10 23:13:20 UTC (rev 261)
+++ trunk/dna-repository/src/test/java/org/jboss/dna/repository/sequencers/StreamSequencerAdapterTest.java 2008-06-10 23:32:20 UTC (rev 262)
@@ -71,7 +71,7 @@
private String repositoryWorkspaceName = "something";
@Before
- public void beforeEach() throws Exception {
+ public void beforeEach() {
final JcrTools tools = new JcrTools();
this.tools = tools;
final SessionFactory sessionFactory = new SessionFactory() {
@@ -91,7 +91,9 @@
* This method always copies the {@link StreamSequencerAdapterTest#sequencerOutput} data into the output {@inheritDoc},
* and does nothing else with any of the other parameters.
*/
- public void sequence( InputStream stream, SequencerOutput output, ProgressMonitor progressMonitor ) {
+ public void sequence( InputStream stream,
+ SequencerOutput output,
+ ProgressMonitor progressMonitor ) {
for (SequencerOutputMap.Entry entry : finalOutput) {
Path nodePath = entry.getPath();
for (SequencerOutputMap.PropertyValue property : entry.getPropertyValues()) {
@@ -104,7 +106,7 @@
}
@After
- public void afterEach() throws Exception {
+ public void afterEach() {
if (session != null) {
try {
session.logout();
@@ -149,7 +151,8 @@
@Test
public void shouldExtractMixinTypesFromStringArrayWithNullValue() {
- assertThat(sequencer.extractMixinTypes(new String[] {"value1", null, "value2"}), is(new String[] {"value1", null, "value2"}));
+ assertThat(sequencer.extractMixinTypes(new String[] {"value1", null, "value2"}), is(new String[] {"value1", null,
+ "value2"}));
}
@Test
@@ -170,7 +173,8 @@
nodeC.setProperty("sequencedProperty", new ByteArrayInputStream(sampleData.getBytes()));
// Set up the node changes ...
- NodeChange nodeChange = new NodeChange(repositoryWorkspaceName, nodeC.getPath(), Event.PROPERTY_CHANGED, Collections.singleton("sequencedProperty"), null);
+ NodeChange nodeChange = new NodeChange(repositoryWorkspaceName, nodeC.getPath(), Event.PROPERTY_CHANGED,
+ Collections.singleton("sequencedProperty"), null);
// Set up the output directory ...
Set<RepositoryNodePath> outputPaths = new HashSet<RepositoryNodePath>();
@@ -202,7 +206,8 @@
nodeC.setProperty("sequencedProperty", (InputStream)null);
// Set up the node changes ...
- NodeChange nodeChange = new NodeChange(repositoryWorkspaceName, nodeC.getPath(), Event.PROPERTY_CHANGED, Collections.singleton("sequencedProperty"), null);
+ NodeChange nodeChange = new NodeChange(repositoryWorkspaceName, nodeC.getPath(), Event.PROPERTY_CHANGED,
+ Collections.singleton("sequencedProperty"), null);
// Set up the output directory ...
Set<RepositoryNodePath> outputPaths = new HashSet<RepositoryNodePath>();
@@ -233,7 +238,8 @@
nodeC.setProperty("sequencedProperty", new ByteArrayInputStream(sampleData.getBytes()));
// Set up the node changes ...
- NodeChange nodeChange = new NodeChange(repositoryWorkspaceName, nodeC.getPath(), Event.PROPERTY_CHANGED, Collections.singleton("sequencedProperty"), null);
+ NodeChange nodeChange = new NodeChange(repositoryWorkspaceName, nodeC.getPath(), Event.PROPERTY_CHANGED,
+ Collections.singleton("sequencedProperty"), null);
// Set up the output directory ...
Set<RepositoryNodePath> outputPaths = new HashSet<RepositoryNodePath>();
@@ -265,7 +271,8 @@
nodeC.setProperty("sequencedProperty", new ByteArrayInputStream(sampleData.getBytes()));
// Set up the node changes ...
- NodeChange nodeChange = new NodeChange(repositoryWorkspaceName, nodeC.getPath(), Event.PROPERTY_CHANGED, Collections.singleton("sequencedProperty"), null);
+ NodeChange nodeChange = new NodeChange(repositoryWorkspaceName, nodeC.getPath(), Event.PROPERTY_CHANGED,
+ Collections.singleton("sequencedProperty"), null);
// Set up the output directory ...
Set<RepositoryNodePath> outputPaths = new HashSet<RepositoryNodePath>();
@@ -296,7 +303,8 @@
nodeC.setProperty("sequencedProperty", new ByteArrayInputStream(sampleData.getBytes()));
// Set up the node changes ...
- NodeChange nodeChange = new NodeChange(repositoryWorkspaceName, nodeC.getPath(), Event.PROPERTY_CHANGED, Collections.singleton("sequencedProperty"), null);
+ NodeChange nodeChange = new NodeChange(repositoryWorkspaceName, nodeC.getPath(), Event.PROPERTY_CHANGED,
+ Collections.singleton("sequencedProperty"), null);
// Set up the output directory ...
Set<RepositoryNodePath> outputPaths = new HashSet<RepositoryNodePath>();
@@ -327,7 +335,7 @@
}
@Test
- public void shouldSequencerOutputProvideAccessToNamespaceRegistry() {
- assertThat(sequencerOutput.getNamespaceRegistry(), notNullValue());
- }
+ public void shouldSequencerOutputProvideAccessToNamespaceRegistry() {
+ assertThat(sequencerOutput.getNamespaceRegistry(), notNullValue());
+ }
}
Modified: trunk/dna-repository/src/test/java/org/jboss/dna/repository/sequencers/xml/XmlSequencerTest.java
===================================================================
--- trunk/dna-repository/src/test/java/org/jboss/dna/repository/sequencers/xml/XmlSequencerTest.java 2008-06-10 23:13:20 UTC (rev 261)
+++ trunk/dna-repository/src/test/java/org/jboss/dna/repository/sequencers/xml/XmlSequencerTest.java 2008-06-10 23:32:20 UTC (rev 262)
@@ -43,171 +43,171 @@
*/
public class XmlSequencerTest {
- private XmlSequencer sequencer;
- private InputStream stream;
- private MockSequencerOutput output;
- private ProgressMonitor monitor;
- private URL xml1;
- private URL xml2;
- private URL xml3;
- private URL xml4;
- private URL xsd;
+ private XmlSequencer sequencer;
+ private InputStream stream;
+ private MockSequencerOutput output;
+ private ProgressMonitor monitor;
+ private URL xml1;
+ private URL xml2;
+ private URL xml3;
+ private URL xml4;
+ private URL xsd;
- @Before
- public void beforeEach() throws Exception {
- sequencer = new XmlSequencer();
- output = new MockSequencerOutput() {
+ @Before
+ public void beforeEach() {
+ sequencer = new XmlSequencer();
+ output = new MockSequencerOutput() {
- @Override
- public void setProperty( Path nodePath,
- Name propertyName,
- Object... values ) {
- super.setProperty(nodePath, propertyName, values);
- // System.out.println(nodePath + "." + propertyName + " = " + Arrays.asList(values));
- }
- };
- monitor = new SimpleProgressMonitor("Test activity");
- xml1 = this.getClass().getClassLoader().getResource("jackrabbitInMemoryTestRepositoryConfig.xml");
- assertThat(xml1, is(notNullValue()));
- xml2 = this.getClass().getClassLoader().getResource("master.xml");
- assertThat(xml2, is(notNullValue()));
- xml3 = this.getClass().getClassLoader().getResource("CurrencyFormatterExample.mxml");
- assertThat(xml3, is(notNullValue()));
- xml4 = this.getClass().getClassLoader().getResource("plugin.xml");
- assertThat(xml4, is(notNullValue()));
- xsd = this.getClass().getClassLoader().getResource("Descriptor.1.0.xsd");
- assertThat(xsd, is(notNullValue()));
- }
+ @Override
+ public void setProperty( Path nodePath,
+ Name propertyName,
+ Object... values ) {
+ super.setProperty(nodePath, propertyName, values);
+ // System.out.println(nodePath + "." + propertyName + " = " + Arrays.asList(values));
+ }
+ };
+ monitor = new SimpleProgressMonitor("Test activity");
+ xml1 = this.getClass().getClassLoader().getResource("jackrabbitInMemoryTestRepositoryConfig.xml");
+ assertThat(xml1, is(notNullValue()));
+ xml2 = this.getClass().getClassLoader().getResource("master.xml");
+ assertThat(xml2, is(notNullValue()));
+ xml3 = this.getClass().getClassLoader().getResource("CurrencyFormatterExample.mxml");
+ assertThat(xml3, is(notNullValue()));
+ xml4 = this.getClass().getClassLoader().getResource("plugin.xml");
+ assertThat(xml4, is(notNullValue()));
+ xsd = this.getClass().getClassLoader().getResource("Descriptor.1.0.xsd");
+ assertThat(xsd, is(notNullValue()));
+ }
- @After
- public void afterEach() throws Exception {
- if (stream != null) {
- try {
- stream.close();
- } finally {
- stream = null;
- }
- }
- }
+ @After
+ public void afterEach() throws Exception {
+ if (stream != null) {
+ try {
+ stream.close();
+ } finally {
+ stream = null;
+ }
+ }
+ }
- @Test
- public void shouldSequenceXml() throws IOException {
- verifyDocument(xml1);
- verifyName(XmlSequencer.COMMENT + "[1]", NameFactory.JCR_PRIMARY_TYPE, XmlSequencer.COMMENT);
- String text = verify(XmlSequencer.COMMENT + "[1]", XmlSequencer.COMMENT_CONTENT, String.class);
- assertThat(text.startsWith("\n Licensed to the Apache Software Foundation (ASF)"), is(true));
- assertThat(text.endsWith(" limitations under the License.\n"), is(true));
- verifyString("", XmlSequencer.DTD_NAME, "Repository");
- verifyString("", XmlSequencer.DTD_PUBLIC_ID, "-//The Apache Software Foundation//DTD Jackrabbit 1.2//EN");
- verifyString("", XmlSequencer.DTD_SYSTEM_ID, "http://jackrabbit.apache.org/dtd/repository-1.2.dtd");
- verifyName(XmlSequencer.COMMENT + "[2]", NameFactory.JCR_PRIMARY_TYPE, XmlSequencer.COMMENT);
- verifyString(XmlSequencer.COMMENT + "[2]", XmlSequencer.COMMENT_CONTENT, " Example Repository Configuration File ");
- verifyName("Repository[1]", NameFactory.JCR_PRIMARY_TYPE, "Repository");
- verifyName("Repository[1]/" + XmlSequencer.COMMENT + "[1]", NameFactory.JCR_PRIMARY_TYPE, XmlSequencer.COMMENT);
- }
+ @Test
+ public void shouldSequenceXml() throws IOException {
+ verifyDocument(xml1);
+ verifyName(XmlSequencer.COMMENT + "[1]", NameFactory.JCR_PRIMARY_TYPE, XmlSequencer.COMMENT);
+ String text = verify(XmlSequencer.COMMENT + "[1]", XmlSequencer.COMMENT_CONTENT, String.class);
+ assertThat(text.startsWith("\n Licensed to the Apache Software Foundation (ASF)"), is(true));
+ assertThat(text.endsWith(" limitations under the License.\n"), is(true));
+ verifyString("", XmlSequencer.DTD_NAME, "Repository");
+ verifyString("", XmlSequencer.DTD_PUBLIC_ID, "-//The Apache Software Foundation//DTD Jackrabbit 1.2//EN");
+ verifyString("", XmlSequencer.DTD_SYSTEM_ID, "http://jackrabbit.apache.org/dtd/repository-1.2.dtd");
+ verifyName(XmlSequencer.COMMENT + "[2]", NameFactory.JCR_PRIMARY_TYPE, XmlSequencer.COMMENT);
+ verifyString(XmlSequencer.COMMENT + "[2]", XmlSequencer.COMMENT_CONTENT, " Example Repository Configuration File ");
+ verifyName("Repository[1]", NameFactory.JCR_PRIMARY_TYPE, "Repository");
+ verifyName("Repository[1]/" + XmlSequencer.COMMENT + "[1]", NameFactory.JCR_PRIMARY_TYPE, XmlSequencer.COMMENT);
+ }
- @Test
- public void shouldHandleNamespaces() throws IOException {
- verifyDocument(xml2);
- verifyName("book[1]/bookinfo[1]/xi:include[1]", NameFactory.JCR_PRIMARY_TYPE, "xi:include");
- verifyString("book[1]/bookinfo[1]/xi:include[1]", "xi:href", "Author_Group.xml");
- verifyName("book[1]/bookinfo[1]/xi:include[2]", NameFactory.JCR_PRIMARY_TYPE, "xi:include");
- verifyString("book[1]/bookinfo[1]/xi:include[2]", "xi:href", "Legal_Notice.xml");
- }
+ @Test
+ public void shouldHandleNamespaces() throws IOException {
+ verifyDocument(xml2);
+ verifyName("book[1]/bookinfo[1]/xi:include[1]", NameFactory.JCR_PRIMARY_TYPE, "xi:include");
+ verifyString("book[1]/bookinfo[1]/xi:include[1]", "xi:href", "Author_Group.xml");
+ verifyName("book[1]/bookinfo[1]/xi:include[2]", NameFactory.JCR_PRIMARY_TYPE, "xi:include");
+ verifyString("book[1]/bookinfo[1]/xi:include[2]", "xi:href", "Legal_Notice.xml");
+ }
- @Test
- public void shouldSequenceEntityDeclarations() throws IOException {
- verifyDocument(xml2);
- verifyName(XmlSequencer.ENTITY + "[1]", NameFactory.JCR_PRIMARY_TYPE, XmlSequencer.ENTITY);
- verifyString(XmlSequencer.ENTITY + "[1]", XmlSequencer.DTD_NAME, "%RH-ENTITIES");
- verifyString(XmlSequencer.ENTITY + "[1]", XmlSequencer.DTD_SYSTEM_ID, "Common_Config/rh-entities.ent");
- verifyName(XmlSequencer.ENTITY + "[2]", NameFactory.JCR_PRIMARY_TYPE, XmlSequencer.ENTITY);
- verifyString(XmlSequencer.ENTITY + "[2]", XmlSequencer.DTD_NAME, "versionNumber");
- verifyString(XmlSequencer.ENTITY + "[2]", XmlSequencer.DTD_VALUE, "0.1");
- verifyName(XmlSequencer.ENTITY + "[3]", NameFactory.JCR_PRIMARY_TYPE, XmlSequencer.ENTITY);
- verifyString(XmlSequencer.ENTITY + "[3]", XmlSequencer.DTD_NAME, "copyrightYear");
- verifyString(XmlSequencer.ENTITY + "[3]", XmlSequencer.DTD_VALUE, "2008");
- }
+ @Test
+ public void shouldSequenceEntityDeclarations() throws IOException {
+ verifyDocument(xml2);
+ verifyName(XmlSequencer.ENTITY + "[1]", NameFactory.JCR_PRIMARY_TYPE, XmlSequencer.ENTITY);
+ verifyString(XmlSequencer.ENTITY + "[1]", XmlSequencer.DTD_NAME, "%RH-ENTITIES");
+ verifyString(XmlSequencer.ENTITY + "[1]", XmlSequencer.DTD_SYSTEM_ID, "Common_Config/rh-entities.ent");
+ verifyName(XmlSequencer.ENTITY + "[2]", NameFactory.JCR_PRIMARY_TYPE, XmlSequencer.ENTITY);
+ verifyString(XmlSequencer.ENTITY + "[2]", XmlSequencer.DTD_NAME, "versionNumber");
+ verifyString(XmlSequencer.ENTITY + "[2]", XmlSequencer.DTD_VALUE, "0.1");
+ verifyName(XmlSequencer.ENTITY + "[3]", NameFactory.JCR_PRIMARY_TYPE, XmlSequencer.ENTITY);
+ verifyString(XmlSequencer.ENTITY + "[3]", XmlSequencer.DTD_NAME, "copyrightYear");
+ verifyString(XmlSequencer.ENTITY + "[3]", XmlSequencer.DTD_VALUE, "2008");
+ }
- @Test
- public void shouldSequenceElementContent() throws IOException {
- verifyDocument(xml2);
- verifyString("book[1]/chapter[4]/sect1[1]/para[8]/" + XmlSequencer.ELEMENT_CONTENT + "[1]",
- XmlSequencer.ELEMENT_CONTENT,
- "The path expression is more complicated."
- + " Sequencer path expressions are used by the sequencing service to determine whether a particular changed node should be sequenced."
- + " The expressions consist of two parts: a selection criteria and an output expression."
- + " Here's a simple example:");
- verifyString("book[1]/chapter[4]/sect1[1]/para[8]/programlisting[1]/" + XmlSequencer.ELEMENT_CONTENT + "[1]",
- XmlSequencer.ELEMENT_CONTENT,
- "/a/b/c@title => /d/e/f");
- }
+ @Test
+ public void shouldSequenceElementContent() throws IOException {
+ verifyDocument(xml2);
+ verifyString("book[1]/chapter[4]/sect1[1]/para[8]/" + XmlSequencer.ELEMENT_CONTENT + "[1]",
+ XmlSequencer.ELEMENT_CONTENT,
+ "The path expression is more complicated."
+ + " Sequencer path expressions are used by the sequencing service to determine whether a particular changed node should be sequenced."
+ + " The expressions consist of two parts: a selection criteria and an output expression."
+ + " Here's a simple example:");
+ verifyString("book[1]/chapter[4]/sect1[1]/para[8]/programlisting[1]/" + XmlSequencer.ELEMENT_CONTENT + "[1]",
+ XmlSequencer.ELEMENT_CONTENT,
+ "/a/b/c@title => /d/e/f");
+ }
- @Test
- public void shouldSequenceCData() throws IOException {
- verifyDocument(xml3);
- verifyString("mx:Application[1]/mx:Script[1]/" + XmlSequencer.CDATA + "[1]",
- XmlSequencer.CDATA_CONTENT,
- "\n\n" + " import mx.events.ValidationResultEvent;\t\t\t\n"
- + " private var vResult:ValidationResultEvent;\n" + "\t\t\t\n"
- + " // Event handler to validate and format input.\n"
- + " private function Format():void {\n" + " \n"
- + " vResult = numVal.validate();\n\n"
- + " if (vResult.type==ValidationResultEvent.VALID) {\n"
- + " var temp:Number=Number(priceUS.text); \n"
- + " formattedUSPrice.text= usdFormatter.format(temp);\n" + " }\n"
- + " \n" + " else {\n"
- + " formattedUSPrice.text=\"\";\n" + " }\n" + " }\n"
- + " ");
- }
+ @Test
+ public void shouldSequenceCData() throws IOException {
+ verifyDocument(xml3);
+ verifyString("mx:Application[1]/mx:Script[1]/" + XmlSequencer.CDATA + "[1]",
+ XmlSequencer.CDATA_CONTENT,
+ "\n\n" + " import mx.events.ValidationResultEvent;\t\t\t\n"
+ + " private var vResult:ValidationResultEvent;\n" + "\t\t\t\n"
+ + " // Event handler to validate and format input.\n"
+ + " private function Format():void {\n" + " \n"
+ + " vResult = numVal.validate();\n\n"
+ + " if (vResult.type==ValidationResultEvent.VALID) {\n"
+ + " var temp:Number=Number(priceUS.text); \n"
+ + " formattedUSPrice.text= usdFormatter.format(temp);\n" + " }\n"
+ + " \n" + " else {\n"
+ + " formattedUSPrice.text=\"\";\n" + " }\n" + " }\n"
+ + " ");
+ }
- @Test
- public void shouldSequenceProcessingInstructions() throws IOException {
- verifyDocument(xml4);
- verifyName(XmlSequencer.PI + "[1]", NameFactory.JCR_PRIMARY_TYPE, XmlSequencer.PI);
- verifyString(XmlSequencer.PI + "[1]", XmlSequencer.TARGET, "eclipse");
- verifyString(XmlSequencer.PI + "[1]", XmlSequencer.PI_CONTENT, "version=\"3.0\"");
- }
+ @Test
+ public void shouldSequenceProcessingInstructions() throws IOException {
+ verifyDocument(xml4);
+ verifyName(XmlSequencer.PI + "[1]", NameFactory.JCR_PRIMARY_TYPE, XmlSequencer.PI);
+ verifyString(XmlSequencer.PI + "[1]", XmlSequencer.TARGET, "eclipse");
+ verifyString(XmlSequencer.PI + "[1]", XmlSequencer.PI_CONTENT, "version=\"3.0\"");
+ }
- @Test
- public void shouldSequenceXsds() throws IOException {
- verifyDocument(xsd);
- verifyName("xs:schema[1]", NameFactory.JCR_PRIMARY_TYPE, "xs:schema");
- verifyString("xs:schema[1]", "xs:targetNamespace", "http://ns.adobe.com/air/application/1.0");
- verifyString("xs:schema[1]", "xs:elementFormDefault", "qualified");
- verifyName("xs:schema[1]/xs:element[1]", NameFactory.JCR_PRIMARY_TYPE, "xs:element");
- verifyString("xs:schema[1]/xs:element[1]", "xs:name", "application");
- }
+ @Test
+ public void shouldSequenceXsds() throws IOException {
+ verifyDocument(xsd);
+ verifyName("xs:schema[1]", NameFactory.JCR_PRIMARY_TYPE, "xs:schema");
+ verifyString("xs:schema[1]", "xs:targetNamespace", "http://ns.adobe.com/air/application/1.0");
+ verifyString("xs:schema[1]", "xs:elementFormDefault", "qualified");
+ verifyName("xs:schema[1]/xs:element[1]", NameFactory.JCR_PRIMARY_TYPE, "xs:element");
+ verifyString("xs:schema[1]/xs:element[1]", "xs:name", "application");
+ }
- private <T> T verify( String nodePath,
- String property,
- Class<T> expectedClass ) {
- Object[] values = output.getPropertyValues(nodePath.length() == 0 ? "." : "./" + nodePath, property);
- assertThat(values, notNullValue());
- assertThat(values.length, is(1));
- Object value = values[0];
- assertThat(value, instanceOf(expectedClass));
- return expectedClass.cast(value);
- }
+ private <T> T verify( String nodePath,
+ String property,
+ Class<T> expectedClass ) {
+ Object[] values = output.getPropertyValues(nodePath.length() == 0 ? "." : "./" + nodePath, property);
+ assertThat(values, notNullValue());
+ assertThat(values.length, is(1));
+ Object value = values[0];
+ assertThat(value, instanceOf(expectedClass));
+ return expectedClass.cast(value);
+ }
- private void verifyDocument( URL url ) throws IOException {
- stream = url.openStream();
- assertThat(stream, is(notNullValue()));
- sequencer.sequence(stream, output, monitor);
- verifyName("", NameFactory.JCR_PRIMARY_TYPE, XmlSequencer.DOCUMENT);
- }
+ private void verifyDocument( URL url ) throws IOException {
+ stream = url.openStream();
+ assertThat(stream, is(notNullValue()));
+ sequencer.sequence(stream, output, monitor);
+ verifyName("", NameFactory.JCR_PRIMARY_TYPE, XmlSequencer.DOCUMENT);
+ }
- private void verifyName( String nodePath,
- String property,
- String expectedName ) {
- Name name = verify(nodePath, property, Name.class);
- assertThat(name, is(output.getFactories().getNameFactory().create(expectedName)));
- }
+ private void verifyName( String nodePath,
+ String property,
+ String expectedName ) {
+ Name name = verify(nodePath, property, Name.class);
+ assertThat(name, is(output.getFactories().getNameFactory().create(expectedName)));
+ }
- private void verifyString( String nodePath,
- String property,
- String expectedString ) {
- String string = verify(nodePath, property, String.class);
- assertThat(string, is(expectedString));
- }
+ private void verifyString( String nodePath,
+ String property,
+ String expectedString ) {
+ String string = verify(nodePath, property, String.class);
+ assertThat(string, is(expectedString));
+ }
}
Modified: trunk/dna-repository/src/test/java/org/jboss/dna/repository/util/JndiSessionFactoryTest.java
===================================================================
--- trunk/dna-repository/src/test/java/org/jboss/dna/repository/util/JndiSessionFactoryTest.java 2008-06-10 23:13:20 UTC (rev 261)
+++ trunk/dna-repository/src/test/java/org/jboss/dna/repository/util/JndiSessionFactoryTest.java 2008-06-10 23:32:20 UTC (rev 262)
@@ -59,7 +59,7 @@
}
@After
- public void afterEach() throws Exception {
+ public void afterEach() {
if (session != null) {
session.logout();
}
@@ -75,7 +75,8 @@
}
}
- protected void assertRegistered( String name, Object obj ) {
+ protected void assertRegistered( String name,
+ Object obj ) {
try {
assertThat(new InitialContext().lookup(name), is(sameInstance(obj)));
} catch (NamingException e) {
@@ -124,21 +125,21 @@
}
@Test
- public void shouldRegisterSuppliedRepositoryInJndi() throws Exception {
+ public void shouldRegisterSuppliedRepositoryInJndi() {
assertNotRegistered(MOCK_REPOSITORY_NAME_ALT);
factory.registerRepository(MOCK_REPOSITORY_NAME_ALT, mockRepository);
assertRegistered(MOCK_REPOSITORY_NAME_ALT, mockRepository);
}
@Test
- public void shouldUnregisterRepositoryInJndiIfNullRepositoryReference() throws Exception {
+ public void shouldUnregisterRepositoryInJndiIfNullRepositoryReference() {
assertRegistered(MOCK_REPOSITORY_NAME, mockRepository);
factory.registerRepository(MOCK_REPOSITORY_NAME, null);
assertNotRegistered(MOCK_REPOSITORY_NAME);
}
@Test
- public void shouldRemoveAllTrailingDelimitersWhenRegisteringRepository() throws Exception {
+ public void shouldRemoveAllTrailingDelimitersWhenRegisteringRepository() {
assertNotRegistered("java:jcr/unit/test/repository");
factory.registerRepository("java:jcr/unit/test/repository///", mockRepository);
assertRegistered("java:jcr/unit/test/repository", mockRepository);
Modified: trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/connection/RepositoryConnectionPoolTest.java
===================================================================
--- trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/connection/RepositoryConnectionPoolTest.java 2008-06-10 23:13:20 UTC (rev 261)
+++ trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/connection/RepositoryConnectionPoolTest.java 2008-06-10 23:32:20 UTC (rev 262)
@@ -43,7 +43,7 @@
private ExecutionEnvironment env;
@Before
- public void beforeEach() throws Exception {
+ public void beforeEach() {
this.repositorySource = new TimeDelayingRepositorySource("source 1");
this.pool = new RepositoryConnectionPool(this.repositorySource, 1, 1, 100, TimeUnit.SECONDS);
this.env = null;
@@ -101,7 +101,8 @@
}
@Test
- public void shouldAllowShutdownToBeCalledMultipleTimesEvenWhenShutdown() throws RepositorySourceException, InterruptedException {
+ public void shouldAllowShutdownToBeCalledMultipleTimesEvenWhenShutdown()
+ throws RepositorySourceException, InterruptedException {
assertThat(pool.getTotalConnectionsCreated(), is(0l));
assertThat(pool.getTotalConnectionsUsed(), is(0l));
@@ -140,7 +141,8 @@
}
@Test
- public void shouldAllowConnectionsToBeClosedMoreThanOnceWithNoIllEffects() throws RepositorySourceException, InterruptedException {
+ public void shouldAllowConnectionsToBeClosedMoreThanOnceWithNoIllEffects()
+ throws RepositorySourceException, InterruptedException {
assertThat(pool.getTotalConnectionsCreated(), is(0l));
assertThat(pool.getTotalConnectionsUsed(), is(0l));
@@ -161,7 +163,8 @@
RepositoryConnectionPool pool = new RepositoryConnectionPool(repositorySource);
pool.setCorePoolSize(numConnectionsInPool);
pool.setMaximumPoolSize(numConnectionsInPool);
- RepositoryOperation.Factory<Integer> operationFactory = RepositorySourceLoadHarness.createMultipleLoadOperationFactory(env, 10);
+ RepositoryOperation.Factory<Integer> operationFactory = RepositorySourceLoadHarness.createMultipleLoadOperationFactory(env,
+ 10);
runLoadTest(pool, numClients, 100, TimeUnit.MILLISECONDS, operationFactory);
pool.shutdown();
pool.awaitTermination(4, TimeUnit.SECONDS);
@@ -174,7 +177,8 @@
RepositoryConnectionPool pool = new RepositoryConnectionPool(repositorySource);
pool.setCorePoolSize(numConnectionsInPool);
pool.setMaximumPoolSize(numConnectionsInPool);
- RepositoryOperation.Factory<Integer> operationFactory = RepositorySourceLoadHarness.createMultipleLoadOperationFactory(env, 10);
+ RepositoryOperation.Factory<Integer> operationFactory = RepositorySourceLoadHarness.createMultipleLoadOperationFactory(env,
+ 10);
runLoadTest(pool, numClients, 100, TimeUnit.MILLISECONDS, operationFactory);
pool.shutdown();
pool.awaitTermination(4, TimeUnit.SECONDS);
@@ -187,7 +191,8 @@
RepositoryConnectionPool pool = new RepositoryConnectionPool(repositorySource);
pool.setCorePoolSize(numConnectionsInPool);
pool.setMaximumPoolSize(numConnectionsInPool);
- RepositoryOperation.Factory<Integer> operationFactory = RepositorySourceLoadHarness.createMultipleLoadOperationFactory(env, 10);
+ RepositoryOperation.Factory<Integer> operationFactory = RepositorySourceLoadHarness.createMultipleLoadOperationFactory(env,
+ 10);
runLoadTest(pool, numClients, 100, TimeUnit.MILLISECONDS, operationFactory);
pool.shutdown();
pool.awaitTermination(4, TimeUnit.SECONDS);
@@ -201,7 +206,8 @@
RepositoryConnectionPool pool = new RepositoryConnectionPool(repositorySource);
pool.setCorePoolSize(numConnectionsInPool);
pool.setMaximumPoolSize(numConnectionsInPool);
- RepositoryOperation.Factory<Integer> operationFactory = RepositorySourceLoadHarness.createMultipleLoadOperationFactory(env, 20);
+ RepositoryOperation.Factory<Integer> operationFactory = RepositorySourceLoadHarness.createMultipleLoadOperationFactory(env,
+ 20);
List<Future<Integer>> results = runLoadTest(pool, numClients, 200, TimeUnit.MILLISECONDS, operationFactory);
int total = 0;
for (Future<Integer> result : results) {
Modified: trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/connection/TimeDelayingRepositorySource.java
===================================================================
--- trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/connection/TimeDelayingRepositorySource.java 2008-06-10 23:13:20 UTC (rev 261)
+++ trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/connection/TimeDelayingRepositorySource.java 2008-06-10 23:32:20 UTC (rev 262)
@@ -106,7 +106,8 @@
return this.loadDelay.get();
}
- public void setConnectionExecuteDelay( long time, TimeUnit unit ) {
+ public void setConnectionExecuteDelay( long time,
+ TimeUnit unit ) {
this.loadDelay.set(unit.toMillis(time));
}
@@ -117,7 +118,8 @@
return this.pingDelay.get();
}
- public void setConnectionPingDelay( long time, TimeUnit unit ) {
+ public void setConnectionPingDelay( long time,
+ TimeUnit unit ) {
this.pingDelay.set(unit.toMillis(time));
}
@@ -152,7 +154,8 @@
* @return
* @throws RepositorySourceException
*/
- protected Connection newConnection( String connectionName, XAResource xaResource ) throws RepositorySourceException {
+ protected Connection newConnection( String connectionName,
+ XAResource xaResource ) throws RepositorySourceException {
Connection c = new Connection(connectionName, this.loadDelay.get(), this.pingDelay.get());
c.setXaResource(xaResource);
return c;
@@ -198,7 +201,9 @@
private final AtomicLong pingDelay;
private final AtomicReference<XAResource> xaResource = new AtomicReference<XAResource>();
- protected Connection( String connectionName, long loadDelay, long pingDelay ) {
+ protected Connection( String connectionName,
+ long loadDelay,
+ long pingDelay ) {
assert connectionName != null && connectionName.trim().length() != 0;
this.loadDelay = new AtomicLong(loadDelay);
this.pingDelay = new AtomicLong(pingDelay);
@@ -246,7 +251,8 @@
/**
* {@inheritDoc}
*/
- public void execute( ExecutionEnvironment env, GraphCommand... commands ) throws RepositorySourceException, InterruptedException {
+ public void execute( ExecutionEnvironment env,
+ GraphCommand... commands ) throws InterruptedException {
long delay = this.loadDelay.get();
if (delay > 0l) Thread.sleep(delay);
this.loadCount.incrementAndGet();
@@ -256,14 +262,16 @@
this.loadResponse.set(response);
}
- public void setLoadDelay( long time, TimeUnit unit ) {
+ public void setLoadDelay( long time,
+ TimeUnit unit ) {
this.loadDelay.set(unit.toMillis(time));
}
/**
* {@inheritDoc}
*/
- public boolean ping( long time, TimeUnit unit ) throws InterruptedException {
+ public boolean ping( long time,
+ TimeUnit unit ) throws InterruptedException {
Thread.sleep(this.pingDelay.get());
return this.pingResponse.get();
}
@@ -272,7 +280,8 @@
this.pingResponse.set(pingResponse);
}
- public void setPingDelay( long time, TimeUnit unit ) {
+ public void setPingDelay( long time,
+ TimeUnit unit ) {
this.pingDelay.set(unit.toMillis(time));
}
Modified: trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/AbstractValueFactoryTest.java
===================================================================
--- trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/AbstractValueFactoryTest.java 2008-06-10 23:13:20 UTC (rev 261)
+++ trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/AbstractValueFactoryTest.java 2008-06-10 23:32:20 UTC (rev 262)
@@ -39,7 +39,6 @@
import org.jboss.dna.spi.graph.PropertyType;
import org.jboss.dna.spi.graph.Reference;
import org.jboss.dna.spi.graph.ValueFactory;
-import org.jboss.dna.spi.graph.IoException;
import org.junit.Before;
import org.junit.Test;
@@ -52,75 +51,79 @@
private static class MockFactory extends AbstractValueFactory<String> {
- protected MockFactory( TextDecoder decoder, StringValueFactory stringValueFactory ) {
+ protected MockFactory( TextDecoder decoder,
+ StringValueFactory stringValueFactory ) {
super(PropertyType.STRING, decoder, stringValueFactory);
}
- public String create( String value ) throws IoException {
+ public String create( String value ) {
return null;
}
- public String create( String value, TextDecoder decoder ) throws IoException {
+ public String create( String value,
+ TextDecoder decoder ) {
return null;
}
- public String create( int value ) throws IoException {
+ public String create( int value ) {
return null;
}
- public String create( long value ) throws IoException {
+ public String create( long value ) {
return null;
}
- public String create( boolean value ) throws IoException {
+ public String create( boolean value ) {
return null;
}
- public String create( float value ) throws IoException {
+ public String create( float value ) {
return null;
}
- public String create( double value ) throws IoException {
+ public String create( double value ) {
return null;
}
- public String create( BigDecimal value ) throws IoException {
+ public String create( BigDecimal value ) {
return null;
}
- public String create( Calendar value ) throws IoException {
+ public String create( Calendar value ) {
return null;
}
- public String create( Date value ) throws IoException {
+ public String create( Date value ) {
return null;
}
- public String create( Name value ) throws IoException {
+ public String create( Name value ) {
return null;
}
- public String create( Path value ) throws IoException {
+ public String create( Path value ) {
return null;
}
- public String create( Reference value ) throws IoException {
+ public String create( Reference value ) {
return null;
}
- public String create( URI value ) throws IoException {
+ public String create( URI value ) {
return null;
}
- public String create( byte[] value ) throws IoException {
+ public String create( byte[] value ) {
return null;
}
- public String create( InputStream stream, int approximateLength ) throws IoException {
+ public String create( InputStream stream,
+ int approximateLength ) {
return null;
}
- public String create( Reader reader, int approximateLength ) throws IoException {
+ public String create( Reader reader,
+ int approximateLength ) {
return null;
}
}
@@ -128,7 +131,7 @@
private AbstractValueFactory factory;
@Before
- public void beforeEach() throws Exception {
+ public void beforeEach() {
factory = new MockFactory(null, null);
}
Modified: trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/BasicNameTest.java
===================================================================
--- trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/BasicNameTest.java 2008-06-10 23:13:20 UTC (rev 261)
+++ trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/BasicNameTest.java 2008-06-10 23:32:20 UTC (rev 262)
@@ -44,7 +44,7 @@
private String validNamespacePrefix;
@Before
- public void beforeEach() throws Exception {
+ public void beforeEach() {
this.validNamespaceUri = "http://www.jboss.org/dna";
this.validLocalName = "localPart";
this.validNamespacePrefix = "dna";
@@ -76,13 +76,13 @@
}
@Test( expected = IllegalArgumentException.class )
- public void shouldNotAllowNullLocalNameInConstructor() {
- new BasicName(validNamespaceUri, null);
+ public void shouldNotAllowNullLocalNameInConstructor() {
+ new BasicName(validNamespaceUri, null);
}
@Test( expected = IllegalArgumentException.class )
- public void shouldAllowEmptyLocalNameInConstructor() {
- new BasicName(validNamespaceUri, "");
+ public void shouldAllowEmptyLocalNameInConstructor() {
+ new BasicName(validNamespaceUri, "");
}
@Test
Modified: trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/BasicNamespaceRegistryTest.java
===================================================================
--- trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/BasicNamespaceRegistryTest.java 2008-06-10 23:13:20 UTC (rev 261)
+++ trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/BasicNamespaceRegistryTest.java 2008-06-10 23:32:20 UTC (rev 262)
@@ -41,7 +41,7 @@
private BasicNamespaceRegistry namespaceRegistry;
@Before
- public void setUp() throws Exception {
+ public void setUp() {
namespaceRegistry = new BasicNamespaceRegistry();
validNamespaceUri1 = "http://www.jboss.org/dna/2";
validNamespaceUri2 = "http://acme.com/something";
Modified: trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/BasicPathSegmentTest.java
===================================================================
--- trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/BasicPathSegmentTest.java 2008-06-10 23:13:20 UTC (rev 261)
+++ trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/BasicPathSegmentTest.java 2008-06-10 23:32:20 UTC (rev 262)
@@ -46,7 +46,7 @@
private Path.Segment segment2;
@Before
- public void beforeEach() throws Exception {
+ public void beforeEach() {
this.registry = new BasicNamespaceRegistry();
this.registry.register("dna", "http://www.jboss.org/dna/namespace");
this.stringValueFactory = new StringValueFactory(Path.DEFAULT_DECODER, Path.DEFAULT_ENCODER);
Modified: trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/BasicPathTest.java
===================================================================
--- trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/BasicPathTest.java 2008-06-10 23:13:20 UTC (rev 261)
+++ trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/BasicPathTest.java 2008-06-10 23:32:20 UTC (rev 262)
@@ -59,7 +59,7 @@
private PathValueFactory pathFactory;
@Before
- public void beforeEach() throws Exception {
+ public void beforeEach() {
validNamespacePrefix = "dna";
validNamespaceUri = "http://www.jboss.org/dna";
validSegmentNames = new Name[] {new BasicName(validNamespaceUri, "a"), new BasicName(validNamespaceUri, "b"),
Modified: trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/BooleanValueFactoryTest.java
===================================================================
--- trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/BooleanValueFactoryTest.java 2008-06-10 23:13:20 UTC (rev 261)
+++ trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/BooleanValueFactoryTest.java 2008-06-10 23:32:20 UTC (rev 262)
@@ -157,7 +157,7 @@
}
@Test
- public void shouldCreateBooleanFromReaderContainingTrueOrFalseStringRegardlessOfCase() throws Exception {
+ public void shouldCreateBooleanFromReaderContainingTrueOrFalseStringRegardlessOfCase() {
assertThat(factory.create(new StringReader("true")), is(true));
assertThat(factory.create(new StringReader("false")), is(false));
assertThat(factory.create(new StringReader("TRUE")), is(true));
Modified: trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/DecimalValueFactoryTest.java
===================================================================
--- trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/DecimalValueFactoryTest.java 2008-06-10 23:13:20 UTC (rev 261)
+++ trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/DecimalValueFactoryTest.java 2008-06-10 23:32:20 UTC (rev 262)
@@ -146,7 +146,7 @@
}
@Test
- public void shouldCreateDecimalFromReaderContainingStringWithDecimal() throws Exception {
+ public void shouldCreateDecimalFromReaderContainingStringWithDecimal() {
assertThat(factory.create(new StringReader("1")), is(BigDecimal.valueOf(1l)));
assertThat(factory.create(new StringReader("-1.0")), is(BigDecimal.valueOf(-1.d)));
assertThat(factory.create(new StringReader("100.000101")), is(BigDecimal.valueOf(100.000101d)));
@@ -158,12 +158,13 @@
}
@Test( expected = IllegalArgumentException.class )
- public void shouldNotCreateDecimalFromInputStreamContainingUtf8EncodingOfStringWithContentsOtherThanDecimal() throws Exception {
+ public void shouldNotCreateDecimalFromInputStreamContainingUtf8EncodingOfStringWithContentsOtherThanDecimal()
+ throws Exception {
factory.create(new ByteArrayInputStream("something".getBytes("UTF-8")));
}
@Test( expected = IllegalArgumentException.class )
- public void shouldNotCreateDecimalFromReaderContainingStringWithContentsOtherThanDecimal() throws Exception {
+ public void shouldNotCreateDecimalFromReaderContainingStringWithContentsOtherThanDecimal() {
factory.create(new StringReader("something"));
}
}
Modified: trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/DoubleValueFactoryTest.java
===================================================================
--- trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/DoubleValueFactoryTest.java 2008-06-10 23:13:20 UTC (rev 261)
+++ trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/DoubleValueFactoryTest.java 2008-06-10 23:32:20 UTC (rev 262)
@@ -148,7 +148,7 @@
}
@Test
- public void shouldCreateDoubleFromReaderContainingStringWithDouble() throws Exception {
+ public void shouldCreateDoubleFromReaderContainingStringWithDouble() {
assertThat(factory.create(new StringReader("0.1")), is(0.1d));
assertThat(factory.create(new StringReader("1")), is(1.0d));
assertThat(factory.create(new StringReader("-1.03")), is(-1.03));
Modified: trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/JodaDateTimeValueFactoryTest.java
===================================================================
--- trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/JodaDateTimeValueFactoryTest.java 2008-06-10 23:13:20 UTC (rev 261)
+++ trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/JodaDateTimeValueFactoryTest.java 2008-06-10 23:32:20 UTC (rev 262)
@@ -156,18 +156,20 @@
}
@Test
- public void shouldCreateDateFromReaderContainingStringWithWellFormedDate() throws Exception {
+ public void shouldCreateDateFromReaderContainingStringWithWellFormedDate() {
assertThat(factory.create(new StringReader(TODAY.getString())), is(TODAY));
assertThat(factory.create(new StringReader(LAST_YEAR.getString())), is(LAST_YEAR));
}
@Test( expected = IllegalArgumentException.class )
- public void shouldNotCreateDateFromByteArrayContainingUtf8EncodingOfStringWithContentThatIsNotWellFormedDate() throws Exception {
+ public void shouldNotCreateDateFromByteArrayContainingUtf8EncodingOfStringWithContentThatIsNotWellFormedDate()
+ throws Exception {
factory.create("something".getBytes("UTF-8"));
}
@Test( expected = IllegalArgumentException.class )
- public void shouldNotCreateDateFromInputStreamContainingUtf8EncodingOfStringWithContentThatIsNotWellFormedDate() throws Exception {
+ public void shouldNotCreateDateFromInputStreamContainingUtf8EncodingOfStringWithContentThatIsNotWellFormedDate()
+ throws Exception {
factory.create(new ByteArrayInputStream("something".getBytes("UTF-8")));
}
Modified: trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/LongValueFactoryTest.java
===================================================================
--- trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/LongValueFactoryTest.java 2008-06-10 23:13:20 UTC (rev 261)
+++ trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/LongValueFactoryTest.java 2008-06-10 23:32:20 UTC (rev 262)
@@ -150,7 +150,7 @@
}
@Test
- public void shouldCreateLongFromReaderContainingStringWithLong() throws Exception {
+ public void shouldCreateLongFromReaderContainingStringWithLong() {
assertThat(factory.create(new StringReader("0")), is(0l));
assertThat(factory.create(new StringReader("10")), is(10l));
assertThat(factory.create(new StringReader("-103")), is(-103l));
Modified: trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/NameValueFactoryTest.java
===================================================================
--- trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/NameValueFactoryTest.java 2008-06-10 23:13:20 UTC (rev 261)
+++ trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/NameValueFactoryTest.java 2008-06-10 23:32:20 UTC (rev 262)
@@ -48,7 +48,7 @@
private Name name;
@Before
- public void beforeEach() throws Exception {
+ public void beforeEach() {
this.registry = new BasicNamespaceRegistry();
this.registry.register("dna", "http://www.jboss.org/dna/namespace");
this.encoder = Path.DEFAULT_ENCODER;
Modified: trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/PathValueFactoryTest.java
===================================================================
--- trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/PathValueFactoryTest.java 2008-06-10 23:13:20 UTC (rev 261)
+++ trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/PathValueFactoryTest.java 2008-06-10 23:32:20 UTC (rev 262)
@@ -48,7 +48,7 @@
private Path path2;
@Before
- public void beforeEach() throws Exception {
+ public void beforeEach() {
this.registry = new BasicNamespaceRegistry();
this.registry.register("dna", "http://www.jboss.org/dna/namespace");
this.stringValueFactory = new StringValueFactory(Path.DEFAULT_DECODER, Path.DEFAULT_ENCODER);
Modified: trunk/docs/examples/gettingstarted/sequencers/src/main/java/org/jboss/example/dna/sequencers/SequencingClient.java
===================================================================
--- trunk/docs/examples/gettingstarted/sequencers/src/main/java/org/jboss/example/dna/sequencers/SequencingClient.java 2008-06-10 23:13:20 UTC (rev 261)
+++ trunk/docs/examples/gettingstarted/sequencers/src/main/java/org/jboss/example/dna/sequencers/SequencingClient.java 2008-06-10 23:32:20 UTC (rev 262)
@@ -65,7 +65,7 @@
public static final String DEFAULT_USERNAME = "jsmith";
public static final char[] DEFAULT_PASSWORD = "secret".toCharArray();
- public static void main( String[] args ) throws Exception {
+ public static void main( String[] args ) {
SequencingClient client = new SequencingClient();
client.setRepositoryInformation(DEFAULT_REPOSITORY_NAME, DEFAULT_WORKSPACE_NAME, DEFAULT_USERNAME, DEFAULT_PASSWORD);
client.setUserInterface(new ConsoleInput(client));
@@ -98,7 +98,10 @@
this.jackrabbitConfigPath = jackrabbitConfigPath != null ? jackrabbitConfigPath : DEFAULT_JACKRABBIT_CONFIG_PATH;
}
- protected void setRepositoryInformation( String repositoryName, String workspaceName, String username, char[] password ) {
+ protected void setRepositoryInformation( String repositoryName,
+ String workspaceName,
+ String username,
+ char[] password ) {
if (this.repository != null) {
throw new IllegalArgumentException("Unable to set repository information when repository is already running");
}
@@ -110,6 +113,7 @@
/**
* Set the user interface that this client should use.
+ *
* @param userInterface
*/
public void setUserInterface( UserInterface userInterface ) {
@@ -118,6 +122,7 @@
/**
* Start up the JCR repository. This method only operates using the JCR API and Jackrabbit-specific API.
+ *
* @throws Exception
*/
public void startRepository() throws Exception {
@@ -127,10 +132,12 @@
// Load the Jackrabbit configuration ...
File configFile = new File(this.jackrabbitConfigPath);
if (!configFile.exists()) {
- throw new SystemFailureException("The Jackrabbit configuration file cannot be found at " + configFile.getAbsoluteFile());
+ throw new SystemFailureException("The Jackrabbit configuration file cannot be found at "
+ + configFile.getAbsoluteFile());
}
if (!configFile.canRead()) {
- throw new SystemFailureException("Unable to read the Jackrabbit configuration file at " + configFile.getAbsoluteFile());
+ throw new SystemFailureException("Unable to read the Jackrabbit configuration file at "
+ + configFile.getAbsoluteFile());
}
String pathToConfig = configFile.getAbsolutePath();
@@ -138,7 +145,8 @@
File workingDirectory = new File(this.workingDirectory);
if (workingDirectory.exists()) {
if (!workingDirectory.isDirectory()) {
- throw new SystemFailureException("Unable to create working directory at " + workingDirectory.getAbsolutePath());
+ throw new SystemFailureException("Unable to create working directory at "
+ + workingDirectory.getAbsolutePath());
}
}
String workingDirectoryPath = workingDirectory.getAbsolutePath();
@@ -173,6 +181,7 @@
/**
* Shutdown the repository. This method only uses the JCR API.
+ *
* @throws Exception
*/
public void shutdownRepository() throws Exception {
@@ -188,6 +197,7 @@
/**
* Start the DNA services.
+ *
* @throws Exception
*/
public void startDnaServices() throws Exception {
@@ -248,7 +258,8 @@
this.observationService = new ObservationService(this.executionContext.getSessionFactory());
this.observationService.getAdministrator().start();
this.observationService.addListener(this.sequencingService);
- this.observationService.monitor(repositoryWorkspaceName, Event.NODE_ADDED | Event.PROPERTY_ADDED | Event.PROPERTY_CHANGED);
+ this.observationService.monitor(repositoryWorkspaceName, Event.NODE_ADDED | Event.PROPERTY_ADDED
+ | Event.PROPERTY_CHANGED);
}
// Start up the sequencing service ...
this.sequencingService.getAdministrator().start();
@@ -256,6 +267,7 @@
/**
* Shut down the DNA services.
+ *
* @throws Exception
*/
public void shutdownDnaServices() throws Exception {
@@ -272,6 +284,7 @@
/**
* Get the sequencing statistics.
+ *
* @return the statistics; never null
*/
public SequencingService.Statistics getStatistics() {
@@ -280,6 +293,7 @@
/**
* Prompt the user interface for the file to upload into the JCR repository, then upload it using the JCR API.
+ *
* @throws Exception
*/
public void uploadFile() throws Exception {
@@ -311,6 +325,7 @@
/**
* Perform a search of the repository for all image metadata automatically created by the image sequencer.
+ *
* @throws Exception
*/
public void search() throws Exception {
@@ -361,7 +376,9 @@
* @throws PathNotFoundException
* @throws ValueFormatException
*/
- private MediaInfo extractMediaInfo( String metadataNodeName, String mediaType, Node mediaNode ) throws RepositoryException, PathNotFoundException, ValueFormatException {
+ private MediaInfo extractMediaInfo( String metadataNodeName,
+ String mediaType,
+ Node mediaNode ) throws RepositoryException, PathNotFoundException, ValueFormatException {
String nodePath = mediaNode.getPath();
String nodeName = mediaNode.getName();
mediaNode = mediaNode.getNode(metadataNodeName);
@@ -394,6 +411,7 @@
/**
* Utility method to create a new JCR session from the execution context's {@link SessionFactory}.
+ *
* @return the session
* @throws RepositoryException
*/
Modified: trunk/docs/examples/gettingstarted/sequencers/src/test/java/org/jboss/example/dna/sequencers/MockUserInterface.java
===================================================================
--- trunk/docs/examples/gettingstarted/sequencers/src/test/java/org/jboss/example/dna/sequencers/MockUserInterface.java 2008-06-10 23:13:20 UTC (rev 261)
+++ trunk/docs/examples/gettingstarted/sequencers/src/test/java/org/jboss/example/dna/sequencers/MockUserInterface.java 2008-06-10 23:32:20 UTC (rev 262)
@@ -35,7 +35,9 @@
private final URL fileToUpload;
private final int numberOfSearchResults;
- public MockUserInterface( URL fileToUpload, String repositoryPath, int numSearchResults ) {
+ public MockUserInterface( URL fileToUpload,
+ String repositoryPath,
+ int numSearchResults ) {
this.repositoryPath = repositoryPath;
this.fileToUpload = fileToUpload;
this.numberOfSearchResults = numSearchResults;
@@ -54,7 +56,7 @@
/**
* {@inheritDoc}
*/
- public URL getFileToUpload() throws IllegalArgumentException {
+ public URL getFileToUpload() {
return this.fileToUpload;
}
Modified: trunk/docs/examples/gettingstarted/sequencers/src/test/java/org/jboss/example/dna/sequencers/SequencingClientTest.java
===================================================================
--- trunk/docs/examples/gettingstarted/sequencers/src/test/java/org/jboss/example/dna/sequencers/SequencingClientTest.java 2008-06-10 23:13:20 UTC (rev 261)
+++ trunk/docs/examples/gettingstarted/sequencers/src/test/java/org/jboss/example/dna/sequencers/SequencingClientTest.java 2008-06-10 23:32:20 UTC (rev 262)
@@ -42,7 +42,7 @@
private SequencingClient client;
@Before
- public void beforeEach() throws Exception {
+ public void beforeEach() {
this.pngImageUrl = Thread.currentThread().getContextClassLoader().getResource("caution.png");
this.pictImageUrl = Thread.currentThread().getContextClassLoader().getResource("caution.pict");
this.jpegImageUrl = Thread.currentThread().getContextClassLoader().getResource("caution.jpg");
Modified: trunk/sequencers/dna-sequencer-images/src/test/java/org/jboss/dna/sequencer/images/ImageMetadataSequencerTest.java
===================================================================
--- trunk/sequencers/dna-sequencer-images/src/test/java/org/jboss/dna/sequencer/images/ImageMetadataSequencerTest.java 2008-06-10 23:13:20 UTC (rev 261)
+++ trunk/sequencers/dna-sequencer-images/src/test/java/org/jboss/dna/sequencer/images/ImageMetadataSequencerTest.java 2008-06-10 23:32:20 UTC (rev 262)
@@ -50,10 +50,10 @@
private URL cautionPng;
@Before
- public void beforeEach() throws Exception {
+ public void beforeEach() {
this.sequencer = new ImageMetadataSequencer();
this.output = new MockSequencerOutput();
- output.getNamespaceRegistry().register("image", "http://jboss.org/dna/images/1.0");
+ output.getNamespaceRegistry().register("image", "http://jboss.org/dna/images/1.0");
this.progress = new SimpleProgressMonitor("Test activity");
this.cautionGif = this.getClass().getClassLoader().getResource("caution.gif");
this.cautionJpg = this.getClass().getClassLoader().getResource("caution.jpg");
@@ -89,8 +89,10 @@
assertThat(output.getPropertyValues("image:metadata", "image:numberOfImages"), is(new Object[] {1}));
assertThat(output.getPropertyValues("image:metadata", "image:physicalWidthDpi"), is(new Object[] {72}));
assertThat(output.getPropertyValues("image:metadata", "image:physicalHeightDpi"), is(new Object[] {72}));
- assertThat(((Float)(output.getPropertyValues("image:metadata", "image:physicalWidthInches")[0])).doubleValue(), is(closeTo(0.666667d, 0.0001d)));
- assertThat(((Float)(output.getPropertyValues("image:metadata", "image:physicalHeightInches")[0])).doubleValue(), is(closeTo(0.666667d, 0.0001d)));
+ assertThat(((Float)(output.getPropertyValues("image:metadata", "image:physicalWidthInches")[0])).doubleValue(),
+ is(closeTo(0.666667d, 0.0001d)));
+ assertThat(((Float)(output.getPropertyValues("image:metadata", "image:physicalHeightInches")[0])).doubleValue(),
+ is(closeTo(0.666667d, 0.0001d)));
}
@Test
Modified: trunk/sequencers/dna-sequencer-images/src/test/java/org/jboss/dna/sequencer/images/ImageMetadataTest.java
===================================================================
--- trunk/sequencers/dna-sequencer-images/src/test/java/org/jboss/dna/sequencer/images/ImageMetadataTest.java 2008-06-10 23:13:20 UTC (rev 261)
+++ trunk/sequencers/dna-sequencer-images/src/test/java/org/jboss/dna/sequencer/images/ImageMetadataTest.java 2008-06-10 23:32:20 UTC (rev 262)
@@ -39,7 +39,7 @@
private InputStream imageStream;
@Before
- public void beforeEach() throws Exception {
+ public void beforeEach() {
this.image = new ImageMetadata();
}
17 years, 6 months
DNA SVN: r261 - trunk/dna-repository/src/main/java/org/jboss/dna/repository/rules.
by dna-commits@lists.jboss.org
Author: jverhaeg(a)redhat.com
Date: 2008-06-10 19:13:20 -0400 (Tue, 10 Jun 2008)
New Revision: 261
Modified:
trunk/dna-repository/src/main/java/org/jboss/dna/repository/rules/RuleSetRepositoryMonitor.java
Log:
DNA-75: Added ability to add problems to a progress monitor. Also clarified some documentation and removed NullProgressMonitor (used only for testing) in lieu of using a mock object.
Modified: trunk/dna-repository/src/main/java/org/jboss/dna/repository/rules/RuleSetRepositoryMonitor.java
===================================================================
--- trunk/dna-repository/src/main/java/org/jboss/dna/repository/rules/RuleSetRepositoryMonitor.java 2008-06-10 22:16:01 UTC (rev 260)
+++ trunk/dna-repository/src/main/java/org/jboss/dna/repository/rules/RuleSetRepositoryMonitor.java 2008-06-10 23:13:20 UTC (rev 261)
@@ -34,7 +34,7 @@
import javax.jcr.RepositoryException;
import javax.jcr.Session;
import net.jcip.annotations.ThreadSafe;
-import org.jboss.dna.common.collection.Problems;
+import org.jboss.dna.common.collection.SimpleProblems;
import org.jboss.dna.common.util.ArgCheck;
import org.jboss.dna.common.util.Logger;
import org.jboss.dna.repository.RepositoryI18n;
@@ -228,18 +228,18 @@
protected RuleSet buildRuleSet( String name, Node ruleSetNode, JcrTools tools ) {
if (ruleSetNode == null) return null;
- Problems problems = new Problems();
- String description = tools.getPropertyAsString(ruleSetNode, "jcr:description", false, problems);
- String classname = tools.getPropertyAsString(ruleSetNode, "dna:classname", true, problems);
- String[] classpath = tools.getPropertyAsStringArray(ruleSetNode, "dna:classpath", false, problems);
- String providerUri = tools.getPropertyAsString(ruleSetNode, "dna:serviceProviderUri", true, problems);
- String ruleSetUri = tools.getPropertyAsString(ruleSetNode, "dna:ruleSetUri", true, name, problems);
- String rules = tools.getPropertyAsString(ruleSetNode, "dna:rules", true, problems);
- Map<String, Object> properties = tools.loadProperties(ruleSetNode, problems);
- if (problems.hasProblems()) {
+ SimpleProblems simpleProblems = new SimpleProblems();
+ String description = tools.getPropertyAsString(ruleSetNode, "jcr:description", false, simpleProblems);
+ String classname = tools.getPropertyAsString(ruleSetNode, "dna:classname", true, simpleProblems);
+ String[] classpath = tools.getPropertyAsStringArray(ruleSetNode, "dna:classpath", false, simpleProblems);
+ String providerUri = tools.getPropertyAsString(ruleSetNode, "dna:serviceProviderUri", true, simpleProblems);
+ String ruleSetUri = tools.getPropertyAsString(ruleSetNode, "dna:ruleSetUri", true, name, simpleProblems);
+ String rules = tools.getPropertyAsString(ruleSetNode, "dna:rules", true, simpleProblems);
+ Map<String, Object> properties = tools.loadProperties(ruleSetNode, simpleProblems);
+ if (simpleProblems.hasProblems()) {
// There are problems, so store and save them, and then return null ...
try {
- if (tools.storeProblems(ruleSetNode, problems)) ruleSetNode.save();
+ if (tools.storeProblems(ruleSetNode, simpleProblems)) ruleSetNode.save();
} catch (RepositoryException e) {
this.logger.error(e, RepositoryI18n.errorWritingProblemsOnRuleSet, tools.getReadable(ruleSetNode));
}
17 years, 6 months
DNA SVN: r260 - in trunk/dna-common/src: main/java/org/jboss/dna/common/monitor and 2 other directories.
by dna-commits@lists.jboss.org
Author: jverhaeg(a)redhat.com
Date: 2008-06-10 18:16:01 -0400 (Tue, 10 Jun 2008)
New Revision: 260
Added:
trunk/dna-common/src/main/java/org/jboss/dna/common/collection/Problems.java
trunk/dna-common/src/main/java/org/jboss/dna/common/collection/SimpleProblems.java
Removed:
trunk/dna-common/src/main/java/org/jboss/dna/common/collection/Problems.java
trunk/dna-common/src/main/java/org/jboss/dna/common/monitor/NullProgressMonitor.java
Modified:
trunk/dna-common/src/main/java/org/jboss/dna/common/collection/UnmodifiableProperties.java
trunk/dna-common/src/main/java/org/jboss/dna/common/monitor/ProgressMonitor.java
trunk/dna-common/src/main/java/org/jboss/dna/common/monitor/ProgressMonitorWrapper.java
trunk/dna-common/src/main/java/org/jboss/dna/common/monitor/SimpleProgressMonitor.java
trunk/dna-common/src/main/java/org/jboss/dna/common/monitor/SubProgressMonitor.java
trunk/dna-common/src/test/java/org/jboss/dna/common/component/ComponentLibraryTest.java
trunk/dna-common/src/test/java/org/jboss/dna/common/monitor/SimpleProgressMonitorTest.java
Log:
DNA-75: Added ability to add problems to a progress monitor. Also clarified some documentation and removed NullProgressMonitor (used only for testing) in lieu of using a mock object.
Deleted: trunk/dna-common/src/main/java/org/jboss/dna/common/collection/Problems.java
===================================================================
--- trunk/dna-common/src/main/java/org/jboss/dna/common/collection/Problems.java 2008-06-10 22:05:23 UTC (rev 259)
+++ trunk/dna-common/src/main/java/org/jboss/dna/common/collection/Problems.java 2008-06-10 22:16:01 UTC (rev 260)
@@ -1,187 +0,0 @@
-/*
- * 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.common.collection;
-
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import net.jcip.annotations.NotThreadSafe;
-import org.jboss.dna.common.i18n.I18n;
-
-/**
- * @author Randall Hauch
- */
-@NotThreadSafe
-public class Problems implements Iterable<Problem> {
-
- private List<Problem> problems;
-
- public Problems() {
- }
-
- public void addError( I18n message, Object... params ) {
- addProblem(new Problem(Problem.Status.ERROR, Problem.DEFAULT_CODE, message, params));
- }
-
- public void addError( Throwable throwable, I18n message, Object... params ) {
- addProblem(new Problem(Problem.Status.ERROR, Problem.DEFAULT_CODE, message, null, null, throwable));
- }
-
- public void addError( I18n message, String resource, String location, Object... params ) {
- addProblem(new Problem(Problem.Status.ERROR, Problem.DEFAULT_CODE, message, resource, location));
- }
-
- public void addError( Throwable throwable, I18n message, String resource, String location, Object... params ) {
- addProblem(new Problem(Problem.Status.ERROR, Problem.DEFAULT_CODE, message, resource, location, throwable));
- }
-
- public void addError( int code, I18n message, Object... params ) {
- addProblem(new Problem(Problem.Status.ERROR, code, message));
- }
-
- public void addError( Throwable throwable, int code, I18n message, Object... params ) {
- addProblem(new Problem(Problem.Status.ERROR, code, message, null, null, throwable));
- }
-
- public void addError( int code, I18n message, String resource, String location, Object... params ) {
- addProblem(new Problem(Problem.Status.ERROR, code, message, resource, location));
- }
-
- public void addError( Throwable throwable, int code, I18n message, String resource, String location, Object... params ) {
- addProblem(new Problem(Problem.Status.ERROR, code, message, resource, location, throwable));
- }
-
- public void addWarning( I18n message, Object... params ) {
- addProblem(new Problem(Problem.Status.WARNING, Problem.DEFAULT_CODE, message));
- }
-
- public void addWarning( Throwable throwable, I18n message, Object... params ) {
- addProblem(new Problem(Problem.Status.WARNING, Problem.DEFAULT_CODE, message, null, null, throwable));
- }
-
- public void addWarning( I18n message, String resource, String location, Object... params ) {
- addProblem(new Problem(Problem.Status.WARNING, Problem.DEFAULT_CODE, message, resource, location));
- }
-
- public void addWarning( Throwable throwable, I18n message, String resource, String location, Object... params ) {
- addProblem(new Problem(Problem.Status.WARNING, Problem.DEFAULT_CODE, message, resource, location, throwable));
- }
-
- public void addWarning( int code, I18n message, Object... params ) {
- addProblem(new Problem(Problem.Status.WARNING, code, message));
- }
-
- public void addWarning( Throwable throwable, int code, I18n message, Object... params ) {
- addProblem(new Problem(Problem.Status.WARNING, code, message, null, null, throwable));
- }
-
- public void addWarning( int code, I18n message, String resource, String location, Object... params ) {
- addProblem(new Problem(Problem.Status.WARNING, code, message, resource, location));
- }
-
- public void addWarning( Throwable throwable, int code, I18n message, String resource, String location, Object... params ) {
- addProblem(new Problem(Problem.Status.WARNING, code, message, resource, location, throwable));
- }
-
- public void addInfo( I18n message, Object... params ) {
- addProblem(new Problem(Problem.Status.INFO, Problem.DEFAULT_CODE, message));
- }
-
- public void addInfo( Throwable throwable, I18n message, Object... params ) {
- addProblem(new Problem(Problem.Status.INFO, Problem.DEFAULT_CODE, message, null, null, throwable));
- }
-
- public void addInfo( I18n message, String resource, String location, Object... params ) {
- addProblem(new Problem(Problem.Status.INFO, Problem.DEFAULT_CODE, message, resource, location));
- }
-
- public void addInfo( Throwable throwable, I18n message, String resource, String location, Object... params ) {
- addProblem(new Problem(Problem.Status.INFO, Problem.DEFAULT_CODE, message, resource, location, throwable));
- }
-
- public void addInfo( int code, I18n message, Object... params ) {
- addProblem(new Problem(Problem.Status.INFO, code, message));
- }
-
- public void addInfo( Throwable throwable, int code, I18n message, Object... params ) {
- addProblem(new Problem(Problem.Status.INFO, code, message, null, null, throwable));
- }
-
- public void addInfo( int code, I18n message, String resource, String location, Object... params ) {
- addProblem(new Problem(Problem.Status.INFO, code, message, resource, location));
- }
-
- public void addInfo( Throwable throwable, int code, I18n message, String resource, String location, Object... params ) {
- addProblem(new Problem(Problem.Status.INFO, code, message, resource, location, throwable));
- }
-
- public boolean hasProblems() {
- return this.problems != null && this.problems.size() > 0;
- }
-
- public boolean hasErrors() {
- if (this.problems == null) return false;
- for (Problem problem : this.problems) {
- if (problem.getStatus() == Problem.Status.ERROR) return true;
- }
- return false;
- }
-
- public boolean hasWarnings() {
- if (this.problems == null) return false;
- for (Problem problem : this.problems) {
- if (problem.getStatus() == Problem.Status.WARNING) return true;
- }
- return false;
- }
-
- public boolean hasInfo() {
- if (this.problems == null) return false;
- for (Problem problem : this.problems) {
- if (problem.getStatus() == Problem.Status.INFO) return true;
- }
- return false;
- }
-
- public boolean isEmpty() {
- return this.problems == null || this.problems.isEmpty();
- }
-
- public int size() {
- if (this.problems == null) return 0;
- return this.problems.size();
- }
-
- /**
- * {@inheritDoc}
- */
- public Iterator<Problem> iterator() {
- return problems.iterator();
- }
-
- protected void addProblem( Problem problem ) {
- if (problem == null) return;
- if (problems == null) problems = new LinkedList<Problem>();
- problems.add(problem);
- }
-
-}
Added: trunk/dna-common/src/main/java/org/jboss/dna/common/collection/Problems.java
===================================================================
--- trunk/dna-common/src/main/java/org/jboss/dna/common/collection/Problems.java (rev 0)
+++ trunk/dna-common/src/main/java/org/jboss/dna/common/collection/Problems.java 2008-06-10 22:16:01 UTC (rev 260)
@@ -0,0 +1,154 @@
+/*
+ *
+ */
+package org.jboss.dna.common.collection;
+
+import java.util.Iterator;
+import org.jboss.dna.common.i18n.I18n;
+
+/**
+ * @author John Verhaeg
+ */
+public interface Problems extends Iterable<Problem> {
+
+ void addError( I18n message,
+ Object... params );
+
+ void addError( Throwable throwable,
+ I18n message,
+ Object... params );
+
+ void addError( I18n message,
+ String resource,
+ String location,
+ Object... params );
+
+ void addError( Throwable throwable,
+ I18n message,
+ String resource,
+ String location,
+ Object... params );
+
+ void addError( int code,
+ I18n message,
+ Object... params );
+
+ void addError( Throwable throwable,
+ int code,
+ I18n message,
+ Object... params );
+
+ void addError( int code,
+ I18n message,
+ String resource,
+ String location,
+ Object... params );
+
+ void addError( Throwable throwable,
+ int code,
+ I18n message,
+ String resource,
+ String location,
+ Object... params );
+
+ void addWarning( I18n message,
+ Object... params );
+
+ void addWarning( Throwable throwable,
+ I18n message,
+ Object... params );
+
+ void addWarning( I18n message,
+ String resource,
+ String location,
+ Object... params );
+
+ void addWarning( Throwable throwable,
+ I18n message,
+ String resource,
+ String location,
+ Object... params );
+
+ void addWarning( int code,
+ I18n message,
+ Object... params );
+
+ void addWarning( Throwable throwable,
+ int code,
+ I18n message,
+ Object... params );
+
+ void addWarning( int code,
+ I18n message,
+ String resource,
+ String location,
+ Object... params );
+
+ void addWarning( Throwable throwable,
+ int code,
+ I18n message,
+ String resource,
+ String location,
+ Object... params );
+
+ void addInfo( I18n message,
+ Object... params );
+
+ void addInfo( Throwable throwable,
+ I18n message,
+ Object... params );
+
+ void addInfo( I18n message,
+ String resource,
+ String location,
+ Object... params );
+
+ void addInfo( Throwable throwable,
+ I18n message,
+ String resource,
+ String location,
+ Object... params );
+
+ void addInfo( int code,
+ I18n message,
+ Object... params );
+
+ void addInfo( Throwable throwable,
+ int code,
+ I18n message,
+ Object... params );
+
+ void addInfo( int code,
+ I18n message,
+ String resource,
+ String location,
+ Object... params );
+
+ void addInfo( Throwable throwable,
+ int code,
+ I18n message,
+ String resource,
+ String location,
+ Object... params );
+
+ boolean hasProblems();
+
+ boolean hasErrors();
+
+ boolean hasWarnings();
+
+ boolean hasInfo();
+
+ boolean isEmpty();
+
+ int size();
+
+ /**
+ * <p>
+ * {@inheritDoc}
+ * </p>
+ *
+ * @see java.lang.Iterable#iterator()
+ */
+ Iterator<Problem> iterator();
+}
Property changes on: trunk/dna-common/src/main/java/org/jboss/dna/common/collection/Problems.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied: trunk/dna-common/src/main/java/org/jboss/dna/common/collection/SimpleProblems.java (from rev 251, trunk/dna-common/src/main/java/org/jboss/dna/common/collection/Problems.java)
===================================================================
--- trunk/dna-common/src/main/java/org/jboss/dna/common/collection/SimpleProblems.java (rev 0)
+++ trunk/dna-common/src/main/java/org/jboss/dna/common/collection/SimpleProblems.java 2008-06-10 22:16:01 UTC (rev 260)
@@ -0,0 +1,263 @@
+/*
+ * 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.common.collection;
+
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import net.jcip.annotations.NotThreadSafe;
+import org.jboss.dna.common.i18n.I18n;
+
+/**
+ * A list of problems for some execution context. The problems will be {@link #iterator() returned} in the order in which they
+ * were encountered (although this cannot be guaranteed in contexts involving multiple threads or processes).
+ *
+ * @author Randall Hauch
+ * @author John Verhaeg
+ */
+@NotThreadSafe
+public class SimpleProblems implements Problems {
+
+ private List<Problem> problems;
+
+ public void addError( I18n message,
+ Object... params ) {
+ addProblem(new Problem(Problem.Status.ERROR, Problem.DEFAULT_CODE, message, params));
+ }
+
+ public void addError( Throwable throwable,
+ I18n message,
+ Object... params ) {
+ addProblem(new Problem(Problem.Status.ERROR, Problem.DEFAULT_CODE, message, null, null, throwable));
+ }
+
+ public void addError( I18n message,
+ String resource,
+ String location,
+ Object... params ) {
+ addProblem(new Problem(Problem.Status.ERROR, Problem.DEFAULT_CODE, message, resource, location));
+ }
+
+ public void addError( Throwable throwable,
+ I18n message,
+ String resource,
+ String location,
+ Object... params ) {
+ addProblem(new Problem(Problem.Status.ERROR, Problem.DEFAULT_CODE, message, resource, location, throwable));
+ }
+
+ public void addError( int code,
+ I18n message,
+ Object... params ) {
+ addProblem(new Problem(Problem.Status.ERROR, code, message));
+ }
+
+ public void addError( Throwable throwable,
+ int code,
+ I18n message,
+ Object... params ) {
+ addProblem(new Problem(Problem.Status.ERROR, code, message, null, null, throwable));
+ }
+
+ public void addError( int code,
+ I18n message,
+ String resource,
+ String location,
+ Object... params ) {
+ addProblem(new Problem(Problem.Status.ERROR, code, message, resource, location));
+ }
+
+ public void addError( Throwable throwable,
+ int code,
+ I18n message,
+ String resource,
+ String location,
+ Object... params ) {
+ addProblem(new Problem(Problem.Status.ERROR, code, message, resource, location, throwable));
+ }
+
+ public void addWarning( I18n message,
+ Object... params ) {
+ addProblem(new Problem(Problem.Status.WARNING, Problem.DEFAULT_CODE, message));
+ }
+
+ public void addWarning( Throwable throwable,
+ I18n message,
+ Object... params ) {
+ addProblem(new Problem(Problem.Status.WARNING, Problem.DEFAULT_CODE, message, null, null, throwable));
+ }
+
+ public void addWarning( I18n message,
+ String resource,
+ String location,
+ Object... params ) {
+ addProblem(new Problem(Problem.Status.WARNING, Problem.DEFAULT_CODE, message, resource, location));
+ }
+
+ public void addWarning( Throwable throwable,
+ I18n message,
+ String resource,
+ String location,
+ Object... params ) {
+ addProblem(new Problem(Problem.Status.WARNING, Problem.DEFAULT_CODE, message, resource, location, throwable));
+ }
+
+ public void addWarning( int code,
+ I18n message,
+ Object... params ) {
+ addProblem(new Problem(Problem.Status.WARNING, code, message));
+ }
+
+ public void addWarning( Throwable throwable,
+ int code,
+ I18n message,
+ Object... params ) {
+ addProblem(new Problem(Problem.Status.WARNING, code, message, null, null, throwable));
+ }
+
+ public void addWarning( int code,
+ I18n message,
+ String resource,
+ String location,
+ Object... params ) {
+ addProblem(new Problem(Problem.Status.WARNING, code, message, resource, location));
+ }
+
+ public void addWarning( Throwable throwable,
+ int code,
+ I18n message,
+ String resource,
+ String location,
+ Object... params ) {
+ addProblem(new Problem(Problem.Status.WARNING, code, message, resource, location, throwable));
+ }
+
+ public void addInfo( I18n message,
+ Object... params ) {
+ addProblem(new Problem(Problem.Status.INFO, Problem.DEFAULT_CODE, message));
+ }
+
+ public void addInfo( Throwable throwable,
+ I18n message,
+ Object... params ) {
+ addProblem(new Problem(Problem.Status.INFO, Problem.DEFAULT_CODE, message, null, null, throwable));
+ }
+
+ public void addInfo( I18n message,
+ String resource,
+ String location,
+ Object... params ) {
+ addProblem(new Problem(Problem.Status.INFO, Problem.DEFAULT_CODE, message, resource, location));
+ }
+
+ public void addInfo( Throwable throwable,
+ I18n message,
+ String resource,
+ String location,
+ Object... params ) {
+ addProblem(new Problem(Problem.Status.INFO, Problem.DEFAULT_CODE, message, resource, location, throwable));
+ }
+
+ public void addInfo( int code,
+ I18n message,
+ Object... params ) {
+ addProblem(new Problem(Problem.Status.INFO, code, message));
+ }
+
+ public void addInfo( Throwable throwable,
+ int code,
+ I18n message,
+ Object... params ) {
+ addProblem(new Problem(Problem.Status.INFO, code, message, null, null, throwable));
+ }
+
+ public void addInfo( int code,
+ I18n message,
+ String resource,
+ String location,
+ Object... params ) {
+ addProblem(new Problem(Problem.Status.INFO, code, message, resource, location));
+ }
+
+ public void addInfo( Throwable throwable,
+ int code,
+ I18n message,
+ String resource,
+ String location,
+ Object... params ) {
+ addProblem(new Problem(Problem.Status.INFO, code, message, resource, location, throwable));
+ }
+
+ public boolean hasProblems() {
+ return this.problems != null && this.problems.size() > 0;
+ }
+
+ public boolean hasErrors() {
+ if (this.problems == null) return false;
+ for (Problem problem : this.problems) {
+ if (problem.getStatus() == Problem.Status.ERROR) return true;
+ }
+ return false;
+ }
+
+ public boolean hasWarnings() {
+ if (this.problems == null) return false;
+ for (Problem problem : this.problems) {
+ if (problem.getStatus() == Problem.Status.WARNING) return true;
+ }
+ return false;
+ }
+
+ public boolean hasInfo() {
+ if (this.problems == null) return false;
+ for (Problem problem : this.problems) {
+ if (problem.getStatus() == Problem.Status.INFO) return true;
+ }
+ return false;
+ }
+
+ public boolean isEmpty() {
+ return this.problems == null || this.problems.isEmpty();
+ }
+
+ public int size() {
+ if (this.problems == null) return 0;
+ return this.problems.size();
+ }
+
+ /**
+ * <p>
+ * {@inheritDoc}
+ * </p>
+ *
+ * @see org.jboss.dna.common.collection.Problems#iterator()
+ */
+ public Iterator<Problem> iterator() {
+ return problems.iterator();
+ }
+
+ protected void addProblem( Problem problem ) {
+ if (problem == null) return;
+ if (problems == null) problems = new LinkedList<Problem>();
+ problems.add(problem);
+ }
+}
Modified: trunk/dna-common/src/main/java/org/jboss/dna/common/collection/UnmodifiableProperties.java
===================================================================
--- trunk/dna-common/src/main/java/org/jboss/dna/common/collection/UnmodifiableProperties.java 2008-06-10 22:05:23 UTC (rev 259)
+++ trunk/dna-common/src/main/java/org/jboss/dna/common/collection/UnmodifiableProperties.java 2008-06-10 22:16:01 UTC (rev 260)
@@ -106,7 +106,8 @@
* {@inheritDoc}
*/
@Override
- public String getProperty( String key, String defaultValue ) {
+ public String getProperty( String key,
+ String defaultValue ) {
return this.delegate.getProperty(key, defaultValue);
}
@@ -168,11 +169,13 @@
/**
* {@inheritDoc}
+ *
* @deprecated
*/
@Deprecated
@Override
- public void save( OutputStream out, String comments ) {
+ public void save( OutputStream out,
+ String comments ) {
this.delegate.save(out, comments);
}
@@ -188,7 +191,8 @@
* {@inheritDoc}
*/
@Override
- public void store( OutputStream out, String comments ) throws IOException {
+ public void store( OutputStream out,
+ String comments ) throws IOException {
this.delegate.store(out, comments);
}
@@ -196,7 +200,9 @@
* {@inheritDoc}
*/
@Override
- public void storeToXML( OutputStream os, String comment, String encoding ) throws IOException {
+ public void storeToXML( OutputStream os,
+ String comment,
+ String encoding ) throws IOException {
this.delegate.storeToXML(os, comment, encoding);
}
@@ -204,7 +210,8 @@
* {@inheritDoc}
*/
@Override
- public void storeToXML( OutputStream os, String comment ) throws IOException {
+ public void storeToXML( OutputStream os,
+ String comment ) throws IOException {
this.delegate.storeToXML(os, comment);
}
@@ -268,7 +275,8 @@
* {@inheritDoc}
*/
@Override
- public synchronized Object put( Object key, Object value ) {
+ public synchronized Object put( Object key,
+ Object value ) {
throw new UnsupportedOperationException();
}
@@ -292,7 +300,8 @@
* {@inheritDoc}
*/
@Override
- public synchronized Object setProperty( String key, String value ) {
+ public synchronized Object setProperty( String key,
+ String value ) {
throw new UnsupportedOperationException();
}
Deleted: trunk/dna-common/src/main/java/org/jboss/dna/common/monitor/NullProgressMonitor.java
===================================================================
--- trunk/dna-common/src/main/java/org/jboss/dna/common/monitor/NullProgressMonitor.java 2008-06-10 22:05:23 UTC (rev 259)
+++ trunk/dna-common/src/main/java/org/jboss/dna/common/monitor/NullProgressMonitor.java 2008-06-10 22:16:01 UTC (rev 260)
@@ -1,100 +0,0 @@
-/*
- * 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.common.monitor;
-
-import java.util.Locale;
-import java.util.concurrent.atomic.AtomicBoolean;
-import org.jboss.dna.common.CommonI18n;
-import org.jboss.dna.common.i18n.I18n;
-import net.jcip.annotations.ThreadSafe;
-
-/**
- * Progress monitor that records nothing.
- * @author Randall Hauch
- */
-@ThreadSafe
-public class NullProgressMonitor implements ProgressMonitor {
-
- private final AtomicBoolean cancelled = new AtomicBoolean(false);
- private final String activityName;
-
- public NullProgressMonitor( String activityName ) {
- this.activityName = activityName;
- }
-
- /**
- * {@inheritDoc}
- */
- public String getActivityName() {
- return this.activityName;
- }
-
- /**
- * {@inheritDoc}
- */
- public void beginTask( double totalWork, I18n name, Object... params ) {
- // do nothing
- }
-
- /**
- * {@inheritDoc}
- */
- public ProgressMonitor createSubtask( double subtaskWork ) {
- return this;
- }
-
- /**
- * {@inheritDoc}
- */
- public void done() {
- // do nothing
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean isCancelled() {
- return cancelled.get();
- }
-
- /**
- * {@inheritDoc}
- */
- public void setCancelled( boolean value ) {
- cancelled.set(value);
- }
-
- /**
- * {@inheritDoc}
- */
- public void worked( double work ) {
- // do nothing
- }
-
- /**
- * {@inheritDoc}
- */
- public ProgressStatus getStatus( Locale locale ) {
- return new ProgressStatus(this.activityName, CommonI18n.nullProgressMonitorTaskName.text(locale), 0.0d, cancelled.get());
- }
-}
Modified: trunk/dna-common/src/main/java/org/jboss/dna/common/monitor/ProgressMonitor.java
===================================================================
--- trunk/dna-common/src/main/java/org/jboss/dna/common/monitor/ProgressMonitor.java 2008-06-10 22:05:23 UTC (rev 259)
+++ trunk/dna-common/src/main/java/org/jboss/dna/common/monitor/ProgressMonitor.java 2008-06-10 22:16:01 UTC (rev 260)
@@ -23,63 +23,92 @@
package org.jboss.dna.common.monitor;
import java.util.Locale;
+import org.jboss.dna.common.collection.Problems;
import org.jboss.dna.common.i18n.I18n;
/**
- * A basic progress monitor that facilitates the monitoring of an activity.
+ * A basic progress monitor that facilitates the updating and monitoring of progress towards the completion of an activity.
+ * Documentation hereafter will refer to the code in an application that updates progress as the <strong>Updater</strong>, and
+ * code that monitors progress as an <strong>Observer</strong>.
* <p>
- * The progress of each activity is started when {@link #beginTask(double, I18n, Object...)} is called, continues with a mixture
- * of work ({@link #worked(double)}) and subtasks ({@link #createSubtask(double)}), and finishes when the activity is
- * completed ({@link #done()}) or cancelled ({@link #setCancelled(boolean)}).
+ * The progress of each {@link #getActivityName() activity} is started when the <strong>Updater</strong> calls
+ * {@link #beginTask(double, I18n, Object...)}, continues with a mixture of work ({@link #worked(double)}) and subtasks ({@link #createSubtask(double)}),
+ * and finishes when the activity is completed ({@link #done()}) or cancelled ({@link #setCancelled(boolean)}).
* </p>
+ * <p>
+ * If an activity is interrupted before its normal completion due to a cancellation request by an <strong>Observer</strong>, it
+ * is still the responsibility of the <strong>Updater</strong> to mark the activity as completed. Similarly, if an activity
+ * cannot be cancelled before its normal completion, the <strong>Updater</strong> must deny any previous cancellation request by
+ * calling {@link #setCancelled(boolean) setCancelled(false)}.
+ * </p>
+ *
* @author Randall Hauch
+ * @author John Verhaeg
*/
public interface ProgressMonitor {
/**
* Get the name of the activity. This should never change for a progress monitor, and all
* {@link #createSubtask(double) subtasks} should have the same name.
+ *
* @return the activity's name
*/
String getActivityName();
/**
- * Start work on the task, specifying the total amount of work that this task constitutes.
+ * Called by the <strong>Updater</strong> to indicate work has started on the task, specifying the total amount of work that
+ * this task constitutes.
+ *
* @param totalWork the total number of work units for the task
* @param name the name of the task
* @param params the parameters for localization
*/
- void beginTask( double totalWork, I18n name, Object... params );
+ void beginTask( double totalWork,
+ I18n name,
+ Object... params );
/**
- * Report work completed for this task.
+ * Called by the <strong>Updater</strong> to report work completed for this task.
+ *
* @param work the number of work units that have been worked
*/
void worked( double work );
/**
- * Create a subtask with the given about of work. The resulting monitor must be started ({@link #beginTask(double, I18n, Object...)})
- * and finished ({@link #done()}).
+ * Called by the <strong>Updater</strong> to create a subtask with the given about of work. The resulting progress monitor
+ * must be started ({@link #beginTask(double, I18n, Object...)}) and finished ({@link #done()}).
+ *
* @param subtaskWork the number of work units for this subtask
* @return the progress monitor for the subtask
*/
ProgressMonitor createSubtask( double subtaskWork );
/**
- * Mark this task as being completed. This method must be called for the task to be properly completed.
+ * Called by the <strong>Updater</strong> to mark this activity as complete. This method must be called, even if the activity
+ * has been cancelled.
*/
void done();
/**
- * Set the cancelled state of this activity. Cancelling the activity must be considered a request that can be denied by
- * setting the cancelled state to <code>false</code>.
- * @param value true if requesting the activity be cancelled.
+ * Return whether this activity has completed.
+ *
+ * @return <code>true</code> if this activity has completed.
*/
+ boolean isDone();
+
+ /**
+ * Called by an <strong>Observer</strong> to request the cancellation of this activity, or by the <strong>Updater</strong>
+ * to deny a prior cancellation request (i.e., when the activity {@link #done() completes} before the <strong>Updater</strong>
+ * recognizes a cancellation request by an <strong>Observer</strong>).
+ *
+ * @param value <code>true</code> if requesting the activity be cancelled.
+ */
void setCancelled( boolean value );
/**
- * Returned whether this activity has been {@link #setCancelled(boolean) cancelled}.
- * @return true if this activity has been requested to be cancelled, or false otherwise.
+ * Return whether a request was made by an <strong>Observer</strong> to {@link #setCancelled(boolean) cancel} this activity.
+ *
+ * @return <code>true</code> if this activity has been requested to be cancelled.
*/
boolean isCancelled();
@@ -87,9 +116,18 @@
* Return the current status of this activity, localized to the specified locale. This method returns an immutable but
* consistent snapshot of the status for this activity. Note that if this instance is a {@link #createSubtask(double) subtask},
* this method returns the status of the subtask.
+ *
* @param locale the locale in which the status is to be represented; if null, the {@link Locale#getDefault() default locale}
- * will be used
+ * will be used
* @return the status of this activity
*/
ProgressStatus getStatus( Locale locale );
+
+ /**
+ * Return the problems encountered during the {@link #getStatus(Locale) progress} made towards completing the associated
+ * {@link #getActivityName() activity}.
+ *
+ * @return the list of problems
+ */
+ Problems getProblems();
}
Modified: trunk/dna-common/src/main/java/org/jboss/dna/common/monitor/ProgressMonitorWrapper.java
===================================================================
--- trunk/dna-common/src/main/java/org/jboss/dna/common/monitor/ProgressMonitorWrapper.java 2008-06-10 22:05:23 UTC (rev 259)
+++ trunk/dna-common/src/main/java/org/jboss/dna/common/monitor/ProgressMonitorWrapper.java 2008-06-10 22:16:01 UTC (rev 260)
@@ -23,10 +23,14 @@
package org.jboss.dna.common.monitor;
import java.util.Locale;
+import org.jboss.dna.common.collection.Problems;
import org.jboss.dna.common.i18n.I18n;
/**
+ * The thread safety of this class is determined by the delegate.
+ *
* @author Randall Hauch
+ * @author John Verhaeg
*/
public class ProgressMonitorWrapper implements ProgressMonitor {
@@ -36,67 +40,61 @@
this.delegate = delegate;
}
- /**
- * @return the wrapped progress monitor
- */
public ProgressMonitor getWrappedMonitor() {
return this.delegate;
}
- /**
- * {@inheritDoc}
- */
- public void beginTask( double totalWork, I18n name, Object... params ) {
+ public void beginTask( double totalWork,
+ I18n name,
+ Object... params ) {
this.delegate.beginTask(totalWork, name, params);
}
- /**
- * {@inheritDoc}
- */
public ProgressMonitor createSubtask( double subtaskWork ) {
return this.delegate.createSubtask(subtaskWork);
}
- /**
- * {@inheritDoc}
- */
public void done() {
this.delegate.done();
}
- /**
- * {@inheritDoc}
- */
public String getActivityName() {
return this.delegate.getActivityName();
}
- /**
- * {@inheritDoc}
- */
public ProgressStatus getStatus( Locale locale ) {
return this.delegate.getStatus(locale);
}
/**
+ * <p>
* {@inheritDoc}
+ * </p>
+ *
+ * @see org.jboss.dna.common.monitor.ProgressMonitor#getProblems()
*/
+ public Problems getProblems() {
+ return delegate.getProblems();
+ }
+
public boolean isCancelled() {
return this.delegate.isCancelled();
}
/**
* {@inheritDoc}
+ *
+ * @see org.jboss.dna.common.monitor.ProgressMonitor#isDone()
*/
+ public boolean isDone() {
+ return delegate.isDone();
+ }
+
public void setCancelled( boolean value ) {
this.delegate.setCancelled(value);
}
- /**
- * {@inheritDoc}
- */
public void worked( double work ) {
this.delegate.worked(work);
}
-
}
Modified: trunk/dna-common/src/main/java/org/jboss/dna/common/monitor/SimpleProgressMonitor.java
===================================================================
--- trunk/dna-common/src/main/java/org/jboss/dna/common/monitor/SimpleProgressMonitor.java 2008-06-10 22:05:23 UTC (rev 259)
+++ trunk/dna-common/src/main/java/org/jboss/dna/common/monitor/SimpleProgressMonitor.java 2008-06-10 22:16:01 UTC (rev 260)
@@ -27,14 +27,21 @@
import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
import net.jcip.annotations.GuardedBy;
-import net.jcip.annotations.ThreadSafe;
+import org.jboss.dna.common.collection.Problems;
+import org.jboss.dna.common.collection.SimpleProblems;
import org.jboss.dna.common.i18n.I18n;
/**
- * A basic progress monitor
+ * A basic progress monitor.
+ * <p>
+ * This class is thread-safe except when accessing or adding {@link #getProblems() problems}. Problems must only be added by the
+ * {@link ProgressMonitor <strong>Updater</strong>}, and accessed by {@link ProgressMonitor Observers} only after the activity
+ * has been {@link #done() completed}.
+ * </p>
+ *
* @author Randall Hauch
+ * @author John Verhaeg
*/
-@ThreadSafe
public class SimpleProgressMonitor implements ProgressMonitor {
@GuardedBy( "lock" )
@@ -45,12 +52,11 @@
private double totalWork;
@GuardedBy( "lock" )
private double worked;
- @GuardedBy( "lock" )
- private boolean done;
private final String activityName;
private final ReadWriteLock lock = new ReentrantReadWriteLock();
private final AtomicBoolean cancelled = new AtomicBoolean(false);
+ private final Problems problems = new SimpleProblems();
public SimpleProgressMonitor( String activityName ) {
this.activityName = activityName != null ? activityName.trim() : "";
@@ -68,7 +74,9 @@
/**
* {@inheritDoc}
*/
- public void beginTask( double totalWork, I18n name, Object... params ) {
+ public void beginTask( double totalWork,
+ I18n name,
+ Object... params ) {
assert totalWork > 0;
try {
this.lock.writeLock().lock();
@@ -89,13 +97,17 @@
}
/**
+ * <p>
* {@inheritDoc}
+ * </p>
+ *
+ * @see org.jboss.dna.common.monitor.ProgressMonitor#done()
*/
public void done() {
boolean alreadyDone = false;
try {
this.lock.writeLock().lock();
- if (!this.done) {
+ if (this.worked < this.totalWork) {
this.worked = this.totalWork;
} else {
alreadyDone = true;
@@ -115,7 +127,21 @@
/**
* {@inheritDoc}
+ *
+ * @see org.jboss.dna.common.monitor.ProgressMonitor#isDone()
*/
+ public boolean isDone() {
+ lock.readLock().lock();
+ try {
+ return worked >= totalWork;
+ } finally {
+ lock.readLock().unlock();
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
public void setCancelled( boolean value ) {
this.cancelled.set(value);
}
@@ -162,4 +188,17 @@
protected void notifyProgress() {
// do nothing
}
+
+ /**
+ * {@inheritDoc}
+ * <p>
+ * Problems must only be added by the {@link ProgressMonitor <strong>Updater</strong>}, and accessed by
+ * {@link ProgressMonitor Observers} only after the activity has been {@link #done() completed}.
+ * </p>
+ *
+ * @see org.jboss.dna.common.monitor.ProgressMonitor#getProblems()
+ */
+ public Problems getProblems() {
+ return problems;
+ }
}
Modified: trunk/dna-common/src/main/java/org/jboss/dna/common/monitor/SubProgressMonitor.java
===================================================================
--- trunk/dna-common/src/main/java/org/jboss/dna/common/monitor/SubProgressMonitor.java 2008-06-10 22:05:23 UTC (rev 259)
+++ trunk/dna-common/src/main/java/org/jboss/dna/common/monitor/SubProgressMonitor.java 2008-06-10 22:16:01 UTC (rev 260)
@@ -25,14 +25,17 @@
import java.util.Locale;
import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
+import net.jcip.annotations.GuardedBy;
+import org.jboss.dna.common.collection.Problems;
import org.jboss.dna.common.i18n.I18n;
-import net.jcip.annotations.GuardedBy;
-import net.jcip.annotations.NotThreadSafe;
/**
+ * This class is thread-safe except when accessing or adding {@link #getProblems() problems}. Problems must only be added by the
+ * {@link ProgressMonitor <strong>Updater</strong>}, and accessed by {@link ProgressMonitor Observers} only after the activity
+ * has been {@link #done() completed}.
+ *
* @author Randall Hauch
*/
-@NotThreadSafe
public class SubProgressMonitor implements ProgressMonitor {
@GuardedBy( "lock" )
@@ -50,7 +53,8 @@
private final ProgressMonitor parent;
private final ReadWriteLock lock = new ReentrantReadWriteLock();
- public SubProgressMonitor( final ProgressMonitor parent, final double subtaskTotalInParent ) {
+ public SubProgressMonitor( final ProgressMonitor parent,
+ final double subtaskTotalInParent ) {
assert subtaskTotalInParent > 0;
assert parent != null;
this.parent = parent;
@@ -74,7 +78,9 @@
/**
* {@inheritDoc}
*/
- public void beginTask( double totalWork, I18n name, Object... params ) {
+ public void beginTask( double totalWork,
+ I18n name,
+ Object... params ) {
assert totalWork > 0;
try {
this.lock.writeLock().lock();
@@ -120,7 +126,16 @@
/**
* {@inheritDoc}
+ *
+ * @see org.jboss.dna.common.monitor.ProgressMonitor#isDone()
*/
+ public boolean isDone() {
+ return parent.isDone();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
public void setCancelled( boolean value ) {
this.parent.setCancelled(value);
}
@@ -150,9 +165,19 @@
public ProgressStatus getStatus( Locale locale ) {
try {
this.lock.readLock().lock();
- return new ProgressStatus(this.getActivityName(), this.taskName.text(locale, this.params), this.submittedToParent, this.subtaskTotalInParent, this.isCancelled());
+ return new ProgressStatus(this.getActivityName(), this.taskName.text(locale, this.params), this.submittedToParent,
+ this.subtaskTotalInParent, this.isCancelled());
} finally {
this.lock.readLock().unlock();
}
}
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.common.monitor.ProgressMonitor#getProblems()
+ */
+ public Problems getProblems() {
+ return parent.getProblems();
+ }
}
Modified: trunk/dna-common/src/test/java/org/jboss/dna/common/component/ComponentLibraryTest.java
===================================================================
--- trunk/dna-common/src/test/java/org/jboss/dna/common/component/ComponentLibraryTest.java 2008-06-10 22:05:23 UTC (rev 259)
+++ trunk/dna-common/src/test/java/org/jboss/dna/common/component/ComponentLibraryTest.java 2008-06-10 22:16:01 UTC (rev 260)
@@ -28,13 +28,15 @@
import static org.hamcrest.core.IsSame.sameInstance;
import static org.junit.Assert.assertThat;
import java.util.List;
-import org.jboss.dna.common.monitor.NullProgressMonitor;
import org.jboss.dna.common.monitor.ProgressMonitor;
import org.junit.Before;
import org.junit.Test;
+import org.mockito.MockitoAnnotations;
+import org.mockito.MockitoAnnotations.Mock;
/**
* @author Randall Hauch
+ * @author John Verhaeg
*/
public class ComponentLibraryTest {
@@ -44,10 +46,12 @@
private SampleComponentConfig configA2;
private String validDescription;
private String[] validClasspath;
- private ProgressMonitor nullMonitor = new NullProgressMonitor(ComponentLibraryTest.class.getName());
+ @Mock
+ private ProgressMonitor nullMonitor;
@Before
- public void beforeEach() throws Exception {
+ public void beforeEach() {
+ MockitoAnnotations.initMocks(this);
this.library = new ComponentLibrary<SampleComponent, SampleComponentConfig>();
this.validDescription = "a Component";
this.validClasspath = new String[] {"com.acme:configA:1.0,com.acme:configB:1.0"};
Modified: trunk/dna-common/src/test/java/org/jboss/dna/common/monitor/SimpleProgressMonitorTest.java
===================================================================
--- trunk/dna-common/src/test/java/org/jboss/dna/common/monitor/SimpleProgressMonitorTest.java 2008-06-10 22:05:23 UTC (rev 259)
+++ trunk/dna-common/src/test/java/org/jboss/dna/common/monitor/SimpleProgressMonitorTest.java 2008-06-10 22:16:01 UTC (rev 260)
@@ -22,14 +22,14 @@
package org.jboss.dna.common.monitor;
-import java.util.Locale;
-import java.util.Set;
import static org.hamcrest.core.Is.is;
import static org.hamcrest.core.IsInstanceOf.instanceOf;
import static org.hamcrest.core.IsNull.notNullValue;
import static org.hamcrest.core.IsSame.sameInstance;
import static org.hamcrest.number.IsCloseTo.closeTo;
import static org.junit.Assert.assertThat;
+import java.util.Locale;
+import java.util.Set;
import org.jboss.dna.common.CommonI18n;
import org.jboss.dna.common.i18n.I18n;
import org.jboss.dna.common.i18n.MockI18n;
@@ -38,6 +38,7 @@
/**
* @author Randall Hauch
+ * @author John Verhaeg
*/
public class SimpleProgressMonitorTest {
@@ -46,7 +47,7 @@
private String validTaskName;
@Before
- public void beforeEach() throws Exception {
+ public void beforeEach() {
this.validActivityName = "Reading from file X";
this.validTaskName = "Checking for file";
this.monitor = new SimpleProgressMonitor(this.validActivityName);
@@ -246,7 +247,10 @@
@Test
public void shouldNotBeMarkedAsDoneAfterCancel() {
-
+ monitor.beginTask(100, MockI18n.passthrough, validTaskName);
+ monitor.setCancelled(true);
+ assertThat(monitor.isCancelled(), is(true));
+ assertThat(monitor.isDone(), is(false));
}
@Test
@@ -317,6 +321,14 @@
assertThat(monitor.isCancelled(), is(true));
}
+ @Test
+ public void shouldRecordProblems() {
+ monitor.beginTask(1000, MockI18n.passthrough, validTaskName);
+ monitor.getProblems().addWarning(MockI18n.passthrough);
+ monitor.done();
+ assertThat(monitor.getProblems().hasWarnings(), is(true));
+ }
+
public static class I18nMessages {
public static I18n testTaskName;
17 years, 6 months