Author: rhauch
Date: 2008-05-08 18:00:44 -0400 (Thu, 08 May 2008)
New Revision: 134
Modified:
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/docs/gettingstarted/en/master.xml
Log:
Changed the example and documentation to note that the PICT file is not sequencable.
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-05-08
20:51:55 UTC (rev 133)
+++
trunk/docs/examples/gettingstarted/sequencers/src/main/java/org/jboss/example/dna/sequencers/SequencingClient.java 2008-05-08
22:00:44 UTC (rev 134)
@@ -226,7 +226,7 @@
String desc = "Sequences image files to extract the characteristics of
the image";
String classname =
"org.jboss.dna.sequencer.images.ImageMetadataSequencer";
String[] classpath = null; // Use the current classpath
- String[] pathExpressions =
{"//(*.(jpg|jpeg|pict|gif|bmp|pcx|png|iff|ras|pbm|pgm|ppm|psd))[*]/jcr:content[@jcr:data]
=> /images/$1"};
+ String[] pathExpressions =
{"//(*.(jpg|jpeg|gif|bmp|pcx|png|iff|ras|pbm|pgm|ppm|psd))[*]/jcr:content[@jcr:data]
=> /images/$1"};
SequencerConfig imageSequencerConfig = new SequencerConfig(name, desc,
classname, classpath, pathExpressions);
this.sequencingService.addSequencer(imageSequencerConfig);
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-05-08
20:51:55 UTC (rev 133)
+++
trunk/docs/examples/gettingstarted/sequencers/src/test/java/org/jboss/example/dna/sequencers/MockUserInterface.java 2008-05-08
22:00:44 UTC (rev 134)
@@ -33,17 +33,19 @@
private final String repositoryPath;
private final URL fileToUpload;
+ private final int numberOfSearchResults;
- public MockUserInterface( URL fileToUpload, String repositoryPath ) {
+ public MockUserInterface( URL fileToUpload, String repositoryPath, int
numSearchResults ) {
this.repositoryPath = repositoryPath;
this.fileToUpload = fileToUpload;
+ this.numberOfSearchResults = numSearchResults;
}
/**
* {@inheritDoc}
*/
public void displaySearchResults( List<ImageInfo> images ) {
- assertThat(images.size(), is(1));
+ assertThat(images.size(), is(this.numberOfSearchResults));
for (ImageInfo image : images) {
System.out.println("Image: " + image);
}
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-05-08
20:51:55 UTC (rev 133)
+++
trunk/docs/examples/gettingstarted/sequencers/src/test/java/org/jboss/example/dna/sequencers/SequencingClientTest.java 2008-05-08
22:00:44 UTC (rev 134)
@@ -1,7 +1,7 @@
/*
* JBoss, Home of Professional Open Source.
* Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
+ * as indicated by the @author tags. See the copyright.txt pngImageUrl in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
@@ -22,6 +22,7 @@
package org.jboss.example.dna.sequencers;
import static org.hamcrest.core.Is.is;
+import static org.hamcrest.core.IsNull.notNullValue;
import static org.junit.Assert.assertThat;
import java.net.URL;
import org.jboss.dna.common.util.FileUtil;
@@ -34,12 +35,16 @@
*/
public class SequencingClientTest {
- private URL file;
+ private URL pngImageUrl;
+ private URL pictImageUrl;
+ private URL jpegImageUrl;
private SequencingClient client;
@Before
public void beforeEach() throws Exception {
- this.file =
Thread.currentThread().getContextClassLoader().getResource("caution.png");
+ this.pngImageUrl =
Thread.currentThread().getContextClassLoader().getResource("caution.png");
+ this.pictImageUrl =
Thread.currentThread().getContextClassLoader().getResource("caution.pict");
+ this.jpegImageUrl =
Thread.currentThread().getContextClassLoader().getResource("caution.jpg");
client = new SequencingClient();
client.setWorkingDirectory("target/repositoryData");
client.setJackrabbitConfigPath("src/main/resources/jackrabbitConfig.xml");
@@ -54,6 +59,13 @@
}
@Test
+ public void shouldFindImages() {
+ assertThat(this.pictImageUrl, is(notNullValue()));
+ assertThat(this.pngImageUrl, is(notNullValue()));
+ assertThat(this.jpegImageUrl, is(notNullValue()));
+ }
+
+ @Test
public void shouldStartupAndShutdownRepository() throws Exception {
client.startRepository();
client.shutdownRepository();
@@ -69,8 +81,8 @@
}
@Test
- public void shouldUploadFile() throws Exception {
- client.setUserInterface(new MockUserInterface(this.file,
"/a/b/caution.png"));
+ public void shouldUploadAndSequencePngFile() throws Exception {
+ client.setUserInterface(new MockUserInterface(this.pngImageUrl,
"/a/b/caution.png", 1));
client.startRepository();
client.startDnaServices();
client.uploadFile();
@@ -87,4 +99,42 @@
assertThat(client.getStatistics().getNumberOfNodesSequenced(), is(1l));
}
+ @Test
+ public void shouldUploadAndSequenceJpegFile() throws Exception {
+ client.setUserInterface(new MockUserInterface(this.jpegImageUrl,
"/a/b/caution.jpeg", 1));
+ client.startRepository();
+ client.startDnaServices();
+ client.uploadFile();
+
+ // Use a trick to wait until the sequencing has been done by sleeping (to give
the sequencing time to start)
+ // and to then shut down the DNA services (which will block until all sequencing
has been completed) ...
+ Thread.sleep(1000);
+ client.shutdownDnaServices();
+
+ // The sequencers should have run, so perform the search.
+ // The mock user interface checks the results.
+ client.search();
+
+ assertThat(client.getStatistics().getNumberOfNodesSequenced(), is(1l));
+ }
+
+ @Test
+ public void shouldUploadAndNotSequencePictFile() throws Exception {
+ client.setUserInterface(new MockUserInterface(this.pictImageUrl,
"/a/b/caution.pict", 0));
+ client.startRepository();
+ client.startDnaServices();
+ client.uploadFile();
+
+ // Use a trick to wait until the sequencing has been done by sleeping (to give
the sequencing time to start)
+ // and to then shut down the DNA services (which will block until all sequencing
has been completed) ...
+ Thread.sleep(1000);
+ client.shutdownDnaServices();
+
+ // The sequencers should have run, so perform the search.
+ // The mock user interface checks the results.
+ client.search();
+
+ assertThat(client.getStatistics().getNumberOfNodesSequenced(), is(0l));
+ }
+
}
Modified: trunk/docs/gettingstarted/en/master.xml
===================================================================
--- trunk/docs/gettingstarted/en/master.xml 2008-05-08 20:51:55 UTC (rev 133)
+++ trunk/docs/gettingstarted/en/master.xml 2008-05-08 22:00:44 UTC (rev 134)
@@ -872,11 +872,14 @@
<title>Uploading an image using the Example Client</title>
<graphic align="center" scale="100"
fileref="images/example-sequencer-upload.png" />
</figure>
- However, you can specify any fully-qualified or relative path. The application will
notify you if it cannot
- find the file you specified. The example client configures JBoss DNA to sequence
image files with one of the following
- file extensions: <code>jpg</code>, <code>jpeg</code>,
<code>pict</code>, <code>gif</code>, <code>bmp</code>,
+ You can specify any fully-qualified or relative path. The application will notify
you if it cannot
+ find the file you specified. The example client configures JBoss DNA to sequence
image files (technically nodes that have names)
+ with one of the following
+ extensions: <code>jpg</code>, <code>jpeg</code>,
<code>gif</code>, <code>bmp</code>,
<code>pcx</code>, <code>png</code>,
<code>iff</code>, <code>ras</code>, <code>pbm</code>,
<code>pgm</code>, <code>ppm</code>, and
<code>psd</code>.
- Files with any other extension will be ignored.
+ Files with other extensions in the repository path will be ignored. For your
convenience, the example provides
+ several files that will be sequenced (<code>caution.png</code>,
<code>caution.jpg</code> and <code>caution.gif</code>)
+ and one image that will not be sequenced (<code>caution.pict</code>).
Feel free to try other files.
</para>
<para>
After you specified the file you want to upload, the example application asks you
where in the repository you'd
@@ -934,11 +937,12 @@
</para>
<para>
Most of the Java classes in the example really have nothing in particular to do with
JBoss DNA. The <code>UserInterface</code>,
- <code>ConsoleInput</code>, and <code>ImageInfo</code>
classes
-
- but this was a pretty
- simple example. Let's look at the Java source codeUnderstanding how you can use
JBoss DNA in your application
+ <code>ConsoleInput</code>, and <code>ImageInfo</code> classes
are there to just make the example easy to run.
+ The interesting code is in <code>SequencingClient</code>.
</para>
+
+ <para>
+ </para>
</sect1>