@Test public void testIterator2() throws IOException { // given dataStore.add(logDatas); // when ArrayList<LogData> acutal = new ArrayList<>(); for (LogData ld : dataStore) { acutal.add(ld); } // then assertArrayEquals(logDatas, acutal.toArray(new LogData[acutal.size()])); }
static public void assertAnyEquals(Object expected, Object actual) { if (expected instanceof byte[] && actual instanceof byte[]) AssertJUnit.assertArrayEquals((byte[]) expected, (byte[]) actual); else AssertJUnit.assertEquals(expected, actual); }
/** * @param templates to format * @param query to apply to the template * @param filters to compare */ @Test(groups = {"templatestest"}, dataProvider = "template-data") public void format(final SearchTemplates templates, final Query query, final SearchFilter[] filters) { AssertJUnit.assertArrayEquals(filters, templates.format(query)); } }
/** * @param query to get terms from * @param terms to compare */ @Test(groups = {"querytest"}, dataProvider = "query-data") public void format(final Query query, final String[] terms) { AssertJUnit.assertArrayEquals(terms, query.getTerms()); } }
@Test(invocationCount = 10) public void testAddLogDataArray() throws InterruptedException { LogData data1 = new LogData(); data1.setId(1); LogData data2 = new LogData(); data2.setId(2); LogData[] toAdd = { data1, data2 }; bufferingLogDataCollectorProxy.add(toAdd); AssertJUnit.assertArrayEquals(toAdd, bufferingLogDataCollectorProxy.getLogData()); Thread.sleep(3 * sleepTime); AssertJUnit.assertArrayEquals(toAdd, delegate.getLogData()); }
public void getAndAssert(byte[] key, byte[] expectedValue) { final String message = format("[XID=%s] Wrong value for key %s", xid, printArray(key, true)); if (expectedValue == null) { assertEquals(message, null, get(key)); } else { assertArrayEquals(message, expectedValue, get(key)); } }
public void testEmbeddedPutHotRodGet() throws Exception { final String key = "8"; final byte[] value = "v1".getBytes(); // 1. Put with Embedded assertNull(cacheFactory2.getEmbeddedCache().put(key, value)); // 2. Get with HotRod assertArrayEquals(value, (byte[]) cacheFactory1.getHotRodCache().get(key)); }
public void testHotRodPutEmbeddedGet() throws Exception { final String key = "4"; final byte[] value = "v1".getBytes(); // 1. Put with HotRod RemoteCache<Object, Object> remote = cacheFactory1.getHotRodCache(); assertNull(remote.withFlags(Flag.FORCE_RETURN_VALUE).put(key, value)); // 2. Get with Embedded assertArrayEquals(value, (byte[]) cacheFactory2.getEmbeddedCache().get(key)); }
public void testStoreByteArrays(final Method m) throws PersistenceException { ConfigurationBuilder base = new ConfigurationBuilder(); // we need to purge the container when loading, because we could try to compare // some old entry using ByteArrayEquivalence and this throws ClassCastException // for non-byte[] arguments cacheManager.defineConfiguration(m.getName(), configureCacheLoader(base, true).build()); Cache<byte[], byte[]> cache = cacheManager.getCache(m.getName()); byte[] key = {1, 2, 3}; byte[] value = {4, 5, 6}; cache.put(key, value); // Lookup in memory, sanity check byte[] lookupKey = {1, 2, 3}; byte[] found = cache.get(lookupKey); assertNotNull(found); assertArrayEquals(value, found); cache.evict(key); // Lookup in cache store found = cache.get(lookupKey); assertNotNull(found); assertArrayEquals(value, found); }
public void testByteArrayHotRodEmbeddedPutRestGet() throws Exception { final String key1 = "14"; final String key2 = "15"; // 1. Put with Hot Rod RemoteCache<String, Object> remote = cacheFactory.getHotRodCache(); assertEquals(null, remote.withFlags(Flag.FORCE_RETURN_VALUE).put(key1, "v1".getBytes())); // 2. Put with Embedded assertEquals(null, cacheFactory.getEmbeddedCache().put(key2, "v2".getBytes())); // 3. Get with REST key1 HttpMethod getHotRodValue = new GetMethod(cacheFactory.getRestUrl() + "/" + key1); getHotRodValue.setRequestHeader("Accept", "text/plain"); cacheFactory.getRestClient().executeMethod(getHotRodValue); assertEquals(getHotRodValue.getStatusText(), HttpStatus.SC_OK, getHotRodValue.getStatusCode()); assertEquals("text/plain", getHotRodValue.getResponseHeader("Content-Type").getValue()); assertArrayEquals("v1".getBytes(), getHotRodValue.getResponseBody()); // 4. Get with REST key2 HttpMethod getEmbeddedValue = new GetMethod(cacheFactory.getRestUrl() + "/" + key2); getEmbeddedValue.setRequestHeader("Accept", "text/plain"); cacheFactory.getRestClient().executeMethod(getEmbeddedValue); assertEquals(getEmbeddedValue.getStatusText(), HttpStatus.SC_OK, getEmbeddedValue.getStatusCode()); assertEquals("text/plain", getEmbeddedValue.getResponseHeader("Content-Type").getValue()); assertArrayEquals("v2".getBytes(), getEmbeddedValue.getResponseBody()); }
la.addBinaryValue(jpegPhotos.get(1)); AssertJUnit.assertEquals("aW1hZ2Ux", la.getStringValue()); AssertJUnit.assertArrayEquals(stringJpegPhotos.toArray(new String[2]), la.getStringValues().toArray(new String[2])); AssertJUnit.assertEquals(2, la.getStringValues().size()); AssertJUnit.assertEquals("image1".getBytes(), la.getBinaryValue()); AssertJUnit.assertArrayEquals(jpegPhotos.toArray(new byte[2][0]), la.getBinaryValues().toArray(new byte[2][0])); AssertJUnit.assertEquals(2, la.getBinaryValues().size()); la.clear(); la.addBinaryValue(jpegPhotos.get(1)); AssertJUnit.assertEquals("aW1hZ2Ux", la.getStringValue()); AssertJUnit.assertArrayEquals(stringJpegPhotos.toArray(new String[2]), la.getStringValues().toArray(new String[2])); AssertJUnit.assertEquals(2, la.getStringValues().size()); AssertJUnit.assertEquals("image1".getBytes(), la.getBinaryValue()); AssertJUnit.assertArrayEquals(jpegPhotos.toArray(new byte[2][0]), la.getBinaryValues().toArray(new byte[2][0])); AssertJUnit.assertEquals(2, la.getBinaryValues().size()); la.clear();
la.addStringValue(commonNames.get(1)); AssertJUnit.assertEquals("Bill Wallace", la.getStringValue()); AssertJUnit.assertArrayEquals(commonNames.toArray(new String[2]), la.getStringValues().toArray(new String[2])); AssertJUnit.assertEquals(2, la.getStringValues().size()); AssertJUnit.assertEquals("Bill Wallace".getBytes(StandardCharsets.UTF_8), la.getBinaryValue()); AssertJUnit.assertArrayEquals( binaryCommonNames.toArray(new byte[2][0]), la.getBinaryValues().toArray(new byte[2][0])); la.addStringValue(commonNames.get(1)); AssertJUnit.assertEquals("Bill Wallace", la.getStringValue()); AssertJUnit.assertArrayEquals(commonNames.toArray(new String[2]), la.getStringValues().toArray(new String[2])); AssertJUnit.assertEquals(2, la.getStringValues().size()); AssertJUnit.assertEquals("Bill Wallace".getBytes(StandardCharsets.UTF_8), la.getBinaryValue()); AssertJUnit.assertArrayEquals( binaryCommonNames.toArray(new byte[2][0]), la.getBinaryValues().toArray(new byte[2][0]));
AssertJUnit.assertArrayEquals(xmlShorts.toArray(), dbShorts.toArray()); } finally { close(session);
@Test public void testGetLogData() { LogData data1 = new LogData(); data1.setId(1); LogData data2 = new LogData(); data2.setId(2); AssertJUnit.assertEquals(0, delegate.getLogData().length); bufferingLogDataCollectorProxy.add(data1); bufferingLogDataCollectorProxy.add(data2); LogData[] logData = bufferingLogDataCollectorProxy.getLogData(); AssertJUnit.assertEquals(2, logData.length); AssertJUnit.assertArrayEquals(new LogData[] { data1, data2 }, logData); }