org.apache.commons.configuration.BaseConfiguration Java Examples

The following examples show how to use org.apache.commons.configuration.BaseConfiguration. 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: Z3950CatalogTest.java    From proarc with GNU General Public License v3.0 6 votes vote down vote up
@Test
public void testReadFields() {
    final String catalogId = "catalogId";
    CatalogConfiguration c = new CatalogConfiguration(catalogId, "", new BaseConfiguration() {{
        addProperty(CatalogConfiguration.PROPERTY_FIELDS, "field1,field2 , field3  ");
        addProperty(CatalogConfiguration.FIELD_PREFIX + '.' + "field1" + '.' + Z3950Catalog.PROPERTY_FIELD_QUERY, "query1");
        addProperty(CatalogConfiguration.FIELD_PREFIX + '.' + "field2" + '.' + Z3950Catalog.PROPERTY_FIELD_QUERY, "query2");
    }});
    Map<String, Z3950Field> result = Z3950Catalog.readFields(c);
    assertNotNull(result);
    assertEquals(3, result.size());
    Z3950Field field1 = result.get("field1");
    assertNotNull("field1", field1);
    assertEquals("query1", field1.getQuery());
    Z3950Field field2 = result.get("field2");
    assertNotNull("field2", field2);
    assertEquals("query2", field2.getQuery());
    Z3950Field field3 = result.get("field3");
    assertNotNull("field3", field3);
    assertNull(field3.getQuery());
}
 
Example #2
Source File: TinkerGraphTest.java    From tinkergraph-gremlin with Apache License 2.0 6 votes vote down vote up
@Test
public void shouldPersistToGraphML() {
    final String graphLocation = TestHelper.makeTestDataDirectory(TinkerGraphTest.class) + "shouldPersistToGraphML.xml";
    final File f = new File(graphLocation);
    if (f.exists() && f.isFile()) f.delete();

    final Configuration conf = new BaseConfiguration();
    conf.setProperty(TinkerGraph.GREMLIN_TINKERGRAPH_GRAPH_FORMAT, "graphml");
    conf.setProperty(TinkerGraph.GREMLIN_TINKERGRAPH_GRAPH_LOCATION, graphLocation);
    final TinkerGraph graph = TinkerGraph.open(conf);
    TinkerFactory.generateModern(graph);
    graph.close();

    final TinkerGraph reloadedGraph = TinkerGraph.open(conf);
    IoTest.assertModernGraph(reloadedGraph, true, true);
    reloadedGraph.close();
}
 
Example #3
Source File: TinkerGraphTest.java    From tinkergraph-gremlin with Apache License 2.0 6 votes vote down vote up
@Test
public void shouldPersistToGraphSON() {
    final String graphLocation = TestHelper.makeTestDataDirectory(TinkerGraphTest.class) + "shouldPersistToGraphSON.json";
    final File f = new File(graphLocation);
    if (f.exists() && f.isFile()) f.delete();

    final Configuration conf = new BaseConfiguration();
    conf.setProperty(TinkerGraph.GREMLIN_TINKERGRAPH_GRAPH_FORMAT, "graphson");
    conf.setProperty(TinkerGraph.GREMLIN_TINKERGRAPH_GRAPH_LOCATION, graphLocation);
    final TinkerGraph graph = TinkerGraph.open(conf);
    TinkerFactory.generateModern(graph);
    graph.close();

    final TinkerGraph reloadedGraph = TinkerGraph.open(conf);
    IoTest.assertModernGraph(reloadedGraph, true, false);
    reloadedGraph.close();
}
 
Example #4
Source File: TinkerGraphTest.java    From tinkergraph-gremlin with Apache License 2.0 6 votes vote down vote up
@Test
public void shouldPersistToGryoAndHandleMultiProperties() {
    final String graphLocation = TestHelper.makeTestDataDirectory(TinkerGraphTest.class) + "shouldPersistToGryoMulti.kryo";
    final File f = new File(graphLocation);
    if (f.exists() && f.isFile()) f.delete();

    final Configuration conf = new BaseConfiguration();
    conf.setProperty(TinkerGraph.GREMLIN_TINKERGRAPH_GRAPH_FORMAT, "gryo");
    conf.setProperty(TinkerGraph.GREMLIN_TINKERGRAPH_GRAPH_LOCATION, graphLocation);
    final TinkerGraph graph = TinkerGraph.open(conf);
    TinkerFactory.generateTheCrew(graph);
    graph.close();

    conf.setProperty(TinkerGraph.GREMLIN_TINKERGRAPH_DEFAULT_VERTEX_PROPERTY_CARDINALITY, VertexProperty.Cardinality.list.toString());
    final TinkerGraph reloadedGraph = TinkerGraph.open(conf);
    IoTest.assertCrewGraph(reloadedGraph, false);
    reloadedGraph.close();
}
 
