Skip to content

Commit

Permalink
Various
Browse files Browse the repository at this point in the history
* Flatten packages
* remove readme.html
* remove JBoss repo from POMN
* Add -ds.xml support
* Remove synthetic ID from hash code and equals
* Add unique column on username
* use identity based ids
* use positive numbers for ids
* Add stuff to README
  • Loading branch information
pmuir committed Mar 20, 2012
1 parent 4d83d10 commit 7bcf64f
Show file tree
Hide file tree
Showing 17 changed files with 117 additions and 233 deletions.
18 changes: 6 additions & 12 deletions tasks/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
jboss-as-tasks
==============
tasks: Testing JPA with Arquillian
==================================

Authors: Oliver Kiss and Lukas Fryc

What is it?
-----------
Expand Down Expand Up @@ -48,16 +50,8 @@ test goal with the following profile activated:
Testing on Managed Server
-------------------------

Arquillian will start the container for you. All you have to do is setup a path to your
extracted . To do this, run

export JBOSS_HOME=/path/to/jboss-as

or if you are using windows

set JBOSS_HOME=X:\path\to\jboss-as

Or hardcode the path in pom.xml file
Arquillian will start the container for you. All you have to do is setup a path to JBoss AS.
Edit `src/test/resources/arquillian` and set the `jbossHome` element.

To run the test in JBoss AS 7 or JBoss EAP 6, run the test goal with the following profile activated:

Expand Down
67 changes: 1 addition & 66 deletions tasks/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -160,40 +160,8 @@
</build>

</profile>

<profile>
<!-- We add the JBoss repository as we need the JBoss AS connectors
for Arquillian -->
<repositories>
<!-- The JBoss Community public repository is a composite repository
of several major repositories -->
<!-- see http://community.jboss.org/wiki/MavenGettingStarted-Users -->
<repository>
<id>jboss-public-repository</id>
<name>JBoss Repository</name>
<url>http://repository.jboss.org/nexus/content/groups/public</url>
<!-- These optional flags are designed to speed up your builds
by reducing remote server calls -->
<releases>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>

<pluginRepositories>
<pluginRepository>
<id>jboss-public-repository</id>
<name>JBoss Repository</name>
<url>http://repository.jboss.org/nexus/content/groups/public</url>
<releases>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>

<!-- An optional Arquillian testing profile that executes tests
in your JBoss AS instance -->
<!-- This profile will start a new JBoss AS instance, and execute
Expand All @@ -211,39 +179,6 @@
</profile>

<profile>
<!-- We add the JBoss repository as we need the JBoss AS connectors
for Arquillian -->
<repositories>
<!-- The JBoss Community public repository is a composite repository
of several major repositories -->
<!-- see http://community.jboss.org/wiki/MavenGettingStarted-Users -->
<repository>
<id>jboss-public-repository</id>
<name>JBoss Repository</name>
<url>http://repository.jboss.org/nexus/content/groups/public</url>
<!-- These optional flags are designed to speed up your builds
by reducing remote server calls -->
<releases>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>

<pluginRepositories>
<pluginRepository>
<id>jboss-public-repository</id>
<name>JBoss Repository</name>
<url>http://repository.jboss.org/nexus/content/groups/public</url>
<releases>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>

<!-- An optional Arquillian testing profile that executes tests
in a remote JBoss AS instance -->
<!-- Run with: mvn clean test -Parq-jbossas-remote -->
Expand Down
59 changes: 0 additions & 59 deletions tasks/readme.html

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.jboss.as.quickstarts.tasks.beans;
package org.jboss.as.quickstarts.tasks;

import javax.ejb.Stateful;
import javax.enterprise.context.RequestScoped;
Expand All @@ -7,6 +7,19 @@
import javax.persistence.PersistenceContext;
import javax.persistence.PersistenceContextType;

