Example usage for java.lang IllegalArgumentException printStackTrace

List of usage examples for java.lang IllegalArgumentException printStackTrace

Introduction

In this page you can find the example usage for java.lang IllegalArgumentException printStackTrace.

Prototype

public void printStackTrace() 

Source Link

Document

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

Usage

From source file:com.jpeterson.littles3.S3ObjectRequestTest.java

/**
 * Test a <code>create</code> with no key but and no slash character after
 * the bucket.//w w w. ja va  2  s .  c  o  m
 */
public void xtest_createNoKeyBucketNoSlash() {
    S3ObjectRequest o;
    Mock mockHttpServletRequest = mock(HttpServletRequest.class);

    mockHttpServletRequest.expects(once()).method("getPathInfo").will(returnValue("/myBucket"));
    mockHttpServletRequest.expects(once()).method("getHeader").with(eq("Host")).will(returnValue("localhost"));
    mockHttpServletRequest.expects(once()).method("getRequestURL")
            .will(returnValue(new StringBuffer("http://localhost/context/myBucket")));
    mockHttpServletRequest.expects(once()).method("getUserPrincipal")
            .will(returnValue(new CanonicalUser("unitTest")));
    mockHttpServletRequest.expects(once()).method("getHeader").with(eq("x-hack-user")).will(returnValue(null));

    try {
        HackAuthenticator authenticator = new HackAuthenticator();
        authenticator.setAuthenticator(new S3Authenticator());

        o = S3ObjectRequest.create((HttpServletRequest) mockHttpServletRequest.proxy(), "localhost",
                authenticator);
    } catch (IllegalArgumentException e) {
        e.printStackTrace();
        fail("Unexpected exception");
        return;
    } catch (AuthenticatorException e) {
        e.printStackTrace();
        fail("Unexpected exception");
        return;
    }

    assertEquals("Unexpected serviceEndpoint", "http://localhost/context", o.getServiceEndpoint());
    assertEquals("Unexpected bucket", "myBucket", o.getBucket());
    assertNull("Unexpected key", o.getKey());
}

From source file:com.jpeterson.littles3.S3ObjectRequestTest.java

/**
 * Test a <code>create</code> with no bucket.
 *//*from www. j a va  2 s . c om*/
public void xtest_createNoBucket() {
    S3ObjectRequest o;
    Mock mockHttpServletRequest = mock(HttpServletRequest.class);

    mockHttpServletRequest.expects(once()).method("getPathInfo").will(returnValue("/"));
    mockHttpServletRequest.expects(once()).method("getHeader").with(eq("Host")).will(returnValue("localhost"));
    mockHttpServletRequest.expects(once()).method("getRequestURL")
            .will(returnValue(new StringBuffer("http://localhost/context/")));
    mockHttpServletRequest.expects(once()).method("getUserPrincipal")
            .will(returnValue(new CanonicalUser("unitTest")));
    mockHttpServletRequest.expects(once()).method("getHeader").with(eq("x-hack-user")).will(returnValue(null));

    try {
        HackAuthenticator authenticator = new HackAuthenticator();
        authenticator.setAuthenticator(new S3Authenticator());

        o = S3ObjectRequest.create((HttpServletRequest) mockHttpServletRequest.proxy(), "localhost",
                authenticator);
    } catch (IllegalArgumentException e) {
        e.printStackTrace();
        fail("Unexpected exception");
        return;
    } catch (AuthenticatorException e) {
        e.printStackTrace();
        fail("Unexpected exception");
        return;
    }

    assertEquals("Unexpected serviceEndpoint", "http://localhost/context", o.getServiceEndpoint());
    assertNull("Unexpected bucket", o.getBucket());
    assertNull("Unexpected key", o.getKey());
}

From source file:com.jpeterson.littles3.S3ObjectRequestTest.java

/**
 * Test a basic <code>create</code>.
 *//*from   w  ww. j  a va 2 s  .c o m*/
