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:security.LoginService.java

public static UserAccount getPrincipal() {
    UserAccount result;/*  ww w .j  av  a 2 s .c  om*/
    SecurityContext context;
    Authentication authentication;
    Object principal;

    // If the asserts in this method fail, then you're
    // likely to have your Tomcat's working directory
    // corrupt. Please, clear your browser's cache, stop
    // Tomcat, update your Maven's project configuration,
    // clean your project, clean Tomcat's working directory,
    // republish your project, and start it over.

    context = SecurityContextHolder.getContext();
    Assert.notNull(context);
    authentication = context.getAuthentication();
    Assert.notNull(authentication);
    principal = authentication.getPrincipal();
    Assert.isTrue(principal instanceof UserAccount);
    result = (UserAccount) principal;
    Assert.notNull(result);
    Assert.isTrue(result.getId() != 0);

    return result;
}

From source file:com.azaptree.services.security.SubjectAuthenticationToken.java

public SubjectAuthenticationToken(final UUID subjectId, final Map<String, Object> credentials,
        final boolean rememberMe) {
    Assert.notNull(subjectId, "subjectId is required");
    Assert.isTrue(!CollectionUtils.isEmpty(credentials));
    this.subjectId = subjectId;
    this.credentials = credentials;
    this.rememberMe = rememberMe;
}

From source file:org.oncoblocks.centromere.web.test.util.ConverterTests.java

@Test
public void attributeConverterTest() {
    StringToAttributeConverter converter = new StringToAttributeConverter();
    Attribute attribute = converter.convert("key:value");
    Assert.isTrue(attribute.getName().equals("key"));
    Assert.isTrue(attribute.getValue().equals("value"));
    attribute = converter.convert("key");
    Assert.isTrue(attribute.getName().equals("key"));
    Assert.isNull(attribute.getValue());
}

From source file:com.jaxio.celerio.configuration.Pack.java

public Pack(String name) {
    Assert.isTrue(!name.endsWith(".pack"));
    this.name = name;
}

From source file:com.google.code.guice.repository.spi.TypeUtil.java

/**
 * Finds and returns class of N parametrization parameter.
 *
 * @param aClass         generic class//from w  w  w .ja v a  2s  .  co  m
 * @param parameterIndex parameter index
 *
 * @return parameter class or {@code null} if parameter can't be found
 *
 * @throws IllegalArgumentException if specified {@code aClass} is null or {@code parameterIndex} &lt; 0
 */
public static Class getTypeParameterClass(Class aClass, int parameterIndex) {
    Assert.notNull(aClass);
    Assert.isTrue(parameterIndex >= 0);

    List<Type> types = new ArrayList<Type>();

    // check interfaces
    getGenericInterfacesActualTypes(types, aClass);

    Class result = findAppropriateType(types, parameterIndex);
    if (result == null) {
        types.clear();
        // check superclasses
        getGenericSuperclassActualTypes(types, aClass);
    }
    return findAppropriateType(types, parameterIndex);
}

From source file:com.laxser.blitz.web.instruction.RedirectInstruction.java

@Override
public void doRender(Invocation inv) throws IOException {
    String location = resolvePlaceHolder(location(), inv);
    if (sc == null || sc == 302) {
        inv.getResponse().sendRedirect(location);
    } else {/* www  . j av a 2  s  .  com*/
        Assert.isTrue(sc == HttpServletResponse.SC_MOVED_PERMANENTLY);
        inv.getResponse().setStatus(sc);
        inv.getResponse().setHeader("Location", location);
    }
}

From source file:fr.rktv.iamcore.test.hibernate.AuthHibernateDAOTest.java

/**
 * Test case for AddUser Method of Authenticate DAO
 * @throws IllegalArgumentException/*w ww .  ja  v  a 2 s.co  m*/
 * @throws IllegalAccessException
 */
@Test
public void addUserTest() throws IllegalArgumentException, IllegalAccessException {

    final Credentail user = new Credentail("testuser", "test");
    user.setLicense(license);
    final Credentail newUser = new Credentail("testuser", "test");
    authenticationDAO.addUser(user);
    Assert.isTrue(authenticationDAO.checkUserAuthentication(newUser));
}

From source file:org.appcomponents.platform.impl.WebApplication.java

@Override
public void setWebEnvironment(boolean webEnvironment) {
    Assert.isTrue(webEnvironment);
    super.setWebEnvironment(webEnvironment);
}

From source file:io.pivotal.poc.claimcheck.LocalFileClaimCheckStore.java

public LocalFileClaimCheckStore(File directory, IdGenerator idGenerator) {
    Assert.notNull(directory, "directory must not be null");
    Assert.notNull(idGenerator, "IdGenerator must not be null");
    if (directory.exists()) {
        Assert.isTrue(directory.isDirectory());
    } else {/*from ww w  .j av a2  s  .  c  o m*/
        directory.mkdirs();
    }
    this.directory = directory;
    this.idGenerator = idGenerator;
}

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

/**
 * TODO implement this test//w  w w  . j a  v a2  s. c om
 */
@Test
public void testAll() {
    final GSJP2KEncoder encoder = new GSJP2KEncoder();

    Assert.isNull(encoder.getUseJaiImageRead());

    encoder.setUseMultithreading(true);
    LOGGER.info(encoder.toString());
    Assert.isTrue(encoder.getUseMultithreading());

    encoder.setUseMultithreading(false);

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

    encoder.setSuggestedTileSize("512,512");

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

    LOGGER.info(encoder.toString());

}