/**
* This class uses CDI to alias Java EE resources, such as the persistence context, to CDI beans. As it is a stateful bean, it
* can produce extended persistence contexts.
*
* <p>
* Example injection on a managed bean field:
* </p>
*
* <pre>
* &#064;Inject
* private EntityManager em;
* </pre>
*/
@Stateful
@RequestScoped
public class Resources {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
package org.jboss.as.quickstarts.tasks.domain;
package org.jboss.as.quickstarts.tasks;

import static javax.persistence.GenerationType.IDENTITY;

import javax.persistence.*;
import java.io.Serializable;
Expand All @@ -8,13 +10,12 @@
*
* @author Oliver Kiss
*/
@SuppressWarnings("serial")
@Entity
@Table(name = "Tasks_task")
public class Task implements Serializable {
private static final long serialVersionUID = 1l;

@Id
@GeneratedValue
@GeneratedValue(strategy = IDENTITY)
private Long id;

@ManyToOne
Expand Down Expand Up @@ -58,45 +59,31 @@ public void setTitle(String title) {
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((id == null) ? 0 : id.hashCode());
result = prime * result + ((title == null) ? 0 : title.hashCode());
result = prime * result + ((owner == null) ? 0 : owner.hashCode());
result = prime * result + ((title == null) ? 0 : title.hashCode());
return result;
}

@Override
public boolean equals(Object obj) {
if (this == obj) {
if (this == obj)
return true;
}
if (obj == null) {
if (obj == null)
return false;
}
if (getClass() != obj.getClass()) {
if (getClass() != obj.getClass())
return false;
}
Task other = (Task) obj;
if (id == null) {
if (other.id != null) {
if (owner == null) {
if (other.owner != null)
return false;
}
} else if (!id.equals(other.id)) {
} else if (!owner.equals(other.owner))
return false;
}
if (title == null) {
if (other.title != null) {
if (other.title != null)
return false;
}
} else if (!title.equals(other.title)) {
} else if (!title.equals(other.title))
return false;
}
if (owner == null) {
if (other.owner != null) {
return false;
}
} else if (!owner.equals(other.owner)) {
return false;
}
return true;
}

}
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package org.jboss.as.quickstarts.tasks.domain;
package org.jboss.as.quickstarts.tasks;

import java.util.List;

import javax.ejb.Local;

/**
* Basic operations for manipulation with tasks
* Basic operations for manipulation of tasks
*
* @author Lukas Fryc
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.jboss.as.quickstarts.tasks.domain;
package org.jboss.as.quickstarts.tasks;

import java.util.List;

Expand All @@ -8,7 +8,7 @@
import javax.persistence.TypedQuery;

/**
* Provides functionality for manipulation with tasks using persistence context from {@link Resources}.
* Provides functionality for manipulation with tasks using the persistence context from {@link Resources}.
*
* @author Lukas Fryc
* @author Oliver Kiss
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
package org.jboss.as.quickstarts.tasks.domain;
package org.jboss.as.quickstarts.tasks;

import static javax.persistence.CascadeType.ALL;
import static javax.persistence.GenerationType.IDENTITY;

import javax.persistence.*;
import java.io.Serializable;
Expand All @@ -10,20 +13,19 @@
*
* @author Oliver Kiss
*/
@SuppressWarnings("serial")
@Entity
@Table(name = "Tasks_user")
public class User implements Serializable {

private static final long serialVersionUID = 1l;

@Id
@GeneratedValue(strategy = GenerationType.TABLE)
@GeneratedValue(strategy = IDENTITY)
private Long id;

@Column(unique=true)
private String username;

@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "owner")
@Column(nullable = true, updatable = false)
@OneToMany(cascade = ALL, mappedBy = "owner")
@Column(updatable = false)
private List<Task> tasks = new ArrayList<Task>();

public User() {
Expand Down Expand Up @@ -61,37 +63,25 @@ public void setTasks(List<Task> tasks) {
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((id == null) ? 0 : id.hashCode());
result = prime * result + ((username == null) ? 0 : username.hashCode());
return result;
}

@Override
public boolean equals(Object obj) {
if (this == obj) {
if (this == obj)
return true;
}
if (obj == null) {
if (obj == null)
return false;
}
if (getClass() != obj.getClass()) {
if (getClass() != obj.getClass())
return false;
}
User other = (User) obj;
if (id == null) {
if (other.id != null) {
return false;
}
} else if (!id.equals(other.id)) {
return false;
}
if (username == null) {
if (other.username != null) {
if (other.username != null)
return false;
}
} else if (!username.equals(other.username)) {
} else if (!username.equals(other.username))
return false;
}
return true;
}

}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.jboss.as.quickstarts.tasks.domain;
package org.jboss.as.quickstarts.tasks;

import javax.ejb.Local;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.jboss.as.quickstarts.tasks.domain;
package org.jboss.as.quickstarts.tasks;

import java.util.List;

Expand Down
Loading

0 comments on commit 7bcf64f

Please sign in to comment.