List of usage examples for org.springframework.util Assert isTrue
public static void isTrue(boolean expression, Supplier<String> messageSupplier)
From source file:org.wallride.support.ProxySecureChannelProcessor.java
@Override public void decide(FilterInvocation invocation, Collection<ConfigAttribute> config) throws IOException, ServletException { Assert.isTrue((invocation != null) && (config != null), "Nulls cannot be provided"); String forwardedProto = invocation.getHttpRequest().getHeader("X-Forwarded-Proto"); for (ConfigAttribute attribute : config) { if (supports(attribute)) { if (forwardedProto != null) { if (!forwardedProto.equals("https")) { getEntryPoint().commence(invocation.getRequest(), invocation.getResponse()); }/*from w ww. j a v a2 s.c o m*/ } else { if (!invocation.getHttpRequest().isSecure()) { getEntryPoint().commence(invocation.getRequest(), invocation.getResponse()); } } } } }
From source file:org.springmodules.validation.util.io.FileIterator.java
public FileIterator(File dir) { Assert.isTrue(dir.isDirectory(), "Given file must be a directory"); fileIterator = new ArrayIterator(dir.listFiles()); }
From source file:org.springmodules.validation.util.condition.string.MaxLengthStringCondition.java
/** * Creates a new MaxLengthStringCondition with a given maximum length. * * @param maxLength The maximum length the checked string will be checked against. *//*from w ww .j av a 2s . c o m*/ public MaxLengthStringCondition(int maxLength) { Assert.isTrue(maxLength >= 0, "Given maximum length must be a non-negative value"); this.maxLength = maxLength; }
From source file:org.springside.modules.test.utils.SeleniumUtils.java
/** * ?driverName??WebDriver./*ww w . jav a2 s .c o m*/ * * ????Windows, IE?XWindows, ?remote dirverWindows. * drivernameremote:192.168.0.2:3000:firefox, ??http://192.168.0.2:3000/wd?selnium remote?. */ public static WebDriver buildDriver(String driverName) throws Exception { WebDriver driver = null; if (HTMLUNIT.equals(driverName)) { driver = new HtmlUnitDriver(); ((HtmlUnitDriver) driver).setJavascriptEnabled(true); } if (FIREFOX.equals(driverName)) { driver = new FirefoxDriver(); } if (IE.equals(driverName)) { driver = new InternetExplorerDriver(); } if (driverName.startsWith(REMOTE)) { String[] params = driverName.split(":"); Assert.isTrue(params.length == 4, "Remote driver is not right, accept format is \"remote:localhost:3000:firefox\", but the input is\"" + driverName + "\""); String remoteHost = params[1]; String remotePort = params[2]; String driverType = params[3]; DesiredCapabilities cap = null; if (FIREFOX.equals(driverType)) { cap = DesiredCapabilities.firefox(); } if (IE.equals(driverType)) { cap = DesiredCapabilities.internetExplorer(); } driver = new RemoteWebDriver(new URL("http://" + remoteHost + ":" + remotePort + "/wd"), cap); } Assert.notNull(driver, "No driver could be found by name:" + driverName); return driver; }
From source file:com.github.springtestdbunit.DatabaseConnections.java
public DatabaseConnections(String[] names, IDatabaseConnection[] connections) { Assert.notEmpty(names, "Names must not be empty"); Assert.notEmpty(connections, "Connections must not be empty"); Assert.isTrue(names.length == connections.length, "Names and Connections must have the same length"); this.names = names; this.connections = connections; }
From source file:org.twinkql.context.Qname.java
/** * To qname./*w ww . ja v a 2 s. com*/ * * @param qualifiedName the qualified name * @return the qname */ public static Qname toQname(String qualifiedName) { String[] names = StringUtils.split(qualifiedName, ":"); Assert.isTrue(names.length == 2, "Error parsing Qualified Name: " + qualifiedName + ". A QualifiedName" + " must be in the format '[namespace]:[localname]."); return new Qname(names[0], names[1]); }
From source file:org.cloudfoundry.identity.uaa.scim.PasswordChangeRequest.java
public void setSchemas(String[] schemas) { Assert.isTrue(Arrays.equals(ScimUser.SCHEMAS, schemas), "Only schema '" + ScimUser.SCHEMAS[0] + "' is currently supported"); }
From source file:org.grails.datastore.gorm.mongo.Near.java
@Override public void setArguments(Object[] arguments) { Assert.isTrue(arguments.length > 0 && arguments[0] instanceof List, "Only a list of elements is supported in an 'near' query"); Collection<?> argument = (Collection<?>) arguments[0]; Assert.isTrue(argument.size() == 2, "A 'near' query requires a two dimensional list of values"); super.setArguments(arguments); }
From source file:com.cxplonka.feature.service.controller.CustomerController.java
@RequestMapping(value = "/{id}", method = RequestMethod.GET) public Customer findOne(@PathVariable long id) { Assert.isTrue(id > 0, "No valid primary key."); return repository.findOne(id); }
From source file:com.frank.search.solr.core.query.result.SimpleGroupResult.java
public SimpleGroupResult(int matches, Integer groupsCount, String name, Page<GroupEntry<T>> groupEntries) { Assert.isTrue(matches >= 0, "matches must be >= 0"); Assert.hasLength(name, "group result name must be not empty"); Assert.notNull(groupEntries, "groupEntries must be not null"); this.matches = matches; this.groupsCount = groupsCount; this.name = name; this.groupEntries = groupEntries; }