01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: package org.apache.jmeter.monitor.model;
18:
19: import junit.framework.TestCase;
20:
21: public class TestObjectFactory extends TestCase {
22:
23: // TODO turn this into a proper test case
24:
25: public void testSomething() throws Exception {
26:
27: }
28:
29: /**
30: * Basic method for testing the class
31: *
32: * @param args
33: */
34: public static void main(String[] args) {
35: if (args != null && args.length == 2) {
36: String file = null;
37: // int count = 1;
38: if (args[0] != null) {
39: file = args[0];
40: }
41: if (args[1] != null) {
42: // count = Integer.parseInt(args[1]);
43: }
44: try {
45: ObjectFactory of = ObjectFactory.getInstance();
46: java.io.File infile = new java.io.File(file);
47: java.io.FileInputStream fis = new java.io.FileInputStream(
48: infile);
49: java.io.InputStreamReader isr = new java.io.InputStreamReader(
50: fis);
51: StringBuffer buf = new StringBuffer();
52: java.io.BufferedReader br = new java.io.BufferedReader(
53: isr);
54: String line = null;
55: while ((line = br.readLine()) != null) {
56: buf.append(line);
57: }
58: System.out.println("contents: ");
59: System.out.println(buf.toString());
60: System.out.println("----------------------");
61: Status st = of.parseBytes(buf.toString().getBytes());
62: if (st == null) {
63: System.out.println("parse failed");
64: } else {
65: System.out.println("parse successful:");
66: System.out.println(st.getJvm().getMemory()
67: .getFree());
68: System.out.println(st.getJvm().getMemory()
69: .getTotal());
70: System.out
71: .println(st.getJvm().getMemory().getMax());
72: System.out.println("connector size: "
73: + st.getConnector().size());
74: Connector conn = (Connector) st.getConnector().get(
75: 0);
76: System.out.println("conn: "
77: + conn.getThreadInfo().getMaxThreads());
78: }
79: } catch (java.io.FileNotFoundException e) {
80: e.printStackTrace();
81: } catch (java.io.IOException e) {
82: e.printStackTrace();
83: }
84: } else {
85: }
86: }
87: }
|