run-tests.sh
4.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
#!/bin/bash
# MCP Test Runner Script
# Runs Java MCP tests with proper classpath and configuration
set -e
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
# Script directory
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
MOQUI_MCP_DIR="$(dirname "$SCRIPT_DIR")"
echo -e "${BLUE}🧪 MCP Test Runner${NC}"
echo "===================="
# Check if Moqui MCP server is running
echo -e "${BLUE}🔍 Checking MCP server status...${NC}"
if ! curl -s http://localhost:8080/mcp > /dev/null 2>&1; then
echo -e "${RED}❌ MCP server not running at http://localhost:8080/mcp${NC}"
echo "Please start the Moqui MCP server first:"
echo " cd $MOQUI_MCP_DIR && ./gradlew run --daemon"
exit 1
fi
echo -e "${GREEN}✅ MCP server is running${NC}"
# Set up Java classpath
echo -e "${BLUE}📦 Setting up classpath...${NC}"
# Add Moqui framework classes
CLASSPATH="$MOQUI_MCP_DIR/build/classes/java/main"
CLASSPATH="$CLASSPATH:$MOQUI_MCP_DIR/build/resources/main"
# Add test classes
CLASSPATH="$CLASSPATH:$MOQUI_MCP_DIR/build/classes/groovy/test"
CLASSPATH="$CLASSPATH:$MOQUI_MCP_DIR/build/resources/test"
CLASSPATH="$CLASSPATH:$MOQUI_MCP_DIR/test/resources"
# Add Moqui framework runtime libraries
if [ -d "$MOQUI_MCP_DIR/../moqui-framework/runtime/lib" ]; then
for jar in "$MOQUI_MCP_DIR/../moqui-framework/runtime/lib"/*.jar; do
if [ -f "$jar" ]; then
CLASSPATH="$CLASSPATH:$jar"
fi
done
fi
# Add Groovy libraries
if [ -d "$MOQUI_MCP_DIR/../moqui-framework/runtime/lib" ]; then
for jar in "$MOQUI_MCP_DIR/../moqui-framework/runtime/lib"/groovy*.jar; do
if [ -f "$jar" ]; then
CLASSPATH="$CLASSPATH:$jar"
fi
done
fi
# Add framework build
if [ -d "$MOQUI_MCP_DIR/../moqui-framework/framework/build/libs" ]; then
for jar in "$MOqui_MCP_DIR/../moqui-framework/framework/build/libs"/*.jar; do
if [ -f "$jar" ]; then
CLASSPATH="$CLASSPATH:$jar"
fi
done
fi
# Add component JAR if it exists
if [ -f "$MOQUI_MCP_DIR/lib/moqui-mcp-2-1.0.0.jar" ]; then
CLASSPATH="$CLASSPATH:$MOQUI_MCP_DIR/lib/moqui-mcp-2-1.0.0.jar"
fi
echo "Classpath: $CLASSPATH"
# Change to Moqui MCP directory
cd "$MOQUI_MCP_DIR"
# Determine which test to run
TEST_TYPE="$1"
case "$TEST_TYPE" in
"infrastructure"|"infra")
echo -e "${BLUE}🏗️ Running infrastructure tests only...${NC}"
TEST_CLASS="org.moqui.mcp.test.McpTestSuite"
TEST_ARGS="infrastructure"
;;
"workflow"|"popcommerce")
echo -e "${BLUE}🛒 Running PopCommerce workflow tests only...${NC}"
TEST_CLASS="org.moqui.mcp.test.McpTestSuite"
TEST_ARGS="workflow"
;;
"help"|"-h"|"--help")
echo "Usage: $0 [test_type]"
echo ""
echo "Test types:"
echo " infrastructure, infra - Run screen infrastructure tests only"
echo " workflow, popcommerce - Run PopCommerce workflow tests only"
echo " (no argument) - Run all tests"
echo ""
echo "Examples:"
echo " $0"
echo " $0 infrastructure"
echo " $0 workflow"
exit 0
;;
"")
echo -e "${BLUE}🧪 Running all MCP tests...${NC}"
TEST_CLASS="org.moqui.mcp.test.McpTestSuite"
TEST_ARGS=""
;;
*)
echo -e "${RED}❌ Unknown test type: $TEST_TYPE${NC}"
echo "Use '$0 help' for usage information"
exit 1
;;
esac
# Run the tests
echo -e "${BLUE}🚀 Executing tests...${NC}"
echo ""
# Set Java options
JAVA_OPTS="-Xmx1g -Xms512m"
JAVA_OPTS="$JAVA_OPTS -Dmoqui.runtime=$MOQUI_MCP_DIR/../runtime"
JAVA_OPTS="$JAVA_OPTS -Dmoqui.conf=MoquiConf.xml"
# Execute the test using Gradle (which handles Groovy classpath properly)
echo "Running tests via Gradle..."
if cd "$MOQUI_MCP_DIR/../../.." && ./gradlew :runtime:component:moqui-mcp-2:test; then
echo ""
echo -e "${GREEN}🎉 Tests completed successfully!${NC}"
exit 0
else
echo ""
echo -e "${RED}❌ Tests failed!${NC}"
exit 1
fi