You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicemix.apache.org by fo...@apache.org on 2006/01/13 15:29:05 UTC
svn commit: r368741 - in
/incubator/servicemix/trunk/tooling/servicemix-web/src/test/java/org/apache:
./ web/ web/JettyServer.java web/jmx/ web/jmx/Foo.java
web/jmx/FooMBean.java web/jmx/JMXWriterTest.java
Author: foconer
Date: Fri Jan 13 06:28:51 2006
New Revision: 368741
URL: http://svn.apache.org/viewcvs?rev=368741&view=rev
Log:
refactored to org.apache.servicemix...
Added:
incubator/servicemix/trunk/tooling/servicemix-web/src/test/java/org/apache/
incubator/servicemix/trunk/tooling/servicemix-web/src/test/java/org/apache/web/
incubator/servicemix/trunk/tooling/servicemix-web/src/test/java/org/apache/web/JettyServer.java
incubator/servicemix/trunk/tooling/servicemix-web/src/test/java/org/apache/web/jmx/
incubator/servicemix/trunk/tooling/servicemix-web/src/test/java/org/apache/web/jmx/Foo.java
incubator/servicemix/trunk/tooling/servicemix-web/src/test/java/org/apache/web/jmx/FooMBean.java
incubator/servicemix/trunk/tooling/servicemix-web/src/test/java/org/apache/web/jmx/JMXWriterTest.java
Added: incubator/servicemix/trunk/tooling/servicemix-web/src/test/java/org/apache/web/JettyServer.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/tooling/servicemix-web/src/test/java/org/apache/web/JettyServer.java?rev=368741&view=auto
==============================================================================
--- incubator/servicemix/trunk/tooling/servicemix-web/src/test/java/org/apache/web/JettyServer.java (added)
+++ incubator/servicemix/trunk/tooling/servicemix-web/src/test/java/org/apache/web/JettyServer.java Fri Jan 13 06:28:51 2006
@@ -0,0 +1,50 @@
+package org.apache.servicemix.web;
+/**
+ *
+ * Copyright 2005 LogicBlaze, Inc. http://www.logicblaze.com
+ *
+ * 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.
+ *
+ **/
+
+import org.mortbay.http.SocketListener;
+import org.mortbay.jetty.Server;
+
+/**
+ * A simple bootstrap class for starting Jetty in your IDE using the local web application.
+ *
+ * @version $Revision: 356269 $
+ */
+public class JettyServer {
+
+ public static final int PORT = 8080;
+
+ public static final String WEBAPP_DIR = "src/webapp";
+
+ public static final String WEBAPP_CTX = "/";
+
+ public static void main(String[] args) throws Exception {
+ int port = PORT;
+ if (args.length > 0) {
+ String text = args[0];
+ port = Integer.parseInt(text);
+ }
+ System.out.println("Starting Web Server on port: " + port);
+ Server server = new Server();
+ SocketListener listener = new SocketListener();
+ listener.setPort(port);
+ server.addWebApplication(WEBAPP_CTX, WEBAPP_DIR);
+ server.addListener(listener);
+ server.start();
+ }
+}
Added: incubator/servicemix/trunk/tooling/servicemix-web/src/test/java/org/apache/web/jmx/Foo.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/tooling/servicemix-web/src/test/java/org/apache/web/jmx/Foo.java?rev=368741&view=auto
==============================================================================
--- incubator/servicemix/trunk/tooling/servicemix-web/src/test/java/org/apache/web/jmx/Foo.java (added)
+++ incubator/servicemix/trunk/tooling/servicemix-web/src/test/java/org/apache/web/jmx/Foo.java Fri Jan 13 06:28:51 2006
@@ -0,0 +1,57 @@
+/**
+ *
+ * Copyright 2005 LogicBlaze, Inc. http://www.logicblaze.com
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ **/
+package org.apache.servicemix.web.jmx;
+
+/**
+ * A dummy MBean implementation
+ *
+ * @version $Revision: 356269 $
+ */
+public class Foo implements FooMBean {
+
+ private int counter;
+ private String name = "James";
+
+ public Foo() {
+ }
+
+ public Foo(String name) {
+ this.name = name;
+ }
+
+ public void increment() {
+ ++counter;
+ }
+
+ public int getCounter() {
+ return counter;
+ }
+
+ public void setCounter(int counter) {
+ this.counter = counter;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+}
Added: incubator/servicemix/trunk/tooling/servicemix-web/src/test/java/org/apache/web/jmx/FooMBean.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/tooling/servicemix-web/src/test/java/org/apache/web/jmx/FooMBean.java?rev=368741&view=auto
==============================================================================
--- incubator/servicemix/trunk/tooling/servicemix-web/src/test/java/org/apache/web/jmx/FooMBean.java (added)
+++ incubator/servicemix/trunk/tooling/servicemix-web/src/test/java/org/apache/web/jmx/FooMBean.java Fri Jan 13 06:28:51 2006
@@ -0,0 +1,37 @@
+/**
+ *
+ * Copyright 2005 LogicBlaze, Inc. http://www.logicblaze.com
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ **/
+
+package org.apache.servicemix.web.jmx;
+
+/**
+ *
+ * @version $Revision: 356269 $
+ */
+public interface FooMBean {
+
+ public void increment();
+
+ public int getCounter();
+
+ public void setCounter(int counter);
+
+ public String getName();
+
+ public void setName(String name);
+
+}
\ No newline at end of file
Added: incubator/servicemix/trunk/tooling/servicemix-web/src/test/java/org/apache/web/jmx/JMXWriterTest.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/tooling/servicemix-web/src/test/java/org/apache/web/jmx/JMXWriterTest.java?rev=368741&view=auto
==============================================================================
--- incubator/servicemix/trunk/tooling/servicemix-web/src/test/java/org/apache/web/jmx/JMXWriterTest.java (added)
+++ incubator/servicemix/trunk/tooling/servicemix-web/src/test/java/org/apache/web/jmx/JMXWriterTest.java Fri Jan 13 06:28:51 2006
@@ -0,0 +1,71 @@
+/**
+ *
+ * Copyright 2005 LogicBlaze, Inc. http://www.logicblaze.com
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ **/
+package org.apache.servicemix.web.jmx;
+
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+
+import java.io.OutputStreamWriter;
+import java.io.PrintWriter;
+import java.util.Set;
+
+import junit.framework.TestCase;
+
+/**
+ *
+ * @version $Revision: 356269 $
+ */
+public class JMXWriterTest extends TestCase {
+
+ protected PrintWriter writer;
+ private JMXWriter jmxWriter;
+ private ManagementContext managementContext = new ManagementContext();
+
+ public void testDetail() throws Exception {
+ Set names = managementContext.getMBeanServer().queryNames(null, null);
+ jmxWriter.outputDetail(names);
+ }
+
+ public void testQuery() throws Exception {
+ MBeanServer beanServer = managementContext.getMBeanServer();
+
+ beanServer.registerMBean(new Foo("James"), new ObjectName("Bar:type=Foo,name=James"));
+ beanServer.registerMBean(new Foo("Rob"), new ObjectName("Bar:type=Foo,name=Rob"));
+ beanServer.registerMBean(new Foo("Hiram"), new ObjectName("Bar:type=Foo,name=Hiram"));
+
+
+ // now lets try find some MBeans using a query
+
+ Set result = beanServer.queryMBeans(null, new ObjectName("*:type=Foo,*"));
+ assertEquals("Size of results: " + result, 3, result.size());
+ }
+
+ protected void setUp() throws Exception {
+ writer = new PrintWriter(new OutputStreamWriter(System.out));
+ jmxWriter = new JMXWriter(writer, managementContext);
+ }
+
+ protected void tearDown() throws Exception {
+ if (writer != null) {
+ writer.close();
+ }
+ }
+
+
+
+}