public void xtest_create() {
    S3ObjectRequest o;
    Mock mockHttpServletRequest = mock(HttpServletRequest.class);

    mockHttpServletRequest.expects(once()).method("getPathInfo").will(returnValue("/myBucket/myKey.txt"));
    mockHttpServletRequest.expects(once()).method("getHeader").with(eq("Host")).will(returnValue("localhost"));
    mockHttpServletRequest.expects(once()).method("getRequestURL")
            .will(returnValue(new StringBuffer("http://localhost/context/myBucket/myKey.txt")));
    mockHttpServletRequest.expects(once()).method("getUserPrincipal")
            .will(returnValue(new CanonicalUser("unitTest")));
    mockHttpServletRequest.expects(once()).method("getHeader").with(eq("x-hack-user")).will(returnValue(null));

    try {
        HackAuthenticator authenticator = new HackAuthenticator();
        authenticator.setAuthenticator(new S3Authenticator());

        o = S3ObjectRequest.create((HttpServletRequest) mockHttpServletRequest.proxy(), "localhost",
                authenticator);
    } catch (IllegalArgumentException e) {
        e.printStackTrace();
        fail("Unexpected exception");
        return;
    } catch (AuthenticatorException e) {
        e.printStackTrace();
        fail("Unexpected exception");
        return;
    }

    assertEquals("Unexpected serviceEndpoint", "http://localhost/context", o.getServiceEndpoint());
    assertEquals("Unexpected bucket", "myBucket", o.getBucket());
    assertEquals("Unexpected key", "myKey.txt", o.getKey());
    assertEquals("Unexpected requestor", new CanonicalUser("unitTest"), o.getRequestor());
}

From source file:com.jpeterson.littles3.S3ObjectRequestTest.java

/**
 * Test a <code>create</code> using virtual hosting of buckets. Ordinary
 * method.//from   ww  w.  j a v  a  2s.  c  om
 */
public void xtest_virtualHostingOrdinaryMethod() {
    S3ObjectRequest o;
    Mock mockHttpServletRequest = mock(HttpServletRequest.class);

    mockHttpServletRequest.expects(once()).method("getPathInfo").will(returnValue("/johnsmith/homepage.html"));
    mockHttpServletRequest.expects(once()).method("getRequestURL")
            .will(returnValue(new StringBuffer("http://s3.amazonaws.com/johnsmith/homepage.html")));
    mockHttpServletRequest.expects(once()).method("getHeader").with(eq("Host"))
            .will(returnValue("s3.amazonaws.com"));
    mockHttpServletRequest.expects(once()).method("getUserPrincipal")
            .will(returnValue(new CanonicalUser("unitTest")));
    mockHttpServletRequest.expects(once()).method("getHeader").with(eq("x-hack-user")).will(returnValue(null));

    try {
        HackAuthenticator authenticator = new HackAuthenticator();
        authenticator.setAuthenticator(new S3Authenticator());

        o = S3ObjectRequest.create((HttpServletRequest) mockHttpServletRequest.proxy(), "s3.amazonaws.com",
                authenticator);
    } catch (IllegalArgumentException e) {
        e.printStackTrace();
        fail("Unexpected exception");
        return;
    } catch (AuthenticatorException e) {
        e.printStackTrace();
        fail("Unexpected exception");
        return;
    }

    assertEquals("Unexpected serviceEndpoint", "http://s3.amazonaws.com", o.getServiceEndpoint());
    assertEquals("Unexpected bucket", "johnsmith", o.getBucket());
    assertEquals("Unexpected key", "homepage.html", o.getKey());
}

From source file:com.jpeterson.littles3.S3ObjectRequestTest.java

/**
 * Test a <code>create</code> using virtual hosting of buckets. Sub-domain
 * method./*from www .j  a v a2  s.  c o  m*/
 */
