killbill-aplcache

Changes

beatrix/pom.xml 2(+1 -1)

osgi-bundles/hello/pom.xml 105(+0 -105)

Details

beatrix/pom.xml 2(+1 -1)

diff --git a/beatrix/pom.xml b/beatrix/pom.xml
index 9026ef1..cb9cbe6 100644
--- a/beatrix/pom.xml
+++ b/beatrix/pom.xml
@@ -200,7 +200,7 @@
                         <phase>initialize</phase>
                         <configuration>
                             <tasks>
-                                <copy file="${basedir}/../osgi-bundles/test/target/killbill-osgi-bundles-test-${project.version}-jar-with-dependencies.jar" tofile="${basedir}/src/test/resources/killbill-osgi-bundles-test-${project.version}-jar-with-dependencies.jar"/>
+                                <copy file="${basedir}/../osgi-bundles/tests/test/target/killbill-osgi-bundles-test-${project.version}-jar-with-dependencies.jar" tofile="${basedir}/src/test/resources/killbill-osgi-bundles-test-${project.version}-jar-with-dependencies.jar"/>
                             </tasks>
                         </configuration>
                         <goals>
diff --git a/osgi-bundles/bundles/pom.xml b/osgi-bundles/bundles/pom.xml
new file mode 100644
index 0000000..c8f46ff
--- /dev/null
+++ b/osgi-bundles/bundles/pom.xml
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ Copyright 2010-2013 Ning, Inc.
+  ~
+  ~ Ning 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.
+  -->
+
+<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/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>com.ning.billing</groupId>
+        <artifactId>killbill</artifactId>
+        <version>0.1.56-SNAPSHOT</version>
+        <relativePath>../pom.xml</relativePath>
+    </parent>
+    <artifactId>killbill-osgi-bundles</artifactId>
+    <name>Killbill billing platform: OSGI bundles</name>
+    <packaging>pom</packaging>
+    <modules>
+        <module>jruby</module>
+        <module>meter</module>
+        <module>webconsolebranding</module>
+    </modules>
+</project>
diff --git a/osgi-bundles/libs/pom.xml b/osgi-bundles/libs/pom.xml
new file mode 100644
index 0000000..7614509
--- /dev/null
+++ b/osgi-bundles/libs/pom.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ Copyright 2010-2013 Ning, Inc.
+  ~
+  ~ Ning 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.
+  -->
+
+<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/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>com.ning.billing</groupId>
+        <artifactId>killbill</artifactId>
+        <version>0.1.56-SNAPSHOT</version>
+        <relativePath>../pom.xml</relativePath>
+    </parent>
+    <artifactId>killbill-osgi-lib-bundles</artifactId>
+    <name>Killbill billing platform: OSGI library bundles</name>
+    <packaging>pom</packaging>
+    <modules>
+    </modules>
+</project>
diff --git a/osgi-bundles/pom.xml b/osgi-bundles/pom.xml
index dc984c2..3c5e4f2 100644
--- a/osgi-bundles/pom.xml
+++ b/osgi-bundles/pom.xml
@@ -23,15 +23,13 @@
         <version>0.1.56-SNAPSHOT</version>
         <relativePath>../pom.xml</relativePath>
     </parent>
-    <artifactId>killbill-osgi-bundles</artifactId>
-    <name>Killbill billing platform: OSGI bundles</name>
+    <artifactId>killbill-osgi-all-bundles</artifactId>
+    <name>Killbill billing platform: OSGI ALL bundles</name>
     <packaging>pom</packaging>
     <modules>
-        <module>hello</module>
-        <module>jruby</module>
-        <module>meter</module>
-        <module>test</module>
-        <module>webconsolebranding</module>
+        <module>libs</module>
+        <module>bundles</module>
+        <module>tests</module>
         <module>defaultbundles</module>
     </modules>
 </project>
