src_fm_fc_ms_ff
stringlengths
43
86.8k
target
stringlengths
20
276k
FailedMessageStatusHistoryResource implements FailedMessageStatusHistoryClient { @Override public List<StatusHistoryResponse> getStatusHistory(FailedMessageId failedMessageId) { final List<StatusHistoryResponse> statusHistoryResponses = new ArrayList<>(); final List<StatusHistoryEvent> statusHistory = failedMessageDao....
@Test public void failedMessageWithStatusHistoryEntries() { when(failedMessageDao.getStatusHistory(FAILED_MESSAGE_ID)).thenReturn(Arrays.asList( new StatusHistoryEvent(StatusHistoryEvent.Status.FAILED, NOW), new StatusHistoryEvent(StatusHistoryEvent.Status.SENT, NOW.plusSeconds(1)) )); assertThat(underTest.getStatusHis...
CreateFailedMessageResource implements CreateFailedMessageClient { public void create(CreateFailedMessageRequest failedMessageRequest) { failedMessageDao.insert(failedMessageFactory.create(failedMessageRequest)); } CreateFailedMessageResource(FailedMessageFactory failedMessageFactory, FailedMessageDao failedMessageDao)...
@Test public void createFailedMessage() throws Exception { when(failedMessageFactory.create(request)).thenReturn(failedMessage); underTest.create(request); verify(failedMessageDao).insert(failedMessage); }
FailedMessageFactory { public FailedMessage create(CreateFailedMessageRequest request) { return FailedMessageBuilder.newFailedMessage() .withFailedMessageId(request.getFailedMessageId()) .withContent(request.getContent()) .withDestination(new Destination(request.getBrokerName(), ofNullable(request.getDestinationName())...
@Test public void createFailedMessageFromRequest() throws Exception { FailedMessage failedMessage = underTest.create(newCreateFailedMessageRequest() .withContent("Hello World") .withBrokerName("broker") .withDestinationName("queue") .withFailedDateTime(NOW) .withFailedMessageId(FAILED_MESSAGE_ID) .withProperties(Collec...
FailedMessageSearchResource implements SearchFailedMessageClient { @Override public FailedMessageResponse getFailedMessage(FailedMessageId failedMessageId) { return failedMessageDao.findById(failedMessageId) .filter(failedMessage -> !DELETED.equals(failedMessage.getStatus())) .map(failedMessageResponseFactory::create) ...
@Test public void findMessageById() { when(failedMessageDao.findById(FAILED_MESSAGE_ID)).thenReturn(Optional.of(failedMessage)); when(failedMessage.getStatus()).thenReturn(FAILED); when(failedMessageResponseFactory.create(failedMessage)).thenReturn(failedMessageResponse); assertThat(underTest.getFailedMessage(FAILED_ME...
RemoveRecordsQueryFactory { public Document create() { return new Document() .append(STATUS_HISTORY + ".0." + STATUS, DELETED.name()) .append(STATUS_HISTORY + ".0." + EFFECTIVE_DATE_TIME, new Document(QueryOperators.LT, now().minus(7, DAYS))); } Document create(); }
@Test public void removeRecordsQueryCreatedSuccessfully() { assertThat(underTest.create(), allOf( hasField(STATUS_HISTORY + ".0." + STATUS, equalTo(StatusHistoryEvent.Status.DELETED.name())), hasField(STATUS_HISTORY + ".0." + EFFECTIVE_DATE_TIME, hasField(QueryOperators.LT, notNullValue(Instant.class))) )); }
FailedMessageSearchResource implements SearchFailedMessageClient { @Override public Collection<SearchFailedMessageResponse> search(SearchFailedMessageRequest request) { return failedMessageSearchService.search(request) .stream() .map(searchFailedMessageResponseAdapter::toResponse) .collect(Collectors.toList()); } Faile...
@Test public void validSearch() { FailedMessage failedMessage = mock(FailedMessage.class); SearchFailedMessageResponse searchFailedMessageResponse = mock(SearchFailedMessageResponse.class); SearchFailedMessageRequest searchFailedMessageRequest = mock(SearchFailedMessageRequest.class); when(searchFailedMessageRequest.ge...
UpdateFailedMessageResource implements UpdateFailedMessageClient { @Override public void update(FailedMessageId failedMessageId, FailedMessageUpdateRequest failedMessageUpdateRequest) { failedMessageService.update(failedMessageId, failedMessageUpdateRequest.getUpdateRequests()); } UpdateFailedMessageResource(FailedMess...
@Test public void resourceDelegatesToTheFailedMessageService() { underTest.update(FAILED_MESSAGE_ID, FailedMessageUpdateRequest.aNewFailedMessageUpdateRequest().withUpdateRequest(updateRequest).build()); verify(failedMessageService).update(FAILED_MESSAGE_ID, Collections.singletonList(updateRequest)); }
MessageTextExtractor { public String extractText(Message message) { if (message instanceof TextMessage) { TextMessage textMessage = (TextMessage) message; try { return textMessage.getText(); } catch (JMSException e) { String errorMsg = String.format("Failed to extract the text from TextMessage: %s", textMessage.toStrin...
@Test public void extractTextFromMessage() throws Exception { TextMessage textMessage = mock(TextMessage.class); when(textMessage.getText()).thenReturn("Text"); assertThat(underTest.extractText(textMessage), is("Text")); } @Test public void throwsExceptionIfNotTextMessage() throws Exception { expectedException.expect(R...
FailedMessageTransformer implements JmsMessageTransformer<TextMessage, FailedMessage> { @Override public void transform(TextMessage textMessage, FailedMessage data) throws JMSException { textMessage.setText(data.getContent()); Map<String, Object> properties = data.getProperties(); properties.keySet().forEach(key -> { t...
@Test public void processingContinuesObjectPropertyCannotBeWritten() throws JMSException { when(failedMessage.getContent()).thenReturn("content"); when(failedMessage.getProperties()).thenReturn(ImmutableMap.of("foo", "bar", "ham", "eggs")); when(failedMessage.getFailedMessageId()).thenReturn(FAILED_MESSAGE_ID); doThrow...
FailedMessageListener implements MessageListener { @Override public void onMessage(Message message) { try { LOGGER.debug("Received message: {} with CorrelationId: {}", message.getJMSMessageID(), message.getJMSCorrelationID()); failedMessageProcessor.process(failedMessageFactory.createFailedMessage(message)); } catch (J...
@Test public void processMessageSuccessfully() throws Exception { when(failedMessageFactory.createFailedMessage(message)).thenReturn(failedMessage); underTest.onMessage(message); verify(failedMessageProcessor).process(failedMessage); } @Test public void exceptionIsThrownRetrievingTheJMSMessageId() throws JMSException {...
FailedMessageConverter implements DocumentWithIdConverter<FailedMessage, FailedMessageId> { @Override public Document createId(FailedMessageId failedMessageId) { return new Document("_id", failedMessageId.getId().toString()); } FailedMessageConverter(DocumentConverter<Destination> destinationDocumentConverter, ...
@Test public void createId() { assertThat(underTest.createId(FAILED_MESSAGE_ID), equalTo(new Document("_id", FAILED_MESSAGE_ID_AS_STRING))); }
CircularBuffer { public int size() { return currentSize; } CircularBuffer(int size); void enqueue(T item); int size(); @SuppressWarnings("unchecked") T getItem(int index); }
@Test public void size() { CircularBuffer<Integer> queue = new CircularBuffer<>(2); assertEquals(0, queue.size()); queue.enqueue(0); queue.enqueue(1); assertEquals(2, queue.size()); queue.enqueue(3); assertEquals(2, queue.size()); }
CircularBuffer { @SuppressWarnings("unchecked") public T getItem(int index) { int target = head - index; if (target < 0) target = queue.length + target; return (T) queue[target]; } CircularBuffer(int size); void enqueue(T item); int size(); @SuppressWarnings("unchecked") T getItem(int index); }
@Test public void getItem() { CircularBuffer<Integer> queue = new CircularBuffer<>(3); queue.enqueue(0); assertEquals((Integer) 0, queue.getItem(0)); queue.enqueue(1); assertEquals((Integer) 1, queue.getItem(0)); assertEquals((Integer) 0, queue.getItem(1)); queue.enqueue(2); assertEquals((Integer) 2, queue.getItem(0));...
KubeCloudInstanceImpl implements KubeCloudInstance { @NotNull @Override public Date getStartedTime() { final PodStatus podStatus = myPod.getStatus(); if(podStatus == null) return myCreationTime; try { final List<PodCondition> podConditions = podStatus.getConditions(); if (podConditions != null && !podConditions.isEmpty...
@Test public void testGetStartedTime() throws Exception { KubeCloudImage image = m.mock(KubeCloudImage.class); ObjectMeta metadata = new ObjectMeta(); metadata.setName("foo"); Pod pod = new Pod("1.0", "kind", metadata, new PodSpec(), new PodStatusBuilder().withStartTime("2017-06-12T22:59Z").build()); m.checking(new Exp...
KubeCloudClient implements CloudClientEx { @Override public boolean isInitialized() { return true; } KubeCloudClient(@NotNull KubeApiConnector apiConnector, @Nullable String serverUuid, @NotNull String cloudProfileId, @NotNull List<KubeClo...
@Test public void testIsInitialized() throws Exception { assertTrue(createClient(Collections.emptyList()).isInitialized()); }
KubeCloudClient implements CloudClientEx { @Override public boolean canStartNewInstance(@NotNull CloudImage cloudImage) { KubeCloudImage kubeCloudImage = (KubeCloudImage) cloudImage; String kubeCloudImageId = kubeCloudImage.getId(); if(!myImageIdToImageMap.containsKey(kubeCloudImageId)){ LOG.debug("Can't start instance...
@Test public void testCanStartNewInstance_UnknownImage() throws Exception { KubeCloudClient cloudClient = createClient(Collections.emptyList()); CloudImage image = m.mock(KubeCloudImage.class); m.checking(new Expectations(){{ allowing(image).getId(); will(returnValue("image-1-id")); }}); assertFalse(cloudClient.canStar...
BoltOptions implements AutoCloseable { @Override public void close() { BoltNative.BoltDBOptions_Free(objectId); } BoltOptions(); BoltOptions(long timeout); BoltOptions(long timeout, boolean noGrowSync, boolean readOnly, int mmapFlags, int initialMmapSize); @Override void close(); }
@Test public void create_and_free() { BoltOptions boltOptions = new BoltOptions(); boltOptions.close(); }
BoltBucket implements AutoCloseable { public void delete(byte[] key) { Error.ByValue error = BoltNative.BoltDBBucket_Delete(objectId, key, key.length); error.checkError(); } BoltBucket(long objectId); @Override void close(); byte[] get(byte[] key); void put(byte[] key, byte[] value); void delete(byte[] key); BoltBucket...
@Test public void delete() throws IOException { try(Bolt bolt = new Bolt(testFolder.newFile().getAbsolutePath())) { bolt.update(boltTransaction -> { try(BoltBucket bucket = boltTransaction.createBucket("test".getBytes())) { byte[] key = "foo".getBytes(); byte[] value = "bar".getBytes(); bucket.put(key, value); bucket.d...
BoltBucket implements AutoCloseable { public BoltBucket createBucket(byte[] name) { Result.ByValue result = BoltNative.BoltDBBucket_CreateBucket(objectId, name, name.length); result.checkError(); return new BoltBucket(result.objectId); } BoltBucket(long objectId); @Override void close(); byte[] get(byte[] key); void pu...
@Test @SuppressWarnings("EmptyTryBlock") public void create_bucket() throws IOException { try(Bolt bolt = new Bolt(testFolder.newFile().getAbsolutePath())) { bolt.update(boltTransaction -> { try(BoltBucket parentBucket = boltTransaction.createBucket("parent".getBytes())) { try(BoltBucket ignored = parentBucket.createBu...
BoltTransaction { public void commit() { Error.ByValue error = BoltNative.BoltDBTransaction_Commit(objectId); error.checkError(); } BoltTransaction(long objectId); void commit(); void rollback(); int getId(); long getDatabaseSize(); BoltBucket createBucket(byte[] name); BoltBucket createBucketIfNotExists(byte[] name); ...
@Test public void commit_transaction() throws IOException { try(Bolt bolt = new Bolt(testFolder.newFile().getAbsolutePath())) { BoltTransaction boltTransaction = bolt.begin(true); boltTransaction.commit(); } }
BoltTransaction { public void rollback() { Error.ByValue error = BoltNative.BoltDBTransaction_Rollback(objectId); error.checkError(); } BoltTransaction(long objectId); void commit(); void rollback(); int getId(); long getDatabaseSize(); BoltBucket createBucket(byte[] name); BoltBucket createBucketIfNotExists(byte[] nam...
@Test public void rollback_transaction() throws IOException { try(Bolt bolt = new Bolt(testFolder.newFile().getAbsolutePath())) { BoltTransaction boltTransaction = bolt.begin(true); boltTransaction.rollback(); } }
BoltTransaction { public int getId() { return BoltNative.BoltDBTransaction_GetId(objectId); } BoltTransaction(long objectId); void commit(); void rollback(); int getId(); long getDatabaseSize(); BoltBucket createBucket(byte[] name); BoltBucket createBucketIfNotExists(byte[] name); void deleteBucket(byte[] name); BoltBu...
@Test public void get_transaction_id() throws IOException { try(Bolt bolt = new Bolt(testFolder.newFile().getAbsolutePath())) { bolt.update(boltTransaction -> Assert.assertTrue(boltTransaction.getId() > 0)); } }
BoltTransaction { public long getDatabaseSize() { return BoltNative.BoltDBTransaction_Size(objectId); } BoltTransaction(long objectId); void commit(); void rollback(); int getId(); long getDatabaseSize(); BoltBucket createBucket(byte[] name); BoltBucket createBucketIfNotExists(byte[] name); void deleteBucket(byte[] nam...
@Test public void get_database_size() throws IOException { try(Bolt bolt = new Bolt(testFolder.newFile().getAbsolutePath())) { bolt.update(boltTransaction -> Assert.assertTrue(boltTransaction.getDatabaseSize() > 0)); } }
BoltTransaction { public BoltBucket createBucket(byte[] name) { Result.ByValue result = BoltNative.BoltDBTransaction_CreateBucket(objectId, name, name.length); result.checkError(); return new BoltBucket(result.objectId); } BoltTransaction(long objectId); void commit(); void rollback(); int getId(); long getDatabaseSize...
@Test @SuppressWarnings("EmptyTryBlock") public void create_bucket() throws IOException { try(Bolt bolt = new Bolt(testFolder.newFile().getAbsolutePath())) { bolt.update(boltTransaction -> { try (BoltBucket ignored = boltTransaction.createBucket("test".getBytes())) {} }); } } @Test(expected = BoltException.class) publi...
BoltCursor implements AutoCloseable { public BoltKeyValue first() { try(KeyValue.ByValue keyValue = BoltNative.BoltDBCursor_First(objectId)) { return keyValue.hasKeyValue() ? new BoltKeyValue(keyValue.getKey(), keyValue.getValue()) : null; } } BoltCursor(long objectId); @Override void close(); BoltKeyValue first(); Bol...
@Test public void move_first() throws IOException { byte[] bucketName = "test".getBytes(); try(Bolt bolt = new Bolt(testFolder.newFile().getAbsolutePath())) { bolt.update(boltTransaction -> { try (BoltBucket ignored = boltTransaction.createBucket(bucketName)) { try (BoltCursor cursor = boltTransaction.createCursor()) {...
BoltTransaction { public BoltBucket createBucketIfNotExists(byte[] name) { Result.ByValue result = BoltNative.BoltDBTransaction_CreateBucketIfNotExists(objectId, name, name.length); result.checkError(); return new BoltBucket(result.objectId); } BoltTransaction(long objectId); void commit(); void rollback(); int getId()...
@Test @SuppressWarnings("EmptyTryBlock") public void create_bucket_if_not_exists() throws IOException { byte[] bucketName = "test".getBytes(); try(Bolt bolt = new Bolt(testFolder.newFile().getAbsolutePath())) { bolt.update(boltTransaction -> { try (BoltBucket ignored = boltTransaction.createBucketIfNotExists(bucketName...
BoltTransaction { public void deleteBucket(byte[] name) { Error.ByValue error = BoltNative.BoltDBTransaction_DeleteBucket(objectId, name, name.length); error.checkError(); } BoltTransaction(long objectId); void commit(); void rollback(); int getId(); long getDatabaseSize(); BoltBucket createBucket(byte[] name); BoltBuc...
@Test(expected = BoltException.class) public void delete_bucket_with_empty_name() throws IOException { try(Bolt bolt = new Bolt(testFolder.newFile().getAbsolutePath())) { bolt.update(boltTransaction -> boltTransaction.deleteBucket("".getBytes())); } }
BoltTransaction { public BoltBucket getBucket(byte[] name) { Result.ByValue result = BoltNative.BoltDBTransaction_Bucket(objectId, name, name.length); result.checkError(); return new BoltBucket(result.objectId); } BoltTransaction(long objectId); void commit(); void rollback(); int getId(); long getDatabaseSize(); BoltB...
@Test(expected = BoltException.class) public void get_bucket_with_empty_name() throws IOException { try(Bolt bolt = new Bolt(testFolder.newFile().getAbsolutePath())) { bolt.update(boltTransaction -> boltTransaction.getBucket("".getBytes())); } }
BoltTransaction { public BoltCursor createCursor() { long cursorObjectId = BoltNative.BoltDBTransaction_Cursor(objectId); return new BoltCursor(cursorObjectId); } BoltTransaction(long objectId); void commit(); void rollback(); int getId(); long getDatabaseSize(); BoltBucket createBucket(byte[] name); BoltBucket createB...
@Test @SuppressWarnings("EmptyTryBlock") public void create_cursor() throws IOException { try(Bolt bolt = new Bolt(testFolder.newFile().getAbsolutePath())) { bolt.update(boltTransaction -> { try (BoltCursor ignored = boltTransaction.createCursor()) {} }); } }
Bolt implements AutoCloseable { public void close() { BoltNative.BoltDB_Close(objectId); } Bolt(String databaseFileName); Bolt(String databaseFileName, EnumSet<BoltFileMode> fileMode); Bolt(String databaseFileName, EnumSet<BoltFileMode> fileMode, BoltOptions options); void close(); BoltTransaction begin(boolean write...
@Test public void open_and_close() throws IOException { Bolt bolt = new Bolt(testFolder.newFile().getAbsolutePath()); bolt.close(); } @Test public void open_from_other_thread() { Thread thread = new Thread(() -> { try { Bolt bolt = new Bolt(testFolder.newFile().getAbsolutePath()); bolt.close(); } catch (Throwable e) { ...
Bolt implements AutoCloseable { public void update(Consumer<BoltTransaction> callback) { BoltTransaction transaction = begin(true); try { callback.accept(transaction); transaction.commit(); } catch (Throwable ex) { transaction.rollback(); throw ex; } } Bolt(String databaseFileName); Bolt(String databaseFileName, EnumS...
@Test public void open_update_transaction() throws IOException { String databaseFileName = testFolder.newFile().getAbsolutePath(); try(Bolt bolt = new Bolt(databaseFileName)) { final boolean[] wasInTransaction = {false}; bolt.update(boltTransaction -> { Assert.assertNotNull(boltTransaction); wasInTransaction[0] = true;...
Bolt implements AutoCloseable { public void view(Consumer<BoltTransaction> callback) { BoltTransaction transaction = begin(false); try { callback.accept(transaction); } finally { transaction.rollback(); } } Bolt(String databaseFileName); Bolt(String databaseFileName, EnumSet<BoltFileMode> fileMode); Bolt(String datab...
@Test public void open_view_transaction() throws IOException { String databaseFileName = testFolder.newFile().getAbsolutePath(); try(Bolt bolt = new Bolt(databaseFileName)) { final boolean[] wasInTransaction = {false}; bolt.view(boltTransaction -> { Assert.assertNotNull(boltTransaction); wasInTransaction[0] = true; });...
BoltCursor implements AutoCloseable { public BoltKeyValue last() { try(KeyValue.ByValue keyValue = BoltNative.BoltDBCursor_Last(objectId)) { return keyValue.hasKeyValue() ? new BoltKeyValue(keyValue.getKey(), keyValue.getValue()) : null; } } BoltCursor(long objectId); @Override void close(); BoltKeyValue first(); BoltK...
@Test public void move_last() throws IOException { byte[] bucketName = "test".getBytes(); try(Bolt bolt = new Bolt(testFolder.newFile().getAbsolutePath())) { bolt.update(boltTransaction -> { try (BoltBucket ignored = boltTransaction.createBucket(bucketName)) { try (BoltCursor cursor = boltTransaction.createCursor()) { ...
BoltCursor implements AutoCloseable { public BoltKeyValue next() { try(KeyValue.ByValue keyValue = BoltNative.BoltDBCursor_Next(objectId)) { return keyValue.hasKeyValue() ? new BoltKeyValue(keyValue.getKey(), keyValue.getValue()) : null; } } BoltCursor(long objectId); @Override void close(); BoltKeyValue first(); BoltK...
@Test public void move_next() throws IOException { try(Bolt bolt = new Bolt(testFolder.newFile().getAbsolutePath())) { bolt.update(boltTransaction -> { try (BoltBucket ignored1 = boltTransaction.createBucket("test1".getBytes())) { try (BoltBucket ignored2 = boltTransaction.createBucket("test2".getBytes())) { try (BoltC...
BoltCursor implements AutoCloseable { public BoltKeyValue prev() { try(KeyValue.ByValue keyValue = BoltNative.BoltDBCursor_Prev(objectId)) { return keyValue.hasKeyValue() ? new BoltKeyValue(keyValue.getKey(), keyValue.getValue()) : null; } } BoltCursor(long objectId); @Override void close(); BoltKeyValue first(); BoltK...
@Test public void move_prev() throws IOException { try(Bolt bolt = new Bolt(testFolder.newFile().getAbsolutePath())) { bolt.update(boltTransaction -> { try (BoltBucket ignored1 = boltTransaction.createBucket("test1".getBytes())) { try (BoltBucket ignored2 = boltTransaction.createBucket("test2".getBytes())) { try (BoltC...
BoltCursor implements AutoCloseable { public BoltKeyValue seek(byte[] seek) { try(KeyValue.ByValue keyValue = BoltNative.BoltDBCursor_Seek(objectId, seek, seek.length)) { return keyValue.hasKeyValue() ? new BoltKeyValue(keyValue.getKey(), keyValue.getValue()) : null; } } BoltCursor(long objectId); @Override void close(...
@Test public void seek() throws IOException { byte[] bucketName1 = "test1".getBytes(); byte[] bucketName2 = "test2".getBytes(); byte[] bucketName3 = "test3".getBytes(); try(Bolt bolt = new Bolt(testFolder.newFile().getAbsolutePath())) { bolt.update(boltTransaction -> { try(BoltBucket ignored1 = boltTransaction.createBu...
BoltCursor implements AutoCloseable { public void delete() { Error.ByValue error = BoltNative.BoltDBCursor_Delete(objectId); error.checkError(); } BoltCursor(long objectId); @Override void close(); BoltKeyValue first(); BoltKeyValue last(); BoltKeyValue next(); BoltKeyValue prev(); BoltKeyValue seek(byte[] seek); void ...
@Test public void delete() throws IOException { byte[] bucketName = "test".getBytes(); try(Bolt bolt = new Bolt(testFolder.newFile().getAbsolutePath())) { bolt.update(boltTransaction -> { try(BoltBucket bucket = boltTransaction.createBucket(bucketName)) { byte[] key = "key".getBytes(); byte[] value = "value".getBytes()...
FlowsApi { public Flow create(CreateFlowRequest body) throws ApiException { ApiResponse<Flow> resp = createWithHttpInfo(body); return resp.getData(); } FlowsApi(); FlowsApi(ApiClient apiClient); ApiClient getApiClient(); void setApiClient(ApiClient apiClient); Flow create(CreateFlowRequest body); ApiResponse<Flow> cre...
@Test public void createTest() throws ApiException { CreateFlowRequest body = null; Flow response = api.create(body); }
FunctionsApi { public KFFunction create(CreateFunctionRequest body) throws ApiException { ApiResponse<KFFunction> resp = createWithHttpInfo(body); return resp.getData(); } FunctionsApi(); FunctionsApi(ApiClient apiClient); ApiClient getApiClient(); void setApiClient(ApiClient apiClient); KFFunction create(CreateFuncti...
@Test public void createTest() throws ApiException { CreateFunctionRequest body = null; KFFunction response = api.create(body); }
FunctionsApi { public void delete(String id) throws ApiException { deleteWithHttpInfo(id); } FunctionsApi(); FunctionsApi(ApiClient apiClient); ApiClient getApiClient(); void setApiClient(ApiClient apiClient); KFFunction create(CreateFunctionRequest body); ApiResponse<KFFunction> createWithHttpInfo(CreateFunctionReque...
@Test public void deleteTest() throws ApiException { String id = null; api.delete(id); }
FunctionsApi { public KFFunction get(String id) throws ApiException { ApiResponse<KFFunction> resp = getWithHttpInfo(id); return resp.getData(); } FunctionsApi(); FunctionsApi(ApiClient apiClient); ApiClient getApiClient(); void setApiClient(ApiClient apiClient); KFFunction create(CreateFunctionRequest body); ApiRespo...
@Test public void getTest() throws ApiException { String id = null; KFFunction response = api.get(id); }
FunctionsApi { public Service getService(String id) throws ApiException { ApiResponse<Service> resp = getServiceWithHttpInfo(id); return resp.getData(); } FunctionsApi(); FunctionsApi(ApiClient apiClient); ApiClient getApiClient(); void setApiClient(ApiClient apiClient); KFFunction create(CreateFunctionRequest body); ...
@Test public void getServiceTest() throws ApiException { String id = null; Service response = api.getService(id); }
FunctionsApi { public Version getVersion(String id, String versionId) throws ApiException { ApiResponse<Version> resp = getVersionWithHttpInfo(id, versionId); return resp.getData(); } FunctionsApi(); FunctionsApi(ApiClient apiClient); ApiClient getApiClient(); void setApiClient(ApiClient apiClient); KFFunction create(...
@Test public void getVersionTest() throws ApiException { String id = null; String versionId = null; Version response = api.getVersion(id, versionId); }
FunctionsApi { public List<Version> getVersions(String id) throws ApiException { ApiResponse<List<Version>> resp = getVersionsWithHttpInfo(id); return resp.getData(); } FunctionsApi(); FunctionsApi(ApiClient apiClient); ApiClient getApiClient(); void setApiClient(ApiClient apiClient); KFFunction create(CreateFunctionR...
@Test public void getVersionsTest() throws ApiException { String id = null; List<Version> response = api.getVersions(id); }
FunctionsApi { public List<KFFunction> list() throws ApiException { ApiResponse<List<KFFunction>> resp = listWithHttpInfo(); return resp.getData(); } FunctionsApi(); FunctionsApi(ApiClient apiClient); ApiClient getApiClient(); void setApiClient(ApiClient apiClient); KFFunction create(CreateFunctionRequest body); ApiRe...
@Test public void listTest() throws ApiException { List<KFFunction> response = api.list(); }
FunctionsApi { public ProxyResponse proxy(String id, String body) throws ApiException { ApiResponse<ProxyResponse> resp = proxyWithHttpInfo(id, body); return resp.getData(); } FunctionsApi(); FunctionsApi(ApiClient apiClient); ApiClient getApiClient(); void setApiClient(ApiClient apiClient); KFFunction create(CreateFu...
@Test public void proxyTest() throws ApiException { String id = null; String body = null; ProxyResponse response = api.proxy(id, body); }
FunctionsApi { public Map<String, String> setVersion(String id, String versionId) throws ApiException { ApiResponse<Map<String, String>> resp = setVersionWithHttpInfo(id, versionId); return resp.getData(); } FunctionsApi(); FunctionsApi(ApiClient apiClient); ApiClient getApiClient(); void setApiClient(ApiClient apiCli...
@Test public void setVersionTest() throws ApiException { String id = null; String versionId = null; Map<String, String> response = api.setVersion(id, versionId); }
FlowsApi { public String delete(String id) throws ApiException { ApiResponse<String> resp = deleteWithHttpInfo(id); return resp.getData(); } FlowsApi(); FlowsApi(ApiClient apiClient); ApiClient getApiClient(); void setApiClient(ApiClient apiClient); Flow create(CreateFlowRequest body); ApiResponse<Flow> createWithHttp...
@Test public void deleteTest() throws ApiException { String id = null; String response = api.delete(id); }
FlowsApi { public Flow deploy(String id) throws ApiException { ApiResponse<Flow> resp = deployWithHttpInfo(id); return resp.getData(); } FlowsApi(); FlowsApi(ApiClient apiClient); ApiClient getApiClient(); void setApiClient(ApiClient apiClient); Flow create(CreateFlowRequest body); ApiResponse<Flow> createWithHttpInfo...
@Test public void deployTest() throws ApiException { String id = null; Flow response = api.deploy(id); }
FlowsApi { public Flow get(String id) throws ApiException { ApiResponse<Flow> resp = getWithHttpInfo(id); return resp.getData(); } FlowsApi(); FlowsApi(ApiClient apiClient); ApiClient getApiClient(); void setApiClient(ApiClient apiClient); Flow create(CreateFlowRequest body); ApiResponse<Flow> createWithHttpInfo(Creat...
@Test public void getTest() throws ApiException { String id = null; Flow response = api.get(id); }
FlowsApi { public DAGStepRef getModel(String id) throws ApiException { ApiResponse<DAGStepRef> resp = getModelWithHttpInfo(id); return resp.getData(); } FlowsApi(); FlowsApi(ApiClient apiClient); ApiClient getApiClient(); void setApiClient(ApiClient apiClient); Flow create(CreateFlowRequest body); ApiResponse<Flow> cr...
@Test public void getModelTest() throws ApiException { String id = null; DAGStepRef response = api.getModel(id); }
FlowsApi { public List<Flow> list() throws ApiException { ApiResponse<List<Flow>> resp = listWithHttpInfo(); return resp.getData(); } FlowsApi(); FlowsApi(ApiClient apiClient); ApiClient getApiClient(); void setApiClient(ApiClient apiClient); Flow create(CreateFlowRequest body); ApiResponse<Flow> createWithHttpInfo(Cr...
@Test public void listTest() throws ApiException { List<Flow> response = api.list(); }
FlowsApi { public String saveModel(String id, Object body) throws ApiException { ApiResponse<String> resp = saveModelWithHttpInfo(id, body); return resp.getData(); } FlowsApi(); FlowsApi(ApiClient apiClient); ApiClient getApiClient(); void setApiClient(ApiClient apiClient); Flow create(CreateFlowRequest body); ApiResp...
@Test public void saveModelTest() throws ApiException { String id = null; Object body = null; String response = api.saveModel(id, body); }
FlowsApi { public String validate(Object body) throws ApiException { ApiResponse<String> resp = validateWithHttpInfo(body); return resp.getData(); } FlowsApi(); FlowsApi(ApiClient apiClient); ApiClient getApiClient(); void setApiClient(ApiClient apiClient); Flow create(CreateFlowRequest body); ApiResponse<Flow> create...
@Test public void validateTest() throws ApiException { Object body = null; String response = api.validate(body); }
ConnectorsApi { public Connector get(String id) throws ApiException { ApiResponse<Connector> resp = getWithHttpInfo(id); return resp.getData(); } ConnectorsApi(); ConnectorsApi(ApiClient apiClient); ApiClient getApiClient(); void setApiClient(ApiClient apiClient); Connector get(String id); ApiResponse<Connector> getWi...
@Test public void getTest() throws ApiException { String id = null; Connector response = api.get(id); }
ConnectorsApi { public List<Connector> list() throws ApiException { ApiResponse<List<Connector>> resp = listWithHttpInfo(); return resp.getData(); } ConnectorsApi(); ConnectorsApi(ApiClient apiClient); ApiClient getApiClient(); void setApiClient(ApiClient apiClient); Connector get(String id); ApiResponse<Connector> ge...
@Test public void listTest() throws ApiException { List<Connector> response = api.list(); }
TableStats { public double estimateScanCost() { return table.numPages() * ioCostPerPage; } TableStats(int tableid, int ioCostPerPage); static TableStats getTableStats(String tablename); static void setTableStats(String tablename, TableStats stats); static void setStatsMap(HashMap<String, TableStats> s); static Map<Stri...
@Test public void estimateScanCostTest() throws IOException, DbException, TransactionAbortedException { Object[] ret; int[] ioCosts = new int[20]; int[] pageNums = new int[ioCosts.length]; for(int i = 0; i < ioCosts.length; ++i) { ioCosts[i] = 1; pageNums[i] = 3*(i+1); } double stats[] = getRandomTableScanCosts(pageNum...
Join extends Operator { public void rewind() throws DbException, TransactionAbortedException { child1.rewind(); child2.rewind(); joinResults.rewind(); } Join(JoinPredicate p, DbIterator child1, DbIterator child2); @Override String getName(); JoinPredicate getJoinPredicate(); String getJoinField1Name(); String getJoinFi...
@Test public void rewind() throws Exception { JoinPredicate pred = new JoinPredicate(0, Predicate.Op.EQUALS, 0); Join op = new Join(pred, scan1, scan2); op.open(); while (op.hasNext()) { assertNotNull(op.next()); } assertTrue(TestUtil.checkExhausted(op)); op.rewind(); eqJoin.open(); Tuple expected = eqJoin.next(); Tupl...
Join extends Operator { public void open() throws DbException, NoSuchElementException, TransactionAbortedException { child1.open(); child2.open(); super.open(); joinResults = blockNestedLoopJoin(); joinResults.open(); } Join(JoinPredicate p, DbIterator child1, DbIterator child2); @Override String getName(); JoinPredica...
@Test public void gtJoin() throws Exception { JoinPredicate pred = new JoinPredicate(0, Predicate.Op.GREATER_THAN, 0); Join op = new Join(pred, scan1, scan2); op.open(); gtJoin.open(); TestUtil.matchAllTuples(gtJoin, op); } @Test public void eqJoin() throws Exception { JoinPredicate pred = new JoinPredicate(0, Predicat...
TableStats { public int estimateTableCardinality(double selectivityFactor) { return (int) Math.ceil(totalTuples() * selectivityFactor); } TableStats(int tableid, int ioCostPerPage); static TableStats getTableStats(String tablename); static void setTableStats(String tablename, TableStats stats); static void setStatsMap(...
@Test public void estimateTableCardinalityTest() { TableStats s = new TableStats(this.tableId, IO_COST); Assert.assertEquals(306, s.estimateTableCardinality(0.3)); Assert.assertEquals(1020, s.estimateTableCardinality(1.0)); Assert.assertEquals(0, s.estimateTableCardinality(0.0)); }
TableStats { public double estimateSelectivity(int field, Predicate.Op op, Field constant) { String fieldName = td.getFieldName(field); if (constant.getType() == Type.INT_TYPE) { int value = ((IntField)constant).getValue(); IntHistogram histogram = (IntHistogram) name2hist.get(fieldName); return histogram.estimateSelec...
@Test public void estimateSelectivityTest() { final int maxCellVal = 32; final Field aboveMax = new IntField(maxCellVal + 10); final Field atMax = new IntField(maxCellVal); final Field halfMaxMin = new IntField(maxCellVal/2); final Field atMin = new IntField(0); final Field belowMin = new IntField(-10); TableStats s = ...
JoinOptimizer { public double estimateJoinCost(LogicalJoinNode j, int card1, int card2, double cost1, double cost2) { if (j instanceof LogicalSubplanJoinNode) { return card1 + cost1 + cost2; } else { TupleDesc desc = p.getTupleDesc(j.t1Alias); int blockSize = Join.blockMemory / desc.getSize(); int fullNum = card1 / blo...
@Test public void estimateJoinCostTest() throws ParsingException { TransactionId tid = new TransactionId(); JoinOptimizer jo; Parser p = new Parser(); String t1Alia = "t1"; String t2Alia = "t2"; jo = new JoinOptimizer(p.generateLogicalPlan(tid, "SELECT * FROM " + tableName1 + " t1, " + tableName2 + " t2 WHERE t1.c1 = t...
JoinOptimizer { public int estimateJoinCardinality(LogicalJoinNode j, int card1, int card2, boolean t1pkey, boolean t2pkey, Map<String, TableStats> stats) { if (j instanceof LogicalSubplanJoinNode) { return card1; } else { return estimateTableJoinCardinality(j.p, j.t1Alias, j.t2Alias, j.f1PureName, j.f2PureName, card1,...
@Test public void estimateJoinCardinality() throws ParsingException { TransactionId tid = new TransactionId(); Parser p = new Parser(); JoinOptimizer j = new JoinOptimizer(p.generateLogicalPlan(tid, "SELECT * FROM " + tableName2 + " t1, " + tableName2 + " t2 WHERE t1.c8 = t2.c7;"), new Vector<LogicalJoinNode>()); doubl...
JoinOptimizer { public Vector<LogicalJoinNode> orderJoins( HashMap<String, TableStats> stats, HashMap<String, Double> filterSelectivities, boolean explain) throws ParsingException { int numJoinNodes = joins.size(); PlanCache pc = new PlanCache(); Set<LogicalJoinNode> wholeSet = null; for (int i = 1; i <= numJoinNodes; ...
@Test public void orderJoinsTest() throws ParsingException, IOException, DbException, TransactionAbortedException { final int IO_COST = 101; TransactionId tid = new TransactionId(); JoinOptimizer j; Vector<LogicalJoinNode> result; Vector<LogicalJoinNode> nodes = new Vector<LogicalJoinNode>(); HashMap<String, TableStats...
Transaction { public void transactionComplete(boolean abort) throws IOException { if (started) { if (abort) { Database.getLogFile().logAbort(tid); } else { Database.getBufferPool().flushPages(tid); Database.getLogFile().logCommit(tid); } try { Database.getBufferPool().transactionComplete(tid, !abort); } catch (IOExcept...
@Test public void attemptTransactionTwice() throws Exception { bp.getPage(tid1, p0, Permissions.READ_ONLY); bp.getPage(tid1, p1, Permissions.READ_WRITE); bp.transactionComplete(tid1, true); bp.getPage(tid2, p0, Permissions.READ_WRITE); bp.getPage(tid2, p0, Permissions.READ_WRITE); }
Join extends Operator { public TupleDesc getTupleDesc() { return td; } Join(JoinPredicate p, DbIterator child1, DbIterator child2); @Override String getName(); JoinPredicate getJoinPredicate(); String getJoinField1Name(); String getJoinField2Name(); TupleDesc getTupleDesc(); void open(); void close(); void rewind(); @O...
@Test public void getTupleDesc() { JoinPredicate pred = new JoinPredicate(0, Predicate.Op.EQUALS, 0); Join op = new Join(pred, scan1, scan2); TupleDesc expected = Utility.getTupleDesc(width1 + width2); TupleDesc actual = op.getTupleDesc(); assertEquals(expected, actual); }
WebsiteRestController { @RequestMapping(method = RequestMethod.GET, value = ApiUrls.URL_SITE_PROFILES_USER_COMMENTS) public HttpEntity<PagedResources<PublicCommentResource>> getUserApprovedCommentPosts( @PathVariable("userId") String userId, @PageableDefault(size = UtilConstants.DEFAULT_RETURN_RECORD_COUNT, page = 0) P...
@Test public void getUserApprovedCommentPosts() throws Exception { Page<CommentPost> page = new PageImpl<CommentPost>(getTestApprovedCommentPostList(), new PageRequest(0, 10), 2); when(commentPostRepositoryMock.findByAuthorIdAndStatusOrderByCreatedTimeDesc( eq(USER_ID), eq(CommentStatusType.APPROVED), any(Pageable.clas...
UserAccount extends BaseAuditableEntity implements SocialUserDetails { public boolean isAuthor(){ for (UserRoleType role : getRoles()) { if (role == UserRoleType.ROLE_AUTHOR){ return true; } } return false; } UserAccount(); UserAccount(String userId, UserRoleType[] roles); String getUserId(); void setUserId(String use...
@Test public void testIsAuthor() { UserAccount normalUser = new UserAccount(); assertFalse(normalUser.isAuthor()); UserRoleType[] roles = new UserRoleType[]{UserRoleType.ROLE_USER, UserRoleType.ROLE_AUTHOR}; UserAccount author = new UserAccount("1234", roles); assertTrue(author.isAuthor()); }
UserAccount extends BaseAuditableEntity implements SocialUserDetails { public boolean isAdmin(){ for (UserRoleType role : getRoles()) { if (role == UserRoleType.ROLE_ADMIN){ return true; } } return false; } UserAccount(); UserAccount(String userId, UserRoleType[] roles); String getUserId(); void setUserId(String userI...
@Test public void testIsAdmin() { UserAccount normalUser = new UserAccount(); assertFalse(normalUser.isAdmin()); UserRoleType[] roles = new UserRoleType[]{UserRoleType.ROLE_USER, UserRoleType.ROLE_ADMIN}; UserAccount author = new UserAccount("1234", roles); assertTrue(author.isAdmin()); }
SingleEntryScope extends AbstractScope implements Scope { public <T> T call(Callable<T> toCall, Object... scopeContents) throws Exception { enter(scopeContents); try { return toCall.call(); } finally { exit(); } } void run(Runnable toRun, Object... scopeContents); T call(Callable<T> toCall, Object... scopeContents); @...
@Test public void testCall() throws Exception { class I implements ThrowingFunction<String, String> { @Override public String apply(String argument) throws Exception { X x = deps.getInstance(X.class); assertNotNull(x); assertEquals("test", x.toString()); return argument + "." + x.toString(); } } String s = SCOPE.run(ne...
ReentrantScope extends AbstractScope { public boolean inScope() { List<?> l = this.lists.get(); return l != null && !l.isEmpty(); } ReentrantScope(); ReentrantScope(Provider<String> injectionInfoProvider); QuietAutoCloseable enter(Object... o); @Override void exit(); boolean inScope(); }
@Test public void testInScope() throws Exception { final int limit = 10; StringBuilder constant = new StringBuilder("hello"); final boolean[] ran = new boolean[1]; class One implements ThrowingFunction<Integer, Void> { @Override public Void apply(Integer argument) throws Exception { ran[0] = true; assertNotNull(depende...
ExecutorServiceProvider implements Provider<ExecutorService> { @Override public ExecutorService get() { ExecutorService result = null; if (registered.compareAndSet(false, true)) { synchronized (this) { if (exe == null) { result = exe = svc.get(); reg.get().add(exe); } else { result = exe; } } } if (result == null) { sy...
@Test public void testSomeMethod() throws IOException, InterruptedException, ExecutionException { Dependencies deps = new Dependencies(new M()); Thing thing = deps.getInstance(Thing.class); ExecutorService exe = deps.getInstance(ExecutorService.class); assertNotNull(exe); assertSame(thing.p.get(), exe); exe.submit(() -...
Dependencies { public <T> T getInstance(Class<T> type) { return getInjector().getInstance(type); } Dependencies(Module... modules); Dependencies(Settings configuration, Module... modules); Dependencies(boolean mergeNamespaces, Map<String, Settings> settings, Set<SettingsBindings> settingsBindings, Module... modules)...
@Test public void testNamedSettings() throws Throwable { MutableSettings settings = SettingsBuilder.createDefault().buildMutableSettings(); settings.setString("stuff", "This is stuff"); assertEquals("This is stuff", settings.getString("stuff")); assertTrue(settings.allKeys().contains("stuff")); assertTrue(settings.toPr...
Reschedulables { public Reschedulable withSimpleDelay(Duration delay, Runnable runnable) { return withSimpleDelay(delay, new CallableForRunnable(runnable)); } @Inject Reschedulables(Settings settings, ShutdownHookRegistry reg, UncaughtExceptionHandler onError); private Reschedulables(int count, ShutdownHookRegistry r...
@Test public void testSimpleDelay() throws Throwable { Runner run = new Runner(); Reschedulable r = rs.withSimpleDelay(Duration.ofMillis(100), run); run.assertWasNotRun(); Thread.sleep(150); run.assertWasNotRun(); long now = System.currentTimeMillis(); r.touch(); Thread.sleep(150); run.assertWasRun(); run.assertRunCoun...
Reschedulables { public Reschedulable withResettingDelay(Duration delay, Runnable runnable) { return withResettingDelay(delay, new CallableForRunnable(runnable)); } @Inject Reschedulables(Settings settings, ShutdownHookRegistry reg, UncaughtExceptionHandler onError); private Reschedulables(int count, ShutdownHookRegi...
@Test public void testResettingDelay() throws Throwable { Runner run = new Runner(); Reschedulable r = rs.withResettingDelay(Duration.ofMillis(100), run); run.assertWasNotRun(); r.touch(); Thread.sleep(40); long now = System.currentTimeMillis(); r.touch(); Thread.sleep(150); run.assertWasRun(); run.assertRunCount(1); u...
Migration { private void rollback(MongoDatabase db, Document agg) { CountDownLatch latch = new CountDownLatch(backupQueryForCollection.size() - 1); Document rollbacks = new Document(); agg.append("rollback", rollbacks); for (String s : backupQueryForCollection.keySet()) { MongoCollection<Document> from = db.getCollecti...
@Test public void testRollback(@Named("stuff") Provider<MongoCollection<Document>> stuff, @Named("migrations") Provider<MongoCollection<Document>> migrations, Provider<MongoDatabase> db, Provider<MongoClient> client, Provider<Dependencies> deps) throws InterruptedException, Throwable { Function<Class<? extends Migratio...
PublisherConfirms { static void publishMessagesIndividually() throws Exception { try (Connection connection = createConnection()) { Channel ch = connection.createChannel(); String queue = UUID.randomUUID().toString(); ch.queueDeclare(queue, false, false, true, null); ch.confirmSelect(); long start = System.nanoTime(); ...
@Test @DisplayName("publish messages individually") void publishMessagesIndividually() throws Exception { Channel ch = connection.createChannel(); ch.confirmSelect(); for (int i = 0; i < messageCount; i++) { String body = String.valueOf(i); ch.basicPublish("", queue, null, body.getBytes()); ch.waitForConfirmsOrDie(5_00...
PublisherConfirms { static void publishMessagesInBatch() throws Exception { try (Connection connection = createConnection()) { Channel ch = connection.createChannel(); String queue = UUID.randomUUID().toString(); ch.queueDeclare(queue, false, false, true, null); ch.confirmSelect(); int batchSize = 100; int outstandingM...
@Test @DisplayName("publish messages in batch") void publishMessagesInBatch() throws Exception { Channel ch = connection.createChannel(); ch.confirmSelect(); int batchSize = 100; int outstandingMessageCount = 0; for (int i = 0; i < messageCount; i++) { String body = String.valueOf(i); ch.basicPublish("", queue, null, b...
PublisherConfirms { static boolean waitUntil(Duration timeout, BooleanSupplier condition) throws InterruptedException { int waited = 0; while (!condition.getAsBoolean() && waited < timeout.toMillis()) { Thread.sleep(100L); waited = +100; } return condition.getAsBoolean(); } static void main(String[] args); }
@Test @DisplayName("allow max of outstanding confirms") void allowMaxOfOutstandingConfirms() throws Exception { int maxOutstandingConfirms = 100; Semaphore semaphore = new Semaphore(maxOutstandingConfirms); Channel ch = connection.createChannel(); ch.confirmSelect(); ConcurrentSkipListSet<Long> outstandingConfirms = ne...
HessianProtocol extends AbstractProxyProtocol { public HessianProtocol() { super(HessianException.class); } HessianProtocol(); void setHttpBinder(HttpBinder httpBinder); @Override int getDefaultPort(); @Override void destroy(); }
@Test public void testHessianProtocol() { HessianServiceImpl server = new HessianServiceImpl(); Assertions.assertFalse(server.isCalled()); ProxyFactory proxyFactory = ExtensionLoader.getExtensionLoader(ProxyFactory.class).getAdaptiveExtension(); Protocol protocol = ExtensionLoader.getExtensionLoader(Protocol.class).get...
EagerThreadPoolExecutor extends ThreadPoolExecutor { @Override public void execute(Runnable command) { if (command == null) { throw new NullPointerException(); } submittedTaskCount.incrementAndGet(); try { super.execute(command); } catch (RejectedExecutionException rx) { final TaskQueue queue = (TaskQueue) super.getQue...
@Test public void testEagerThreadPool() throws Exception { String name = "eager-tf"; int queues = 5; int cores = 5; int threads = 10; long alive = 1000; TaskQueue<Runnable> taskQueue = new TaskQueue<Runnable>(queues); final EagerThreadPoolExecutor executor = new EagerThreadPoolExecutor(cores, threads, alive, TimeUnit.M...
EagerThreadPool implements ThreadPool { @Override public Executor getExecutor(URL url) { String name = url.getParameter(Constants.THREAD_NAME_KEY, Constants.DEFAULT_THREAD_NAME); int cores = url.getParameter(Constants.CORE_THREADS_KEY, Constants.DEFAULT_CORE_THREADS); int threads = url.getParameter(Constants.THREADS_KE...
@Test public void getExecutor1() throws Exception { URL url = URL.valueOf("dubbo: Constants.THREAD_NAME_KEY + "=demo&" + Constants.CORE_THREADS_KEY + "=1&" + Constants.THREADS_KEY + "=2&" + Constants.ALIVE_KEY + "=1000&" + Constants.QUEUES_KEY + "=0"); ThreadPool threadPool = new EagerThreadPool(); ThreadPoolExecutor e...
FixedThreadPool implements ThreadPool { @Override public Executor getExecutor(URL url) { String name = url.getParameter(Constants.THREAD_NAME_KEY, Constants.DEFAULT_THREAD_NAME); int threads = url.getParameter(Constants.THREADS_KEY, Constants.DEFAULT_THREADS); int queues = url.getParameter(Constants.QUEUES_KEY, Constan...
@Test public void getExecutor1() throws Exception { URL url = URL.valueOf("dubbo: Constants.THREAD_NAME_KEY + "=demo&" + Constants.CORE_THREADS_KEY + "=1&" + Constants.THREADS_KEY + "=2&" + Constants.QUEUES_KEY + "=0"); ThreadPool threadPool = new FixedThreadPool(); ThreadPoolExecutor executor = (ThreadPoolExecutor) th...
CachedThreadPool implements ThreadPool { @Override public Executor getExecutor(URL url) { String name = url.getParameter(Constants.THREAD_NAME_KEY, Constants.DEFAULT_THREAD_NAME); int cores = url.getParameter(Constants.CORE_THREADS_KEY, Constants.DEFAULT_CORE_THREADS); int threads = url.getParameter(Constants.THREADS_K...
@Test public void getExecutor1() throws Exception { URL url = URL.valueOf("dubbo: Constants.THREAD_NAME_KEY + "=demo&" + Constants.CORE_THREADS_KEY + "=1&" + Constants.THREADS_KEY + "=2&" + Constants.ALIVE_KEY + "=1000&" + Constants.QUEUES_KEY + "=0"); ThreadPool threadPool = new CachedThreadPool(); ThreadPoolExecutor ...
JEtcdClient extends AbstractEtcdClient<JEtcdClient.EtcdWatcher> { @Override public void delete(String path) { clientWrapper.delete(path); } JEtcdClient(URL url); @Override void doCreatePersistent(String path); @Override long doCreateEphemeral(String path); @Override boolean checkExists(String path); @Override EtcdWatch...
@Test public void test_watch_when_create_path() throws InterruptedException { String path = "/dubbo/com.alibaba.dubbo.demo.DemoService/providers"; String child = "/dubbo/com.alibaba.dubbo.demo.DemoService/providers/demoService1"; final CountDownLatch notNotified = new CountDownLatch(1); ChildListener childListener = (p...
JsonRpcProtocol extends AbstractProxyProtocol { public JsonRpcProtocol() { super(HttpException.class, JsonRpcClientException.class); } JsonRpcProtocol(); void setHttpBinder(HttpBinder httpBinder); @Override int getDefaultPort(); @Override void destroy(); static final String ACCESS_CONTROL_ALLOW_ORIGIN_HEADER; static fi...
@Test public void testJsonrpcProtocol() { JsonRpcServiceImpl server = new JsonRpcServiceImpl(); assertFalse(server.isCalled()); ProxyFactory proxyFactory = ExtensionLoader.getExtensionLoader(ProxyFactory.class).getAdaptiveExtension(); Protocol protocol = ExtensionLoader.getExtensionLoader(Protocol.class).getAdaptiveExt...
JEtcdClient extends AbstractEtcdClient<JEtcdClient.EtcdWatcher> { @Override public boolean put(String key, String value) { return clientWrapper.put(key, value); } JEtcdClient(URL url); @Override void doCreatePersistent(String path); @Override long doCreateEphemeral(String path); @Override boolean checkExists(String pat...
@Test public void test_watch_when_modify() { String path = "/dubbo/config/jetcd-client-unit-test/configurators"; String endpoint = "http: CountDownLatch latch = new CountDownLatch(1); ByteSequence key = ByteSequence.from(path, UTF_8); Watch.Listener listener = Watch.listener(response -> { for (WatchEvent event : respon...
MulticastExchangeNetworker implements ExchangeNetworker { @Override public ExchangeGroup lookup(URL url) throws RemotingException { return new MulticastExchangeGroup(url); } @Override ExchangeGroup lookup(URL url); }
@Test public void testJoin() throws RemotingException, InterruptedException { final String groupURL = "multicast: MulticastExchangeNetworker multicastExchangeNetworker = new MulticastExchangeNetworker(); final CountDownLatch countDownLatch = new CountDownLatch(1); Peer peer1 = multicastExchangeNetworker.lookup(URL.valu...
FileNetworker implements Networker { @Override public Group lookup(URL url) throws RemotingException { return new FileGroup(url); } @Override Group lookup(URL url); }
@Test public void testJoin(@TempDir Path folder) throws RemotingException, InterruptedException { final String groupURL = "file: FileNetworker networker = new FileNetworker(); Group group = networker.lookup(URL.valueOf(groupURL)); final CountDownLatch countDownLatch = new CountDownLatch(1); Peer peer1 = group.join(URL....
MulticastNetworker implements Networker { @Override public Group lookup(URL url) throws RemotingException { return new MulticastGroup(url); } @Override Group lookup(URL url); }
@Test public void testJoin() throws RemotingException, InterruptedException { final String groupURL = "multicast: final String peerURL = "dubbo: final CountDownLatch countDownLatch = new CountDownLatch(1); Peer peer1 = Networkers.join(groupURL, peerURL, new ChannelHandlerAdapter() { @Override public void received(Chann...
ConsumerConfig extends AbstractReferenceConfig { @Override public void setTimeout(Integer timeout) { super.setTimeout(timeout); String rmiTimeout = System.getProperty("sun.rmi.transport.tcp.responseTimeout"); if (timeout != null && timeout > 0 && (StringUtils.isEmpty(rmiTimeout))) { System.setProperty("sun.rmi.transpor...
@Test public void testTimeout() throws Exception { try { System.clearProperty("sun.rmi.transport.tcp.responseTimeout"); ConsumerConfig consumer = new ConsumerConfig(); consumer.setTimeout(10); assertThat(consumer.getTimeout(), is(10)); assertThat(System.getProperty("sun.rmi.transport.tcp.responseTimeout"), equalTo("10"...
ApplicationConfig extends AbstractConfig { public void setEnvironment(String environment) { checkName(Constants.ENVIRONMENT, environment); if (environment != null) { if (!(Constants.DEVELOPMENT_ENVIRONMENT.equals(environment) || Constants.TEST_ENVIRONMENT.equals(environment) || Constants.PRODUCTION_ENVIRONMENT.equals(e...
@Test public void testEnvironment2() throws Exception { Assertions.assertThrows(IllegalStateException.class, () -> { ApplicationConfig application = new ApplicationConfig("app"); application.setEnvironment("illegal-env"); }); }
JsonRpcProtocol extends AbstractProxyProtocol { @Override public void destroy() { super.destroy(); for (String key : new ArrayList<>(serverMap.keySet())) { HttpServer server = serverMap.remove(key); if (server != null) { try { if (logger.isInfoEnabled()) { logger.info("Close jsonrpc server " + server.getUrl()); } serve...
@Test public void testJsonrpcProtocolForServerJetty9() { JsonRpcServiceImpl server = new JsonRpcServiceImpl(); assertFalse(server.isCalled()); ProxyFactory proxyFactory = ExtensionLoader.getExtensionLoader(ProxyFactory.class).getAdaptiveExtension(); Protocol protocol = ExtensionLoader.getExtensionLoader(Protocol.class)...
ApplicationConfig extends AbstractConfig { public void setQosAcceptForeignIp(Boolean qosAcceptForeignIp) { this.qosAcceptForeignIp = qosAcceptForeignIp; } ApplicationConfig(); ApplicationConfig(String name); @Parameter(key = Constants.APPLICATION_KEY, required = true, useKeyAsProperty = false) String getName(); void s...
@Test public void testParameters() throws Exception { ApplicationConfig application = new ApplicationConfig("app"); application.setQosAcceptForeignIp(true); Map<String, String> parameters = new HashMap<String, String>(); parameters.put("k1", "v1"); ApplicationConfig.appendParameters(parameters, application); assertThat...
AbstractInterfaceConfig extends AbstractMethodConfig { protected void checkRegistry() { loadRegistriesFromBackwardConfig(); convertRegistryIdsToRegistries(); for (RegistryConfig registryConfig : registries) { if (!registryConfig.isValid()) { throw new IllegalStateException("No registry config found or it's not a valid ...
@Test public void testCheckRegistry2() { Assertions.assertThrows(IllegalStateException.class, () -> { InterfaceConfig interfaceConfig = new InterfaceConfig(); interfaceConfig.checkRegistry(); }); }
AbstractInterfaceConfig extends AbstractMethodConfig { @SuppressWarnings("deprecation") protected void checkApplication() { createApplicationIfAbsent(); if (!application.isValid()) { throw new IllegalStateException("No application config found or it's not a valid config! " + "Please add <dubbo:application name=\"...\" ...
@Test public void checkApplication2() { Assertions.assertThrows(IllegalStateException.class, () -> { InterfaceConfig interfaceConfig = new InterfaceConfig(); interfaceConfig.checkApplication(); }); }
AbstractInterfaceConfig extends AbstractMethodConfig { protected List<URL> loadRegistries(boolean provider) { List<URL> registryList = new ArrayList<URL>(); if (CollectionUtils.isNotEmpty(registries)) { for (RegistryConfig config : registries) { String address = config.getAddress(); if (StringUtils.isEmpty(address)) { ...
@Test public void testLoadRegistries() { System.setProperty("dubbo.registry.address", "addr1"); InterfaceConfig interfaceConfig = new InterfaceConfig(); interfaceConfig.checkRegistry(); List<URL> urls = interfaceConfig.loadRegistries(true); Assertions.assertEquals(1, urls.size()); URL url = urls.get(0); Assertions.asse...
AbstractInterfaceConfig extends AbstractMethodConfig { protected URL loadMonitor(URL registryURL) { checkMonitor(); Map<String, String> map = new HashMap<String, String>(); map.put(Constants.INTERFACE_KEY, MonitorService.class.getName()); appendRuntimeParameters(map); String hostToRegistry = ConfigUtils.getSystemProper...
@Test public void testLoadMonitor() { System.setProperty("dubbo.monitor.address", "monitor-addr:12080"); System.setProperty("dubbo.monitor.protocol", "monitor"); InterfaceConfig interfaceConfig = new InterfaceConfig(); URL url = interfaceConfig.loadMonitor(new URL("dubbo", "addr1", 9090)); Assertions.assertEquals("moni...
AbstractInterfaceConfig extends AbstractMethodConfig { protected void checkInterfaceAndMethods(Class<?> interfaceClass, List<MethodConfig> methods) { Assert.notNull(interfaceClass, new IllegalStateException("interface not allow null!")); if (!interfaceClass.isInterface()) { throw new IllegalStateException("The interfac...
@Test public void checkInterfaceAndMethods1() { Assertions.assertThrows(IllegalStateException.class, () -> { InterfaceConfig interfaceConfig = new InterfaceConfig(); interfaceConfig.checkInterfaceAndMethods(null, null); }); } @Test public void checkInterfaceAndMethods2() { Assertions.assertThrows(IllegalStateException....
InvokerInvocationHandler implements InvocationHandler { @Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { String methodName = method.getName(); Class<?>[] parameterTypes = method.getParameterTypes(); if (method.getDeclaringClass() == Object.class) { return method.invoke(invok...
@Test public void testInvokeToString() throws Throwable { String methodName = "toString"; when(invoker.toString()).thenReturn(methodName); Method method = invoker.getClass().getMethod(methodName); Object result = invokerInvocationHandler.invoke(null, method, new Object[]{}); Assertions.assertEquals(methodName, result);...