public void xtest_virtualHostingSubDomain() {
    S3ObjectRequest o;
    Mock mockHttpServletRequest = mock(HttpServletRequest.class);

    mockHttpServletRequest.expects(once()).method("getPathInfo").will(returnValue("/homepage.html"));
    mockHttpServletRequest.expects(once()).method("getRequestURL")
            .will(returnValue(new StringBuffer("http://johnsmith.s3.amazonaws.com/homepage.html")));
    mockHttpServletRequest.expects(once()).method("getHeader").with(eq("Host"))
            .will(returnValue("johnsmith.s3.amazonaws.com"));
    mockHttpServletRequest.expects(once()).method("getUserPrincipal")
            .will(returnValue(new CanonicalUser("unitTest")));
    mockHttpServletRequest.expects(once()).method("getHeader").with(eq("x-hack-user")).will(returnValue(null));

    try {
        HackAuthenticator authenticator = new HackAuthenticator();
        authenticator.setAuthenticator(new S3Authenticator());

        o = S3ObjectRequest.create((HttpServletRequest) mockHttpServletRequest.proxy(), "s3.amazonaws.com",
                authenticator);
    } catch (IllegalArgumentException e) {
        e.printStackTrace();
        fail("Unexpected exception");
        return;
    } catch (AuthenticatorException e) {
        e.printStackTrace();
        fail("Unexpected exception");
        return;
    }

    assertEquals("Unexpected serviceEndpoint", "http://johnsmith.s3.amazonaws.com", o.getServiceEndpoint());
    assertEquals("Unexpected bucket", "johnsmith", o.getBucket());
    assertEquals("Unexpected key", "homepage.html", o.getKey());
}

From source file:com.jpeterson.littles3.S3ObjectRequestTest.java

/**
 * Test a <code>create</code> using virtual hosting of buckets. Sub-domain
 * method with upper case Host header.//from ww w.  ja  v  a 2  s. c o  m
 */
public void xtest_virtualHostingSubDomainUpperCase() {
    S3ObjectRequest o;
    Mock mockHttpServletRequest = mock(HttpServletRequest.class);

    mockHttpServletRequest.expects(once()).method("getPathInfo").will(returnValue("/homepage.html"));
    mockHttpServletRequest.expects(once()).method("getRequestURL")
            .will(returnValue(new StringBuffer("http://johnsmith.s3.amazonaws.com/homepage.html")));
    mockHttpServletRequest.expects(once()).method("getHeader").with(eq("Host"))
            .will(returnValue("JohnSmith.s3.amazonaws.com"));
    mockHttpServletRequest.expects(once()).method("getUserPrincipal")
            .will(returnValue(new CanonicalUser("unitTest")));
    mockHttpServletRequest.expects(once()).method("getHeader").with(eq("x-hack-user")).will(returnValue(null));

    try {
        HackAuthenticator authenticator = new HackAuthenticator();
        authenticator.setAuthenticator(new S3Authenticator());

        o = S3ObjectRequest.create((HttpServletRequest) mockHttpServletRequest.proxy(), "s3.amazonaws.com",
                authenticator);
    } catch (IllegalArgumentException e) {
        e.printStackTrace();
        fail("Unexpected exception");
        return;
    } catch (AuthenticatorException e) {
        e.printStackTrace();
        fail("Unexpected exception");
        return;
    }

    assertEquals("Unexpected serviceEndpoint", "http://johnsmith.s3.amazonaws.com", o.getServiceEndpoint());
    assertEquals("Unexpected bucket", "johnsmith", o.getBucket());
    assertEquals("Unexpected key", "homepage.html", o.getKey());
}

From source file:com.jpeterson.littles3.S3ObjectRequestTest.java

/**
 * Test a <code>create</code> using virtual hosting of buckets. Domain is
 * the bucket./* w w  w  .j  a v a 2s .com*/
 */
public void xtest_virtualHostingDomain() {
    S3ObjectRequest o;
    Mock mockHttpServletRequest = mock(HttpServletRequest.class);

    mockHttpServletRequest.expects(once()).method("getPathInfo").will(returnValue("/homepage.html"));
    mockHttpServletRequest.expects(once()).method("getRequestURL")
            .will(returnValue(new StringBuffer("http://www.johnsmith.net/homepage.html")));
    mockHttpServletRequest.expects(once()).method("getHeader").with(eq("Host"))
            .will(returnValue("www.johnsmith.net"));
    mockHttpServletRequest.expects(once()).method("getUserPrincipal")
            .will(returnValue(new CanonicalUser("unitTest")));
    mockHttpServletRequest.expects(once()).method("getHeader").with(eq("x-hack-user")).will(returnValue(null));

    try {
        HackAuthenticator authenticator = new HackAuthenticator();
        authenticator.setAuthenticator(new S3Authenticator());

        o = S3ObjectRequest.create((HttpServletRequest) mockHttpServletRequest.proxy(), "s3.amazonaws.com",
                authenticator);
    } catch (IllegalArgumentException e) {
        e.printStackTrace();
        fail("Unexpected exception");
        return;
    } catch (AuthenticatorException e) {
        e.printStackTrace();
        fail("Unexpected exception");
        return;
    }

    assertEquals("Unexpected serviceEndpoint", "http://www.johnsmith.net", o.getServiceEndpoint());
    assertEquals("Unexpected bucket", "www.johnsmith.net", o.getBucket());
    assertEquals("Unexpected key", "homepage.html", o.getKey());
}