Example #5
Source File: TinkerIoRegistryV2d0.java    From tinkergraph-gremlin with Apache License 2.0 6 votes vote down vote up
@Override
public TinkerGraph deserialize(final JsonParser jsonParser, final DeserializationContext deserializationContext) throws IOException, JsonProcessingException {
    final Configuration conf = new BaseConfiguration();
    conf.setProperty("gremlin.tinkergraph.defaultVertexPropertyCardinality", "list");
    final TinkerGraph graph = TinkerGraph.open(conf);

    while (jsonParser.nextToken() != JsonToken.END_OBJECT) {
        if (jsonParser.getCurrentName().equals("vertices")) {
            while (jsonParser.nextToken() != JsonToken.END_ARRAY) {
                if (jsonParser.currentToken() == JsonToken.START_OBJECT) {
                    final DetachedVertex v = (DetachedVertex) deserializationContext.readValue(jsonParser, Vertex.class);
                    v.attach(Attachable.Method.getOrCreate(graph));
                }
            }
        } else if (jsonParser.getCurrentName().equals("edges")) {
            while (jsonParser.nextToken() != JsonToken.END_ARRAY) {
                if (jsonParser.currentToken() == JsonToken.START_OBJECT) {
                    final DetachedEdge e = (DetachedEdge) deserializationContext.readValue(jsonParser, Edge.class);
                    e.attach(Attachable.Method.getOrCreate(graph));
                }
            }
        }
    }

    return graph;
}
 
Example #6
Source File: TitanTxLongVersionedGraphTest.java    From antiquity with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected ActiveVersionedGraph<?, Long> generateGraph() {
    File f = new File("/tmp/testgraph");
    if (f.exists()) {
        if (f.isDirectory()) {
            try {
                FileUtils.deleteDirectory(f);
            } catch (IOException e) {
                throw new IllegalStateException(e);
            }
        } else {
            f.delete();
        }

    }

    Configuration c = new BaseConfiguration();
    c.addProperty("storage.directory","/tmp/testgraph");
    TitanGraph g = TitanFactory.open(c);

    return new ActiveVersionedGraph.ActiveVersionedTransactionalGraphBuilder<TitanGraph, Long>(g, new LongGraphIdentifierBehavior())
            .init(true).conf(null).build();
}
 
Example #7
Source File: PropertyPatternMessageColorizerTest.java    From otroslogviewer with Apache License 2.0 6 votes vote down vote up
@BeforeMethod
public void setUp() throws ConfigurationException, IOException {
  p.put(PropertyPatternMessageColorizer.PROP_NAME, "Test");
  p.put(PropertyPatternMessageColorizer.PROP_DESCRIPTION, "D");
  p.put(PropertyPatternMessageColorizer.PROP_PATTERN, "a(\\d+\\(a\\))a");
  p.put("foreground", "#FFFF00");
  p.put("background", "#00FFFF");
  p.put("font.bold", "false");
  p.put("font.italic", "true");
  p.put("foreground.1", "#FF0000");
  p.put("background.1", "#0000FF");
  p.put("font.bold.1", "true");
  p.put("font.italic.1", "false");

  ByteArrayOutputStream bout = new ByteArrayOutputStream();
  p.store(bout, "");
  ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray());

  colorizer = new PropertyPatternMessageColorizer(new ThemeConfig(new BaseConfiguration()));
  colorizer.init(bin);
}
 
Example #8
Source File: PinotLLCRealtimeSegmentManagerTest.java    From incubator-pinot with Apache License 2.0 6 votes vote down vote up
@Test
public void testSegmentAlreadyThereAndExtraneousFilesDeleted()
    throws Exception {
  PinotFSFactory.init(new BaseConfiguration());
  File tableDir = new File(TEMP_DIR, RAW_TABLE_NAME);
  String segmentName = new LLCSegmentName(RAW_TABLE_NAME, 0, 0, CURRENT_TIME_MS).getSegmentName();
  String otherSegmentName = new LLCSegmentName(RAW_TABLE_NAME, 1, 0, CURRENT_TIME_MS).getSegmentName();
  String segmentFileName = SegmentCompletionUtils.generateSegmentFileName(segmentName);
  String extraSegmentFileName = SegmentCompletionUtils.generateSegmentFileName(segmentName);
  String otherSegmentFileName = SegmentCompletionUtils.generateSegmentFileName(otherSegmentName);
  File segmentFile = new File(tableDir, segmentFileName);
  File extraSegmentFile = new File(tableDir, extraSegmentFileName);
  File otherSegmentFile = new File(tableDir, otherSegmentFileName);
  FileUtils.write(segmentFile, "temporary file contents");
  FileUtils.write(extraSegmentFile, "temporary file contents");
  FileUtils.write(otherSegmentFile, "temporary file contents");

  FakePinotLLCRealtimeSegmentManager segmentManager = new FakePinotLLCRealtimeSegmentManager();
  String segmentLocation = SCHEME + tableDir + "/" + segmentFileName;
  CommittingSegmentDescriptor committingSegmentDescriptor = new CommittingSegmentDescriptor(segmentName,
      PARTITION_OFFSET.toString(), 0, segmentLocation);
  segmentManager.commitSegmentFile(REALTIME_TABLE_NAME, committingSegmentDescriptor);
  assertFalse(segmentFile.exists());
  assertFalse(extraSegmentFile.exists());
  assertTrue(otherSegmentFile.exists());
}
 
