This repository has been archived by the owner on Jul 25, 2020. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9cd3cfa
commit 00500cb
Showing
10 changed files
with
389 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,3 +23,4 @@ velocity.log | |
.factorypath | ||
Makefile | ||
.apt_generated | ||
jclouds-db.* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
## H2 provider ## | ||
h2-jdbc is a storage provider for the h2 embedded database. It is implemented using JPA and Hibernate. | ||
|
||
## Running the tests ## | ||
To run the tests you can use this command | ||
``` | ||
mvn test | ||
``` | ||
You can also run the integration tests with | ||
``` | ||
mvn integration-test | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
Licensed to the Apache Software Foundation (ASF) under one or more | ||
contributor license agreements. See the NOTICE file distributed with | ||
this work for additional information regarding copyright ownership. | ||
The ASF 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/maven-v4_0_0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>org.apache.jclouds.labs</groupId> | ||
<artifactId>jclouds-labs</artifactId> | ||
<version>2.0.0-SNAPSHOT</version> | ||
</parent> | ||
<artifactId>h2-jdbc</artifactId> | ||
<name>jclouds h2 jdbc provider</name> | ||
<description>jclouds implementation to target h2 databases</description> | ||
<packaging>bundle</packaging> | ||
|
||
<properties> | ||
<jclouds.osgi.export>org.jclouds.jdbc*;version="${project.version}"</jclouds.osgi.export> | ||
<jclouds.osgi.import>org.jclouds*;version="${project.version}",*</jclouds.osgi.import> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.apache.jclouds.labs</groupId> | ||
<artifactId>jdbc</artifactId> | ||
<version>${project.version}</version> | ||
<type>jar</type> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.jclouds</groupId> | ||
<artifactId>jclouds-blobstore</artifactId> | ||
<version>${project.version}</version> | ||
<type>jar</type> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.jclouds</groupId> | ||
<artifactId>jclouds-core</artifactId> | ||
<version>${project.version}</version> | ||
<type>test-jar</type> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.jclouds</groupId> | ||
<artifactId>jclouds-blobstore</artifactId> | ||
<version>${project.version}</version> | ||
<type>test-jar</type> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.jclouds.driver</groupId> | ||
<artifactId>jclouds-log4j</artifactId> | ||
<version>${project.version}</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.google.auto.service</groupId> | ||
<artifactId>auto-service</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.google.inject.extensions</groupId> | ||
<artifactId>guice-persist</artifactId> | ||
<version>4.0</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.hibernate.javax.persistence</groupId> | ||
<artifactId>hibernate-jpa-2.1-api</artifactId> | ||
<version>1.0.0.Final</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.hibernate</groupId> | ||
<artifactId>hibernate-entitymanager</artifactId> | ||
<version>4.3.9.Final</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.h2database</groupId> | ||
<artifactId>h2</artifactId> | ||
<version>1.4.187</version> | ||
</dependency> | ||
|
||
<!-- Test Dependencies --> | ||
<dependency> | ||
<groupId>org.assertj</groupId> | ||
<artifactId>assertj-core</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
</project> | ||
|
67 changes: 67 additions & 0 deletions
67
h2-jdbc/src/main/java/org/jclouds/h2/jdbc/H2JdbcProviderMetadata.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF 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.jclouds.h2.jdbc; | ||
|
||
import org.jclouds.h2.jdbc.config.H2JdbcBlobStoreContextModule; | ||
import org.jclouds.jdbc.JdbcApiMetadata; | ||
import org.jclouds.providers.ProviderMetadata; | ||
import org.jclouds.providers.internal.BaseProviderMetadata; | ||
|
||
import com.google.auto.service.AutoService; | ||
|
||
@AutoService(ProviderMetadata.class) | ||
public class H2JdbcProviderMetadata extends BaseProviderMetadata { | ||
|
||
public static Builder builder() { | ||
return new Builder(); | ||
} | ||
|
||
@Override | ||
public Builder toBuilder() { | ||
return builder().fromProviderMetadata(this); | ||
} | ||
|
||
public H2JdbcProviderMetadata() { | ||
super(builder()); | ||
} | ||
|
||
public H2JdbcProviderMetadata(Builder builder) { | ||
super(builder); | ||
} | ||
|
||
public static class Builder extends BaseProviderMetadata.Builder { | ||
protected Builder() { | ||
id("h2-jdbc") | ||
.name("H2 Jdbc") | ||
.apiMetadata(new JdbcApiMetadata() | ||
.toBuilder() | ||
.defaultModule(H2JdbcBlobStoreContextModule.class) | ||
.build()); | ||
} | ||
|
||
@Override | ||
public H2JdbcProviderMetadata build() { | ||
return new H2JdbcProviderMetadata(this); | ||
} | ||
|
||
@Override | ||
public Builder fromProviderMetadata(ProviderMetadata in) { | ||
super.fromProviderMetadata(in); | ||
return this; | ||
} | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
h2-jdbc/src/main/java/org/jclouds/h2/jdbc/config/H2JdbcBlobStoreContextModule.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF 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.jclouds.h2.jdbc.config; | ||
|
||
import java.util.Properties; | ||
|
||
import org.jclouds.jdbc.config.JdbcBlobStoreContextModule; | ||
|
||
import com.google.inject.persist.jpa.JpaPersistModule; | ||
|
||
public class H2JdbcBlobStoreContextModule extends JdbcBlobStoreContextModule { | ||
|
||
private static final String DEFAULT_FILE = "./jclouds-db"; | ||
|
||
protected void configure() { | ||
super.configure(); | ||
|
||
Properties properties = new Properties(); | ||
properties.setProperty("hibernate.connection.url", "jdbc:h2:" + DEFAULT_FILE); | ||
|
||
install(new JpaPersistModule("jclouds-h2").properties(properties)); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<!-- | ||
Licensed to the Apache Software Foundation (ASF) under one or more | ||
contributor license agreements. See the NOTICE file distributed with | ||
this work for additional information regarding copyright ownership. | ||
The ASF 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. | ||
--> | ||
<persistence xmlns="http://java.sun.com/xml/ns/persistence" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd" | ||
version="1.0"> | ||
|
||
<persistence-unit name="jclouds-h2" transaction-type="RESOURCE_LOCAL"> | ||
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider> | ||
|
||
<class>org.jclouds.jdbc.entity.ContainerEntity</class> | ||
<class>org.jclouds.jdbc.entity.BlobEntity</class> | ||
<class>org.jclouds.jdbc.entity.ChunkEntity</class> | ||
<class>org.jclouds.jdbc.entity.PayloadEntity</class> | ||
<exclude-unlisted-classes>true</exclude-unlisted-classes> | ||
|
||
<properties> | ||
<property name="hibernate.dialect" value="org.hibernate.dialect.H2Dialect" /> | ||
<property name="hibernate.connection.driver_class" value="org.h2.Driver" /> | ||
<property name="hibernate.connection.user" value="sa" /> | ||
<!-- Allow hibernate to generate our schema --> | ||
<property name="hibernate.hbm2ddl.auto" value="create" /> | ||
</properties> | ||
</persistence-unit> | ||
|
||
</persistence> |
30 changes: 30 additions & 0 deletions
30
h2-jdbc/src/test/java/org/jclouds/h2/jdbc/H2JdbcProviderTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF 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.jclouds.h2.jdbc; | ||
|
||
import org.jclouds.jdbc.JdbcApiMetadata; | ||
import org.jclouds.providers.internal.BaseProviderMetadataTest; | ||
import org.testng.annotations.Test; | ||
|
||
@Test(groups = "unit", testName = "H2JdbcProviderTest") | ||
public class H2JdbcProviderTest extends BaseProviderMetadataTest { | ||
|
||
public H2JdbcProviderTest() { | ||
super(new H2JdbcProviderMetadata(), new JdbcApiMetadata()); | ||
} | ||
|
||
} |
34 changes: 34 additions & 0 deletions
34
h2-jdbc/src/test/java/org/jclouds/h2/jdbc/blobstore/H2JdbcBlobIntegrationTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF 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.jclouds.h2.jdbc.blobstore; | ||
|
||
import com.google.common.collect.ImmutableSet; | ||
import com.google.inject.Module; | ||
import org.jclouds.blobstore.integration.internal.BaseBlobIntegrationTest; | ||
import org.testng.annotations.Test; | ||
|
||
@Test(groups = { "integration" }, singleThreaded = true, testName = "blobstore.H2JdbcBlobIntegrationTest") | ||
public class H2JdbcBlobIntegrationTest extends BaseBlobIntegrationTest { | ||
public H2JdbcBlobIntegrationTest() { | ||
provider = "h2-jdbc"; | ||
} | ||
|
||
@Override | ||
protected Iterable<Module> setupModules() { | ||
return ImmutableSet.<Module> of(this.getLoggingModule()); | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
h2-jdbc/src/test/java/org/jclouds/h2/jdbc/blobstore/H2JdbcContainerIntegrationTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF 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.jclouds.h2.jdbc.blobstore; | ||
|
||
import com.google.common.collect.ImmutableSet; | ||
import com.google.inject.Module; | ||
import org.jclouds.blobstore.integration.internal.BaseContainerIntegrationTest; | ||
import org.testng.annotations.Test; | ||
|
||
@Test(groups = { "integration" }, singleThreaded = true, testName = "blobstore.H2JdbcContainerIntegrationTest") | ||
public class H2JdbcContainerIntegrationTest extends BaseContainerIntegrationTest { | ||
public H2JdbcContainerIntegrationTest() { | ||
provider = "h2-jdbc"; | ||
} | ||
|
||
@Override | ||
protected Iterable<Module> setupModules() { | ||
return ImmutableSet.<Module> of(this.getLoggingModule()); | ||
} | ||
} |
Oops, something went wrong.