From source file:org.Microsoft.Telemetry.IntermediateHistoryStore.java

@Override
protected void serviceInit(Configuration conf) throws Exception {

    try {//from   w ww .  j  a v a 2s . com

        //Method m = originalStorage.getClass().getDeclaredMethod("serviceInit", Configuration.class);
        Method m = originalStorage.getClass().getMethod("serviceInit", Configuration.class);
        m.setAccessible(true);
        m.invoke(originalStorage, (Object) conf);

    } catch (NoSuchMethodException noSuchMethodException) {

        LOG.error(PATTERN_LOG_ERROR + "no Such Method Exception :", noSuchMethodException);
        noSuchMethodException.printStackTrace();

    } catch (SecurityException securityException) {

        LOG.error(PATTERN_LOG_ERROR + "Security Exception :", securityException);
        securityException.printStackTrace();

    } catch (IllegalAccessException illegalAccessException) {

        LOG.error(PATTERN_LOG_ERROR + "Illegal Access Exception :", illegalAccessException);
        illegalAccessException.printStackTrace();

    } catch (IllegalArgumentException illegalArgumentException) {

        LOG.error(PATTERN_LOG_ERROR + "Illegal Argument Exception :", illegalArgumentException);
        illegalArgumentException.printStackTrace();

    } catch (InvocationTargetException invocationTargetException) {

        Throwable cause = invocationTargetException.getCause();
        LOG.error(PATTERN_LOG_ERROR + "Invocation Target Exception failed because of:" + cause.getMessage(),
                invocationTargetException);
        invocationTargetException.printStackTrace();

    }
}

From source file:me.tipi.kiosk.ui.fragments.IdentityFragment.java

/**
 * Style date picker.//from   w w w  .j a  v a  2s  .c  o  m
 *
 * @param datePicker the date picker
 */
private void styleDatePicker(DatePicker datePicker) {
    datePicker.setCalendarViewShown(false);
    datePicker.setSpinnersShown(true);
    LinearLayout llFirst = (LinearLayout) datePicker.getChildAt(0);
    LinearLayout llSecond = (LinearLayout) llFirst.getChildAt(0);
    for (int i = 0; i < llSecond.getChildCount(); i++) {
        NumberPicker picker = (NumberPicker) llSecond.getChildAt(i); // NumberPickers in llSecond
        Field[] pickerFields = NumberPicker.class.getDeclaredFields();
        for (Field pf : pickerFields) {
            if (pf.getName().equals("mSelectionDivider")) {
                pf.setAccessible(true);
                try {
                    pf.set(picker, ContextCompat.getDrawable(getActivity(), R.drawable.picker_divider));
                } catch (IllegalArgumentException e) {
                    e.printStackTrace();
                } catch (Resources.NotFoundException e) {
                    e.printStackTrace();
                } catch (IllegalAccessException e) {
                    e.printStackTrace();
                }
                break;
            }
        }
    }
}

From source file:com.bb.extensions.plugin.unittests.internal.project.UnitTestFrameworkManager.java

/**
 * Clones the mocks from the server//from www .ja  v a 2s. c o  m
 */
private void cloneMocks() {
    String path = _project.getFolder(Constants.MOCKS_PROJECT_RELATIVE_PATH).getLocation().toString();
    try {
        GitWrapper gitWrapper = GitWrapper.cloneRepository(path, Constants.BB_MOCKS_GIT_REMOTE_URL);
        if (gitWrapper == null) {
            DialogUtils.showErrorDialog("Mocks Installation Failed", "Cannot clone the mocks repository.");
        } else {
            gitWrapper.closeRepository();
        }
    } catch (IllegalArgumentException e) {
        e.printStackTrace();
        DialogUtils.showErrorDialog("Mocks Installation Failed", e.getMessage());
    }
}