1 //******************************************************************
3 // Copyright 2015 Samsung Electronics All Rights Reserved.
5 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
7 // Licensed under the Apache License, Version 2.0 (the "License");
8 // you may not use this file except in compliance with the License.
9 // You may obtain a copy of the License at
11 // http://www.apache.org/licenses/LICENSE-2.0
13 // Unless required by applicable law or agreed to in writing, software
14 // distributed under the License is distributed on an "AS IS" BASIS,
15 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 // See the License for the specific language governing permissions and
17 // limitations under the License.
19 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
21 #include "ResourceContainer.h"
22 #include "BundleInfo.h"
23 #include "oc_logger.hpp"
27 using namespace OIC::Service;
28 using OC::oc_log_stream;
30 /* Annother way to create a context: */
31 auto info_logger = []() -> boost::iostreams::stream<OC::oc_log_stream> &
33 static OC::oc_log_stream ols(oc_make_ostream_logger);
34 static boost::iostreams::stream<OC::oc_log_stream> os(ols);
41 info_logger()->set_module("ContainerTest");
42 info_logger()->set_level(OC_LOG_INFO);
44 info_logger() << "Starting container test." << std::flush;
46 ResourceContainer *container = ResourceContainer::getInstance();
47 container->startContainer("examples/ResourceContainerConfig.xml");
49 std::list<BundleInfo *> bundles = container->listBundles();
50 std::list<BundleInfo *>::iterator bundleIt;
52 for (bundleIt = bundles.begin(); bundleIt != bundles.end(); bundleIt++)
54 BundleInfo *bi = *bundleIt;
55 info_logger() << "Available bundle: " << bi->getID() << endl;
58 cout << "Press enter to stop all bundles " << endl;
61 for (bundleIt = bundles.begin(); bundleIt != bundles.end(); bundleIt++)
63 BundleInfo *bi = *bundleIt;
64 info_logger() << "Stopping bundle: " << bi->getID() << endl;
65 container->stopBundle(bi->getID());
68 cout << "Press enter to restart all bundles " << endl;
71 for (bundleIt = bundles.begin(); bundleIt != bundles.end(); bundleIt++)
73 BundleInfo *bi = *bundleIt;
74 info_logger() << "Starting bundle: " << bi->getID() << endl;
75 container->startBundle(bi->getID());
78 cout << "Press enter to stop container " << endl;
80 container->stopContainer();
81 cout << "Container stopped. Bye" << endl;