Example #9
Source File: TinkerGraphTest.java    From tinkergraph-gremlin with Apache License 2.0 6 votes vote down vote up
@Test
public void shouldPersistToGryo() {
    final String graphLocation = TestHelper.makeTestDataDirectory(TinkerGraphTest.class) + "shouldPersistToGryo.kryo";
    final File f = new File(graphLocation);
    if (f.exists() && f.isFile()) f.delete();

    final Configuration conf = new BaseConfiguration();
    conf.setProperty(TinkerGraph.GREMLIN_TINKERGRAPH_GRAPH_FORMAT, "gryo");
    conf.setProperty(TinkerGraph.GREMLIN_TINKERGRAPH_GRAPH_LOCATION, graphLocation);
    final TinkerGraph graph = TinkerGraph.open(conf);
    TinkerFactory.generateModern(graph);
    graph.close();

    final TinkerGraph reloadedGraph = TinkerGraph.open(conf);
    IoTest.assertModernGraph(reloadedGraph, true, false);
    reloadedGraph.close();
}
 
Example #10
Source File: TinkerGraphTest.java    From tinkergraph-gremlin with Apache License 2.0 6 votes vote down vote up
@Test
public void shouldPersistWithRelativePath() {
    final String graphLocation = TestHelper.convertToRelative(TinkerGraphTest.class,
            new File(TestHelper.makeTestDataDirectory(TinkerGraphTest.class)))  + "shouldPersistToGryoRelative.kryo";
    final File f = new File(graphLocation);
    if (f.exists() && f.isFile()) f.delete();

    final Configuration conf = new BaseConfiguration();
    conf.setProperty(TinkerGraph.GREMLIN_TINKERGRAPH_GRAPH_FORMAT, "gryo");
    conf.setProperty(TinkerGraph.GREMLIN_TINKERGRAPH_GRAPH_LOCATION, graphLocation);
    final TinkerGraph graph = TinkerGraph.open(conf);
    TinkerFactory.generateModern(graph);
    graph.close();

    final TinkerGraph reloadedGraph = TinkerGraph.open(conf);
    IoTest.assertModernGraph(reloadedGraph, true, false);
    reloadedGraph.close();
}
 
Example #11
Source File: LogPatternsPage.java    From otroslogviewer with Apache License 2.0 6 votes vote down vote up
private void importFromIde() {
  final BaseConfiguration configuration = new BaseConfiguration();
  final WizardSettings settings = this.getController().getSettings();
  configuration.setProperty(ConfKeys.JUMP_TO_CODE_HOST, settings.get(Config.IDE_HOST));
  configuration.setProperty(ConfKeys.JUMP_TO_CODE_PORT, settings.get(Config.IDE_PORT));
  loggerConfigTextPane.setEditable(false);
  loggerConfigTextPane.setText("Importing log patterns from IDE");
  new SwingWorker<Set<String>, Void>() {
    @Override
    protected Set<String> doInBackground() throws Exception {
      return new JumpToCodeServiceImpl(configuration).loggerPatterns();
    }

    @Override
    protected void done() {
      try {
        loggerConfigTextPane.setEditable(true);
        loggerConfigTextPane.setText(Joiner.on("\n").join(get()));
      } catch (InterruptedException | ExecutionException e) {
        e.printStackTrace();
      }
    }
  }.execute();
}
 
Example #12
Source File: BitsyGraph.java    From bitsy with Apache License 2.0 6 votes vote down vote up
@Override
public Configuration configuration() {
    if (this.origConfig != null) {
            return this.origConfig;
    } else {
        Configuration ans = new BaseConfiguration();
        ans.setProperty(DB_PATH_KEY, dbPath.toString());
        ans.setProperty(ALLOW_FULL_GRAPH_SCANS_KEY, allowFullGraphScans);
        ans.setProperty(DEFAULT_ISOLATION_LEVEL_KEY, defaultIsolationLevel.toString());
        ans.setProperty(TX_LOG_THRESHOLD_KEY, getTxLogThreshold());
        ans.setProperty(REORG_FACTOR_KEY, getReorgFactor());
        ans.setProperty(CREATE_DIR_IF_MISSING_KEY, createDirIfMissing);

        ans.setProperty(VERTEX_INDICES_KEY, String.join(",", getIndexedKeys(Vertex.class)));
        ans.setProperty(EDGE_INDICES_KEY, String.join(",", getIndexedKeys(Vertex.class)));

        return ans;
    }
}
 
