Example usage for org.springframework.util Assert isTrue

List of usage examples for org.springframework.util Assert isTrue

Introduction

In this page you can find the example usage for org.springframework.util Assert isTrue.

Prototype

@Deprecated
public static void isTrue(boolean expression) 

Source Link

Document

Assert a boolean expression, throwing an IllegalArgumentException if the expression evaluates to false .

Usage

From source file:it.geosolutions.geoserver.rest.encoder.coverage.GSImageMosaicEncoderTest.java

/**
 * TODO implement this test//from  www  .  j a  v a  2 s  .c o m
 */
@Test
public void testAll() {
    final GSImageMosaicEncoder encoder = new GSImageMosaicEncoder();

    Assert.isNull(encoder.getUseJaiImageRead());

    encoder.setAllowMultithreading(true);

    Assert.isTrue(encoder.getAllowMultithreading());

    encoder.setAllowMultithreading(false);

    Assert.isTrue(!encoder.getAllowMultithreading());

    encoder.setSUGGESTED_TILE_SIZE("512,512");

    Assert.isTrue(encoder.getSuggestedTileSize().equalsIgnoreCase("512,512"));

    LOGGER.info(encoder.toString());

    encoder.addSUGGESTED_TILE_SIZE("512,512");

}

From source file:org.nebulaframework.util.io.IOSupport.java

/**
 * Overloaded version reads from the given {@codeInputStream} until end of stream
 * occurs or until a specified number of bytes is read (whichever occurs first). 
 * Returns the data read as a {@code byte[]}
 * /*from www . j a  va2  s  .  c om*/
 * @param is InputStream
 * 
 * @return bytes read as {@code byte[]} 
 * 
 * @throws IOException If IO error occurs during operation
 * @throws IllegalArgumentException if {@code InputStream} is {@code null}
 */
public static byte[] readBytes(InputStream is, long len) throws IOException, IllegalArgumentException {

    Assert.notNull(is);
    Assert.isTrue(len > 0);

    int byteRead = -1;
    List<Byte> list = new ArrayList<Byte>();

    // Read all bytes until specified 'len' bytes are read
    while (((byteRead = is.read()) != -1) || (len > 0)) {
        list.add((byte) byteRead);
        len--;
    }

    // Convert to byte[] and return
    return tobyteArray(list);
}

From source file:com.streamreduce.util.FeedClient.java

public FeedClient(Connection connection) {
    super(connection);

    this.feedUrl = connection.getUrl();

    Assert.isTrue(connection.getProviderId().equals(ProviderIdConstants.FEED_PROVIDER_ID));
}

From source file:org.arrow.test.WorkflowTestUtils.java

/**
 * Asserts whether all BPMN entities of the given {@link ProcessInstance}
 * has the state 'SUCCESS'.//  w w  w .  ja  v a 2 s . c  om
 * 
 * @param execRepo
 * @param pi
 */
public static void assertSuccessState(ExecutionRepository execRepo, ProcessInstance pi, String[] ids) {

    Set<Execution> executions = execRepo.findByProcessInstance(pi);
    Assert.notNull(executions);

    for (Execution execution : executions) {
        BpmnNodeEntity entity = (BpmnNodeEntity) execution.getEntity();
        State state = execution.getState();

        if (contains(ids, entity.getId())) {
            Assert.isTrue(State.SUCCESS.compareTo(state) == 0);
        }
    }
}

From source file:com.pw.ism.heartbeat.InMemoryHeartbeatRepositoryTest.java

@Test
public void shouldAddHeartBeat() throws Exception {
    Heartbeat hb1 = new Heartbeat();
    hb1.setCustomer("TEST1");
    hb1.setNetwork("NETWORK1");

    Heartbeat hb2 = new Heartbeat();
    hb2.setCustomer("CUST2");
    hb2.setNetwork("NETWORK2");

    repo.addHeartbeat(hb1, Instant.now().minusSeconds(5));
    repo.addHeartbeat(hb2, Instant.now().minusSeconds(2));

    List<Heartbeat> list = repo.getExpiredHeartbeats(6);
    Assert.isTrue(list.isEmpty());

    list = repo.getExpiredHeartbeats(3);
    Assert.isTrue(list.contains(hb1));//from  www  .  ja  v  a  2s. c o m

    list = repo.getExpiredHeartbeats(1);
    Assert.isTrue(list.contains(hb2));
    Assert.isTrue(list.contains(hb1));
}

From source file:com.sinosoft.one.mvc.web.instruction.RedirectInstruction.java

@Override
public void doRender(Invocation inv) throws IOException {
    String location = resolvePlaceHolder(location(), inv);
    if (sc == null || sc == 302) {
        String contextPath = inv.getRequest().getContextPath();
        if (!location.startsWith(contextPath)) {
            if (!location.startsWith("/")) {
                location = "/" + location;
            }//w w  w .ja v  a  2  s.co  m
            location = contextPath + location;
        }
        inv.getResponse().sendRedirect(location);
    } else {
        Assert.isTrue(sc == HttpServletResponse.SC_MOVED_PERMANENTLY);
        inv.getResponse().setStatus(sc);
        inv.getResponse().setHeader("Location", location);
    }
}

From source file:org.oncoblocks.centromere.web.test.security.TokenTests.java

@Test
public void tokenGeneration() {
    String token = tokenOperations.createToken(user);
    Assert.notNull(token);//from  w  w  w  .  j  a  v a2 s  .  c o m
    Assert.isTrue(!"".equals(token));
    Assert.isTrue(token.startsWith("user"));
}

From source file:com.cisco.oss.foundation.http.api.test.InterfacesResource.java

@GET
@Produces("text/plain")
//    @Transactional(rollbackFor=Exception.class)
public String requestGetIfs(@Context UriInfo uriInfo, @HeaderParam("Session-ID") String sessionId,
        @HeaderParam("Source-ID") String sourceId, @HeaderParam("Source-Type") String sourceType) {

    //        FlowContextFactory.createFlowContext();
    AUDITOR.info("starting InterfacesResource.requestGetIfs...");

    LOGGER.debug("psSms InterfacesResource: Get interfaces");

    //        Assert.isTrue(config != null);

    Assert.isTrue(FlowContextFactory.getFlowContext() != null);

    AUDITOR.info("exit InterfacesResource.requestGetIfs...");
    return "psSms adaptor v3.34.0; ICD version 2.10\n" + "01. (see 7.1 in ICD)   SMS notifies PS\n"
            + "02. (see 7.3 in ICD)   Notify Pin Change\n" + "03. (see 10.5 in ICD)  Unpair Devices\n"
            + "04. (see 10.8 in ICD)  Reset Master Pin\n"
            + "05. (see 10.14 in ICD) Refresh CPE Household data\n";
}

From source file:com.laxser.blitz.lama.provider.jdbc.JdbcDataAccess.java

public void setInterpreters(SQLInterpreter[] interpreters) {
    Assert.isTrue(interpreters.length > 0);
    this.interpreters = interpreters;
}

From source file:org.spring.beans.factory.config.BeanDependencyOrderVerificationBeanPostProcessor.java

@Override
public void afterPropertiesSet() throws Exception {
    Assert.notNull(beanNameOrderList);//from  w ww  .  j a va 2s.c  o  m
    Assert.isTrue(2 == beanNameOrderList.size());
    System.out.printf("Bean Name List is (%1$s)%n", beanNameOrderList);
}