Example usage for org.apache.commons.lang NullArgumentException printStackTrace

List of usage examples for org.apache.commons.lang NullArgumentException printStackTrace

Introduction

In this page you can find the example usage for org.apache.commons.lang NullArgumentException printStackTrace.

Prototype

public void printStackTrace() 

Source Link

Document

Prints this throwable and its backtrace to the standard error stream.

Usage

From source file:m.c.m.proxyma.context.ProxyFolderBeanTest.java

/**
 * Test of setFolderName method, of class ProxyFolderBean.
 */// ww  w  .ja va  2  s  .co  m
public void testSetFolderName() {
    System.out.println("setFolderName");
    String destination = "http://www.google.com";
    ProxymaFacade proxyma = new ProxymaFacade();
    ProxymaContext context = proxyma.createNewContext("default", "/", "src/test/resources/test-config.xml",
            "/tmp/");
    String folderName = "default";
    ProxyFolderBean instance = null;

    try {
        instance = proxyma.createNewProxyFolder(folderName, destination, context);
    } catch (Exception e) {
        e.printStackTrace();
        fail("ProxyFolderBean creation failed");
    }

    try {
        folderName = null;
        instance.setFolderName(folderName);
        fail("Exception not thrown.");
    } catch (NullArgumentException x) {
        folderName = null;
    } catch (Exception e) {
        e.printStackTrace();
        fail("unexpected exception thrown");
    }

    try {
        folderName = " ";
        instance.setFolderName(folderName);
        fail("Exception not thrown.");
    } catch (IllegalArgumentException x) {
        folderName = null;
    } catch (Exception e) {
        e.printStackTrace();
        fail("unexpected exception thrown");
    }

    try {
        folderName = " amico/pippo";
        instance.setFolderName(folderName);
        fail("Exception not thrown.");
    } catch (IllegalArgumentException x) {
        folderName = null;
    } catch (Exception e) {
        e.printStackTrace();
        fail("unexpected exception thrown");
    }

    try {
        folderName = " amico%20pippo ";
        String expected = "amico%20pippo";
        instance.setFolderName(folderName);
        assertEquals(instance.getFolderName(), expected);
    } catch (IllegalArgumentException x) {
        folderName = null;
    } catch (Exception e) {
        e.printStackTrace();
        fail("unexpected exception thrown");
    }

    try {
        folderName = "default";
        instance.setFolderName(folderName);
    } catch (Exception x) {
        x.printStackTrace();
        fail("Exception thrown.");
    }
    assertEquals(instance.getFolderName(), folderName);

    //Cleanup pool
    try {
        proxyma.removeProxyFolder(instance, context);
        proxyma.destroyContext(context);
    } catch (Exception x) {
        fail("Unable to unregister the context");
    }
}