Imported Upstream version 1.0.0
[platform/upstream/iotivity.git] / service / easy-setup / sdk / mediator / android / EasySetupCore / src / androidTest / java / org / iotivity / service / easysetup / mediator / EnrolleeDeviceFactoryTest.java
1 /**\r
2  * ***************************************************************\r
3  * <p/>\r
4  * Copyright 2015 Samsung Electronics All Rights Reserved.\r
5  * <p/>\r
6  * <p/>\r
7  * <p/>\r
8  * Licensed under the Apache License, Version 2.0 (the "License");\r
9  * you may not use this file except in compliance with the License.\r
10  * You may obtain a copy of the License at\r
11  * <p/>\r
12  * http://www.apache.org/licenses/LICENSE-2.0\r
13  * <p/>\r
14  * Unless required by applicable law or agreed to in writing, software\r
15  * distributed under the License is distributed on an "AS IS" BASIS,\r
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
17  * See the License for the specific language governing permissions and\r
18  * limitations under the License.\r
19  * <p/>\r
20  * ****************************************************************\r
21  */\r
22 \r
23 package org.iotivity.service.easysetup.mediator;\r
24 \r
25 import android.net.wifi.WifiConfiguration;\r
26 import android.test.AndroidTestCase;\r
27 \r
28 public class EnrolleeDeviceFactoryTest extends AndroidTestCase {\r
29 \r
30     EnrolleeDeviceFactory mFactory;\r
31 \r
32     @Override\r
33     protected void setUp() throws Exception {\r
34         super.setUp();\r
35         mFactory = EnrolleeDeviceFactory.newInstance(getContext());\r
36         assertTrue(mFactory != null);\r
37 \r
38     }\r
39 \r
40     @Override\r
41     protected void tearDown() throws Exception {\r
42         super.tearDown();\r
43         mFactory = null;\r
44     }\r
45 \r
46 \r
47     public void testNewEnrolleeDevice_with_WiFiOnboarding() {\r
48 \r
49         /* Create On boarding configuration */\r
50         WiFiOnBoardingConfig mWiFiOnBoardingConfig = new WiFiOnBoardingConfig();\r
51         mWiFiOnBoardingConfig.setSSId("EasySetup123");\r
52         mWiFiOnBoardingConfig.setSharedKey("EasySetup123");\r
53         mWiFiOnBoardingConfig.setAuthAlgo(WifiConfiguration.AuthAlgorithm.OPEN);\r
54         mWiFiOnBoardingConfig.setKms(WifiConfiguration.KeyMgmt.WPA_PSK);\r
55 \r
56         /* Create provisioning configuration */\r
57         WiFiProvConfig mWiFiProvConfig = new WiFiProvConfig("hub2.4G", "11112222");\r
58 \r
59         /* Create enrolling device */\r
60         EnrolleeDevice device = mFactory.newEnrolleeDevice(mWiFiOnBoardingConfig, mWiFiProvConfig);\r
61 \r
62         /* Check if the the device is created */\r
63         assertTrue(device != null);\r
64 \r
65         /* Check if the the correct device is created as per the given configuration*/\r
66         assertTrue((device instanceof EnrolleeDeviceWiFiOnboarding));\r
67 \r
68     }\r
69 \r
70 }\r