save
Showing
11 changed files
with
229 additions
and
0 deletions
PckUtils/.classpath
0 → 100644
| 1 | <?xml version="1.0" encoding="UTF-8"?> | ||
| 2 | <classpath> | ||
| 3 | <classpathentry kind="src" output="target/classes" path="src/main/java"> | ||
| 4 | <attributes> | ||
| 5 | <attribute name="optional" value="true"/> | ||
| 6 | <attribute name="maven.pomderived" value="true"/> | ||
| 7 | </attributes> | ||
| 8 | </classpathentry> | ||
| 9 | <classpathentry kind="src" output="target/test-classes" path="src/test/java"> | ||
| 10 | <attributes> | ||
| 11 | <attribute name="optional" value="true"/> | ||
| 12 | <attribute name="maven.pomderived" value="true"/> | ||
| 13 | </attributes> | ||
| 14 | </classpathentry> | ||
| 15 | <classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"> | ||
| 16 | <attributes> | ||
| 17 | <attribute name="maven.pomderived" value="true"/> | ||
| 18 | </attributes> | ||
| 19 | </classpathentry> | ||
| 20 | <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"> | ||
| 21 | <attributes> | ||
| 22 | <attribute name="maven.pomderived" value="true"/> | ||
| 23 | </attributes> | ||
| 24 | </classpathentry> | ||
| 25 | <classpathentry kind="output" path="target/classes"/> | ||
| 26 | </classpath> |
PckUtils/.gitignore
0 → 100644
| 1 | /target |
PckUtils/.project
0 → 100644
| 1 | <?xml version="1.0" encoding="UTF-8"?> | ||
| 2 | <projectDescription> | ||
| 3 | <name>PckUtils</name> | ||
| 4 | <comment></comment> | ||
| 5 | <projects> | ||
| 6 | </projects> | ||
| 7 | <buildSpec> | ||
| 8 | <buildCommand> | ||
| 9 | <name>org.eclipse.jdt.core.javabuilder</name> | ||
| 10 | <arguments> | ||
| 11 | </arguments> | ||
| 12 | </buildCommand> | ||
| 13 | <buildCommand> | ||
| 14 | <name>org.eclipse.m2e.core.maven2Builder</name> | ||
| 15 | <arguments> | ||
| 16 | </arguments> | ||
| 17 | </buildCommand> | ||
| 18 | </buildSpec> | ||
| 19 | <natures> | ||
| 20 | <nature>org.eclipse.jdt.core.javanature</nature> | ||
| 21 | <nature>org.eclipse.m2e.core.maven2Nature</nature> | ||
| 22 | </natures> | ||
| 23 | </projectDescription> |
PckUtils/pom.xml
0 → 100644
| 1 | <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
| 2 | xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
| 3 | <modelVersion>4.0.0</modelVersion> | ||
| 4 | |||
| 5 | <groupId>HardwareConfig</groupId> | ||
| 6 | <artifactId>PUtils</artifactId> | ||
| 7 | <version>0.0.1-SNAPSHOT</version> | ||
| 8 | <packaging>jar</packaging> | ||
| 9 | |||
| 10 | <name>PUtils</name> | ||
| 11 | <url>http://maven.apache.org</url> | ||
| 12 | |||
| 13 | <properties> | ||
| 14 | <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
| 15 | </properties> | ||
| 16 | |||
| 17 | <build> | ||
| 18 | <plugins> | ||
| 19 | <plugin> | ||
| 20 | <groupId>org.apache.maven.plugins</groupId> | ||
| 21 | <artifactId>maven-compiler-plugin</artifactId> | ||
| 22 | <configuration> | ||
| 23 | <source>1.7</source> | ||
| 24 | <target>1.7</target> | ||
| 25 | <showDeprecation>true</showDeprecation> | ||
| 26 | <showWarnings>true</showWarnings> | ||
| 27 | <executable>${env.JAVA_HOME_7}/bin/javac</executable> | ||
| 28 | <fork>true</fork> | ||
| 29 | </configuration> | ||
| 30 | </plugin> | ||
| 31 | </plugins> | ||
| 32 | </build> | ||
| 33 | |||
| 34 | |||
| 35 | <dependencies> | ||
| 36 | <dependency> | ||
| 37 | <groupId>junit</groupId> | ||
| 38 | <artifactId>junit</artifactId> | ||
| 39 | <version>3.8.1</version> | ||
| 40 | <scope>test</scope> | ||
| 41 | </dependency> | ||
| 42 | |||
| 43 | <dependency> | ||
| 44 | <groupId>org.emercit</groupId> | ||
| 45 | <artifactId>projecttools</artifactId> | ||
| 46 | <version>1.5</version> | ||
| 47 | </dependency> | ||
| 48 | |||
| 49 | </dependencies> | ||
| 50 | |||
| 51 | <repositories> | ||
| 52 | <!--other repositories if any--> | ||
| 53 | <repository> | ||
| 54 | <id>project.local</id> | ||
| 55 | <name>project</name> | ||
| 56 | <url>file:/root/git/hardwareconfig/DevTools/repo</url> | ||
| 57 | </repository> | ||
| 58 | </repositories> | ||
| 59 | |||
| 60 | |||
| 61 | </project> |
| 1 | package org.emercit.pckutils.checkservice; | ||
| 2 | |||
| 3 | import org.emercit.pckutils.cmd.CmdExec; | ||
| 4 | |||
| 5 | import org.emercit.projecttools.constants.Paths; | ||
| 6 | |||
| 7 | import java.util.Vector; | ||
| 8 | |||
| 9 | |||
| 10 | public class STService { | ||
| 11 | |||
| 12 | private CmdExec cmd=new CmdExec(); | ||
| 13 | |||
| 14 | public boolean IsRun(String service) throws Exception { | ||
| 15 | |||
| 16 | Vector<String> values=cmd.Run(Paths.FINDPROCESS_SCRIPT+" "+service); | ||
| 17 | |||
| 18 | return Boolean.valueOf(values.firstElement()); | ||
| 19 | |||
| 20 | } | ||
| 21 | |||
| 22 | } |
| 1 | package org.emercit.pckutils.cmd; | ||
| 2 | |||
| 3 | |||
| 4 | import java.io.BufferedReader; | ||
| 5 | import java.io.InputStreamReader; | ||
| 6 | import java.util.List; | ||
| 7 | import java.util.ArrayList; | ||
| 8 | import java.util.Random; | ||
| 9 | |||
| 10 | import java.util.Vector; | ||
| 11 | |||
| 12 | |||
| 13 | |||
| 14 | public class CmdExec { | ||
| 15 | |||
| 16 | |||
| 17 | public Vector<String> Run(String cmd) throws Exception { | ||
| 18 | |||
| 19 | Vector<String> v=new Vector<String>(); | ||
| 20 | |||
| 21 | Runtime run = Runtime.getRuntime(); | ||
| 22 | |||
| 23 | Process proc = run.exec(new String[]{"/bin/sh", "-c",cmd}); | ||
| 24 | proc.waitFor(); | ||
| 25 | BufferedReader br = new BufferedReader(new InputStreamReader(proc.getInputStream())); | ||
| 26 | while(br.ready()) { | ||
| 27 | v.add(br.readLine()); | ||
| 28 | } | ||
| 29 | |||
| 30 | return v; | ||
| 31 | } | ||
| 32 | } | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | package HardwareConfig.PUtils; | ||
| 2 | |||
| 3 | import junit.framework.Test; | ||
| 4 | import junit.framework.TestCase; | ||
| 5 | import junit.framework.TestSuite; | ||
| 6 | |||
| 7 | /** | ||
| 8 | * Unit test for simple App. | ||
| 9 | */ | ||
| 10 | public class AppTest | ||
| 11 | extends TestCase | ||
| 12 | { | ||
| 13 | /** | ||
| 14 | * Create the test case | ||
| 15 | * | ||
| 16 | * @param testName name of the test case | ||
| 17 | */ | ||
| 18 | public AppTest( String testName ) | ||
| 19 | { | ||
| 20 | super( testName ); | ||
| 21 | } | ||
| 22 | |||
| 23 | /** | ||
| 24 | * @return the suite of tests being tested | ||
| 25 | */ | ||
| 26 | public static Test suite() | ||
| 27 | { | ||
| 28 | return new TestSuite( AppTest.class ); | ||
| 29 | } | ||
| 30 | |||
| 31 | /** | ||
| 32 | * Rigourous Test :-) | ||
| 33 | */ | ||
| 34 | public void testApp() | ||
| 35 | { | ||
| 36 | assertTrue( true ); | ||
| 37 | } | ||
| 38 | } |
-
Please register or sign in to post a comment