List of usage examples for junit.framework Assert assertEquals
static public void assertEquals(int expected, int actual)
From source file:org.ocpsoft.rewrite.servlet.config.EncodeQueryConfigurationTest.java
@Test public void testQueryEncodingExclusions() throws Exception { HttpAction<HttpGet> action = get("/encodequeryexcluding?foo=bar&keep=this"); Assert.assertEquals(210, action.getResponse().getStatusLine().getStatusCode()); Assert.assertTrue(action.getCurrentContextRelativeURL().contains("c=")); Assert.assertTrue(action.getCurrentContextRelativeURL().contains("keep=this")); }
From source file:org.ocpsoft.rewrite.cdi.bridge.CdiMultipleFeaturesTest.java
@Test public void testRewriteProviderBridgeAcceptsChanges() throws Exception { HttpAction<HttpGet> action = get("/success"); Assert.assertEquals(200, action.getResponse().getStatusLine().getStatusCode()); }
From source file:com.rackspacecloud.blueflood.io.serializers.astyanax.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 ww w . java 2 s . c om .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(Serializers.enumRollupInstance.toByteBuffer(e0).array())); baos.write("\n".getBytes()); baos.write(Base64.encodeBase64(Serializers.enumRollupInstance.toByteBuffer(e1).array())); baos.write("\n".getBytes()); baos.write(Base64.encodeBase64(Serializers.enumRollupInstance.toByteBuffer(e2).array())); baos.write("\n".getBytes()); baos.write(Base64.encodeBase64(Serializers.enumRollupInstance.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 = Serializers.serializerFor(BluefloodEnumRollup.class).fromByteBuffer(bb); Assert.assertEquals(e0, ee0); bb = ByteBuffer.wrap(Base64.decodeBase64(reader.readLine().getBytes())); BluefloodEnumRollup ee1 = Serializers.serializerFor(BluefloodEnumRollup.class).fromByteBuffer(bb); Assert.assertEquals(e1, ee1); bb = ByteBuffer.wrap(Base64.decodeBase64(reader.readLine().getBytes())); BluefloodEnumRollup ee2 = Serializers.serializerFor(BluefloodEnumRollup.class).fromByteBuffer(bb); Assert.assertEquals(e2, ee2); bb = ByteBuffer.wrap(Base64.decodeBase64(reader.readLine().getBytes())); BluefloodEnumRollup ee3 = Serializers.serializerFor(BluefloodEnumRollup.class).fromByteBuffer(bb); Assert.assertEquals(er, ee3); Assert.assertFalse(ee0.equals(ee1)); }
From source file:org.jasig.ssp.util.importer.job.twodottwo.RawItemHeaderFailTest.java
@SuppressWarnings("unchecked") @Test//ww w . j a va 2 s . c om public void testJob() throws Exception { JobExecution jobExecution = jobLauncherTestUtils.launchJob(); Map<String, ReportEntry> report = (Map<String, ReportEntry>) jobExecution.getExecutionContext() .get("report"); Assert.assertNotNull(report); Set<Entry<String, ReportEntry>> entrySet = report.entrySet(); Assert.assertEquals(1, entrySet.size()); for (Entry<String, ReportEntry> entry : entrySet) { Assert.assertEquals(new Integer(0), entry.getValue().getNumberInsertedUpdated()); //TODO this should eventually be 1 see SSP-1919 Assert.assertEquals(new Integer(3), entry.getValue().getNumberParsed()); Assert.assertEquals(new Integer(3), entry.getValue().getNumberSkippedOnParse()); } List<ErrorEntry> errors = (List<ErrorEntry>) jobExecution.getExecutionContext().get("errors"); Assert.assertEquals(3, errors.size()); for (ErrorEntry error : errors) { Assert.assertEquals(new Integer(-1), new Integer(Integer.parseInt(error.getLineNumber()))); } }
From source file:ar.com.zauber.commons.xmpp.message.XMPPMessageTest.java
/** mensaje simple, error */ @Test/*from www . j a v a 2 s .c om*/ public final void testSimpleError() throws Exception { final XMPPMessage c = new XMPPMessage("body", "title"); c.setMessageType(Type.error); org.jivesoftware.smack.packet.Message m = c.getXMPPMessage("juan"); m.setPacketID("0"); Assert.assertEquals(getResult("simple-error.xml"), m.toXML()); }
From source file:org.ocpsoft.rewrite.servlet.wrapper.ResponseContentInterceptorTest.java
@Test public void testResponseBufferingAppliesAllBuffers() throws Exception { HttpAction<HttpGet> action = get("/index.html"); Assert.assertEquals(200, action.getStatusCode()); Assert.assertEquals("lowercase", action.getResponseContent()); }
From source file:org.opencastproject.remotetest.server.IngestZipTest.java
@Test public void testIngestZip() throws Exception { byte[] bytesToPost = IOUtils.toByteArray(getClass().getClassLoader().getResourceAsStream("ingest.zip")); HttpPost post = new HttpPost(BASE_URL + "/ingest/addZippedMediaPackage"); post.setEntity(new ByteArrayEntity(bytesToPost)); HttpResponse response = client.execute(post); Assert.assertEquals(200, response.getStatusLine().getStatusCode()); }
From source file:com.dianping.maven.plugin.tools.misc.file.BytemanScriptGeneratorTest.java
@Test public void test() throws Exception { String expected = "# usage:\n" + "# -javaagent:{BYTEMAN_HOME}/lib/byteman.jar=script:{BTM_HOME}/{BTM_NAME},boot:{BYTEMAN_HOME}/lib/byteman.jar -Dorg.jboss.byteman.transform.all\n" + "#\n" + "RULE lion change\n" + "CLASS com.dianping.lion.client.InitializeConfig\n" + "METHOD postProcessBeanFactory\n" + "AT INVOKE setPts\n" + "IF true\n" + "DO $this.pts.put(\"http://service.dianping.com/hawk/alarm/commonAlarmSerivce\", \"192.168.8.2:1234\");\n" + " $this.pts.put(\"alpaca.url\", \"http://www.dianping.com\");\n" + " System.out.println(\"Phoenix runtime config modification complete...\")\n" + "ENDRULE"; Map<String, String> args = new HashMap<String, String>(); args.put("http://service.dianping.com/hawk/alarm/commonAlarmSerivce", "192.168.8.2:1234"); args.put("alpaca.url", "http://www.dianping.com"); BytemanScriptGenerator bsg = new BytemanScriptGenerator(); bsg.generate(file, args);/*from w ww . jav a 2 s. c o m*/ Assert.assertEquals(expected, FileUtils.readFileToString(file)); }
From source file:org.deviceconnect.android.manager.test.JSONConversionTest.java
/** * dConnectManager?BundleJSON????????????. * // w ww.ja v a 2 s . c om * @throws JSONException ??????? */ public void testConversion() throws JSONException { StringBuilder builder = new StringBuilder(); builder.append(DCONNECT_MANAGER_URI); builder.append("/json_test"); builder.append("?"); builder.append(DConnectMessage.EXTRA_DEVICE_ID + "=" + getDeviceId()); builder.append("&"); builder.append(DConnectMessage.EXTRA_ACCESS_TOKEN + "=" + getAccessToken()); HttpUriRequest request = new HttpGet(builder.toString()); JSONObject response = sendRequest(request); assertResultOK(response); JSONObject root = response.getJSONObject("extra"); Assert.assertNotNull("root is null.", root); Assert.assertFalse(root.has(IntentDConnectMessage.EXTRA_REQUEST_CODE)); Assert.assertEquals("http://localhost:8080", root.getString("uri")); Assert.assertEquals(0, root.getInt("byte")); Assert.assertEquals('0', root.getInt("char")); Assert.assertEquals(0, root.getInt("int")); Assert.assertEquals(0L, root.getLong("long")); Assert.assertEquals(0.0, root.getDouble("float"), TEST_FLOATING_VALUE); Assert.assertEquals(0.0, root.getDouble("double"), TEST_FLOATING_VALUE); Assert.assertEquals(false, root.getBoolean("boolean")); Assert.assertEquals(0, root.getInt(Byte.class.getName())); Assert.assertEquals('0', root.getInt(Character.class.getName())); Assert.assertEquals(0, root.getInt(Integer.class.getName())); Assert.assertEquals(0L, root.getLong(Long.class.getName())); Assert.assertEquals(0.0, root.getDouble(Float.class.getName()), TEST_FLOATING_VALUE); Assert.assertEquals(0.0, root.getDouble(Double.class.getName()), TEST_FLOATING_VALUE); Assert.assertEquals(false, root.getBoolean(Boolean.class.getName())); Assert.assertEquals(String.class.getName(), root.getString(String.class.getName())); Assert.assertEquals(1, root.getJSONArray(int[].class.getName()).length()); Assert.assertEquals(0, root.getJSONArray(int[].class.getName()).get(0)); Assert.assertEquals(1, root.getJSONArray(long[].class.getName()).length()); Assert.assertEquals(0L, root.getJSONArray(long[].class.getName()).getLong(0)); Assert.assertEquals(1, root.getJSONArray(float[].class.getName()).length()); Assert.assertEquals(0.0, root.getJSONArray(float[].class.getName()).getDouble(0), TEST_FLOATING_VALUE); Assert.assertEquals(1, root.getJSONArray(double[].class.getName()).length()); Assert.assertEquals(0.0, root.getJSONArray(double[].class.getName()).getDouble(0), TEST_FLOATING_VALUE); Assert.assertEquals(1, root.getJSONArray(boolean[].class.getName()).length()); Assert.assertEquals(false, root.getJSONArray(boolean[].class.getName()).get(0)); Assert.assertEquals(1, root.getJSONArray(Integer[].class.getName()).length()); Assert.assertEquals(0, root.getJSONArray(Integer[].class.getName()).get(0)); Assert.assertEquals(1, root.getJSONArray(Long[].class.getName()).length()); Assert.assertEquals(0L, root.getJSONArray(Long[].class.getName()).getLong(0)); Assert.assertEquals(1, root.getJSONArray(Float[].class.getName()).length()); Assert.assertEquals(0.0, root.getJSONArray(Float[].class.getName()).getDouble(0), TEST_FLOATING_VALUE); Assert.assertEquals(1, root.getJSONArray(Double[].class.getName()).length()); Assert.assertEquals(0.0, root.getJSONArray(Double[].class.getName()).getDouble(0), TEST_FLOATING_VALUE); Assert.assertEquals(1, root.getJSONArray(Boolean[].class.getName()).length()); Assert.assertEquals(false, root.getJSONArray(Boolean[].class.getName()).get(0)); Assert.assertEquals(1, root.getJSONArray(String[].class.getName()).length()); Assert.assertEquals("String", root.getJSONArray(String[].class.getName()).get(0)); Assert.assertNotNull(root.getJSONObject(Bundle.class.getName())); Assert.assertEquals(1, root.getJSONArray(Bundle[].class.getName()).length()); Assert.assertNotNull(root.getJSONArray(Bundle[].class.getName()).get(0)); Assert.assertEquals(1, root.getJSONArray("ArrayList<Integer>").length()); Assert.assertEquals(0, root.getJSONArray("ArrayList<Integer>").get(0)); }
From source file:org.paxml.selenium.rc.FileServerTest.java
@Test public void testClasspathResource2() throws Exception { InputStream inWeb = null;/* ww w . j a va 2 s . c o m*/ InputStream inClass = null; final String path = "/paxml/dynamic.xml"; try { URL url = new URL(server.hostIt(path, false)); inWeb = url.openStream(); inClass = new ClassPathResource(path).getInputStream(); Assert.assertEquals(IOUtils.readLines(inClass).toString(), IOUtils.readLines(inWeb).toString()); } finally { IOUtils.closeQuietly(inWeb); IOUtils.closeQuietly(inClass); } }