Permalink
Browse files

Added JavaDoc generation

Renamed BooksTestCase
Added a license file
  • Loading branch information...
scholnicks
scholnicks committed Aug 3, 2013
1 parent 54970f4 commit de38db87022c8e8279dd341439ffbb4a0088f005
View
@@ -5,32 +5,62 @@
<property name="version" value="1.0.0" />
<property name="source.dir" value="src" />
<property name="class.dir" value="target" />
<property name="doc.dir" value="api-doc" />
<property name="jarFile.location" value="dist/${app.name}-${version}.jar" />
<property name="library.dir" value="../../library" />
<target name="init" description="initilization">
<mkdir dir="${class.dir}" />
<mkdir dir="${doc.dir}" />
<mkdir dir="dist" />
</target>
<path id="class.path">
<pathelement location="${library.dir}/jackson-core.jar" />
<pathelement location="${library.dir}/jackson-annotations.jar" />
<pathelement location="${library.dir}/jackson-databind.jar" />
<pathelement location="${library.dir}/log4j.jar" />
<pathelement location="${library.dir}/commons-lang-2.5.jar" />
</path>
<target name="compile" depends="clean,init" description="compiles isbndb">
<javac destdir="${class.dir}" srcdir="${source.dir}" target="1.6" includeantruntime="false" verbose="false">
<classpath>
<pathelement location="${library.dir}/jackson-core.jar" />
<pathelement location="${library.dir}/jackson-annotations.jar" />
<pathelement location="${library.dir}/jackson-databind.jar" />
<pathelement location="${library.dir}/log4j.jar" />
<pathelement location="${library.dir}/commons-lang-2.5.jar" />
</classpath>
</javac>
<javac destdir="${class.dir}" srcdir="${source.dir}" target="1.6"
includeantruntime="false" verbose="false" classpathref="class.path" />
</target>
<target name="jar" depends="compile" description="create the JAR">
<jar destfile="${jarFile.location}" basedir="${class.dir}" compress="true" />
</target>
<path id="complete.class.path">
<pathelement location="${library.dir}/jackson-core.jar" />
<pathelement location="${library.dir}/jackson-annotations.jar" />
<pathelement location="${library.dir}/jackson-databind.jar" />
<pathelement location="${library.dir}/log4j.jar" />
<pathelement location="${class.dir}" />
</path>
<target name="doc" description="Create the JavaDoc" depends="compile">
<javadoc destdir="${doc.dir}" author="true" version="true"
use="true" windowtitle="isbndb Library" private="false" verbose="false"
>
<classpath refid="complete.class.path" />
<packageset dir="${source.dir}" defaultexcludes="yes">
<include name="**/**"/>
</packageset>
<doctitle><![CDATA[<h1>isbndb Library</h1>]]></doctitle>
<link href="http://java.sun.com/javase/6/docs/api/" />
<link href="http://logging.apache.org/log4j/1.2/apidocs/" />
<link href="http://commons.apache.org/proper/commons-lang/javadocs/api-2.6/" />
<link href="http://jackson.codehaus.org/1.8.4/javadoc/" />
</javadoc>
</target>
<target name="clean" description="removes all intermediate files">
<delete dir="dist" />
<delete dir="${class.dir}" />
<delete dir="${doc.dir}" />
</target>
</project>
View
@@ -0,0 +1,22 @@
The MIT License (MIT)
Copyright (c) 2013- Steve Scholnick <steve@scholnick.net>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
@@ -26,10 +26,12 @@
*/
public final class BooksProxy {
private static final Logger log = Logger.getLogger(BooksProxy.class);
private static final int MINIMUM_WAIT_INTERVAL = 1000;
private final ObjectMapper mapper;
private String developerKey;
private Long waitInterval = 1000L;
private String developerKey;
private int waitInterval = MINIMUM_WAIT_INTERVAL;
private static final BooksProxy INSTANCE = new BooksProxy();
@@ -50,14 +52,15 @@ public void setDeveloperKey(String developerKey) {
this.developerKey = developerKey;
}
/** Returns the wait interval */
public Long getWaitInterval() {
/** Returns the wait interval between calls to isbndb */
public int getWaitInterval() {
return waitInterval;
}
/** Sets the wait interval */
public void setWaitInterval(Long waitInterval) {
/** Sets the wait interval between calls to isbndb */
public void setWaitInterval(int waitInterval) {
this.waitInterval = waitInterval;
validateWaitInterval();
}
/**
@@ -176,6 +179,14 @@ private BooksProxy() {
loadProperties();
}
/** Ensures the <code>waitInterval</code> cannot be less that the minimum */
private void validateWaitInterval() {
if (waitInterval < MINIMUM_WAIT_INTERVAL) {
waitInterval = MINIMUM_WAIT_INTERVAL;
log.warn("Wait interval cannot be less than the minimum wait interval of " + MINIMUM_WAIT_INTERVAL);
}
}
/** Loads the properies if <code>isbndb.properties</code> exists in the classpath */
private void loadProperties() {
try {
@@ -188,7 +199,8 @@ private void loadProperties() {
String waitInternalProperty = props.getProperty("wait.interval");
if (waitInternalProperty != null) {
waitInterval = Long.valueOf(waitInternalProperty.trim());
waitInterval = Integer.valueOf(waitInternalProperty.trim());
validateWaitInterval();
}
}
}
View
@@ -1,9 +1,11 @@
isbndb
======
Library for interacting with the isbndb REST endpoints. Each call to the REST APU will be spaced by 1 second.
Library for interacting with the isbndb REST endpoints. There is a default 1 second interval betweeen calls, which is enforced as a minimum.
Download from : http://www.scholnick.net/isbndb-1.0.0.jar
* Download from : [hhttp://www.scholnick.net/isbndb/isbndb.jar](http://www.scholnick.net/isbndb/isbndb-1.0.0.jar)
* JavaDoc : <http://www.scholnick.net/isbndb/api-doc>
* License : <http://www.scholnick.net/isbndb/license.txt>
isbndb library is dependent on the following libraries:
@@ -0,0 +1,8 @@
pattern = %d - %c - %p - %m%n
log4j.rootLogger = DEBUG,ConsoleAppender
log4j.appender.ConsoleAppender=org.apache.log4j.ConsoleAppender
log4j.appender.ConsoleAppender.layout = org.apache.log4j.PatternLayout
log4j.appender.ConsoleAppender.layout.ConversionPattern = ${pattern}
@@ -17,7 +17,7 @@
*
* @author Steve Scholnick <steve@scholnick.net>
*/
public final class BookTestCase {
public final class BooksProxyTestCase {
@Test
public void singleBookTitle() throws IOException {
List<Book> books = BooksProxy.getInstance().parse( getURL("single_book.json") );
@@ -72,6 +72,20 @@ public void downloadBookWithSpacesInTitle() throws Exception {
assertEquals(10, books.size());
}
@Test
public void minimumWaitIntervalUnder() throws Exception {
BooksProxy.getInstance().setWaitInterval(0);
assertEquals(1000, BooksProxy.getInstance().getWaitInterval());
BooksProxy.getInstance().setWaitInterval(1000);
}
@Test
public void minimumWaitIntervalOver() throws Exception {
BooksProxy.getInstance().setWaitInterval(2500);
assertEquals(2500, BooksProxy.getInstance().getWaitInterval());
BooksProxy.getInstance().setWaitInterval(1000);
}
private URL getURL(String fileName) throws IOException {
return this.getClass().getClassLoader().getResource("net/scholnick/isbndb/unittests/data/" + fileName);
}

0 comments on commit de38db8

Please sign in to comment.