View Javadoc
1   package net.sf.mbus4j.devices;
2   
3   /*
4    * #%L
5    * mbus4j-master
6    * %%
7    * Copyright (C) 2009 - 2014 MBus4J
8    * %%
9    * mbus4j - Drivers for the M-Bus protocol - http://mbus4j.sourceforge.net/
10   * Copyright (C) 2009-2014, mbus4j.sf.net, and individual contributors as indicated
11   * by the @authors tag. See the copyright.txt in the distribution for a
12   * full listing of individual contributors.
13   * 
14   * This is free software; you can redistribute it and/or modify it
15   * under the terms of the GNU General Public License as
16   * published by the Free Software Foundation; either version 3 of
17   * the License, or (at your option) any later version.
18   * 
19   * This software is distributed in the hope that it will be useful,
20   * but WITHOUT ANY WARRANTY; without even the implied warranty of
21   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22   * Lesser General Public License for more details.
23   * 
24   * You should have received a copy of the GNU Lesser General Public
25   * License along with this software; if not, write to the Free
26   * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
27   * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
28   * #L%
29   */
30  
31  import net.sf.mbus4j.dataframes.MBusMedium;
32  
33  import org.junit.After;
34  import org.junit.AfterClass;
35  import static org.junit.Assert.*;
36  
37  import org.junit.Before;
38  import org.junit.BeforeClass;
39  import org.junit.Ignore;
40  import org.junit.Test;
41  
42  import java.io.ByteArrayInputStream;
43  import java.io.ByteArrayOutputStream;
44  import java.io.ObjectInputStream;
45  import java.io.ObjectOutputStream;
46  import java.util.Map;
47  
48  /**
49   *
50   * @author aploese
51   */
52  public class GenericDeviceTest {
53  
54      private GenericDevice instance;
55  
56      public GenericDeviceTest() {
57      }
58  
59      @BeforeClass
60      public static void setUpClass()
61              throws Exception {
62      }
63  
64      @AfterClass
65      public static void tearDownClass()
66              throws Exception {
67      }
68  
69      @Before
70      public void setUp() {
71      }
72  
73      @After
74      public void tearDown() {
75      }
76  
77      /**
78       * Test of getMan method, of class GenericDevice.
79       */
80      @Test
81      @Ignore
82      public void testGetManufacturer() {
83          System.out.println("getManufacturer");
84  
85          GenericDevice instance = null;
86          String expResult = "";
87          String result = instance.getManufacturer();
88          assertEquals(expResult, result);
89          // TODO review the generated test code and remove the default call to fail.
90          fail("The test case is a prototype.");
91      }
92  
93      /**
94       * Test of getMedium method, of class GenericDevice.
95       */
96      @Test
97      @Ignore
98      public void testGetMedium() {
99          System.out.println("getMedium");
100 
101         GenericDevice instance = null;
102         MBusMedium expResult = null;
103         MBusMedium result = instance.getMedium();
104         assertEquals(expResult, result);
105         // TODO review the generated test code and remove the default call to fail.
106         fail("The test case is a prototype.");
107     }
108 
109     /**
110      * Test of readValues method, of class GenericDevice.
111      */
112     @Test
113     @Ignore
114     public void testReadValues()
115             throws Exception {
116         System.out.println("readValues");
117 
118         Sender sender = null;
119         GenericDevice instance = null;
120         Map expResult = null;
121         // TODO review the generated test code and remove the default call to fail.
122         fail("The test case is a prototype.");
123     }
124 
125     @Test
126     @Ignore
127     public void testSerialize()
128             throws Exception {
129         ByteArrayOutputStream bos = new ByteArrayOutputStream();
130         ObjectOutputStream objOut = new ObjectOutputStream(bos);
131         objOut.writeObject(instance);
132         objOut.close();
133 
134         ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
135         System.out.println(String.format("Serialized AcwHeatmeter: (size: %s) %s",
136                 bos.size(),
137                 bos.toString()));
138 
139         GenericDevice result = (GenericDevice) new ObjectInputStream(bis).readObject();
140         assertEquals(instance, result);
141         System.out.println(instance.toString());
142         System.out.println(result.toString());
143         assertEquals(instance.isAcd(),
144                 result.isAcd());
145         assertEquals(instance.isDfc(),
146                 result.isDfc());
147     }
148 }