Example usage for java.lang IllegalArgumentException getClass

List of usage examples for java.lang IllegalArgumentException getClass

Introduction

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

Prototype

@HotSpotIntrinsicCandidate
public final native Class<?> getClass();

Source Link

Document

Returns the runtime class of this Object .

Usage

From source file:jp.terasoluna.fw.validation.FieldChecksTest11.java

/**
 * testValidateMultiField03() <br>
 * <br>/*from w  w  w  . jav  a2s  .c  om*/
 * () <br>
 * C, F, G, I <br>
 * <br>
 * () bean:"bean"<br>
 * () va:ValidatorActionn?<br>
 * () field:???Field?<br>
 * <br>
 * varmultiFieldValidator=""<br>
 * () errors:MockValidationErrors?<br>
 * <br>
 * () errors:errorMessage?null??????<br>
 * () :IllegalArgumentException<br>
 *  "var value[multiFieldValidator] is required."<br>
 * () :ERROR<br>
 *  "var value[multiFieldValidator] is required."<br>
 * <br>
 * field??var-namemultiFieldValidator??var-value????? ???IllegalArgumentException?????? <br>
 * @throws Exception ?????
 */
@Test
public void testValidateMultiField03() throws Exception {
    // ??
    Object bean = "bean";
    ValidatorAction va = new ValidatorAction();
    Field field = new Field();
    Var var = new Var("multiFieldValidator", "", null);
    field.addVar(var);
    FieldChecks_ValidationErrorsImpl03 errors = new FieldChecks_ValidationErrorsImpl03();

    // 
    FieldChecks fieldChecks = new FieldChecks();
    try {
        fieldChecks.validateMultiField(bean, va, field, errors);
        fail("IllegalArgumentException??????");
    } catch (IllegalArgumentException e) {
        // 
        assertNull(errors.errorMessage);
        assertEquals(IllegalArgumentException.class.getName(), e.getClass().getName());
        assertEquals("var value[multiFieldValidator] is required.", e.getMessage());
        assertThat(logger.getLoggingEvents(), is(asList(error("var value[multiFieldValidator] is required."))));
    }
}

From source file:jp.terasoluna.fw.validation.FieldChecksTest11.java

/**
 * testValidateMultiField05() <br>
 * <br>/* w  w  w .  j  a  v  a 2s. c  o  m*/
 * () <br>
 * F, G, I <br>
 * <br>
 * () bean:"bean"<br>
 * () va:ValidatorActionn?<br>
 * () field:???Field?<br>
 * <br>
 * varmultiFieldValidator="java.lang.String"<br>
 * () errors:MockValidationErrors?<br>
 * <br>
 * () errors:errorMessage?null??????<br>
 * () :IllegalArgumentException<br>
 * "var value[multiFieldValidator] is invalid."<br>
 * ??ClassCastException<br>
 * () :ERROR<br>
 * "var value[multiFieldValidator] is invalid."<br>
 * ??ClassCastException<br>
 * <br>
 * field??var-namemultiFieldValidator??var-value? MultiFieldValidator??????????????
 * IllegalArgumentException?????? <br>
 * @throws Exception ?????
 */
@Test
public void testValidateMultiField05() throws Exception {
    // ??
    Object bean = "bean";
    ValidatorAction va = new ValidatorAction();
    Field field = new Field();
    Var var = new Var("multiFieldValidator", "java.lang.String", null);
    field.addVar(var);
    FieldChecks_ValidationErrorsImpl03 errors = new FieldChecks_ValidationErrorsImpl03();

    // 
    FieldChecks fieldChecks = new FieldChecks();
    try {
        fieldChecks.validateMultiField(bean, va, field, errors);
        fail("IllegalArgumentException??????");
    } catch (IllegalArgumentException e) {
        // 
        assertNull(errors.errorMessage);
        assertEquals(IllegalArgumentException.class.getName(), e.getClass().getName());
        assertEquals("var value[multiFieldValidator] is invalid.", e.getMessage());
        assertTrue(e.getCause() instanceof ClassCastException);
        assertThat(logger.getLoggingEvents().get(0).getMessage(),
                is(equalTo("var value[multiFieldValidator] is invalid.")));
        assertThat(logger.getLoggingEvents().get(0).getThrowable().get(), instanceOf(ClassCastException.class));
    }
}