diff --git a/osgi-bundles/tests/pom.xml b/osgi-bundles/tests/pom.xml
new file mode 100644
index 0000000..83d2509
--- /dev/null
+++ b/osgi-bundles/tests/pom.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ Copyright 2010-2013 Ning, Inc.
+  ~
+  ~ Ning 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.
+  -->
+
+<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/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>com.ning.billing</groupId>
+        <artifactId>killbill</artifactId>
+        <version>0.1.56-SNAPSHOT</version>
+        <relativePath>../pom.xml</relativePath>
+    </parent>
+    <artifactId>killbill-osgi-test-bundles</artifactId>
+    <name>Killbill billing platform: OSGI Test bundles</name>
+    <packaging>pom</packaging>
+    <modules>
+        <module>test</module>
+    </modules>
+</project>
diff --git a/osgi-bundles/tests/src/assemble/assembly.xml b/osgi-bundles/tests/src/assemble/assembly.xml
new file mode 100644
index 0000000..44d5bf3
--- /dev/null
+++ b/osgi-bundles/tests/src/assemble/assembly.xml
@@ -0,0 +1,58 @@
+<!--
+            POM
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-assembly-plugin</artifactId>
+                <version>2.3</version>
+                <configuration>
+                    <tarLongFileMode>gnu</tarLongFileMode>
+                    <appendAssemblyId>false</appendAssemblyId>
+                    <descriptors>
+                        <descriptor>src/assemble/assembly.xml</descriptor>
+                    </descriptors>
+                </configuration>
+                <executions>
+                    <execution>
+                        <id>assemble-bundle-test</id>
+                        <goals>
+                            <goal>single</goal>
+                        </goals>
+                        <phase>package</phase>
+                    </execution>
+                </executions>
+            </plugin>
+
+-->
+<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
+          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+          xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
+    <id>xoxo-test</id>
+    <formats>
+        <format>jar</format>
+    </formats>
+    <includeBaseDirectory>false</includeBaseDirectory>
+
+    <fileSets>
+        <fileSet>
+            <directory>target/classes</directory>
+            <outputDirectory>/</outputDirectory>
+            <fileMode>0755</fileMode>
+        </fileSet>
+    </fileSets>
+
+    <dependencySets>
+        <dependencySet>
+
+            <scope>compile</scope>
+            <outputFileNameMapping>
+                ${artifact.groupId}-${artifact.artifactId}-${artifact.version}${dashClassifier?}.${artifact.extension}
+            </outputFileNameMapping>
+            <useProjectArtifact>false</useProjectArtifact>
+            <outputDirectory>/</outputDirectory>
+            <unpack>true</unpack>
+            <fileMode>0644</fileMode>
+        </dependencySet>
+
+    </dependencySets>
+
+</assembly>
diff --git a/osgi-bundles/tests/test/src/test/java/com/ning/billing/osgi/bundles/test/dao/TestDao.java b/osgi-bundles/tests/test/src/test/java/com/ning/billing/osgi/bundles/test/dao/TestDao.java
new file mode 100644
index 0000000..fe63c4c
--- /dev/null
+++ b/osgi-bundles/tests/test/src/test/java/com/ning/billing/osgi/bundles/test/dao/TestDao.java
@@ -0,0 +1,89 @@
+/*
+ * Copyright 2010-2013 Ning, Inc.
+ *
+ * Ning 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 com.ning.billing.osgi.bundles.test.dao;
+
+
+import java.math.BigDecimal;
+import java.util.UUID;
+
+import org.skife.jdbi.v2.Handle;
+import org.skife.jdbi.v2.IDBI;
+import org.skife.jdbi.v2.TransactionCallback;
+import org.skife.jdbi.v2.TransactionStatus;
+
+public class TestDao {
+
+    private final IDBI dbi;
+
+    public TestDao(final IDBI dbi) {
+        this.dbi = dbi;
+    }
+
+    public void createTable() {
+
+        dbi.inTransaction(new TransactionCallback<Object>() {
+            @Override
+            public Object inTransaction(final Handle conn, final TransactionStatus status) throws Exception {
+                conn.execute("DROP TABLE IF EXISTS test_bundle;");
+                conn.execute("CREATE TABLE test_bundle (" +
+                "record_id int(11) unsigned NOT NULL AUTO_INCREMENT, " +
+                "is_started bool DEFAULT false, " +
+                "is_logged bool DEFAULT false, " +
+                "external_key varchar(128) NULL, " +
+                "payment_id char(36) NULL," +
+                "payment_method_id char(36) NULL," +
+                "payment_amount decimal(10,4) NULL," +
+                "PRIMARY KEY(record_id)" +
+                ");");
+                return null;
+            }
+        });
+    }
+
+    public void insertStarted() {
+        dbi.inTransaction(new TransactionCallback<Object>() {
+            @Override
+            public Object inTransaction(final Handle conn, final TransactionStatus status) throws Exception {
+                conn.execute("INSERT INTO test_bundle (is_started) VALUES (1);");
+                return null;
+            }
+        });
+    }
+
+    public void insertAccountExternalKey(final String externalKey) {
+        dbi.inTransaction(new TransactionCallback<Object>() {
+            @Override
+            public Object inTransaction(final Handle conn, final TransactionStatus status) throws Exception {
+                conn.execute("UPDATE test_bundle SET external_key = '" + externalKey + "' WHERE record_id = 1;");
+                return null;
+            }
+        });
+    }
+
+    public void insertProcessedPayment(final UUID paymentId, final UUID paymentMethodId, final BigDecimal paymentAmount) {
+        dbi.inTransaction(new TransactionCallback<Object>() {
+            @Override
+            public Object inTransaction(final Handle conn, final TransactionStatus status) throws Exception {
+                conn.execute("UPDATE test_bundle SET payment_id = '" + paymentId.toString() +
+                             "', payment_method_id = '" + paymentMethodId.toString() +
+                             "', payment_amount = " + paymentAmount +
+                             " WHERE record_id = 1;");
+                return null;
+            }
+        });
+    }
+}
diff --git a/osgi-bundles/tests/test/src/test/java/com/ning/billing/osgi/bundles/test/Logger.java b/osgi-bundles/tests/test/src/test/java/com/ning/billing/osgi/bundles/test/Logger.java
new file mode 100644
index 0000000..4b85926
--- /dev/null
+++ b/osgi-bundles/tests/test/src/test/java/com/ning/billing/osgi/bundles/test/Logger.java
@@ -0,0 +1,70 @@
+/*
+ * Copyright 2010-2013 Ning, Inc.
+ *
+ * Ning 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 com.ning.billing.osgi.bundles.test;
+
+import javax.annotation.Nullable;
+
+import org.osgi.framework.BundleContext;
+import org.osgi.service.log.LogService;
+import org.osgi.util.tracker.ServiceTracker;
+
+public class Logger {
+
+    // The name of the LogService
+    private static final String LOG_SERVICE_NAME = "org.osgi.service.log.LogService";
+
+    // The ServiceTracker to emit log services
+    private ServiceTracker logTracker;
+
+    public void start(final BundleContext context) {
+        // Track the log service using a ServiceTracker
+        logTracker = new ServiceTracker(context, LOG_SERVICE_NAME, null);
+        logTracker.open();
+    }
+
+    public void close() {
+        if (logTracker != null) {
+            logTracker.close();
+        }
+    }
+
+    public void log(final int level, final String message) {
+        log(level, message, null);
+    }
+
+    public void log(final int level, final String message, @Nullable final Throwable t) {
+        // log using the LogService if available
+        final Object log = logTracker.getService();
+        if (log != null) {
+            if (t == null) {
+                ((LogService) log).log(level, message);
+            } else {
+                ((LogService) log).log(level, message, t);
+            }
+        } else {
+            if (level >= 2) {
+                System.out.println(message);
+            } else {
+                System.err.println(message);
+            }
+
+            if (t != null) {
+                t.printStackTrace(System.err);
+            }
+        }
+    }
+}
diff --git a/osgi-bundles/tests/test/src/test/java/com/ning/billing/osgi/bundles/test/TestPaymentPluginApi.java b/osgi-bundles/tests/test/src/test/java/com/ning/billing/osgi/bundles/test/TestPaymentPluginApi.java
new file mode 100644
index 0000000..6860948
--- /dev/null
+++ b/osgi-bundles/tests/test/src/test/java/com/ning/billing/osgi/bundles/test/TestPaymentPluginApi.java
@@ -0,0 +1,114 @@
+/*
+ * Copyright 2010-2013 Ning, Inc.
+ *
+ * Ning 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 com.ning.billing.osgi.bundles.test;
+
+import java.math.BigDecimal;
+import java.util.List;
+import java.util.UUID;
+
+import org.joda.time.DateTime;
+
+import com.ning.billing.account.api.Account;
+import com.ning.billing.osgi.bundles.test.dao.TestDao;
+import com.ning.billing.payment.api.PaymentMethodPlugin;
+import com.ning.billing.payment.plugin.api.PaymentInfoPlugin;
+import com.ning.billing.payment.plugin.api.PaymentMethodInfoPlugin;
+import com.ning.billing.payment.plugin.api.PaymentPluginApi;
+import com.ning.billing.payment.plugin.api.PaymentPluginApiException;
+import com.ning.billing.payment.plugin.api.RefundInfoPlugin;
+import com.ning.billing.util.callcontext.CallContext;
+import com.ning.billing.util.callcontext.TenantContext;
+
+public class TestPaymentPluginApi implements PaymentPluginApi {
+
+    private final TestDao testDao;
+    private final String name;
+
+    public TestPaymentPluginApi(final String name, final TestDao testDao) {
+        this.testDao = testDao;
+        this.name = name;
+    }
+
+    @Override
+    public String getName() {
+        return name;
+    }
+
+    @Override
+    public PaymentInfoPlugin processPayment(final UUID kbPaymentId, final UUID kbPaymentMethodId, final BigDecimal amount, final CallContext context) throws PaymentPluginApiException {
+        testDao.insertProcessedPayment(kbPaymentId, kbPaymentMethodId, amount);
+        return new PaymentInfoPlugin() {
+            @Override
+            public BigDecimal getAmount() {
+                return amount;
+            }
+            @Override
+            public DateTime getCreatedDate() {
+                return new DateTime();
+            }
+            @Override
+            public DateTime getEffectiveDate() {
+                return new DateTime();
+            }
+            @Override
+            public PaymentPluginStatus getStatus() {
+                return PaymentPluginStatus.PROCESSED;
+            }
+            @Override
+            public String getGatewayError() {
+                return null;
+            }
+            @Override
+            public String getGatewayErrorCode() {
+                return null;
+            }
+        };
+    }
+
+    @Override
+    public PaymentInfoPlugin getPaymentInfo(final UUID kbPaymentId, final TenantContext context) throws PaymentPluginApiException {
+        return null;
+    }
+
+    @Override
+    public RefundInfoPlugin processRefund(final UUID kbPaymentId, final BigDecimal refundAmount, final CallContext context) throws PaymentPluginApiException {
+        return null;
+    }
+
+    @Override
+    public void addPaymentMethod(final UUID kbPaymentMethodId, final PaymentMethodPlugin paymentMethodProps, final boolean setDefault, final CallContext context) throws PaymentPluginApiException {
+    }
+
+    @Override
+    public void deletePaymentMethod(final UUID kbPaymentMethodId, final CallContext context) throws PaymentPluginApiException {
+    }
+
+    @Override
+    public void setDefaultPaymentMethod(final UUID kbPaymentMethodId, final CallContext context) throws PaymentPluginApiException {
+    }
+
+    @Override
+    public List<PaymentMethodInfoPlugin> getPaymentMethods(final UUID kbAccountId, final boolean refreshFromGateway, final CallContext context) throws PaymentPluginApiException {
+        return null;
+    }
+
+    @Override
+    public void resetPaymentMethods(final List<PaymentMethodInfoPlugin> paymentMethods) throws PaymentPluginApiException {
+    }
+
+
+}
diff --git a/osgi-bundles/tests/test/src/test/resources/ddl_test.sql b/osgi-bundles/tests/test/src/test/resources/ddl_test.sql
new file mode 100644
index 0000000..e4bfa5d
--- /dev/null
+++ b/osgi-bundles/tests/test/src/test/resources/ddl_test.sql
@@ -0,0 +1,10 @@
+/*! SET storage_engine=INNODB */;
+
+DROP TABLE IF EXISTS test_bundle;
+CREATE TABLE test_bundle (
+    record_id int(11) unsigned NOT NULL AUTO_INCREMENT,
+    is_started bool DEFAULT false,
+    is_logged bool DEFAULT false,
+    external_key varchar(128) NULL
+    PRIMARY KEY(record_id)
+);