[jboss-svn-commits] JBoss Common SVN: r3923 - in arquillian/trunk/demo/src: main/java/com/acme/cdi and 12 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Fri Jan 8 09:36:45 EST 2010
Author: aslak
Date: 2010-01-08 09:36:44 -0500 (Fri, 08 Jan 2010)
New Revision: 3923
Added:
arquillian/trunk/demo/src/main/java/com/acme/cdi/
arquillian/trunk/demo/src/main/java/com/acme/cdi/payment/
arquillian/trunk/demo/src/main/java/com/acme/cdi/payment/Asynchronous.java
arquillian/trunk/demo/src/main/java/com/acme/cdi/payment/AsynchronousPaymentProcessor.java
arquillian/trunk/demo/src/main/java/com/acme/cdi/payment/MockPaymentProcessor.java
arquillian/trunk/demo/src/main/java/com/acme/cdi/payment/PaymentProcessor.java
arquillian/trunk/demo/src/main/java/com/acme/cdi/payment/Synchronous.java
arquillian/trunk/demo/src/main/java/com/acme/cdi/payment/SynchronousPaymentProcessor.java
arquillian/trunk/demo/src/main/java/com/acme/cdi/random/
arquillian/trunk/demo/src/main/java/com/acme/cdi/random/Random.java
arquillian/trunk/demo/src/main/java/com/acme/cdi/random/RandomNumberGenerator.java
arquillian/trunk/demo/src/main/java/com/acme/cdi/translate/
arquillian/trunk/demo/src/main/java/com/acme/cdi/translate/NorwegianTranslator.java
arquillian/trunk/demo/src/main/java/com/acme/cdi/translate/SentenceParser.java
arquillian/trunk/demo/src/main/java/com/acme/cdi/translate/TextTranslator.java
arquillian/trunk/demo/src/main/java/com/acme/cdi/translate/TranslateController.java
arquillian/trunk/demo/src/main/java/com/acme/cdi/translate/Translator.java
arquillian/trunk/demo/src/test/java/com/acme/cdi/payment/
arquillian/trunk/demo/src/test/java/com/acme/cdi/payment/SynchronousPaymentProcessorTestCase.java
arquillian/trunk/demo/src/test/java/com/acme/cdi/random/
arquillian/trunk/demo/src/test/java/com/acme/cdi/random/RandomTestCase.java
arquillian/trunk/demo/src/test/java/com/acme/cdi/translate/
arquillian/trunk/demo/src/test/java/com/acme/cdi/translate/TranslateTestCase.java
arquillian/trunk/demo/src/test/resources/com/
arquillian/trunk/demo/src/test/resources/com/acme/
arquillian/trunk/demo/src/test/resources/com/acme/cdi/
arquillian/trunk/demo/src/test/resources/com/acme/cdi/payment/
arquillian/trunk/demo/src/test/resources/com/acme/cdi/payment/beans.xml
Log:
ARQ-35 ARQ-54 Added more examples for the Weld SE container, taken from the Weld Reference guide
Added: arquillian/trunk/demo/src/main/java/com/acme/cdi/payment/Asynchronous.java
===================================================================
--- arquillian/trunk/demo/src/main/java/com/acme/cdi/payment/Asynchronous.java (rev 0)
+++ arquillian/trunk/demo/src/main/java/com/acme/cdi/payment/Asynchronous.java 2010-01-08 14:36:44 UTC (rev 3923)
@@ -0,0 +1,29 @@
+/*
+ * 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 com.acme.cdi.payment;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import javax.inject.Qualifier;
+
+ at Qualifier
+ at Retention(RetentionPolicy.RUNTIME)
+ at Target({ElementType.TYPE, ElementType.METHOD, ElementType.FIELD, ElementType.PARAMETER})
+public @interface Asynchronous {}
\ No newline at end of file
Added: arquillian/trunk/demo/src/main/java/com/acme/cdi/payment/AsynchronousPaymentProcessor.java
===================================================================
--- arquillian/trunk/demo/src/main/java/com/acme/cdi/payment/AsynchronousPaymentProcessor.java (rev 0)
+++ arquillian/trunk/demo/src/main/java/com/acme/cdi/payment/AsynchronousPaymentProcessor.java 2010-01-08 14:36:44 UTC (rev 3923)
@@ -0,0 +1,26 @@
+/*
+ * 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 com.acme.cdi.payment;
+
+ at Asynchronous
+public class AsynchronousPaymentProcessor implements PaymentProcessor {
+
+ public void process(String payment)
+ {
+
+ }
+}
\ No newline at end of file
Added: arquillian/trunk/demo/src/main/java/com/acme/cdi/payment/MockPaymentProcessor.java
===================================================================
--- arquillian/trunk/demo/src/main/java/com/acme/cdi/payment/MockPaymentProcessor.java (rev 0)
+++ arquillian/trunk/demo/src/main/java/com/acme/cdi/payment/MockPaymentProcessor.java 2010-01-08 14:36:44 UTC (rev 3923)
@@ -0,0 +1,30 @@
+/*
+ * 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 com.acme.cdi.payment;
+
+import javax.enterprise.inject.Alternative;
+
+ at Alternative @Asynchronous @Synchronous
+public class MockPaymentProcessor implements PaymentProcessor {
+
+ public static Boolean HAS_BEEN_CALLED = false;
+
+ @Override
+ public void process(String payment) {
+ HAS_BEEN_CALLED = true;
+ }
+}
Added: arquillian/trunk/demo/src/main/java/com/acme/cdi/payment/PaymentProcessor.java
===================================================================
--- arquillian/trunk/demo/src/main/java/com/acme/cdi/payment/PaymentProcessor.java (rev 0)
+++ arquillian/trunk/demo/src/main/java/com/acme/cdi/payment/PaymentProcessor.java 2010-01-08 14:36:44 UTC (rev 3923)
@@ -0,0 +1,23 @@
+/*
+ * 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 com.acme.cdi.payment;
+
+public interface PaymentProcessor {
+
+ void process(String payment);
+
+}
Added: arquillian/trunk/demo/src/main/java/com/acme/cdi/payment/Synchronous.java
===================================================================
--- arquillian/trunk/demo/src/main/java/com/acme/cdi/payment/Synchronous.java (rev 0)
+++ arquillian/trunk/demo/src/main/java/com/acme/cdi/payment/Synchronous.java 2010-01-08 14:36:44 UTC (rev 3923)
@@ -0,0 +1,29 @@
+/*
+ * 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 com.acme.cdi.payment;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import javax.inject.Qualifier;
+
+ at Qualifier
+ at Retention(RetentionPolicy.RUNTIME)
+ at Target({ElementType.TYPE, ElementType.METHOD, ElementType.FIELD, ElementType.PARAMETER})
+public @interface Synchronous {}
\ No newline at end of file
Added: arquillian/trunk/demo/src/main/java/com/acme/cdi/payment/SynchronousPaymentProcessor.java
===================================================================
--- arquillian/trunk/demo/src/main/java/com/acme/cdi/payment/SynchronousPaymentProcessor.java (rev 0)
+++ arquillian/trunk/demo/src/main/java/com/acme/cdi/payment/SynchronousPaymentProcessor.java 2010-01-08 14:36:44 UTC (rev 3923)
@@ -0,0 +1,26 @@
+/*
+ * 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 com.acme.cdi.payment;
+
+ at Synchronous
+public class SynchronousPaymentProcessor implements PaymentProcessor {
+
+ public void process(String payment)
+ {
+
+ }
+}
\ No newline at end of file
Added: arquillian/trunk/demo/src/main/java/com/acme/cdi/random/Random.java
===================================================================
--- arquillian/trunk/demo/src/main/java/com/acme/cdi/random/Random.java (rev 0)
+++ arquillian/trunk/demo/src/main/java/com/acme/cdi/random/Random.java 2010-01-08 14:36:44 UTC (rev 3923)
@@ -0,0 +1,29 @@
+/*
+ * 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 com.acme.cdi.random;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import javax.inject.Qualifier;
+
+ at Qualifier
+ at Retention(RetentionPolicy.RUNTIME)
+ at Target({ElementType.TYPE, ElementType.METHOD, ElementType.PARAMETER, ElementType.FIELD})
+public @interface Random {}
\ No newline at end of file
Added: arquillian/trunk/demo/src/main/java/com/acme/cdi/random/RandomNumberGenerator.java
===================================================================
--- arquillian/trunk/demo/src/main/java/com/acme/cdi/random/RandomNumberGenerator.java (rev 0)
+++ arquillian/trunk/demo/src/main/java/com/acme/cdi/random/RandomNumberGenerator.java 2010-01-08 14:36:44 UTC (rev 3923)
@@ -0,0 +1,32 @@
+/*
+ * 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 com.acme.cdi.random;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.inject.Produces;
+import javax.inject.Named;
+
+ at ApplicationScoped
+public class RandomNumberGenerator {
+
+ private java.util.Random random = new java.util.Random(System.currentTimeMillis());
+
+ @Produces @Named @Random int getRandomNumber()
+ {
+ return random.nextInt(100);
+ }
+}
\ No newline at end of file
Added: arquillian/trunk/demo/src/main/java/com/acme/cdi/translate/NorwegianTranslator.java
===================================================================
--- arquillian/trunk/demo/src/main/java/com/acme/cdi/translate/NorwegianTranslator.java (rev 0)
+++ arquillian/trunk/demo/src/main/java/com/acme/cdi/translate/NorwegianTranslator.java 2010-01-08 14:36:44 UTC (rev 3923)
@@ -0,0 +1,28 @@
+/*
+ * 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 com.acme.cdi.translate;
+
+import javax.ejb.Stateless;
+
+ at Stateless
+public class NorwegianTranslator implements Translator {
+
+ @Override
+ public String translate(String sentence) {
+ return "hei";
+ }
+}
Added: arquillian/trunk/demo/src/main/java/com/acme/cdi/translate/SentenceParser.java
===================================================================
--- arquillian/trunk/demo/src/main/java/com/acme/cdi/translate/SentenceParser.java (rev 0)
+++ arquillian/trunk/demo/src/main/java/com/acme/cdi/translate/SentenceParser.java 2010-01-08 14:36:44 UTC (rev 3923)
@@ -0,0 +1,31 @@
+/*
+ * 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 com.acme.cdi.translate;
+
+import java.io.Serializable;
+import java.util.Arrays;
+import java.util.List;
+
+public class SentenceParser implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ public List<String> parse(String text)
+ {
+ return Arrays.asList(text.split(" "));
+ }
+}
\ No newline at end of file
Added: arquillian/trunk/demo/src/main/java/com/acme/cdi/translate/TextTranslator.java
===================================================================
--- arquillian/trunk/demo/src/main/java/com/acme/cdi/translate/TextTranslator.java (rev 0)
+++ arquillian/trunk/demo/src/main/java/com/acme/cdi/translate/TextTranslator.java 2010-01-08 14:36:44 UTC (rev 3923)
@@ -0,0 +1,44 @@
+/*
+ * 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 com.acme.cdi.translate;
+
+import java.io.Serializable;
+
+import javax.inject.Inject;
+
+public class TextTranslator implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ private SentenceParser sentenceParser;
+ private Translator sentenceTranslator;
+
+ @Inject
+ TextTranslator(SentenceParser sentenceParser, Translator sentenceTranslator) {
+ this.sentenceParser = sentenceParser;
+ this.sentenceTranslator = sentenceTranslator;
+ }
+
+ public String translate(String text) {
+
+ StringBuilder sb = new StringBuilder();
+ for (String sentence : sentenceParser.parse(text)) {
+ sb.append(sentenceTranslator.translate(sentence));
+ }
+ return sb.toString();
+ }
+}
\ No newline at end of file
Added: arquillian/trunk/demo/src/main/java/com/acme/cdi/translate/TranslateController.java
===================================================================
--- arquillian/trunk/demo/src/main/java/com/acme/cdi/translate/TranslateController.java (rev 0)
+++ arquillian/trunk/demo/src/main/java/com/acme/cdi/translate/TranslateController.java 2010-01-08 14:36:44 UTC (rev 3923)
@@ -0,0 +1,54 @@
+/*
+ * 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 com.acme.cdi.translate;
+
+import java.io.Serializable;
+
+import javax.enterprise.context.SessionScoped;
+import javax.inject.Inject;
+import javax.inject.Named;
+
+ at Named
+ at SessionScoped
+public class TranslateController implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ @Inject
+ TextTranslator textTranslator;
+
+ private String inputText;
+
+ private String translation;
+
+ // JSF action method, perhaps
+ public void translate() {
+ translation = textTranslator.translate(inputText);
+ }
+
+ public String getInputText() {
+ return inputText;
+ }
+
+ public void setInputText(String text) {
+ this.inputText = text;
+ }
+
+ public String getTranslation() {
+ return translation;
+ }
+}
\ No newline at end of file
Added: arquillian/trunk/demo/src/main/java/com/acme/cdi/translate/Translator.java
===================================================================
--- arquillian/trunk/demo/src/main/java/com/acme/cdi/translate/Translator.java (rev 0)
+++ arquillian/trunk/demo/src/main/java/com/acme/cdi/translate/Translator.java 2010-01-08 14:36:44 UTC (rev 3923)
@@ -0,0 +1,26 @@
+/*
+ * 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 com.acme.cdi.translate;
+
+import javax.ejb.Local;
+
+ at Local
+public interface Translator {
+
+ public String translate(String sentence);
+
+}
\ No newline at end of file
Added: arquillian/trunk/demo/src/test/java/com/acme/cdi/payment/SynchronousPaymentProcessorTestCase.java
===================================================================
--- arquillian/trunk/demo/src/test/java/com/acme/cdi/payment/SynchronousPaymentProcessorTestCase.java (rev 0)
+++ arquillian/trunk/demo/src/test/java/com/acme/cdi/payment/SynchronousPaymentProcessorTestCase.java 2010-01-08 14:36:44 UTC (rev 3923)
@@ -0,0 +1,58 @@
+/*
+ * 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 com.acme.cdi.payment;
+
+import javax.inject.Inject;
+
+import org.jboss.arquillian.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.shrinkwrap.api.Archives;
+import org.jboss.shrinkwrap.api.Paths;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+/**
+ * InjectionTestCase
+ *
+ * @author <a href="mailto:aslak at conduct.no">Aslak Knutsen</a>
+ * @version $Revision: $
+ */
+ at RunWith(Arquillian.class)
+public class SynchronousPaymentProcessorTestCase {
+
+ @Deployment
+ public static JavaArchive createDeployment() {
+ return Archives.create("test.jar", JavaArchive.class)
+ .addPackage(
+ Synchronous.class.getPackage()
+ )
+ .addManifestResource(
+ "com/acme/cdi/payment/beans.xml",
+ Paths.create("beans.xml"));
+ }
+
+ @Inject @Synchronous PaymentProcessor processor;
+
+ @Test
+ public void shouldBeReplacedByAMock() throws Exception
+ {
+ processor.process("");
+ Assert.assertTrue(MockPaymentProcessor.HAS_BEEN_CALLED);
+ }
+}
Added: arquillian/trunk/demo/src/test/java/com/acme/cdi/random/RandomTestCase.java
===================================================================
--- arquillian/trunk/demo/src/test/java/com/acme/cdi/random/RandomTestCase.java (rev 0)
+++ arquillian/trunk/demo/src/test/java/com/acme/cdi/random/RandomTestCase.java 2010-01-08 14:36:44 UTC (rev 3923)
@@ -0,0 +1,62 @@
+/*
+ * 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 com.acme.cdi.random;
+
+import javax.inject.Inject;
+
+import junit.framework.Assert;
+
+import org.jboss.arquillian.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.shrinkwrap.api.Archives;
+import org.jboss.shrinkwrap.api.Paths;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.jboss.shrinkwrap.impl.base.asset.ByteArrayAsset;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import com.acme.cdi.random.Random;
+
+/**
+ * InjectionTestCase
+ *
+ * @author <a href="mailto:aslak at conduct.no">Aslak Knutsen</a>
+ * @version $Revision: $
+ */
+ at RunWith(Arquillian.class)
+public class RandomTestCase {
+
+ @Deployment
+ public static JavaArchive createDeployment() {
+ return Archives.create("test.jar", JavaArchive.class)
+ .addPackage(
+ Random.class.getPackage()
+ )
+ .addManifestResource(
+ new ByteArrayAsset("<beans/>".getBytes()),
+ Paths.create("beans.xml"));
+ }
+
+ @Inject @Random
+ private int randomNumber;
+
+ @Test
+ public void shouldRun() throws Exception
+ {
+ Assert.assertTrue(randomNumber < 101);
+ }
+}
Added: arquillian/trunk/demo/src/test/java/com/acme/cdi/translate/TranslateTestCase.java
===================================================================
--- arquillian/trunk/demo/src/test/java/com/acme/cdi/translate/TranslateTestCase.java (rev 0)
+++ arquillian/trunk/demo/src/test/java/com/acme/cdi/translate/TranslateTestCase.java 2010-01-08 14:36:44 UTC (rev 3923)
@@ -0,0 +1,66 @@
+/*
+ * 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 com.acme.cdi.translate;
+
+import javax.inject.Inject;
+
+import junit.framework.Assert;
+
+import org.jboss.arquillian.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.shrinkwrap.api.Archives;
+import org.jboss.shrinkwrap.api.Paths;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.jboss.shrinkwrap.impl.base.asset.ByteArrayAsset;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import com.acme.cdi.translate.TranslateController;
+
+ at RunWith(Arquillian.class)
+public class TranslateTestCase {
+
+ @Deployment
+ public static JavaArchive createDeployment() {
+ return Archives.create("test.jar", JavaArchive.class)
+ .addPackage(
+ TranslateController.class.getPackage())
+ .addManifestResource(
+ new ByteArrayAsset("<beans/>".getBytes()),
+ Paths.create("beans.xml"));
+ }
+
+ @Inject TranslateController controller;
+
+ @Test
+ public void shouldSetInputText() throws Exception
+ {
+ controller.setInputText("hi");
+ }
+
+ @Test
+ public void shouldTranslate() throws Exception
+ {
+ controller.translate();
+ }
+
+ @Test
+ public void shouldVerify() throws Exception
+ {
+ Assert.assertEquals("hei", controller.getTranslation());
+ }
+}
Added: arquillian/trunk/demo/src/test/resources/com/acme/cdi/payment/beans.xml
===================================================================
--- arquillian/trunk/demo/src/test/resources/com/acme/cdi/payment/beans.xml (rev 0)
+++ arquillian/trunk/demo/src/test/resources/com/acme/cdi/payment/beans.xml 2010-01-08 14:36:44 UTC (rev 3923)
@@ -0,0 +1,6 @@
+<beans xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/beans_1_0.xsd">
+ <alternatives>
+ <class>com.acme.cdi.payment.MockPaymentProcessor</class>
+ </alternatives>
+</beans>
\ No newline at end of file
More information about the jboss-svn-commits
mailing list