Clean up servicemgr pkg 89/203289/1
authorjw_wonny.cha <jw_wonny.cha@samsung.com>
Thu, 11 Apr 2019 08:44:20 +0000 (17:44 +0900)
committerjw_wonny.cha <jw_wonny.cha@samsung.com>
Thu, 11 Apr 2019 08:44:20 +0000 (17:44 +0900)
Change-Id: I02acf26b69e369415e2f8fe432ae9687ef42382c
Signed-off-by: jw_wonny.cha <jw_wonny.cha@samsung.com>
src/servicemgr/common_test.go [deleted file]
src/servicemgr/configure.go [deleted file]
src/servicemgr/service_map.go
src/servicemgr/types.go
src/servicemgr/types_concurrent_map_test.go [deleted file]
src/servicemgr/types_test.go [new file with mode: 0755]

diff --git a/src/servicemgr/common_test.go b/src/servicemgr/common_test.go
deleted file mode 100755 (executable)
index 47e646e..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-/*******************************************************************************
- * Copyright 2019 Samsung Electronics All Rights Reserved.
- *
- * 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 servicemgr_test
-
-import (
-       "strings"
-       "testing"
-)
-
-const (
-       serviceName  = "ls"
-       serviceName2 = "main2"
-)
-
-func assertEqualStr(t *testing.T, a, b string) {
-       t.Helper()
-       if strings.Compare(a, b) != 0 {
-               t.Errorf("%s != %s", a, b)
-       }
-}
-
-func retError(t *testing.T, err error) {
-       t.Helper()
-
-       if err != nil {
-               t.Error(err.Error())
-       }
-}
diff --git a/src/servicemgr/configure.go b/src/servicemgr/configure.go
deleted file mode 100755 (executable)
index 6fef8bb..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
-/*******************************************************************************
- * Copyright 2019 Samsung Electronics All Rights Reserved.
- *
- * 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 servicemgr
-
-import "errors"
-
-const (
-       // ConstKeyServiceID is key of service id
-       ConstKeyServiceID = "ServiceID"
-
-       // ConstKeyServiceName is key of service name
-       ConstKeyServiceName = "ServiceName"
-
-       // ConstKeyNotiChan is key of notification channel
-       ConstKeyNotiChan = "NotiChan"
-
-       // ConstKeyStatus is key of status
-       ConstKeyStatus = "Status"
-
-       // ConstKeyUserArgs is key of user argument
-       ConstKeyUserArgs = "UserArgs"
-
-       // ConstKeyNotiTargetURL is key of notification target URL
-       ConstKeyNotiTargetURL = "NotificationTargetURL"
-
-       // ConstServiceStatusFailed is service status is failed
-       ConstServiceStatusFailed = "Failed"
-
-       // ConstServiceStatusStarted is service status is started
-       ConstServiceStatusStarted = "Started"
-
-       // ConstServiceStatusFinished is service status is finished
-       ConstServiceStatusFinished = "Finished"
-
-       // ConstServiceFound is service status is found
-       ConstServiceFound = "Found"
-
-       // ConstServiceNotFound is service status is not found
-       ConstServiceNotFound = "NotFound"
-
-       // ConstServiceExecuteURI is URI for creating & executing service
-       ConstServiceExecuteURI = "/api/v1/servicemgr/services"
-
-       // ConstServiceStatusNotiURI is URI for notification status of service
-       ConstServiceStatusNotiURI = "/api/v1/servicemgr/services/notification/"
-)
-
-var (
-       // ErrInvalidService is for error type of invalid service
-       ErrInvalidService = errors.New("It is Invalid Service")
-
-       // ServiceMap is service map
-       ServiceMap ConcurrentMap
-
-       // ServiceIdx is for unique service ID (process id)
-       ServiceIdx uint64
-)
index 93514bdaa129fee72f12f97299b6bfa9b38ca663..8b72954f000a7ae0de83542e063bf598cfb04bc7 100755 (executable)
@@ -1,3 +1,5 @@
+package servicemgr
+
 /*******************************************************************************
  * Copyright 2019 Samsung Electronics All Rights Reserved.
  *
@@ -14,7 +16,6 @@
  * limitations under the License.
  *
  *******************************************************************************/
