Example usage for java.lang AssertionError AssertionError

List of usage examples for java.lang AssertionError AssertionError

Introduction

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

Prototype

public AssertionError(double detailMessage) 

Source Link

Document

Constructs an AssertionError with its detail message derived from the specified double, which is converted to a string as defined in section 15.18.1.1 of The Java™ Language Specification.

Usage

From source file:com.feilong.taglib.functions.ELFunctions.java

/** Don't let anyone instantiate this class. */
private ELFunctions() {
    //AssertionError?. ?????. ???.
    //see Effective Java 2nd
    throw new AssertionError("No " + getClass().getName() + " instances for you!");
}

From source file:io.pivotal.spring.cloud.cloudfoundry.ConfigServerServiceInfoCreatorTest.java

@Test
public void configServerServiceCreationWithTags() {
    when(mockEnvironment.getEnvValue(VCAP_SERVICES_ENV_KEY)).thenReturn(getServicesPayload(
            getConfigServerServicePayload(CONFIG_SERVER_SERVICE_TAG_NAME, hostname, port, username, password)));

    List<ServiceInfo> serviceInfos = testCloudConnector.getServiceInfos();
    assertServiceFoundOfType(serviceInfos, CONFIG_SERVER_SERVICE_TAG_NAME, ConfigServerServiceInfo.class);
    ConfigServerServiceInfo configServiceInfo = (ConfigServerServiceInfo) serviceInfos.stream()
            .filter(serviceInfo -> serviceInfo instanceof ConfigServerServiceInfo).findFirst()
            .orElseThrow(() -> new AssertionError("A ConfigServiceInfo should exist"));
    Assert.assertEquals("config_client_id", configServiceInfo.getClientId());
    Assert.assertEquals("its_a_secret_dont_tell", configServiceInfo.getClientSecret());
    Assert.assertEquals("https://p-spring-cloud-services.uaa.my-cf.com/oauth/token",
            configServiceInfo.getAccessTokenUri());

}

From source file:mobisocial.musubi.util.CertifiedHttpClient.java

private SSLSocketFactory newSslSocketFactory() {
    try {/* w w w.j a  v  a 2s  .  c  o m*/
        KeyStore trusted = KeyStore.getInstance("BKS");
        InputStream in = mContext.getResources().openRawResource(R.raw.servercertificates);
        try {
            trusted.load(in, "ez24get".toCharArray());
        } finally {
            in.close();
        }
        SSLSocketFactory sf = new SSLSocketFactory(trusted);
        //don't check the host name because we are doing funny redirects.  the
        //actual cert is good enough because it is bundled.
        sf.setHostnameVerifier(new AllowAllHostnameVerifier());
        return sf;
    } catch (Exception e) {
        throw new AssertionError(e);
    }
}

From source file:net.sf.ehcache.server.util.WebTestUtil.java

/**
 * Checks that the expected string occurs within the content string.
 */// w w w.  j a va2s  . c o m
public static void assertContains(final String string, final String content) {
    if (content.indexOf(string) == -1) {
        throw new AssertionError(content + "' does not contain '" + string + "'");
    }
}

From source file:com.ticket.validation.terminal.restful.JsonObjectConverter.java

@Override
public TypedOutput toBody(Object object) {
    try {//from w  ww  .jav  a 2s.  c  om
        return new JsonTypedOutput(new Gson().toJson(object).getBytes(encoding), encoding);
    } catch (UnsupportedEncodingException e) {
        throw new AssertionError(e);
    }
}

From source file:com.alexshabanov.springrestapi.restapitest.DefaultRestTestSupport.java

@Override
public final MockHttpServletResponse handle(HttpServletRequest request) {
    final MockHttpServletResponse response = new MockHttpServletResponse();
    Object handler = null;//from  w  w w  . j  a  v a  2s.  com

    try {
        // delegates request processing to the spring facilities
        for (HandlerMapping mapping : context.getBeansOfType(HandlerMapping.class).values()) {
            final HandlerExecutionChain chain = mapping.getHandler(request);
            if (chain == null) {
                continue;
            }

            handler = chain.getHandler();
            if (handler != null) {
                handlerAdapter.handle(request, response, chain.getHandler());
                break;
            }
        }

        if (handler == null) {
            throw new AssertionError("Can't handle request in the current context");
        }
    } catch (Exception e) {
        if (handleException(e, request, response, handler)) {
            return response;
        }

        // exception mapping has not been found - propagate error outside the method boundaries
        throw new AssertionError(e);
    }

    return response;
}

From source file:co.paralleluniverse.common.monitoring.Monitor.java

public void registerMBean() {
    try {/* ww w. j  a v a  2  s . co  m*/
        LOG.info("Registering MBean {}", name);
        MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
        ObjectName mxbeanName = new ObjectName(name);
        mbs.registerMBean(this, mxbeanName);

        this.registered = true;
    } catch (InstanceAlreadyExistsException ex) {
        throw new RuntimeException(ex);
    } catch (MBeanRegistrationException ex) {
        throw new RuntimeException(ex);
    } catch (NotCompliantMBeanException ex) {
        throw new AssertionError(ex);
    } catch (MalformedObjectNameException ex) {
        throw new AssertionError(ex);
    }
}

From source file:com.wavemaker.tools.data.OperationWrapperGenerator.java

public String generate(String className, DataServiceOperation operation) {

    this.beanInfo = new BeanInfo(className);

    BeanGenerator generator = new BeanGenerator(className);

    generator.addClassJavadoc(//  w  w  w. j  ava  2 s  .c  om
            "Generated for query \"" + operation.getQueryName() + "\" on " + StringUtils.getFormattedDate());

    List<String> outputTypes = operation.getOutputTypes();
    List<String> outputNames = DataServiceUtils.getColumnNames(outputTypes.size(), operation.getOutputNames());

    int i = 0;
    boolean addSerializableMember = false;
    for (String type : operation.getOutputTypes()) {
        String name = outputNames.get(i);
        generator.addProperty(name, type);
        this.beanInfo.addProperty(name, type);
        i++;

        if (type.equals(CLOB_TYPE) || type.equals(BLOB_TYPE)) {
            addSerializableMember = true;
        }
    }

    ByteArrayOutputStream os = new ByteArrayOutputStream();

    try {
        if (addSerializableMember == false) {
            generator.generate(os);
        } else {
            generator.generateAux(os);
        }
    } catch (IOException ex) {
        throw new AssertionError(ex);
    }
    return os.toString();
}

From source file:at.beeone.netbankinglight.test.JsonParserTest.java

protected String getSampleJson(String filename) {
    try {// ww w  .j  a  v  a2s.c  om
        InputStream inputStream = getClass().getClassLoader().getResourceAsStream(filename);
        StringBuilder jsonString = IoHelper.readStream(inputStream);
        return jsonString.toString();
    } catch (Exception e) {
        throw new AssertionError(e);
    }
}

From source file:com.tech.utils.CustomCollectionUtil.java

/**
 * CustomCollectionUtil constructor is hidden to ensure this class cannot be
 * instantiated./*from  w  w w  .  j  a  v a 2s.c  o m*/
 */
private CustomCollectionUtil() {
    throw new AssertionError("Instantiation of this class in not allowed.");
}