/** * Checks correctness of the state after unmarshalling. */ void checkAfterUnmarshalled() { assertEquals(shortVal.shortValue(), 0x1122); assertEquals(longVal, 0x8877665544332211L); assertNull(aArr); assertNull(strVal); assertEquals(doubleVal, 123.456); } }
void put(FileLruCache cache, String key, byte[] data) { try { OutputStream stream = cache.openPutStream(key); assertNotNull(stream); stream.write(data); stream.close(); } catch (IOException e) { // Fail test and print Exception assertNull(e); } }
@Test public void testLoadInvalidAssetName() { LottieResult<LottieComposition> result = LottieCompositionFactory.fromAssetSync(RuntimeEnvironment.application, "square2.json"); assertEquals(FileNotFoundException.class, result.getException().getClass()); assertNull(result.getValue()); }
@Test public void testX() throws Exception { JSONObject serverResponse = new JSONObject(errorClassificationJSON); JSONArray jsonArray = serverResponse.getJSONArray("android_sdk_error_categories"); FacebookRequestErrorClassification errorClassification = FacebookRequestErrorClassification.createFromJSON(jsonArray); assertNotNull(errorClassification); assertNull(errorClassification.getRecoveryMessage(FacebookRequestError.Category.OTHER)); assertNull(errorClassification.getRecoveryMessage(FacebookRequestError.Category.TRANSIENT)); assertNotNull(errorClassification.getRecoveryMessage( FacebookRequestError.Category.LOGIN_RECOVERABLE)); assertEquals(2, errorClassification.getOtherErrors().size()); assertEquals(2, errorClassification.getLoginRecoverableErrors().size()); assertEquals(6, errorClassification.getTransientErrors().size()); // test subcodes assertEquals(2, errorClassification.getOtherErrors().get(102).size()); assertNull(errorClassification.getLoginRecoverableErrors().get(102)); } }
@Test public void testLoadInvalidJsonString() { LottieResult<LottieComposition> result = LottieCompositionFactory.fromJsonStringSync(NOT_JSON, "not_json"); assertNotNull(result.getException()); assertNull(result.getValue()); }
public void deleteCounter() { EntityManager em = emf.createEntityManager(); Counters counters = new Counters(); counters = em.find(Counters.class, id3); Assert.assertNotNull(counters); Assert.assertNotNull(counters.getCounter()); em.remove(counters); EntityManager em1 = emf.createEntityManager(); counters = em1.find(Counters.class, id3); Assert.assertNull(counters); em.close(); }
@Override public void serverReceiveRequest(RPCContext context) { Map<String,ByteBuffer> meta = context.requestCallMeta(); Assert.assertNotNull(meta); Assert.assertNotNull(context.getMessage()); Assert.assertNull(context.getResponsePayload()); if (!meta.containsKey(key)) return; ByteBuffer buf = meta.get(key); Assert.assertNotNull(buf); Assert.assertNotNull(buf.array()); String partialstr = new String(buf.array()); Assert.assertNotNull(partialstr); Assert.assertEquals("partial string mismatch", "ap", partialstr); buf = ByteBuffer.wrap((partialstr + "a").getBytes()); Assert.assertTrue(buf.remaining() > 0); meta.put(key, buf); }
/** * Test delete. */ private void testDelete() { PersonMTM p1 = em.find(PersonMTM.class, "p1"); Assert.assertNotNull(p1); em.remove(p1); PersonMTM p = em.find(PersonMTM.class, "p1"); Assert.assertNull(p); }
/** * Test delete. */ private void testDelete() { Metrics m = em.find(Metrics.class, getMetricsId()); em.remove(m); em.clear(); Metrics m1 = em.find(Metrics.class, getMetricsId()); Assert.assertNull(m1); }
/** * PDI-6960 - Group by and Memory group by ignores NULL values ("sum" aggregation) * * We do not assign 0 instead of null. */ @Test public void newAggregateInitializationTest() { Object[] r = new Object[18]; Arrays.fill( r, null ); step.newAggregate( r ); Object[] agg = data.agg; Assert.assertEquals( "All possible aggregation cases considered", 18, agg.length ); // all aggregations types is int values, filled in ascending order in perconditions for ( int i = 0; i < agg.length; i++ ) { int type = i + 1; if ( strings.contains( type ) ) { Assert.assertTrue( "This is appendable type, type=" + type, agg[i] instanceof Appendable ); } else if ( statistics.contains( type ) ) { Assert.assertTrue( "This is collection, type=" + type, agg[i] instanceof Collection ); } else { Assert.assertNull( "Aggregation initialized with null, type=" + type, agg[i] ); } } } }
@Test public void testMarkCleaned() throws Exception { CompactionRequest rqst = new CompactionRequest("foo", "bar", CompactionType.MINOR); rqst.setPartitionname("ds=today"); txnHandler.compact(rqst); assertEquals(0, txnHandler.findReadyToClean().size()); CompactionInfo ci = txnHandler.findNextToCompact("fred"); assertNotNull(ci); assertEquals(0, txnHandler.findReadyToClean().size()); txnHandler.markCompacted(ci); assertNull(txnHandler.findNextToCompact("fred")); List<CompactionInfo> toClean = txnHandler.findReadyToClean(); assertEquals(1, toClean.size()); assertNull(txnHandler.findNextToCompact("fred")); txnHandler.markCleaned(ci); assertNull(txnHandler.findNextToCompact("fred")); assertEquals(0, txnHandler.findReadyToClean().size()); ShowCompactResponse rsp = txnHandler.showCompact(new ShowCompactRequest()); assertEquals(1, rsp.getCompactsSize()); assertTrue(TxnHandler.SUCCEEDED_RESPONSE.equals(rsp.getCompacts().get(0).getState())); }
@Test public void testLoadJsonString() { LottieResult<LottieComposition> result = LottieCompositionFactory.fromJsonStringSync(JSON, "json"); assertNull(result.getException()); assertNotNull(result.getValue()); }
public void testDelete(boolean useSameEm) { EntityManager em = emf.createEntityManager(); StudentDoublePrimitive studentMax = em.find(StudentDoublePrimitive.class, maxValue); Assert.assertNotNull(studentMax); Assert.assertEquals(getMaxValue(short.class), studentMax.getAge()); Assert.assertEquals("Kuldeep", studentMax.getName()); em.remove(studentMax); if (!useSameEm) { em.close(); em = emf.createEntityManager(); } studentMax = em.find(StudentDoublePrimitive.class, maxValue); Assert.assertNull(studentMax); em.close(); }
@Override public void clientFinishConnect(RPCContext context) { Map<String,ByteBuffer> handshakeMeta = context.responseHandshakeMeta(); Assert.assertNull(context.getRequestPayload()); Assert.assertNull(context.getResponsePayload()); Assert.assertNotNull(handshakeMeta); if (!handshakeMeta.containsKey(key)) return; ByteBuffer buf = handshakeMeta.get(key); Assert.assertNotNull(buf); Assert.assertNotNull(buf.array()); String partialstr = new String(buf.array()); Assert.assertNotNull(partialstr); Assert.assertEquals("partial string mismatch", "apac", partialstr); buf = ByteBuffer.wrap((partialstr + "he").getBytes()); Assert.assertTrue(buf.remaining() > 0); handshakeMeta.put(key, buf); checkRPCMetaMap(handshakeMeta); }
void checkInputStream(byte[] expected, InputStream actual) { try { for (int i = 0; i < expected.length; i++) { int b = actual.read(); assertEquals(((int)expected[i]) & 0xff, b); } int eof = actual.read(); assertEquals(-1, eof); } catch (IOException e) { // Fail test and print Exception assertNull(e); } }
/** * Test delete. */ private void testDelete() { Person p = em.find(Person.class, "101"); Assert.assertNotNull(p); em.remove(p); em.clear(); Person p1 = em.find(Person.class, "101"); Assert.assertNull(p1); }
/** {@inheritDoc} */ @SuppressWarnings("unchecked") @Nullable @Override public Object onGet(Object key, Object val) { if (disabled) return val; assertNotNull(retInterceptor); Object ret = retInterceptor.onGet(key, val); System.out.println("Get [key=" + key + ", val=" + val + ", ret=" + ret + ']'); if (val != null) { Object old = getMap.put(key, val); assertNull(old); // Fot get interceptor is called on near node only. } invokeCnt.incrementAndGet(); return ret; }
@Test public void testNewAggregate() throws KettleException { Object[] r = new Object[16]; Arrays.fill( r, null ); Aggregate agg = new Aggregate(); step.newAggregate( r, agg ); Assert.assertEquals( "All possible aggregation cases considered", 16, agg.agg.length ); // all aggregations types is int values, filled in ascending order in perconditions for ( int i = 0; i < agg.agg.length; i++ ) { int type = i + 1; if ( strings.contains( type ) ) { Assert.assertTrue( "This is appendable type, type=" + type, agg.agg[i] instanceof Appendable ); } else if ( statistics.contains( type ) ) { Assert.assertTrue( "This is collection, type=" + type, agg.agg[i] instanceof Collection ); } else { Assert.assertNull( "Aggregation initialized with null, type=" + type, agg.agg[i] ); } } } }
@Test public void testFindNextToClean() throws Exception { CompactionRequest rqst = new CompactionRequest("foo", "bar", CompactionType.MINOR); rqst.setPartitionname("ds=today"); txnHandler.compact(rqst); assertEquals(0, txnHandler.findReadyToClean().size()); CompactionInfo ci = txnHandler.findNextToCompact("fred"); assertNotNull(ci); assertEquals(0, txnHandler.findReadyToClean().size()); txnHandler.markCompacted(ci); assertNull(txnHandler.findNextToCompact("fred")); List<CompactionInfo> toClean = txnHandler.findReadyToClean(); assertEquals(1, toClean.size()); assertNull(txnHandler.findNextToCompact("fred")); ShowCompactResponse rsp = txnHandler.showCompact(new ShowCompactRequest()); List<ShowCompactResponseElement> compacts = rsp.getCompacts(); assertEquals(1, compacts.size()); ShowCompactResponseElement c = compacts.get(0); assertEquals("foo", c.getDbname()); assertEquals("bar", c.getTablename()); assertEquals("ds=today", c.getPartitionname()); assertEquals(CompactionType.MINOR, c.getType()); assertEquals("ready for cleaning", c.getState()); assertNull(c.getWorkerid()); }
@Test public void testLoadInvalidJsonReader() { JsonReader reader = new JsonReader(new StringReader(NOT_JSON)); LottieResult<LottieComposition> result = LottieCompositionFactory.fromJsonReaderSync(reader, "json"); assertNotNull(result.getException()); assertNull(result.getValue()); }