scala.actors.threadpool.Arrays Java Examples
The following examples show how to use
scala.actors.threadpool.Arrays.
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: ThrottleConditionEvaluatorTest.java From carbon-apimgt with Apache License 2.0 | 6 votes |
@Test public void testGetThrottledInConditionWithComplexCondition2() { ThrottleProperties throttleProperties = new ThrottleProperties(); throttleProperties.setEnableHeaderConditions(true); ServiceReferenceHolder.getInstance().setThrottleProperties(throttleProperties); MessageContext messageContext = TestUtils.getMessageContext(apiContext, apiVersion); Map map = new TreeMap(); map.put("abc", "cde"); map.put("bcd", "xyz"); map.put("X-Forwarded-For", "127.0.0.2"); ((Axis2MessageContext) messageContext).getAxis2MessageContext() .setProperty(org.apache.axis2.context.MessageContext.TRANSPORT_HEADERS, map); Map<String, List<ConditionDto>> conditionMap = new HashMap<>(); conditionMap.put("condition1", Arrays.asList(new ConditionDto[]{getHeaderCondition(false)})); conditionMap.put("default", Arrays.asList(new ConditionDto[]{getIPCondition(false), getHeaderCondition(false) })); String condition = throttleConditionEvaluator.getThrottledInCondition(messageContext, null, conditionMap); Assert.assertEquals(condition, "condition1"); }
Example #2
Source File: ThrottleConditionEvaluatorTest.java From carbon-apimgt with Apache License 2.0 | 6 votes |
@Test public void testGetThrottledInConditionWithHeaderCondition() { ThrottleProperties throttleProperties = new ThrottleProperties(); throttleProperties.setEnableHeaderConditions(true); ServiceReferenceHolder.getInstance().setThrottleProperties(throttleProperties); MessageContext messageContext = TestUtils.getMessageContext(apiContext, apiVersion); Map map = new TreeMap(); map.put("abc", "cde"); map.put("bcd", "xyz"); ((Axis2MessageContext) messageContext).getAxis2MessageContext() .setProperty(org.apache.axis2.context.MessageContext.TRANSPORT_HEADERS, map); Map<String, List<ConditionDto>> conditionMap = new HashMap<>(); conditionMap.put("condition1", Arrays.asList(new ConditionDto[]{getHeaderCondition(false)})); conditionMap.put("default", Arrays.asList(new ConditionDto[]{getHeaderCondition(false)})); String condition = throttleConditionEvaluator.getThrottledInCondition(messageContext, null, conditionMap); Assert.assertEquals(condition, "condition1"); }
Example #3
Source File: ThrottleConditionEvaluatorTest.java From carbon-apimgt with Apache License 2.0 | 6 votes |
@Test public void testGetThrottledInConditionWithHeaderConditionNegative() { ThrottleProperties throttleProperties = new ThrottleProperties(); throttleProperties.setEnableHeaderConditions(true); ServiceReferenceHolder.getInstance().setThrottleProperties(throttleProperties); MessageContext messageContext = TestUtils.getMessageContext(apiContext, apiVersion); Map map = new TreeMap(); map.put("abc", "cd1"); map.put("bcd", "xyz"); ((Axis2MessageContext) messageContext).getAxis2MessageContext() .setProperty(org.apache.axis2.context.MessageContext.TRANSPORT_HEADERS, map); Map<String, List<ConditionDto>> conditionMap = new HashMap<>(); conditionMap.put("condition1", Arrays.asList(new ConditionDto[]{getHeaderCondition(false)})); conditionMap.put("default", Arrays.asList(new ConditionDto[]{getHeaderCondition(false)})); String condition = throttleConditionEvaluator.getThrottledInCondition(messageContext, null, conditionMap); Assert.assertEquals(condition, "default"); }
Example #4
Source File: ThrottleConditionEvaluatorTest.java From carbon-apimgt with Apache License 2.0 | 6 votes |
@Test public void testGetThrottledInConditionWithHeaderConditionInvert() { ThrottleProperties throttleProperties = new ThrottleProperties(); throttleProperties.setEnableHeaderConditions(true); ServiceReferenceHolder.getInstance().setThrottleProperties(throttleProperties); MessageContext messageContext = TestUtils.getMessageContext(apiContext, apiVersion); Map map = new TreeMap(); map.put("abc", "cde"); map.put("bcd", "xyz"); ((Axis2MessageContext) messageContext).getAxis2MessageContext() .setProperty(org.apache.axis2.context.MessageContext.TRANSPORT_HEADERS, map); Map<String, List<ConditionDto>> conditionMap = new HashMap<>(); conditionMap.put("condition1", Arrays.asList(new ConditionDto[]{getHeaderCondition(true)})); conditionMap.put("default", Arrays.asList(new ConditionDto[]{getHeaderCondition(true)})); String condition = throttleConditionEvaluator.getThrottledInCondition(messageContext, null, conditionMap); Assert.assertEquals(condition, "default"); }
Example #5
Source File: ThrottleConditionEvaluatorTest.java From carbon-apimgt with Apache License 2.0 | 6 votes |
@Test public void testGetThrottledInConditionWithHeaderConditionNegativeInvert() { ThrottleProperties throttleProperties = new ThrottleProperties(); throttleProperties.setEnableHeaderConditions(true); ServiceReferenceHolder.getInstance().setThrottleProperties(throttleProperties); MessageContext messageContext = TestUtils.getMessageContext(apiContext, apiVersion); Map map = new TreeMap(); map.put("abc", "cd1"); map.put("bcd", "xyz"); ((Axis2MessageContext) messageContext).getAxis2MessageContext() .setProperty(org.apache.axis2.context.MessageContext.TRANSPORT_HEADERS, map); Map<String, List<ConditionDto>> conditionMap = new HashMap<>(); conditionMap.put("condition1", Arrays.asList(new ConditionDto[]{getHeaderCondition(true)})); conditionMap.put("default", Arrays.asList(new ConditionDto[]{getHeaderCondition(true)})); String condition = throttleConditionEvaluator.getThrottledInCondition(messageContext, null, conditionMap); Assert.assertEquals(condition, "condition1"); }
Example #6
Source File: ThrottleConditionEvaluatorTest.java From carbon-apimgt with Apache License 2.0 | 6 votes |
@Test public void testGetThrottledInConditionWithJWTCondition() { ThrottleProperties throttleProperties = new ThrottleProperties(); throttleProperties.setEnableJwtConditions(true); String jwt = "eyJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJ3c28yLm9yZy9wcm9kdWN0cy9hbSIsImV4cCI6MTM0NTE4MzQ5MjE4MSwiaHR0cDov" + "L3dzbzIub3JnL2NsYWltcy9hYmMiOiJjZGUiLCJodHRwOi8vd3NvMi5vcmcvY2xhaW1zL2JjZCI6Inh5eiJ9.9zGU062DJ5mQ5hne" + "41h4IRpLbaY_b5thRxb3feebOcA"; AuthenticationContext authenticationContext = new AuthenticationContext(); authenticationContext.setCallerToken(jwt); ServiceReferenceHolder.getInstance().setThrottleProperties(throttleProperties); MessageContext messageContext = TestUtils.getMessageContext(apiContext, apiVersion); Map<String, List<ConditionDto>> conditionMap = new HashMap<>(); conditionMap.put("condition1", Arrays.asList(new ConditionDto[]{getJWTCondition(false)})); conditionMap.put("default", Arrays.asList(new ConditionDto[]{getJWTCondition(false)})); String condition = throttleConditionEvaluator.getThrottledInCondition(messageContext, authenticationContext, conditionMap); Assert.assertEquals(condition, "condition1"); }
Example #7
Source File: ThrottleConditionEvaluatorTest.java From carbon-apimgt with Apache License 2.0 | 6 votes |
@Test public void testGetThrottledInConditionWithJWTConditionNegative() { ThrottleProperties throttleProperties = new ThrottleProperties(); throttleProperties.setEnableJwtConditions(true); ServiceReferenceHolder.getInstance().setThrottleProperties(throttleProperties); MessageContext messageContext = TestUtils.getMessageContext(apiContext, apiVersion); String jwt = "eyJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJ3c28yLm9yZy9wcm9kdWN0cy9hbSIsImV4cCI6MTM0NTE4MzQ5MjE4MSwiaHR0cD" + "ovL3dzbzIub3JnL2NsYWltcy9hYmMiOiJjZCIsImh0dHA6Ly93c28yLm9yZy9jbGFpbXMvYmNkIjoieHl6In0=.yg-FAt9-h7CR" + "p7DCM6m4x5xWGxwj4mwXHH4b4sUP9h0"; AuthenticationContext authenticationContext = new AuthenticationContext(); authenticationContext.setCallerToken(jwt); Map<String, List<ConditionDto>> conditionMap = new HashMap<>(); conditionMap.put("condition1", Arrays.asList(new ConditionDto[]{getJWTCondition(false)})); conditionMap.put("default", Arrays.asList(new ConditionDto[]{getJWTCondition(false)})); String condition = throttleConditionEvaluator.getThrottledInCondition(messageContext, authenticationContext, conditionMap); Assert.assertEquals(condition, "default"); }
Example #8
Source File: ThrottleConditionEvaluatorTest.java From carbon-apimgt with Apache License 2.0 | 6 votes |
@Test public void testGetThrottledInConditionWithJWTConditionInvert() { ThrottleProperties throttleProperties = new ThrottleProperties(); throttleProperties.setEnableJwtConditions(true); String jwt = "eyJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJ3c28yLm9yZy9wcm9kdWN0cy9hbSIsImV4cCI6MTM0NTE4MzQ5MjE4MSwiaHR0cDov" + "L3dzbzIub3JnL2NsYWltcy9hYmMiOiJjZGUiLCJodHRwOi8vd3NvMi5vcmcvY2xhaW1zL2JjZCI6Inh5eiJ9.9zGU062DJ5mQ5hne" + "41h4IRpLbaY_b5thRxb3feebOcA"; AuthenticationContext authenticationContext = new AuthenticationContext(); authenticationContext.setCallerToken(jwt); ServiceReferenceHolder.getInstance().setThrottleProperties(throttleProperties); MessageContext messageContext = TestUtils.getMessageContext(apiContext, apiVersion); Map<String, List<ConditionDto>> conditionMap = new HashMap<>(); conditionMap.put("condition1", Arrays.asList(new ConditionDto[]{getJWTCondition(true)})); conditionMap.put("default", Arrays.asList(new ConditionDto[]{getJWTCondition(true)})); String condition = throttleConditionEvaluator.getThrottledInCondition(messageContext, authenticationContext, conditionMap); Assert.assertEquals(condition, "default"); }
Example #9
Source File: ThrottleConditionEvaluatorTest.java From carbon-apimgt with Apache License 2.0 | 6 votes |
@Test public void testGetThrottledInConditionWithJWTConditionNegativeInvert() { ThrottleProperties throttleProperties = new ThrottleProperties(); throttleProperties.setEnableJwtConditions(true); ServiceReferenceHolder.getInstance().setThrottleProperties(throttleProperties); MessageContext messageContext = TestUtils.getMessageContext(apiContext, apiVersion); String jwt = "eyJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJ3c28yLm9yZy9wcm9kdWN0cy9hbSIsImV4cCI6MTM0NTE4MzQ5MjE4MSwiaHR0cD" + "ovL3dzbzIub3JnL2NsYWltcy9hYmMiOiJjZCIsImh0dHA6Ly93c28yLm9yZy9jbGFpbXMvYmNkIjoieHl6In0=.yg-FAt9-h7CR" + "p7DCM6m4x5xWGxwj4mwXHH4b4sUP9h0"; AuthenticationContext authenticationContext = new AuthenticationContext(); authenticationContext.setCallerToken(jwt); Map<String, List<ConditionDto>> conditionMap = new HashMap<>(); conditionMap.put("condition1", Arrays.asList(new ConditionDto[]{getJWTCondition(true)})); conditionMap.put("default", Arrays.asList(new ConditionDto[]{getJWTCondition(true)})); String condition = throttleConditionEvaluator.getThrottledInCondition(messageContext, authenticationContext, conditionMap); Assert.assertEquals(condition, "condition1"); }
Example #10
Source File: ThrottleConditionEvaluatorTest.java From carbon-apimgt with Apache License 2.0 | 6 votes |
@Test public void testGetThrottledInConditionWithComplexConditionWithLowerProperties() { ThrottleProperties throttleProperties = new ThrottleProperties(); throttleProperties.setEnableHeaderConditions(true); ServiceReferenceHolder.getInstance().setThrottleProperties(throttleProperties); MessageContext messageContext = TestUtils.getMessageContext(apiContext, apiVersion); ((Axis2MessageContext) messageContext).getAxis2MessageContext().setProperty("REST_URL_POSTFIX", "/temperature?abc=cde&bcd=xyz"); Map map = new TreeMap(); map.put("X-Forwarded-For", "127.0.0.1"); ((Axis2MessageContext) messageContext).getAxis2MessageContext() .setProperty(org.apache.axis2.context.MessageContext.TRANSPORT_HEADERS, map); Map<String, List<ConditionDto>> conditionMap = new HashMap<>(); conditionMap.put("condition1", Arrays.asList(new ConditionDto[]{getComplexCondition1()})); conditionMap.put("default", Arrays.asList(new ConditionDto[]{getComplexCondition1(), getComplexCondition2()})); String condition = throttleConditionEvaluator.getThrottledInCondition(messageContext, null, conditionMap); Assert.assertEquals(null, condition); }
Example #11
Source File: HiveMetaStoreBridgeTest.java From incubator-atlas with Apache License 2.0 | 6 votes |
@Test public void testImportThatUpdatesRegisteredDatabase() throws Exception { // setup database when(hiveClient.getAllDatabases()).thenReturn(Arrays.asList(new String[]{TEST_DB_NAME})); String description = "This is a default database"; when(hiveClient.getDatabase(TEST_DB_NAME)).thenReturn( new Database(TEST_DB_NAME, description, "/user/hive/default", null)); when(hiveClient.getAllTables(TEST_DB_NAME)).thenReturn(Arrays.asList(new String[]{})); returnExistingDatabase(TEST_DB_NAME, atlasClient, CLUSTER_NAME); HiveMetaStoreBridge bridge = new HiveMetaStoreBridge(CLUSTER_NAME, hiveClient, atlasClient); bridge.importHiveMetadata(true); // verify update is called verify(atlasClient).updateEntity(eq("72e06b34-9151-4023-aa9d-b82103a50e76"), (Referenceable) argThat( new MatchesReferenceableProperty(HiveMetaStoreBridge.DESCRIPTION_ATTR, description))); }
Example #12
Source File: ExportServiceTest.java From incubator-atlas with Apache License 2.0 | 6 votes |
private void verifyExportForEmployeeData(ZipSource zipSource) throws AtlasBaseException { final List<String> expectedEntityTypes = Arrays.asList(new String[]{"Manager", "Employee", "Department"}); assertNotNull(zipSource.getCreationOrder()); assertEquals(zipSource.getCreationOrder().size(), 2); assertTrue(zipSource.hasNext()); while (zipSource.hasNext()) { AtlasEntity entity = zipSource.next(); assertNotNull(entity); assertEquals(AtlasEntity.Status.ACTIVE, entity.getStatus()); assertTrue(expectedEntityTypes.contains(entity.getTypeName())); } verifyTypeDefs(zipSource); }
Example #13
Source File: ThrottleConditionEvaluatorTest.java From carbon-apimgt with Apache License 2.0 | 6 votes |
@Test public void testGetThrottledInConditionWithComplexCondition() { ThrottleProperties throttleProperties = new ThrottleProperties(); throttleProperties.setEnableHeaderConditions(true); ServiceReferenceHolder.getInstance().setThrottleProperties(throttleProperties); MessageContext messageContext = TestUtils.getMessageContext(apiContext, apiVersion); ((Axis2MessageContext) messageContext).getAxis2MessageContext().setProperty("REST_URL_POSTFIX", "/temperature?abc=cde&bcd=xyz"); Map map = new TreeMap(); map.put("X-Forwarded-For", "127.0.0.1"); map.put("abc", "cde"); map.put("bcd", "xyz"); ((Axis2MessageContext) messageContext).getAxis2MessageContext() .setProperty(org.apache.axis2.context.MessageContext.TRANSPORT_HEADERS, map); Map<String, List<ConditionDto>> conditionMap = new HashMap<>(); conditionMap.put("condition1", Arrays.asList(new ConditionDto[]{getComplexCondition1()})); conditionMap.put("default", Arrays.asList(new ConditionDto[]{getComplexCondition1(), getComplexCondition2()})); String condition = throttleConditionEvaluator.getThrottledInCondition(messageContext, null, conditionMap); Assert.assertEquals(condition, "condition1"); }
Example #14
Source File: ActiveInstanceState.java From incubator-atlas with Apache License 2.0 | 6 votes |
/** * Update state of the active server instance. * * This method writes this instance's Server Address to a shared node in Zookeeper. * This information is used by other passive instances to locate the current active server. * @throws Exception * @param serverId ID of this server instance */ public void update(String serverId) throws AtlasBaseException { try { CuratorFramework client = curatorFactory.clientInstance(); HAConfiguration.ZookeeperProperties zookeeperProperties = HAConfiguration.getZookeeperProperties(configuration); String atlasServerAddress = HAConfiguration.getBoundAddressForId(configuration, serverId); List<ACL> acls = Arrays.asList( new ACL[]{AtlasZookeeperSecurityProperties.parseAcl(zookeeperProperties.getAcl(), ZooDefs.Ids.OPEN_ACL_UNSAFE.get(0))}); Stat serverInfo = client.checkExists().forPath(getZnodePath(zookeeperProperties)); if (serverInfo == null) { client.create(). withMode(CreateMode.EPHEMERAL). withACL(acls). forPath(getZnodePath(zookeeperProperties)); } client.setData().forPath(getZnodePath(zookeeperProperties), atlasServerAddress.getBytes(Charset.forName("UTF-8"))); } catch (Exception e) { throw new AtlasBaseException(AtlasErrorCode.CURATOR_FRAMEWORK_UPDATE, e, "forPath: getZnodePath"); } }
Example #15
Source File: ThrottleConditionEvaluatorTest.java From carbon-apimgt with Apache License 2.0 | 5 votes |
@Test public void testGetThrottledInConditionWithQueryConditionInvert() { ThrottleProperties throttleProperties = new ThrottleProperties(); throttleProperties.setEnableQueryParamConditions(true); ServiceReferenceHolder.getInstance().setThrottleProperties(throttleProperties); MessageContext messageContext = TestUtils.getMessageContext(apiContext, apiVersion); ((Axis2MessageContext) messageContext).getAxis2MessageContext().setProperty("REST_URL_POSTFIX", "/temperature?abc=cde&bcd=xyz"); Map<String, List<ConditionDto>> conditionMap = new HashMap<>(); conditionMap.put("condition1", Arrays.asList(new ConditionDto[]{getQueryParamCondition(true)})); conditionMap.put("default", Arrays.asList(new ConditionDto[]{getQueryParamCondition(true)})); String condition = throttleConditionEvaluator.getThrottledInCondition(messageContext, null, conditionMap); Assert.assertEquals(condition, "default"); }
Example #16
Source File: ThrottleConditionEvaluatorTest.java From carbon-apimgt with Apache License 2.0 | 5 votes |
@Test public void testGetThrottledInConditionWithQueryConditionNegative() { ThrottleProperties throttleProperties = new ThrottleProperties(); throttleProperties.setEnableQueryParamConditions(true); ServiceReferenceHolder.getInstance().setThrottleProperties(throttleProperties); MessageContext messageContext = TestUtils.getMessageContext(apiContext, apiVersion); ((Axis2MessageContext) messageContext).getAxis2MessageContext().setProperty("REST_URL_POSTFIX", "/temperature?abc=cd&bcd=xyz"); Map<String, List<ConditionDto>> conditionMap = new HashMap<>(); conditionMap.put("condition1", Arrays.asList(new ConditionDto[]{getQueryParamCondition(false)})); conditionMap.put("default", Arrays.asList(new ConditionDto[]{getQueryParamCondition(false)})); String condition = throttleConditionEvaluator.getThrottledInCondition(messageContext, null, conditionMap); Assert.assertEquals(condition, "default"); }
Example #17
Source File: ThrottleConditionEvaluatorTest.java From carbon-apimgt with Apache License 2.0 | 5 votes |
@Test public void testGetThrottledInConditionWithQueryCondition() { ThrottleProperties throttleProperties = new ThrottleProperties(); throttleProperties.setEnableQueryParamConditions(true); ServiceReferenceHolder.getInstance().setThrottleProperties(throttleProperties); MessageContext messageContext = TestUtils.getMessageContext(apiContext, apiVersion); ((Axis2MessageContext) messageContext).getAxis2MessageContext().setProperty("REST_URL_POSTFIX", "/temperature?abc=cde&bcd=xyz"); Map<String, List<ConditionDto>> conditionMap = new HashMap<>(); conditionMap.put("condition1", Arrays.asList(new ConditionDto[]{getQueryParamCondition(false)})); conditionMap.put("default", Arrays.asList(new ConditionDto[]{getQueryParamCondition(false)})); String condition = throttleConditionEvaluator.getThrottledInCondition(messageContext, null, conditionMap); Assert.assertEquals(condition, "condition1"); }
Example #18
Source File: ThrottleConditionEvaluatorTest.java From carbon-apimgt with Apache License 2.0 | 5 votes |
@Test public void testGetThrottledInConditionWithComplexConditionNegative() { ThrottleProperties throttleProperties = new ThrottleProperties(); throttleProperties.setEnableHeaderConditions(true); ServiceReferenceHolder.getInstance().setThrottleProperties(throttleProperties); MessageContext messageContext = TestUtils.getMessageContext(apiContext, apiVersion); ((Axis2MessageContext) messageContext).getAxis2MessageContext().setProperty("REST_URL_POSTFIX", "/temperature?abc=cde&bcd=xyz"); Map<String, List<ConditionDto>> conditionMap = new HashMap<>(); conditionMap.put("condition1", Arrays.asList(new ConditionDto[]{getComplexCondition1()})); conditionMap.put("default", Arrays.asList(new ConditionDto[]{getComplexCondition1(), getComplexCondition2()})); String condition = throttleConditionEvaluator.getThrottledInCondition(messageContext, null, conditionMap); Assert.assertEquals(null, condition); }
Example #19
Source File: ThrottleConditionEvaluatorTest.java From carbon-apimgt with Apache License 2.0 | 5 votes |
@Test public void testGetThrottledInConditionWithQueryConditionNegativeInvert() { ThrottleProperties throttleProperties = new ThrottleProperties(); throttleProperties.setEnableQueryParamConditions(true); ServiceReferenceHolder.getInstance().setThrottleProperties(throttleProperties); MessageContext messageContext = TestUtils.getMessageContext(apiContext, apiVersion); ((Axis2MessageContext) messageContext).getAxis2MessageContext().setProperty("REST_URL_POSTFIX", "/temperature?abc=cd&bcd=xyz"); Map<String, List<ConditionDto>> conditionMap = new HashMap<>(); conditionMap.put("condition1", Arrays.asList(new ConditionDto[]{getQueryParamCondition(true)})); conditionMap.put("default", Arrays.asList(new ConditionDto[]{getQueryParamCondition(true)})); String condition = throttleConditionEvaluator.getThrottledInCondition(messageContext, null, conditionMap); Assert.assertEquals(condition, "condition1"); }
Example #20
Source File: TypeSystemTest.java From incubator-atlas with Apache License 2.0 | 5 votes |
@Test public void testGetTraitsNames() throws Exception { HierarchicalTypeDefinition<TraitType> classificationTraitDefinition = TypesUtil .createTraitTypeDef("Classification", ImmutableSet.<String>of(), TypesUtil.createRequiredAttrDef("tag", DataTypes.STRING_TYPE)); HierarchicalTypeDefinition<TraitType> piiTrait = TypesUtil.createTraitTypeDef("PII", ImmutableSet.<String>of()); HierarchicalTypeDefinition<TraitType> phiTrait = TypesUtil.createTraitTypeDef("PHI", ImmutableSet.<String>of()); HierarchicalTypeDefinition<TraitType> pciTrait = TypesUtil.createTraitTypeDef("PCI", ImmutableSet.<String>of()); HierarchicalTypeDefinition<TraitType> soxTrait = TypesUtil.createTraitTypeDef("SOX", ImmutableSet.<String>of()); HierarchicalTypeDefinition<TraitType> secTrait = TypesUtil.createTraitTypeDef("SEC", ImmutableSet.<String>of()); HierarchicalTypeDefinition<TraitType> financeTrait = TypesUtil.createTraitTypeDef("Finance", ImmutableSet.<String>of()); getTypeSystem().defineTypes(ImmutableList.<EnumTypeDefinition>of(), ImmutableList.<StructTypeDefinition>of(), ImmutableList.of(classificationTraitDefinition, piiTrait, phiTrait, pciTrait, soxTrait, secTrait, financeTrait), ImmutableList.<HierarchicalTypeDefinition<ClassType>>of()); final ImmutableList<String> traitsNames = getTypeSystem().getTypeNamesByCategory(DataTypes.TypeCategory.TRAIT); Assert.assertEquals(traitsNames.size(), 7); List traits = Arrays.asList(new String[]{"Classification", "PII", "PHI", "PCI", "SOX", "SEC", "Finance",}); Assert.assertFalse(Collections.disjoint(traitsNames, traits)); }
Example #21
Source File: ThrottleConditionEvaluatorTest.java From carbon-apimgt with Apache License 2.0 | 5 votes |
@Test public void testGetThrottledInConditionWithIPRangeConditionWithDefaultInvert() { MessageContext messageContext = TestUtils.getMessageContext(apiContext, apiVersion); Map map = new TreeMap(); map.put("X-Forwarded-For", "192.168.0.5"); ((Axis2MessageContext) messageContext).getAxis2MessageContext() .setProperty(org.apache.axis2.context.MessageContext.TRANSPORT_HEADERS, map); Map<String, List<ConditionDto>> conditionMap = new HashMap<>(); conditionMap.put("condition1", Arrays.asList(new ConditionDto[]{getIpRangeCondition(true)})); conditionMap.put("default", Arrays.asList(new ConditionDto[]{getIpRangeCondition(true)})); String condition = throttleConditionEvaluator.getThrottledInCondition(messageContext, null, conditionMap); Assert.assertEquals(condition, "default"); }
Example #22
Source File: ThrottleConditionEvaluatorTest.java From carbon-apimgt with Apache License 2.0 | 5 votes |
@Test public void testGetThrottledInConditionWithIPRangeConditionWithDefaultIpNotInRange() { MessageContext messageContext = TestUtils.getMessageContext(apiContext, apiVersion); Map map = new TreeMap(); map.put("X-Forwarded-For", "192.168.0.12"); ((Axis2MessageContext) messageContext).getAxis2MessageContext() .setProperty(org.apache.axis2.context.MessageContext.TRANSPORT_HEADERS, map); Map<String, List<ConditionDto>> conditionMap = new HashMap<>(); conditionMap.put("condition1", Arrays.asList(new ConditionDto[]{getIpRangeCondition(false)})); conditionMap.put("default", Arrays.asList(new ConditionDto[]{getIpRangeCondition(false)})); String condition = throttleConditionEvaluator.getThrottledInCondition(messageContext, null, conditionMap); Assert.assertEquals(condition, "default"); }
Example #23
Source File: ThrottleConditionEvaluatorTest.java From carbon-apimgt with Apache License 2.0 | 5 votes |
@Test public void testGetThrottledInConditionWithIPRangeConditionWithDefault() { MessageContext messageContext = TestUtils.getMessageContext(apiContext, apiVersion); Map map = new TreeMap(); map.put("X-Forwarded-For", "192.168.0.5"); ((Axis2MessageContext) messageContext).getAxis2MessageContext() .setProperty(org.apache.axis2.context.MessageContext.TRANSPORT_HEADERS, map); Map<String, List<ConditionDto>> conditionMap = new HashMap<>(); conditionMap.put("condition1", Arrays.asList(new ConditionDto[]{getIpRangeCondition(false)})); conditionMap.put("default", Arrays.asList(new ConditionDto[]{getIpRangeCondition(false)})); String condition = throttleConditionEvaluator.getThrottledInCondition(messageContext, null, conditionMap); Assert.assertEquals(condition, "condition1"); }
Example #24
Source File: ThrottleConditionEvaluatorTest.java From carbon-apimgt with Apache License 2.0 | 5 votes |
@Test public void testGetThrottledInConditionWithIPConditionWithDefaultWithInvertNegative() { MessageContext messageContext = TestUtils.getMessageContext(apiContext, apiVersion); Map map = new TreeMap(); map.put("X-Forwarded-For", "127.0.0.1"); ((Axis2MessageContext) messageContext).getAxis2MessageContext() .setProperty(org.apache.axis2.context.MessageContext.TRANSPORT_HEADERS, map); Map<String, List<ConditionDto>> conditionMap = new HashMap<>(); conditionMap.put("condition1", Arrays.asList(new ConditionDto[]{getIPCondition(true)})); conditionMap.put("default", Arrays.asList(new ConditionDto[]{getIPCondition(true)})); String condition = throttleConditionEvaluator.getThrottledInCondition(messageContext, null, conditionMap); Assert.assertEquals(condition, "default"); }
Example #25
Source File: ThrottleConditionEvaluatorTest.java From carbon-apimgt with Apache License 2.0 | 5 votes |
@Test public void testGetThrottledInConditionWithIPConditionWithDefaultWithInvert() { MessageContext messageContext = TestUtils.getMessageContext(apiContext, apiVersion); Map map = new TreeMap(); map.put("X-Forwarded-For", "127.0.0.2"); ((Axis2MessageContext) messageContext).getAxis2MessageContext() .setProperty(org.apache.axis2.context.MessageContext.TRANSPORT_HEADERS, map); Map<String, List<ConditionDto>> conditionMap = new HashMap<>(); conditionMap.put("condition1", Arrays.asList(new ConditionDto[]{getIPCondition(true)})); conditionMap.put("default", Arrays.asList(new ConditionDto[]{getIPCondition(true)})); String condition = throttleConditionEvaluator.getThrottledInCondition(messageContext, null, conditionMap); Assert.assertEquals(condition, "condition1"); }
Example #26
Source File: ThrottleConditionEvaluatorTest.java From carbon-apimgt with Apache License 2.0 | 5 votes |
@Test public void testGetThrottledInConditionWithIPConditionWithDefault() { MessageContext messageContext = TestUtils.getMessageContext(apiContext, apiVersion); Map map = new TreeMap(); map.put("X-Forwarded-For", "127.0.0.2"); ((Axis2MessageContext) messageContext).getAxis2MessageContext() .setProperty(org.apache.axis2.context.MessageContext.TRANSPORT_HEADERS, map); Map<String, List<ConditionDto>> conditionMap = new HashMap<>(); conditionMap.put("condition1", Arrays.asList(new ConditionDto[]{getIPCondition(false)})); conditionMap.put("default", Arrays.asList(new ConditionDto[]{getIPCondition(false)})); String condition = throttleConditionEvaluator.getThrottledInCondition(messageContext, null, conditionMap); Assert.assertEquals(condition, "default"); }
Example #27
Source File: ThrottleConditionEvaluatorTest.java From carbon-apimgt with Apache License 2.0 | 5 votes |
@Test public void testGetThrottledInConditionWithIPCondition() { MessageContext messageContext = TestUtils.getMessageContext(apiContext, apiVersion); Map map = new TreeMap(); map.put("X-Forwarded-For", "127.0.0.1"); ((Axis2MessageContext) messageContext).getAxis2MessageContext() .setProperty(org.apache.axis2.context.MessageContext.TRANSPORT_HEADERS, map); Map<String, List<ConditionDto>> conditionMap = new HashMap<>(); conditionMap.put("condition1", Arrays.asList(new ConditionDto[]{getIPCondition(false)})); conditionMap.put("default", Arrays.asList(new ConditionDto[]{getIPCondition(false)})); String condition = throttleConditionEvaluator.getThrottledInCondition(messageContext, null, conditionMap); Assert.assertEquals(condition, "condition1"); }
Example #28
Source File: ThrottleConditionEvaluatorTest.java From carbon-apimgt with Apache License 2.0 | 5 votes |
@Test public void testGetThrottledInConditionWithIPRangeConditionWithDefaultIpNotInRangeInvert() { MessageContext messageContext = TestUtils.getMessageContext(apiContext, apiVersion); Map map = new TreeMap(); map.put("X-Forwarded-For", "192.168.0.12"); ((Axis2MessageContext) messageContext).getAxis2MessageContext() .setProperty(org.apache.axis2.context.MessageContext.TRANSPORT_HEADERS, map); Map<String, List<ConditionDto>> conditionMap = new HashMap<>(); conditionMap.put("condition1", Arrays.asList(new ConditionDto[]{getIpRangeCondition(true)})); conditionMap.put("default", Arrays.asList(new ConditionDto[]{getIpRangeCondition(true)})); String condition = throttleConditionEvaluator.getThrottledInCondition(messageContext, null, conditionMap); Assert.assertEquals(condition, "condition1"); }
Example #29
Source File: ActiveInstanceStateTest.java From incubator-atlas with Apache License 2.0 | 5 votes |
@Test public void testSharedPathIsCreatedWithRightACLIfNotExists() throws Exception { when(configuration.getString(HAConfiguration.ATLAS_SERVER_ADDRESS_PREFIX +"id1")).thenReturn(HOST_PORT); when(configuration.getString(HAConfiguration.HA_ZOOKEEPER_ACL)).thenReturn("sasl:[email protected]"); when(configuration.getString( HAConfiguration.ATLAS_SERVER_HA_ZK_ROOT_KEY, HAConfiguration.ATLAS_SERVER_ZK_ROOT_DEFAULT)). thenReturn(HAConfiguration.ATLAS_SERVER_ZK_ROOT_DEFAULT); when(curatorFactory.clientInstance()).thenReturn(curatorFramework); ExistsBuilder existsBuilder = mock(ExistsBuilder.class); when(curatorFramework.checkExists()).thenReturn(existsBuilder); when(existsBuilder.forPath(getPath())).thenReturn(null); CreateBuilder createBuilder = mock(CreateBuilder.class); when(curatorFramework.create()).thenReturn(createBuilder); when(createBuilder.withMode(CreateMode.EPHEMERAL)).thenReturn(createBuilder); ACL expectedAcl = new ACL(ZooDefs.Perms.ALL, new Id("sasl", "[email protected]")); when(createBuilder. withACL(Arrays.asList(new ACL[]{expectedAcl}))).thenReturn(createBuilder); SetDataBuilder setDataBuilder = mock(SetDataBuilder.class); when(curatorFramework.setData()).thenReturn(setDataBuilder); ActiveInstanceState activeInstanceState = new ActiveInstanceState(configuration, curatorFactory); activeInstanceState.update("id1"); verify(createBuilder).forPath(getPath()); }
Example #30
Source File: HiveMetaStoreBridgeTest.java From incubator-atlas with Apache License 2.0 | 5 votes |
@Test public void testImportWhenPartitionKeysAreNull() throws Exception { setupDB(hiveClient, TEST_DB_NAME); List<Table> hiveTables = setupTables(hiveClient, TEST_DB_NAME, TEST_TABLE_NAME); Table hiveTable = hiveTables.get(0); returnExistingDatabase(TEST_DB_NAME, atlasClient, CLUSTER_NAME); when(atlasClient.getEntity(HiveDataTypes.HIVE_TABLE.getName(), AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME, HiveMetaStoreBridge.getTableQualifiedName(CLUSTER_NAME, TEST_DB_NAME, TEST_TABLE_NAME))).thenReturn( getEntityReference(HiveDataTypes.HIVE_TABLE.getName(), "82e06b34-9151-4023-aa9d-b82103a50e77")); String processQualifiedName = HiveMetaStoreBridge.getTableProcessQualifiedName(CLUSTER_NAME, hiveTable); when(atlasClient.getEntity(HiveDataTypes.HIVE_PROCESS.getName(), AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME, processQualifiedName)).thenReturn(getEntityReference(HiveDataTypes.HIVE_PROCESS.getName(), "82e06b34-9151-4023-aa9d-b82103a50e77")); when(atlasClient.getEntity("82e06b34-9151-4023-aa9d-b82103a50e77")).thenReturn(createTableReference()); Partition partition = mock(Partition.class); when(partition.getTable()).thenReturn(hiveTable); List partitionValues = Arrays.asList(new String[]{}); when(partition.getValues()).thenReturn(partitionValues); when(hiveClient.getPartitions(hiveTable)).thenReturn(Arrays.asList(new Partition[]{partition})); HiveMetaStoreBridge bridge = new HiveMetaStoreBridge(CLUSTER_NAME, hiveClient, atlasClient); try { bridge.importHiveMetadata(true); } catch (Exception e) { Assert.fail("Partition with null key caused import to fail with exception ", e); } }