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();
}