You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by tv...@apache.org on 2015/11/23 23:07:23 UTC
[11/51] [partial] tomee git commit: removing ^M (windows eol)
http://git-wip-us.apache.org/repos/asf/tomee/blob/6e2a4f7c/examples/component-interfaces/src/test/java/org/superbiz/FriendlyPersonTest.java
----------------------------------------------------------------------
diff --git a/examples/component-interfaces/src/test/java/org/superbiz/FriendlyPersonTest.java b/examples/component-interfaces/src/test/java/org/superbiz/FriendlyPersonTest.java
index 60cb575..b55ba85 100644
--- a/examples/component-interfaces/src/test/java/org/superbiz/FriendlyPersonTest.java
+++ b/examples/component-interfaces/src/test/java/org/superbiz/FriendlyPersonTest.java
@@ -1,180 +1,180 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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
- * <p/>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p/>
- * 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.superbiz;
-
-import junit.framework.TestCase;
-
-import javax.ejb.embeddable.EJBContainer;
-import javax.naming.Context;
-import java.util.Locale;
-
-/**
- * @version $Rev$ $Date$
- */
-public class FriendlyPersonTest extends TestCase {
-
- private Context context;
-
- protected void setUp() throws Exception {
- context = EJBContainer.createEJBContainer().getContext();
- }
-
- /**
- * Here we lookup and test the FriendlyPerson bean via its EJB 2.1 EJBHome and EJBObject interfaces
- *
- * @throws Exception
- */
- //START SNIPPET: remotehome
- public void testEjbHomeAndEjbObject() throws Exception {
- Object object = context.lookup("java:global/component-interfaces/FriendlyPerson!org.superbiz.FriendlyPersonEjbHome");
- FriendlyPersonEjbHome home = (FriendlyPersonEjbHome) object;
- FriendlyPersonEjbObject friendlyPerson = home.create();
-
- friendlyPerson.setDefaultLanguage("en");
-
- assertEquals("Hello David!", friendlyPerson.greet("David"));
- assertEquals("Hello Amelia!", friendlyPerson.greet("Amelia"));
-
- friendlyPerson.setLanguagePreferences("Amelia", "es");
-
- assertEquals("Hello David!", friendlyPerson.greet("David"));
- assertEquals("Hola Amelia!", friendlyPerson.greet("Amelia"));
-
- // Amelia took some French, let's see if she remembers
- assertEquals("Bonjour Amelia!", friendlyPerson.greet("fr", "Amelia"));
-
- // Dave should take some Polish and if he had, he could say Hi in Polish
- assertEquals("Witaj Dave!", friendlyPerson.greet("pl", "Dave"));
-
- // Let's see if I speak Portuguese
- assertEquals("Sorry, I don't speak " + new Locale("pt").getDisplayLanguage() + ".", friendlyPerson.greet("pt", "David"));
-
- // Ok, well I've been meaning to learn, so...
- friendlyPerson.addGreeting("pt", "Ola {0}!");
-
- assertEquals("Ola David!", friendlyPerson.greet("pt", "David"));
- }
- //END SNIPPET: remotehome
-
- /**
- * Here we lookup and test the FriendlyPerson bean via its EJB 2.1 EJBLocalHome and EJBLocalObject interfaces
- *
- * @throws Exception
- */
- public void testEjbLocalHomeAndEjbLocalObject() throws Exception {
- Object object = context.lookup("java:global/component-interfaces/FriendlyPerson!org.superbiz.FriendlyPersonEjbLocalHome");
- FriendlyPersonEjbLocalHome home = (FriendlyPersonEjbLocalHome) object;
- FriendlyPersonEjbLocalObject friendlyPerson = home.create();
-
- friendlyPerson.setDefaultLanguage("en");
-
- assertEquals("Hello David!", friendlyPerson.greet("David"));
- assertEquals("Hello Amelia!", friendlyPerson.greet("Amelia"));
-
- friendlyPerson.setLanguagePreferences("Amelia", "es");
-
- assertEquals("Hello David!", friendlyPerson.greet("David"));
- assertEquals("Hola Amelia!", friendlyPerson.greet("Amelia"));
-
- // Amelia took some French, let's see if she remembers
- assertEquals("Bonjour Amelia!", friendlyPerson.greet("fr", "Amelia"));
-
- // Dave should take some Polish and if he had, he could say Hi in Polish
- assertEquals("Witaj Dave!", friendlyPerson.greet("pl", "Dave"));
-
- // Let's see if I speak Portuguese
- assertEquals("Sorry, I don't speak " + new Locale("pt").getDisplayLanguage() + ".", friendlyPerson.greet("pt", "David"));
-
- // Ok, well I've been meaning to learn, so...
- friendlyPerson.addGreeting("pt", "Ola {0}!");
-
- assertEquals("Ola David!", friendlyPerson.greet("pt", "David"));
- }
-
- /**
- * Here we lookup and test the FriendlyPerson bean via its EJB 3.0 business remote interface
- *
- * @throws Exception
- */
- //START SNIPPET: remote
- public void testBusinessRemote() throws Exception {
- Object object = context.lookup("java:global/component-interfaces/FriendlyPerson!org.superbiz.FriendlyPersonRemote");
-
- FriendlyPersonRemote friendlyPerson = (FriendlyPersonRemote) object;
-
- friendlyPerson.setDefaultLanguage("en");
-
- assertEquals("Hello David!", friendlyPerson.greet("David"));
- assertEquals("Hello Amelia!", friendlyPerson.greet("Amelia"));
-
- friendlyPerson.setLanguagePreferences("Amelia", "es");
-
- assertEquals("Hello David!", friendlyPerson.greet("David"));
- assertEquals("Hola Amelia!", friendlyPerson.greet("Amelia"));
-
- // Amelia took some French, let's see if she remembers
- assertEquals("Bonjour Amelia!", friendlyPerson.greet("fr", "Amelia"));
-
- // Dave should take some Polish and if he had, he could say Hi in Polish
- assertEquals("Witaj Dave!", friendlyPerson.greet("pl", "Dave"));
-
- // Let's see if I speak Portuguese
- assertEquals("Sorry, I don't speak " + new Locale("pt").getDisplayLanguage() + ".", friendlyPerson.greet("pt", "David"));
-
- // Ok, well I've been meaning to learn, so...
- friendlyPerson.addGreeting("pt", "Ola {0}!");
-
- assertEquals("Ola David!", friendlyPerson.greet("pt", "David"));
- }
- //START SNIPPET: remote
-
- /**
- * Here we lookup and test the FriendlyPerson bean via its EJB 3.0 business local interface
- *
- * @throws Exception
- */
- public void testBusinessLocal() throws Exception {
- Object object = context.lookup("java:global/component-interfaces/FriendlyPerson!org.superbiz.FriendlyPersonLocal");
-
- FriendlyPersonLocal friendlyPerson = (FriendlyPersonLocal) object;
-
- friendlyPerson.setDefaultLanguage("en");
-
- assertEquals("Hello David!", friendlyPerson.greet("David"));
- assertEquals("Hello Amelia!", friendlyPerson.greet("Amelia"));
-
- friendlyPerson.setLanguagePreferences("Amelia", "es");
-
- assertEquals("Hello David!", friendlyPerson.greet("David"));
- assertEquals("Hola Amelia!", friendlyPerson.greet("Amelia"));
-
- // Amelia took some French, let's see if she remembers
- assertEquals("Bonjour Amelia!", friendlyPerson.greet("fr", "Amelia"));
-
- // Dave should take some Polish and if he had, he could say Hi in Polish
- assertEquals("Witaj Dave!", friendlyPerson.greet("pl", "Dave"));
-
- // Let's see if I speak Portuguese
- assertEquals("Sorry, I don't speak " + new Locale("pt").getDisplayLanguage() + ".", friendlyPerson.greet("pt", "David"));
-
- // Ok, well I've been meaning to learn, so...
- friendlyPerson.addGreeting("pt", "Ola {0}!");
-
- assertEquals("Ola David!", friendlyPerson.greet("pt", "David"));
- }
-
-}
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.superbiz;
+
+import junit.framework.TestCase;
+
+import javax.ejb.embeddable.EJBContainer;
+import javax.naming.Context;
+import java.util.Locale;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class FriendlyPersonTest extends TestCase {
+
+ private Context context;
+
+ protected void setUp() throws Exception {
+ context = EJBContainer.createEJBContainer().getContext();
+ }
+
+ /**
+ * Here we lookup and test the FriendlyPerson bean via its EJB 2.1 EJBHome and EJBObject interfaces
+ *
+ * @throws Exception
+ */
+ //START SNIPPET: remotehome
+ public void testEjbHomeAndEjbObject() throws Exception {
+ Object object = context.lookup("java:global/component-interfaces/FriendlyPerson!org.superbiz.FriendlyPersonEjbHome");
+ FriendlyPersonEjbHome home = (FriendlyPersonEjbHome) object;
+ FriendlyPersonEjbObject friendlyPerson = home.create();
+
+ friendlyPerson.setDefaultLanguage("en");
+
+ assertEquals("Hello David!", friendlyPerson.greet("David"));
+ assertEquals("Hello Amelia!", friendlyPerson.greet("Amelia"));
+
+ friendlyPerson.setLanguagePreferences("Amelia", "es");
+
+ assertEquals("Hello David!", friendlyPerson.greet("David"));
+ assertEquals("Hola Amelia!", friendlyPerson.greet("Amelia"));
+
+ // Amelia took some French, let's see if she remembers
+ assertEquals("Bonjour Amelia!", friendlyPerson.greet("fr", "Amelia"));
+
+ // Dave should take some Polish and if he had, he could say Hi in Polish
+ assertEquals("Witaj Dave!", friendlyPerson.greet("pl", "Dave"));
+
+ // Let's see if I speak Portuguese
+ assertEquals("Sorry, I don't speak " + new Locale("pt").getDisplayLanguage() + ".", friendlyPerson.greet("pt", "David"));
+
+ // Ok, well I've been meaning to learn, so...
+ friendlyPerson.addGreeting("pt", "Ola {0}!");
+
+ assertEquals("Ola David!", friendlyPerson.greet("pt", "David"));
+ }
+ //END SNIPPET: remotehome
+
+ /**
+ * Here we lookup and test the FriendlyPerson bean via its EJB 2.1 EJBLocalHome and EJBLocalObject interfaces
+ *
+ * @throws Exception
+ */
+ public void testEjbLocalHomeAndEjbLocalObject() throws Exception {
+ Object object = context.lookup("java:global/component-interfaces/FriendlyPerson!org.superbiz.FriendlyPersonEjbLocalHome");
+ FriendlyPersonEjbLocalHome home = (FriendlyPersonEjbLocalHome) object;
+ FriendlyPersonEjbLocalObject friendlyPerson = home.create();
+
+ friendlyPerson.setDefaultLanguage("en");
+
+ assertEquals("Hello David!", friendlyPerson.greet("David"));
+ assertEquals("Hello Amelia!", friendlyPerson.greet("Amelia"));
+
+ friendlyPerson.setLanguagePreferences("Amelia", "es");
+
+ assertEquals("Hello David!", friendlyPerson.greet("David"));
+ assertEquals("Hola Amelia!", friendlyPerson.greet("Amelia"));
+
+ // Amelia took some French, let's see if she remembers
+ assertEquals("Bonjour Amelia!", friendlyPerson.greet("fr", "Amelia"));
+
+ // Dave should take some Polish and if he had, he could say Hi in Polish
+ assertEquals("Witaj Dave!", friendlyPerson.greet("pl", "Dave"));
+
+ // Let's see if I speak Portuguese
+ assertEquals("Sorry, I don't speak " + new Locale("pt").getDisplayLanguage() + ".", friendlyPerson.greet("pt", "David"));
+
+ // Ok, well I've been meaning to learn, so...
+ friendlyPerson.addGreeting("pt", "Ola {0}!");
+
+ assertEquals("Ola David!", friendlyPerson.greet("pt", "David"));
+ }
+
+ /**
+ * Here we lookup and test the FriendlyPerson bean via its EJB 3.0 business remote interface
+ *
+ * @throws Exception
+ */
+ //START SNIPPET: remote
+ public void testBusinessRemote() throws Exception {
+ Object object = context.lookup("java:global/component-interfaces/FriendlyPerson!org.superbiz.FriendlyPersonRemote");
+
+ FriendlyPersonRemote friendlyPerson = (FriendlyPersonRemote) object;
+
+ friendlyPerson.setDefaultLanguage("en");
+
+ assertEquals("Hello David!", friendlyPerson.greet("David"));
+ assertEquals("Hello Amelia!", friendlyPerson.greet("Amelia"));
+
+ friendlyPerson.setLanguagePreferences("Amelia", "es");
+
+ assertEquals("Hello David!", friendlyPerson.greet("David"));
+ assertEquals("Hola Amelia!", friendlyPerson.greet("Amelia"));
+
+ // Amelia took some French, let's see if she remembers
+ assertEquals("Bonjour Amelia!", friendlyPerson.greet("fr", "Amelia"));
+
+ // Dave should take some Polish and if he had, he could say Hi in Polish
+ assertEquals("Witaj Dave!", friendlyPerson.greet("pl", "Dave"));
+
+ // Let's see if I speak Portuguese
+ assertEquals("Sorry, I don't speak " + new Locale("pt").getDisplayLanguage() + ".", friendlyPerson.greet("pt", "David"));
+
+ // Ok, well I've been meaning to learn, so...
+ friendlyPerson.addGreeting("pt", "Ola {0}!");
+
+ assertEquals("Ola David!", friendlyPerson.greet("pt", "David"));
+ }
+ //START SNIPPET: remote
+
+ /**
+ * Here we lookup and test the FriendlyPerson bean via its EJB 3.0 business local interface
+ *
+ * @throws Exception
+ */
+ public void testBusinessLocal() throws Exception {
+ Object object = context.lookup("java:global/component-interfaces/FriendlyPerson!org.superbiz.FriendlyPersonLocal");
+
+ FriendlyPersonLocal friendlyPerson = (FriendlyPersonLocal) object;
+
+ friendlyPerson.setDefaultLanguage("en");
+
+ assertEquals("Hello David!", friendlyPerson.greet("David"));
+ assertEquals("Hello Amelia!", friendlyPerson.greet("Amelia"));
+
+ friendlyPerson.setLanguagePreferences("Amelia", "es");
+
+ assertEquals("Hello David!", friendlyPerson.greet("David"));
+ assertEquals("Hola Amelia!", friendlyPerson.greet("Amelia"));
+
+ // Amelia took some French, let's see if she remembers
+ assertEquals("Bonjour Amelia!", friendlyPerson.greet("fr", "Amelia"));
+
+ // Dave should take some Polish and if he had, he could say Hi in Polish
+ assertEquals("Witaj Dave!", friendlyPerson.greet("pl", "Dave"));
+
+ // Let's see if I speak Portuguese
+ assertEquals("Sorry, I don't speak " + new Locale("pt").getDisplayLanguage() + ".", friendlyPerson.greet("pt", "David"));
+
+ // Ok, well I've been meaning to learn, so...
+ friendlyPerson.addGreeting("pt", "Ola {0}!");
+
+ assertEquals("Ola David!", friendlyPerson.greet("pt", "David"));
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/tomee/blob/6e2a4f7c/examples/cucumber-jvm/src/test/java/org/superbiz/cucumber/CucumberTest.java
----------------------------------------------------------------------
diff --git a/examples/cucumber-jvm/src/test/java/org/superbiz/cucumber/CucumberTest.java b/examples/cucumber-jvm/src/test/java/org/superbiz/cucumber/CucumberTest.java
index f4abf95..511a2d0 100644
--- a/examples/cucumber-jvm/src/test/java/org/superbiz/cucumber/CucumberTest.java
+++ b/examples/cucumber-jvm/src/test/java/org/superbiz/cucumber/CucumberTest.java
@@ -1,25 +1,25 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.superbiz.cucumber;
-
-import cucumber.api.junit.Cucumber;
-import org.junit.runner.RunWith;
-
-@RunWith(Cucumber.class)
-public class CucumberTest {
- // the suite, will load automatically the features
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.superbiz.cucumber;
+
+import cucumber.api.junit.Cucumber;
+import org.junit.runner.RunWith;
+
+@RunWith(Cucumber.class)
+public class CucumberTest {
+ // the suite, will load automatically the features
+}
http://git-wip-us.apache.org/repos/asf/tomee/blob/6e2a4f7c/examples/cucumber-jvm/src/test/java/org/superbiz/cucumber/HelloStepDef.java
----------------------------------------------------------------------
diff --git a/examples/cucumber-jvm/src/test/java/org/superbiz/cucumber/HelloStepDef.java b/examples/cucumber-jvm/src/test/java/org/superbiz/cucumber/HelloStepDef.java
index b27e3a7..d082e15 100644
--- a/examples/cucumber-jvm/src/test/java/org/superbiz/cucumber/HelloStepDef.java
+++ b/examples/cucumber-jvm/src/test/java/org/superbiz/cucumber/HelloStepDef.java
@@ -1,42 +1,42 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.superbiz.cucumber;
-
-import cucumber.api.java.en.Given;
-import cucumber.api.java.en.Then;
-
-import javax.inject.Inject;
-
-import static org.junit.Assert.assertEquals;
-
-public class HelloStepDef {
-
- @Inject
- private Hello hello;
-
- private String name;
-
- @Given("^A name '([a-z]*)'$")
- public void initName(final String name) {
- this.name = name;
- }
-
- @Then("^The bean says '([ a-z]*)'$")
- public void checkResult(final String result) {
- assertEquals(result, hello.hello(name));
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.superbiz.cucumber;
+
+import cucumber.api.java.en.Given;
+import cucumber.api.java.en.Then;
+
+import javax.inject.Inject;
+
+import static org.junit.Assert.assertEquals;
+
+public class HelloStepDef {
+
+ @Inject
+ private Hello hello;
+
+ private String name;
+
+ @Given("^A name '([a-z]*)'$")
+ public void initName(final String name) {
+ this.name = name;
+ }
+
+ @Then("^The bean says '([ a-z]*)'$")
+ public void checkResult(final String result) {
+ assertEquals(result, hello.hello(name));
+ }
+}
http://git-wip-us.apache.org/repos/asf/tomee/blob/6e2a4f7c/examples/custom-injection/src/main/java/org/superbiz/enventries/Pickup.java
----------------------------------------------------------------------
diff --git a/examples/custom-injection/src/main/java/org/superbiz/enventries/Pickup.java b/examples/custom-injection/src/main/java/org/superbiz/enventries/Pickup.java
index b33dd5a..87668f2 100644
--- a/examples/custom-injection/src/main/java/org/superbiz/enventries/Pickup.java
+++ b/examples/custom-injection/src/main/java/org/superbiz/enventries/Pickup.java
@@ -1,35 +1,35 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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
- * <p/>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p/>
- * 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.superbiz.enventries;
-
-//START SNIPPET: code
-
-import java.beans.PropertyEditorManager;
-
-public enum Pickup {
-
- HUMBUCKER,
- SINGLE_COIL;
-
- // Here's the little magic where we register the PickupEditor
- // which knows how to create this object from a string.
- // You can add any of your own Property Editors in the same way.
- static {
- PropertyEditorManager.registerEditor(Pickup.class, PickupEditor.class);
- }
-}
-//END SNIPPET: code
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.superbiz.enventries;
+
+//START SNIPPET: code
+
+import java.beans.PropertyEditorManager;
+
+public enum Pickup {
+
+ HUMBUCKER,
+ SINGLE_COIL;
+
+ // Here's the little magic where we register the PickupEditor
+ // which knows how to create this object from a string.
+ // You can add any of your own Property Editors in the same way.
+ static {
+ PropertyEditorManager.registerEditor(Pickup.class, PickupEditor.class);
+ }
+}
+//END SNIPPET: code
http://git-wip-us.apache.org/repos/asf/tomee/blob/6e2a4f7c/examples/custom-injection/src/main/java/org/superbiz/enventries/PickupEditor.java
----------------------------------------------------------------------
diff --git a/examples/custom-injection/src/main/java/org/superbiz/enventries/PickupEditor.java b/examples/custom-injection/src/main/java/org/superbiz/enventries/PickupEditor.java
index 808cfe2..af6062b 100644
--- a/examples/custom-injection/src/main/java/org/superbiz/enventries/PickupEditor.java
+++ b/examples/custom-injection/src/main/java/org/superbiz/enventries/PickupEditor.java
@@ -1,45 +1,45 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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
- * <p/>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p/>
- * 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.superbiz.enventries;
-
-/**
- * With a java.beans.PropertyEditor, you can go way beyond the built-in
- * types that OpenEJB supports and can extend dependency injection to
- * just about anywhere.
- * <p/>
- * In the world of electric guitars, two types of pickups are used: humbucking, and single-coil.
- * Guitarists often refer to their guitars as HSS, meaning a guitar with 1 humbucker and
- * 2 single coil pickups, and so on. This little PropertyEditor supports that shorthand notation.
- *
- * @version $Revision$ $Date$
- */
-//START SNIPPET: code
-public class PickupEditor extends java.beans.PropertyEditorSupport {
-
- public void setAsText(String text) throws IllegalArgumentException {
- text = text.trim();
-
- if (text.equalsIgnoreCase("H")) {
- setValue(Pickup.HUMBUCKER);
- } else if (text.equalsIgnoreCase("S")) {
- setValue(Pickup.SINGLE_COIL);
- } else {
- throw new IllegalStateException("H and S are the only supported Pickup aliases");
- }
- }
-}
-//END SNIPPET: code
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.superbiz.enventries;
+
+/**
+ * With a java.beans.PropertyEditor, you can go way beyond the built-in
+ * types that OpenEJB supports and can extend dependency injection to
+ * just about anywhere.
+ * <p/>
+ * In the world of electric guitars, two types of pickups are used: humbucking, and single-coil.
+ * Guitarists often refer to their guitars as HSS, meaning a guitar with 1 humbucker and
+ * 2 single coil pickups, and so on. This little PropertyEditor supports that shorthand notation.
+ *
+ * @version $Revision$ $Date$
+ */
+//START SNIPPET: code
+public class PickupEditor extends java.beans.PropertyEditorSupport {
+
+ public void setAsText(String text) throws IllegalArgumentException {
+ text = text.trim();
+
+ if (text.equalsIgnoreCase("H")) {
+ setValue(Pickup.HUMBUCKER);
+ } else if (text.equalsIgnoreCase("S")) {
+ setValue(Pickup.SINGLE_COIL);
+ } else {
+ throw new IllegalStateException("H and S are the only supported Pickup aliases");
+ }
+ }
+}
+//END SNIPPET: code
http://git-wip-us.apache.org/repos/asf/tomee/blob/6e2a4f7c/examples/custom-injection/src/main/java/org/superbiz/enventries/Stratocaster.java
----------------------------------------------------------------------
diff --git a/examples/custom-injection/src/main/java/org/superbiz/enventries/Stratocaster.java b/examples/custom-injection/src/main/java/org/superbiz/enventries/Stratocaster.java
index 95a2fcf..a60bba5 100644
--- a/examples/custom-injection/src/main/java/org/superbiz/enventries/Stratocaster.java
+++ b/examples/custom-injection/src/main/java/org/superbiz/enventries/Stratocaster.java
@@ -1,76 +1,76 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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
- * <p/>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p/>
- * 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.superbiz.enventries;
-
-import javax.annotation.Resource;
-import javax.ejb.Stateless;
-import java.io.File;
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
-
-/**
- * In addition to the standard env-entry types (String, Integer, Long, Short, Byte, Boolean, Double, Float, Character)
- * OpenEJB supports many other types.
- */
-//START SNIPPET: code
-@Stateless
-public class Stratocaster {
-
- @Resource(name = "pickups")
- private List<Pickup> pickups;
-
- @Resource(name = "style")
- private Style style;
-
- @Resource(name = "dateCreated")
- private Date dateCreated;
-
- @Resource(name = "guitarStringGuages")
- private Map<String, Float> guitarStringGuages;
-
- @Resource(name = "certificateOfAuthenticity")
- private File certificateOfAuthenticity;
-
- public Date getDateCreated() {
- return dateCreated;
- }
-
- /**
- * Gets the guage of the electric guitar strings
- * used in this guitar.
- *
- * @param string
- * @return
- */
- public float getStringGuage(String string) {
- return guitarStringGuages.get(string);
- }
-
- public List<Pickup> getPickups() {
- return pickups;
- }
-
- public Style getStyle() {
- return style;
- }
-
- public File getCertificateOfAuthenticity() {
- return certificateOfAuthenticity;
- }
-}
-//END SNIPPET: code
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.superbiz.enventries;
+
+import javax.annotation.Resource;
+import javax.ejb.Stateless;
+import java.io.File;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * In addition to the standard env-entry types (String, Integer, Long, Short, Byte, Boolean, Double, Float, Character)
+ * OpenEJB supports many other types.
+ */
+//START SNIPPET: code
+@Stateless
+public class Stratocaster {
+
+ @Resource(name = "pickups")
+ private List<Pickup> pickups;
+
+ @Resource(name = "style")
+ private Style style;
+
+ @Resource(name = "dateCreated")
+ private Date dateCreated;
+
+ @Resource(name = "guitarStringGuages")
+ private Map<String, Float> guitarStringGuages;
+
+ @Resource(name = "certificateOfAuthenticity")
+ private File certificateOfAuthenticity;
+
+ public Date getDateCreated() {
+ return dateCreated;
+ }
+
+ /**
+ * Gets the guage of the electric guitar strings
+ * used in this guitar.
+ *
+ * @param string
+ * @return
+ */
+ public float getStringGuage(String string) {
+ return guitarStringGuages.get(string);
+ }
+
+ public List<Pickup> getPickups() {
+ return pickups;
+ }
+
+ public Style getStyle() {
+ return style;
+ }
+
+ public File getCertificateOfAuthenticity() {
+ return certificateOfAuthenticity;
+ }
+}
+//END SNIPPET: code
http://git-wip-us.apache.org/repos/asf/tomee/blob/6e2a4f7c/examples/custom-injection/src/main/java/org/superbiz/enventries/Style.java
----------------------------------------------------------------------
diff --git a/examples/custom-injection/src/main/java/org/superbiz/enventries/Style.java b/examples/custom-injection/src/main/java/org/superbiz/enventries/Style.java
index 57fc335..5e5919c 100644
--- a/examples/custom-injection/src/main/java/org/superbiz/enventries/Style.java
+++ b/examples/custom-injection/src/main/java/org/superbiz/enventries/Style.java
@@ -1,30 +1,30 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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
- * <p/>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p/>
- * 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.superbiz.enventries;
-
-/**
- * @version $Revision$ $Date$
- */
-//START SNIPPET: code
-public enum Style {
-
- STANDARD,
- DELUX,
- VINTAGE;
-
-}
-//END SNIPPET: code
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.superbiz.enventries;
+
+/**
+ * @version $Revision$ $Date$
+ */
+//START SNIPPET: code
+public enum Style {
+
+ STANDARD,
+ DELUX,
+ VINTAGE;
+
+}
+//END SNIPPET: code
http://git-wip-us.apache.org/repos/asf/tomee/blob/6e2a4f7c/examples/custom-injection/src/test/java/org/superbiz/enventries/StratocasterTest.java
----------------------------------------------------------------------
diff --git a/examples/custom-injection/src/test/java/org/superbiz/enventries/StratocasterTest.java b/examples/custom-injection/src/test/java/org/superbiz/enventries/StratocasterTest.java
index 03822c6..81242ab 100644
--- a/examples/custom-injection/src/test/java/org/superbiz/enventries/StratocasterTest.java
+++ b/examples/custom-injection/src/test/java/org/superbiz/enventries/StratocasterTest.java
@@ -1,63 +1,63 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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
- * <p/>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p/>
- * 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.superbiz.enventries;
-
-import junit.framework.TestCase;
-
-import javax.ejb.EJB;
-import javax.ejb.embeddable.EJBContainer;
-import java.io.File;
-import java.text.DateFormat;
-import java.util.Date;
-import java.util.List;
-import java.util.Locale;
-
-import static java.util.Arrays.asList;
-
-/**
- * @version $Rev$ $Date$
- */
-//START SNIPPET: code
-public class StratocasterTest extends TestCase {
-
- @EJB
- private Stratocaster strat;
-
- public void test() throws Exception {
- EJBContainer.createEJBContainer().getContext().bind("inject", this);
-
- Date date = DateFormat.getDateInstance(DateFormat.MEDIUM, Locale.US).parse("Mar 1, 1962");
- assertEquals("Strat.getDateCreated()", date, strat.getDateCreated());
-
- List<Pickup> pickups = asList(Pickup.SINGLE_COIL, Pickup.SINGLE_COIL, Pickup.SINGLE_COIL);
- assertEquals("Strat.getPickups()", pickups, strat.getPickups());
-
- assertEquals("Strat.getStyle()", Style.VINTAGE, strat.getStyle());
-
- assertEquals("Strat.getStringGuage(\"E1\")", 0.052F, strat.getStringGuage("E1"), 1e-15);
- assertEquals("Strat.getStringGuage(\"A\")", 0.042F, strat.getStringGuage("A"), 1e-15);
- assertEquals("Strat.getStringGuage(\"D\")", 0.030F, strat.getStringGuage("D"), 1e-15);
- assertEquals("Strat.getStringGuage(\"G\")", 0.017F, strat.getStringGuage("G"), 1e-15);
- assertEquals("Strat.getStringGuage(\"B\")", 0.013F, strat.getStringGuage("B"), 1e-15);
- assertEquals("Strat.getStringGuage(\"E\")", 0.010F, strat.getStringGuage("E"), 1e-15);
-
- File file = new File("/tmp/strat-certificate.txt");
- assertEquals("Strat.getCertificateOfAuthenticity()", file, strat.getCertificateOfAuthenticity());
-
- }
-}
-//END SNIPPET: code
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.superbiz.enventries;
+
+import junit.framework.TestCase;
+
+import javax.ejb.EJB;
+import javax.ejb.embeddable.EJBContainer;
+import java.io.File;
+import java.text.DateFormat;
+import java.util.Date;
+import java.util.List;
+import java.util.Locale;
+
+import static java.util.Arrays.asList;
+
+/**
+ * @version $Rev$ $Date$
+ */
+//START SNIPPET: code
+public class StratocasterTest extends TestCase {
+
+ @EJB
+ private Stratocaster strat;
+
+ public void test() throws Exception {
+ EJBContainer.createEJBContainer().getContext().bind("inject", this);
+
+ Date date = DateFormat.getDateInstance(DateFormat.MEDIUM, Locale.US).parse("Mar 1, 1962");
+ assertEquals("Strat.getDateCreated()", date, strat.getDateCreated());
+
+ List<Pickup> pickups = asList(Pickup.SINGLE_COIL, Pickup.SINGLE_COIL, Pickup.SINGLE_COIL);
+ assertEquals("Strat.getPickups()", pickups, strat.getPickups());
+
+ assertEquals("Strat.getStyle()", Style.VINTAGE, strat.getStyle());
+
+ assertEquals("Strat.getStringGuage(\"E1\")", 0.052F, strat.getStringGuage("E1"), 1e-15);
+ assertEquals("Strat.getStringGuage(\"A\")", 0.042F, strat.getStringGuage("A"), 1e-15);
+ assertEquals("Strat.getStringGuage(\"D\")", 0.030F, strat.getStringGuage("D"), 1e-15);
+ assertEquals("Strat.getStringGuage(\"G\")", 0.017F, strat.getStringGuage("G"), 1e-15);
+ assertEquals("Strat.getStringGuage(\"B\")", 0.013F, strat.getStringGuage("B"), 1e-15);
+ assertEquals("Strat.getStringGuage(\"E\")", 0.010F, strat.getStringGuage("E"), 1e-15);
+
+ File file = new File("/tmp/strat-certificate.txt");
+ assertEquals("Strat.getCertificateOfAuthenticity()", file, strat.getCertificateOfAuthenticity());
+
+ }
+}
+//END SNIPPET: code
http://git-wip-us.apache.org/repos/asf/tomee/blob/6e2a4f7c/examples/datasource-definition/src/main/java/org/superbiz/dsdef/Persister.java
----------------------------------------------------------------------
diff --git a/examples/datasource-definition/src/main/java/org/superbiz/dsdef/Persister.java b/examples/datasource-definition/src/main/java/org/superbiz/dsdef/Persister.java
index bd65da8..f8fd676 100644
--- a/examples/datasource-definition/src/main/java/org/superbiz/dsdef/Persister.java
+++ b/examples/datasource-definition/src/main/java/org/superbiz/dsdef/Persister.java
@@ -1,42 +1,42 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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
- * <p/>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p/>
- * 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.superbiz.dsdef;
-
-import javax.annotation.Resource;
-import javax.annotation.sql.DataSourceDefinition;
-import javax.inject.Named;
-import javax.sql.DataSource;
-
-@DataSourceDefinition(transactional = true,
- url = "jdbc:h2:mem:persister",
- className = "org.h2.jdbcx.JdbcDataSource",
- user = "sa",
- password = "",
- name = "java:app/jdbc/persister",
- initialPoolSize = 1,
- maxPoolSize = 3
-)
-@Named
-public class Persister {
-
- @Resource(lookup = "java:app/jdbc/persister")
- private DataSource ds;
-
- public DataSource getDs() {
- return ds;
- }
-}
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.superbiz.dsdef;
+
+import javax.annotation.Resource;
+import javax.annotation.sql.DataSourceDefinition;
+import javax.inject.Named;
+import javax.sql.DataSource;
+
+@DataSourceDefinition(transactional = true,
+ url = "jdbc:h2:mem:persister",
+ className = "org.h2.jdbcx.JdbcDataSource",
+ user = "sa",
+ password = "",
+ name = "java:app/jdbc/persister",
+ initialPoolSize = 1,
+ maxPoolSize = 3
+)
+@Named
+public class Persister {
+
+ @Resource(lookup = "java:app/jdbc/persister")
+ private DataSource ds;
+
+ public DataSource getDs() {
+ return ds;
+ }
+}
http://git-wip-us.apache.org/repos/asf/tomee/blob/6e2a4f7c/examples/datasource-definition/src/test/java/org/superbiz/dsdef/DataSourceDefinitionTest.java
----------------------------------------------------------------------
diff --git a/examples/datasource-definition/src/test/java/org/superbiz/dsdef/DataSourceDefinitionTest.java b/examples/datasource-definition/src/test/java/org/superbiz/dsdef/DataSourceDefinitionTest.java
index aedc7ea..c323c51 100644
--- a/examples/datasource-definition/src/test/java/org/superbiz/dsdef/DataSourceDefinitionTest.java
+++ b/examples/datasource-definition/src/test/java/org/superbiz/dsdef/DataSourceDefinitionTest.java
@@ -1,110 +1,110 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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
- * <p/>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p/>
- * 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.superbiz.dsdef;
-
-import org.apache.openejb.resource.jdbc.dbcp.DbcpManagedDataSource;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-import javax.ejb.embeddable.EJBContainer;
-import javax.inject.Inject;
-import javax.naming.NamingException;
-import javax.sql.DataSource;
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-
-import static org.hamcrest.CoreMatchers.instanceOf;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertThat;
-import static org.junit.Assert.assertTrue;
-
-public class DataSourceDefinitionTest {
-
- private static EJBContainer container;
-
- @Inject
- private Persister persister;
-
- @BeforeClass
- public static void start() {
- container = EJBContainer.createEJBContainer();
- }
-
- @Before
- public void inject() throws NamingException {
- container.getContext().bind("inject", this);
- }
-
- @AfterClass
- public static void stop() {
- container.close();
- }
-
- @Test
- public void checkDs() throws SQLException {
- final DataSource ds = persister.getDs();
- assertNotNull(ds);
- assertThat(ds, instanceOf(DbcpManagedDataSource.class));
-
- final DbcpManagedDataSource castedDs = (DbcpManagedDataSource) ds;
-
- final String driver = castedDs.getDriverClassName();
- assertEquals("org.h2.jdbcx.JdbcDataSource", driver);
-
- final String user = castedDs.getUserName();
- assertEquals("sa", user);
-
- final String url = castedDs.getUrl();
- assertEquals("jdbc:h2:mem:persister", url);
-
- final int initPoolSize = castedDs.getInitialSize();
- assertEquals(1, initPoolSize);
-
- final int maxIdle = castedDs.getMaxIdle();
- assertEquals(3, maxIdle);
-
- final Connection connection = ds.getConnection();
- assertNotNull(connection);
-
- execute(connection, "CREATE TABLE TEST(ID INT PRIMARY KEY, NAME VARCHAR(255))");
- execute(connection, "INSERT INTO TEST(ID, NAME) VALUES(1, 'foo')");
- connection.commit();
-
- final PreparedStatement statement = ds.getConnection().prepareStatement("SELECT NAME FROM TEST");
- statement.execute();
- final ResultSet set = statement.getResultSet();
-
- assertTrue(set.next());
- assertEquals("foo", set.getString("NAME"));
- }
-
- @Test
- public void lookup() throws NamingException {
- final Object o = container.getContext().lookup("java:app/jdbc/persister");
- assertNotNull(o);
- assertEquals(persister.getDs(), o);
- }
-
- private void execute(final Connection connection, final String sql) throws SQLException {
- connection.prepareStatement(sql).execute();
- }
-}
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.superbiz.dsdef;
+
+import org.apache.openejb.resource.jdbc.dbcp.DbcpManagedDataSource;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import javax.ejb.embeddable.EJBContainer;
+import javax.inject.Inject;
+import javax.naming.NamingException;
+import javax.sql.DataSource;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+import static org.hamcrest.CoreMatchers.instanceOf;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
+
+public class DataSourceDefinitionTest {
+
+ private static EJBContainer container;
+
+ @Inject
+ private Persister persister;
+
+ @BeforeClass
+ public static void start() {
+ container = EJBContainer.createEJBContainer();
+ }
+
+ @Before
+ public void inject() throws NamingException {
+ container.getContext().bind("inject", this);
+ }
+
+ @AfterClass
+ public static void stop() {
+ container.close();
+ }
+
+ @Test
+ public void checkDs() throws SQLException {
+ final DataSource ds = persister.getDs();
+ assertNotNull(ds);
+ assertThat(ds, instanceOf(DbcpManagedDataSource.class));
+
+ final DbcpManagedDataSource castedDs = (DbcpManagedDataSource) ds;
+
+ final String driver = castedDs.getDriverClassName();
+ assertEquals("org.h2.jdbcx.JdbcDataSource", driver);
+
+ final String user = castedDs.getUserName();
+ assertEquals("sa", user);
+
+ final String url = castedDs.getUrl();
+ assertEquals("jdbc:h2:mem:persister", url);
+
+ final int initPoolSize = castedDs.getInitialSize();
+ assertEquals(1, initPoolSize);
+
+ final int maxIdle = castedDs.getMaxIdle();
+ assertEquals(3, maxIdle);
+
+ final Connection connection = ds.getConnection();
+ assertNotNull(connection);
+
+ execute(connection, "CREATE TABLE TEST(ID INT PRIMARY KEY, NAME VARCHAR(255))");
+ execute(connection, "INSERT INTO TEST(ID, NAME) VALUES(1, 'foo')");
+ connection.commit();
+
+ final PreparedStatement statement = ds.getConnection().prepareStatement("SELECT NAME FROM TEST");
+ statement.execute();
+ final ResultSet set = statement.getResultSet();
+
+ assertTrue(set.next());
+ assertEquals("foo", set.getString("NAME"));
+ }
+
+ @Test
+ public void lookup() throws NamingException {
+ final Object o = container.getContext().lookup("java:app/jdbc/persister");
+ assertNotNull(o);
+ assertEquals(persister.getDs(), o);
+ }
+
+ private void execute(final Connection connection, final String sql) throws SQLException {
+ connection.prepareStatement(sql).execute();
+ }
+}