List of usage examples for java.lang AssertionError AssertionError
public AssertionError(double detailMessage)
double
, which is converted to a string as defined in section 15.18.1.1 of The Java™ Language Specification. From source file:com.hurence.logisland.utils.HttpUtils.java
public static void populateKeyValueListFromUrlQuery(String urlQuery, List<String> keys, List<String> values) { try {/* w w w . j av a2s . c o m*/ if (urlQuery == null) { return; } for (String param : urlQuery.split("&")) { try { QueryParam queryParam = new QueryParam(); String[] pair = param.split("="); if (pair.length == 0) { continue; } String value = ""; String key = URLDecoder.decode(pair[0], "UTF-8"); if (key != null && !key.equals("null")) { keys.add(key); } if (pair.length > 1) { value = URLDecoder.decode(pair[1], "UTF-8"); } if (value != null && !value.equals("null")) { values.add(value); } } catch (IllegalArgumentException ex) { log.debug("error decoding value : " + ex); } } } catch (UnsupportedEncodingException ex) { throw new AssertionError(ex); } }
From source file:bi.meteorite.pages.SaikuTable.java
public void shouldNotHaveRowElementsWhere(BeanMatcher... matchers) { List<WebElement> rows = getRowElementsWhere(matchers); if (!rows.isEmpty()) { throw new AssertionError("Expecting a table with no rows where: " + Arrays.deepToString(matchers)); }/*from w w w .java 2s.c o m*/ }
From source file:com.galeoconsulting.leonardinius.api.impl.ChainingClassLoader.java
private Class<?> callFindClass(ClassLoader classloader, String name) throws ClassNotFoundException { try {//from w w w .j a v a 2 s . c o m return (Class<?>) MethodsHolder.findClassMethod.invoke(classloader, name); } catch (IllegalAccessException e) { throw new AssertionError(e); //unexpected } catch (InvocationTargetException e) { if (e.getTargetException() instanceof ClassNotFoundException) { throw (ClassNotFoundException) e.getTargetException(); } throw new AssertionError(e); // unexpected } }
From source file:com.wickettasks.business.services.user.TestUserService.java
@Test(expected = IllegalArgumentException.class) public void anEmailIsMandatoryToCreateAnUser() { try {// w ww .j a v a2 s. c o m this.userService.add(null, "password"); } catch (ExistingUserException e) { throw new AssertionError(e); } }
From source file:com.sunchenbin.store.feilong.core.io.FilenameUtil.java
/** Don't let anyone instantiate this class. */ private FilenameUtil() { //AssertionError?. ?????. ???. //see Effective Java 2nd throw new AssertionError("No " + getClass().getName() + " instances for you!"); }
From source file:com.hoccer.tools.TestHelper.java
public static void blockUntilEquals(String pFailMessage, long pTimeout, Object pExpected, final TestHelper.Measurement pMesurement) throws Exception { Object mesuredValue = null;//from w ww. j ava2s . c o m long start = System.currentTimeMillis(); while (System.currentTimeMillis() - start < pTimeout) { mesuredValue = pMesurement.getActualValue(); if (pExpected.equals(mesuredValue)) { return; } try { Thread.sleep(20); } catch (InterruptedException e) { throw new AssertionError(e); } } throw new AssertionFailedError( pFailMessage + ": should be <" + pExpected + ">, but was <" + mesuredValue + ">"); }
From source file:com.asakusafw.directio.hive.serde.DataModelDriver.java
/** * Creates a new instance./* ww w . ja v a 2 s.c o m*/ * @param descriptor the target data model descriptor * @param sourceInspector the object inspector for the drive data * @param configuration the driver configuration */ public DataModelDriver(DataModelDescriptor descriptor, StructObjectInspector sourceInspector, DataModelMapping configuration) { this.sourceInspector = sourceInspector; List<Mapping> mappings; switch (configuration.getFieldMappingStrategy()) { case NAME: mappings = computeMappingByName(descriptor, sourceInspector); break; case POSITION: mappings = computeMappingByPosition(descriptor, sourceInspector); break; default: throw new AssertionError(configuration.getFieldMappingStrategy()); } List<StructField> sources = new ArrayList<>(); List<PropertyDescriptor> targets = new ArrayList<>(); for (Mapping mapping : mappings) { if (checkMapping(descriptor, mapping, configuration)) { assert mapping.source != null; assert mapping.target != null; sources.add(mapping.source); targets.add(mapping.target); if (LOG.isDebugEnabled()) { LOG.debug(MessageFormat.format("Map column: {0}:{1} -> {2}:{3}", //$NON-NLS-1$ mapping.source.getFieldName(), mapping.source.getFieldObjectInspector().getTypeName(), mapping.target.getFieldName(), mapping.target.getTypeInfo())); } } } assert sources.size() == targets.size(); this.sourceFields = sources.toArray(new StructField[sources.size()]); this.targetProperties = targets.toArray(new PropertyDescriptor[targets.size()]); this.propertyDrivers = new ValueDriver[sourceFields.length]; for (int i = 0; i < sourceFields.length; i++) { propertyDrivers[i] = targetProperties[i].getDriver(sourceFields[i].getFieldObjectInspector()); } }
From source file:com.joyent.manta.serialization.EncryptedMultipartUploadSerializationHelperTest.java
public void canSerializeAndDeserializeUpload() throws IOException { final UUID uploadId = new UUID(0L, 0L); final String path = "/user/stor/myObject"; final String partsDir = "/user/uploads/0/" + uploadId; final ServerSideMultipartUpload inner = new ServerSideMultipartUpload(uploadId, path, partsDir); final EncryptionContext encryptionContext = new EncryptionContext(secretKey, cipherDetails); final EncryptionState encryptionState = new EncryptionState(encryptionContext); @SuppressWarnings("unchecked") final EncryptedMultipartUpload<ServerSideMultipartUpload> upload = (EncryptedMultipartUpload<ServerSideMultipartUpload>) newUploadInstance( inner, encryptionState);// w w w . j av a 2 s .c o m Field cipherStreamField = ReflectionUtils.getField(EncryptionState.class, "cipherStream"); MultipartOutputStream multipartStream = new MultipartOutputStream(cipherDetails.getBlockSizeInBytes()); OutputStream cipherStream = EncryptingEntityHelper.makeCipherOutputForStream(multipartStream, encryptionContext); try { FieldUtils.writeField(cipherStreamField, encryptionState, cipherStream); } catch (IllegalAccessException e) { throw new AssertionError(e); } final byte[] serializedData = helper.serialize(upload); final EncryptedMultipartUpload<ServerSideMultipartUpload> deserialized = helper.deserialize(serializedData); Assert.assertEquals(upload, deserialized); }
From source file:com.discovery.darchrow.date.DateExtensionUtil.java
/** Don't let anyone instantiate this class. */ private DateExtensionUtil() { //AssertionError?. ?????. ???. //see Effective Java 2nd throw new AssertionError("No " + getClass().getName() + " instances for you!"); }
From source file:com.netflix.adminresources.AdminResourceTest.java
@Test(expected = HttpHostConnectException.class) public void testCustomPort() throws Exception { ConfigurationManager.getConfigInstance().setProperty(AdminResourcesContainer.CONTAINER_LISTEN_PORT, CUSTOM_LISTEN_PORT);/*from w ww . j ava 2s . co m*/ startServer(); HttpClient client = new DefaultHttpClient(); HttpGet healthGet = new HttpGet( "http://localhost:" + AdminResourcesContainer.LISTEN_PORT_DEFAULT + "/healthcheck"); client.execute(healthGet); throw new AssertionError("Admin container did not bind to the custom port " + CUSTOM_LISTEN_PORT + ", instead listened to default port: " + AdminResourcesContainer.LISTEN_PORT_DEFAULT); }