src_fm_fc_ms_ff stringlengths 43 86.8k | target stringlengths 20 276k |
|---|---|
MessageDequeue implements ApplicationService { @Override public void start() { if (handlerExecutor != null || pollerExecutor != null) { throw new IllegalStateException("Already started"); } if (nrThreads > 0) { freeThreads.set(nrThreads); handlerExecutor = Executors.newFixedThreadPool(nrThreads); pollerExecutor = Execu... | @Test(expected = IllegalStateException.class) public void start_twice() { when(mailMessageDao.claimMessage()).thenReturn(null); subject.start(); subject.start(); }
@Test public void noMessages() { when(mailMessageDao.claimMessage()).thenReturn(null); subject.start(); verifyZeroInteractions(messageHandler); }
@Test publ... |
MessageDequeue implements ApplicationService { @Override public void stop(final boolean force) { LOGGER.info("Message dequeue stopping"); if (stopExecutor(pollerExecutor)) { pollerExecutor = null; } if (stopExecutor(handlerExecutor)) { handlerExecutor = null; } LOGGER.info("Message dequeue stopped"); } @Autowired Mess... | @Test public void stop_not_running() throws InterruptedException { subject.stop(true); } |
MessageDequeue implements ApplicationService { private void handleMessage(final String messageId) { final MimeMessage message = mailMessageDao.getMessage(messageId); try { loggerContext.init(getMessageIdLocalPart(message)); try { handleMessageInContext(messageId, message); } finally { loggerContext.remove(); } } catch ... | @Test public void handleMessage() throws Exception { final MimeMessage message = MimeMessageProvider.getMessageSimpleTextUnsigned(); when(messageFilter.shouldProcess(any(MailMessage.class))).thenReturn(true); when(messageParser.parse(eq(message), any(UpdateContext.class))).thenReturn( new MailMessage("", "", "", "", ""... |
MessageDequeue implements ApplicationService { String getMessageIdLocalPart(final Message message) throws MessagingException { final String[] headers = message.getHeader("Message-Id"); if (headers != null && headers.length > 0) { Matcher matcher = MESSAGE_ID_PATTERN.matcher(headers[0]); if (matcher.matches()) { return ... | @Test public void getMessageIdLocalPart_local_and_domain_parts() throws Exception { Message message = mock(Message.class); when(message.getHeader("Message-Id")).thenReturn(new String[]{"<20120527220444.GA6565@ripe.net>"}); final String messageIdLocalPart = subject.getMessageIdLocalPart(message); assertThat(messageIdLoc... |
MessageParser { public MailMessage parse(final MimeMessage message, final UpdateContext updateContext) throws MessagingException { final MailMessageBuilder messageBuilder = new MailMessageBuilder(); messageBuilder.id(message.getMessageID()); parseSubject(messageBuilder, message, updateContext); String[] deliveryDate = ... | @Test public void parseKeywords_validOnes() throws Exception { final Keyword[] validKeywords = new Keyword[]{Keyword.HELP, Keyword.HOWTO, Keyword.NEW, Keyword.NONE}; for (Keyword keyword : validKeywords) { final String keywordKeyword = keyword.getKeyword(); if (keywordKeyword == null) { continue; } when(mimeMessage.get... |
MessageParser { Charset getCharset(final ContentType contentType) { final String charset = contentType.getParameter("charset"); if (charset != null) { try { return Charset.forName(MimeUtility.javaCharset(charset)); } catch (UnsupportedCharsetException e) { loggerContext.log(new Message(Messages.Type.WARNING, "Unsupport... | @Test public void illegal_charset() throws Exception { assertThat(subject.getCharset(new ContentType("text/plain;\n\tcharset=\"_iso-2022-jp$ESC\"")), is(StandardCharsets.ISO_8859_1)); } |
DnsCheckRequest { @Override public boolean equals(final Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; final DnsCheckRequest that = (DnsCheckRequest) o; return Objects.equals(domain, that.domain) && Objects.equals(glue, that.glue); } DnsCheckRequest(final Update updat... | @Test public void equals_null() { assertThat(new DnsCheckRequest(update, "domain", "glue").equals(null), is(false)); }
@Test public void equals_other_class() { assertThat(new DnsCheckRequest(update, "domain", "glue").equals(""), is(false)); }
@Test public void equals_same_instance() { final DnsCheckRequest dnsCheckRequ... |
ZonemasterDnsGateway implements DnsGateway { @Override public Map<DnsCheckRequest, DnsCheckResponse> performDnsChecks(final Set<DnsCheckRequest> dnsCheckRequests) { return dnsCheckRequests .parallelStream() .collect(Collectors.toMap( dnsCheckRequest -> dnsCheckRequest, new ZonemasterFunction())); } ZonemasterDnsGateway... | @Test public void single_record_with_error_message() { mock(RpslObject.parse("domain: 22.0.193.in-addr.arpa")); when(startDomainTestResponse.getResult()).thenReturn("1"); when(testProgressResponse.getResult()).thenReturn("50").thenReturn("100"); when(result.getResults()).thenReturn(Lists.newArrayList(message)); when(me... |
DnsChecker { public void checkAll(final UpdateRequest updateRequest, final UpdateContext updateContext) { if (!dnsCheckEnabled) { return; } Set<DnsCheckRequest> dnsCheckRequestSet = Sets.newLinkedHashSet(); for (Update update : updateRequest.getUpdates()) { if (isDnsCheckRequired(update)) { dnsCheckRequestSet.add(creat... | @Test public void check_delete() { when(update.getOperation()).thenReturn(Operation.DELETE); subject.checkAll(updateRequest, updateContext); verifyZeroInteractions(dnsGateway); }
@Test public void check_not_domain() { when(update.getType()).thenReturn(ObjectType.INETNUM); subject.checkAll(updateRequest, updateContext);... |
AutnumAuthentication extends AuthenticationStrategyBase { @Override public boolean supports(final PreparedUpdate update) { return update.getType().equals(ObjectType.AUT_NUM) && update.getAction().equals(Action.CREATE); } @Autowired AutnumAuthentication(final RpslObjectDao objectDao, final AuthenticationModule authenti... | @Test public void supports_autnum_create() { when(update.getAction()).thenReturn(Action.CREATE); when(update.getType()).thenReturn(ObjectType.AUT_NUM); final boolean supported = subject.supports(update); assertThat(supported, is(true)); }
@Test public void supports_other_than_autnum_create() { for (final ObjectType obj... |
AutnumAuthentication extends AuthenticationStrategyBase { @Override public List<RpslObject> authenticate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject object = update.getUpdatedObject(); final CIString pkey = object.getKey(); final long number = Long.parseLong(pkey.toString().substr... | @Test public void authenticated_by_mntlower_succeeds() { when(update.getUpdatedObject()).thenReturn(RpslObject.parse("aut-num: AS3333")); when(objectDao.findAsBlock(3333, 3333)).thenReturn(RpslObject.parse("as-block: AS3209 - AS3353\nmnt-lower: LOW-MNT")); final ArrayList<RpslObject> parentMaintainers = Lists.newArrayL... |
MntIrtAuthentication extends AuthenticationStrategyBase { @Override public boolean supports(final PreparedUpdate update) { return !update.getNewValues(AttributeType.MNT_IRT).isEmpty(); } @Autowired MntIrtAuthentication(final AuthenticationModule credentialValidators, final RpslObjectDao rpslObjectDao); @Override boole... | @Test public void operates_on_updates_with_new_mntirts() { when(update.getNewValues(AttributeType.MNT_IRT)).thenReturn(ciSet("IRT-MNT")); assertThat(subject.supports(update), is(true)); }
@Test public void does_not_support_updates_with_same_mntirts() { when(update.getNewValues(AttributeType.MNT_IRT)).thenReturn(Sets.<C... |
MntIrtAuthentication extends AuthenticationStrategyBase { @Override public List<RpslObject> authenticate(final PreparedUpdate update, final UpdateContext updateContext) { final Collection<CIString> keys = update.getNewValues(AttributeType.MNT_IRT); final List<RpslObject> candidates = rpslObjectDao.getByKeys(ObjectType.... | @Test public void authentication_succeeds() { when(update.getType()).thenReturn(ObjectType.INETNUM); when(update.getNewValues(AttributeType.MNT_IRT)).thenReturn(ciSet("IRT-MNT")); when(update.getReferenceObject()).thenReturn(RpslObject.parse("inetnum: 192.0/24")); when(update.getUpdatedObject()).thenReturn(RpslObject.p... |
MntByAuthentication extends AuthenticationStrategyBase { @Override public boolean supports(final PreparedUpdate update) { return ObjectTemplate.getTemplate(update.getType()).hasAttribute(AttributeType.MNT_BY); } @Autowired MntByAuthentication(final Maintainers maintainers,
final AuthenticationM... | @Test public void supports_every_object_with_a_mntby_attribute() { when(update.getType()).thenReturn(ObjectType.POEM); assertThat(subject.supports(update), is(true)); when(update.getType()).thenReturn(ObjectType.INETNUM); assertThat(subject.supports(update), is(true)); verifyZeroInteractions(maintainers); } |
MntByAuthentication extends AuthenticationStrategyBase { @Override public List<RpslObject> authenticate(final PreparedUpdate update, final UpdateContext updateContext) { try { return authenticateMntBy(update, updateContext); } catch (AuthenticationFailedException e) { return authenticateByAddressSpaceHolder(update, upd... | @Test public void authenticate_succeeds() { final RpslObject org = RpslObject.parse("organisation: ORG1\nmnt-by: TEST-MNT"); when(update.getReferenceObject()).thenReturn(org); when(update.getType()).thenReturn(ObjectType.ORGANISATION); when(update.getUpdatedObject()).thenReturn(RpslObject.parse("organisation: ORG1\nmnt... |
RouteIpAddressAuthentication extends RouteAuthentication { @Override public List<RpslObject> authenticate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); final RpslAttribute typeAttribute = updatedObject.getTypeAttribute(); final IpInterval a... | @Test public void exact_match_route_without_mntRoutes_succeeds() { final RpslObject existingRoute = RpslObject.parse("" + "route: 192.91.244.0/23\n" + "origin: AS12\n" + "mnt-by: TEST-MNT"); final Ipv4Resource existingRouteResource = Ipv4Resource.parse(existingRoute.getTypeAttribute().getCleanValue()); final Ipv4RouteE... |
DomainAuthentication extends AuthenticationStrategyBase { @Override public boolean supports(final PreparedUpdate update) { return update.getAction().equals(Action.CREATE) && (update.getType().equals(ObjectType.DOMAIN)); } @Autowired DomainAuthentication(final Ipv4Tree ipv4Tree,
final Ip... | @Test public void supports_create_domain() { when(update.getAction()).thenReturn(Action.CREATE); when(update.getType()).thenReturn(ObjectType.DOMAIN); assertThat(subject.supports(update), is(true)); }
@Test public void supports_modify_domain() { when(update.getAction()).thenReturn(Action.MODIFY); when(update.getType())... |
DomainAuthentication extends AuthenticationStrategyBase { @Override public List<RpslObject> authenticate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject rpslObject = update.getUpdatedObject(); final CIString domainString = rpslObject.getKey(); final Domain domain = Domain.parse(domain... | @Test public void authenticate_enum_domain() { final RpslObject rpslObject = RpslObject.parse("domain: 2.1.2.1.5.5.5.2.0.2.1.e164.arpa"); when(update.getUpdatedObject()).thenReturn(rpslObject); final List<RpslObject> authenticated = subject.authenticate(update, updateContext); assertThat(authenticated, hasSize(0)); ver... |
OrgRefAuthentication extends AuthenticationStrategyBase { @Override public boolean supports(final PreparedUpdate update) { return !update.getNewValues(AttributeType.ORG).isEmpty(); } @Autowired OrgRefAuthentication(final AuthenticationModule credentialValidators, final RpslObjectDao rpslObjectDao); @Override boolean s... | @Test public void supports_update_with_new_org_references() { when(update.getNewValues(AttributeType.ORG)).thenReturn(ciSet("ORG2")); when(update.getUpdatedObject()).thenReturn(RpslObject.parse("organisation: ORG1\norg: ORG1")); assertThat(subject.supports(update), is(true)); }
@Test public void no_difference_in_org_re... |
OrgRefAuthentication extends AuthenticationStrategyBase { @Override public List<RpslObject> authenticate(final PreparedUpdate update, final UpdateContext updateContext) { final List<Message> authenticationMessages = Lists.newArrayList(); final Map<RpslObject, List<RpslObject>> candidatesForOrganisations = getCandidates... | @Test public void authentication_succeeds() { when(update.getType()).thenReturn(ObjectType.INETNUM); when(update.getReferenceObject()).thenReturn(RpslObject.parse("inetnum: 192.0/24\norg: ORG1")); when(update.getUpdatedObject()).thenReturn(RpslObject.parse("inetnum: 192.0/24\norg: ORG2")); final RpslObject organisation... |
InetnumAuthentication extends AuthenticationStrategyBase { @Override public boolean supports(final PreparedUpdate update) { return update.getAction().equals(Action.CREATE) && (update.getType().equals(ObjectType.INETNUM) || update.getType().equals(ObjectType.INET6NUM)); } @Autowired InetnumAuthentication(final Authenti... | @Test public void supports_creating_inetnum() { when(update.getAction()).thenReturn(Action.CREATE); when(update.getType()).thenReturn(ObjectType.INETNUM); assertThat(subject.supports(update), is(true)); }
@Test public void supports_creating_inet6num() { when(update.getAction()).thenReturn(Action.CREATE); when(update.ge... |
InetnumAuthentication extends AuthenticationStrategyBase { @Override public List<RpslObject> authenticate(final PreparedUpdate update, final UpdateContext updateContext) { final IpInterval ipInterval = IpInterval.parse(update.getUpdatedObject().getKey()); IpEntry ipEntry; try { ipEntry = getParentEntry(ipInterval); } c... | @Test public void authenticate_mntlower_inetnum_succeeds() { when(update.getUpdatedObject()).thenReturn(RpslObject.parse("inetnum: 192.0/24")); final RpslObject parent = RpslObject.parse("inetnum: 192.0/16\nmnt-lower: LWR-MNT"); when(rpslObjectDao.getById(anyInt())).thenReturn(parent); when(ipv4Tree.findFirstLessSpecif... |
X509CredentialValidator implements CredentialValidator<X509Credential, X509Credential> { @Override public boolean hasValidCredential(final PreparedUpdate update, final UpdateContext updateContext, final Collection<X509Credential> offeredCredentials, final X509Credential knownCredential) { for (final X509Credential offe... | @Test public void authentication_success() { boolean result = subject.hasValidCredential(update, updateContext, Sets.newHashSet(offeredCredential), knownCredential); assertThat(result, is(true)); }
@Test public void authentication_keycert_not_found() throws Exception { when(rpslObjectDao.getByKey(ObjectType.KEY_CERT, "... |
SsoCredentialValidator implements CredentialValidator<SsoCredential, SsoCredential> { @Override public Class<SsoCredential> getSupportedCredentials() { return SsoCredential.class; } @Autowired SsoCredentialValidator(final LoggerContext loggerContext); @Override Class<SsoCredential> getSupportedCredentials(); @Override... | @Test public void supportedCredentials() { assertThat(subject.getSupportedCredentials(), Is.<Class<SsoCredential>>is(SsoCredential.class)); } |
SsoCredentialValidator implements CredentialValidator<SsoCredential, SsoCredential> { @Override public boolean hasValidCredential(final PreparedUpdate update, final UpdateContext updateContext, final Collection<SsoCredential> offeredCredentials, final SsoCredential knownCredential) { for (SsoCredential offered : offere... | @Test public void hasValidCredential() { final UserSession offered = new UserSession("test@ripe.net", "Test User", true, "2033-01-30T16:38:27.369+11:00"); offered.setUuid("testuuid"); final SsoCredential offeredCredential = (SsoCredential)SsoCredential.createOfferedCredential(offered); final SsoCredential knownCredenti... |
AuthenticationModule { @CallerSensitive public List<RpslObject> authenticate(final PreparedUpdate update, final UpdateContext updateContext, final Collection<RpslObject> maintainers) { final Credentials offered = update.getCredentials(); boolean passwordRemovedRemark = false; loggerContext.logAuthenticationStrategy(upd... | @Test public void authenticate_finds_all_candidates() { when(credentialValidator.hasValidCredential(any(PreparedUpdate.class), any(UpdateContext.class), anyCollection(), any(PasswordCredential.class))).thenReturn(true); final RpslObject mntner1 = RpslObject.parse("mntner: TEST-MNT\nauth: MD5-PWsomething"); final RpslOb... |
PasswordCredentialValidator implements CredentialValidator<PasswordCredential, PasswordCredential> { @Override public Class<PasswordCredential> getSupportedCredentials() { return PasswordCredential.class; } @Autowired PasswordCredentialValidator(LoggerContext loggerContext); @Override Class<PasswordCredential> getSupp... | @Test public void supports() { assertEquals(PasswordCredential.class, subject.getSupportedCredentials()); } |
PgpCredentialValidator implements CredentialValidator<PgpCredential, PgpCredential> { @Override public boolean hasValidCredential(final PreparedUpdate update, final UpdateContext updateContext, final Collection<PgpCredential> offeredCredentials, final PgpCredential knownCredential) { for (final PgpCredential offeredCre... | @Test public void setsEffectiveCredential() { final String message = "-----BEGIN PGP SIGNED MESSAGE-----\n" + "Hash: SHA1\n" + "\n" + "inetnum: 213.168.127.96 - 213.168.127.10\n" + "netname: NETNAME\n" + "descr: Description\n" + "country: DE\n" + "admin-c: TEST-RIPE\n" + "tech-c: TEST-RIPE\n" + "status: ASSIGNED PA\n" ... |
TimestampAttributeGenerator extends AttributeGenerator { @Override public RpslObject generateAttributes(final RpslObject originalObject, final RpslObject updatedObject, final Update update, final UpdateContext updateContext) { final Action action = updateContext.getAction(update); if (action == Action.CREATE || action ... | @Test public void create_input_has_no_timestamps() { testDateTimeProvider.setTime(actionTime()); when(updateContext.getAction(update)).thenReturn(Action.CREATE); final RpslObject input = TEMPLATE; final RpslObject updatedObject = subject.generateAttributes(null, input, update, updateContext); assertThat(updatedObject.f... |
KeycertAttributeGenerator extends AttributeGenerator { public RpslObject generateAttributes(final RpslObject originalObject, final Update update, final UpdateContext updateContext) { return generateAttributes(originalObject, originalObject, update, updateContext); } @Autowired KeycertAttributeGenerator(final KeyWrappe... | @Test public void generate_attributes_for_x509_certificate() { final RpslObject keycert = RpslObject.parse( "key-cert: X509-1\n" + "certif: -----BEGIN CERTIFICATE-----\n" + "certif: MIIC8DCCAlmgAwIBAgICBIQwDQYJKoZIhvcNAQEEBQAwXjELMAkGA1UEBhMCTkwx\n" + "certif: ETAPBgNVBAoTCFJJUEUgTkNDMR0wGwYDVQQLExRSSVBFIE5DQyBMSVIgTmV... |
AutnumAttributeGenerator extends AttributeGenerator { @Override public RpslObject generateAttributes(final RpslObject originalObject, final RpslObject updatedObject, final Update update, final UpdateContext updateContext) { switch (updatedObject.getType()) { case AUT_NUM: return generateStatus(originalObject, updatedOb... | @Test public void generate_other_status_on_create() { final RpslObject autnum = RpslObject.parse("aut-num: AS3333\nmnt-by: TEST-MNT\nsource: RIPE"); final RpslObject result = autnumStatusAttributeGenerator.generateAttributes(null, autnum, update, updateContext); assertThat(result.getValueForAttribute(AttributeType.STAT... |
SsoTranslator { public RpslObject translateFromCacheAuthToUsername(final UpdateContext updateContext, final RpslObject rpslObject) { return translateAuthFromCache(updateContext, rpslObject); } @Autowired SsoTranslator(final CrowdClient crowdClient); void populateCacheAuthToUsername(final UpdateContext updateContext, f... | @Test public void translate_to_uuid_username_stored_in_context_already() { final RpslObject object = RpslObject.parse("mntner: TEST-MNT\nauth: SSO username@test.net"); when(updateContext.getSsoTranslationResult("username@test.net")).thenReturn("BBBB-1234-CCCC-DDDD"); final RpslObject result = subject.translateFromCache... |
RepoScanner { public RepoScanner() { githubUser = System.getProperty("githubUser"); githubToken = System.getProperty("githubToken"); if (githubUser == null || githubToken == null) { String msg = ("To scan GitHub for submissions please provide your username and a valid Personal Access Token.\n" + "Without this the submi... | @Test public void testRepoScanner() throws IOException { try { JSONObject submissions = new RepoScanner() .getSubmissionsFromRepo("bpmn-miwg/bpmn-miwg-test-suite"); System.out.println(submissions); FileUtils.writeStringToFile(new File("target/submissions.json"), submissions.toJSONString()); } catch (Throwable t) { assu... |
ModelInterchangeMojo extends AbstractMojo { public void execute() throws MojoExecutionException { getLog().info("Running BPMN-MIWG test suite..."); if (!outputDirectory.exists()) { outputDirectory.mkdirs(); } try { Collection<String> inputFolders = new LinkedList<String>(); if (!resources.isEmpty()) { for (Resource res... | @Test public void testMojo() { try { Resource res = new Resource(); res.setDirectory(SRC_TEST_RESOURCES); mojo.resources.add(res); mojo.execute(); System.out .println("Checking expected output exists with base folder: " + TestUtil.REPORT_BASE_FOLDER_NAME); assertTrue(overview.exists()); Document document = docBuilder.p... |
DebugWebViewClient extends WebViewClient implements LogControl { @RequiresApi(api = Build.VERSION_CODES.M) @Override public void onReceivedError(final WebView view, final WebResourceRequest request, final WebResourceError error) { logger.onReceivedError(view, request, error); client.onReceivedError(view, request, error... | @Test public void onReceivedError() { final int code = 500; final String message = "foo"; final String url = "bar"; debugClient.onReceivedError(webView, code, message, url); verifyLogger().onReceivedError(webView, code, message, url); verifyWrappedClient().onReceivedError(webView, code, message, url); }
@Test public vo... |
DebugWebViewClient extends WebViewClient implements LogControl { @Override @Deprecated @SuppressWarnings("deprecation") public void onTooManyRedirects(WebView view, Message cancelMsg, Message continueMsg) { logger.onTooManyRedirects(view, cancelMsg, continueMsg); client.onTooManyRedirects(view, cancelMsg, continueMsg);... | @Test @SuppressWarnings("deprecation") public void onTooManyRedirects() { final Message cancelMsg = Mockito.mock(Message.class); final Message continueMsg = Mockito.mock(Message.class); debugClient.onTooManyRedirects(webView, cancelMsg, continueMsg); verifyLogger().onTooManyRedirects(webView, cancelMsg, continueMsg); v... |
DebugWebViewClient extends WebViewClient implements LogControl { @Override public void onReceivedHttpAuthRequest(WebView view, HttpAuthHandler handler, String host, String realm) { logger.onReceivedHttpAuthRequest(view, handler, host, realm); client.onReceivedHttpAuthRequest(view, handler, host, realm); } DebugWebViewC... | @Test public void onReceivedHttpAuthRequest() { final HttpAuthHandler handler = Mockito.mock(HttpAuthHandler.class); final String host = "foo"; final String realm = "bar"; debugClient.onReceivedHttpAuthRequest(webView, handler, host, realm); verifyLogger().onReceivedHttpAuthRequest(webView, handler, host, realm); verif... |
DebugWebViewClient extends WebViewClient implements LogControl { @Override public void onPageStarted(WebView view, String url, Bitmap facIcon) { logger.onPageStarted(view, url, facIcon); client.onPageStarted(view, url, facIcon); } DebugWebViewClient(); DebugWebViewClient(@NonNull final WebViewClient client); @Suppress... | @Test public void onPageStarted() { final String url = "foo"; final Bitmap bitmap = Mockito.mock(Bitmap.class); debugClient.onPageStarted(webView, url, bitmap); verifyLogger().onPageStarted(webView, url, bitmap); verifyWrappedClient().onPageStarted(webView, url, bitmap); } |
DebugWebViewClient extends WebViewClient implements LogControl { @Override public void onPageFinished(WebView view, String url) { logger.onPageFinished(view, url); client.onPageFinished(view, url); } DebugWebViewClient(); DebugWebViewClient(@NonNull final WebViewClient client); @SuppressWarnings("WeakerAccess") Debug... | @Test public void onPageFinished() { final String url = "foo"; debugClient.onPageFinished(webView, url); verifyLogger().onPageFinished(webView, url); verifyWrappedClient().onPageFinished(webView, url); } |
DebugWebViewClient extends WebViewClient implements LogControl { @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP) @Override public void onReceivedClientCertRequest(WebView view, ClientCertRequest request) { logger.onReceivedClientCertRequest(view, request); client.onReceivedClientCertRequest(view, request); } DebugWebV... | @Test public void onReceivedClientCertRequest() { final ClientCertRequest request = Mockito.mock(ClientCertRequest.class); debugClient.onReceivedClientCertRequest(webView, request); verifyLogger().onReceivedClientCertRequest(webView, request); verifyWrappedClient().onReceivedClientCertRequest(webView, request); } |
DebugWebViewClient extends WebViewClient implements LogControl { @Override public void onFormResubmission(final WebView view, final Message dontResend, final Message resend) { logger.onFormResubmission(view, dontResend, resend); client.onFormResubmission(view, dontResend, resend); } DebugWebViewClient(); DebugWebViewC... | @Test public void onFormResubmission() { final Message dontResend = Mockito.mock(Message.class); final Message resend = Mockito.mock(Message.class); debugClient.onFormResubmission(webView, dontResend, resend); verifyLogger().onFormResubmission(webView, dontResend, resend); verifyWrappedClient().onFormResubmission(webVi... |
DebugWebViewClient extends WebViewClient implements LogControl { @Override public void doUpdateVisitedHistory(final WebView view, final String url, final boolean isReload) { logger.doUpdateVisitedHistory(view, url, isReload); client.doUpdateVisitedHistory(view, url, isReload); } DebugWebViewClient(); DebugWebViewClien... | @Test public void doUpdateVisitedHistory() { final String url = "foo"; final boolean reload = true; debugClient.doUpdateVisitedHistory(webView, url, reload); verifyLogger().doUpdateVisitedHistory(webView, url, reload); verifyWrappedClient().doUpdateVisitedHistory(webView, url, reload); } |
DebugWebViewClient extends WebViewClient implements LogControl { @Override public boolean shouldOverrideKeyEvent(final WebView view, final KeyEvent event) { final boolean retVal = client.shouldOverrideKeyEvent(view, event); logger.shouldOverrideKeyEvent(view, event, retVal); return retVal; } DebugWebViewClient(); Debu... | @Test public void shouldOverrideKeyEvent() { final KeyEvent keyEvent = Mockito.mock(KeyEvent.class); final boolean retVal = debugClient.shouldOverrideKeyEvent(webView, keyEvent); verifyLogger().shouldOverrideKeyEvent(webView, keyEvent, retVal); verifyWrappedClient().shouldOverrideKeyEvent(webView, keyEvent); } |
DebugWebViewClient extends WebViewClient implements LogControl { @Override public void onUnhandledKeyEvent(final WebView view, final KeyEvent event) { logger.onUnhandledKeyEvent(view, event); client.onUnhandledKeyEvent(view, event); } DebugWebViewClient(); DebugWebViewClient(@NonNull final WebViewClient client); @Supp... | @Test public void onUnhandledKeyEvent() { final KeyEvent keyEvent = Mockito.mock(KeyEvent.class); debugClient.onUnhandledKeyEvent(webView, keyEvent); verifyLogger().onUnhandledKeyEvent(webView, keyEvent); verifyWrappedClient().onUnhandledKeyEvent(webView, keyEvent); } |
DebugWebViewClient extends WebViewClient implements LogControl { @Override public void onScaleChanged(final WebView view, final float oldScale, final float newScale) { logger.onScaleChanged(view, oldScale, newScale); client.onScaleChanged(view, oldScale, newScale); } DebugWebViewClient(); DebugWebViewClient(@NonNull f... | @Test public void onScaleChanged() { final float oldScale = 1.0f; final float newScale = 2.0f; debugClient.onScaleChanged(webView, oldScale, newScale); verifyLogger().onScaleChanged(webView, oldScale, newScale); verifyWrappedClient().onScaleChanged(webView, oldScale, newScale); } |
DebugWebViewClient extends WebViewClient implements LogControl { @Override public void onReceivedLoginRequest(final WebView view, final String realm, final String account, final String args) { logger.onReceivedLoginRequest(view, realm, account, args); client.onReceivedLoginRequest(view, realm, account, args); } DebugWe... | @Test public void onReceivedLoginRequest() { final String realm = "realm"; final String account = "account"; final String args = "args"; debugClient.onReceivedLoginRequest(webView, realm, account, args); verifyLogger().onReceivedLoginRequest(webView, realm, account, args); verifyWrappedClient().onReceivedLoginRequest(w... |
DebugWebViewClient extends WebViewClient implements LogControl { @RequiresApi(api = Build.VERSION_CODES.O) @Override public boolean onRenderProcessGone(final WebView view, final RenderProcessGoneDetail detail) { final boolean retVal = client.onRenderProcessGone(view, detail); logger.onRenderProcessGone(view, detail, re... | @Test public void onRenderProcessGone() { final RenderProcessGoneDetail detail = Mockito.mock(RenderProcessGoneDetail.class); final boolean retVal = debugClient.onRenderProcessGone(webView, detail); verifyLogger().onRenderProcessGone(webView, detail, retVal); verifyWrappedClient().onRenderProcessGone(webView, detail); ... |
DebugWebViewClient extends WebViewClient implements LogControl { @RequiresApi(api = Build.VERSION_CODES.O_MR1) @Override public void onSafeBrowsingHit(final WebView view, final WebResourceRequest request, final int threatType, final SafeBrowsingResponse callback) { logger.onSafeBrowsingHit(view, request, threatType, ca... | @Test public void onSafeBrowsingHit() { final WebResourceRequest request = Mockito.mock(WebResourceRequest.class); final SafeBrowsingResponse callback = Mockito.mock(SafeBrowsingResponse.class); final int threatType = -1; debugClient.onSafeBrowsingHit(webView, request, threatType, callback); verifyLogger().onSafeBrowsi... |
DebugWebViewClientLogger implements LogControl { @RequiresApi(api = Build.VERSION_CODES.M) public void onReceivedError(final WebView view, final WebResourceRequest request, final WebResourceError error) { if (loggingEnabled) { final Uri url = request.getUrl(); final String method = request.getMethod(); final int code =... | @Test public void onReceivedError() { final int code = 500; final String message = "foo"; final String url = "bar"; logger.setLoggingEnabled(false); logger.onReceivedError(webView, code, message, url); verifyLogNotCalled(); logger.setLoggingEnabled(true); logger.onReceivedError(webView, code, message, url); verifyLogEn... |
DebugWebViewClientLogger implements LogControl { @RequiresApi(api = Build.VERSION_CODES.M) public void onReceivedHttpError(final WebView view, final WebResourceRequest request, final WebResourceResponse errorResponse) { if (loggingEnabled) { final Uri url = request.getUrl(); final int code = errorResponse.getStatusCode... | @Test public void onReceivedHttpError() { final WebResourceRequest request = Mockito.mock(WebResourceRequest.class); final WebResourceResponse response = Mockito.mock(WebResourceResponse.class); logger.setLoggingEnabled(false); logger.onReceivedHttpError(webView, request, response); verifyLogNotCalled(); logger.setLogg... |
DebugWebViewClientLogger implements LogControl { public void onReceivedSslError(final WebView view, final SslErrorHandler handler, final SslError error) { if (loggingEnabled) { logger.logError(String.format(LOCALE, "%s onReceivedSslError() ERR: %s", SPACE, error)); } } DebugWebViewClientLogger(); DebugWebViewClientLog... | @Test public void onReceivedSslError() { final SslErrorHandler errorHandler = Mockito.mock(SslErrorHandler.class); final SslError sslError = Mockito.mock(SslError.class); logger.setLoggingEnabled(false); logger.onReceivedSslError(webView, errorHandler, sslError); verifyLogNotCalled(); logger.setLoggingEnabled(true); lo... |
DebugWebViewClientLogger implements LogControl { @RequiresApi(api = Build.VERSION_CODES.N) public void shouldOverrideUrlLoading(WebView view, WebResourceRequest request, boolean retVal) { if (loggingEnabled) { final Uri url = request.getUrl(); final String method = request.getMethod(); final boolean redirect = request.... | @Test public void shouldOverrideUrlLoading() { final String url = "foo"; logger.setLoggingEnabled(false); logger.shouldOverrideUrlLoading(webView, url, false); verifyLogNotCalled(); logger.setLoggingEnabled(true); logger.shouldOverrideUrlLoading(webView, url, false); verifyLogEngine().log(Mockito.anyString()); } |
DebugWebViewClientLogger implements LogControl { public void onLoadResource(WebView view, String url) { if (loggingEnabled) { logger.log(String.format(LOCALE, "%s onLoadResource() %s", SPACE, url)); } } DebugWebViewClientLogger(); DebugWebViewClientLogger(@NonNull final String tag); @VisibleForTesting(otherwise = Visi... | @Test public void onLoadResource() { final String url = "foo"; logger.setLoggingEnabled(false); logger.onLoadResource(webView, url); verifyLogNotCalled(); logger.setLoggingEnabled(true); logger.onLoadResource(webView, url); verifyLogEngine().log(Mockito.anyString()); } |
DebugWebViewClientLogger implements LogControl { @TargetApi(Build.VERSION_CODES.M) public void onPageCommitVisible(WebView view, String url) { if (loggingEnabled) { logger.log(String.format(LOCALE, "%s onPageCommitVisible() %s", SPACE, url)); } } DebugWebViewClientLogger(); DebugWebViewClientLogger(@NonNull final Stri... | @Test public void onPageCommitVisible() { final String url = "foo"; logger.setLoggingEnabled(false); logger.onPageCommitVisible(webView, url); verifyLogNotCalled(); logger.setLoggingEnabled(true); logger.onPageCommitVisible(webView, url); verifyLogEngine().log(Mockito.anyString()); } |
DebugWebViewClientLogger implements LogControl { @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP) public void shouldInterceptRequest(WebView view, String url, WebResourceResponse retVal) { if (loggingEnabled) { final String result = retVal == null ? "false" : StringUtils.toString(retVal); logger.log(String.format(LOCAL... | @Test public void shouldInterceptRequest() { final String url = "foo"; final WebResourceResponse response = Mockito.mock(WebResourceResponse.class); logger.setLoggingEnabled(false); logger.shouldInterceptRequest(webView, url, response); verifyLogNotCalled(); logger.setLoggingEnabled(true); logger.shouldInterceptRequest... |
DebugWebViewClient extends WebViewClient implements LogControl { @RequiresApi(api = Build.VERSION_CODES.M) @Override public void onReceivedHttpError(final WebView view, final WebResourceRequest request, final WebResourceResponse errorResponse) { logger.onReceivedHttpError(view, request, errorResponse); client.onReceive... | @Test public void onReceivedHttpError() { final WebResourceRequest request = Mockito.mock(WebResourceRequest.class); final WebResourceResponse response = Mockito.mock(WebResourceResponse.class); debugClient.onReceivedHttpError(webView, request, response); verifyLogger().onReceivedHttpError(webView, request, response); ... |
DebugWebViewClientLogger implements LogControl { public void onTooManyRedirects(WebView view, Message cancelMsg, Message continueMsg) { if (loggingEnabled) { logger.logError(String.format(LOCALE, "%s onTooManyRedirects()", SPACE)); } } DebugWebViewClientLogger(); DebugWebViewClientLogger(@NonNull final String tag); @V... | @Test public void onTooManyRedirects() { final Message cancelMsg = Mockito.mock(Message.class); final Message continueMsg = Mockito.mock(Message.class); logger.setLoggingEnabled(false); logger.onTooManyRedirects(webView, cancelMsg, continueMsg); verifyLogNotCalled(); logger.setLoggingEnabled(true); logger.onTooManyRedi... |
DebugWebViewClientLogger implements LogControl { public void onReceivedHttpAuthRequest(WebView view, HttpAuthHandler handler, String host, String realm) { if (loggingEnabled) { logger.logSecurity(String.format(LOCALE, "%s onReceivedHttpAuthRequest() %s %s %s", SPACE, host, realm, handler)); } } DebugWebViewClientLogger... | @Test public void onReceivedHttpAuthRequest() { final HttpAuthHandler handler = Mockito.mock(HttpAuthHandler.class); final String host = "foo"; final String realm = "bar"; logger.setLoggingEnabled(false); logger.onReceivedHttpAuthRequest(webView, handler, host, realm); verifyLogNotCalled(); logger.setLoggingEnabled(tru... |
DebugWebViewClientLogger implements LogControl { public void onPageStarted(WebView view, String url, Bitmap facIcon) { if (loggingEnabled) { logger.log(String.format(LOCALE, "%s onPageStarted() %s", IN, url)); } } DebugWebViewClientLogger(); DebugWebViewClientLogger(@NonNull final String tag); @VisibleForTesting(other... | @Test public void onPageStarted() { final String url = "foo"; final Bitmap bitmap = Mockito.mock(Bitmap.class); logger.setLoggingEnabled(false); logger.onPageStarted(webView, url, bitmap); verifyLogNotCalled(); logger.setLoggingEnabled(true); logger.onPageStarted(webView, url, bitmap); verifyLogEngine().log(Mockito.any... |
DebugWebViewClientLogger implements LogControl { public void onPageFinished(WebView view, String url) { if (loggingEnabled) { logger.log(String.format(LOCALE, "%s onPageFinished() %s", OUT, url)); } } DebugWebViewClientLogger(); DebugWebViewClientLogger(@NonNull final String tag); @VisibleForTesting(otherwise = Visibl... | @Test public void onPageFinished() { final String url = "foo"; logger.setLoggingEnabled(false); logger.onPageFinished(webView, url); verifyLogNotCalled(); logger.setLoggingEnabled(true); logger.onPageFinished(webView, url); verifyLogEngine().log(Mockito.anyString()); } |
DebugWebViewClientLogger implements LogControl { @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP) public void onReceivedClientCertRequest(WebView view, ClientCertRequest request) { if (loggingEnabled) { logger.logSecurity(String.format(LOCALE, "%s onReceivedClientCertRequest() %s", SPACE, StringUtils.toString(request))... | @Test public void onReceivedClientCertRequest() { final ClientCertRequest request = Mockito.mock(ClientCertRequest.class); logger.setLoggingEnabled(false); logger.onReceivedClientCertRequest(webView, request); verifyLogNotCalled(); logger.setLoggingEnabled(true); logger.onReceivedClientCertRequest(webView, request); ve... |
DebugWebViewClientLogger implements LogControl { public void onFormResubmission(final WebView view, final Message dontResend, final Message resend) { if (loggingEnabled) { logger.log(String.format(LOCALE, "%s onFormResubmission()", SPACE)); } } DebugWebViewClientLogger(); DebugWebViewClientLogger(@NonNull final String... | @Test public void onFormResubmission() { final Message dontResend = Mockito.mock(Message.class); final Message resend = Mockito.mock(Message.class); logger.setLoggingEnabled(false); logger.onFormResubmission(webView, dontResend, resend); verifyLogNotCalled(); logger.setLoggingEnabled(true); logger.onFormResubmission(we... |
DebugWebViewClientLogger implements LogControl { public void doUpdateVisitedHistory(final WebView view, final String url, final boolean isReload) { if (loggingEnabled) { logger.log(String.format(LOCALE, "%s doUpdateVisitedHistory() %s, isReload: %s", SPACE, url, isReload)); } } DebugWebViewClientLogger(); DebugWebView... | @Test public void doUpdateVisitedHistory() { final String url = "foo"; final boolean reload = true; logger.setLoggingEnabled(false); logger.doUpdateVisitedHistory(webView, url, reload); verifyLogNotCalled(); logger.setLoggingEnabled(true); logger.doUpdateVisitedHistory(webView, url, reload); verifyLogEngine().log(Mocki... |
DebugWebViewClientLogger implements LogControl { public void shouldOverrideKeyEvent(final WebView view, final KeyEvent event, boolean retVal) { if (loggingEnabled && logKeyEventsEnabled) { logger.logKeyEvent(String.format(LOCALE, "%s shouldOverrideKeyEvent() 1/2 EVENT : %s", SPACE, event)); logger.logKeyEvent(String.fo... | @Test public void shouldOverrideKeyEvent() { final KeyEvent keyEvent = Mockito.mock(KeyEvent.class); logger.setLoggingEnabled(false); logger.setLogKeyEventsEnabled(false); logger.shouldOverrideKeyEvent(webView, keyEvent, false); verifyLogNotCalled(); logger.setLoggingEnabled(false); logger.setLogKeyEventsEnabled(true);... |
DebugWebViewClientLogger implements LogControl { public void onUnhandledInputEvent(final WebView view, final InputEvent event) { if (loggingEnabled && logKeyEventsEnabled) { logger.logKeyEvent(String.format(LOCALE, "%s onUnhandledInputEvent() %s", SPACE, event)); } } DebugWebViewClientLogger(); DebugWebViewClientLogge... | @Test public void onUnhandledInputEvent() { final InputEvent inputEvent = Mockito.mock(InputEvent.class); logger.setLoggingEnabled(false); logger.setLogKeyEventsEnabled(false); logger.onUnhandledInputEvent(webView, inputEvent); verifyLogNotCalled(); logger.setLoggingEnabled(false); logger.setLogKeyEventsEnabled(true); ... |
DebugWebViewClientLogger implements LogControl { public void onUnhandledKeyEvent(final WebView view, final KeyEvent event) { if (loggingEnabled && logKeyEventsEnabled) { logger.logKeyEvent(String.format(LOCALE, "%s onUnhandledKeyEvent() %s", SPACE, event)); } } DebugWebViewClientLogger(); DebugWebViewClientLogger(@Non... | @Test public void onUnhandledKeyEvent() { final KeyEvent keyEvent = Mockito.mock(KeyEvent.class); logger.setLoggingEnabled(false); logger.setLogKeyEventsEnabled(false); logger.onUnhandledKeyEvent(webView, keyEvent); verifyLogNotCalled(); logger.setLoggingEnabled(false); logger.setLogKeyEventsEnabled(true); logger.onUnh... |
DebugWebViewClient extends WebViewClient implements LogControl { @Override public void onReceivedSslError(final WebView view, final SslErrorHandler handler, final SslError error) { logger.onReceivedSslError(view, handler, error); client.onReceivedSslError(view, handler, error); } DebugWebViewClient(); DebugWebViewClie... | @Test public void onReceivedSslError() { final SslErrorHandler errorHandler = Mockito.mock(SslErrorHandler.class); final SslError sslError = Mockito.mock(SslError.class); debugClient.onReceivedSslError(webView, errorHandler, sslError); verifyLogger().onReceivedSslError(webView, errorHandler, sslError); verifyWrappedCli... |
DebugWebViewClientLogger implements LogControl { public void onScaleChanged(final WebView view, final float oldScale, final float newScale) { if (loggingEnabled) { logger.log(String.format(LOCALE, "%s onScaleChanged() old: %s, new: %s", SPACE, oldScale, newScale)); } } DebugWebViewClientLogger(); DebugWebViewClientLog... | @Test public void onScaleChanged() { final float oldScale = 1.0f; final float newScale = 2.0f; logger.setLoggingEnabled(false); logger.onScaleChanged(webView, oldScale, newScale); verifyLogNotCalled(); logger.setLoggingEnabled(true); logger.onScaleChanged(webView, oldScale, newScale); verifyLogEngine().log(Mockito.anyS... |
DebugWebViewClientLogger implements LogControl { public void onReceivedLoginRequest(final WebView view, final String realm, final String account, final String args) { if (loggingEnabled) { logger.logSecurity(String.format(LOCALE, "%s onReceivedLoginRequest() %s, %s, %s", SPACE, realm, account, args)); } } DebugWebViewC... | @Test public void onReceivedLoginRequest() { final String realm = "realm"; final String account = "account"; final String args = "args"; logger.setLoggingEnabled(false); logger.onReceivedLoginRequest(webView, realm, account, args); verifyLogNotCalled(); logger.setLoggingEnabled(true); logger.onReceivedLoginRequest(webV... |
DebugWebViewClientLogger implements LogControl { @RequiresApi(api = Build.VERSION_CODES.O) public void onRenderProcessGone(final WebView view, final RenderProcessGoneDetail detail, boolean retVal) { if (loggingEnabled) { logger.log(String.format(LOCALE, "%s onRenderProcessGone() 1/2 DETAIL: %s", SPACE, detail)); logger... | @Test public void onRenderProcessGone() { final RenderProcessGoneDetail detail = Mockito.mock(RenderProcessGoneDetail.class); logger.setLoggingEnabled(false); logger.onRenderProcessGone(webView, detail, false); verifyLogNotCalled(); logger.setLoggingEnabled(true); logger.onRenderProcessGone(webView, detail, false); ver... |
DebugWebViewClientLogger implements LogControl { @RequiresApi(api = Build.VERSION_CODES.O_MR1) public void onSafeBrowsingHit(final WebView view, final WebResourceRequest request, final int threatType, final SafeBrowsingResponse callback) { if (loggingEnabled) { final Uri url = request.getUrl(); final String method = re... | @Test public void onSafeBrowsingHit() { final WebResourceRequest request = Mockito.mock(WebResourceRequest.class); final SafeBrowsingResponse callback = Mockito.mock(SafeBrowsingResponse.class); final int threatType = -1; logger.setLoggingEnabled(false); logger.onSafeBrowsingHit(webView, request, threatType, callback);... |
DebugWebViewClient extends WebViewClient implements LogControl { @RequiresApi(api = Build.VERSION_CODES.N) @Override public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) { final boolean retVal = client.shouldOverrideUrlLoading(view, request); logger.shouldOverrideUrlLoading(view, request, r... | @Test public void shouldOverrideUrlLoading() { final String url = "foo"; final boolean retVal = debugClient.shouldOverrideUrlLoading(webView, url); verifyLogger().shouldOverrideUrlLoading(webView, url, retVal); verifyWrappedClient().shouldOverrideUrlLoading(webView, url); }
@Test public void shouldOverrideUrlLoading1()... |
DebugWebViewClient extends WebViewClient implements LogControl { @Override public void onLoadResource(WebView view, String url) { logger.onLoadResource(view, url); client.onLoadResource(view, url); } DebugWebViewClient(); DebugWebViewClient(@NonNull final WebViewClient client); @SuppressWarnings("WeakerAccess") Debug... | @Test public void onLoadResource() { final String url = "foo"; debugClient.onLoadResource(webView, url); verifyLogger().onLoadResource(webView, url); verifyWrappedClient().onLoadResource(webView, url); } |
DebugWebViewClient extends WebViewClient implements LogControl { @TargetApi(Build.VERSION_CODES.M) @Override public void onPageCommitVisible(WebView view, String url) { logger.onPageCommitVisible(view, url); client.onPageCommitVisible(view, url); } DebugWebViewClient(); DebugWebViewClient(@NonNull final WebViewClient ... | @Test public void onPageCommitVisible() { final String url = "foo"; debugClient.onPageCommitVisible(webView, url); verifyLogger().onPageCommitVisible(webView, url); verifyWrappedClient().onPageCommitVisible(webView, url); } |
DebugWebViewClient extends WebViewClient implements LogControl { @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP) @Deprecated public WebResourceResponse shouldInterceptRequest(WebView view, String url) { final WebResourceResponse retVal = client.shouldInterceptRequest(view, url); logger.shouldInterceptRequest(view, url... | @Test public void shouldInterceptRequest() { final String url = "foo"; final WebResourceResponse retVal = debugClient.shouldInterceptRequest(webView, url); verifyLogger().shouldInterceptRequest(webView, url, retVal); verifyWrappedClient().shouldInterceptRequest(webView, url); }
@Test public void shouldInterceptRequest_... |
AbstractCloudConnector implements CloudConnector { @Override public List<ServiceInfo> getServiceInfos() { List<ServiceInfo> serviceInfos = new ArrayList<ServiceInfo>(); for (SD serviceData : getServicesData()) { serviceInfos.add(getServiceInfo(serviceData)); } return serviceInfos; } AbstractCloudConnector(Class<? exten... | @Test public void fallbacksCorrectly() { TestServiceData acceptableServiceData = new TestServiceData("my-service1", "test-tag"); TestServiceData unAcceptableServiceData = new TestServiceData("my-service2", "unknown-tag"); CloudConnector testCloudConnector = new TestCloudConnector(acceptableServiceData, unAcceptableServ... |
RelationalServiceInfo extends UriBasedServiceInfo { @ServiceProperty(category = "connection") public String getJdbcUrl() { return jdbcUrl == null ? buildJdbcUrl() : jdbcUrl; } RelationalServiceInfo(String id, String uriString, String jdbcUrlDatabaseType); RelationalServiceInfo(String id, String uriString, String jdbcU... | @Test public void jdbcUrlWithQueryNoUsernamePassword() { RelationalServiceInfo serviceInfo = createServiceInfo("dbtype: assertEquals("jdbc:jdbcdbtype: }
@Test public void jdbcUrl() { RelationalServiceInfo serviceInfo = createServiceInfoWithJdbcUrl("bad: "jdbc:jdbcdbtype: assertEquals("jdbc:jdbcdbtype: }
@Test public vo... |
Cloud { public Properties getCloudProperties() { Map<String, List<ServiceInfo>> mappedServiceInfos = new HashMap<>(); for (ServiceInfo serviceInfo : getServiceInfos()) { String key = getServiceLabel(serviceInfo); List<ServiceInfo> serviceInfosForLabel = mappedServiceInfos.computeIfAbsent(key, k -> new ArrayList<>()); s... | @Test public void appProps() { Map<String, Object> appProps = new HashMap<>(); appProps.put("foo", "bar"); appProps.put("users", null); StubCloudConnector stubCloudConnector = CloudTestUtil.getTestCloudConnector(new StubApplicationInstanceInfo("instance-id-1", "myapp", appProps)); Cloud testCloud = new Cloud(stubCloudC... |
Cloud { public <SC> SC getServiceConnector(String serviceId, Class<SC> serviceConnectorType, ServiceConnectorConfig serviceConnectorConfig) { ServiceInfo serviceInfo = getServiceInfo(serviceId); return getServiceConnector(serviceInfo, serviceConnectorType, serviceConnectorConfig); } Cloud(CloudConnector cloudConnector,... | @Test public void serviceConnectorCreationDefaultTypeAndConfig() { StubServiceInfo testServiceInfo = new StubServiceInfo("test-id", "test-host", 1000, "test-username", "test-password"); StubCloudConnector stubCloudConnector = CloudTestUtil.getTestCloudConnector(testServiceInfo); serviceConnectorCreators.add(new StubSer... |
Cloud { public <SC> SC getSingletonServiceConnector(Class<SC> serviceConnectorType, ServiceConnectorConfig serviceConnectorConfig) { List<ServiceInfo> matchingServiceInfos = getServiceInfos(serviceConnectorType); if (matchingServiceInfos.size() != 1) { throw new CloudException("No unique service matching " + serviceCon... | @Test public void getSingletonServiceConnectorSingleService() { StubServiceInfo testServiceInfo = new StubServiceInfo("test-id", "test-host", 1000, "test-username", "test-password"); StubCloudConnector stubCloudConnector = CloudTestUtil.getTestCloudConnector(testServiceInfo); serviceConnectorCreators.add(new StubServic... |
Cloud { public List<ServiceInfo> getServiceInfos() { return flatten(cloudConnector.getServiceInfos()); } Cloud(CloudConnector cloudConnector, List<ServiceConnectorCreator<?, ? extends ServiceInfo>> serviceConnectorCreators); ApplicationInstanceInfo getApplicationInstanceInfo(); ServiceInfo getServiceInfo(String service... | @Test public void serviceInfoNoServices() { StubCloudConnector stubCloudConnector = CloudTestUtil.getTestCloudConnector(); Cloud testCloud = new Cloud(stubCloudConnector, serviceConnectorCreators); assertEquals(0, testCloud.getServiceInfos().size()); assertEquals(0, testCloud.getServiceInfos(StubServiceInfo.class).size... |
CloudFactory { List<CloudConnector> getCloudConnectors() { return cloudConnectors; } CloudFactory(); Cloud getCloud(); void registerCloudConnector(CloudConnector cloudConnector); } | @Test public void cloudConnectorRegistration() { CloudFactory cloudFactory = new CloudFactory(); List<CloudConnector> registeredConnectors = cloudFactory.getCloudConnectors(); assertEquals("One connector registered", 1, registeredConnectors.size()); assertEquals("Registered connector is stub connector", StubCloudConnec... |
Cloud { public ServiceInfo getServiceInfo(String serviceId) { for (ServiceInfo serviceInfo : getServiceInfos()) { if (serviceInfo.getId().equals(serviceId)) { return serviceInfo; } } throw new CloudException("No service with id " + serviceId + " found"); } Cloud(CloudConnector cloudConnector, List<ServiceConnectorCreat... | @Test public void getServiceInfoByValidId() { StubServiceInfo testServiceInfo1 = new StubServiceInfo("test-id1", "test-host", 1000, "test-username", "test-password"); StubServiceInfo testServiceInfo2 = new StubServiceInfo("test-id2", "test-host", 1000, "test-username", "test-password"); StubCloudConnector stubCloudConn... |
Cloud { @SuppressWarnings("unchecked") public <T extends ServiceInfo> List<T> getServiceInfosByType(Class<T> serviceInfoType) { List<ServiceInfo> allServiceInfos = getServiceInfos(); List<T> matchingServiceInfos = new ArrayList<>(); for (ServiceInfo serviceInfo : allServiceInfos) { if (serviceInfoType.isAssignableFrom(... | @Test public void getServiceInfosByType() { StubServiceInfo testServiceInfo = new StubServiceInfo("test-id", "test-host", 1000, "test-username", "test-password"); TestServiceInfoTypeA testServiceInfoTypeA1 = new TestServiceInfoTypeA("test-id-a1"); TestServiceInfoTypeA testServiceInfoTypeA2 = new TestServiceInfoTypeA("t... |
Cloud { public <T extends ServiceInfo> T getSingletonServiceInfoByType(Class<T> serviceInfoType) { List<T> serviceInfos = getServiceInfosByType(serviceInfoType); if (serviceInfos.size() != 1) { throw new CloudException( "No unique service info " + serviceInfoType + " found. Expected 1, found " + serviceInfos.size()); }... | @Test(expected=CloudException.class) public void getSingletonServiceInfoByTypeNoService() { StubCloudConnector stubCloudConnector = CloudTestUtil.getTestCloudConnector(); Cloud testCloud = new Cloud(stubCloudConnector, serviceConnectorCreators); testCloud.getSingletonServiceInfoByType(StubServiceInfo.class); }
@Test(ex... |
CloudFactory { List<ServiceConnectorCreator<?, ? extends ServiceInfo>> getServiceCreators() { return serviceCreators; } CloudFactory(); Cloud getCloud(); void registerCloudConnector(CloudConnector cloudConnector); } | @Test public void cloudServiceConnectorCreatorRegistration() { CloudFactory cloudFactory = new CloudFactory(); List<ServiceConnectorCreator<?, ? extends ServiceInfo>> registeredServiceConnectorCreators = cloudFactory.getServiceCreators(); assertEquals("One serviceCreators registered", 2, registeredServiceConnectorCreat... |
LocalConfigUtil { static Map<String, String> readServices(Properties properties) { Map<String, String> services = new HashMap<String, String>(); for (String propertyName : properties.stringPropertyNames()) { if (LocalConfigConnector.META_PROPERTIES.contains(propertyName)) { logger.finer("skipping meta property " + prop... | @Test public void testPropertyParsing() { first.setProperty("spring.cloud.appId", "should skip me because I'm meta"); first.setProperty("spring.cloud.service1", "one"); first.setProperty("spring.cloud.", "should skip me because I don't have an ID"); first.setProperty("spring.cloud.service.two", "two"); first.setPropert... |
LocalConfigUtil { static List<UriBasedServiceData> readServicesData(LinkedHashMap<String, Properties> propertySources) { Map<String, String> collectedServices = new HashMap<String, String>(); for (Map.Entry<String, Properties> propertySource : propertySources.entrySet()) { if (propertySource.getValue().isEmpty()) { log... | @Test public void testCollation() { first.setProperty("spring.cloud.first", "firstUri"); second.setProperty("spring.cloud.second", "secondUri"); List<UriBasedServiceData> serviceData = LocalConfigUtil.readServicesData(propertySources); assertEquals(2, serviceData.size()); boolean foundFirst = false; for (UriBasedServic... |
LocalConfigConnector extends AbstractCloudConnector<UriBasedServiceData> { @Override public boolean isInMatchingCloud() { if (fileProperties == null) readFileProperties(); String appId = findProperty(APP_ID_PROPERTY); if (appId == null) logger.info("the property " + APP_ID_PROPERTY + " was not found in the system prope... | @Test public void testNoAppIdAnywhere() { assertFalse(connector.isInMatchingCloud()); } |
PropertiesFileResolver { File findCloudPropertiesFileFromSystem() { String filename = null; try { filename = env.getSystemProperty(LocalConfigConnector.PROPERTIES_FILE_PROPERTY); } catch (SecurityException e) { logger.log(Level.WARNING, "SecurityManager prevented reading system property " + LocalConfigConnector.PROPERT... | @Test public void testSecurityExceptionHandling() { env = mock(PassthroughEnvironmentAccessor.class); resolver = new PropertiesFileResolver(env); when(env.getSystemProperty(LocalConfigConnector.PROPERTIES_FILE_PROPERTY)).thenThrow(new SecurityException()); assertNull(resolver.findCloudPropertiesFileFromSystem()); verif... |
PropertiesFileResolver { File findCloudPropertiesFileFromClasspath() { InputStream in = getClass().getClassLoader().getResourceAsStream(classpathPropertiesFilename); if (in == null) { logger.info("no " + classpathPropertiesFilename + " found on the classpath to direct us to an external properties file"); return null; }... | @Test public void testNoClasspathFile() { resolver = new PropertiesFileResolver(env, "bazquux.properties"); assertNull(resolver.findCloudPropertiesFileFromClasspath()); }
@Test public void testClasspathFileWithoutKey() { resolver = new PropertiesFileResolver(env, "localconfig.testuris.properties"); assertNull(resolver.... |
CloudFactory { public Cloud getCloud() { CloudConnector suitableCloudConnector = null; for (CloudConnector cloudConnector : cloudConnectors) { if (cloudConnector.isInMatchingCloud()) { suitableCloudConnector = cloudConnector; break; } } if (suitableCloudConnector == null) { throw new CloudException("No suitable cloud c... | @Test public void cloudRetriveal() { CloudFactory cloudFactory = new CloudFactory(); Cloud cloud = cloudFactory.getCloud(); assertNotNull(cloud); } |
PropertiesFileResolver { File findCloudPropertiesFile() { File file = findCloudPropertiesFileFromSystem(); if (file != null) { logger.info("using configuration file from system properties"); return file; } file = findCloudPropertiesFileFromClasspath(); if (file != null) logger.info("using configuration file derived fro... | @Test public void testFromSystem() { env.setSystemProperty(LocalConfigConnector.PROPERTIES_FILE_PROPERTY, PROPERTIES_FILE_NAME); assertEquals(PROPERTIES_FILE_NAME, resolver.findCloudPropertiesFile().getPath()); }
@Test public void testFromClasspath() { resolver = new PropertiesFileResolver(env, "spring-cloud-template.p... |
CassandraClusterCreator extends AbstractServiceConnectorCreator<Cluster, CassandraServiceInfo> { @Override public Cluster create(CassandraServiceInfo serviceInfo, ServiceConnectorConfig serviceConnectorConfig) { Builder builder = Cluster.builder() .addContactPoints(serviceInfo.getContactPoints().toArray(new String[0]))... | @Test public void shouldCreateCluster() throws Exception { CassandraServiceInfo info = new CassandraServiceInfo("local", Collections.singletonList("127.0.0.1"), 9142); Cluster cluster = creator.create(info, null); Configuration configuration = cluster.getConfiguration(); assertThat(configuration.getProtocolOptions().ge... |
UrlDecodingDataSource extends DelegatingDataSource { @Override public Connection getConnection() throws SQLException { if (successfullyConnected) return super.getConnection(); synchronized (this) { Connection connection; try { connection = super.getConnection(); successfullyConnected = true; } catch (SQLException e) { ... | @Test public void whenConnectionToEncodedUrlIsSuccessful() throws SQLException { MockDataSource delegateDataSource = pooledDataSourceRequiringEncodedUrl(); UrlDecodingDataSource urlDecodingDataSource = new UrlDecodingDataSource(delegateDataSource, "url"); Connection connection = urlDecodingDataSource.getConnection(); a... |
CloudFoundryServiceInfoCreator implements ServiceInfoCreator<SI, Map<String, Object>> { @SuppressWarnings("unchecked") protected boolean tagsMatch(Map<String, Object> serviceData) { List<String> serviceTags = (List<String>) serviceData.get("tags"); return tags.containsOne(serviceTags); } CloudFoundryServiceInfoCreator(... | @Test public void tagsMatch() { DummyServiceInfoCreator serviceInfoCreator = new DummyServiceInfoCreator(new Tags("firstTag", "secondTag")); assertAcceptedWithTags(serviceInfoCreator, "firstTag", "noMatchTag"); assertAcceptedWithTags(serviceInfoCreator, "noMatchTag", "secondTag"); assertAcceptedWithTags(serviceInfoCrea... |
CloudFoundryServiceInfoCreator implements ServiceInfoCreator<SI, Map<String, Object>> { protected boolean uriKeyMatchesScheme(Map<String, Object> serviceData) { if (uriSchemes == null) { return false; } Map<String, Object> credentials = getCredentials(serviceData); if (credentials != null) { for (String uriScheme : uri... | @Test public void uriKeyMatchesScheme() { DummyServiceInfoCreator serviceInfoCreator = new DummyServiceInfoCreator(new Tags(), "amqp", "amqps"); assertAcceptedWithCredentials(serviceInfoCreator, "amqpUri", "https: assertAcceptedWithCredentials(serviceInfoCreator, "amqpsUri", "https: assertAcceptedWithCredentials(servic... |
Tags { public boolean containsOne(List<String> tags) { if (tags != null) { for (String value : values) { for (String tag : tags) { if (tag.equalsIgnoreCase(value)) { return true; } } } } return false; } Tags(String... values); String[] getTags(); boolean containsOne(List<String> tags); boolean contains(String tag); boo... | @Test public void containsOne() { Tags tags = new Tags("test1", "test2"); assertTrue(tags.containsOne(Arrays.asList("test1", "testx"))); assertTrue(tags.containsOne(Arrays.asList("testx", "test2"))); assertTrue(tags.containsOne(Arrays.asList("TESTX", "TEST2"))); assertFalse(tags.containsOne(Arrays.asList("testx", "test... |
Tags { public boolean contains(String tag) { if (tag != null) { for (String value : values) { if (tag.equalsIgnoreCase(value)) { return true; } } } return false; } Tags(String... values); String[] getTags(); boolean containsOne(List<String> tags); boolean contains(String tag); boolean startsWith(String tag); } | @Test public void contains() { Tags tags = new Tags("test1", "test2"); assertTrue(tags.contains("test1")); assertTrue(tags.contains("test2")); assertTrue(tags.contains("TEST2")); assertFalse(tags.contains("testx")); }
@Test public void containsWithEmptyTags() { assertFalse(EMPTY_TAGS.contains("test")); } |
Tags { public boolean startsWith(String tag) { if (tag != null) { for (String value : values) { if (startsWithIgnoreCase(tag, value)) { return true; } } } return false; } Tags(String... values); String[] getTags(); boolean containsOne(List<String> tags); boolean contains(String tag); boolean startsWith(String tag); } | @Test public void startsWith() { Tags tags = new Tags("test"); assertTrue(tags.startsWith("test-123")); assertTrue(tags.startsWith("TEST-123")); assertFalse(tags.startsWith("abcd")); }
@Test public void startsWithWithEmptyTags() { assertFalse(EMPTY_TAGS.startsWith("test")); } |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.