[zb4osgi-changeset] [scm] ZigBee 4 OSGi repository change: r573 - in /projects/zb4osgi/trunk/zigbee.zcl.library/src: main/java/it/cnr/isti/zigbee/zcl/library/impl/general/level_control/ test/java/it/cnr/isti/zigbee/zcl/library/impl/general/level_control/
scm-notify at zb4osgi.aaloa.org
scm-notify at zb4osgi.aaloa.org
Sun Oct 28 17:48:03 CET 2012
Author: stefano.lenzi
Date: Sun Oct 28 17:48:03 2012
New Revision: 573
Log:
Add Unit test for step Command
Using ByteArrayStreamSerializer instead of DefaultSerializer ( fixes #164)
Added:
projects/zb4osgi/trunk/zigbee.zcl.library/src/test/java/it/cnr/isti/zigbee/zcl/library/impl/general/level_control/
projects/zb4osgi/trunk/zigbee.zcl.library/src/test/java/it/cnr/isti/zigbee/zcl/library/impl/general/level_control/StepCommandTest.java (with props)
Modified:
projects/zb4osgi/trunk/zigbee.zcl.library/src/main/java/it/cnr/isti/zigbee/zcl/library/impl/general/level_control/StepCommand.java
Modified: projects/zb4osgi/trunk/zigbee.zcl.library/src/main/java/it/cnr/isti/zigbee/zcl/library/impl/general/level_control/StepCommand.java
==============================================================================
--- projects/zb4osgi/trunk/zigbee.zcl.library/src/main/java/it/cnr/isti/zigbee/zcl/library/impl/general/level_control/StepCommand.java (original)
+++ projects/zb4osgi/trunk/zigbee.zcl.library/src/main/java/it/cnr/isti/zigbee/zcl/library/impl/general/level_control/StepCommand.java Sun Oct 28 17:48:03 2012
@@ -25,6 +25,7 @@
import it.cnr.isti.zigbee.zcl.library.api.core.ZBSerializer;
import it.cnr.isti.zigbee.zcl.library.api.general.LevelControl;
import it.cnr.isti.zigbee.zcl.library.impl.core.AbstractCommand;
+import it.cnr.isti.zigbee.zcl.library.impl.core.ByteArrayOutputStreamSerializer;
import it.cnr.isti.zigbee.zcl.library.impl.core.DefaultSerializer;
/**
*
@@ -55,11 +56,11 @@
public byte[] getPayload(){
if( payload == null){
- payload = new byte[3];
- ZBSerializer serializer = new DefaultSerializer(payload,0);
+ ByteArrayOutputStreamSerializer serializer = new ByteArrayOutputStreamSerializer();
serializer.append_byte((byte)mode);
serializer.append_byte((byte)step);
serializer.append_short((short)time);
+ payload = serializer.getPayload();
}
return payload;
}
Added: projects/zb4osgi/trunk/zigbee.zcl.library/src/test/java/it/cnr/isti/zigbee/zcl/library/impl/general/level_control/StepCommandTest.java
==============================================================================
--- projects/zb4osgi/trunk/zigbee.zcl.library/src/test/java/it/cnr/isti/zigbee/zcl/library/impl/general/level_control/StepCommandTest.java (added)
+++ projects/zb4osgi/trunk/zigbee.zcl.library/src/test/java/it/cnr/isti/zigbee/zcl/library/impl/general/level_control/StepCommandTest.java Sun Oct 28 17:48:03 2012
@@ -1,0 +1,48 @@
+/*
+
+ Copyright 2008-2010 CNR-ISTI, http://isti.cnr.it
+ Institute of Information Science and Technologies
+ of the Italian National Research Council
+
+
+ See the NOTICE file distributed with this work for additional
+ information regarding copyright ownership
+
+ Licensed 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 it.cnr.isti.zigbee.zcl.library.impl.general.level_control;
+
+import static org.junit.Assert.assertArrayEquals;
+
+import org.junit.Test;
+
+/**
+ *
+ * @author <a href="mailto:stefano.lenzi at isti.cnr.it">Stefano "Kismet" Lenzi</a>
+ * @version $LastChangedRevision$ ($LastChangedDate$)
+ * @since 0.7.1
+ *
+ */
+public class StepCommandTest {
+
+ @Test
+ public void testGetPayload() {
+ StepCommand command = new StepCommand((byte)0, (short)255, 32);
+ assertArrayEquals(new byte[]{
+ 0x00, (byte) 0xff, 0x20, 0x00
+ }, command.getPayload()
+ );
+ }
+
+
+}
Propchange: projects/zb4osgi/trunk/zigbee.zcl.library/src/test/java/it/cnr/isti/zigbee/zcl/library/impl/general/level_control/StepCommandTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: projects/zb4osgi/trunk/zigbee.zcl.library/src/test/java/it/cnr/isti/zigbee/zcl/library/impl/general/level_control/StepCommandTest.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: projects/zb4osgi/trunk/zigbee.zcl.library/src/test/java/it/cnr/isti/zigbee/zcl/library/impl/general/level_control/StepCommandTest.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: projects/zb4osgi/trunk/zigbee.zcl.library/src/test/java/it/cnr/isti/zigbee/zcl/library/impl/general/level_control/StepCommandTest.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
More information about the Commit
mailing list