Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WELD-1560 - CustomCDIProviderTest based on incorrect assumption
- Loading branch information
Showing
9 changed files
with
281 additions
and
87 deletions.
There are no files selected for viewing
43 changes: 43 additions & 0 deletions
43
...e/src/test/java/org/jboss/weld/environment/se/test/provider/custom/CustomCDIProvider.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,43 @@ | ||
/* | ||
* JBoss, Home of Professional Open Source | ||
* Copyright 2012, Red Hat, Inc., 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.weld.environment.se.test.provider.custom; | ||
|
||
import javax.enterprise.inject.Vetoed; | ||
import javax.enterprise.inject.spi.CDI; | ||
import javax.enterprise.inject.spi.CDIProvider; | ||
|
||
/** | ||
* @author Martin Kouba | ||
* | ||
*/ | ||
@Vetoed | ||
public class CustomCDIProvider implements CDIProvider { | ||
|
||
public static boolean isCalled = false; | ||
|
||
@Override | ||
public CDI<Object> getCDI() { | ||
isCalled = true; | ||
return null; | ||
} | ||
|
||
public static void reset() { | ||
isCalled = false; | ||
} | ||
|
||
} |
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
37 changes: 0 additions & 37 deletions
37
...ments/se/core/src/test/java/org/jboss/weld/environment/se/test/provider/custom/MyCDI.java
This file was deleted.
Oops, something went wrong.
10 changes: 0 additions & 10 deletions
10
...se/core/src/test/java/org/jboss/weld/environment/se/test/provider/custom/MyException.java
This file was deleted.
Oops, something went wrong.
88 changes: 88 additions & 0 deletions
88
...nts/se/core/src/test/java/org/jboss/weld/environment/se/test/provider/custom/TestCDI.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,88 @@ | ||
/* | ||
* JBoss, Home of Professional Open Source | ||
* Copyright 2013, Red Hat, Inc., 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.weld.environment.se.test.provider.custom; | ||
|
||
import java.lang.annotation.Annotation; | ||
import java.util.Iterator; | ||
|
||
import javax.enterprise.inject.Instance; | ||
import javax.enterprise.inject.Vetoed; | ||
import javax.enterprise.inject.spi.BeanManager; | ||
import javax.enterprise.inject.spi.CDI; | ||
import javax.enterprise.util.TypeLiteral; | ||
|
||
/** | ||
* | ||
* @author Martin Kouba | ||
*/ | ||
@Vetoed | ||
public class TestCDI extends CDI<Object> { | ||
|
||
/** | ||
* WORKAROUND - it's not possible to unset the CDIProvider via {@link CDI#setCDIProvider(javax.enterprise.inject.spi.CDIProvider)} but it's possible to set the field | ||
* value directly in a subclass. However, it was probably not intended for the subclass to be able to do this. | ||
*/ | ||
public static void unsetCDIProvider() { | ||
configuredProvider = null; | ||
} | ||
|
||
@Override | ||
public Instance<Object> select(Annotation... qualifiers) { | ||
throw new UnsupportedOperationException(); | ||
} | ||
|
||
@Override | ||
public <U> Instance<U> select(Class<U> subtype, Annotation... qualifiers) { | ||
throw new UnsupportedOperationException(); | ||
} | ||
|
||
@Override | ||
public <U> Instance<U> select(TypeLiteral<U> subtype, Annotation... qualifiers) { | ||
throw new UnsupportedOperationException(); | ||
} | ||
|
||
@Override | ||
public boolean isUnsatisfied() { | ||
throw new UnsupportedOperationException(); | ||
} | ||
|
||
@Override | ||
public boolean isAmbiguous() { | ||
throw new UnsupportedOperationException(); | ||
} | ||
|
||
@Override | ||
public void destroy(Object instance) { | ||
throw new UnsupportedOperationException(); | ||
} | ||
|
||
@Override | ||
public Iterator<Object> iterator() { | ||
throw new UnsupportedOperationException(); | ||
} | ||
|
||
@Override | ||
public Object get() { | ||
throw new UnsupportedOperationException(); | ||
} | ||
|
||
@Override | ||
public BeanManager getBeanManager() { | ||
throw new UnsupportedOperationException(); | ||
} | ||
|
||
} |
43 changes: 43 additions & 0 deletions
43
...ase/src/main/java/org/jboss/weld/environment/servlet/test/provider/CustomCDIProvider.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,43 @@ | ||
/* | ||
* JBoss, Home of Professional Open Source | ||
* Copyright 2012, Red Hat, Inc., 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.weld.environment.servlet.test.provider; | ||
|
||
import javax.enterprise.inject.Vetoed; | ||
import javax.enterprise.inject.spi.CDI; | ||
import javax.enterprise.inject.spi.CDIProvider; | ||
|
||
/** | ||
* @author Martin Kouba | ||
* | ||
*/ | ||
@Vetoed | ||
public class CustomCDIProvider implements CDIProvider { | ||
|
||
public static boolean isCalled = false; | ||
|
||
@Override | ||
public CDI<Object> getCDI() { | ||
isCalled = true; | ||
return null; | ||
} | ||
|
||
public static void reset() { | ||
isCalled = false; | ||
} | ||
|
||
} |
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
27 changes: 0 additions & 27 deletions
27
...ts/base/src/main/java/org/jboss/weld/environment/servlet/test/provider/MyCDIProvider.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.