@Test public void systemPropSecureFacetStatisticalSampleSize() { int sampleSize; System.setProperty(PROP_SECURE_FACETS_VALUE_JVM_PARAM, PROP_SECURE_FACETS_VALUE_STATISTICAL); System.setProperty(STATISTICAL_FACET_SAMPLE_SIZE_JVM_PARAM, "10"); sampleSize = SecureFacetConfiguration.getInstance(RANDOM_SEED, root).getStatisticalFacetSampleSize(); assertEquals(10, sampleSize); System.setProperty(STATISTICAL_FACET_SAMPLE_SIZE_JVM_PARAM, "-10"); sampleSize = SecureFacetConfiguration.getInstance(RANDOM_SEED, root).getStatisticalFacetSampleSize(); assertEquals(STATISTICAL_FACET_SAMPLE_SIZE_DEFAULT, sampleSize); System.setProperty(STATISTICAL_FACET_SAMPLE_SIZE_JVM_PARAM, "100000000000"); sampleSize = SecureFacetConfiguration.getInstance(RANDOM_SEED, root).getStatisticalFacetSampleSize(); assertEquals(STATISTICAL_FACET_SAMPLE_SIZE_DEFAULT, sampleSize); }
this.secureFacets = SecureFacetConfiguration.getInstance(randomSeed, facetsConfig); this.numberOfTopFacets = getOptionalValue(facetsConfig, PROP_FACETS_TOP_CHILDREN, DEFAULT_FACET_COUNT); } else { this.secureFacets = SecureFacetConfiguration.getInstance(randomSeed, null); this.numberOfTopFacets = DEFAULT_FACET_COUNT;
@Test public void systemPropSecureFacet() { SecureFacetConfiguration config; System.setProperty(PROP_SECURE_FACETS_VALUE_JVM_PARAM, "random"); config = SecureFacetConfiguration.getInstance(RANDOM_SEED, root); assertEquals(MODE.SECURE, config.getMode()); System.setProperty(PROP_SECURE_FACETS_VALUE_JVM_PARAM, "secure"); config = SecureFacetConfiguration.getInstance(RANDOM_SEED, root); assertEquals(MODE.SECURE, config.getMode()); System.setProperty(PROP_SECURE_FACETS_VALUE_JVM_PARAM, "insecure"); config = SecureFacetConfiguration.getInstance(RANDOM_SEED, root); assertEquals(MODE.INSECURE, config.getMode()); System.setProperty(PROP_SECURE_FACETS_VALUE_JVM_PARAM, "insecure"); builder.setProperty(PROP_SECURE_FACETS, "secure"); config = SecureFacetConfiguration.getInstance(RANDOM_SEED, builder.getNodeState()); assertEquals(MODE.SECURE, config.getMode()); }
@Test public void orderingOfOverrides() { System.setProperty(PROP_SECURE_FACETS_VALUE_JVM_PARAM, "insecure"); System.setProperty(STATISTICAL_FACET_SAMPLE_SIZE_JVM_PARAM, "10"); NodeState nodeState; SecureFacetConfiguration config; int sampleSize; nodeState = builder.child("config1").setProperty(PROP_SECURE_FACETS, "secure").getNodeState(); config = SecureFacetConfiguration.getInstance(RANDOM_SEED, nodeState); assertEquals(MODE.SECURE, config.getMode()); assertEquals(-1, config.getStatisticalFacetSampleSize()); nodeState = builder.child("config2") .setProperty(PROP_SECURE_FACETS, PROP_SECURE_FACETS_VALUE_STATISTICAL) .setProperty(PROP_STATISTICAL_FACET_SAMPLE_SIZE, 20) .getNodeState(); config = SecureFacetConfiguration.getInstance(RANDOM_SEED, nodeState); sampleSize = config.getStatisticalFacetSampleSize(); assertEquals(20, sampleSize); nodeState = builder.child("config3") .setProperty(PROP_SECURE_FACETS, PROP_SECURE_FACETS_VALUE_STATISTICAL) .getNodeState(); config = SecureFacetConfiguration.getInstance(RANDOM_SEED, nodeState); sampleSize = config.getStatisticalFacetSampleSize(); assertEquals(10, sampleSize); }
@Test public void invalidSecureFacetSampleSize() { int sampleSize; NodeBuilder configBuilder = builder.child("config").setProperty(PROP_SECURE_FACETS, PROP_SECURE_FACETS_VALUE_STATISTICAL); NodeState nodeState = configBuilder.getNodeState(); configBuilder.setProperty(PROP_STATISTICAL_FACET_SAMPLE_SIZE, -10); sampleSize = SecureFacetConfiguration.getInstance(RANDOM_SEED, nodeState).getStatisticalFacetSampleSize(); assertEquals(STATISTICAL_FACET_SAMPLE_SIZE_DEFAULT, sampleSize); System.setProperty(STATISTICAL_FACET_SAMPLE_SIZE_JVM_PARAM, "10"); configBuilder.setProperty(PROP_STATISTICAL_FACET_SAMPLE_SIZE, -20); nodeState = configBuilder.getNodeState(); sampleSize = SecureFacetConfiguration.getInstance(RANDOM_SEED, nodeState).getStatisticalFacetSampleSize(); assertEquals(10, sampleSize); System.setProperty(STATISTICAL_FACET_SAMPLE_SIZE_JVM_PARAM, "-10"); configBuilder.setProperty(PROP_STATISTICAL_FACET_SAMPLE_SIZE, -20); sampleSize = SecureFacetConfiguration.getInstance(RANDOM_SEED, nodeState).getStatisticalFacetSampleSize(); assertEquals(STATISTICAL_FACET_SAMPLE_SIZE_DEFAULT, sampleSize); System.setProperty(STATISTICAL_FACET_SAMPLE_SIZE_JVM_PARAM, "-10"); configBuilder.setProperty(PROP_STATISTICAL_FACET_SAMPLE_SIZE, 10); nodeState = configBuilder.getNodeState(); sampleSize = SecureFacetConfiguration.getInstance(RANDOM_SEED, nodeState).getStatisticalFacetSampleSize(); assertEquals(10, sampleSize); }
@Test public void legacyConfig() { NodeState ns = builder.setProperty(PROP_SECURE_FACETS, true).getNodeState(); SecureFacetConfiguration config = SecureFacetConfiguration.getInstance(RANDOM_SEED, ns); assertEquals(MODE.SECURE, config.getMode()); assertEquals(-1, config.getStatisticalFacetSampleSize()); ns = builder.setProperty(PROP_SECURE_FACETS, false).getNodeState(); config = SecureFacetConfiguration.getInstance(RANDOM_SEED, ns); assertEquals(MODE.INSECURE, config.getMode()); assertEquals(-1, config.getStatisticalFacetSampleSize()); }
@Test public void nonSecureConfigMode() { SecureFacetConfiguration config; builder.setProperty(PROP_SECURE_FACETS, "insecure"); config = SecureFacetConfiguration.getInstance(RANDOM_SEED, builder.getNodeState()); assertEquals(-1, config.getStatisticalFacetSampleSize()); builder.setProperty(PROP_SECURE_FACETS, "statistical"); config = SecureFacetConfiguration.getInstance(RANDOM_SEED, builder.getNodeState()); assertEquals(STATISTICAL_FACET_SAMPLE_SIZE_DEFAULT, config.getStatisticalFacetSampleSize()); }
@Test public void defaultConfig() { SecureFacetConfiguration config = SecureFacetConfiguration.getInstance(RANDOM_SEED, root); assertEquals(config.getMode(), MODE.SECURE); int sampleSize = config.getStatisticalFacetSampleSize(); assertEquals(-1, sampleSize); }