-package servicemgr
 
 import (
        "sync/atomic"
index 92251edfd8dde660150e4b1ebe992022d2e2a88f..d782c72d8bc0259088385fdd180816888b2b0301 100755 (executable)
@@ -1,3 +1,5 @@
+package servicemgr
+
 /*******************************************************************************
  * Copyright 2019 Samsung Electronics All Rights Reserved.
  *
  * limitations under the License.
  *
  *******************************************************************************/
-package servicemgr
 
-import "sync"
+import (
+       "errors"
+       "sync"
+)
+
+const (
+       // ConstKeyServiceID is key of service id
+       ConstKeyServiceID = "ServiceID"
+
+       // ConstKeyServiceName is key of service name
+       ConstKeyServiceName = "ServiceName"
+
+       // ConstKeyNotiChan is key of notification channel
+       ConstKeyNotiChan = "NotiChan"
+
+       // ConstKeyStatus is key of status
+       ConstKeyStatus = "Status"
+
+       // ConstKeyUserArgs is key of user argument
+       ConstKeyUserArgs = "UserArgs"
+
+       // ConstKeyNotiTargetURL is key of notification target URL
+       ConstKeyNotiTargetURL = "NotificationTargetURL"
+
+       // ConstServiceStatusFailed is service status is failed
+       ConstServiceStatusFailed = "Failed"
+
+       // ConstServiceStatusStarted is service status is started
+       ConstServiceStatusStarted = "Started"
+
+       // ConstServiceStatusFinished is service status is finished
+       ConstServiceStatusFinished = "Finished"
+
+       // ConstServiceFound is service status is found
+       ConstServiceFound = "Found"
+
+       // ConstServiceNotFound is service status is not found
+       ConstServiceNotFound = "NotFound"
+)
+
+var (
+       logPrefix = "servicemgr"
+
+       // ErrInvalidService is for error type of invalid service
+       ErrInvalidService = errors.New("It is Invalid Service")
+
+       // ServiceMap is service map
+       ServiceMap ConcurrentMap
 
-var logPrefix = "servicemgr"
+       // ServiceIdx is for unique service ID (process id)
+       ServiceIdx uint64
+)
 
 // ServiceParam structrue
 type ServiceParam struct {
diff --git a/src/servicemgr/types_concurrent_map_test.go b/src/servicemgr/types_concurrent_map_test.go
deleted file mode 100755 (executable)
index 113b6e6..0000000
+++ /dev/null
@@ -1,86 +0,0 @@
-/*******************************************************************************
- * Copyright 2019 Samsung Electronics All Rights Reserved.
- *
- * 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 servicemgr_test
-
-import (
-       "servicemgr"
-       "strings"
-       "testing"
-)
-
-func TestMapSetGet(t *testing.T) {
-       servicemgr.Init()
-       servicemgr.ServiceMap.Set(uint64(1), serviceName)
-
-       str, _ := servicemgr.ServiceMap.Get(uint64(1))
-       assertEqualStr(t, str.(string), serviceName)
-}
-
-func TestMapRemove(t *testing.T) {
-       servicemgr.Init()
-       servicemgr.ServiceMap.Set(uint64(1), serviceName)
-
-       servicemgr.ServiceMap.Remove(uint64(1))
-
-       exist, _ := servicemgr.ServiceMap.Get(uint64(1))
-       if exist != nil {
-               t.Error("ConcurrentMap Remove API is failed")
-       }
-}
-
-func TestMapModify(t *testing.T) {
-       servicemgr.Init()
-       servicemgr.ServiceMap.Set(uint64(1), serviceName)
-       servicemgr.ServiceMap.Set(uint64(1), serviceName2)
-
-       str, _ := servicemgr.ServiceMap.Get(uint64(1))
-       assertEqualStr(t, str.(string), serviceName2)
-}
-
-func TestMapIter(t *testing.T) {
-       servicemgr.Init()
-       servicemgr.ServiceMap.Set(uint64(1), serviceName)
-       servicemgr.ServiceMap.Set(uint64(2), serviceName2)
-
-       mapItem := servicemgr.ServiceMap.Iter()
-       compareStr := make([]string, 10)
-       idx := 0
-
-       for {
-               msg := <-mapItem
-
-               t.Log(msg.Key, msg.Value)
-
-               if msg.Value == nil && msg.Key == 0 {
-                       break
-               } else {
-                       compareStr[idx] = msg.Value.(string)
-               }
-       }
-
-       for _, str := range compareStr {
-               if len(str) == 0 {
-                       break
-               }
-
-               if strings.Compare(str, serviceName) == 0 || strings.Compare(str, serviceName2) == 0 {
-                       continue
-               } else {
-                       t.Fail()
-               }
-       }
-}
diff --git a/src/servicemgr/types_test.go b/src/servicemgr/types_test.go
new file mode 100755 (executable)
index 0000000..490faba
--- /dev/null
@@ -0,0 +1,87 @@
+package servicemgr_test
+
+/*******************************************************************************
+ * Copyright 2019 Samsung Electronics All Rights Reserved.
+ *
+ * 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.
+ *
+ *******************************************************************************/
+
+import (
+       "servicemgr"
+       "strings"
+       "testing"
+)
+
+func TestMapSetGet(t *testing.T) {
+       servicemgr.Init()
+       servicemgr.ServiceMap.Set(uint64(1), serviceName)
+
+       str, _ := servicemgr.ServiceMap.Get(uint64(1))
+       assertEqualStr(t, str.(string), serviceName)
+}
+
+func TestMapRemove(t *testing.T) {
+       servicemgr.Init()
+       servicemgr.ServiceMap.Set(uint64(1), serviceName)
+
+       servicemgr.ServiceMap.Remove(uint64(1))
+
+       exist, _ := servicemgr.ServiceMap.Get(uint64(1))
+       if exist != nil {
+               t.Error("ConcurrentMap Remove API is failed")
+       }
+}
+
+func TestMapModify(t *testing.T) {
+       servicemgr.Init()
+       servicemgr.ServiceMap.Set(uint64(1), serviceName)
+       servicemgr.ServiceMap.Set(uint64(1), serviceName2)
+
+       str, _ := servicemgr.ServiceMap.Get(uint64(1))
+       assertEqualStr(t, str.(string), serviceName2)
+}
+
+func TestMapIter(t *testing.T) {
+       servicemgr.Init()
+       servicemgr.ServiceMap.Set(uint64(1), serviceName)
+       servicemgr.ServiceMap.Set(uint64(2), serviceName2)
+
+       mapItem := servicemgr.ServiceMap.Iter()
+       compareStr := make([]string, 10)
+       idx := 0
+
+       for {
+               msg := <-mapItem
+
+               t.Log(msg.Key, msg.Value)
+
+               if msg.Value == nil && msg.Key == 0 {
+                       break
+               } else {
+                       compareStr[idx] = msg.Value.(string)
+               }
+       }
+
+       for _, str := range compareStr {
+               if len(str) == 0 {
+                       break
+               }
+
+               if strings.Compare(str, serviceName) == 0 || strings.Compare(str, serviceName2) == 0 {
+                       continue
+               } else {
+                       t.Fail()
+               }
+       }
+}