You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by rm...@apache.org on 2016/08/26 08:31:29 UTC
[1/2] tomee git commit: OWB snapshot for extension generated id
stability
Repository: tomee
Updated Branches:
refs/heads/master 24af48bc1 -> d995c9446
OWB snapshot for extension generated id stability
Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/cf13b574
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/cf13b574
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/cf13b574
Branch: refs/heads/master
Commit: cf13b5744f96ad23a0e6588369bb3cdb8882ae31
Parents: 24af48b
Author: Romain manni-Bucau <rm...@gmail.com>
Authored: Fri Aug 26 10:31:01 2016 +0200
Committer: Romain manni-Bucau <rm...@gmail.com>
Committed: Fri Aug 26 10:31:01 2016 +0200
----------------------------------------------------------------------
pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tomee/blob/cf13b574/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 7b7b6d1..9008810 100644
--- a/pom.xml
+++ b/pom.xml
@@ -97,7 +97,7 @@
<version.javaee-api>7.0</version.javaee-api>
<openjpa.version>2.4.1</openjpa.version>
- <org.apache.openwebbeans.version>1.6.3</org.apache.openwebbeans.version>
+ <org.apache.openwebbeans.version>1.6.4-SNAPSHOT</org.apache.openwebbeans.version>
<jcs.version>2.0-M1</jcs.version>
<johnzon.version>0.9.5</johnzon.version>
[2/2] tomee git commit: CredentialDigest test
Posted by rm...@apache.org.
CredentialDigest test
Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/d995c944
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/d995c944
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/d995c944
Branch: refs/heads/master
Commit: d995c944636bc9978633376ee6ec5ada4994dca9
Parents: cf13b57
Author: Romain manni-Bucau <rm...@gmail.com>
Authored: Fri Aug 26 10:31:14 2016 +0200
Committer: Romain manni-Bucau <rm...@gmail.com>
Committed: Fri Aug 26 10:31:14 2016 +0200
----------------------------------------------------------------------
.../tests/datasourcerealm/AddUser.java | 45 +++++++
.../datasourcerealm/DataSourceRealmTest.java | 127 +++++++++++++++++++
.../arquillian/tests/datasourcerealm/Role.java | 47 +++++++
.../tests/datasourcerealm/RoleId.java | 65 ++++++++++
.../arquillian/tests/datasourcerealm/User.java | 60 +++++++++
arquillian/arquillian-tomee-tests/pom.xml | 6 +-
6 files changed, 349 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tomee/blob/d995c944/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/datasourcerealm/AddUser.java
----------------------------------------------------------------------
diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/datasourcerealm/AddUser.java b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/datasourcerealm/AddUser.java
new file mode 100644
index 0000000..29d5511
--- /dev/null
+++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/datasourcerealm/AddUser.java
@@ -0,0 +1,45 @@
+/**
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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.apache.openejb.arquillian.tests.datasourcerealm;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.context.Initialized;
+import javax.enterprise.event.Observes;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import javax.transaction.Transactional;
+
+public class AddUser {
+ @PersistenceContext
+ private EntityManager em;
+
+ @Transactional
+ public void add(@Observes @Initialized(ApplicationScoped.class) Object init) {
+ final User user = new User();
+ user.setUserName("test");
+ user.setUserPass("9003d1df22eb4d3820015070385194c8"); // md5(pwd)
+ em.persist(user);
+
+ final RoleId roleId = new RoleId();
+ roleId.setUserName(user.getUserName());
+ roleId.setUserRole("arquillian");
+
+ final Role role = new Role();
+ role.setId(roleId);
+ em.persist(role);
+ }
+}
http://git-wip-us.apache.org/repos/asf/tomee/blob/d995c944/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/datasourcerealm/DataSourceRealmTest.java
----------------------------------------------------------------------
diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/datasourcerealm/DataSourceRealmTest.java b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/datasourcerealm/DataSourceRealmTest.java
new file mode 100644
index 0000000..6ba794b
--- /dev/null
+++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/datasourcerealm/DataSourceRealmTest.java
@@ -0,0 +1,127 @@
+/**
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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.apache.openejb.arquillian.tests.datasourcerealm;
+
+import org.apache.ziplock.IO;
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.arquillian.test.api.ArquillianResource;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.EmptyAsset;
+import org.jboss.shrinkwrap.api.asset.StringAsset;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.jboss.shrinkwrap.descriptor.api.Descriptors;
+import org.jboss.shrinkwrap.descriptor.api.webapp31.WebAppDescriptor;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import javax.ws.rs.client.ClientBuilder;
+import javax.ws.rs.core.MediaType;
+import java.io.IOException;
+import java.net.URISyntaxException;
+import java.net.URL;
+
+import static javax.xml.bind.DatatypeConverter.printBase64Binary;
+import static org.junit.Assert.assertEquals;
+
+@RunWith(Arquillian.class)
+public class DataSourceRealmTest {
+ @Deployment(testable = false)
+ public static Archive<?> war() {
+ return ShrinkWrap.create(WebArchive.class, DataSourceRealmTest.class.getName() + ".war")
+ .addClasses(AddUser.class)
+ .addAsWebInfResource(new StringAsset( // JPA for user/role provisioning and table init
+ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
+ "<persistence xmlns=\"http://java.sun.com/xml/ns/persistence\"\n" +
+ " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n" +
+ " xsi:schemaLocation=\"\n" +
+ " http://java.sun.com/xml/ns/persistence\n" +
+ " http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd\"\n" +
+ " version=\"2.0\">\n" +
+ " <persistence-unit name=\"users\">\n" +
+ " <jta-data-source>jdbc/users-managed</jta-data-source>\n" +
+ " <non-jta-data-source>jdbc/users</non-jta-data-source>\n" +
+ " <class>org.apache.openejb.arquillian.tests.datasourcerealm.User</class>\n" +
+ " <class>org.apache.openejb.arquillian.tests.datasourcerealm.Role</class>\n" +
+ " <class>org.apache.openejb.arquillian.tests.datasourcerealm.RoleId</class>\n" +
+ " <exclude-unlisted-classes>true</exclude-unlisted-classes>\n" +
+ " <properties>\n" +
+ " <property name=\"openejb.jpa.init-entitymanager\" value=\"true\" />\n" +
+ " <property name=\"openjpa.jdbc.SynchronizeMappings\" value=\"buildSchema(ForeignKeys=true)\"/>\n" +
+ " <property name=\"openjpa.RuntimeUnenhancedClasses\" value=\"supported\"/>\n" +
+ " </properties>\n" +
+ " </persistence-unit>\n" +
+ "</persistence>"), "persistence.xml")
+ .addAsManifestResource(new StringAsset(
+ "<Context>\n" +
+ " <Realm className=\"org.apache.catalina.realm.DataSourceRealm\" \n" +
+ " dataSourceName=\"jdbc/users\" localDataSource=\"true\"\n" +
+ " userTable=\"users\" userNameCol=\"user_name\" userCredCol=\"user_pass\"\n" +
+ " userRoleTable=\"user_roles\" roleNameCol=\"user_role\">\n" +
+ "\n" +
+ " <CredentialHandler className=\"org.apache.catalina.realm.MessageDigestCredentialHandler\" algorithm=\"md5\" />\n" +
+ " </Realm>\n" +
+ "</Context>"), "context.xml")
+ .addAsWebInfResource(new StringAsset(
+ "<Resources>\n" +
+ " <Resource id=\"jdbc/users-managed\" type=\"DataSource\">\n" +
+ " JtaManaged = true\n" +
+ " JdbcUrl = jdbc:hsqldb:mem:DataSourceRealmTest_users\n" +
+ " LogSql = true\n" +
+ " </Resource>\n" +
+ " <Resource id=\"jdbc/users\" type=\"DataSource\">\n" +
+ " JtaManaged = false\n" +
+ " JdbcUrl = jdbc:hsqldb:mem:DataSourceRealmTest_users\n" +
+ " LogSql = true\n" +
+ " </Resource>\n" +
+ "</Resources>"), "resources.xml")
+ .addAsWebResource(new StringAsset("touched"), "index.html")
+ .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml")
+ .setWebXML(new StringAsset(
+ Descriptors.create(WebAppDescriptor.class)
+ .getOrCreateSecurityConstraint()
+ .createWebResourceCollection()
+ .webResourceName("all")
+ .urlPattern("/*")
+ .up()
+ .getOrCreateAuthConstraint()
+ .roleName("arquillian")
+ .up()
+ .up()
+ .getOrCreateLoginConfig()
+ .authMethod("BASIC")
+ .up()
+ .exportAsString()));
+ }
+
+ @ArquillianResource
+ private URL base;
+
+ @Test(expected = IOException.class)
+ public void forbidden() throws IOException {
+ IO.slurp(base);
+ }
+
+ @Test
+ public void allowed() throws IOException, URISyntaxException {
+ assertEquals("touched", ClientBuilder.newClient()
+ .target(base.toURI()).request(MediaType.TEXT_PLAIN)
+ .header("Authorization", "Basic " + printBase64Binary("test:pwd".getBytes("UTF-8")))
+ .get(String.class));
+ }
+}
http://git-wip-us.apache.org/repos/asf/tomee/blob/d995c944/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/datasourcerealm/Role.java
----------------------------------------------------------------------
diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/datasourcerealm/Role.java b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/datasourcerealm/Role.java
new file mode 100644
index 0000000..08efcdf
--- /dev/null
+++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/datasourcerealm/Role.java
@@ -0,0 +1,47 @@
+/**
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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.apache.openejb.arquillian.tests.datasourcerealm;
+
+import javax.persistence.EmbeddedId;
+import javax.persistence.Entity;
+import javax.persistence.Table;
+
+@Entity
+@Table(name = "user_roles")
+public class Role {
+ @EmbeddedId
+ private RoleId id;
+
+ public RoleId getId() {
+ return id;
+ }
+
+ public void setId(final RoleId id) {
+ this.id = id;
+ }
+
+ @Override
+ public boolean equals(final Object o) {
+ return this == o || !(o == null || !Role.class.isInstance(o)) && id.equals(Role.class.cast(o).id);
+
+ }
+
+ @Override
+ public int hashCode() {
+ return id.hashCode();
+ }
+}
http://git-wip-us.apache.org/repos/asf/tomee/blob/d995c944/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/datasourcerealm/RoleId.java
----------------------------------------------------------------------
diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/datasourcerealm/RoleId.java b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/datasourcerealm/RoleId.java
new file mode 100644
index 0000000..0a3c387
--- /dev/null
+++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/datasourcerealm/RoleId.java
@@ -0,0 +1,65 @@
+/**
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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.apache.openejb.arquillian.tests.datasourcerealm;
+
+import javax.persistence.Column;
+import javax.persistence.Embeddable;
+
+@Embeddable
+public class RoleId {
+ @Column(name = "user_name")
+ private String userName;
+
+ @Column(name = "user_role")
+ private String userRole;
+
+ public String getUserName() {
+ return userName;
+ }
+
+ public void setUserName(final String userName) {
+ this.userName = userName;
+ }
+
+ public String getUserRole() {
+ return userRole;
+ }
+
+ public void setUserRole(final String userRole) {
+ this.userRole = userRole;
+ }
+
+ @Override
+ public boolean equals(final Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || !RoleId.class.isInstance(o)) {
+ return false;
+ }
+ final RoleId roleId = RoleId.class.cast(o);
+ return userName.equals(roleId.userName) && userRole.equals(roleId.userRole);
+
+ }
+
+ @Override
+ public int hashCode() {
+ int result = userName.hashCode();
+ result = 31 * result + userRole.hashCode();
+ return result;
+ }
+}
http://git-wip-us.apache.org/repos/asf/tomee/blob/d995c944/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/datasourcerealm/User.java
----------------------------------------------------------------------
diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/datasourcerealm/User.java b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/datasourcerealm/User.java
new file mode 100644
index 0000000..f49d8e4
--- /dev/null
+++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/datasourcerealm/User.java
@@ -0,0 +1,60 @@
+/**
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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.apache.openejb.arquillian.tests.datasourcerealm;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+@Entity
+@Table(name = "users")
+public class User {
+ @Id
+ @Column(name = "user_name")
+ private String userName;
+
+ @Column(name = "user_pass")
+ private String userPass;
+
+ public String getUserName() {
+ return userName;
+ }
+
+ public void setUserName(final String userName) {
+ this.userName = userName;
+ }
+
+ public String getUserPass() {
+ return userPass;
+ }
+
+ public void setUserPass(final String userPass) {
+ this.userPass = userPass;
+ }
+
+ @Override
+ public boolean equals(final Object o) {
+ return this == o || !(o == null || !User.class.isInstance(o)) && userName.equals(User.class.cast(o).userName);
+
+ }
+
+ @Override
+ public int hashCode() {
+ return userName.hashCode();
+ }
+}
http://git-wip-us.apache.org/repos/asf/tomee/blob/d995c944/arquillian/arquillian-tomee-tests/pom.xml
----------------------------------------------------------------------
diff --git a/arquillian/arquillian-tomee-tests/pom.xml b/arquillian/arquillian-tomee-tests/pom.xml
index be26792..70137ae 100644
--- a/arquillian/arquillian-tomee-tests/pom.xml
+++ b/arquillian/arquillian-tomee-tests/pom.xml
@@ -160,6 +160,7 @@
</goals>
<configuration>
<skip>${maven.test.skip}</skip>
+ <argLine>-javaagent:${settings.localRepository}/org/apache/tomee/openejb-javaagent/${project.version}/openejb-javaagent-${project.version}.jar</argLine>
<systemPropertyVariables>
<tomee.version>${project.version}</tomee.version>
<arquillian.launch>tomee-embedded</arquillian.launch>
@@ -275,7 +276,10 @@
</goals>
<configuration>
<skip>${skip.embedded}</skip>
- <argLine>-XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=512M</argLine>
+ <argLine>
+ -javaagent:${settings.localRepository}/org/apache/tomee/openejb-javaagent/${project.version}/openejb-javaagent-${project.version}.jar
+ -XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=512M
+ </argLine>
<systemPropertyVariables>
<tomee.version>${project.version}</tomee.version>
<arquillian.launch>tomee-embedded</arquillian.launch>