Example #13
Source File: ShowConfigTest.java    From otroslogviewer with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) throws UnsupportedLookAndFeelException {
  final SubstanceBusinessBlackSteelLookAndFeel newLookAndFeel = new SubstanceBusinessBlackSteelLookAndFeel();
  UIManager.setLookAndFeel(newLookAndFeel);
  DataConfiguration configuration = new DataConfiguration(new BaseConfiguration());
  ConfigurationProvider configurationProvider = new ConfigurationProviderImpl(configuration, new File(System.getProperty("java.io.tmpdir")));
  configuration.setProperty("view1.text", "ASD ASD");
  configuration.setProperty("view2.text", "sdf\nd\ndf\ns");
  JFrame f = new JFrame("CV");
  f.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
  f.getContentPane().setLayout(new BorderLayout());
  ConfigView[] configViews = {
      new View1(), // 
      new View2(), //
      new ViewTable(),// 
      new DateFormatView(),// 
      new ValidationView(),
      new ValidationView2()//
  };
  f.getContentPane().add(new ConfigComponent(configurationProvider, configViews));
  f.pack();
  f.setVisible(true);
}
 
Example #14
Source File: OfflineNonReplicaGroupSegmentAssignmentTest.java    From incubator-pinot with Apache License 2.0 6 votes vote down vote up
@Test
public void testBootstrapTable() {
  Map<String, Map<String, String>> currentAssignment = new TreeMap<>();
  for (String segmentName : SEGMENTS) {
    List<String> instancesAssigned =
        _segmentAssignment.assignSegment(segmentName, currentAssignment, _instancePartitionsMap);
    currentAssignment
        .put(segmentName, SegmentAssignmentUtils.getInstanceStateMap(instancesAssigned, SegmentStateModel.ONLINE));
  }

  // Bootstrap table should reassign all segments based on their alphabetical order
  Configuration rebalanceConfig = new BaseConfiguration();
  rebalanceConfig.setProperty(RebalanceConfigConstants.BOOTSTRAP, true);
  Map<String, Map<String, String>> newAssignment =
      _segmentAssignment.rebalanceTable(currentAssignment, _instancePartitionsMap, rebalanceConfig);
  assertEquals(newAssignment.size(), NUM_SEGMENTS);
  List<String> sortedSegments = new ArrayList<>(SEGMENTS);
  sortedSegments.sort(null);
  for (int i = 0; i < NUM_SEGMENTS; i++) {
    assertEquals(newAssignment.get(sortedSegments.get(i)), currentAssignment.get(SEGMENTS.get(i)));
  }
}
 
Example #15
Source File: Kramerius4ExportOptionsTest.java    From proarc with GNU General Public License v3.0 6 votes vote down vote up
@Test
public void testFrom() {
    Configuration config = new BaseConfiguration();
    String[] excludes = {"ID1", "ID2", "ID3"};
    config.addProperty(Kramerius4ExportOptions.PROP_EXCLUDE_DATASTREAM_ID, excludes);

    config.addProperty(Kramerius4ExportOptions.PROP_RENAME_PREFIX + ".ID1", "NEWID1");
    config.addProperty(Kramerius4ExportOptions.PROP_RENAME_PREFIX + ".ID2", "NEWID2");

    String policy = "policy:public";
    config.addProperty(Kramerius4ExportOptions.PROP_POLICY, policy);

    Kramerius4ExportOptions result = Kramerius4ExportOptions.from(config);
    assertEquals(new HashSet<String>(Arrays.asList(excludes)), result.getExcludeDatastreams());
    assertEquals("NEWID1", result.getDsIdMap().get("ID1"));
    assertEquals("NEWID2", result.getDsIdMap().get("ID2"));
    assertEquals(policy, result.getPolicy());
}
 
