Skip to content
Snippets Groups Projects
Commit 61f8513f authored by jkerdreu's avatar jkerdreu
Browse files

Remove tests from the xAAL-Lib package to xAAL-Tests



git-svn-id: https://redmine.imt-atlantique.fr/svn/xaal/code/Java/branches/0.7@2609 b32b6428-25c9-4566-ad07-03861ab6144f
parent 481286fe
Branches
No related tags found
No related merge requests found
jar: build
ant jar
build:
ant build
clean:
ant clean
run:
ant jar
java -jar dist/xAAL-Lib.jar
\ No newline at end of file
deploy:jar
cp -f dist/xAAL-Lib.jar ../xAAL-Tests/lib/
......@@ -378,7 +378,7 @@ public class Engine extends Thread {
*/
private void sleep() {
try {
Thread.sleep(100);
Thread.sleep(20);
} catch (InterruptedException ex) {
LOGGER.info(ex.toString());
LOGGER.info(ex.getStackTrace().toString());
......
......@@ -16,7 +16,6 @@ import java.util.logging.Logger;
import javax.crypto.Cipher;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;
import javax.swing.LookAndFeel;
import com.upokecenter.cbor.CBORObject;
......
build:
ant build
clean:
ant clean
run:
ant jar
java -jar dist/xAAL-Tests.jar
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8" ?>
<project name="xAAL-Tests" basedir="." default="main">
<property name="src.dir" value="src"/>
<property name="build.dir" value="build"/>
<property name="dist.dir" value="dist"/>
<property name="lib.dir" value="lib"/>
<property name="jre.version" value="11"/>
<property name="classes.dir" value="${build.dir}/classes"/>
<property name="jar.dir" value="${dist.dir}"/>
<property name="main-class" value="org.imta.xaal.tests.Test"/>
<path id="classpath">
<fileset dir="${lib.dir}" includes="**/*.jar"/>
</path>
<target name="clean">
<delete dir="${build.dir}"/>
<delete dir="${dist.dir}" />
</target>
<target name="build">
<mkdir dir="${classes.dir}"/>
<javac srcdir="${src.dir}" destdir="${classes.dir}" includeantruntime="false" classpathref="classpath" source="${jre.version}" target="${jre.version}"/>
</target>
<target name="jar" depends="build">
<mkdir dir="${jar.dir}"/>
<jar destfile="${jar.dir}/${ant.project.name}.jar" basedir="${classes.dir}">
<zipgroupfileset dir="lib" includes="*.jar"/>
<manifest>
<attribute name="Main-Class" value="${main-class}"/>
</manifest>
</jar>
</target>
<target name="run" depends="jar">
<java fork="true" classname="${main-class}">
<classpath>
<path refid="classpath"/>
<path location="${jar.dir}/${ant.project.name}.jar"/>
</classpath>
</java>
</target>
<target name="clean-build" depends="clean,jar"/>
<target name="main" depends="clean,run"/>
</project>
../../xAAL-Lib/dist/xAAL-Lib.jar
\ No newline at end of file
package org.imta.xaal.tests;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.Arrays;
import java.util.UUID;
import org.imta.xaal.lib.Attribute;
import org.imta.xaal.lib.Device;
import org.imta.xaal.lib.Message;
public class Lamp extends Device {
Attribute light = new Attribute("light", false);
Attribute brightness = new Attribute("brightness", 100);
public Lamp(UUID address) throws URISyntaxException{
super(address);
setDevType("lamp.dimmer");
setVendorID("Jkx Industries");
setVersion("35 rev2");
setProductID("Dummy Java Lamp");
setHwID("6b2");
setInfo(getProductID()+ " " + getHwID());
setSchema( new URI("http://foobar.com"));
setUrl(new URI("http://dev.foobar.org"));
registerAttributes(Arrays.asList(light,brightness));
}
public void toggle() {
var state = (boolean)light.getValue();
if (state==true)
light.setValue(false);
else
light.setValue(true);
}
public void turn_on() {
light.setValue(true);
}
public void turn_off() {
light.setValue(false);
}
public void setBrightness(Integer target) {
if (target<=0) turn_off();
else turn_on();
brightness.setValue(target);
}
@Override
public Message handleRequest(Message msg) {
switch (msg.getAction()) {
case "toggle":
toggle();
break;
case "turn_on":
turn_on();
break;
case "turn_off":
turn_off();
break;
case "dim":
Integer target = msg.getBodyAsMap().get("target").AsInt32();
setBrightness(target);
break;
}
return null;
}
}
package org.imta.xaal.tests;
import java.util.Arrays;
import java.util.UUID;
import org.imta.xaal.lib.Engine;
import org.imta.xaal.lib.Config;
public class Test {
/**
* @param args the command line arguments
*/
public static void main(String[] args) throws Exception{
Engine eng = new Engine(Config.getInstance());
Lamp l1 = new Lamp(UUID.fromString("6265eb30-8c59-11e9-98b1-b827ebe99201"));
Lamp l2 = new Lamp(UUID.fromString("6265eb30-8c59-11e9-98b1-b827ebe99202"));
UUID grp = UUID.randomUUID();
l1.setGroupID(grp);
l2.setGroupID(grp);
eng.registerDevices(Arrays.asList(l1,l2));
eng.start();
l1.toggle();
l2.setBrightness(50);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment