forked from arquillian/arquillian_deprecated
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ARQ-117 Added more descriptive exception messages
- Loading branch information
1 parent
26dcc30
commit 7d828f8
Showing
5 changed files
with
131 additions
and
5 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
64 changes: 64 additions & 0 deletions
64
impl-base/src/test/java/org/jboss/arquillian/impl/DynamicServiceLoaderTestCase.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,64 @@ | ||
/* | ||
* JBoss, Home of Professional Open Source | ||
* Copyright 2009, 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 org.jboss.arquillian.impl; | ||
|
||
import java.util.Collection; | ||
|
||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
/** | ||
* Verify the behavior of the Dynamic Service Loader | ||
* | ||
* @author <a href="mailto:aknutsen@redhat.com">Aslak Knutsen</a> | ||
* @version $Revision: $ | ||
*/ | ||
public class DynamicServiceLoaderTestCase | ||
{ | ||
|
||
@Test(expected = IllegalStateException.class) | ||
public void shouldFailIfMultipleProvidersFound() throws Exception | ||
{ | ||
new DynamicServiceLoader().onlyOne(Service.class); | ||
} | ||
|
||
@Test | ||
public void shouldNotFailIfMultipleProvidersFoundPointingToSameImpl() throws Exception | ||
{ | ||
Service2 service = new DynamicServiceLoader().onlyOne(Service2.class); | ||
|
||
Assert.assertTrue( | ||
"verify that a instance of Service2Impl was loaded", | ||
service.getClass() == Service2Impl.class); | ||
} | ||
|
||
@Test | ||
public void shouldLoadAllInstances() throws Exception { | ||
Collection<Service> services = new DynamicServiceLoader().all(Service.class); | ||
|
||
Assert.assertEquals( | ||
"verify that all services where found and loaded", | ||
2, services.size()); | ||
} | ||
|
||
public interface Service {} | ||
public static class ServiceImpl1 implements Service {} | ||
public static class ServiceImpl2 implements Service {} | ||
|
||
public interface Service2 {} | ||
public static class Service2Impl implements Service2 {} | ||
} |
2 changes: 2 additions & 0 deletions
2
...esources/META-INF/services/org.jboss.arquillian.impl.DynamicServiceLoaderTestCase$Service
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,2 @@ | ||
org.jboss.arquillian.impl.DynamicServiceLoaderTestCase$ServiceImpl1 | ||
org.jboss.arquillian.impl.DynamicServiceLoaderTestCase$ServiceImpl2 |
2 changes: 2 additions & 0 deletions
2
...sources/META-INF/services/org.jboss.arquillian.impl.DynamicServiceLoaderTestCase$Service2
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,2 @@ | ||
org.jboss.arquillian.impl.DynamicServiceLoaderTestCase$Service2Impl | ||
org.jboss.arquillian.impl.DynamicServiceLoaderTestCase$Service2Impl |
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