Example #16
Source File: DesaServicesTest.java    From proarc with GNU General Public License v3.0 6 votes vote down vote up
@Before
public void setUp() {
    conf = new BaseConfiguration();
    conf.setProperty(DesaServices.PROPERTY_DESASERVICES, "ds1, dsNulls");

    String prefix = DesaServices.PREFIX_DESA + '.' + "ds1" + '.';
    conf.setProperty(prefix + DesaConfiguration.PROPERTY_USER, "ds1user");
    conf.setProperty(prefix + DesaConfiguration.PROPERTY_PASSWD, "ds1passwd");
    conf.setProperty(prefix + DesaConfiguration.PROPERTY_PRODUCER, "ds1producer");
    conf.setProperty(prefix + DesaConfiguration.PROPERTY_OPERATOR, "ds1operator");
    conf.setProperty(prefix + DesaConfiguration.PROPERTY_EXPORTMODELS, "model:id1, model:id2");
    conf.setProperty(prefix + DesaConfiguration.PROPERTY_RESTAPI, "https://SERVER/dea-frontend/rest/sipsubmission");
    conf.setProperty(prefix + DesaConfiguration.PROPERTY_WEBSERVICE, "https://SERVER/dea-frontend/ws/SIPSubmissionService");
    conf.setProperty(prefix + DesaConfiguration.PROPERTY_NOMENCLATUREACRONYMS, "acr1, acr2");

    prefix = DesaServices.PREFIX_DESA + '.' + "dsNulls" + '.';
    conf.setProperty(prefix + DesaConfiguration.PROPERTY_USER, null);
    conf.setProperty(prefix + DesaConfiguration.PROPERTY_PASSWD, "");
    conf.setProperty(prefix + DesaConfiguration.PROPERTY_EXPORTMODELS, null);
    conf.setProperty(prefix + DesaConfiguration.PROPERTY_NOMENCLATUREACRONYMS, null);

    prefix = DesaServices.PREFIX_DESA + '.' + "dsNotActive" + '.';
    conf.setProperty(prefix + DesaConfiguration.PROPERTY_USER, "NA");
    desaServices = new DesaServices(conf);
}
 
Example #17
Source File: ElasticSearchConfigTest.java    From titan1withtp3.1 with Apache License 2.0 6 votes vote down vote up
@Test
public void testLocalNodeUsingExt() throws BackendException, InterruptedException {

    String baseDir = Joiner.on(File.separator).join("target", "es", "jvmlocal_ext");

    assertFalse(new File(baseDir + File.separator + "data").exists());

    CommonsConfiguration cc = new CommonsConfiguration(new BaseConfiguration());
    cc.set("index." + INDEX_NAME + ".elasticsearch.ext.node.data", "true");
    cc.set("index." + INDEX_NAME + ".elasticsearch.ext.node.client", "false");
    cc.set("index." + INDEX_NAME + ".elasticsearch.ext.node.local", "true");
    cc.set("index." + INDEX_NAME + ".elasticsearch.ext.path.data", baseDir + File.separator + "data");
    cc.set("index." + INDEX_NAME + ".elasticsearch.ext.path.work", baseDir + File.separator + "work");
    cc.set("index." + INDEX_NAME + ".elasticsearch.ext.path.logs", baseDir + File.separator + "logs");
    ModifiableConfiguration config =
            new ModifiableConfiguration(GraphDatabaseConfiguration.ROOT_NS,
                    cc, BasicConfiguration.Restriction.NONE);
    config.set(INTERFACE, ElasticSearchSetup.NODE.toString(), INDEX_NAME);
    Configuration indexConfig = config.restrictTo(INDEX_NAME);
    IndexProvider idx = new ElasticSearchIndex(indexConfig);
    simpleWriteAndQuery(idx);
    idx.close();

    assertTrue(new File(baseDir + File.separator + "data").exists());
}
 
Example #18
Source File: ElasticSearchConfigTest.java    From titan1withtp3.1 with Apache License 2.0 6 votes vote down vote up
@Test
public void testLocalNodeUsingExtAndIndexDirectory() throws BackendException, InterruptedException {

    String baseDir = Joiner.on(File.separator).join("target", "es", "jvmlocal_ext2");

    assertFalse(new File(baseDir + File.separator + "data").exists());

    CommonsConfiguration cc = new CommonsConfiguration(new BaseConfiguration());
    cc.set("index." + INDEX_NAME + ".elasticsearch.ext.node.data", "true");
    cc.set("index." + INDEX_NAME + ".elasticsearch.ext.node.client", "false");
    cc.set("index." + INDEX_NAME + ".elasticsearch.ext.node.local", "true");
    ModifiableConfiguration config =
            new ModifiableConfiguration(GraphDatabaseConfiguration.ROOT_NS,
                    cc, BasicConfiguration.Restriction.NONE);
    config.set(INTERFACE, ElasticSearchSetup.NODE.toString(), INDEX_NAME);
    config.set(INDEX_DIRECTORY, baseDir, INDEX_NAME);
    Configuration indexConfig = config.restrictTo(INDEX_NAME);
    IndexProvider idx = new ElasticSearchIndex(indexConfig);
    simpleWriteAndQuery(idx);
    idx.close();

    assertTrue(new File(baseDir + File.separator + "data").exists());
}
 
Example #19
Source File: ConnectToSocketHubAppenderActionTest.java    From otroslogviewer with Apache License 2.0 6 votes vote down vote up
@Test
public void tryToConnectFail() throws IOException {
  OtrosApplication otrosApplication = new OtrosApplication();
  ConnectToSocketHubAppenderAction action = new ConnectToSocketHubAppenderAction(otrosApplication);
  DataConfiguration dc = new DataConfiguration(new BaseConfiguration());
  String hostAndPort = "abc:50";
  SocketFactory socketFactory = mock(SocketFactory.class);
  when(socketFactory.createSocket("abc", 50)).thenThrow(new UnknownHostException());

  try {
    action.tryToConnectToSocket(dc, hostAndPort, socketFactory);
    Assert.fail();
  } catch (UnknownHostException e) {
    //success
  }

  assertEquals(0, dc.getList(ConfKeys.SOCKET_HUB_APPENDER_ADDRESSES).size());
}
 