From source file:jp.terasoluna.fw.validation.FieldChecksTest11.java

/**
 * testValidateMultiField04() <br>
 * <br>/* w w  w  . j a v a2s.  c  o m*/
 * () <br>
 * F, G, I <br>
 * <br>
 * () bean:"bean"<br>
 * () va:ValidatorActionn?<br>
 * () field:???Field?<br>
 * <br>
 * varmultiFieldValidator="not.Exist"<br>
 * () errors:MockValidationErrors?<br>
 * <br>
 * () errors:errorMessage?null??????<br>
 * () :IllegalArgumentException<br>
 * "var value[multiFieldValidator] is invalid."<br>
 * ??ClassLoadException<br>
 * () :ERROR<br>
 * "var value[multiFieldValidator] is invalid."<br>
 * ??ClassLoadException<br>
 * <br>
 * field??var-namemultiFieldValidator??var-value?? ????????????IllegalArgumentException?
 * ????? <br>
 * @throws Exception ?????
 */
@Test
public void testValidateMultiField04() throws Exception {
    // ??
    Object bean = "bean";
    ValidatorAction va = new ValidatorAction();
    Field field = new Field();
    Var var = new Var("multiFieldValidator", "not.Exist", null);
    field.addVar(var);
    FieldChecks_ValidationErrorsImpl03 errors = new FieldChecks_ValidationErrorsImpl03();

    // 
    FieldChecks fieldChecks = new FieldChecks();
    try {
        fieldChecks.validateMultiField(bean, va, field, errors);
        fail("IllegalArgumentException??????");
    } catch (IllegalArgumentException e) {
        // 
        assertNull(errors.errorMessage);
        assertEquals(IllegalArgumentException.class.getName(), e.getClass().getName());
        assertEquals("var value[multiFieldValidator] is invalid.", e.getMessage());
        assertTrue(e.getCause() instanceof ClassLoadException);
        assertThat(logger.getLoggingEvents().get(0).getMessage(),
                is(equalTo("var value[multiFieldValidator] is invalid.")));

        // assertTrue(LogUTUtil.checkError(
        // "var value[multiFieldValidator] is invalid.",
        // new ClassLoadException(new RuntimeException())));

        assertThat(logger.getLoggingEvents().get(0).getThrowable().get(), instanceOf(ClassLoadException.class));
        assertThat(logger.getLoggingEvents().get(0).getThrowable().get().getCause(),
                instanceOf(ClassNotFoundException.class));
    }
}

From source file:com.aol.advertising.qiao.emitter.KafkaEmitter.java

private void _validate() throws Exception {
    if (brokerList == null)
        throw new ConfigurationException("missing required brokerList");

    if (topic == null)
        throw new ConfigurationException("missing required topic");

    if (clientId == null || clientId.length() == 0)
        clientId = InetAddress.getLocalHost().getHostAddress();

    if (acknowledgePolicy != null) {
        try {/*from   www  . j  a  v a 2 s .co  m*/
            ackPolicy = ACK_POLICY.find(acknowledgePolicy);
        } catch (IllegalArgumentException e) {
            logger.warn("invalid acknowledgePolicy value: " + acknowledgePolicy + ".  Use default setting "
                    + DEFAULT_ACK_POLICY);

            ackPolicy = DEFAULT_ACK_POLICY;
        } catch (Exception e) {
            logger.warn("Failed to validate acknowledgePolicy value: " + acknowledgePolicy + " => "
                    + e.getClass().getSimpleName() + ": " + e.getMessage() + ".  Use default setting "
                    + DEFAULT_ACK_POLICY);

            ackPolicy = DEFAULT_ACK_POLICY;
        }
    }
}

From source file:org.openhab.binding.modbus.internal.handler.ModbusDataThingHandler.java

private void tryUpdateState(ChannelUID uid, State state) {
    try {/*from   w w  w  .  j  ava 2s . com*/
        updateState(uid, state);
    } catch (IllegalArgumentException e) {
        logger.warn("Error updating state '{}' (type {}) to channel {}: {} {}", state,
                Optional.ofNullable(state).map(s -> s.getClass().getName()).orElse("null"), uid,
                e.getClass().getName(), e.getMessage());
    }
}

