Source Code Cross Referenced for ServiceConfigBuilderTest.java in  » EJB-Server-geronimo » service-builder » org » apache » geronimo » deployment » service » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » EJB Server geronimo » service builder » org.apache.geronimo.deployment.service 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         *  Licensed to the Apache Software Foundation (ASF) under one or more
003:         *  contributor license agreements.  See the NOTICE file distributed with
004:         *  this work for additional information regarding copyright ownership.
005:         *  The ASF licenses this file to You under the Apache License, Version 2.0
006:         *  (the "License"); you may not use this file except in compliance with
007:         *  the License.  You may obtain a copy of the License at
008:         *
009:         *     http://www.apache.org/licenses/LICENSE-2.0
010:         *
011:         *  Unless required by applicable law or agreed to in writing, software
012:         *  distributed under the License is distributed on an "AS IS" BASIS,
013:         *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         *  See the License for the specific language governing permissions and
015:         *  limitations under the License.
016:         */package org.apache.geronimo.deployment.service;
017:
018:        import java.io.File;
019:        import java.net.URL;
020:        import java.util.ArrayList;
021:        import java.util.Collections;
022:        import java.util.Set;
023:        import java.util.HashSet;
024:        import java.util.jar.JarFile;
025:
026:        import javax.management.ObjectName;
027:
028:        import junit.framework.TestCase;
029:        import org.apache.geronimo.deployment.DeploymentContext;
030:        import org.apache.geronimo.deployment.FooBarBean;
031:        import org.apache.geronimo.deployment.ModuleIDBuilder;
032:        import org.apache.geronimo.deployment.NamespaceDrivenBuilder;
033:        import org.apache.geronimo.deployment.xbeans.ModuleDocument;
034:        import org.apache.geronimo.deployment.xbeans.ModuleType;
035:        import org.apache.geronimo.gbean.AbstractName;
036:        import org.apache.geronimo.gbean.GBeanData;
037:        import org.apache.geronimo.gbean.ReferenceCollection;
038:        import org.apache.geronimo.gbean.ReferenceCollectionListener;
039:        import org.apache.geronimo.kernel.Jsr77Naming;
040:        import org.apache.geronimo.kernel.Naming;
041:        import org.apache.geronimo.kernel.config.ConfigurationManager;
042:        import org.apache.geronimo.kernel.config.ConfigurationModuleType;
043:        import org.apache.geronimo.kernel.config.SimpleConfigurationManager;
044:        import org.apache.geronimo.kernel.mock.MockRepository;
045:        import org.apache.geronimo.kernel.repository.ArtifactManager;
046:        import org.apache.geronimo.kernel.repository.ArtifactResolver;
047:        import org.apache.geronimo.kernel.repository.DefaultArtifactManager;
048:        import org.apache.geronimo.kernel.repository.DefaultArtifactResolver;
049:        import org.apache.geronimo.kernel.repository.Environment;
050:        import org.apache.geronimo.kernel.repository.ListableRepository;
051:        import org.apache.geronimo.kernel.repository.Artifact;
052:
053:        /**
054:         * @version $Rev: 566893 $ $Date: 2007-08-16 17:52:52 -0700 (Thu, 16 Aug 2007) $
055:         */
056:        public class ServiceConfigBuilderTest extends TestCase {
057:
058:            private Environment parentEnvironment = new Environment();
059:
060:            public void testNonService() throws Exception {
061:                URL url = getClass().getResource("/empty.jar");
062:                File file = new File(url.getPath());
063:                JarFile jar = new JarFile(file);
064:                assertTrue(file.exists());
065:                ServiceConfigBuilder builder = new ServiceConfigBuilder(
066:                        parentEnvironment, null, new Jsr77Naming());
067:                assertNull(builder.getDeploymentPlan(null, jar,
068:                        new ModuleIDBuilder()));
069:                jar.close();
070:            }
071:
072:            public void testJavaBeanXmlAttribute() throws Exception {
073:                ReferenceCollection referenceCollection = new MockReferenceCollection();
074:                JavaBeanXmlAttributeBuilder javaBeanXmlAttributeBuilder = new JavaBeanXmlAttributeBuilder();
075:                //this is kind of cheating, we rely on the builder to iterate through existing members of the collection.
076:                referenceCollection.add(javaBeanXmlAttributeBuilder);
077:                Naming naming = new Jsr77Naming();
078:                NamespaceDrivenBuilder gbeanBuilder = new GBeanBuilder(
079:                        referenceCollection, null);
080:                //        ConfigurationBuilder serviceBuilder = new ServiceConfigBuilder(parentEnvironment, null, Collections.singleton(gbeanBuilder), naming);
081:                ClassLoader cl = Thread.currentThread().getContextClassLoader();
082:                final URL plan1 = cl.getResource("services/plan1.xml");
083:                ModuleDocument doc = ModuleDocument.Factory.parse(plan1);
084:                ModuleType plan = doc.getModule();
085:                File outFile = File.createTempFile("foo", "bar");
086:                outFile.delete();
087:                if (!outFile.mkdirs()) {
088:                    fail("could not create temp dir");
089:                }
090:                try {
091:
092:                    Environment environment = EnvironmentBuilder
093:                            .buildEnvironment(plan.getEnvironment());
094:                    Set<Artifact> repo = new HashSet<Artifact>();
095:                    repo.add(Artifact.create("geronimo/foo1/DEV/car"));
096:                    repo.add(Artifact.create("geronimo/foo2/DEV/car"));
097:                    repo.add(Artifact.create("geronimo/foo3/DEV/car"));
098:                    repo.add(Artifact.create("geronimo/foo4/DEV/car"));
099:                    ListableRepository mockRepository = new MockRepository(repo);
100:                    ArtifactManager artifactManager = new DefaultArtifactManager();
101:                    ArtifactResolver artifactResolver = new DefaultArtifactResolver(
102:                            artifactManager, Collections
103:                                    .singleton(mockRepository), null);
104:                    ConfigurationManager configurationManager = new SimpleConfigurationManager(
105:                            Collections.EMPTY_SET, artifactResolver,
106:                            Collections.EMPTY_SET);
107:                    AbstractName moduleName = naming.createRootName(environment
108:                            .getConfigId(), "foo", "bar");
109:                    DeploymentContext context = new DeploymentContext(outFile,
110:                            null, environment, moduleName,
111:                            ConfigurationModuleType.CAR, naming,
112:                            configurationManager, Collections
113:                                    .singleton(mockRepository));
114:
115:                    gbeanBuilder.build(plan, context, context);
116:                    Set gbeanNames = context.getGBeanNames();
117:                    assertEquals(1, gbeanNames.size());
118:                    AbstractName beanName = (AbstractName) gbeanNames
119:                            .iterator().next();
120:                    GBeanData data = context.getGBeanInstance(beanName);
121:                    FooBarBean fooBarBean = (FooBarBean) data
122:                            .getAttribute("fooBarBean");
123:                    assertNotNull(fooBarBean);
124:                    assertEquals("foo", fooBarBean.getFoo());
125:                    assertEquals(10, fooBarBean.getBar());
126:                    FooBarBean inner = fooBarBean.getBean();
127:                    assertNotNull(inner);
128:                    assertEquals("foo2", inner.getFoo());
129:                    assertEquals(100, inner.getBar());
130:                    assertNull(inner.getBean());
131:                } finally {
132:                    recursiveDelete(outFile);
133:                }
134:            }
135:
136:            private void recursiveDelete(File file) {
137:
138:                File[] list = file.listFiles();
139:                if (list != null) {
140:                    for (int i = 0; i < list.length; i++) {
141:                        File file1 = list[i];
142:                        if (file1.isDirectory()) {
143:                            recursiveDelete(file1);
144:                        }
145:                    }
146:                }
147:                file.delete();
148:            }
149:
150:            private static class MockReferenceCollection extends ArrayList
151:                    implements  ReferenceCollection {
152:
153:                public void addReferenceCollectionListener(
154:                        ReferenceCollectionListener listener) {
155:
156:                }
157:
158:                public void removeReferenceCollectionListener(
159:                        ReferenceCollectionListener listener) {
160:
161:                }
162:
163:                public ObjectName[] getMemberObjectNames() {
164:                    return new ObjectName[0];
165:                }
166:            }
167:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.