Example #20
Source File: ReloadablePropertySourceTest.java    From herd with Apache License 2.0 6 votes vote down vote up
/**
 * Asserts that when a property is requested from the configruation, and it fires an error event (ex. Database is not available), the previously stored
 * values are not cleared.
 */
@Test
public void testAssertGetPropertyErrorReturnPreviousValue() throws Exception
{
    // Get a reloadable property source that loads properties from the configuration every time a property is read.
    BaseConfiguration configuration = new BaseConfiguration()
    {
        @Override
        public Object getProperty(String key)
        {
            fireError(EVENT_READ_PROPERTY, key, null, new IllegalStateException("test exception"));
            return null;
        }
    };
    configuration.addProperty(TEST_KEY, TEST_VALUE_1);
    ReloadablePropertySource reloadablePropertySource = getNewReloadablePropertiesSource(0L, configuration);
    verifyPropertySourceValue(reloadablePropertySource, TEST_VALUE_1);
}
 
Example #21
Source File: PinotLLCRealtimeSegmentManagerTest.java    From incubator-pinot with Apache License 2.0 6 votes vote down vote up
@Test
public void testCommitSegmentFile()
    throws Exception {
  PinotFSFactory.init(new BaseConfiguration());
  File tableDir = new File(TEMP_DIR, RAW_TABLE_NAME);
  String segmentName = new LLCSegmentName(RAW_TABLE_NAME, 0, 0, CURRENT_TIME_MS).getSegmentName();
  String segmentFileName = SegmentCompletionUtils.generateSegmentFileName(segmentName);
  File segmentFile = new File(tableDir, segmentFileName);
  FileUtils.write(segmentFile, "temporary file contents");

  FakePinotLLCRealtimeSegmentManager segmentManager = new FakePinotLLCRealtimeSegmentManager();
  String segmentLocation = SCHEME + tableDir + "/" + segmentFileName;
  CommittingSegmentDescriptor committingSegmentDescriptor = new CommittingSegmentDescriptor(segmentName,
      PARTITION_OFFSET.toString(), 0, segmentLocation);
  segmentManager.commitSegmentFile(REALTIME_TABLE_NAME, committingSegmentDescriptor);
  assertFalse(segmentFile.exists());
}
 
Example #22
Source File: GenericExternalProcessTest.java    From proarc with GNU General Public License v3.0 6 votes vote down vote up
@Test
    public void testAddInputFile() throws Exception {
        final String inputName = "input.txt";
        final File input = temp.newFile(inputName);
        final BaseConfiguration conf = new BaseConfiguration();
        conf.addProperty(ExternalProcess.PROP_EXEC, "test.sh");
        conf.addProperty(ExternalProcess.PROP_ARG, "-i ${input.file.name}");
        conf.addProperty(ExternalProcess.PROP_ARG, "-path ${input.file}[0]");
        conf.addProperty(ExternalProcess.PROP_ARG, "-o ${input.folder}");
        GenericExternalProcess gp = new GenericExternalProcess(conf).addInputFile(input);
        assertEquals(gp.getParameters().getMap().get(GenericExternalProcess.SRC_NAME_EXT), input.getName());
        assertEquals(gp.getParameters().getMap().get(GenericExternalProcess.SRC_PATH), input.getAbsolutePath());
        assertEquals(gp.getParameters().getMap().get(GenericExternalProcess.SRC_PARENT), input.getParentFile().getAbsolutePath());
        List<String> cmdLines = gp.buildCmdLine(conf);
//        System.out.println(cmdLines.toString());
    }
 
Example #23
Source File: HadoopPinotFSTest.java    From incubator-pinot with Apache License 2.0 6 votes vote down vote up
@Test
public void testCopy()
    throws IOException {
  URI baseURI = URI.create(TMP_DIR + "/HadoopPinotFSTest");
  HadoopPinotFS hadoopFS = new HadoopPinotFS();
  hadoopFS.init(new BaseConfiguration());
  hadoopFS.mkdir(new Path(baseURI.getPath(), "src").toUri());
  hadoopFS.mkdir(new Path(baseURI.getPath(), "src/dir").toUri());
  hadoopFS.touch(new Path(baseURI.getPath(), "src/dir/1").toUri());
  hadoopFS.touch(new Path(baseURI.getPath(), "src/dir/2").toUri());
  String[] srcFiles = hadoopFS.listFiles(new Path(baseURI.getPath(), "src").toUri(), true);
  Assert.assertEquals(srcFiles.length, 3);
  hadoopFS.copy(new Path(baseURI.getPath(), "src").toUri(), new Path(baseURI.getPath(), "dest").toUri());
  Assert.assertTrue(hadoopFS.exists(new Path(baseURI.getPath(), "dest").toUri()));
  Assert.assertTrue(hadoopFS.exists(new Path(baseURI.getPath(), "dest/dir").toUri()));
  Assert.assertTrue(hadoopFS.exists(new Path(baseURI.getPath(), "dest/dir/1").toUri()));
  Assert.assertTrue(hadoopFS.exists(new Path(baseURI.getPath(), "dest/dir/2").toUri()));
  String[] destFiles = hadoopFS.listFiles(new Path(baseURI.getPath(), "dest").toUri(), true);
  Assert.assertEquals(destFiles.length, 3);
  hadoopFS.delete(baseURI, true);
}
 
