This repository was archived by the owner on May 11, 2026. It is now read-only.
Repository navigation
Expand file tree
/
Copy pathJoobyTest.java
More file actions
129 lines (120 loc) · 3.07 KB
/
Copy pathJoobyTest.java
File metadata and controls
129 lines (120 loc) · 3.07 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
/**
* Jooby https://jooby.io
* Apache License Version 2.0 https://jooby.io/LICENSE.txt
* Copyright 2014 Edgar Espina
*/
package io.jooby;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
/**
* Startup Jooby applications using JUnit extension mechanism.
*
* When this annotation is set at class level, a single jooby application is started:
*
* <pre>{@code
* @JoobyTest(MyApp.class)
* public class MyTest {
*
* @Test
* public void test() {
* Use your favorite HTTP client and call Jooby.
* }
* }
* }</pre>
*
* When this annotation is set at method level, a jooby application is started per test/method:
*
* <pre>{@code
*
* public class MyTest {
*
* @JoobyTest(MyApp.class)
* public void test() {
* Use your favorite HTTP client and call Jooby.
* }
*
* @JoobyTest(MyApp.class)
* public void anotherTest() {
* Use your favorite HTTP client and call Jooby.
* }
* }
* }</pre>
*
* Server path and port can be injected as instance fields or method parameters:
*
* <pre>{@code
*
* @JoobyTest(MyApp.class)
* public MyTest {
*
* public String serverPath;
*
* public void test() {
* Use your favorite HTTP client and call Jooby.
* }
* }
* }</pre>
*
* <pre>{@code
* public MyTest {
*
* @JoobyTest(MyApp.class)
* public void test(String serverPath) {
* Use your favorite HTTP client and call Jooby.
* }
* }
* }</pre>
*
* @author edgar
* @since 2.0.0
*/
@Target({TYPE, METHOD})
@Retention(RUNTIME)
@Test
@ExtendWith(JoobyExtension.class)
public @interface JoobyTest {
/**
* Application class. Required.
*
* @return Application class.
*/
Class<? extends Jooby> value();
/**
* Factory class (owner of {@link #factoryMethod()}. Use for create an application
* programmatically.
*
* @return Factory class or fallback for current test class.
*/
Class<?> factoryClass() default Object.class;
/**
* Name of factory method to create an application programmatically.
*
* @return Name of factory method to create an application programmatically.
*/
String factoryMethod() default "";
/**
* Application environment, default is <code>test</code>.
*
* @return Application environment, default is <code>test</code>.
*/
String environment() default "test";
/**
* Server port. At class level default port is <code>8911</code>. At method level default port
* is random.
*
* @return Server port. At class level default port is <code>8911</code>. At method level default
* port is random.
*/
int port() default -1;
/**
* Application execution mode. Default is {@link ExecutionMode#DEFAULT}.
*
* @return Application execution mode. Default is {@link ExecutionMode#DEFAULT}.
*/
ExecutionMode executionMode() default ExecutionMode.DEFAULT;
}