Search in sources :

Example 1 with LaserDefinitionException

use of cern.laser.definition.LaserDefinitionException in project ACS by ACS-Community.

the class CategoryDefinitionHandlerImplTest method testUploadReader.

//
// -- TEST METHODS --------------------------------------------------
//
/*
   * Class to test for void upload(Reader)
   */
public void testUploadReader() {
    InputStream is = getClass().getResourceAsStream("create-category-definitions.xml");
    InputStreamReader reader = new InputStreamReader(new BufferedInputStream(is));
    try {
        handler.upload(reader);
    } catch (LaserDefinitionException e) {
        fail(e.getMessage());
    }
    try {
        assertNotNull(categoryBrowsing.getCategoryByPath("CERN.DEFUNITTESTS"));
    } catch (LaserException e1) {
        fail(e1.getMessage());
    }
    try {
        assertNotNull(categoryBrowsing.getCategoryByPath("CERN.DEFUNITTESTS.DEFUNITTEST1"));
    } catch (LaserException e2) {
        fail(e2.getMessage());
    }
    try {
        assertNotNull(categoryBrowsing.getCategoryByPath("CERN.DEFUNITTESTS.DEFUNITTEST2"));
    } catch (LaserException e3) {
        fail(e3.getMessage());
    }
    try {
        assertNotNull(categoryBrowsing.getCategoryByPath("CERN.DEFUNITTESTS.DEFUNITTEST3"));
    } catch (LaserException e4) {
        fail(e4.getMessage());
    }
    is = getClass().getResourceAsStream("remove-category-definitions.xml");
    reader = new InputStreamReader(new BufferedInputStream(is));
    try {
        handler.upload(reader);
    } catch (LaserDefinitionException e5) {
        fail(e5.getMessage());
    }
    try {
        assertNull(categoryBrowsing.getCategoryByPath("CERN.DEFUNITTESTS"));
    } catch (LaserException e6) {
    }
    try {
        assertNull(categoryBrowsing.getCategoryByPath("CERN.DEFUNITTESTS.DEFUNITTEST1"));
    } catch (LaserException e7) {
    }
    try {
        assertNull(categoryBrowsing.getCategoryByPath("CERN.DEFUNITTESTS.DEFUNITTEST2"));
    } catch (LaserException e8) {
    }
    try {
        assertNull(categoryBrowsing.getCategoryByPath("CERN.DEFUNITTESTS.DEFUNITTEST3"));
    } catch (LaserException e9) {
    }
}
Also used : InputStreamReader(java.io.InputStreamReader) BufferedInputStream(java.io.BufferedInputStream) BufferedInputStream(java.io.BufferedInputStream) InputStream(java.io.InputStream) LaserDefinitionException(cern.laser.definition.LaserDefinitionException) LaserException(cern.laser.client.LaserException)

Aggregations

LaserException (cern.laser.client.LaserException)1 LaserDefinitionException (cern.laser.definition.LaserDefinitionException)1 BufferedInputStream (java.io.BufferedInputStream)1 InputStream (java.io.InputStream)1 InputStreamReader (java.io.InputStreamReader)1