List of usage examples for junit.framework Assert assertEquals
static public void assertEquals(int expected, int actual)
From source file:edu.txstate.dmlab.clusteringwiki.cluster.ClusterDocumentComparisonTest.java
@Test public void testClusterDocSimilarityToItself() throws Exception { final CollectionContext ctx = getTestContext(); final IClusterDocument d1 = new ClusterDocument(0, null, ctx); final IClusterDocument d2 = new ClusterDocument(1, null, ctx); String[] terms = new String[] { "hello", "world", "and", "some", "other", "terms", "in", "text" }; int[] tc = new int[] { 2, 1, 1, 1, 2, 1, 1, 2 }; for (int i = 0; i < terms.length; i++) { int index = ctx.getTermId(terms[i]); d1.add(index, tc[i], false);//from www . ja v a 2 s . co m d2.add(index, tc[i], false); } d1.rebuildArrays(); d2.rebuildArrays(); double sim = d1.computeSimilarity(d2); Assert.assertEquals(sim, 1.0D); }
From source file:org.ocpsoft.rewrite.servlet.config.RequestConstraintTransformTest.java
@Test public void testSatisfiedConstraintPreventsRuleExecution() throws Exception { HttpAction<HttpGet> action = get("/constraint/ONE/TWO"); Assert.assertEquals(211, action.getResponse().getStatusLine().getStatusCode()); }
From source file:com.brienwheeler.lib.spring.beans.AutowireUtilsTest.java
@Test public void testGetAutowireBeans() { SmartClassPathXmlApplicationContext context = new SmartClassPathXmlApplicationContext( TestConstants.CTX_BEAN_DUMPER); Collection<ContextBeanDumper> beanDumpers = AutowireUtils.getAutowireBeans(context, ContextBeanDumper.class, log);/*from w w w . j a va 2s. co m*/ Assert.assertEquals(1, beanDumpers.size()); Collection<PropertyPlaceholderConfigurer> configurers = AutowireUtils.getAutowireBeans(context, PropertyPlaceholderConfigurer.class, log); Assert.assertEquals(0, configurers.size()); }
From source file:org.ocpsoft.rewrite.servlet.config.RequestNullBindingTest.java
@Test public void testNonLongBinding() throws Exception { HttpAction<HttpGet> action = get("/foo/abc"); Assert.assertEquals(500, action.getResponse().getStatusLine().getStatusCode()); }
From source file:org.ocpsoft.rewrite.servlet.config.ResourceReadParamsInConditionTest.java
@Test public void testParamReadsForNotMatchingCondition() throws Exception { HttpAction<HttpGet> action = get("/missing.txt"); Assert.assertEquals(404, action.getResponse().getStatusLine().getStatusCode()); }
From source file:com.netflix.simianarmy.conformity.TestCrossZoneLoadBalancing.java
@Test public void testEnabledCrossZoneLoadBalancing() { Cluster cluster = new Cluster("cluster1", "us-east-1", new AutoScalingGroup("asg2")); Conformity result = check(cluster);//from www. j av a2 s. c o m Assert.assertEquals(result.getRuleId(), getName()); Assert.assertEquals(result.getFailedComponents().size(), 0); }
From source file:com.nomsic.randb.persistence.xml.JaxbIndexTest.java
@Test public void testRead() throws RandbException { File file = new File(TARGET_TEST_DATA_INDEX_XML); Index index = new Index(); String key = "name"; String value = "filename"; index.addBlockGroup(key, value);/*from w w w . jav a 2 s . c o m*/ jaxbUtil.write(index, file); index = (Index) jaxbUtil.read(file); Assert.assertTrue(index.getIndexMap().containsKey(key)); Assert.assertEquals(value, index.getIndexMap().get(key)); }
From source file:com.googlecode.fascinator.storage.ram.RamStorageTest.java
@Test public void createObject() throws Exception { // Create a test object DigitalObject newObject = ram.createObject("oai:eprints.usq.edu.au:318"); Payload dcPayload = newObject.createStoredPayload("oai_dc", IOUtils.toInputStream("<dc><title>test</title></dc>")); dcPayload.setLabel("Dublin Core Metadata"); // Makes sure the object reports only 1 payload Set<String> payloads = newObject.getPayloadIdList(); Assert.assertEquals(1, payloads.size()); // Make sure our payload retrieves and is labelled correctly Payload payload = newObject.getPayload("oai_dc"); Assert.assertEquals("Dublin Core Metadata", payload.getLabel()); // Remove the payload and recheck object payload size newObject.removePayload(payload.getId()); payloads = newObject.getPayloadIdList(); Assert.assertEquals(0, payloads.size()); // Remove the object from storage try {/*from w w w .ja v a 2 s . co m*/ ram.removeObject(newObject.getId()); } catch (StorageException ex) { Assert.fail("Error deleting newObject : " + ex.getMessage()); } }
From source file:com.rackspacecloud.blueflood.io.serializers.EnumRollupSerializationTest.java
@Test public void testEnumV1RoundTrip() throws IOException { BluefloodEnumRollup e0 = new BluefloodEnumRollup().withEnumValue("enumValue1", 1L) .withEnumValue("enumValue2", 5L); BluefloodEnumRollup e1 = new BluefloodEnumRollup().withEnumValue( "t4.enum.abcdefg.hijklmnop.qrstuvw.xyz.ABCDEFG.HIJKLMNOP.QRSTUVW.XYZ.abcdefg.hijklmnop.qrstuvw.xyz.met", 34454722343L)//from www. j a va 2s . c o m .withEnumValue( "t5.enum.abcdefg.hijklmnop.qrstuvw.xyz.ABCDEFG.HIJKLMNOP.QRSTUVW.XYZ.abcdefg.hijklmnop.qrstuvw.xyz.met", 34454722343L) .withEnumValue("enumValue2", 10L); BluefloodEnumRollup e2 = new BluefloodEnumRollup().withEnumValue("enumValue1", 1L) .withEnumValue("enumValue1", 1L); BluefloodEnumRollup er = BluefloodEnumRollup .buildRollupFromEnumRollups(Rollups.asPoints(BluefloodEnumRollup.class, 0, 300, e0, e1, e2)); Assert.assertEquals(4, er.getCount()); Map<Long, Long> map = er.getHashedEnumValuesWithCounts(); Assert.assertTrue(map.get((long) "enumValue1".hashCode()) == 3L); Assert.assertTrue(map.get((long) "enumValue2".hashCode()) == 15L); ByteArrayOutputStream baos = new ByteArrayOutputStream(); baos.write(Base64.encodeBase64(new NumericSerializer.EnumRollupSerializer().toByteBuffer(e0).array())); baos.write("\n".getBytes()); baos.write(Base64.encodeBase64(new NumericSerializer.EnumRollupSerializer().toByteBuffer(e1).array())); baos.write("\n".getBytes()); baos.write(Base64.encodeBase64(new NumericSerializer.EnumRollupSerializer().toByteBuffer(e2).array())); baos.write("\n".getBytes()); baos.write(Base64.encodeBase64(new NumericSerializer.EnumRollupSerializer().toByteBuffer(er).array())); baos.write("\n".getBytes()); baos.close(); BufferedReader reader = new BufferedReader( new InputStreamReader(new ByteArrayInputStream(baos.toByteArray()))); ByteBuffer bb = ByteBuffer.wrap(Base64.decodeBase64(reader.readLine().getBytes())); BluefloodEnumRollup ee0 = NumericSerializer.serializerFor(BluefloodEnumRollup.class).fromByteBuffer(bb); Assert.assertEquals(e0, ee0); bb = ByteBuffer.wrap(Base64.decodeBase64(reader.readLine().getBytes())); BluefloodEnumRollup ee1 = NumericSerializer.serializerFor(BluefloodEnumRollup.class).fromByteBuffer(bb); Assert.assertEquals(e1, ee1); bb = ByteBuffer.wrap(Base64.decodeBase64(reader.readLine().getBytes())); BluefloodEnumRollup ee2 = NumericSerializer.serializerFor(BluefloodEnumRollup.class).fromByteBuffer(bb); Assert.assertEquals(e2, ee2); bb = ByteBuffer.wrap(Base64.decodeBase64(reader.readLine().getBytes())); BluefloodEnumRollup ee3 = NumericSerializer.serializerFor(BluefloodEnumRollup.class).fromByteBuffer(bb); Assert.assertEquals(er, ee3); Assert.assertFalse(ee0.equals(ee1)); }
From source file:org.openxdata.server.service.impl.RoleServiceTest.java
@Test public void deleteRole_shouldNotDeleteAdminRole() throws Exception { List<Role> roles = roleService.getRoles(); Assert.assertEquals(2, roles.size()); Role role = roles.get(0);//from www. j av a 2s . co m roleService.deleteRole(role); Assert.assertEquals(2, roleService.getRoles().size()); }