File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1616//
1717package org .bridgedb ;
1818
19+ import java .io .IOException ;
20+ import java .io .InputStream ;
1921import java .util .HashMap ;
2022import java .util .Map ;
23+ import java .util .Properties ;
2124
2225/**
2326 * Central access point for connecting to IDMappers.
@@ -69,4 +72,23 @@ public static void register(String protocol, Driver driver)
6972 {
7073 drivers .put (protocol , driver );
7174 }
75+
76+ private static volatile String version ;
77+
78+ /**
79+ * Returns the version of BridgeDb.
80+ */
81+ public static String getVersion () {
82+ if (version != null ) return version ;
83+ try (InputStream stream = BridgeDb .class .getResourceAsStream ("/version.props" )) {
84+ Properties props = new Properties ();
85+ props .load (stream );
86+ version = props .getProperty ("bridgedb.version" );
87+ return version ;
88+ } catch (IOException exception ) {
89+ exception .printStackTrace ();
90+ }
91+ return null ;
92+ }
93+
7294}
Original file line number Diff line number Diff line change 1+ /* Copyright (c) 2025 Egon Willighagen <egonw@users.sf.net>
2+ *
3+ * Licensed under the Apache License, Version 2.0 (the "License");
4+ * you may not use this file except in compliance with the License.
5+ * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
6+ *
7+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS,
8+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9+ * See the License for the specific language governing permissions and limitations under the License.
10+ */
11+ package org .bridgedb ;
12+
13+ import static org .junit .jupiter .api .Assertions .assertNotNull ;
14+ import static org .junit .jupiter .api .Assertions .assertTrue ;
15+
16+ import org .junit .jupiter .api .Test ;
17+
18+ public class BridgeDbTest {
19+
20+ @ Test
21+ public void testVersion () {
22+ String version = BridgeDb .getVersion ();
23+ assertNotNull (version );
24+ assertTrue (version .startsWith ("3." ));
25+ }
26+ }
You can’t perform that action at this time.
0 commit comments