@Test @Transactional(propagation = Propagation.NOT_SUPPORTED) void verifyAnnotationAutowiredFields() { assertInTransaction(false); assertNull(nonrequiredLong, "The nonrequiredLong field should NOT have been autowired."); assertNotNull(pet, "The pet field should have been autowired."); assertEquals(pet.getName(), "Fido", "pet's name."); }
private static void assertColumnList(List<com.amazonaws.services.glue.model.Column> actual, List<Column> expected) { if (expected == null) { assertNull(actual); } assertEquals(actual.size(), expected.size()); for (int i = 0; i < expected.size(); i++) { assertColumn(actual.get(i), expected.get(i)); } }
@Test public void testBuildExpressionNullOrEmptyValues() { assertNull(buildGlueExpression(PARTITION_KEYS, ImmutableList.of())); assertNull(buildGlueExpression(PARTITION_KEYS, null)); }
@Test public void testExecuteUpdateWithInsert() throws Exception { try (Connection connection = createConnection("blackhole", "blackhole")) { try (Statement statement = connection.createStatement()) { assertEquals(statement.executeUpdate("INSERT INTO test_table VALUES (1), (2)"), 2); assertNull(statement.getResultSet()); assertEquals(statement.getUpdateCount(), 2); assertEquals(statement.getLargeUpdateCount(), 2); } } }
@Test public void testCreateGroupedStateEmpty() { GeometryState state = factory.createGroupedState(); assertNull(state.getGeometry()); assertTrue(state.getEstimatedSize() > 0, String.format("Estimated memory size was %d", state.getEstimatedSize())); }
@Test(description = "it should override the property name") public void overridePropertyName() { final Map<String, Schema> schemas = readAll(ModelWithAltPropertyName.class); final Map<String, Schema> properties = schemas.get("sample_model").getProperties(); assertNull(properties.get("id")); assertNotNull(properties.get("the_id")); }
private void checkType(Schema property, Class<?> cls, String type, String format) { assertTrue(cls.isInstance(property)); assertEquals(property.getType(), type); if (format == null) { assertNull(property.getFormat()); } else { assertEquals(property.getFormat(), format); } }
@Test public void testAddColumn() MaterializedResult materializedRows = computeActual("SELECT x, a FROM test_add_column ORDER BY x"); assertEquals(materializedRows.getMaterializedRows().get(0).getField(0), 123); assertNull(materializedRows.getMaterializedRows().get(0).getField(1)); assertEquals(materializedRows.getMaterializedRows().get(1).getField(0), 234); assertEquals(materializedRows.getMaterializedRows().get(1).getField(1), 111L); materializedRows = computeActual("SELECT x, a, b FROM test_add_column ORDER BY x"); assertEquals(materializedRows.getMaterializedRows().get(0).getField(0), 123); assertNull(materializedRows.getMaterializedRows().get(0).getField(1)); assertNull(materializedRows.getMaterializedRows().get(0).getField(2)); assertEquals(materializedRows.getMaterializedRows().get(1).getField(0), 234); assertEquals(materializedRows.getMaterializedRows().get(1).getField(1), 111L); assertNull(materializedRows.getMaterializedRows().get(1).getField(2)); assertEquals(materializedRows.getMaterializedRows().get(2).getField(0), 345); assertEquals(materializedRows.getMaterializedRows().get(2).getField(1), 222L); assertUpdate("DROP TABLE test_add_column_a"); assertUpdate("DROP TABLE test_add_column_ab"); assertFalse(getQueryRunner().tableExists(getSession(), "test_add_column")); assertFalse(getQueryRunner().tableExists(getSession(), "test_add_column_a")); assertFalse(getQueryRunner().tableExists(getSession(), "test_add_column_ab"));
private static void assertMinMax(StringStatistics actualStringStatistics, Slice expectedMin, Slice expectedMax) { if (expectedMax == null && expectedMin == null) { assertNull(actualStringStatistics); return; } assertNotNull(actualStringStatistics); assertEquals(actualStringStatistics.getMin(), expectedMin); assertEquals(actualStringStatistics.getMax(), expectedMax); }
private void assertSetNull(int sqlType, int expectedSqlType) throws SQLException { try (Connection connection = createConnection(); PreparedStatement statement = connection.prepareStatement("SELECT ?")) { statement.setNull(1, sqlType); try (ResultSet rs = statement.executeQuery()) { assertTrue(rs.next()); assertNull(rs.getObject(1)); assertTrue(rs.wasNull()); assertFalse(rs.next()); assertEquals(rs.getMetaData().getColumnType(1), expectedSqlType); } } }
@Test public void testExecuteUpdateWithCreateTable() throws Exception { try (Connection connection = createConnection("blackhole", "blackhole")) { try (Statement statement = connection.createStatement()) { assertEquals(statement.executeUpdate("CREATE TABLE test_execute_create (x bigint)"), 0); assertNull(statement.getResultSet()); assertEquals(statement.getUpdateCount(), 0); assertEquals(statement.getLargeUpdateCount(), 0); } } }
@Test(description = "it should generate a JSON with read-only from pojo, #1161") public void readOnlyJsonGeneration() throws IOException { Map<String, Schema> models = ModelConverters.getInstance().read(ReadOnlyModel.class); Schema model = models.get("ReadOnlyModel"); Schema id = (Schema) model.getProperties().get("id"); assertTrue(id.getReadOnly()); Schema readWriteId = (Schema) model.getProperties().get("readWriteId"); assertNull(readWriteId.getReadOnly()); }
@Test public void getAnnotationTest() throws NoSuchMethodException { final Method method = Child.class.getMethod("annotationHolder"); Assert.assertNotNull(ReflectionUtils.getAnnotation(method, Schema.class)); Assert.assertNull(ReflectionUtils.getAnnotation(method, ApiResponse.class)); }
private static void assertSourceFinished(LocalExchangeSource source) { assertTrue(source.isFinished()); LocalExchangeBufferInfo bufferInfo = source.getBufferInfo(); assertEquals(bufferInfo.getBufferedPages(), 0); assertEquals(bufferInfo.getBufferedBytes(), 0); assertTrue(source.waitForReading().isDone()); assertNull(source.removePage()); assertTrue(source.waitForReading().isDone()); assertTrue(source.isFinished()); }
private static void assertColumnList(List<Column> actual, List<com.amazonaws.services.glue.model.Column> expected) { if (expected == null) { assertNull(actual); } assertEquals(actual.size(), expected.size()); for (int i = 0; i < expected.size(); i++) { assertColumn(actual.get(i), expected.get(i)); } }
@Test public void testUriWithSslEnabled() throws SQLException { PrestoDriverUri parameters = createDriverUri("presto://localhost:8080/blackhole?SSL=true"); assertUriPortScheme(parameters, 8080, "https"); Properties properties = parameters.getProperties(); assertNull(properties.getProperty(SSL_TRUST_STORE_PATH.getKey())); assertNull(properties.getProperty(SSL_TRUST_STORE_PASSWORD.getKey())); }
@Test public void testTaskCancellationAfterCompleted() throws InterruptedException { final AtomicReference<Throwable> cancelActionValue = new AtomicReference<>(); Task<?> completed = Task.value(10); completed.addListener(p -> { if (p.isFailed() && Exceptions.isCancellation(p.getError())) { cancelActionValue.set(p.getError().getCause()); } } ); runAndWait("TestTaskCancellation.testTaskCancellationAfterCompleted", completed); Exception cancelReason = new Exception(); assertFalse(completed.cancel(cancelReason)); assertNull(cancelActionValue.get()); }
@Test public void findMethodTest() throws NoSuchMethodException { final Method methodToFind1 = Child.class.getMethod("parametrizedMethod1", Integer.class); final Method method1 = ReflectionUtils.findMethod(methodToFind1, Parent.class); Assert.assertNotNull(method1); Assert.assertEquals(method1.getParameterTypes()[0], Number.class); final Method methodToFind2 = Child.class.getMethod("parametrizedMethod4", Long.class); final Method method2 = ReflectionUtils.findMethod(methodToFind2, Parent.class); Assert.assertNull(method2); }
@Test(description = "it should deserialize a BooleanSchema") public void deserializeBooleanSchema() throws IOException { final String json = "{\"type\":\"boolean\",\"default\":false}"; final Schema p = m.readValue(json, Schema.class); assertEquals(p.getType(), "boolean"); assertNull(p.getFormat()); assertEquals(p.getClass(), BooleanSchema.class); assertEquals(((BooleanSchema) p).getDefault(), Boolean.FALSE); assertEquals(m.writeValueAsString(p), json); }
@Test public void testRequestTimeout() throws IOException { try (AsyncHttpClient client = asyncHttpClient()) { Future<Response> responseFuture = client.prepareGet(getTargetUrl()).setRequestTimeout(100).execute(); Response response = responseFuture.get(2000, TimeUnit.MILLISECONDS); assertNull(response); } catch (InterruptedException e) { fail("Interrupted.", e); } catch (ExecutionException e) { assertTrue(e.getCause() instanceof TimeoutException); checkTimeoutMessage(e.getCause().getMessage(), true); } catch (TimeoutException e) { fail("Timeout.", e); } }