Example #24
Source File: MultiGraphsTest.java    From hugegraph with Apache License 2.0 6 votes vote down vote up
public static HugeGraph openGraphWithBackend(String graph, String backend,
                                             String serializer,
                                             String... configs) {
    PropertiesConfiguration conf = Utils.getConf();
    Configuration config = new BaseConfiguration();
    for (Iterator<String> keys = conf.getKeys(); keys.hasNext();) {
        String key = keys.next();
        config.setProperty(key, conf.getProperty(key));
    }
    ((BaseConfiguration) config).setDelimiterParsingDisabled(true);
    config.setProperty(CoreOptions.STORE.name(), graph);
    config.setProperty(CoreOptions.BACKEND.name(), backend);
    config.setProperty(CoreOptions.SERIALIZER.name(), serializer);
    for (int i = 0; i < configs.length;) {
        config.setProperty(configs[i++], configs[i++]);
    }
    return ((HugeGraph) GraphFactory.open(config));
}
 
Example #25
Source File: StackTraceColorizerTest.java    From otroslogviewer with Apache License 2.0 5 votes vote down vote up
@Test
  public void testColorize() throws IOException, BadLocationException {
    //given
    String string = "something\n" +
      "java.io.FileNotFoundException: fred.txt //comment\n" +
      "\tat java.io.FileInputStream.<init>(FileInputStream.java) //code comment \n" +
      "\tat java.io.FileInputStream.<init>(FileInputStream.java) //code comment\n" +
      "\tat A.ExTest.readMyFile(ExTest.java:19) //Some code\n" +
      "  at ExTest.main(ExTest.java:7)\n";

    StackTraceColorizer colorizer = new StackTraceColorizer(new ThemeConfig(new BaseConfiguration()));

    //when
    Collection<MessageFragmentStyle> colorize = colorizer.colorize(string);
    //then
//    System.out.println("Substring: \"" + string.substring(137,210)+"\"\n\n");
//    System.out.println("Substring: \"" + string.substring(137,137+7)+"\"\n\n");
//    System.out.println("Substring: \"" + string.substring(145,145+15)+"\"\n\n");
//    System.out.println("Substring: \"" + string.substring(161,161+6)+"\"\n\n");
//    System.out.println("Substring: \"" + string.substring(229,229+14)+"\"\n\n");
    assertEquals(colorize.size(),47);

    assertTrue(colorize.stream().filter(msf -> msf.getOffset() == 137 && msf.getLength() == 7 && msf.getStyle().getName().equals("stylePackage")).findAny().isPresent());
    assertTrue(colorize.stream().filter(msf -> msf.getOffset() == 145 && msf.getLength() == 15 && msf.getStyle().getName().equals("styleClass")).findAny().isPresent());
    assertTrue(colorize.stream().filter(msf -> msf.getOffset() == 161 && msf.getLength() == 6 && msf.getStyle().getName().equals("styleMethod")).findAny().isPresent());
    assertTrue(colorize.stream().filter(msf -> msf.getOffset() == 168 && msf.getLength() == 20 && msf.getStyle().getName().equals("styleFile")).findAny().isPresent());
    assertTrue(colorize.stream().filter(msf -> msf.getOffset() == 189 && msf.getLength() == 15 && msf.getStyle().getName().equals("styleCodeComment")).findAny().isPresent());
    final Optional<MessageFragmentStyle> styleWithLocationOptional = colorize.stream().filter(msf -> msf.getOffset() == 229 && msf.getLength() == 14 && msf.getStyle().getName().startsWith("styleFile-LocationInfo")).findAny();
    assertTrue(styleWithLocationOptional.isPresent());
    final LocationInfo locationInfo = (LocationInfo) styleWithLocationOptional.get().getStyle().getAttribute(StackTraceColorizer.STYLE_ATTRIBUTE_LOCATION_INFO);
    assertEquals(locationInfo.getPackageName(),Optional.of("A"));
    assertEquals(locationInfo.getClassName(),Optional.of("A.ExTest"));
    assertEquals(locationInfo.getMethod(),Optional.of("readMyFile"));
    assertEquals(locationInfo.getFileName(),Optional.of("ExTest.java"));
    assertEquals(locationInfo.getLineNumber(),Optional.of(19));
    assertEquals(locationInfo.getMessage(),Optional.empty());


  }
 
