org.hd.d.pg2k.test.dev
Class ExhibitUploadTest

java.lang.Object
  extended by junit.framework.Assert
      extended by junit.framework.TestCase
          extended by org.hd.d.pg2k.test.dev.ExhibitUploadTest
All Implemented Interfaces:
junit.framework.Test

public final class ExhibitUploadTest
extends junit.framework.TestCase

Tests the exhibit upload mechanisms. May need to be running in a WAR container and in master mode for all tests to be operable (unless, exceptionally, the loopbackURL is pointing at another instance).


Field Summary
static int MIN_UPLOAD_SPEED_BYTESPERSEC
          Minimum binary upload speed in Bps (bytes per second); strictly positive.
private static java.util.Random rnd
          Private source of OK pseudo-random numbers.
private  java.io.File uploadDir
          The upload directory, or null if none set.
 
Constructor Summary
ExhibitUploadTest(java.lang.String name)
           
 
Method Summary
private static UploadInfoBean _makeTestUploadUIB(SimpleExhibitPipelineIF p, java.lang.String suffix)
          Makes a new random, legal UploadInfoBean for test purposes; never null.
protected  void setUp()
          Do any setup needed for the tests.
protected  void tearDown()
          Do any clearup needed after the tests.
 void testBatchUploaderResponseHandling()
          Test send/receive of server response to batch-upload client.
 void testDirectUploadBad()
          Verify that bad uploads are rejected.
 void testDirectUploadJPEG()
          Test direct binary upload (of a JPEG image) for correctness.
 void testDirectUploadSimple()
          Test simple upload (of non-binary data) directly, not over HTTP.
 
Methods inherited from class junit.framework.TestCase
countTestCases, createResult, getName, run, run, runBare, runTest, setName, toString
 
Methods inherited from class junit.framework.Assert
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

uploadDir

private java.io.File uploadDir
The upload directory, or null if none set.


MIN_UPLOAD_SPEED_BYTESPERSEC

public static final int MIN_UPLOAD_SPEED_BYTESPERSEC
Minimum binary upload speed in Bps (bytes per second); strictly positive. The pre-200401020 algorithm could usually manage about 10kBps when uploading into a slow, remote (NFS-mounted) filesystem (with JDK 1.3.1 -server so that the JVM was not the bottleneck). So we enforce a minimum of at least 10kBps.

See Also:
Constant Field Values

rnd

private static final java.util.Random rnd
Private source of OK pseudo-random numbers.

Constructor Detail

ExhibitUploadTest

public ExhibitUploadTest(java.lang.String name)
Method Detail

setUp

protected void setUp()
              throws java.lang.Exception
Do any setup needed for the tests.

Overrides:
setUp in class junit.framework.TestCase
Throws:
java.lang.Exception

tearDown

protected void tearDown()
                 throws java.lang.Exception
Do any clearup needed after the tests.

Overrides:
tearDown in class junit.framework.TestCase
Throws:
java.lang.Exception

testDirectUploadSimple

public void testDirectUploadSimple()
                            throws java.lang.Exception
Test simple upload (of non-binary data) directly, not over HTTP. Generate a new random HTML text-fragment file, with a new, valid name, and upload it simulating a browser POST transaction, checking that it arrives intact in the upload directory.

Throws:
java.lang.Exception

_makeTestUploadUIB

private static UploadInfoBean _makeTestUploadUIB(SimpleExhibitPipelineIF p,
                                                 java.lang.String suffix)
                                          throws java.io.IOException
Makes a new random, legal UploadInfoBean for test purposes; never null. Creates a unique new random exhibit name for uploading to, picking one of the existing categories and authors from the current live data set.

May cause a jUnit assertion failure if it cannot do this successfully.

Parameters:
p - data pipeline for test data set; must have at least one author and one category we can use
suffix - must be legal non-null suffix for the file type to be uploaded, eg ".htxt" for HTML text, ".jpg" for a JPEG image
Returns:
correctly initialised UploadInfoBean; never null
Throws:
java.io.IOException - in case of difficulty with the data source

testDirectUploadJPEG

public void testDirectUploadJPEG()
                          throws java.lang.Exception
Test direct binary upload (of a JPEG image) for correctness. We also measure and print the overall speed of upload which can be tuned, though the performance threshold enforced is low enough to allow even slow development machines to meet it.

Throws:
java.lang.Exception

testDirectUploadBad

public void testDirectUploadBad()
                         throws java.lang.Exception
Verify that bad uploads are rejected. In particular, test that:

Throws:
java.lang.Exception

testBatchUploaderResponseHandling

public void testBatchUploaderResponseHandling()
                                       throws java.lang.Exception
Test send/receive of server response to batch-upload client.

Throws:
java.lang.Exception

DHD Multimedia Gallery V1.57.21

Copyright (c) 1996-2011, Damon Hart-Davis. All rights reserved.