-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix dependency conflict "InjectionManagerFactory not found"
Fix #9 Change-Id: I83f2074c431994f72a62e37ab4a6086c3142a1b5
- Loading branch information
Showing
3 changed files
with
85 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
src/test/java/com/baidu/hugegraph/unit/version/VersionTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
/* | ||
* Copyright 2017 HugeGraph Authors | ||
* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with this | ||
* work for additional information regarding copyright ownership. The ASF | ||
* licenses this file to You under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package com.baidu.hugegraph.unit.version; | ||
|
||
import java.io.BufferedReader; | ||
import java.io.Closeable; | ||
import java.io.InputStreamReader; | ||
|
||
import org.junit.Test; | ||
|
||
import com.baidu.hugegraph.testutil.Assert; | ||
import com.baidu.hugegraph.version.CommonVersion; | ||
|
||
public class VersionTest { | ||
|
||
@Test | ||
public void testGetCommonVersion() { | ||
String version = CommonVersion.VERSION.get(); | ||
Assert.assertNotNull(version); | ||
String pomVersion = readVersionFromPom(); | ||
Assert.assertEquals(version, pomVersion); | ||
} | ||
|
||
private static String readVersionFromPom() { | ||
String cmd = "cat \"pom.xml\" | grep \"<version>\" | head -1 | " + | ||
"awk -F '<|>' '{print $3}'"; | ||
|
||
Process process = null; | ||
InputStreamReader isr = null; | ||
try { | ||
String[] commond = {"/bin/sh", "-c", cmd}; | ||
process = Runtime.getRuntime().exec(commond); | ||
process.waitFor(); | ||
|
||
isr = new InputStreamReader(process.getInputStream()); | ||
BufferedReader br = new BufferedReader(isr); | ||
return br.readLine(); | ||
} catch (Exception e) { | ||
throw new RuntimeException(e); | ||
} finally { | ||
closeStream(isr); | ||
// Destroy child process | ||
if (process != null) { | ||
process.destroy(); | ||
} | ||
} | ||
} | ||
|
||
private static void closeStream(Closeable stream) { | ||
if (stream != null) { | ||
try { | ||
stream.close(); | ||
} catch (Exception ignored) { | ||
} | ||
} | ||
} | ||
} |