org.testng.collections.Maps Java Examples
The following examples show how to use
org.testng.collections.Maps.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MemberMetadataTest.java From kop with Apache License 2.0 | 6 votes |
@Test public void testMatchesSupportedProtocols() { Map<String, byte[]> protocols = Maps.newHashMap(); protocols.put("range", new byte[0]); MemberMetadata member = newMember(protocols); assertTrue(member.matches(protocols)); protocols = new HashMap<>(); protocols.put("range", new byte[] { 0 }); assertFalse(member.matches(protocols)); protocols = new HashMap<>(); protocols.put("roundrobin", new byte[0]); assertFalse(member.matches(protocols)); protocols = new HashMap<>(); protocols.put("range", new byte[0]); protocols.put("roundrobin", new byte[0]); assertFalse(member.matches(protocols)); }
Example #2
Source File: TestCompaction.java From pulsar with Apache License 2.0 | 6 votes |
private static Map<Integer, String> consumeCompactedTopic(PulsarClient client, String topic, String subscription, int numKeys) throws PulsarClientException { Map<Integer, String> keys = Maps.newHashMap(); try (Consumer<byte[]> consumer = client.newConsumer() .readCompacted(true) .topic(topic) .subscriptionName(subscription) .subscribe() ) { for (int i = 0; i < numKeys; i++) { Message<byte[]> m = consumer.receive(); keys.put(Integer.parseInt(m.getKey()), new String(m.getValue(), UTF_8)); } } return keys; }
Example #3
Source File: AdminApiSchemaValidationEnforced.java From pulsar with Apache License 2.0 | 6 votes |
@Test public void testEnableSchemaValidationEnforcedHasSchemaMatch() throws Exception { admin.namespaces().createNamespace("schema-validation-enforced/enable-has-schema-match"); String namespace = "schema-validation-enforced/enable-has-schema-match"; String topicName = "persistent://schema-validation-enforced/enable-has-schema-match/test"; assertFalse(admin.namespaces().getSchemaValidationEnforced(namespace)); try { admin.schemas().getSchemaInfo(topicName); } catch (PulsarAdminException.NotFoundException e) { assertTrue(e.getMessage().contains("HTTP 404 Not Found")); } admin.namespaces().setSchemaValidationEnforced(namespace,true); Map<String, String> properties = Maps.newHashMap(); SchemaInfo schemaInfo = new SchemaInfo(); schemaInfo.setType(SchemaType.STRING); schemaInfo.setProperties(properties); schemaInfo.setName("test"); schemaInfo.setSchema("".getBytes()); PostSchemaPayload postSchemaPayload = new PostSchemaPayload("STRING", "", properties); admin.schemas().createSchema(topicName, postSchemaPayload); try (Producer<String> p = pulsarClient.newProducer(Schema.STRING).topic(topicName).create()) { p.send("test schemaValidationEnforced"); } assertEquals(admin.schemas().getSchemaInfo(topicName).getName(), schemaInfo.getName()); assertEquals(admin.schemas().getSchemaInfo(topicName).getType(), schemaInfo.getType()); }
Example #4
Source File: AdminApiSchemaValidationEnforced.java From pulsar with Apache License 2.0 | 6 votes |
@Test public void testDisableSchemaValidationEnforcedHasSchema() throws Exception { admin.namespaces().createNamespace("schema-validation-enforced/default-has-schema"); String namespace = "schema-validation-enforced/default-has-schema"; String topicName = "persistent://schema-validation-enforced/default-has-schema/test"; assertFalse(admin.namespaces().getSchemaValidationEnforced(namespace)); admin.namespaces().setSchemaValidationEnforced(namespace, false); try { admin.schemas().getSchemaInfo(topicName); } catch (PulsarAdminException.NotFoundException e) { assertTrue(e.getMessage().contains("HTTP 404 Not Found")); } Map<String, String> properties = Maps.newHashMap(); SchemaInfo schemaInfo = new SchemaInfo(); schemaInfo.setType(SchemaType.STRING); schemaInfo.setProperties(properties); schemaInfo.setName("test"); schemaInfo.setSchema("".getBytes()); PostSchemaPayload postSchemaPayload = new PostSchemaPayload("STRING", "", properties); admin.schemas().createSchema(topicName, postSchemaPayload); try (Producer p = pulsarClient.newProducer().topic(topicName).create()) { p.send("test schemaValidationEnforced".getBytes()); } assertEquals(admin.schemas().getSchemaInfo(topicName), schemaInfo); }
Example #5
Source File: UtilsTest.java From pulsar with Apache License 2.0 | 6 votes |
private Record<byte[]> createRecord(byte[] data, String algo, String[] keyNames, byte[][] keyValues, byte[] param, Map<String, String> metadata1, Map<String, String> metadata2, int batchSize, int compressionMsgSize, Map<String, String> properties, boolean isEncryption) { EncryptionContext ctx = null; if(isEncryption) { ctx = new EncryptionContext(); ctx.setAlgorithm(algo); ctx.setBatchSize(Optional.of(batchSize)); ctx.setCompressionType(CompressionType.LZ4); ctx.setUncompressedMessageSize(compressionMsgSize); Map<String, EncryptionKey> keys = Maps.newHashMap(); EncryptionKey encKeyVal = new EncryptionKey(); encKeyVal.setKeyValue(keyValues[0]); encKeyVal.setMetadata(metadata1); EncryptionKey encKeyVal2 = new EncryptionKey(); encKeyVal2.setKeyValue(keyValues[1]); encKeyVal2.setMetadata(metadata2); keys.put(keyNames[0], encKeyVal); keys.put(keyNames[1], encKeyVal2); ctx.setKeys(keys); ctx.setParam(param); } return new RecordImpl(data, properties, Optional.ofNullable(ctx)); }
Example #6
Source File: KinesisSinkTest.java From pulsar with Apache License 2.0 | 6 votes |
@Test public void testDefaultCredentialProvider() throws Exception { KinesisSink sink = new KinesisSink(); Map<String, String> credentialParam = Maps.newHashMap(); String awsCredentialPluginParam = new Gson().toJson(credentialParam); try { sink.defaultCredentialProvider(awsCredentialPluginParam); Assert.fail("accessKey and SecretKey validation not applied"); } catch (IllegalArgumentException ie) { // Ok.. } final String accesKey = "ak"; final String secretKey = "sk"; credentialParam.put(KinesisSink.ACCESS_KEY_NAME, accesKey); credentialParam.put(KinesisSink.SECRET_KEY_NAME, secretKey); awsCredentialPluginParam = new Gson().toJson(credentialParam); AWSCredentialsProvider credentialProvider = sink.defaultCredentialProvider(awsCredentialPluginParam) .getCredentialProvider(); Assert.assertNotNull(credentialProvider); Assert.assertEquals(credentialProvider.getCredentials().getAWSAccessKeyId(), accesKey); Assert.assertEquals(credentialProvider.getCredentials().getAWSSecretKey(), secretKey); sink.close(); }
Example #7
Source File: PulsarSpoutTest.java From pulsar with Apache License 2.0 | 6 votes |
@Override protected void setup() throws Exception { super.internalSetup(); super.producerBaseSetup(); serviceUrl = pulsar.getWebServiceAddress(); pulsarSpoutConf = new PulsarSpoutConfiguration(); pulsarSpoutConf.setServiceUrl(serviceUrl); pulsarSpoutConf.setTopic(topic); pulsarSpoutConf.setSubscriptionName(subscriptionName); pulsarSpoutConf.setMessageToValuesMapper(messageToValuesMapper); pulsarSpoutConf.setFailedRetriesTimeout(1, TimeUnit.SECONDS); pulsarSpoutConf.setMaxFailedRetries(2); pulsarSpoutConf.setSharedConsumerEnabled(true); pulsarSpoutConf.setMetricsTimeIntervalInSecs(60); pulsarSpoutConf.setSubscriptionType(SubscriptionType.Shared); spout = new PulsarSpout(pulsarSpoutConf, PulsarClient.builder()); mockCollector = new MockSpoutOutputCollector(); SpoutOutputCollector collector = new SpoutOutputCollector(mockCollector); TopologyContext context = mock(TopologyContext.class); when(context.getThisComponentId()).thenReturn("test-spout-" + methodName); when(context.getThisTaskId()).thenReturn(0); spout.open(Maps.newHashMap(), context, collector); producer = pulsarClient.newProducer().topic(topic).create(); }
Example #8
Source File: PulsarSpoutTest.java From pulsar with Apache License 2.0 | 6 votes |
@Test public void testSharedConsumer() throws Exception { TopicStats topicStats = admin.topics().getStats(topic); assertEquals(topicStats.subscriptions.get(subscriptionName).consumers.size(), 1); PulsarSpout otherSpout = new PulsarSpout(pulsarSpoutConf, PulsarClient.builder()); MockSpoutOutputCollector otherMockCollector = new MockSpoutOutputCollector(); SpoutOutputCollector collector = new SpoutOutputCollector(otherMockCollector); TopologyContext context = mock(TopologyContext.class); when(context.getThisComponentId()).thenReturn("test-spout-" + methodName); when(context.getThisTaskId()).thenReturn(1); otherSpout.open(Maps.newHashMap(), context, collector); topicStats = admin.topics().getStats(topic); assertEquals(topicStats.subscriptions.get(subscriptionName).consumers.size(), 1); otherSpout.close(); topicStats = admin.topics().getStats(topic); assertEquals(topicStats.subscriptions.get(subscriptionName).consumers.size(), 1); }
Example #9
Source File: PulsarSpoutTest.java From pulsar with Apache License 2.0 | 6 votes |
@Test public void testNoSharedConsumer() throws Exception { TopicStats topicStats = admin.topics().getStats(topic); assertEquals(topicStats.subscriptions.get(subscriptionName).consumers.size(), 1); pulsarSpoutConf.setSharedConsumerEnabled(false); PulsarSpout otherSpout = new PulsarSpout(pulsarSpoutConf, PulsarClient.builder()); MockSpoutOutputCollector otherMockCollector = new MockSpoutOutputCollector(); SpoutOutputCollector collector = new SpoutOutputCollector(otherMockCollector); TopologyContext context = mock(TopologyContext.class); when(context.getThisComponentId()).thenReturn("test-spout-" + methodName); when(context.getThisTaskId()).thenReturn(1); otherSpout.open(Maps.newHashMap(), context, collector); topicStats = admin.topics().getStats(topic); assertEquals(topicStats.subscriptions.get(subscriptionName).consumers.size(), 2); otherSpout.close(); topicStats = admin.topics().getStats(topic); assertEquals(topicStats.subscriptions.get(subscriptionName).consumers.size(), 1); }
Example #10
Source File: PulsarSpoutTest.java From pulsar with Apache License 2.0 | 6 votes |
@Test public void testFailedConsumer() { PulsarSpoutConfiguration pulsarSpoutConf = new PulsarSpoutConfiguration(); pulsarSpoutConf.setServiceUrl(serviceUrl); pulsarSpoutConf.setTopic("persistent://invalidTopic"); pulsarSpoutConf.setSubscriptionName(subscriptionName); pulsarSpoutConf.setMessageToValuesMapper(messageToValuesMapper); pulsarSpoutConf.setFailedRetriesTimeout(1, TimeUnit.SECONDS); pulsarSpoutConf.setMaxFailedRetries(2); pulsarSpoutConf.setSharedConsumerEnabled(false); pulsarSpoutConf.setMetricsTimeIntervalInSecs(60); pulsarSpoutConf.setSubscriptionType(SubscriptionType.Shared); PulsarSpout spout = new PulsarSpout(pulsarSpoutConf, PulsarClient.builder()); MockSpoutOutputCollector mockCollector = new MockSpoutOutputCollector(); SpoutOutputCollector collector = new SpoutOutputCollector(mockCollector); TopologyContext context = mock(TopologyContext.class); when(context.getThisComponentId()).thenReturn("new-test" + methodName); when(context.getThisTaskId()).thenReturn(0); try { spout.open(Maps.newHashMap(), context, collector); fail("should have failed as consumer creation failed"); } catch (IllegalStateException e) { // Ok } }
Example #11
Source File: PulsarBoltTest.java From pulsar with Apache License 2.0 | 6 votes |
@Test public void testSharedProducer() throws Exception { TopicStats topicStats = admin.topics().getStats(topic); Assert.assertEquals(topicStats.publishers.size(), 1); PulsarBolt otherBolt = new PulsarBolt(pulsarBoltConf, PulsarClient.builder()); MockOutputCollector otherMockCollector = new MockOutputCollector(); OutputCollector collector = new OutputCollector(otherMockCollector); TopologyContext context = mock(TopologyContext.class); when(context.getThisComponentId()).thenReturn("test-bolt-" + methodName); when(context.getThisTaskId()).thenReturn(1); otherBolt.prepare(Maps.newHashMap(), context, collector); topicStats = admin.topics().getStats(topic); Assert.assertEquals(topicStats.publishers.size(), 1); otherBolt.close(); topicStats = admin.topics().getStats(topic); Assert.assertEquals(topicStats.publishers.size(), 1); }
Example #12
Source File: PulsarBoltTest.java From pulsar with Apache License 2.0 | 6 votes |
@Test public void testFailedProducer() { PulsarBoltConfiguration pulsarBoltConf = new PulsarBoltConfiguration(); pulsarBoltConf.setServiceUrl(serviceUrl); pulsarBoltConf.setTopic("persistent://invalid"); pulsarBoltConf.setTupleToMessageMapper(tupleToMessageMapper); pulsarBoltConf.setMetricsTimeIntervalInSecs(60); PulsarBolt bolt = new PulsarBolt(pulsarBoltConf, PulsarClient.builder()); MockOutputCollector mockCollector = new MockOutputCollector(); OutputCollector collector = new OutputCollector(mockCollector); TopologyContext context = mock(TopologyContext.class); when(context.getThisComponentId()).thenReturn("new" + methodName); when(context.getThisTaskId()).thenReturn(0); try { bolt.prepare(Maps.newHashMap(), context, collector); fail("should have failed as producer creation failed"); } catch (IllegalStateException ie) { // Ok. } }
Example #13
Source File: PulsarBoltTest.java From pulsar with Apache License 2.0 | 6 votes |
@Override protected void setup() throws Exception { super.internalSetup(); super.producerBaseSetup(); serviceUrl = pulsar.getWebServiceAddress(); pulsarBoltConf = new PulsarBoltConfiguration(); pulsarBoltConf.setServiceUrl(serviceUrl); pulsarBoltConf.setTopic(topic); pulsarBoltConf.setTupleToMessageMapper(tupleToMessageMapper); pulsarBoltConf.setMetricsTimeIntervalInSecs(60); bolt = new PulsarBolt(pulsarBoltConf, PulsarClient.builder()); mockCollector = new MockOutputCollector(); OutputCollector collector = new OutputCollector(mockCollector); TopologyContext context = mock(TopologyContext.class); when(context.getThisComponentId()).thenReturn("test-bolt-" + methodName); when(context.getThisTaskId()).thenReturn(0); bolt.prepare(Maps.newHashMap(), context, collector); consumer = pulsarClient.newConsumer().topic(topic).subscriptionName(subscriptionName).subscribe(); }
Example #14
Source File: TestRunner.java From qaf with MIT License | 6 votes |
private List<List<IMethodInstance>> createInstances(List<IMethodInstance> methodInstances) { Map<Object, List<IMethodInstance>> map = Maps.newHashMap(); // MapList<IMethodInstance[], Object> map = new MapList<IMethodInstance[], Object>(); for (IMethodInstance imi : methodInstances) { for (Object o : imi.getInstances()) { System.out.println(o); List<IMethodInstance> l = map.get(o); if (l == null) { l = Lists.newArrayList(); map.put(o, l); } l.add(imi); } // for (Object instance : imi.getInstances()) { // map.put(imi, instance); // } } // return map.getKeys(); // System.out.println(map); return new ArrayList<List<IMethodInstance>>(map.values()); }
Example #15
Source File: SolrIndexerTest.java From q with Apache License 2.0 | 6 votes |
@Test void createDocTest() { BaseIndexer indexer = new SolrIndexer("", TEST1); List<String> languages = Lists.newArrayList(); languages.add(LOCALE); Map<String, Object> createdDoc = indexer.createDoc(ID, ENGLISH_TITLE, SPANISH_TITLE, ALT_TITLE, languages); Map<String, Object> expectedDoc = Maps.newHashMap(); expectedDoc.put(Properties.idField.get(), ID + "_" + TEST1); expectedDoc.put(Properties.titleFields.get().get(0) + "_en", ENGLISH_TITLE); Set<Object> localizedTitles = Sets.newHashSet(); localizedTitles.add(SPANISH_TITLE); expectedDoc.put(Properties.titleFields.get().get(0) + "_es", localizedTitles); expectedDoc.put(Properties.docTypeFieldName.get(), TEST1); Assert.assertEquals(createdDoc, expectedDoc); StringBuilder jsonStringOfDoc = indexer.getJsonStringOfDoc(new ObjectMapper().valueToTree(createdDoc)); Assert.assertEquals(jsonStringOfDoc.toString(), "[{\"query_testing_type\":\"test1\",\"title_en\":\"title en\",\"id\":\"123_test1\",\"title_es\":[\"title es\"]}]"); String urlForAddingDoc = indexer.getUrlForAddingDoc(createdDoc); Assert.assertEquals(urlForAddingDoc, "http://localhost:8983/solr/qtest/update"); String urlForCommitting = indexer.getUrlForCommitting(); Assert.assertEquals(urlForCommitting, "http://localhost:8983/solr/qtest/update?commit=true"); }
Example #16
Source File: ProxyWithAuthorizationTest.java From pulsar with Apache License 2.0 | 5 votes |
protected final void createAdminClient() throws Exception { Map<String, String> authParams = Maps.newHashMap(); authParams.put("tlsCertFile", TLS_SUPERUSER_CLIENT_CERT_FILE_PATH); authParams.put("tlsKeyFile", TLS_SUPERUSER_CLIENT_KEY_FILE_PATH); admin = spy(PulsarAdmin.builder().serviceHttpUrl(brokerUrlTls.toString()) .tlsTrustCertsFilePath(TLS_PROXY_TRUST_CERT_FILE_PATH).allowTlsInsecureConnection(true) .authentication(AuthenticationTls.class.getName(), authParams).build()); }
Example #17
Source File: ProxyWithAuthorizationTest.java From pulsar with Apache License 2.0 | 5 votes |
@SuppressWarnings("deprecation") private PulsarClient createPulsarClient(String proxyServiceUrl, ClientBuilder clientBuilder) throws PulsarClientException { Map<String, String> authParams = Maps.newHashMap(); authParams.put("tlsCertFile", TLS_CLIENT_CERT_FILE_PATH); authParams.put("tlsKeyFile", TLS_CLIENT_KEY_FILE_PATH); Authentication authTls = new AuthenticationTls(); authTls.configure(authParams); return clientBuilder.serviceUrl(proxyServiceUrl).statsInterval(0, TimeUnit.SECONDS) .tlsTrustCertsFilePath(TLS_PROXY_TRUST_CERT_FILE_PATH).allowTlsInsecureConnection(true) .authentication(authTls).enableTls(true) .operationTimeout(1000, TimeUnit.MILLISECONDS).build(); }
Example #18
Source File: UtilTest.java From proxy with MIT License | 5 votes |
@Test public void defaultToEmptyCollectionsOnNullValueTest() throws Throwable { assertTrue(Util.defaultToEmptyCollectionsOnNullValue(List.class, null).isEmpty()); assertTrue(Util.defaultToEmptyCollectionsOnNullValue(List.class, Lists.newArrayList("1")).contains("1")); Set<Object> set = Sets.newHashSet(); set.add(1); assertTrue(Util.defaultToEmptyCollectionsOnNullValue(Set.class, set).contains(1)); assertTrue(Util.defaultToEmptyCollectionsOnNullValue(Set.class, null).isEmpty()); Map<Object, Object> map = Maps.newHashMap(); map.put(1, 2); assertTrue(Util.defaultToEmptyCollectionsOnNullValue(Map.class, map).containsKey(1)); assertTrue(Util.defaultToEmptyCollectionsOnNullValue(Map.class, map).containsValue(2)); assertTrue(Util.defaultToEmptyCollectionsOnNullValue(Map.class, null).isEmpty()); Object[] arr = set.toArray(new Object[set.size()]); assertTrue(Util.defaultToEmptyCollectionsOnNullValue(Object[].class, null).length == 0); assertTrue(Util.defaultToEmptyCollectionsOnNullValue(Object[].class, arr).length == 1); Properties prop = new Properties(); prop.put("1", "2"); assertTrue(Util.defaultToEmptyCollectionsOnNullValue(Properties.class, prop).containsKey("1")); assertTrue(Util.defaultToEmptyCollectionsOnNullValue(Properties.class, prop).containsValue("2")); assertTrue(Util.defaultToEmptyCollectionsOnNullValue(Properties.class, null).isEmpty()); assertTrue(Util.defaultToEmptyCollectionsOnNullValue(Collection.class, null).isEmpty()); assertTrue(Util.defaultToEmptyCollectionsOnNullValue(Collection.class, set).contains(1)); assertTrue(Util.defaultToEmptyCollectionsOnNullValue(String.class, null) == null); assertTrue(Util.defaultToEmptyCollectionsOnNullValue(String.class, "123").contentEquals("123")); }
Example #19
Source File: PulsarFunctionsTest.java From pulsar with Apache License 2.0 | 5 votes |
protected Map<String, String> produceSchemaInsertMessagesToInputTopic(String inputTopicName, int numMessages, Schema<Foo> schema) throws Exception { @Cleanup PulsarClient client = PulsarClient.builder() .serviceUrl(pulsarCluster.getPlainTextServiceUrl()) .build(); @Cleanup Producer<Foo> producer = client.newProducer(schema) .topic(inputTopicName) .create(); LinkedHashMap<String, String> kvs = new LinkedHashMap<>(); for (int i = 0; i < numMessages; i++) { String key = "key-" + i; JdbcPostgresSinkTester.Foo obj = new JdbcPostgresSinkTester.Foo(); obj.setField1("field1_insert_" + i); obj.setField2("field2_insert_" + i); obj.setField3(i); String value = new String(schema.encode(obj)); Map<String, String> properties = Maps.newHashMap(); properties.put("ACTION", "INSERT"); kvs.put(key, value); kvs.put("ACTION", "INSERT"); producer.newMessage() .properties(properties) .key(key) .value(obj) .send(); } return kvs; }
Example #20
Source File: UmaGetClaimsGatheringUrlTest.java From oxd with Apache License 2.0 | 5 votes |
@Parameters({"opHost", "redirectUrls", "rsProtect", "paramRedirectUrl"}) @Test public void test_withCustomParameter(String opHost, String redirectUrls, String rsProtect, String paramRedirectUrl) throws Exception { final DevelopersApi client = Tester.api(); final RegisterSiteResponse site = RegisterSiteTest.registerSite(client, opHost, redirectUrls); RsProtectTest.protectResources(client, site, UmaFullTest.resourceList(rsProtect)); final UmaRsCheckAccessResponse checkAccess = RsCheckAccessTest.checkAccess(client, site, null); final UmaRpGetClaimsGatheringUrlParams params = new UmaRpGetClaimsGatheringUrlParams(); params.setOxdId(site.getOxdId()); params.setTicket(checkAccess.getTicket()); params.setClaimsRedirectUri(paramRedirectUrl); Map<String, String> customParameterMap = Maps.newHashMap(); customParameterMap.put("param1", "value1"); customParameterMap.put("param2", "value2"); params.setCustomParameters(customParameterMap); final UmaRpGetClaimsGatheringUrlResponse response = client.umaRpGetClaimsGatheringUrl(params, Tester.getAuthorization(site), null); final Map<String, String> parameters = CoreUtils.splitQuery(response.getUrl()); assertTrue(isNotBlank(parameters.get("client_id"))); assertTrue(isNotBlank(parameters.get("ticket"))); assertTrue(isNotBlank(parameters.get("state"))); assertTrue(isNotBlank(parameters.get("param1"))); assertTrue(isNotBlank(parameters.get("param2"))); assertTrue(isNotBlank(response.getState())); assertEquals(paramRedirectUrl, parameters.get("claims_redirect_uri")); }
Example #21
Source File: UmaGetClaimsGatheringUrlTest.java From oxd with Apache License 2.0 | 5 votes |
@Parameters({"host", "opHost", "paramRedirectUrl", "rsProtect"}) @Test public void test_withCustomParameter(String host, String opHost, String paramRedirectUrl, String rsProtect) throws IOException { ClientInterface client = Tester.newClient(host); RegisterSiteResponse site = RegisterSiteTest.registerSite(client, opHost, paramRedirectUrl); RsProtectTest.protectResources(client, site, UmaFullTest.resourceList(rsProtect).getResources()); final RsCheckAccessResponse checkAccess = RsCheckAccessTest.checkAccess(client, site, null); final RpGetClaimsGatheringUrlParams params = new RpGetClaimsGatheringUrlParams(); params.setOxdId(site.getOxdId()); params.setTicket(checkAccess.getTicket()); params.setClaimsRedirectUri(paramRedirectUrl); Map<String, String> customParameterMap = Maps.newHashMap(); customParameterMap.put("param1", "value1"); customParameterMap.put("param2", "value2"); params.setCustomParameters(customParameterMap); final RpGetClaimsGatheringUrlResponse response = client.umaRpGetClaimsGatheringUrl(Tester.getAuthorization(site), null, params); Map<String, String> parameters = CoreUtils.splitQuery(response.getUrl()); assertTrue(StringUtils.isNotBlank(parameters.get("client_id"))); assertTrue(StringUtils.isNotBlank(parameters.get("ticket"))); assertTrue(StringUtils.isNotBlank(parameters.get("state"))); assertTrue(StringUtils.isNotBlank(response.getState())); assertTrue(StringUtils.isNotBlank(parameters.get("param1"))); assertTrue(StringUtils.isNotBlank(parameters.get("param2"))); assertEquals(paramRedirectUrl, parameters.get("claims_redirect_uri")); }
Example #22
Source File: PulsarFunctionsTest.java From pulsar with Apache License 2.0 | 5 votes |
protected Map<String, String> produceSchemaUpdateMessagesToInputTopic(String inputTopicName, int numMessages, Schema<Foo> schema) throws Exception { @Cleanup PulsarClient client = PulsarClient.builder() .serviceUrl(pulsarCluster.getPlainTextServiceUrl()) .build(); @Cleanup Producer<Foo> producer = client.newProducer(schema) .topic(inputTopicName) .create(); LinkedHashMap<String, String> kvs = new LinkedHashMap<>(); log.info("update start"); for (int i = 0; i < numMessages; i++) { String key = "key-" + i; JdbcPostgresSinkTester.Foo obj = new JdbcPostgresSinkTester.Foo(); obj.setField1("field1_insert_" + i); obj.setField2("field2_update_" + i); obj.setField3(i); String value = new String(schema.encode(obj)); Map<String, String> properties = Maps.newHashMap(); properties.put("ACTION", "UPDATE"); kvs.put(key, value); kvs.put("ACTION", "UPDATE"); producer.newMessage() .properties(properties) .key(key) .value(obj) .send(); } log.info("update end"); return kvs; }
Example #23
Source File: PulsarFunctionsTest.java From pulsar with Apache License 2.0 | 5 votes |
protected Map<String, String> produceSchemaDeleteMessagesToInputTopic(String inputTopicName, int numMessages, Schema<Foo> schema) throws Exception { @Cleanup PulsarClient client = PulsarClient.builder() .serviceUrl(pulsarCluster.getPlainTextServiceUrl()) .build(); @Cleanup Producer<Foo> producer = client.newProducer(schema) .topic(inputTopicName) .create(); LinkedHashMap<String, String> kvs = new LinkedHashMap<>(); for (int i = 0; i < numMessages; i++) { String key = "key-" + i; JdbcPostgresSinkTester.Foo obj = new JdbcPostgresSinkTester.Foo(); obj.setField1("field1_insert_" + i); obj.setField2("field2_update_" + i); obj.setField3(i); String value = new String(schema.encode(obj)); Map<String, String> properties = Maps.newHashMap(); properties.put("ACTION", "DELETE"); kvs.put(key, value); kvs.put("ACTION", "DELETE"); producer.newMessage() .properties(properties) .key(key) .value(obj) .send(); } return kvs; }
Example #24
Source File: SinkTester.java From pulsar with Apache License 2.0 | 5 votes |
public SinkTester(String networkAlias, SinkType sinkType) { this.networkAlias = networkAlias; this.sinkType = sinkType; this.sinkArchive = null; this.sinkClassName = null; this.sinkConfig = Maps.newHashMap(); }
Example #25
Source File: IntegrationJobTagSuite.java From incubator-gobblin with Apache License 2.0 | 5 votes |
/** * Create different jobs with different tags */ @Override protected Map<String, Config> overrideJobConfigs(Config rawJobConfig) { Map<String, Config> jobConfigs = Maps.newHashMap(); for(Map.Entry<String, String> assoc: JOB_TAG_ASSOCIATION.entrySet()) { Config newConfig = getConfigOverride(rawJobConfig, assoc.getKey(), assoc.getValue()); jobConfigs.put(assoc.getKey(), newConfig); } return jobConfigs; }
Example #26
Source File: SinkTester.java From pulsar with Apache License 2.0 | 5 votes |
public SinkTester(String networkAlias, String sinkArchive, String sinkClassName) { this.networkAlias = networkAlias; this.sinkType = SinkType.UNDEFINED; this.sinkArchive = sinkArchive; this.sinkClassName = sinkClassName; this.sinkConfig = Maps.newHashMap(); }
Example #27
Source File: HiveConverterUtilsTest.java From incubator-gobblin with Apache License 2.0 | 5 votes |
@Test public void copyTableQueryTest() throws Exception { Map<String, String> partitionsDMLInfo = Maps.newHashMap(); String partitionName = "datepartition"; String partitionValue = "2017-07-15-08"; partitionsDMLInfo.put(partitionName, partitionValue); String expectedQuery = "INSERT OVERWRITE TABLE `" + outputDatabaseName + "`.`" + outputTableName + "` \n" + "PARTITION (`" + partitionName + "`) \n" + "SELECT * FROM `" + inputDbName + "`.`" + inputTableName + "` WHERE " + "`" + partitionName + "`='" + partitionsDMLInfo.get(partitionName) + "'"; String actualQuery = HiveConverterUtils.generateTableCopy(inputTableName, outputTableName, inputDbName, outputDatabaseName, Optional.of(partitionsDMLInfo)); Assert.assertEquals(expectedQuery, actualQuery); }
Example #28
Source File: ProxyWithAuthorizationNegTest.java From pulsar with Apache License 2.0 | 5 votes |
protected final void createAdminClient() throws Exception { Map<String, String> authParams = Maps.newHashMap(); authParams.put("tlsCertFile", TLS_SUPERUSER_CLIENT_CERT_FILE_PATH); authParams.put("tlsKeyFile", TLS_SUPERUSER_CLIENT_KEY_FILE_PATH); admin = spy(PulsarAdmin.builder().serviceHttpUrl(brokerUrlTls.toString()) .tlsTrustCertsFilePath(TLS_BROKER_TRUST_CERT_FILE_PATH).allowTlsInsecureConnection(true) .authentication(AuthenticationTls.class.getName(), authParams).build()); }
Example #29
Source File: ElasticsearchIndexerTest.java From q with Apache License 2.0 | 5 votes |
@Test void createDocTest() { BaseIndexer indexer = new ElasticsearchIndexer("", TEST1); List<String> languages = Lists.newArrayList(); languages.add(LOCALE); Map<String, Object> createdDoc = indexer.createDoc(ID, ENGLISH_TITLE, SPANISH_TITLE, ALT_TITLE, languages); Map<String, Object> expectedDoc = Maps.newHashMap(); expectedDoc.put(Properties.idField.get(), ID + "_" + TEST1); expectedDoc.put(Properties.titleFields.get().get(0) + "_en", ENGLISH_TITLE); Set<Object> localizedTitles = Sets.newHashSet(); localizedTitles.add(SPANISH_TITLE); expectedDoc.put(Properties.titleFields.get().get(0) + "_es", localizedTitles); expectedDoc.put(Properties.docTypeFieldName.get(), TEST1); Assert.assertEquals(createdDoc, expectedDoc); StringBuilder jsonStringOfDoc = indexer.getJsonStringOfDoc(new ObjectMapper().valueToTree(createdDoc)); Assert.assertEquals(jsonStringOfDoc.toString(), "{\"query_testing_type\":\"test1\",\"title_en\":\"title en\",\"id\":\"123_test1\",\"title_es\":[\"title es\"]}"); String urlForAddingDoc = indexer.getUrlForAddingDoc(createdDoc); Assert.assertEquals(urlForAddingDoc, "http://localhost:8983/solr/qtest/test_doc/123_test1"); String urlForCommitting = indexer.getUrlForCommitting(); Assert.assertEquals(urlForCommitting, "http://localhost:8983/solr/qtest/_flush"); }
Example #30
Source File: QueriesTest.java From q with Apache License 2.0 | 5 votes |
@Test void createDocTest() { GoogleDataExtractor titleExtractor = Mockito.mock(GoogleDataExtractor.class); Map<String, Map<Integer, TitleWithQueries>> mapOfQueriesToTitles = Maps.newHashMap(); Map<Integer, TitleWithQueries> titlesWithQueries = Maps.newHashMap(); TitleWithQueries titleWithQueries = new TitleWithQueries(DATASET_ID); titleWithQueries.setValue(TitleWithQueries.ID, ID1); titleWithQueries.setValue(TitleWithQueries.TITLE_EN, ENGLISH_TITLE); titleWithQueries.setValue(TitleWithQueries.TITLE_LOCALE, SPANISH_TITLE); titleWithQueries.setValue(TitleWithQueries.Q_ + "regular", Q1); titlesWithQueries.put(1, titleWithQueries); TitleWithQueries titleWithQueries2 = new TitleWithQueries(DATASET_ID); titleWithQueries2.setValue(TitleWithQueries.ID, ID2); titleWithQueries2.setValue(TitleWithQueries.TITLE_EN, ENGLISH_TITLE); titleWithQueries2.setValue(TitleWithQueries.TITLE_LOCALE, SPANISH_TITLE); titleWithQueries2.setValue(TitleWithQueries.Q_ + "regular", Q1); titlesWithQueries.put(2, titleWithQueries2); mapOfQueriesToTitles.put(DATASET_ID, titlesWithQueries); Mockito.when(titleExtractor.getTitlesWithQueriesPerDataset()).thenReturn(mapOfQueriesToTitles); Queries queries = new Queries(DATASET_ID, TEST1, titleExtractor); queries.populateFromGoogleSpreadsheets(); Map<String, Set<String>> queryToIdMap = queries.getQueryToIdMap(); Map<String, Set<String>> expectedQueryToIdMap = Maps.newHashMap(); Set<String> titles = Sets.newHashSet(); titles.add(ID1+"_"+DATASET_ID); titles.add(ID2+"_"+DATASET_ID); expectedQueryToIdMap.put(Q1, titles); Assert.assertEquals(queryToIdMap, expectedQueryToIdMap); }