Return-Path: Delivered-To: apmail-jakarta-jcs-dev-archive@www.apache.org Received: (qmail 27830 invoked from network); 11 Jul 2006 19:36:29 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 11 Jul 2006 19:36:29 -0000 Received: (qmail 18114 invoked by uid 500); 11 Jul 2006 19:36:28 -0000 Delivered-To: apmail-jakarta-jcs-dev-archive@jakarta.apache.org Received: (qmail 18102 invoked by uid 500); 11 Jul 2006 19:36:28 -0000 Mailing-List: contact jcs-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "JCS Developers List" Delivered-To: mailing list jcs-dev@jakarta.apache.org Received: (qmail 18091 invoked by uid 500); 11 Jul 2006 19:36:28 -0000 Delivered-To: apmail-jakarta-jcs-commits@jakarta.apache.org Received: (qmail 18085 invoked by uid 500); 11 Jul 2006 19:36:28 -0000 Delivered-To: apmail-jakarta-jcs-cvs@jakarta.apache.org Received: (qmail 18079 invoked by uid 99); 11 Jul 2006 19:36:28 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 11 Jul 2006 12:36:28 -0700 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [140.211.166.113] (HELO eris.apache.org) (140.211.166.113) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 11 Jul 2006 12:36:26 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id CEEAF1A9820; Tue, 11 Jul 2006 12:36:06 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r420957 [2/2] - in /jakarta/jcs/trunk: ./ src/java/org/apache/jcs/auxiliary/ src/java/org/apache/jcs/auxiliary/disk/jdbc/ src/java/org/apache/jcs/auxiliary/disk/jdbc/mysql/ src/java/org/apache/jcs/auxiliary/disk/jdbc/mysql/util/ src/java/or... Date: Tue, 11 Jul 2006 19:36:03 -0000 To: jcs-cvs@jakarta.apache.org From: asmuts@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20060711193606.CEEAF1A9820@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Modified: jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/socket/tcp/LateralTCPSender.java URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/socket/tcp/LateralTCPSender.java?rev=420957&r1=420956&r2=420957&view=diff ============================================================================== --- jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/socket/tcp/LateralTCPSender.java (original) +++ jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/socket/tcp/LateralTCPSender.java Tue Jul 11 12:36:02 2006 @@ -1,19 +1,14 @@ package org.apache.jcs.auxiliary.lateral.socket.tcp; /* - * Copyright 2001-2004 The Apache Software Foundation. - * - * Licensed under the Apache License, Version 2.0 (the "License") - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright 2001-2004 The Apache Software Foundation. Licensed under the Apache + * License, Version 2.0 (the "License") you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law + * or agreed to in writing, software distributed under the License is + * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the specific language + * governing permissions and limitations under the License. */ import java.io.BufferedReader; @@ -35,7 +30,6 @@ /** * This class is based on the log4j SocketAppender class. I'm using a differnet * repair structure, so it is significant;y different. - * * @version $Id$ */ public class LateralTCPSender @@ -81,8 +75,8 @@ private Object getLock = new int[0]; /** - * Constructor for the LateralTCPSender object - * + * Constructor for the LateralTCPSender object. + *

* @param lca * @exception IOException */ @@ -113,7 +107,7 @@ /** * Creates a connection to a TCP server. - * + *

* @param host * @param port * @throws IOException @@ -129,7 +123,7 @@ { log.debug( "Attempting connection to " + address.getHostName() ); - // have time out socket open do this for us + // have time out socket open do this for us socket = SocketOpener.openSocket( host, port, openTimeOut ); if ( socket == null ) @@ -157,10 +151,9 @@ } /** - * Gets the addressByName attribute of the LateralTCPSender object - * + * Gets the addressByName attribute of the LateralTCPSender object. + *

* @param host - * * @return The addressByName value * @throws IOException */ @@ -178,7 +171,9 @@ } } - /** Sends commands to the lateral cache listener. + /** + * Sends commands to the lateral cache listener. + *

* @param led * @throws IOException */ @@ -194,7 +189,10 @@ } } - log.debug( "sending LateralElementDescriptor" ); + if ( log.isDebugEnabled() ) + { + log.debug( "sending LateralElementDescriptor" ); + } if ( led == null ) { @@ -204,7 +202,7 @@ if ( address == null ) { throw new IOException( "No remote host is set for LateralTCPSender." ); - //return; + // return; } if ( oos != null ) @@ -218,7 +216,10 @@ counter = 0; // Failing to reset the object output stream every now and // then creates a serious memory leak. - log.debug( "Doing oos.reset()" ); + if ( log.isDebugEnabled() ) + { + log.debug( "Doing oos.reset()" ); + } oos.reset(); } } @@ -238,7 +239,7 @@ * is not recommended for performance reasons. If you have 10 laterals, then * you have to make 10 failed gets to find out none of the caches have the * item. - * + *

* @param led * @return * @throws IOException @@ -260,7 +261,6 @@ if ( oos != null ) { - // Synchronized to insure that the get requests to server from this // sender and the responses are processed in order, else you could // return the wrong item from the cache. @@ -274,7 +274,7 @@ try { - // clean up input stream, nothing should be there yet. + // clean up input stream, nothing should be there yet. if ( socket.getInputStream().available() > 0 ) { socket.getInputStream().read( new byte[socket.getInputStream().available()] ); @@ -297,10 +297,9 @@ ice = (ICacheElement) obj; if ( ice == null ) { - //p( "ice is null" ); + // p( "ice is null" ); // TODO: count misses } - } catch ( IOException ioe ) { @@ -329,17 +328,19 @@ throw e; } } - } // end synchronized block + } + // end synchronized block return ice; - }// end sendAndReceive + } /** * Closes connection used by all LateralTCPSenders for this lateral * conneciton. Dispose request should come into the facade and be sent to * all lateral cache sevices. The lateral cache service will then call this * method. + *

* @param cache * @throws IOException */ @@ -355,7 +356,8 @@ } /** - * @param tcpLateralCacheAttributes The tcpLateralCacheAttributes to set. + * @param tcpLateralCacheAttributes + * The tcpLateralCacheAttributes to set. */ public void setTcpLateralCacheAttributes( ITCPLateralCacheAttributes tcpLateralCacheAttributes ) { @@ -371,7 +373,8 @@ } /** - * @param remoteHost The remoteHost to set. + * @param remoteHost + * The remoteHost to set. */ public void setRemoteHost( String remoteHost ) { @@ -386,9 +389,8 @@ return remoteHost; } - /** - * This is a Testing Method. It should be moved to a unit test. - * + /** + * This is a Testing Method. It should be moved to a unit test. * @param args */ public static void main( String args[] ) @@ -396,7 +398,7 @@ try { LateralTCPSender lur = null; - //new LateralTCPSender( "localhost", 1111 ); + // new LateralTCPSender( "localhost", 1111 ); // process user input till done boolean notDone = true; Added: jakarta/jcs/trunk/src/test-conf/TestMySQLDiskCache.ccf URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/test-conf/TestMySQLDiskCache.ccf?rev=420957&view=auto ============================================================================== --- jakarta/jcs/trunk/src/test-conf/TestMySQLDiskCache.ccf (added) +++ jakarta/jcs/trunk/src/test-conf/TestMySQLDiskCache.ccf Tue Jul 11 12:36:02 2006 @@ -0,0 +1,50 @@ +# Cache configuration for the 'TestMySQLDiskCache' test. The memory cache has a +# a maximum of 100 objects, so objects should get pushed into the disk cache. +# Since it is too much of a burden to expect a mysal instance for unit tests, we are using hsql to +# verify that the mysql disk cache works. + +jcs.default=MYSQL +jcs.default.cacheattributes=org.apache.jcs.engine.CompositeCacheAttributes +jcs.default.cacheattributes.MaxObjects=100 +jcs.default.cacheattributes.MemoryCacheName=org.apache.jcs.engine.memory.lru.LRUMemoryCache +jcs.default.cacheattributes.UseMemoryShrinker=false +jcs.default.cacheattributes.MaxMemoryIdleTimeSeconds=3600 +jcs.default.cacheattributes.ShrinkerIntervalSeconds=60 +jcs.default.elementattributes=org.apache.jcs.engine.ElementAttributes +jcs.default.elementattributes.IsEternal=false +jcs.default.elementattributes.MaxLifeSeconds=700 +jcs.default.elementattributes.IdleTime=1800 +jcs.default.elementattributes.IsSpool=true +jcs.default.elementattributes.IsRemote=true +jcs.default.elementattributes.IsLateral=true + +############################################################## +################## AUXILIARY CACHES AVAILABLE ################ +# MYSQL disk cache +jcs.auxiliary.MYSQL=org.apache.jcs.auxiliary.disk.jdbc.mysql.MySQLDiskCacheFactory +jcs.auxiliary.MYSQL.attributes=org.apache.jcs.auxiliary.disk.jdbc.mysql.MySQLDiskCacheAttributes +jcs.auxiliary.MYSQL.attributes.userName=sa +jcs.auxiliary.MYSQL.attributes.password= +jcs.auxiliary.MYSQL.attributes.url=jdbc:hsqldb:target/cache_hsql_db +jcs.auxiliary.MYSQL.attributes.driverClassName=org.hsqldb.jdbcDriver +jcs.auxiliary.MYSQL.attributes.tableName=JCS_STORE_MYSQL +jcs.auxiliary.MYSQL.attributes.testBeforeInsert=false +jcs.auxiliary.MYSQL.attributes.maxActive=15 +jcs.auxiliary.MYSQL.attributes.allowRemoveAll=true +jcs.auxiliary.MYSQL.attributes.MaxPurgatorySize=10000000 +jcs.auxiliary.MYSQL.attributes.optimizationSchedule=12:34:56,02:34:54 +jcs.auxiliary.MYSQL.attributes.balkDuringOptimization=true +jcs.auxiliary.MYSQL.attributes.EventQueueType=POOLED +jcs.auxiliary.MYSQL.attributes.EventQueuePoolName=disk_cache_event_queue + + +############################################################## +################## OPTIONAL THREAD POOL CONFIGURATION ######### +# Disk Cache pool +thread_pool.disk_cache_event_queue.useBoundary=false +thread_pool.disk_cache_event_queue.boundarySize=500 +thread_pool.disk_cache_event_queue.maximumPoolSize=15 +thread_pool.disk_cache_event_queue.minimumPoolSize=10 +thread_pool.disk_cache_event_queue.keepAliveTime=3500 +thread_pool.disk_cache_event_queue.whenBlockedPolicy=RUN +thread_pool.disk_cache_event_queue.startUpSize=10 Added: jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/disk/jdbc/mysql/MySQLDiskCacheHsqlBackedUnitTest.java URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/disk/jdbc/mysql/MySQLDiskCacheHsqlBackedUnitTest.java?rev=420957&view=auto ============================================================================== --- jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/disk/jdbc/mysql/MySQLDiskCacheHsqlBackedUnitTest.java (added) +++ jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/disk/jdbc/mysql/MySQLDiskCacheHsqlBackedUnitTest.java Tue Jul 11 12:36:02 2006 @@ -0,0 +1,182 @@ +package org.apache.jcs.auxiliary.disk.jdbc.mysql; + +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.SQLException; +import java.sql.Statement; +import java.util.Properties; + +import junit.framework.TestCase; + +import org.apache.jcs.JCS; + +/** + * Runs basic tests for the JDBC disk cache. + * + * @author Aaron Smuts + * + */ +public class MySQLDiskCacheHsqlBackedUnitTest + extends TestCase +{ + + /** + * Test setup + */ + public void setUp() + { + JCS.setConfigFilename( "/TestMySQLDiskCache.ccf" ); + } + + /** + * Test the basic JDBC disk cache functionality with a hsql backing. + * + * @throws Exception + */ + public void testSimpleJDBCPutGetWithHSQL() + throws Exception + { + System.setProperty( "hsqldb.cache_scale", "8" ); + + String rafroot = "target"; + Properties p = new Properties(); + String driver = p.getProperty( "driver", "org.hsqldb.jdbcDriver" ); + String url = p.getProperty( "url", "jdbc:hsqldb:" ); + String database = p.getProperty( "database", rafroot + "/cache_hsql_db" ); + String user = p.getProperty( "user", "sa" ); + String password = p.getProperty( "password", "" ); + + new org.hsqldb.jdbcDriver(); + Class.forName( driver ).newInstance(); + Connection cConn = DriverManager.getConnection( url + database, user, password ); + + setupTABLE( cConn ); + + runTestForRegion( "testCache1", 30 ); + } + + /** + * Adds items to cache, gets them, and removes them. The item count is more + * than the size of the memory cache, so items should spool to disk. + * + * @param region + * Name of the region to access + * @param items + * + * @exception Exception + * If an error occurs + */ + public void runTestForRegion( String region, int items ) + throws Exception + { + JCS jcs = JCS.getInstance( region ); + + System.out.println( "BEFORE PUT \n" + jcs.getStats() ); + + // Add items to cache + + for ( int i = 0; i <= items; i++ ) + { + jcs.put( i + ":key", region + " data " + i ); + } + + System.out.println( jcs.getStats() ); + + Thread.sleep( 1000 ); + + System.out.println( jcs.getStats() ); + + // Test that all items are in cache + + for ( int i = 0; i <= items; i++ ) + { + String value = (String) jcs.get( i + ":key" ); + + assertEquals( "key = [" + i + ":key] value = [" + value + "]", region + " data " + i, value ); + } + + // Remove all the items + + for ( int i = 0; i <= items; i++ ) + { + jcs.remove( i + ":key" ); + } + + // Verify removal + + for ( int i = 0; i <= items; i++ ) + { + assertNull( "Removed key should be null: " + i + ":key", jcs.get( i + ":key" ) ); + } + } + + /** + * SETUP TABLE FOR CACHE + * + * @param cConn + */ + void setupTABLE( Connection cConn ) + { + boolean newT = true; + + StringBuffer createSql = new StringBuffer(); + createSql.append( "CREATE CACHED TABLE JCS_STORE_MYSQL " ); + createSql.append( "( " ); + createSql.append( "CACHE_KEY VARCHAR(250) NOT NULL, " ); + createSql.append( "REGION VARCHAR(250) NOT NULL, " ); + createSql.append( "ELEMENT BINARY, " ); + createSql.append( "CREATE_TIME DATE, " ); + createSql.append( "CREATE_TIME_SECONDS BIGINT, " ); + createSql.append( "MAX_LIFE_SECONDS BIGINT, " ); + createSql.append( "SYSTEM_EXPIRE_TIME_SECONDS BIGINT, " ); + createSql.append( "IS_ETERNAL CHAR(1), " ); + createSql.append( "PRIMARY KEY (CACHE_KEY, REGION) " ); + createSql.append( ");" ); + + Statement sStatement = null; + try + { + sStatement = cConn.createStatement(); + } + catch ( SQLException e ) + { + e.printStackTrace(); + } + + try + { + sStatement.executeQuery( createSql.toString() ); + sStatement.close(); + } + catch ( SQLException e ) + { + if ( e.toString().indexOf( "already exists" ) != -1 ) + { + newT = false; + } + else + { + // TODO figure out if it exists prior to trying to create it. + // log.error( "Problem creating table.", e ); + e.printStackTrace(); + } + } + + String setupData[] = { "create index iKEY on JCS_STORE_MYSQL (CACHE_KEY, REGION)" }; + + if ( newT ) + { + for ( int i = 1; i < setupData.length; i++ ) + { + try + { + sStatement.executeQuery( setupData[i] ); + } + catch ( SQLException e ) + { + System.out.println( "Exception: " + e ); + } + } + } // end ifnew + } +} Added: jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/disk/jdbc/mysql/MySQLDiskCacheUnitTest.java URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/disk/jdbc/mysql/MySQLDiskCacheUnitTest.java?rev=420957&view=auto ============================================================================== --- jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/disk/jdbc/mysql/MySQLDiskCacheUnitTest.java (added) +++ jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/disk/jdbc/mysql/MySQLDiskCacheUnitTest.java Tue Jul 11 12:36:02 2006 @@ -0,0 +1,40 @@ +package org.apache.jcs.auxiliary.disk.jdbc.mysql; + +import junit.framework.TestCase; + +import org.apache.jcs.auxiliary.disk.jdbc.TableState; + +/** + * Simple tests for the MySQLDisk Cache. + *

+ * We will probably need to setup an hsql behind this, to test some of the pass through methods. + *

+ * @author Aaron Smuts + */ +public class MySQLDiskCacheUnitTest + extends TestCase +{ + /** + * Verify that we simply return null on get if an optimization is in + * progress and the cache is configured to balk on optimization. + *

+ * This is a bit tricky since we don't want to have to have a mysql instance + * running. Right now this doesn't really test much + */ + public void testBalkOnGet() + { + MySQLDiskCacheAttributes attributes = new MySQLDiskCacheAttributes(); + String tableName = "JCS_TEST"; + attributes.setDriverClassName( "org.gjt.mm.mysql.Driver" ); + attributes.setTableName( tableName ); + attributes.setBalkDuringOptimization( true ); + + TableState tableState = new TableState( tableName ); + tableState.setState( TableState.OPTIMIZATION_RUNNING ); + + MySQLDiskCache cache = new MySQLDiskCache( attributes, tableState ); + + Object result = cache.doGet( "myKey" ); + assertNull( "The result should be null", result ); + } +} Added: jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/disk/jdbc/mysql/MySQLTableOptimizerManualTester.java URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/disk/jdbc/mysql/MySQLTableOptimizerManualTester.java?rev=420957&view=auto ============================================================================== --- jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/disk/jdbc/mysql/MySQLTableOptimizerManualTester.java (added) +++ jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/disk/jdbc/mysql/MySQLTableOptimizerManualTester.java Tue Jul 11 12:36:02 2006 @@ -0,0 +1,54 @@ +package org.apache.jcs.auxiliary.disk.jdbc.mysql; + +import org.apache.jcs.auxiliary.disk.jdbc.TableState; + +import junit.framework.TestCase; + +/** + * Hand run tests for the MySQL table optimizer. + *

+ * @author Aaron Smuts + */ +public class MySQLTableOptimizerManualTester + extends TestCase +{ + + /** + * Run the optimization against live a table. + */ + public void testBasicOptimization() + { + MySQLDiskCacheAttributes attributes = new MySQLDiskCacheAttributes(); + attributes.setUserName( "java" ); + attributes.setPassword( "letmein" ); + attributes.setUrl( "jdbc:mysql://10.19.98.43:3306/flight_option_cache" ); + attributes.setDriverClassName( "org.gjt.mm.mysql.Driver" ); + String tableName = "JCS_STORE_FLIGHT_OPTION_ITINERARY"; + attributes.setTableName( tableName ); + TableState tableState = new TableState( tableName); + + MySQLTableOptimizer optimizer = new MySQLTableOptimizer( attributes, tableState ); + + optimizer.optimizeTable(); + } + + /** + * Run the optimization against live a table. + */ + public void testBasicOptimizationUnknownTable() + { + MySQLDiskCacheAttributes attributes = new MySQLDiskCacheAttributes(); + attributes.setUserName( "java" ); + attributes.setPassword( "letmein" ); + attributes.setUrl( "jdbc:mysql://10.19.98.43:3306/flight_option_cache" ); + attributes.setDriverClassName( "org.gjt.mm.mysql.Driver" ); + String tableName = "DOESNTEXIST"; + attributes.setTableName( tableName ); + TableState tableState = new TableState( tableName); + + MySQLTableOptimizer optimizer = new MySQLTableOptimizer( attributes, tableState ); + + optimizer.optimizeTable(); + } + +} Added: jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/disk/jdbc/mysql/util/ScheduleParserUtilUnitTest.java URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/disk/jdbc/mysql/util/ScheduleParserUtilUnitTest.java?rev=420957&view=auto ============================================================================== --- jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/disk/jdbc/mysql/util/ScheduleParserUtilUnitTest.java (added) +++ jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/disk/jdbc/mysql/util/ScheduleParserUtilUnitTest.java Tue Jul 11 12:36:02 2006 @@ -0,0 +1,109 @@ +package org.apache.jcs.auxiliary.disk.jdbc.mysql.util; + +import java.util.Date; + +import junit.framework.TestCase; + +/** + * Unit tests for the schedule parser. + *

+ * @author Aaron Smuts + */ +public class ScheduleParserUtilUnitTest + extends TestCase +{ + + /** + * Verify that we get an exception and not a null pointer for null input. + */ + public void testGetDatesWithNullInput() + { + try + { + ScheduleParser.createDatesForSchedule( null ); + + fail( "Should have thrown an exception" ); + } + catch ( ScheduleFormatException e ) + { + // expected + } + } + + /** + * Verify that we get an exception and not a null pointer for null input. + */ + public void testGetDateWithNullInput() + { + try + { + ScheduleParser.getDateForSchedule( null ); + + fail( "Should have thrown an exception" ); + } + catch ( ScheduleFormatException e ) + { + // expected + } + } + + /** + * Verify that we get one date for one date. + * @throws ScheduleFormatException + */ + public void testGetsDatesSingle() + throws ScheduleFormatException + { + String schedule = "12:34:56"; + Date[] dates = ScheduleParser.createDatesForSchedule( schedule ); + + assertEquals( "Wrong number of dates returned.", 1, dates.length ); + } + /** + * Verify that we get one date for one date. + * @throws ScheduleFormatException + */ + public void testGetsDatesMultiple() + throws ScheduleFormatException + { + String schedule = "12:34:56,03:51:00,12:34:12"; + Date[] dates = ScheduleParser.createDatesForSchedule( schedule ); + //System.out.println( dates ); + assertEquals( "Wrong number of dates returned.", 3, dates.length ); + } + + /** + * Verify that we get an exception for a single bad date in a list. + */ + public void testGetDatesMalformedNoColon() + { + try + { + String schedule = "12:34:56,03:51:00,123234"; + ScheduleParser.createDatesForSchedule( schedule ); + + fail( "Should have thrown an exception for a malformed date" ); + } + catch ( ScheduleFormatException e ) + { + // expected + } + } + /** + * Verify that we get an exception for a schedule that has a non numeric item. + */ + public void testGetDatesMalformedNan() + { + try + { + String schedule = "12:34:56,03:51:00,aa:12:12"; + ScheduleParser.createDatesForSchedule( schedule ); + + fail( "Should have thrown an exception for a malformed date" ); + } + catch ( ScheduleFormatException e ) + { + // expected + } + } +} --------------------------------------------------------------------- To unsubscribe, e-mail: jcs-dev-unsubscribe@jakarta.apache.org For additional commands, e-mail: jcs-dev-help@jakarta.apache.org