Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactored event implementation and updated event APIs to latest spec…
…ification revision. git-svn-id: http://anonsvn.jboss.org/repos/weld/ri/trunk@117 1c488680-804c-0410-94cd-c6b725194a0e
- Loading branch information
Showing
9 changed files
with
302 additions
and
56 deletions.
There are no files selected for viewing
50 changes: 50 additions & 0 deletions
50
webbeans-api/src/main/java/javax/webbeans/DuplicateBindingTypeException.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,50 @@ | ||
/* | ||
* JBoss, Home of Professional Open Source | ||
* Copyright 2008, Red Hat Middleware LLC, and individual contributors | ||
* by the @authors tag. See the copyright.txt in the distribution for a | ||
* full listing of individual contributors. | ||
* | ||
* 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 javax.webbeans; | ||
|
||
/** | ||
* This exception is thrown whenever more than one binding type instance of the | ||
* same type is used with the API. | ||
* | ||
* @author David Allen | ||
*/ | ||
public class DuplicateBindingTypeException extends RuntimeException | ||
{ | ||
|
||
private static final long serialVersionUID = 4194175477451120383L; | ||
|
||
public DuplicateBindingTypeException() | ||
{ | ||
super(); | ||
} | ||
|
||
public DuplicateBindingTypeException(String message, Throwable cause) | ||
{ | ||
super(message, cause); | ||
} | ||
|
||
public DuplicateBindingTypeException(String message) | ||
{ | ||
super(message); | ||
} | ||
|
||
public DuplicateBindingTypeException(Throwable cause) | ||
{ | ||
super(cause); | ||
} | ||
|
||
} |
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
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
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
96 changes: 96 additions & 0 deletions
96
webbeans-ri/src/test/java/org/jboss/webbeans/test/EventComponentModelTest.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,96 @@ | ||
package org.jboss.webbeans.test; | ||
|
||
import java.lang.annotation.Annotation; | ||
import java.util.ArrayList; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Set; | ||
|
||
import javax.webbeans.Dependent; | ||
import javax.webbeans.Event; | ||
import javax.webbeans.Standard; | ||
|
||
import org.jboss.webbeans.bindings.StandardAnnotationLiteral; | ||
import org.jboss.webbeans.injectable.ComponentConstructor; | ||
import org.jboss.webbeans.introspector.SimpleAnnotatedItem; | ||
import org.jboss.webbeans.model.EventComponentModel; | ||
import org.jboss.webbeans.test.bindings.AnotherDeploymentTypeAnnotationLiteral; | ||
import org.jboss.webbeans.test.mock.MockContainerImpl; | ||
import org.testng.annotations.BeforeMethod; | ||
import org.testng.annotations.Test; | ||
|
||
/** | ||
* Unit tests for the component model used only for the container supplied | ||
* Event component. | ||
* | ||
* @author David Allen | ||
* | ||
*/ | ||
public class EventComponentModelTest | ||
{ | ||
private MockContainerImpl manager = null; | ||
private EventComponentModel<Event<? extends Object>> eventComponentModel = null; | ||
|
||
@BeforeMethod | ||
public void before() throws Exception | ||
{ | ||
List<Annotation> enabledDeploymentTypes = new ArrayList<Annotation>(); | ||
enabledDeploymentTypes.add(new StandardAnnotationLiteral()); | ||
enabledDeploymentTypes.add(new AnotherDeploymentTypeAnnotationLiteral()); | ||
manager = new MockContainerImpl(enabledDeploymentTypes); | ||
eventComponentModel = new EventComponentModel<Event<? extends Object>>( | ||
new SimpleAnnotatedItem<Object>( | ||
new HashMap<Class<? extends Annotation>, Annotation>()), | ||
new SimpleAnnotatedItem<Object>( | ||
new HashMap<Class<? extends Annotation>, Annotation>()), | ||
manager); | ||
|
||
} | ||
|
||
/** | ||
* The name should always be null since this type of component is not allowed to have a name. | ||
*/ | ||
@Test(groups = "eventbus") | ||
public void testName() | ||
{ | ||
assert eventComponentModel.getName() == null; | ||
} | ||
|
||
/** | ||
* The scope type should always be @Dependent | ||
*/ | ||
@Test(groups = "eventbus") | ||
public void testScopeType() | ||
{ | ||
assert eventComponentModel.getScopeType().annotationType().equals(Dependent.class); | ||
} | ||
|
||
/** | ||
* The deployment type should always be @Standard | ||
*/ | ||
@Test(groups = "eventbus") | ||
public void testDeploymentType() | ||
{ | ||
assert eventComponentModel.getDeploymentType().annotationType().equals(Standard.class); | ||
} | ||
|
||
@Test(groups = "eventbus") | ||
public void testApiTypes() | ||
{ | ||
Set<Class> apis = eventComponentModel.getApiTypes(); | ||
assert apis.size() >= 1; | ||
for (Class api : apis) | ||
{ | ||
api.equals(Event.class); | ||
} | ||
} | ||
|
||
@Test(groups = "eventbus") | ||
public void testConstructor() | ||
{ | ||
ComponentConstructor<Event<? extends Object>> constructor = eventComponentModel.getConstructor(); | ||
assert constructor != null; | ||
Event<? extends Object> event = constructor.invoke(manager); | ||
assert event != null; | ||
} | ||
} |
Oops, something went wrong.