You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by sa...@apache.org on 2013/07/02 11:38:00 UTC

[18/23] Refactoring org.wso2.carbon to org.apache.stratos

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/ee2ab783/components/stratos/billing/org.apache.stratos.billing.core/2.1.3/src/test/java/org/wso2/carbon/billing/test/TriggerTest.java
----------------------------------------------------------------------
diff --git a/components/stratos/billing/org.apache.stratos.billing.core/2.1.3/src/test/java/org/wso2/carbon/billing/test/TriggerTest.java b/components/stratos/billing/org.apache.stratos.billing.core/2.1.3/src/test/java/org/wso2/carbon/billing/test/TriggerTest.java
new file mode 100644
index 0000000..9b4f609
--- /dev/null
+++ b/components/stratos/billing/org.apache.stratos.billing.core/2.1.3/src/test/java/org/wso2/carbon/billing/test/TriggerTest.java
@@ -0,0 +1,226 @@
+/*
+ * Copyright (c) 2008, WSO2 Inc. (http://www.wso2.org) 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 org.wso2.carbon.billing.test;
+
+import junit.framework.TestCase;
+import org.wso2.carbon.billing.core.BillingEngine;
+import org.wso2.carbon.billing.core.BillingException;
+import org.wso2.carbon.billing.core.BillingManager;
+import org.wso2.carbon.billing.core.conf.BillingConfiguration;
+import org.wso2.carbon.billing.core.dataobjects.*;
+import org.wso2.carbon.utils.CarbonUtils;
+
+import javax.sql.DataSource;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.List;
+
+public class TriggerTest extends TestCase {
+    private static final String BILLING_CONFIG = "billing-config.xml";
+    private static final String SELLER_ID = "carbonHome2TestShop";
+    private BillingEngine billingEngine;
+
+    public void setUp() throws Exception {
+        /*RuleServerManager ruleServerManager = new RuleServerManager();
+        RuleServerConfiguration configuration = new RuleServerConfiguration(new JSR94BackendRuntimeFactory());
+        ruleServerManager.init(configuration);
+        Util.setRuleEngineConfigService(ruleServerManager);
+
+        String carbonHome = "src/test/resources/carbonhome2";
+        System.setProperty("carbon.home", carbonHome);
+        System.setProperty("carbon.config.dir.path", carbonHome + "/repository/conf");
+
+        SessionDescription sessionDescription = new SessionDescription();
+        sessionDescription.setSessionType(SessionDescription.STATEFUL_SESSION);
+        ruleServerManager = new RuleServerManager();// TODO to get from a OSGI service
+        configuration = new RuleServerConfiguration(new JSR94BackendRuntimeFactory());
+        ruleServerManager.init(configuration);
+
+        Util.setRuleEngineConfigService(ruleServerManager);
+        */
+
+        String configFile = CarbonUtils.getCarbonConfigDirPath() + "/" + BILLING_CONFIG;
+        BillingConfiguration billingConfiguration = new BillingConfiguration(configFile);
+
+        DataSource dataSource = billingConfiguration.getDataSource();
+        assertNotNull("data should be not null", dataSource);
+        try {
+            if (BillingManager.getInstance() != null) {
+                BillingManager.destroyInstance();
+            }
+        } catch (Exception e) {
+
+        }
+        BillingManager billingManager = new BillingManager(billingConfiguration);
+        //billingManager.scheduleBilling();
+        billingEngine = billingManager.getBillingEngine(SELLER_ID);
+    }
+
+    public void testEngine() throws BillingException {
+        TestUtils.deleteAllTables();
+        // first enter some items
+        String[] itemNames = {"item-1", "item-2", "item-3", "item-4", "item-5", "item-6", "item-7", "item-8"};
+        Cash[] itemCosts = {new Cash("$1.2"), new Cash("$2.12"), new Cash("$3.24"), new Cash("$4.34"),
+                new Cash("$5.82"), new Cash("$6.92"), new Cash("$7.11"), new Cash("$8.01")};
+        List<Item> items = new ArrayList<Item>();
+        boolean succeeded = false;
+        try {
+            billingEngine.beginTransaction();
+            for (int i = 0; i < Math.min(itemNames.length, itemCosts.length); i++) {
+                String itemName = itemNames[i];
+                Cash itemCost = itemCosts[i];
+                Item item = new Item();
+                item.setName(itemName);
+                item.setCost(itemCost);
+                List<Item> existingItems = billingEngine.getItemsWithName(itemName);
+                for (Item existingItem : existingItems) {
+                    //billingEngine.deleteItem(existingItem.getId());
+                }
+                billingEngine.addItem(item);
+                items.add(item);
+            }
+            succeeded = true;
+        } finally {
+            if (succeeded) {
+                billingEngine.commitTransaction();
+            } else {
+                billingEngine.rollbackTransaction();
+            }
+        }
+
+        String[] customerNames = {"customer-1", "customer-2", "customer-3", "customer-4", "customer-5", "customer-6"};
+        List<Customer> customers = new ArrayList<Customer>();
+        succeeded = false;
+        try {
+            billingEngine.beginTransaction();
+            for (String customerName : customerNames) {
+                Customer customer = new Customer();
+                customer.setName(customerName);
+
+                List<Customer> existingCustomers = billingEngine.getCustomersWithName(customerName);
+                for (Customer existingCustomer : existingCustomers) {
+                    //billingEngine.deleteCustomer(existingCustomer.getId());
+                }
+
+                //billingEngine.addCustomer(customer);
+                customers.add(customer);
+            }
+            succeeded = true;
+        } finally {
+            if (succeeded) {
+                billingEngine.commitTransaction();
+            } else {
+                billingEngine.rollbackTransaction();
+            }
+        }
+
+        // adding the subscriptions
+        List<Subscription> subscriptions = new ArrayList<Subscription>();
+        succeeded = false;
+        try {
+            billingEngine.beginTransaction();
+            // first we clean the subscription table
+
+            int[] subIdToItemId = {0, 3, 2, 1, 4, 7, 6, 5, 2, 3, 1, 1, 4, 6, 5, 0};
+            int[] subIdToCustomerId = {0, 3, 2, 1, 4, 1, 0, 5, 2, 3, 1, 1, 4, 0, 5, 0};
+            String[] payment1 = {"$0.5", "$3.2", "$2", "$1.8", "$4", "1", "0.8",
+                    "$5", "$2", "$3.2", "$1", "$1.2", "$4", "0.2", "$5", "$0.2"};
+            String[] payment2 = {"$5", "$2", "$3.2", "$1", "$1.2", "$4", "0.2",
+                    "$5", "$0.2", "$0.5", "$3.2", "$2", "$1.8", "$4", "1", "0.8"};
+
+            // then get some customers subscribed to items
+            Calendar calendarToStart = Calendar.getInstance();
+            calendarToStart.set(Calendar.YEAR, 2010);
+            calendarToStart.set(Calendar.MONTH, Calendar.JANUARY);
+            calendarToStart.set(Calendar.DAY_OF_MONTH, 20);
+            calendarToStart.set(Calendar.HOUR_OF_DAY, 12);
+            calendarToStart.set(Calendar.MINUTE, 10);
+            calendarToStart.set(Calendar.SECOND, 20);
+            long timestampToStart = calendarToStart.getTimeInMillis();
+            for (int i = 0; i < 15; i++) {
+                long startTime = (10000 * i) % 60000 + timestampToStart;
+                long duration = (5000 * i) % 40000;
+                long endTime = startTime + duration;
+                Customer customer = customers.get(subIdToCustomerId[i]);
+                Item item = items.get(subIdToItemId[i]);
+                Subscription subscription = new Subscription();
+                subscription.setCustomer(customer);
+                subscription.setItem(item);
+                subscription.setActive(true);
+
+                subscription.setActiveSince(new Date(startTime));
+                subscription.setActiveUntil(new Date(endTime));
+
+                billingEngine.addSubscription(subscription);
+                subscriptions.add(subscription);
+
+                // adding purchase order - purchase order1
+                Payment purchaseOrder1 = new Payment();
+                purchaseOrder1.addSubscription(subscription);
+                purchaseOrder1.setAmount(new Cash(payment1[i]));
+                billingEngine.addPayment(purchaseOrder1);
+
+                // adding purchase order - purchase order1
+                Payment purchaseOrder2 = new Payment();
+                purchaseOrder2.addSubscription(subscription);
+                purchaseOrder2.setAmount(new Cash(payment2[i]));
+                billingEngine.addPayment(purchaseOrder2);
+            }
+
+            succeeded = true;
+
+        } finally {
+            if (succeeded) {
+                billingEngine.commitTransaction();
+            } else {
+                billingEngine.rollbackTransaction();
+            }
+        }
+
+        //billingEngine.generateBill();
+        // instead of calling the billing engine we are triggering the scheduler
+        billingEngine.scheduleBilling();
+
+        // now get the invoice of each customers
+        Cash[] totalCosts = {new Cash("$0.20"), new Cash("$2.12"), new Cash("$3.24"),
+                new Cash("$4.34"), new Cash("$5.82"), new Cash("$6.92")};
+        Cash[] totalPayments = {new Cash("$5.50"), new Cash("$2.80"), new Cash("$5.20"),
+                new Cash("$5.20"), new Cash("$5.20"), new Cash("$10.00")};
+        Cash[] carriedForward = {new Cash("$-4.30"), new Cash("$-0.68"), new Cash("$-1.96"),
+                new Cash("$-0.86"), new Cash("$0.62"), new Cash("$-3.08")};
+
+        assertEquals(6, customers.size());
+        try {
+            Thread.currentThread().sleep(14000);
+        } catch (InterruptedException e) {
+            assertTrue(false);
+        }
+        assertEquals(2, FiveSecondTriggerTester.getCount());
+
+        for (int i = 0; i < customers.size(); i++) {
+
+            Customer customer = customers.get(i);
+            List<Invoice> invoices = billingEngine.getAllInvoices(customer);
+            assertEquals(1, invoices.size());
+            Invoice invoice = invoices.get(0);
+            //Invoice invoice = billingEngine.getLastInvoice(customer);
+            assertEquals(totalCosts[i], invoice.getTotalCost());
+            assertEquals(totalPayments[i], invoice.getTotalPayment());
+            assertEquals(carriedForward[i], invoice.getCarriedForward());
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/ee2ab783/components/stratos/billing/org.apache.stratos.billing.core/2.1.3/src/test/resources/carbonhome1/repository/conf/billing-config.xml
----------------------------------------------------------------------
diff --git a/components/stratos/billing/org.apache.stratos.billing.core/2.1.3/src/test/resources/carbonhome1/repository/conf/billing-config.xml b/components/stratos/billing/org.apache.stratos.billing.core/2.1.3/src/test/resources/carbonhome1/repository/conf/billing-config.xml
new file mode 100644
index 0000000..af722bd
--- /dev/null
+++ b/components/stratos/billing/org.apache.stratos.billing.core/2.1.3/src/test/resources/carbonhome1/repository/conf/billing-config.xml
@@ -0,0 +1,83 @@
+<!--
+ ~ Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ ~
+ ~ WSO2 Inc. licenses this file to you 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.
+ -->
+<billingConfig xmlns="http://wso2.com/carbon/multitenancy/billing/config">
+    <dbConfig>
+        <url>jdbc:mysql://localhost:3306/billing_test1</url>
+        <userName>billing</userName>
+        <password>billing</password>
+        <driverName>com.mysql.jdbc.Driver</driverName>
+        <maxActive>80</maxActive>
+        <maxWait>60000</maxWait>
+        <minIdle>5</minIdle>
+    </dbConfig>
+    <tasks>
+        <task id="carbonHome1TestShop">
+            <subscriptionFilter>multitenancy</subscriptionFilter>
+            <schedule
+                    scheduleHelperClass="org.wso2.carbon.billing.core.scheduler.scheduleHelpers.OneTimeScheduleHelper">
+                <parameter name="dayToTriggerOn">1</parameter>
+                <parameter name="hourToTriggerOn">0</parameter>
+                <parameter name="timeZone">GMT-8:00</parameter>
+            </schedule>
+            <handlers>
+                <handler
+                        class="org.wso2.carbon.billing.core.handlers.DefaultSubscriptionFeedingHandler">
+                </handler>
+                <handler
+                        class="org.wso2.carbon.billing.core.handlers.SubscriptionTreeBuildingHandler">
+                </handler>
+                <!--<handler class="org.wso2.carbon.billing.core.handlers.RuleHandler">
+                    <parameter name="file">multitenancy-billing-rule.xml</parameter>
+                </handler> -->
+                <handler class="org.wso2.carbon.billing.core.handlers.InvoiceCalculationHandler">
+                </handler>
+                <handler class="org.wso2.carbon.billing.core.handlers.DefaultFinalizingHandler">
+                </handler>
+            </handlers>
+			<!--
+            <billDelivery>
+                <email config="multitenancy-bill-email-config.xml"/>
+            </billDelivery>
+			-->
+        </task>
+
+        <task id="ruleTestShop">
+            <subscriptionFilter>multitenancy</subscriptionFilter>
+            <handlers>
+                <handler
+                        class="org.wso2.carbon.billing.core.handlers.DefaultSubscriptionFeedingHandler">
+                </handler>
+                <handler
+                        class="org.wso2.carbon.billing.core.handlers.SubscriptionTreeBuildingHandler">
+                </handler>
+                <handler class="org.wso2.carbon.billing.core.handlers.InvoiceCalculationHandler">
+                </handler>
+                <handler class="org.wso2.carbon.billing.core.handlers.RuleHandler">
+                    <parameter name="file">billing-rules1.drl</parameter>
+                </handler>
+                <handler class="org.wso2.carbon.billing.core.handlers.DefaultFinalizingHandler">
+                </handler>
+            </handlers>
+			<!--
+            <billDelivery>
+                <email config="multitenancy-bill-email-config.xml"/>
+            </billDelivery>
+			-->
+        </task>
+    </tasks>
+</billingConfig>

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/ee2ab783/components/stratos/billing/org.apache.stratos.billing.core/2.1.3/src/test/resources/carbonhome1/repository/conf/billing-rules1.drl
----------------------------------------------------------------------
diff --git a/components/stratos/billing/org.apache.stratos.billing.core/2.1.3/src/test/resources/carbonhome1/repository/conf/billing-rules1.drl b/components/stratos/billing/org.apache.stratos.billing.core/2.1.3/src/test/resources/carbonhome1/repository/conf/billing-rules1.drl
new file mode 100644
index 0000000..1905308
--- /dev/null
+++ b/components/stratos/billing/org.apache.stratos.billing.core/2.1.3/src/test/resources/carbonhome1/repository/conf/billing-rules1.drl
@@ -0,0 +1,15 @@
+import org.wso2.carbon.billing.core.dataobjects.Customer;
+import org.wso2.carbon.billing.core.dataobjects.Invoice;
+import org.wso2.carbon.billing.core.dataobjects.Cash;
+
+rule customerOneSpecial
+when
+$customer : Customer(name == "customer-1" )
+
+then
+
+Invoice invoice = $customer.getActiveInvoice();
+Cash total = invoice.getTotalCost();
+invoice.setTotalCost(Cash.subtract(total, new Cash("$1")));
+
+end

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/ee2ab783/components/stratos/billing/org.apache.stratos.billing.core/2.1.3/src/test/resources/carbonhome1/repository/conf/email-registration-complete.xml
----------------------------------------------------------------------
diff --git a/components/stratos/billing/org.apache.stratos.billing.core/2.1.3/src/test/resources/carbonhome1/repository/conf/email-registration-complete.xml b/components/stratos/billing/org.apache.stratos.billing.core/2.1.3/src/test/resources/carbonhome1/repository/conf/email-registration-complete.xml
new file mode 100644
index 0000000..c2fcd09
--- /dev/null
+++ b/components/stratos/billing/org.apache.stratos.billing.core/2.1.3/src/test/resources/carbonhome1/repository/conf/email-registration-complete.xml
@@ -0,0 +1,31 @@
+<!--
+ ~ Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ ~
+ ~ WSO2 Inc. licenses this file to you 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.
+ -->
+<configuration>
+    <subject>WSO2 Governance as a Service - Registration completed</subject>
+    <body>
+        Hi {admin-name},
+        Congratulations!. You have successfully crated an account in WSO2 Governance as a Service.
+        Now you can access your account by visiting the following URL. Please bookmark this URL for
+        the later visits.
+
+        Your account url: https://governance.stratoslive.wso2.com/t/{domain-name}
+
+        Thanks,
+        WSO2 Governance as a Service Team
+    </body>
+</configuration>

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/ee2ab783/components/stratos/billing/org.apache.stratos.billing.core/2.1.3/src/test/resources/carbonhome1/repository/conf/email-registration.xml
----------------------------------------------------------------------
diff --git a/components/stratos/billing/org.apache.stratos.billing.core/2.1.3/src/test/resources/carbonhome1/repository/conf/email-registration.xml b/components/stratos/billing/org.apache.stratos.billing.core/2.1.3/src/test/resources/carbonhome1/repository/conf/email-registration.xml
new file mode 100644
index 0000000..3a3f22d
--- /dev/null
+++ b/components/stratos/billing/org.apache.stratos.billing.core/2.1.3/src/test/resources/carbonhome1/repository/conf/email-registration.xml
@@ -0,0 +1,33 @@
+<!--
+ ~ Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ ~
+ ~ WSO2 Inc. licenses this file to you 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.
+ -->
+<configuration>
+    <targetEpr>https://localhost:9443/carbon/email-verification/validator_ajaxprocessor.jsp
+    </targetEpr>
+    <subject>WSO2 Governance as a Service - Registration confirmation</subject>
+    <body>
+        Hi,
+        Thank you for registering for an account in WSO2 Governance as a Service. In order to
+        activate your account, Please click the following link and verfiy your email.
+    </body>
+    <footer>
+        Thanks,
+        WSO2 Governance Team
+        http://governance.stratoslive.wso2.com
+    </footer>
+    <redirectPath>../tenant-register/tenant_add_ajaxprocessor.jsp</redirectPath>
+</configuration>

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/ee2ab783/components/stratos/billing/org.apache.stratos.billing.core/2.1.3/src/test/resources/carbonhome1/repository/conf/email-update.xml
----------------------------------------------------------------------
diff --git a/components/stratos/billing/org.apache.stratos.billing.core/2.1.3/src/test/resources/carbonhome1/repository/conf/email-update.xml b/components/stratos/billing/org.apache.stratos.billing.core/2.1.3/src/test/resources/carbonhome1/repository/conf/email-update.xml
new file mode 100644
index 0000000..3f3b8ea
--- /dev/null
+++ b/components/stratos/billing/org.apache.stratos.billing.core/2.1.3/src/test/resources/carbonhome1/repository/conf/email-update.xml
@@ -0,0 +1,34 @@
+<!--
+ ~ Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ ~
+ ~ WSO2 Inc. licenses this file to you 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.
+ -->
+<configuration>
+    <targetEpr>https://localhost:9443/carbon/email-verification/validator_ajaxprocessor.jsp
+    </targetEpr>
+    <subject>WSO2 Governance as a Service - Updating the contact email address</subject>
+    <body>
+        Hi,
+        We got a request to change the contact email address of WSO2 Governance as a Service
+        account. In order to update the contact details, Please click the following link and verfiy
+        your email address.
+    </body>
+    <footer>
+        Thanks,
+        WSO2 Governance Team
+        http://governance.stratoslive.wso2.com
+    </footer>
+    <redirectPath>../account-mgt/update_verifier.jsp</redirectPath>
+</configuration>

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/ee2ab783/components/stratos/billing/org.apache.stratos.billing.core/2.1.3/src/test/resources/carbonhome1/repository/conf/multitenancy-billing-rule.xml
----------------------------------------------------------------------
diff --git a/components/stratos/billing/org.apache.stratos.billing.core/2.1.3/src/test/resources/carbonhome1/repository/conf/multitenancy-billing-rule.xml b/components/stratos/billing/org.apache.stratos.billing.core/2.1.3/src/test/resources/carbonhome1/repository/conf/multitenancy-billing-rule.xml
new file mode 100644
index 0000000..3bde368
--- /dev/null
+++ b/components/stratos/billing/org.apache.stratos.billing.core/2.1.3/src/test/resources/carbonhome1/repository/conf/multitenancy-billing-rule.xml
@@ -0,0 +1,41 @@
+<!--
+ ~ Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ ~
+ ~ WSO2 Inc. licenses this file to you 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.
+ -->
+<configuration xmlns="http://www.wso2.org/products/rule/drools">
+    <executionSet uri="simpleItemRuleXML">
+        <source key="file:{conf-dir}/billing-rules1.drl"/>
+
+        <!-- <source>
+
+       <x><![CDATA[
+        rule InvokeABC
+        // rules inbuilt to the rule conf
+        end
+
+        ]]>
+       </x>
+       </source> -->
+        <creation>
+            <property name="source" value="drl"/>
+
+        </creation>
+    </executionSet>
+    <session type="stateless"/>
+    <input name="facts" type="billing" key="dataContext"></input>
+
+    <output name="results" type="billing" key="dataContext"></output>
+</configuration>

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/ee2ab783/components/stratos/billing/org.apache.stratos.billing.core/2.1.3/src/test/resources/carbonhome1/repository/conf/multitenancy-packages.xml
----------------------------------------------------------------------
diff --git a/components/stratos/billing/org.apache.stratos.billing.core/2.1.3/src/test/resources/carbonhome1/repository/conf/multitenancy-packages.xml b/components/stratos/billing/org.apache.stratos.billing.core/2.1.3/src/test/resources/carbonhome1/repository/conf/multitenancy-packages.xml
new file mode 100644
index 0000000..7dc9d8b
--- /dev/null
+++ b/components/stratos/billing/org.apache.stratos.billing.core/2.1.3/src/test/resources/carbonhome1/repository/conf/multitenancy-packages.xml
@@ -0,0 +1,88 @@
+<!--
+ ~ Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ ~
+ ~ WSO2 Inc. licenses this file to you 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.
+ -->
+<packages xmlns="http://wso2.com/carbon/multitenancy/billing/pacakges">
+    <package name="Demo">
+        <users>
+            <limit>5</limit>
+            <charge>0</charge>
+            <!-- $ per user per month -->
+        </users>
+        <resourceVolume>
+            <limit>10</limit>
+            <!--mb per user -->
+        </resourceVolum>
+        <bandwidth>
+            <limit>1000</limit>
+            <!-- mb per user -->
+            <overuseCharge>0</overuseCharse>
+            <!-- $ per user per month -->
+        </bandwidth>
+    </package>
+    <package name="SMB">
+        <users>
+            <limit>10</limit>
+            <charge>10</charge>
+            <!-- $ per user per month -->
+        </users>
+        <resourceVolume>
+            <limit>25</limit>
+            <!--mb per user -->
+        </resourceVolum>
+        <bandwidth>
+            <limit>2000</limit>
+            <!-- mb per user -->
+            <overuseCharge>.1</overuseCharse>
+            <!-- $ per user per month -->
+        </bandwidth>
+        <userLimit>10</userLimit>
+    </package>
+    <package name="Professional">
+        <users>
+            <limit>50</limit>
+            <charge>50</charge>
+            <!-- $ per user per month -->
+        </users>
+        <resourceVolume>
+            <limit>100</limit>
+            <!--mb per user -->
+        </resourceVolum>
+        <bandwidth>
+            <limit>2000</limit>
+            <!-- mb per user -->
+            <overuseCharge>.1</overuseCharse>
+            <!-- $ per user per month -->
+        </bandwidth>
+    </package>
+    <package name="Enterprise">
+        <users>
+            <limit>unlimited</limit>
+            <charge>5000</charge>
+            <!-- $ per user per month -->
+        </users>
+        <resourceVolume>
+            <limit>100</limit>
+            <!--mb per user -->
+        </resourceVolum>
+        <bandwidth>
+            <limit>4000</limit>
+            <!-- mb per user -->
+            <overuseCharge>.1</overuseCharse>
+            <!-- $ per user per month -->
+        </bandwidth>
+    </package>
+</packages>

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/ee2ab783/components/stratos/billing/org.apache.stratos.billing.core/2.1.3/src/test/resources/carbonhome1/repository/conf/notification.xml
----------------------------------------------------------------------
diff --git a/components/stratos/billing/org.apache.stratos.billing.core/2.1.3/src/test/resources/carbonhome1/repository/conf/notification.xml b/components/stratos/billing/org.apache.stratos.billing.core/2.1.3/src/test/resources/carbonhome1/repository/conf/notification.xml
new file mode 100644
index 0000000..25e09e8
--- /dev/null
+++ b/components/stratos/billing/org.apache.stratos.billing.core/2.1.3/src/test/resources/carbonhome1/repository/conf/notification.xml
@@ -0,0 +1,23 @@
+<!--
+ ~ Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ ~
+ ~ WSO2 Inc. licenses this file to you 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.
+ -->
+<!-- configure the notifications -->
+<Notifications>
+    <enabled>true</enabled>
+    <host>http://localhost/feed.xml?product={product}&amp;build={build}&amp;instance={instance.id}&amp;tenant={tenant}</host>
+</Notifications>
+

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/ee2ab783/components/stratos/billing/org.apache.stratos.billing.core/2.1.3/src/test/resources/carbonhome2/repository/conf/billing-config.xml
----------------------------------------------------------------------
diff --git a/components/stratos/billing/org.apache.stratos.billing.core/2.1.3/src/test/resources/carbonhome2/repository/conf/billing-config.xml b/components/stratos/billing/org.apache.stratos.billing.core/2.1.3/src/test/resources/carbonhome2/repository/conf/billing-config.xml
new file mode 100644
index 0000000..abd2f55
--- /dev/null
+++ b/components/stratos/billing/org.apache.stratos.billing.core/2.1.3/src/test/resources/carbonhome2/repository/conf/billing-config.xml
@@ -0,0 +1,86 @@
+<!--
+ ~ Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ ~
+ ~ WSO2 Inc. licenses this file to you 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.
+ -->
+<billingConfig xmlns="http://wso2.com/carbon/multitenancy/billing/config">
+    <dbConfig>
+        <url>jdbc:mysql://localhost:3306/billing_test1</url>
+        <userName>billing</userName>
+        <password>billing</password>
+        <driverName>com.mysql.jdbc.Driver</driverName>
+        <maxActive>80</maxActive>
+        <maxWait>60000</maxWait>
+        <minIdle>5</minIdle>
+    </dbConfig>
+    <tasks>
+        <task id="carbonHome2TestShop">
+            <subscriptionFilter>multitenancy</subscriptionFilter>
+            <schedule
+                    scheduleHelperClass="org.wso2.carbon.billing.test.FiveSecondTriggerCalculator">
+                <parameter name="countUpToLimit">2</parameter>
+            </schedule>
+            <handlers>
+                <handler
+                        class="org.wso2.carbon.billing.core.handlers.DefaultSubscriptionFeedingHandler">
+                </handler>
+                <handler
+                        class="org.wso2.carbon.billing.core.handlers.SubscriptionTreeBuildingHandler">
+                </handler>
+                <!--<handler class="org.wso2.carbon.billing.core.handlers.RuleHandler">
+                    <parameter name="file">multitenancy-billing-rule.xml</parameter>
+                </handler> -->
+                <handler class="org.wso2.carbon.billing.core.handlers.InvoiceCalculationHandler">
+                </handler>
+                <handler class="org.wso2.carbon.billing.core.handlers.RuleHandler">
+                    <parameter name="file">billing-rules1.drl</parameter>
+                </handler>
+                <handler class="org.wso2.carbon.billing.core.handlers.DefaultFinalizingHandler">
+                </handler>
+                <handler class="org.wso2.carbon.billing.test.FiveSecondTriggerTester">
+                </handler>
+            </handlers>
+			<!--
+            <billDelivery>
+                <email config="multitenancy-bill-email-config.xml"/>
+            </billDelivery>
+			-->
+        </task>
+
+        <task id="ruleTestShop">
+            <subscriptionFilter>multitenancy</subscriptionFilter>
+            <handlers>
+                <handler
+                        class="org.wso2.carbon.billing.core.handlers.DefaultSubscriptionFeedingHandler">
+                </handler>
+                <handler
+                        class="org.wso2.carbon.billing.core.handlers.SubscriptionTreeBuildingHandler">
+                </handler>
+                <handler class="org.wso2.carbon.billing.core.handlers.InvoiceCalculationHandler">
+                </handler>
+                <handler class="org.wso2.carbon.billing.core.handlers.RuleHandler">
+                    <parameter name="file">billing-rules1.drl</parameter>
+                </handler>
+                <handler class="org.wso2.carbon.billing.core.handlers.DefaultFinalizingHandler">
+                </handler>
+            </handlers>
+			<!--
+            <billDelivery>
+                <email config="multitenancy-bill-email-config.xml"/>
+            </billDelivery>
+			-->
+        </task>
+    </tasks>
+</billingConfig>

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/ee2ab783/components/stratos/billing/org.apache.stratos.billing.core/2.1.3/src/test/resources/carbonhome2/repository/conf/billing-rules1.drl
----------------------------------------------------------------------
diff --git a/components/stratos/billing/org.apache.stratos.billing.core/2.1.3/src/test/resources/carbonhome2/repository/conf/billing-rules1.drl b/components/stratos/billing/org.apache.stratos.billing.core/2.1.3/src/test/resources/carbonhome2/repository/conf/billing-rules1.drl
new file mode 100644
index 0000000..1905308
--- /dev/null
+++ b/components/stratos/billing/org.apache.stratos.billing.core/2.1.3/src/test/resources/carbonhome2/repository/conf/billing-rules1.drl
@@ -0,0 +1,15 @@
+import org.wso2.carbon.billing.core.dataobjects.Customer;
+import org.wso2.carbon.billing.core.dataobjects.Invoice;
+import org.wso2.carbon.billing.core.dataobjects.Cash;
+
+rule customerOneSpecial
+when
+$customer : Customer(name == "customer-1" )
+
+then
+
+Invoice invoice = $customer.getActiveInvoice();
+Cash total = invoice.getTotalCost();
+invoice.setTotalCost(Cash.subtract(total, new Cash("$1")));
+
+end

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/ee2ab783/components/stratos/billing/org.apache.stratos.billing.core/2.1.3/src/test/resources/carbonhome2/repository/conf/email-registration-complete.xml
----------------------------------------------------------------------
diff --git a/components/stratos/billing/org.apache.stratos.billing.core/2.1.3/src/test/resources/carbonhome2/repository/conf/email-registration-complete.xml b/components/stratos/billing/org.apache.stratos.billing.core/2.1.3/src/test/resources/carbonhome2/repository/conf/email-registration-complete.xml
new file mode 100644
index 0000000..c2fcd09
--- /dev/null
+++ b/components/stratos/billing/org.apache.stratos.billing.core/2.1.3/src/test/resources/carbonhome2/repository/conf/email-registration-complete.xml
@@ -0,0 +1,31 @@
+<!--
+ ~ Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ ~
+ ~ WSO2 Inc. licenses this file to you 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.
+ -->
+<configuration>
+    <subject>WSO2 Governance as a Service - Registration completed</subject>
+    <body>
+        Hi {admin-name},
+        Congratulations!. You have successfully crated an account in WSO2 Governance as a Service.
+        Now you can access your account by visiting the following URL. Please bookmark this URL for
+        the later visits.
+
+        Your account url: https://governance.stratoslive.wso2.com/t/{domain-name}
+
+        Thanks,
+        WSO2 Governance as a Service Team
+    </body>
+</configuration>

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/ee2ab783/components/stratos/billing/org.apache.stratos.billing.core/2.1.3/src/test/resources/carbonhome2/repository/conf/email-registration.xml
----------------------------------------------------------------------
diff --git a/components/stratos/billing/org.apache.stratos.billing.core/2.1.3/src/test/resources/carbonhome2/repository/conf/email-registration.xml b/components/stratos/billing/org.apache.stratos.billing.core/2.1.3/src/test/resources/carbonhome2/repository/conf/email-registration.xml
new file mode 100644
index 0000000..3a3f22d
--- /dev/null
+++ b/components/stratos/billing/org.apache.stratos.billing.core/2.1.3/src/test/resources/carbonhome2/repository/conf/email-registration.xml
@@ -0,0 +1,33 @@
+<!--
+ ~ Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ ~
+ ~ WSO2 Inc. licenses this file to you 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.
+ -->
+<configuration>
+    <targetEpr>https://localhost:9443/carbon/email-verification/validator_ajaxprocessor.jsp
+    </targetEpr>
+    <subject>WSO2 Governance as a Service - Registration confirmation</subject>
+    <body>
+        Hi,
+        Thank you for registering for an account in WSO2 Governance as a Service. In order to
+        activate your account, Please click the following link and verfiy your email.
+    </body>
+    <footer>
+        Thanks,
+        WSO2 Governance Team
+        http://governance.stratoslive.wso2.com
+    </footer>
+    <redirectPath>../tenant-register/tenant_add_ajaxprocessor.jsp</redirectPath>
+</configuration>

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/ee2ab783/components/stratos/billing/org.apache.stratos.billing.core/2.1.3/src/test/resources/carbonhome2/repository/conf/email-update.xml
----------------------------------------------------------------------
diff --git a/components/stratos/billing/org.apache.stratos.billing.core/2.1.3/src/test/resources/carbonhome2/repository/conf/email-update.xml b/components/stratos/billing/org.apache.stratos.billing.core/2.1.3/src/test/resources/carbonhome2/repository/conf/email-update.xml
new file mode 100644
index 0000000..3f3b8ea
--- /dev/null
+++ b/components/stratos/billing/org.apache.stratos.billing.core/2.1.3/src/test/resources/carbonhome2/repository/conf/email-update.xml
@@ -0,0 +1,34 @@
+<!--
+ ~ Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ ~
+ ~ WSO2 Inc. licenses this file to you 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.
+ -->
+<configuration>
+    <targetEpr>https://localhost:9443/carbon/email-verification/validator_ajaxprocessor.jsp
+    </targetEpr>
+    <subject>WSO2 Governance as a Service - Updating the contact email address</subject>
+    <body>
+        Hi,
+        We got a request to change the contact email address of WSO2 Governance as a Service
+        account. In order to update the contact details, Please click the following link and verfiy
+        your email address.
+    </body>
+    <footer>
+        Thanks,
+        WSO2 Governance Team
+        http://governance.stratoslive.wso2.com
+    </footer>
+    <redirectPath>../account-mgt/update_verifier.jsp</redirectPath>
+</configuration>

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/ee2ab783/components/stratos/billing/org.apache.stratos.billing.core/2.1.3/src/test/resources/carbonhome2/repository/conf/multitenancy-billing-rule.xml
----------------------------------------------------------------------
diff --git a/components/stratos/billing/org.apache.stratos.billing.core/2.1.3/src/test/resources/carbonhome2/repository/conf/multitenancy-billing-rule.xml b/components/stratos/billing/org.apache.stratos.billing.core/2.1.3/src/test/resources/carbonhome2/repository/conf/multitenancy-billing-rule.xml
new file mode 100644
index 0000000..3bde368
--- /dev/null
+++ b/components/stratos/billing/org.apache.stratos.billing.core/2.1.3/src/test/resources/carbonhome2/repository/conf/multitenancy-billing-rule.xml
@@ -0,0 +1,41 @@
+<!--
+ ~ Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ ~
+ ~ WSO2 Inc. licenses this file to you 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.
+ -->
+<configuration xmlns="http://www.wso2.org/products/rule/drools">
+    <executionSet uri="simpleItemRuleXML">
+        <source key="file:{conf-dir}/billing-rules1.drl"/>
+
+        <!-- <source>
+
+       <x><![CDATA[
+        rule InvokeABC
+        // rules inbuilt to the rule conf
+        end
+
+        ]]>
+       </x>
+       </source> -->
+        <creation>
+            <property name="source" value="drl"/>
+
+        </creation>
+    </executionSet>
+    <session type="stateless"/>
+    <input name="facts" type="billing" key="dataContext"></input>
+
+    <output name="results" type="billing" key="dataContext"></output>
+</configuration>

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/ee2ab783/components/stratos/billing/org.apache.stratos.billing.core/2.1.3/src/test/resources/carbonhome2/repository/conf/multitenancy-packages.xml
----------------------------------------------------------------------
diff --git a/components/stratos/billing/org.apache.stratos.billing.core/2.1.3/src/test/resources/carbonhome2/repository/conf/multitenancy-packages.xml b/components/stratos/billing/org.apache.stratos.billing.core/2.1.3/src/test/resources/carbonhome2/repository/conf/multitenancy-packages.xml
new file mode 100644
index 0000000..0239204
--- /dev/null
+++ b/components/stratos/billing/org.apache.stratos.billing.core/2.1.3/src/test/resources/carbonhome2/repository/conf/multitenancy-packages.xml
@@ -0,0 +1,88 @@
+<!--
+ ~ Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ ~
+ ~ WSO2 Inc. licenses this file to you 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.
+ -->
+<packages xmlns="http://wso2.com/carbon/multitenancy/billing/pacakges">
+    <package name="multitenancy-free">
+        <users>
+            <limit>5</limit>
+            <charge>0</charge>
+            <!-- $ per user per month -->
+        </users>
+        <resourceVolume>
+            <limit>10</limit>
+            <!--mb per user -->
+        </resourceVolum>
+        <bandwidth>
+            <limit>1000</limit>
+            <!-- mb per user -->
+            <overuseCharge>0</overuseCharse>
+            <!-- $ per user per month -->
+        </bandwidth>
+    </package>
+    <package name="multitenancy-small">
+        <users>
+            <limit>10</limit>
+            <charge>10</charge>
+            <!-- $ per user per month -->
+        </users>
+        <resourceVolume>
+            <limit>25</limit>
+            <!--mb per user -->
+        </resourceVolum>
+        <bandwidth>
+            <limit>2000</limit>
+            <!-- mb per user -->
+            <overuseCharge>.1</overuseCharse>
+            <!-- $ per user per month -->
+        </bandwidth>
+        <userLimit>10</userLimit>
+    </package>
+    <package name="multitenancy-medium">
+        <users>
+            <limit>50</limit>
+            <charge>50</charge>
+            <!-- $ per user per month -->
+        </users>
+        <resourceVolume>
+            <limit>100</limit>
+            <!--mb per user -->
+        </resourceVolum>
+        <bandwidth>
+            <limit>2000</limit>
+            <!-- mb per user -->
+            <overuseCharge>.1</overuseCharse>
+            <!-- $ per user per month -->
+        </bandwidth>
+    </package>
+    <package name="multitenancy-large">
+        <users>
+            <limit>unlimited</limit>
+            <charge>5000</charge>
+            <!-- $ per user per month -->
+        </users>
+        <resourceVolume>
+            <limit>100</limit>
+            <!--mb per user -->
+        </resourceVolum>
+        <bandwidth>
+            <limit>4000</limit>
+            <!-- mb per user -->
+            <overuseCharge>.1</overuseCharse>
+            <!-- $ per user per month -->
+        </bandwidth>
+    </package>
+</packages>

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/ee2ab783/components/stratos/billing/org.apache.stratos.billing.core/2.1.3/src/test/resources/carbonhome2/repository/conf/notification.xml
----------------------------------------------------------------------
diff --git a/components/stratos/billing/org.apache.stratos.billing.core/2.1.3/src/test/resources/carbonhome2/repository/conf/notification.xml b/components/stratos/billing/org.apache.stratos.billing.core/2.1.3/src/test/resources/carbonhome2/repository/conf/notification.xml
new file mode 100644
index 0000000..25e09e8
--- /dev/null
+++ b/components/stratos/billing/org.apache.stratos.billing.core/2.1.3/src/test/resources/carbonhome2/repository/conf/notification.xml
@@ -0,0 +1,23 @@
+<!--
+ ~ Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ ~
+ ~ WSO2 Inc. licenses this file to you 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.
+ -->
+<!-- configure the notifications -->
+<Notifications>
+    <enabled>true</enabled>
+    <host>http://localhost/feed.xml?product={product}&amp;build={build}&amp;instance={instance.id}&amp;tenant={tenant}</host>
+</Notifications>
+

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/ee2ab783/components/stratos/billing/org.apache.stratos.billing.mgt.ui/2.1.0/pom.xml
----------------------------------------------------------------------
diff --git a/components/stratos/billing/org.apache.stratos.billing.mgt.ui/2.1.0/pom.xml b/components/stratos/billing/org.apache.stratos.billing.mgt.ui/2.1.0/pom.xml
new file mode 100644
index 0000000..e2162ab
--- /dev/null
+++ b/components/stratos/billing/org.apache.stratos.billing.mgt.ui/2.1.0/pom.xml
@@ -0,0 +1,117 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+# Copyright (c) 2008, WSO2 Inc. (http://www.wso2.org) 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.
+  -->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <parent>
+        <groupId>org.wso2.carbon</groupId>
+        <artifactId>billing-parent</artifactId>
+        <version>2.1.0</version>
+<relativePath>../../pom.xml</relativePath>
+    </parent>
+
+    <modelVersion>4.0.0</modelVersion>
+    <artifactId>org.wso2.carbon.billing.mgt.ui</artifactId>
+    <version>2.1.0</version>
+    <packaging>bundle</packaging>
+    <name>WSO2 Stratos - Billing - User Interface</name>
+
+    <build>
+
+        <plugins>
+
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                
+                <extensions>true</extensions>
+                <configuration>
+                    <instructions>
+                        <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
+                        <Bundle-Name>${project.artifactId}</Bundle-Name>
+                        <Export-Package>
+                            org.wso2.carbon.billing.mgt.ui.*,
+                        </Export-Package>
+                        <Import-Package>
+                        	org.wso2.carbon.billing.mgt.stub.services.*; version="${carbon.platform.package.import.version.range}",
+                            javax.servlet;version="${imp.pkg.version.javax.servlet}",
+                            javax.servlet.http;version="${imp.pkg.version.javax.servlet}",
+                            !javax.xml.namespace,
+                            javax.xml.namespace; version=0.0.0,                            
+                            org.apache.lucene.*,
+                            *;resolution:=optional
+                        </Import-Package>
+                        <Carbon-Component>UIBundle</Carbon-Component>
+                    </instructions>
+                </configuration>
+            </plugin>
+
+        </plugins>
+    </build>
+
+    <dependencies>
+
+        <dependency>
+            <groupId>org.wso2.carbon</groupId>
+            <artifactId>org.wso2.carbon.registry.common.ui</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.wso2.carbon</groupId>
+            <artifactId>org.wso2.carbon.registry.core</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>commons-logging</groupId>
+            <artifactId>commons-logging</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.eclipse.equinox</groupId>
+            <artifactId>javax.servlet</artifactId>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.axis2.wso2</groupId>
+            <artifactId>axis2</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.ws.commons.axiom.wso2</groupId>
+            <artifactId>axiom</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.wso2.carbon</groupId>
+            <artifactId>org.wso2.carbon.ui</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.wso2.carbon</groupId>
+            <artifactId>org.wso2.carbon.core</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.wso2.carbon</groupId>
+			<artifactId>org.wso2.carbon.billing.mgt.stub</artifactId>
+			<version>4.1.0</version>
+        </dependency>
+        <dependency>
+            <groupId>org.wso2.carbon</groupId>
+            <artifactId>org.wso2.carbon.stratos.common</artifactId>
+        </dependency>
+        <dependency>
+          <groupId>org.json.wso2</groupId>
+          <artifactId>json</artifactId>
+          <version>1.0.0.wso2v1</version>
+        </dependency>
+    </dependencies>
+
+</project>

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/ee2ab783/components/stratos/billing/org.apache.stratos.billing.mgt.ui/2.1.0/src/main/java/org/wso2/carbon/billing/mgt/ui/clients/BillingServiceClient.java
----------------------------------------------------------------------
diff --git a/components/stratos/billing/org.apache.stratos.billing.mgt.ui/2.1.0/src/main/java/org/wso2/carbon/billing/mgt/ui/clients/BillingServiceClient.java b/components/stratos/billing/org.apache.stratos.billing.mgt.ui/2.1.0/src/main/java/org/wso2/carbon/billing/mgt/ui/clients/BillingServiceClient.java
new file mode 100644
index 0000000..82b57fe
--- /dev/null
+++ b/components/stratos/billing/org.apache.stratos.billing.mgt.ui/2.1.0/src/main/java/org/wso2/carbon/billing/mgt/ui/clients/BillingServiceClient.java
@@ -0,0 +1,122 @@
+/*
+*  Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+*
+*  WSO2 Inc. licenses this file to you 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 org.wso2.carbon.billing.mgt.ui.clients;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.client.Options;
+import org.apache.axis2.client.ServiceClient;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.wso2.carbon.CarbonConstants;
+import org.wso2.carbon.billing.mgt.stub.beans.xsd.*;
+import org.wso2.carbon.billing.mgt.stub.services.MultitenancyBillingServiceStub;
+import org.wso2.carbon.registry.core.exceptions.RegistryException;
+import org.wso2.carbon.ui.CarbonUIUtil;
+import org.wso2.carbon.utils.ServerConstants;
+
+import javax.servlet.ServletConfig;
+import javax.servlet.http.HttpSession;
+
+public class BillingServiceClient {
+     private static final Log log = LogFactory.getLog(BillingServiceClient.class);
+
+    private MultitenancyBillingServiceStub stub;
+    private String epr;
+
+    public BillingServiceClient(
+            String cookie, String backendServerURL, ConfigurationContext configContext)
+            throws RegistryException {
+
+        epr = backendServerURL + "MultitenancyBillingService";
+
+        try {
+            stub = new MultitenancyBillingServiceStub(configContext, epr);
+
+            ServiceClient client = stub._getServiceClient();
+            Options option = client.getOptions();
+            option.setManageSession(true);
+            option.setProperty(org.apache.axis2.transport.http.HTTPConstants.COOKIE_STRING, cookie);
+
+        } catch (AxisFault axisFault) {
+            String msg = "Failed to initiate BillingService service client. " + axisFault.getMessage();
+            log.error(msg, axisFault);
+            throw new RegistryException(msg, axisFault);
+        }
+    }
+
+    public BillingServiceClient(ServletConfig config, HttpSession session)
+            throws RegistryException {
+
+        String cookie = (String)session.getAttribute(ServerConstants.ADMIN_SERVICE_COOKIE);
+        String backendServerURL = CarbonUIUtil.getServerURL(config.getServletContext(), session);
+        ConfigurationContext configContext = (ConfigurationContext) config.
+                getServletContext().getAttribute(CarbonConstants.CONFIGURATION_CONTEXT);
+        epr = backendServerURL + "MultitenancyBillingService";
+
+        try {
+            stub = new MultitenancyBillingServiceStub(configContext, epr);
+
+            ServiceClient client = stub._getServiceClient();
+            Options option = client.getOptions();
+            option.setManageSession(true);
+            option.setProperty(org.apache.axis2.transport.http.HTTPConstants.COOKIE_STRING, cookie);
+
+        } catch (AxisFault axisFault) {
+            String msg = "Failed to initiate BillingService service client. " + axisFault.getMessage();
+            log.error(msg, axisFault);
+            throw new RegistryException(msg, axisFault);
+        }
+    }
+
+    public BillingPeriod[] getAvailableBillingPeriods() throws Exception {
+        return stub.getAvailableBillingPeriods();
+    }
+    
+    public BillingPeriod[] getBillingPeriodsBySuperTenant(String tenantDomain) throws Exception {
+        return stub.getAvailableBillingPeriodsBySuperTenant(tenantDomain);
+    }
+
+    public MultitenancyInvoice getPastInvoice(int invoiceId) throws Exception {
+        return stub.getPastInvoice(invoiceId);
+    }
+
+    public MultitenancyInvoice getCurrentInvoice() throws Exception {
+        return stub.getCurrentInvoice();    
+    }
+
+    public int addPayment(Payment payment, String amount) throws Exception{
+        return stub.addPayment(payment, amount);
+    }
+    
+    public int makeAdjustment(Payment payment, String amount) throws Exception {
+        return stub.makeAdjustment(payment, amount);
+    }
+
+    public PaginatedBalanceInfoBean getPaginatedBalanceInfo(int pageNumber) throws Exception {
+        return stub.getPaginatedBalances(pageNumber);    
+    }
+
+    public OutstandingBalanceInfoBean[] getOutstandingBalance(String tenantDomain) throws Exception {
+        return stub.getOutstandingBalance(tenantDomain);
+    }
+    
+    public boolean addDiscount(Discount discount, String tenantDomain) throws Exception {
+        return stub.addDiscount(discount, tenantDomain);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/ee2ab783/components/stratos/billing/org.apache.stratos.billing.mgt.ui/2.1.0/src/main/java/org/wso2/carbon/billing/mgt/ui/utils/BillingUtil.java
----------------------------------------------------------------------
diff --git a/components/stratos/billing/org.apache.stratos.billing.mgt.ui/2.1.0/src/main/java/org/wso2/carbon/billing/mgt/ui/utils/BillingUtil.java b/components/stratos/billing/org.apache.stratos.billing.mgt.ui/2.1.0/src/main/java/org/wso2/carbon/billing/mgt/ui/utils/BillingUtil.java
new file mode 100644
index 0000000..97f4e18
--- /dev/null
+++ b/components/stratos/billing/org.apache.stratos.billing.mgt.ui/2.1.0/src/main/java/org/wso2/carbon/billing/mgt/ui/utils/BillingUtil.java
@@ -0,0 +1,182 @@
+/*
+ *  Copyright (c) 2005-2008, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ *
+ *  WSO2 Inc. licenses this file to you 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 org.wso2.carbon.billing.mgt.ui.utils;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.wso2.carbon.billing.mgt.stub.beans.xsd.*;
+import org.wso2.carbon.billing.mgt.ui.clients.BillingServiceClient;
+import org.wso2.carbon.registry.common.ui.UIException;
+
+import javax.servlet.ServletConfig;
+import javax.servlet.http.HttpSession;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+
+public class BillingUtil {
+    private static final Log log = LogFactory.getLog(BillingUtil.class);
+
+    public static BillingPeriod[] getAvailableBillingPeriods(
+            ServletConfig config, HttpSession session) throws UIException {
+        try {
+            BillingServiceClient serviceClient = new BillingServiceClient(config, session);
+            return serviceClient.getAvailableBillingPeriods();
+        } catch (Exception e) {
+            String msg = "Failed to get available billing periods.";
+            log.error(msg, e);
+            throw new UIException(msg, e);
+        }
+    }
+    
+    public static BillingPeriod[] getAvailableBillingPeriodsBySuperTenant(
+            ServletConfig config, HttpSession session, String tenantDomain) throws UIException {
+
+        try{
+            BillingServiceClient client = new BillingServiceClient(config, session);
+            return client.getBillingPeriodsBySuperTenant(tenantDomain);
+        }catch(Exception e){
+            String msg = "Error occurred while getting available invoice dates for tenant: " +
+                    tenantDomain;
+            log.error(msg, e);
+            throw new UIException(msg, e);
+        }
+    }
+
+    public static String[] getAvailableBillingMonths(ServletConfig config,
+                                 HttpSession session) throws UIException{
+        return getAvailableBillingMonths(getAvailableBillingPeriods(config, session));
+    }
+
+    public static MultitenancyInvoice getPastInvoice(
+            ServletConfig config, HttpSession session, int invoiceId) throws UIException {
+        //int invoiceId = (Integer)session.getAttribute("invoiceId");
+
+        try {
+            BillingServiceClient serviceClient = new BillingServiceClient(config, session);
+            return serviceClient.getPastInvoice(invoiceId);
+        } catch (Exception e) {
+            String msg = "Failed to get past invoice for invoice id:" + invoiceId + ".";
+            log.error(msg, e);
+            throw new UIException(msg, e);
+        }
+    }
+
+    public static MultitenancyInvoice getCurrentInvoice(
+            ServletConfig config, HttpSession session) throws UIException {
+        try {
+            BillingServiceClient serviceClient = new BillingServiceClient(config, session);
+            return serviceClient.getCurrentInvoice();
+        } catch (java.lang.Exception e) {
+            String msg = "Failed to get the current invoice.";
+            log.error(msg, e);
+            throw new UIException(msg, e);
+        }
+    }
+
+    public static String[] getAvailableBillingMonths(BillingPeriod[] billingPeriods){
+
+        if(billingPeriods==null || billingPeriods.length==0){
+            return new String[0];
+        }
+
+        String[] billingMonths = new String[billingPeriods.length];
+        DateFormat yearMonthFormat = new SimpleDateFormat("yyyy-MMM-dd");
+        int index = 0;
+        for(BillingPeriod period : billingPeriods){
+            billingMonths[index++] = yearMonthFormat.format(period.getInvoiceDate());
+        }
+        return billingMonths;
+    }
+
+    public static int addPaymentDetails(ServletConfig config, HttpSession session,
+                                        Payment payment, String amount) throws UIException {
+        try{
+            BillingServiceClient serviceClient = new BillingServiceClient(config, session);
+            return serviceClient.addPayment(payment, amount);
+        }catch (Exception exp){
+            String msg = "Failed to add the payment record " + payment.getDescription();
+            log.error(msg, exp);
+            throw new UIException(msg, exp);
+        }
+    }
+
+    public static int makeAdjustment(ServletConfig config, HttpSession session,
+                                        Payment payment, String amount) throws UIException {
+        try{
+            BillingServiceClient serviceClient = new BillingServiceClient(config, session);
+            return serviceClient.makeAdjustment(payment, amount);
+        }catch (Exception exp){
+            String msg = "Failed to add the payment record " + payment.getDescription();
+            log.error(msg, exp);
+            throw new UIException(msg, exp);
+        }
+    }
+
+    public static PaginatedBalanceInfoBean getPaginatedBalanceInfo(ServletConfig config, HttpSession session,
+                                                                   int pageNumber) throws UIException{
+        try{
+            BillingServiceClient serviceClient = new BillingServiceClient(config, session);
+            return serviceClient.getPaginatedBalanceInfo(pageNumber);
+        }catch (Exception exp){
+            String msg = "Failed to get paginated balance info ";
+            log.error(msg, exp);
+            throw new UIException(msg, exp);
+        }
+    }
+
+    public static OutstandingBalanceInfoBean[] getOutstandingBalance(
+            ServletConfig config, HttpSession session, String tenantDomain) throws UIException{
+        try{
+            BillingServiceClient serviceClient = new BillingServiceClient(config, session);
+            return serviceClient.getOutstandingBalance(tenantDomain);
+        }catch (Exception exp){
+            String msg = "Failed to get balance info for domain: " + tenantDomain;
+            log.error(msg, exp);
+            throw new UIException(msg, exp);
+        }
+    }
+
+    public static boolean addDiscount(
+            ServletConfig config, HttpSession session, Discount discount, String tenantDomain) throws UIException{
+
+        try{
+            BillingServiceClient serviceClient = new BillingServiceClient(config, session);
+            return serviceClient.addDiscount(discount, tenantDomain);
+        }catch (Exception exp){
+            String msg = "Failed to failed to add the discount for tenant: " + discount.getTenantId();
+            log.error(msg, exp);
+            throw new UIException(msg, exp);
+        }
+    }
+
+   /* public static String getModifiedSubscriptionPlan(String plan){
+        if("multitenancy-free".equals(plan)){
+            return StratosConstants.MULTITENANCY_FREE_PLAN;
+        }else if("multitenancy-small".equals(plan)){
+            return StratosConstants.MULTITENANCY_SMALL_PLAN;
+        }else if("multitenancy-medium".equals(plan)){
+            return StratosConstants.MULTITENANCY_MEDIUM_PLAN;
+        }else if("multitenancy-large".equals(plan)){
+            return StratosConstants.MULTITENANCY_LARGE_PLAN;
+        }else{
+            return "Undefined";
+        }
+    }*/
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/ee2ab783/components/stratos/billing/org.apache.stratos.billing.mgt.ui/2.1.0/src/main/resources/META-INF/component.xml
----------------------------------------------------------------------
diff --git a/components/stratos/billing/org.apache.stratos.billing.mgt.ui/2.1.0/src/main/resources/META-INF/component.xml b/components/stratos/billing/org.apache.stratos.billing.mgt.ui/2.1.0/src/main/resources/META-INF/component.xml
new file mode 100644
index 0000000..1b8a348
--- /dev/null
+++ b/components/stratos/billing/org.apache.stratos.billing.mgt.ui/2.1.0/src/main/resources/META-INF/component.xml
@@ -0,0 +1,100 @@
+<!--
+ ~ Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ ~
+ ~ WSO2 Inc. licenses this file to you 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.
+ -->
+<component xmlns="http://products.wso2.org/carbon">
+    <!-- sample menu configuration -->
+    <menus>
+        <menu>
+            <id>multitenancy_billing_menu</id>
+            <i18n-key>billing.menu</i18n-key>
+            <i18n-bundle>org.wso2.carbon.billing.mgt.ui.i18n.Resources</i18n-bundle>
+            <parent-menu></parent-menu>
+            <link>#</link>
+            <region>region4</region>
+            <style-class>home</style-class>
+            <order>23</order>
+            <icon>../services/images/services.gif</icon>
+	        <require-permission>/permission/admin/billing/invoice</require-permission>
+        </menu>
+        <menu>
+            <id>multitenancy_invoice_menu</id>
+            <i18n-key>view.invoice.menu</i18n-key>
+            <i18n-bundle>org.wso2.carbon.billing.mgt.ui.i18n.Resources</i18n-bundle>
+            <parent-menu>multitenancy_billing_menu</parent-menu>
+            <link>../tenant-billing/past_invoice.jsp</link>
+            <region>region4</region>
+            <order>50</order>
+            <style-class>manage</style-class>
+            <icon>../tenant-billing/images/view-invoice.gif</icon>
+            <require-permission>/permission/admin/billing/invoice</require-permission>
+            <require-not-super-tenant>true</require-not-super-tenant>
+        </menu>
+        <menu>
+            <id>multitenancy_balance_menu</id>
+            <i18n-key>view.balance.menu</i18n-key>
+            <i18n-bundle>org.wso2.carbon.billing.mgt.ui.i18n.Resources</i18n-bundle>
+            <parent-menu>multitenancy_billing_menu</parent-menu>
+            <link>../tenant-billing/view_balance.jsp</link>
+            <region>region4</region>
+            <order>51</order>
+            <style-class>manage</style-class>
+            <icon>../tenant-billing/images/view-invoice.gif</icon>
+            <require-permission>/permission/admin/billing/invoice</require-permission>
+            <require-super-tenant>true</require-super-tenant>
+        </menu>
+        <menu>
+            <id>adjustment_menu</id>
+            <i18n-key>adjustment.menu</i18n-key>
+            <i18n-bundle>org.wso2.carbon.billing.mgt.ui.i18n.Resources</i18n-bundle>
+            <parent-menu>multitenancy_billing_menu</parent-menu>
+            <link>../tenant-billing/adjustments.jsp</link>
+            <region>region4</region>
+            <order>52</order>
+            <style-class>manage</style-class>
+            <icon>../tenant-billing/images/view-invoice.gif</icon>
+            <require-permission>/permission/admin/billing/invoice</require-permission>
+            <require-super-tenant>true</require-super-tenant>
+        </menu>
+        <menu>
+            <id>discount_menu</id>
+            <i18n-key>discount.menu</i18n-key>
+            <i18n-bundle>org.wso2.carbon.billing.mgt.ui.i18n.Resources</i18n-bundle>
+            <parent-menu>multitenancy_billing_menu</parent-menu>
+            <link>../tenant-billing/discounts.jsp</link>
+            <region>region4</region>
+            <order>53</order>
+            <style-class>manage</style-class>
+            <icon>../tenant-billing/images/view-invoice.gif</icon>
+            <require-permission>/permission/admin/billing/invoice</require-permission>
+            <require-super-tenant>true</require-super-tenant>
+        </menu>
+        <menu>
+            <id>multitenancy_interim_invoice_menu</id>
+            <i18n-key>interim.invoice</i18n-key>
+            <i18n-bundle>org.wso2.carbon.billing.mgt.ui.i18n.Resources</i18n-bundle>
+            <parent-menu>multitenancy_billing_menu</parent-menu>
+            <link>../tenant-billing/interim_invoice.jsp</link>
+            <region>region4</region>
+            <order>60</order>
+            <style-class>manage</style-class>
+            <icon>../tenant-billing/images/view-invoice.gif</icon>
+            <require-permission>/permission/admin/billing/invoice</require-permission>
+            <require-not-super-tenant>true</require-not-super-tenant>
+        </menu>
+    </menus>
+
+</component>

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/ee2ab783/components/stratos/billing/org.apache.stratos.billing.mgt.ui/2.1.0/src/main/resources/org/wso2/carbon/billing/mgt/ui/i18n/JSResources.properties
----------------------------------------------------------------------
diff --git a/components/stratos/billing/org.apache.stratos.billing.mgt.ui/2.1.0/src/main/resources/org/wso2/carbon/billing/mgt/ui/i18n/JSResources.properties b/components/stratos/billing/org.apache.stratos.billing.mgt.ui/2.1.0/src/main/resources/org/wso2/carbon/billing/mgt/ui/i18n/JSResources.properties
new file mode 100644
index 0000000..bf90999
--- /dev/null
+++ b/components/stratos/billing/org.apache.stratos.billing.mgt.ui/2.1.0/src/main/resources/org/wso2/carbon/billing/mgt/ui/i18n/JSResources.properties
@@ -0,0 +1 @@
+empty=To make sure the js properties file is not empty

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/ee2ab783/components/stratos/billing/org.apache.stratos.billing.mgt.ui/2.1.0/src/main/resources/org/wso2/carbon/billing/mgt/ui/i18n/Resources.properties
----------------------------------------------------------------------
diff --git a/components/stratos/billing/org.apache.stratos.billing.mgt.ui/2.1.0/src/main/resources/org/wso2/carbon/billing/mgt/ui/i18n/Resources.properties b/components/stratos/billing/org.apache.stratos.billing.mgt.ui/2.1.0/src/main/resources/org/wso2/carbon/billing/mgt/ui/i18n/Resources.properties
new file mode 100644
index 0000000..7d0bbbc
--- /dev/null
+++ b/components/stratos/billing/org.apache.stratos.billing.mgt.ui/2.1.0/src/main/resources/org/wso2/carbon/billing/mgt/ui/i18n/Resources.properties
@@ -0,0 +1,52 @@
+view.invoice.menu=Invoices
+view.balance.menu=View Balance
+billing.menu=Billing & Metering
+interim.invoice=Interim Invoice
+view.invoice=View Invoice
+invoice.information=Invoice Information for
+invoice.information.head=Invoice Information
+start.date=Invoice period start date
+end.date=Invoice period end date
+invoice.date=Invoice Date
+invoice.summary=Invoice Summary
+subscription=Subscription
+active.since=Active since
+active.until=Active until
+payment=Payment
+transaction.id=Transaction Id
+payment.id=id
+payment.date=Payment Date
+paid.amount=Paid amount
+charges.subscriptions=Charges for Subscriptions
+payment.details=Payment details
+brought.forward=Brought forward
+carried.forward=Carried forward
+total.cost=Total cost
+total.payments=Total payments
+no.invoice.information=Invoice information not available
+no.invoice.information.details=Invoice information is not available because you have not subscribed to any paid packages.
+no.invoice.at.the.moment=Invoice information is not available yet.
+select.billing.month=Select the month
+select.invoice=Select the Invoice
+invoice=Invoice
+month=Month
+enter.tenant.domain=Enter the Tenant Domain
+this.is.active.subscription=This is your current active subscription
+adjustment.menu=Adjustments
+invoice.adjustments=Invoice Adjustments
+find.invoices=Find Invoices
+adjustment.information=Adjustment Information
+submit=Submit
+cancel=Cancel
+amount=Amount $
+description=Description
+discounts=Discounts
+discount.percentage=Discount Percentage
+discount.start.date=Start Date (YYYY-MM-DD)
+discount.end.date=End Date (YYYY-MM-DD)
+discounts.table.title=Discount Information
+discount.menu=Discounts
+tenant.domain=Tenant Domain
+discount.type=Discount Type
+type.percentage=Percentage
+type.amount=Amount
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/ee2ab783/components/stratos/billing/org.apache.stratos.billing.mgt.ui/2.1.0/src/main/resources/web/tenant-billing/add_discount_ajaxprocessor.jsp
----------------------------------------------------------------------
diff --git a/components/stratos/billing/org.apache.stratos.billing.mgt.ui/2.1.0/src/main/resources/web/tenant-billing/add_discount_ajaxprocessor.jsp b/components/stratos/billing/org.apache.stratos.billing.mgt.ui/2.1.0/src/main/resources/web/tenant-billing/add_discount_ajaxprocessor.jsp
new file mode 100644
index 0000000..3821477
--- /dev/null
+++ b/components/stratos/billing/org.apache.stratos.billing.mgt.ui/2.1.0/src/main/resources/web/tenant-billing/add_discount_ajaxprocessor.jsp
@@ -0,0 +1,66 @@
+<%--
+ ~ Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ ~
+ ~ WSO2 Inc. licenses this file to you 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.
+ --%>
+<%@ page import="org.wso2.carbon.billing.mgt.stub.beans.xsd.Invoice" %>
+<%@ page import="org.wso2.carbon.billing.mgt.stub.beans.xsd.Payment" %>
+<%@ page import="org.wso2.carbon.billing.mgt.ui.utils.BillingUtil" %>
+<%@ page import="java.util.Date" %>
+<%@ page import="org.wso2.carbon.billing.mgt.stub.beans.xsd.Discount" %>
+<%@ page import="java.text.DateFormat" %>
+<%@ page import="java.text.SimpleDateFormat" %>
+<%
+
+    String tenantDomain = request.getParameter("tenantDomain");
+    String percentageStr = request.getParameter("percentage");
+    String amountStr = request.getParameter("amount");
+    String startDateStr = request.getParameter("startDate");
+    String endDateStr = request.getParameter("endDate");
+    String discountType = request.getParameter("discountType");
+
+    Discount discount = new Discount();
+    
+    if("percentage".equals(discountType)){
+        discount.setPercentageType(true);
+        discount.setPercentage(Float.parseFloat(percentageStr));
+    }else if("amount".equals(discountType)){
+        discount.setPercentageType(false);
+        discount.setAmount(Float.parseFloat(amountStr));
+    }
+
+    DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
+    discount.setStartDate(df.parse(startDateStr));
+    if(endDateStr!=null){
+        discount.setEndDate(df.parse(endDateStr));
+    }
+    
+    boolean added = false;
+    try{
+        added = BillingUtil.addDiscount(config, session, discount, tenantDomain);
+    }catch (Exception e){
+        e.printStackTrace();
+    }
+
+    if(added){
+        session.setAttribute("discountAdded", "true");
+    }else{
+        session.setAttribute("discountAdded", "false");
+    }
+
+
+%>
+
+<jsp:forward page="discounts.jsp"/>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/ee2ab783/components/stratos/billing/org.apache.stratos.billing.mgt.ui/2.1.0/src/main/resources/web/tenant-billing/add_payment-ajaxprocessor.jsp
----------------------------------------------------------------------
diff --git a/components/stratos/billing/org.apache.stratos.billing.mgt.ui/2.1.0/src/main/resources/web/tenant-billing/add_payment-ajaxprocessor.jsp b/components/stratos/billing/org.apache.stratos.billing.mgt.ui/2.1.0/src/main/resources/web/tenant-billing/add_payment-ajaxprocessor.jsp
new file mode 100644
index 0000000..25badd8
--- /dev/null
+++ b/components/stratos/billing/org.apache.stratos.billing.mgt.ui/2.1.0/src/main/resources/web/tenant-billing/add_payment-ajaxprocessor.jsp
@@ -0,0 +1,56 @@
+<%--
+ ~ Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ ~
+ ~ WSO2 Inc. licenses this file to you 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.
+ --%>
+<%@page contentType="text/html" pageEncoding="UTF-8"%>
+<%@ page import="org.json.JSONObject" %>
+<%@ page import="org.wso2.carbon.billing.mgt.stub.beans.xsd.Invoice" %>
+<%@ page import="org.wso2.carbon.billing.mgt.stub.beans.xsd.Payment" %>
+<%@ page import="org.wso2.carbon.billing.mgt.ui.utils.BillingUtil" %>
+<%@ page import="java.util.Date" %>
+<%
+    String amount = request.getParameter("amount");
+    String transactionId = request.getParameter("transactionId");
+    String invoiceId = request.getParameter("invoiceId");
+
+    Payment payment = new Payment();
+
+    Invoice invoice = new Invoice();
+    invoice.setId(Integer.parseInt(invoiceId));
+    payment.setInvoice(invoice);
+
+    //We set the transaction id as the description
+    payment.setDescription(transactionId);
+    payment.setDate(new Date(System.currentTimeMillis()));
+
+    try{
+        int paymentId = BillingUtil.addPaymentDetails(config, session, payment, amount);
+
+        JSONObject obj = new JSONObject();
+        obj.put("paymentId", paymentId);
+        if(paymentId>0){
+            obj.put("status", "success");
+            obj.put("amount", amount);
+            obj.put("transactionId", transactionId);
+            obj.put("invoiceId", invoiceId);
+        }else{
+            obj.put("status", "fail");
+        }
+        out.write(obj.toString());
+    }catch (Exception e){
+        e.printStackTrace();
+    }
+%>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/ee2ab783/components/stratos/billing/org.apache.stratos.billing.mgt.ui/2.1.0/src/main/resources/web/tenant-billing/add_registration_payment-ajaxprocessor.jsp
----------------------------------------------------------------------
diff --git a/components/stratos/billing/org.apache.stratos.billing.mgt.ui/2.1.0/src/main/resources/web/tenant-billing/add_registration_payment-ajaxprocessor.jsp b/components/stratos/billing/org.apache.stratos.billing.mgt.ui/2.1.0/src/main/resources/web/tenant-billing/add_registration_payment-ajaxprocessor.jsp
new file mode 100644
index 0000000..987a946
--- /dev/null
+++ b/components/stratos/billing/org.apache.stratos.billing.mgt.ui/2.1.0/src/main/resources/web/tenant-billing/add_registration_payment-ajaxprocessor.jsp
@@ -0,0 +1,79 @@
+<%--
+ ~ Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ ~
+ ~ WSO2 Inc. licenses this file to you 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.
+ --%>
+<%@page contentType="text/html" pageEncoding="UTF-8" %>
+<%@ page import="org.apache.axis2.AxisFault" %>
+<%@ page import="org.apache.axis2.client.Options" %>
+<%@ page import="org.apache.axis2.client.ServiceClient" %>
+<%@ page import="org.apache.axis2.context.ConfigurationContext" %>
+<%@ page import="org.json.JSONObject" %>
+<%@ page import="org.wso2.carbon.CarbonConstants" %>
+<%@ page import="org.wso2.carbon.billing.mgt.stub.beans.xsd.Payment" %>
+<%@ page import="org.wso2.carbon.billing.mgt.stub.services.MultitenancyBillingServiceStub" %>
+<%@ page import="org.wso2.carbon.billing.mgt.ui.utils.BillingUtil" %>
+<%@ page import="org.wso2.carbon.registry.core.exceptions.RegistryException" %>
+<%@ page import="org.wso2.carbon.stratos.common.util.CommonUtil" %>
+<%@ page import="org.wso2.carbon.ui.CarbonUIUtil" %>
+<%@ page import="org.wso2.carbon.utils.CarbonUtils" %>
+<%@ page import="org.wso2.carbon.utils.ServerConstants" %>
+<%@ page import="java.util.Date" %>
+<%
+    String amount = request.getParameter("amount");
+    String usagePlan = request.getParameter("usagePlan");
+    String regDomain = session.getAttribute("regTenantDomain").toString();
+    String transactionId = request.getParameter("transactionId");
+
+    Payment payment = new Payment();
+    payment.setDescription(regDomain + " " + transactionId);
+    payment.setDate(new Date(System.currentTimeMillis()));
+
+    // Stub to call the billing service in order to add the registration payment record. 
+    MultitenancyBillingServiceStub stub;
+    String cookie = (String) session.getAttribute(ServerConstants.ADMIN_SERVICE_COOKIE);
+    String backendServerURL = CarbonUIUtil.getServerURL(config.getServletContext(), session);
+    ConfigurationContext configContext = (ConfigurationContext) config.
+            getServletContext().getAttribute(CarbonConstants.CONFIGURATION_CONTEXT);
+    String epr = backendServerURL + "MultitenancyBillingService";
+    String adminUserName = CommonUtil.getAdminUserName();
+    String adminPassword = CommonUtil.getAdminPassword();
+
+    try {
+        stub = new MultitenancyBillingServiceStub(configContext, epr);
+
+        ServiceClient client = stub._getServiceClient();
+        Options option = client.getOptions();
+        option.setManageSession(true);
+        option.setProperty(org.apache.axis2.transport.http.HTTPConstants.COOKIE_STRING, cookie);
+        CarbonUtils.setBasicAccessSecurityHeaders(adminUserName, adminPassword, client);
+        int paymentId = stub.addRegistrationPayment(payment, amount, usagePlan);
+
+        JSONObject obj = new JSONObject();
+        obj.put("paymentId", paymentId);
+        if (paymentId > 0) {
+            obj.put("status", "success");
+            obj.put("amount", amount);
+        } else {
+            obj.put("status", "fail");
+        }
+        out.write(obj.toString());
+
+    } catch (Exception ex) {
+        String msg = "Failed to initiate BillingService service client. " + ex.getMessage();
+        throw new Exception(msg, ex);
+    }
+
+%>