Example #26
Source File: PhysicalMaterialBuilderTest.java    From proarc with GNU General Public License v3.0 5 votes vote down vote up
@Test
public void testBuild() throws Exception {
    CatalogConfiguration c = new CatalogConfiguration("testCatalogId", "", new BaseConfiguration() {{
        addProperty(CatalogConfiguration.PROPERTY_URL, "tcp://localhost:9991");
        addProperty(CatalogConfiguration.PROPERTY_NAME, "test");
        addProperty(CatalogConfiguration.PROPERTY_TYPE, Z3950Catalog.TYPE);
    }});
    String xml = IOUtils.toString(WorkflowManagerTest.class.getResource("rdczmods.xml"), StandardCharsets.UTF_8);
    PhysicalMaterial pm = new PhysicalMaterialBuilder().build(xml, c);
    assertEquals(xml, pm.getMetadata());
    assertEquals(c.getUrl(), pm.getSource());
    assertEquals("Nová vlna = : La nouvelle vague : Truffaut, Godard, Chabrol, Rohmer, Rivette", pm.getLabel());

}
 
Example #27
Source File: BatchImportJobTest.java    From proarc with GNU General Public License v3.0 5 votes vote down vote up
private Configuration getConfig(String schedule, String path, String profiles) {
    return new BaseConfiguration() {{
        addProperty(BatchImportJob.BATCH_IMPORT_JOB_PATH, path);
        addProperty(JobHandler.JOB_SCHEDULE, schedule);
        addProperty(BatchImportJob.BATCH_IMPORT_JOB_PROFILES, profiles);
    }};
}
 
Example #28
Source File: MetsUtilsTest.java    From proarc with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Tests if all roles are fill
 */
@Test
public void missingRole() throws Exception {
    for (MetsExportTestElement testElement : testElements) {
        // copyFiles(testElement);
        String sourceDirPath = getTargetPath() + File.separator +
                testElement.getDirectory() + File.separator;
        File resultDir = tmp.newFolder("result" + testElement.getResultFolder());
        String path = sourceDirPath + testElement.getInitialDocument();
        DigitalObject dbObj = MetsUtils.readFoXML(path);
        Configuration config = new BaseConfiguration();
        config.addProperty(NdkExportOptions.PROP_NDK_AGENT_ARCHIVIST, "Archivist");
        config.addProperty(NdkExportOptions.PROP_NDK_AGENT_CREATOR, "");
        MetsContext context = new MetsContext();
        context.setPath(sourceDirPath);
        context.setFsParentMap(TestConst.parents);
        context.setOutputPath(resultDir.getAbsolutePath());
        context.setAllowNonCompleteStreams(true);
        context.setAllowMissingURNNBN(true);
        context.setConfig(NdkExportOptions.getOptions(config));
        MetsElement metsElement = MetsElement.getElement(dbObj, null, context, true);
        MetsElementVisitor visitor = new MetsElementVisitor();
        try {
            metsElement.accept(visitor);
            Assert.fail("The validation error expected.");
        } catch (MetsExportException ex) {
            String message = "Error - missing role. Please insert value in proarc.cfg into export.ndk.agent.creator and export.ndk.agent.archivist";
            assertEquals(message, ex.getMessage());
        }
    }
}
 
Example #29
Source File: NdkExportOptionsTest.java    From proarc with GNU General Public License v3.0 5 votes vote down vote up
@Test
public void testGetOptions() {
    Configuration config = new BaseConfiguration();

    String creator = "KNAV";
    config.addProperty(NdkExportOptions.PROP_NDK_AGENT_CREATOR, creator);

    String archivist = "ProArc";
    config.addProperty(NdkExportOptions.PROP_NDK_AGENT_ARCHIVIST, archivist);

    NdkExportOptions result = NdkExportOptions.getOptions(config);

    assertEquals("creator", creator, result.getCreator());
    assertEquals("archivist", archivist, result.getArchivist());
}
 
Example #30
Source File: StackTraceColorizerTest.java    From otroslogviewer with Apache License 2.0 5 votes vote down vote up
@Test
public void testColorizingNeeded() throws IOException {
  //given
  String string = IOUtils.toString(getSystemResourceAsStream("stacktrace/stacktrace.txt"), UTF_8);
  StackTraceColorizer colorizer = new StackTraceColorizer(new ThemeConfig(new BaseConfiguration()));
  //when
  boolean colorizingNeeded = colorizer.colorizingNeeded(string);
  //then
  AssertJUnit.assertTrue(colorizingNeeded);
}