From source file:jp.terasoluna.fw.util.GenericPropertyUtilTest.java

/**
 * testResolveCollectionType01()/*  w w  w .  ja  v a  2 s .  c o  m*/
 * <br><br>
 * ()<br>
 * G <br>
 * <br>
 * () bean:null<br>
 * <br>
 * () :IllegalArgumentException<br>
 * <br>
 * bean?null???IllegalArgumentException?????? <br>
 * @throws Exception ?????
 */
@Test
public void testResolveCollectionType01() throws Exception {
    try {
        // 
        GenericPropertyUtil.resolveCollectionType(null, null);
        // 
        fail("???????");
    } catch (IllegalArgumentException e) {
        assertEquals(IllegalArgumentException.class.getName(), e.getClass().getName());
    }
}

From source file:jp.terasoluna.fw.util.GenericPropertyUtilTest.java

/**
 * testResolveCollectionType02() <br>
 * <br>/*from  w  w w  .  jav  a2  s  .  co m*/
 * () <br>
 * G <br>
 * <br>
 * () bean:Object<br>
 * () name:null<br>
 * <br>
 * () :IllegalArgumentException<br>
 * <br>
 * name?null???IllegalArgumentException?????? <br>
 * @throws Exception ?????
 */
@Test
public void testResolveCollectionType02() throws Exception {
    try {
        // 
        GenericPropertyUtil.resolveCollectionType(new Object(), null);
        // 
        fail("???????");
    } catch (IllegalArgumentException e) {
        assertEquals(IllegalArgumentException.class.getName(), e.getClass().getName());
    }
}

From source file:jp.terasoluna.fw.util.GenericPropertyUtilTest.java

/**
 * testResolveCollectionType03() <br>
 * <br>//from  w  w  w .ja v  a  2s .  c  o m
 * () <br>
 * G <br>
 * <br>
 * () bean:Object?Class<br>
 * () name:""<br>
 * <br>
 * () :IllegalArgumentException<br>
 * <br>
 * name????IllegalArgumentException?????? <br>
 * @throws Exception ?????
 */
@Test
public void testResolveCollectionType03() throws Exception {
    try {
        // 
        GenericPropertyUtil.resolveCollectionType(new Object(), "");
        // 
        fail("???????");
    } catch (IllegalArgumentException e) {
        assertEquals(IllegalArgumentException.class.getName(), e.getClass().getName());
    }
}

From source file:jp.terasoluna.fw.util.GenericPropertyUtilTest.java

/**
 * testResolveCollectionType04() <br>
 * <br>// w w  w  . j  a  va  2 s .  c  o  m
 * () <br>
 * G <br>
 * <br>
 * () bean:Object?Class<br>
 * () name:"   "<br>
 * <br>
 * () :IllegalArgumentException<br>
 * <br>
 * name????IllegalArgumentException?????? <br>
 * @throws Exception ?????
 */
@Test
public void testResolveCollectionType04() throws Exception {
    try {
        // 
        GenericPropertyUtil.resolveCollectionType(new Object(), "   ");
        // 
        fail("???????");
    } catch (IllegalArgumentException e) {
        assertEquals(IllegalArgumentException.class.getName(), e.getClass().getName());
    }
}

From source file:jp.terasoluna.fw.util.GenericPropertyUtilTest.java

/**
 * testResolveCollectionType05() <br>
 * <br>//  www  . j  a  va2 s.c o  m
 * () <br>
 * G <br>
 * <br>
 * () bean:List<String> list0???????getter????<br>
 * () name:"list0"<br>
 * <br>
 * () :IllegalArgumentException<br>
 * <br>
 * ???????IllegalArgumentException?????? <br>
 * @throws Exception ?????
 */
@Test
public void testResolveCollectionType05() throws Exception {
    try {
        // 
        GenericPropertyUtil.resolveCollectionType(new GenericPropertyUtil_Stub01(), "list0");
        // 
        fail("???????");
    } catch (IllegalArgumentException e) {
        assertEquals(IllegalArgumentException.class.getName(), e.getClass().getName());
    }
}