List of usage examples for org.springframework.util Assert isTrue
public static void isTrue(boolean expression, Supplier<String> messageSupplier)
From source file:org.apache.cxf.fediz.service.idp.service.jpa.TrustedIdpDAOJPATest.java
@Test public void testReadAllTrustedIdps() { List<TrustedIdp> trustedIdps = trustedIdpDAO.getTrustedIDPs(0, 999); Assert.isTrue(2 <= trustedIdps.size(), "Size doesn't match"); }
From source file:org.apache.cxf.fediz.service.idp.service.jpa.ClaimDAOJPATest.java
@Test public void testReadExistingClaim() { Claim claim = claimDAO.getClaim("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/givenname"); Assert.isTrue("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/givenname" .equals(claim.getClaimType().toString()), "ClaimType doesn't match"); Assert.isTrue("firstname".equals(claim.getDisplayName()), "Claim Display name doesn't match"); Assert.isTrue("Description for firstname".equals(claim.getDescription()), "Claim Description name doesn't match"); }
From source file:com.athena.peacock.controller.web.ospackage.PackageController.java
@RequestMapping("/list") public @ResponseBody GridJsonResponse list(GridJsonResponse jsonRes, PackageDto ospackage) throws Exception { Assert.isTrue(StringUtils.isNotEmpty(ospackage.getMachineId()), "machineId must not be null."); jsonRes.setTotal(packageService.getPackageListCnt(ospackage)); jsonRes.setList(packageService.getPackageList(ospackage)); return jsonRes; }
From source file:cz.jirutka.spring.http.client.cache.internal.SizeLimitedHttpResponseReader.java
/** * @param maxBodySize The maximal size to read in bytes. It must be * greater then zero and should be multiple of the * {@code bufferSize}. * @param bufferSize The buffer size in bytes. It must be greater then zero. *//*from w ww . j av a 2s .c om*/ public SizeLimitedHttpResponseReader(int maxBodySize, int bufferSize) { Assert.isTrue(maxBodySize > 0, "bytesLimit must be greater then zero"); Assert.isTrue(maxBodySize > 0, "bufferSize must be greater then zero"); this.maxBodySize = maxBodySize; this.bufferSize = bufferSize; }
From source file:org.codehaus.griffon.plugins.AbstractGriffonPlugin.java
public AbstractGriffonPlugin(Class pluginClass, GriffonContext application) { Assert.notNull(pluginClass, "Argument [pluginClass] cannot be null"); Assert.isTrue(pluginClass.getName().endsWith(TRAILING_NAME), "Argument [pluginClass] with value [" + pluginClass + "] is not a Griffon plugin (class name must end with 'GriffonPlugin')"); this.application = application; this.pluginClass = pluginClass; }
From source file:com.jaxio.celerio.configuration.database.ForeignKey.java
public void addImportedKey(ImportedKey key) { if (importedKeys.isEmpty()) { name = key.getFkName();//from ww w . j a v a 2 s .co m } else { Assert.isTrue(name.equalsIgnoreCase(key.getFkName()), "FkName must be the same"); } importedKeys.add(key); }
From source file:at.porscheinformatik.common.spring.web.extended.expression.CdnExpressionHandler.java
private String buildLink(CdnEntry entry) { String link = config.isOptimizeResources() ? entry.getMinifiedLocation() : entry.getLocation(); int index = link.lastIndexOf("."); Assert.isTrue(index > 0, "Value for CDN must contain an ending [" + link + "]"); String ending = link.substring(index + 1); if ("js".equals(ending)) { return HtmlUtils.buildScriptLink(link); } else if ("css".equals(ending)) { return HtmlUtils.buildStyleLink(link); } else {/* w ww . ja v a2s .com*/ throw new IllegalArgumentException("Ending ." + ending + " not known"); } }
From source file:org.kmnet.com.fw.common.codelist.EnumCodeList.java
/** * Constructor.// w w w .ja v a 2 s . c om * * @param enumClass Enum class of which this codelist consists. Must implement {@link CodeListItem} * @throws java.lang.IllegalArgumentException if the given class does not implement {@link CodeListItem} */ public EnumCodeList(Class<? extends Enum<?>> enumClass) { Assert.isTrue(CodeListItem.class.isAssignableFrom(enumClass), "the given enumClass must implement " + CodeListItem.class); Map<String, String> codeList = new LinkedHashMap<String, String>(); Method method = ReflectionUtils.findMethod(enumClass, "values"); Enum<?>[] result = (Enum<?>[]) ReflectionUtils.invokeMethod(method, enumClass); for (Enum<?> e : result) { CodeListItem item = (CodeListItem) e; codeList.put(item.getCodeValue(), item.getCodeLabel()); } this.codeListMap = Collections.unmodifiableMap(codeList); }
From source file:org.apache.cxf.fediz.service.idp.service.jpa.EntitlementDAOJPATest.java
@Test public void testReadExistingEntitlement() { Entitlement entitlement = entitlementDAO.getEntitlement("CLAIM_LIST"); Assert.isTrue("CLAIM_LIST".equals(entitlement.getName()), "Entitlement name doesn't match"); Assert.isTrue("Description for CLAIM_LIST".equals(entitlement.getDescription()), "Entitlement Description doesn't match"); }
From source file:com.codeabovelab.dm.cluman.cluster.registry.DockerRegistryAuthAdapter.java
@Override public void handle(AuthContext ctx) { String tokenReq = ctx.getAuthenticate(); String[] split = StringUtils.split(tokenReq, " "); Assert.isTrue(split.length == 2, "invalid token request " + tokenReq); String type = split[0];/* w w w .ja v a 2s .c o m*/ switch (type) { case "Bearer": Map<String, String> map = Splitter.on(",").withKeyValueSeparator("=").split(split[1].replace("\"", "")); AuthInfo authInfo = AuthInfo.builder().realm(map.get("realm")).service(map.get("service")) .scope(map.get("scope")).build(); String token = getToken(authInfo); ctx.getRequestHeaders().add(AUTHORIZATION, "Bearer " + token); break; case "Basic": ctx.getRequestHeaders().add(AUTHORIZATION, createBasicHeader(provider.getRegistryCredentials())); break; default: throw new IllegalArgumentException("Invalid token string " + tokenReq); } }