Skip to content

Commit 105f203

Browse files
committed
Wire tests. Fix dialog layout and minimum size.
1 parent 44dda85 commit 105f203

File tree

11 files changed

+711
-549
lines changed

11 files changed

+711
-549
lines changed

src/ServiceStackEclipse/ServiceStackEclipse.Bundle/net.servicestack.eclipse.iml

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,26 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
3-
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_5" inherit-compiler-output="false">
3+
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_7" inherit-compiler-output="false">
44
<output url="file://$MODULE_DIR$/target/classes" />
55
<output-test url="file://$MODULE_DIR$/target/test-classes" />
6-
<content url="file://$MODULE_DIR$/../ServiceStackEclipse.Bundle" />
6+
<content url="file://$MODULE_DIR$">
7+
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
8+
<sourceFolder url="file://$MODULE_DIR$/src-test" isTestSource="true" />
9+
<excludeFolder url="file://$MODULE_DIR$/target" />
10+
</content>
711
<orderEntry type="inheritedJdk" />
812
<orderEntry type="sourceFolder" forTests="false" />
13+
<orderEntry type="module-library">
14+
<library>
15+
<CLASSES>
16+
<root url="jar://$APPLICATION_HOME_DIR$/plugins/testng/lib/testng.jar!/" />
17+
</CLASSES>
18+
<JAVADOC />
19+
<SOURCES />
20+
</library>
21+
</orderEntry>
22+
<orderEntry type="library" name="Maven: junit:junit:4.11" level="project" />
23+
<orderEntry type="library" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" />
924
<orderEntry type="module-library">
1025
<library name="Maven: p2.eclipse-plugin:javax.annotation:1.2.0.v201401042248">
1126
<CLASSES>
@@ -34,7 +49,7 @@
3449
</library>
3550
</orderEntry>
3651
<orderEntry type="module-library">
37-
<library name="Maven: net.servicestack.eclipse:net.servicestack.eclipse:libs/httpcore-4.3.2.jar:1.0.7.qualifier">
52+
<library name="Maven: net.servicestack.eclipse:net.servicestack.eclipse:libs/httpcore-4.3.2.jar:1.0.6.qualifier">
3853
<CLASSES>
3954
<root url="jar://$MODULE_DIR$/libs/httpcore-4.3.2.jar!/" />
4055
</CLASSES>
@@ -43,7 +58,7 @@
4358
</library>
4459
</orderEntry>
4560
<orderEntry type="module-library">
46-
<library name="Maven: net.servicestack.eclipse:net.servicestack.eclipse:libs/httpclient-4.3.3.jar:1.0.7.qualifier">
61+
<library name="Maven: net.servicestack.eclipse:net.servicestack.eclipse:libs/httpclient-4.3.3.jar:1.0.6.qualifier">
4762
<CLASSES>
4863
<root url="jar://$MODULE_DIR$/libs/httpclient-4.3.3.jar!/" />
4964
</CLASSES>
@@ -52,7 +67,7 @@
5267
</library>
5368
</orderEntry>
5469
<orderEntry type="module-library">
55-
<library name="Maven: net.servicestack.eclipse:net.servicestack.eclipse:libs/maven-core-3.0.5.jar:1.0.7.qualifier">
70+
<library name="Maven: net.servicestack.eclipse:net.servicestack.eclipse:libs/maven-core-3.0.5.jar:1.0.6.qualifier">
5671
<CLASSES>
5772
<root url="jar://$MODULE_DIR$/libs/maven-core-3.0.5.jar!/" />
5873
</CLASSES>
@@ -61,7 +76,7 @@
6176
</library>
6277
</orderEntry>
6378
<orderEntry type="module-library">
64-
<library name="Maven: net.servicestack.eclipse:net.servicestack.eclipse:libs/maven-model-3.0.5.jar:1.0.7.qualifier">
79+
<library name="Maven: net.servicestack.eclipse:net.servicestack.eclipse:libs/maven-model-3.0.5.jar:1.0.6.qualifier">
6580
<CLASSES>
6681
<root url="jar://$MODULE_DIR$/libs/maven-model-3.0.5.jar!/" />
6782
</CLASSES>
@@ -70,7 +85,7 @@
7085
</library>
7186
</orderEntry>
7287
<orderEntry type="module-library">
73-
<library name="Maven: net.servicestack.eclipse:net.servicestack.eclipse:libs/plexus-utils-2.0.6.jar:1.0.7.qualifier">
88+
<library name="Maven: net.servicestack.eclipse:net.servicestack.eclipse:libs/plexus-utils-2.0.6.jar:1.0.6.qualifier">
7489
<CLASSES>
7590
<root url="jar://$MODULE_DIR$/libs/plexus-utils-2.0.6.jar!/" />
7691
</CLASSES>
Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,24 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22

33
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4-
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
5-
<modelVersion>4.0.0</modelVersion>
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
66

7-
<version>1.0.6-SNAPSHOT</version>
8-
<artifactId>net.servicestack.eclipse</artifactId>
9-
<packaging>eclipse-plugin</packaging>
10-
<name>ServiceStackEclipse.Bundle</name>
11-
12-
<parent>
13-
<version>1.0.0-SNAPSHOT</version>
14-
<groupId>net.servicestack.eclipse</groupId>
15-
<artifactId>parent</artifactId>
16-
</parent>
7+
<version>1.0.6-SNAPSHOT</version>
8+
<artifactId>net.servicestack.eclipse</artifactId>
9+
<packaging>eclipse-plugin</packaging>
10+
<name>ServiceStackEclipse.Bundle</name>
1711

12+
<parent>
13+
<version>1.0.0-SNAPSHOT</version>
14+
<groupId>net.servicestack.eclipse</groupId>
15+
<artifactId>parent</artifactId>
16+
</parent>
17+
<dependencies>
18+
<dependency>
19+
<groupId>junit</groupId>
20+
<artifactId>junit</artifactId>
21+
<version>4.11</version>
22+
</dependency>
23+
</dependencies>
1824
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
package net.servicestack.eclipseTests.nativetypes;
2+
3+
import net.servicestack.eclipse.nativetypes.JavaNativeTypesHandler;
4+
import net.servicestack.eclipse.nativetypes.NativeTypesLanguage;
5+
import org.junit.Assert;
6+
import org.junit.Test;
7+
8+
import java.io.FileNotFoundException;
9+
import java.util.HashMap;
10+
import java.util.Map;
11+
12+
13+
/**
14+
* Created by Layoric on 15/10/2015.
15+
*/
16+
public class JavaNativeTypesHandlerTest {
17+
18+
private static final String optionsTest = "/* Options:\n"+
19+
"Date: 2015-10-15 05:08:08\n"+
20+
"Version: 4.046\n"+
21+
"BaseUrl: http://techstacks.io\n"+
22+
"\n"+
23+
"//Package: \n"+
24+
"//GlobalNamespace: dto\n"+
25+
"//AddPropertyAccessors: True\n"+
26+
"//SettersReturnThis: True\n"+
27+
"//AddServiceStackTypes: True\n"+
28+
"AddResponseStatus: False\n"+
29+
"AddImplicitVersion: \n"+
30+
"IncludeTypes: \n"+
31+
"ExcludeTypes: \n"+
32+
"//TreatTypesAsStrings: \n"+
33+
"//DefaultImports: java.math.*,java.util.*,net.servicestack.client.*,com.google.gson.annotations.*,com.google.gson.reflect.*\n"+
34+
"*/\n"+
35+
"\n"+
36+
"import java.math.*;\n"+
37+
"import java.util.*;\n"+
38+
"import net.servicestack.client.*;\n"+
39+
"import com.google.gson.annotations.*;\n"+
40+
"import com.google.gson.reflect.*;";
41+
42+
@Test
43+
public void testParseComments() throws Exception {
44+
JavaNativeTypesHandler nativeTypesHandler = new JavaNativeTypesHandler();
45+
Map<String,String> result = nativeTypesHandler.parseComments(optionsTest);
46+
Assert.assertTrue(result.containsKey("AddResponseStatus"));
47+
Assert.assertTrue(result.containsKey("AddImplicitVersion"));
48+
Assert.assertTrue(result.containsKey("IncludeTypes"));
49+
Assert.assertTrue(result.containsKey("ExcludeTypes"));
50+
Assert.assertTrue(!result.containsKey("Package"));
51+
}
52+
53+
@Test
54+
public void testGenerateUrl() throws Exception {
55+
JavaNativeTypesHandler nativeTypesHandler = new JavaNativeTypesHandler();
56+
String url = nativeTypesHandler.generateUrl("http://techstacks.io", null);
57+
Assert.assertEquals("http://techstacks.io/types/java", url);
58+
Map<String,String> options = new HashMap<String, String>();
59+
options.put("Package","net.servicestack.testing");
60+
String urlWithOptions = nativeTypesHandler.generateUrl("http://techstacks.io",
61+
options);
62+
Assert.assertEquals("http://techstacks.io/types/java?Package=net.servicestack.testing", urlWithOptions);
63+
64+
}
65+
66+
@Test
67+
public void testGetUpdatedCode() throws Exception {
68+
JavaNativeTypesHandler nativeTypesHandler = new JavaNativeTypesHandler();
69+
String code = nativeTypesHandler.getUpdatedCode("http://techstacks.io", null);
70+
Assert.assertTrue(code.startsWith("/* Options"));
71+
}
72+
73+
@Test
74+
public void testGetTypesLanguage() throws Exception {
75+
JavaNativeTypesHandler nativeTypesHandler = new JavaNativeTypesHandler();
76+
Assert.assertEquals(NativeTypesLanguage.Java,nativeTypesHandler.getTypesLanguage());
77+
}
78+
79+
@Test
80+
public void testValidateServiceStackEndpoint() throws Exception {
81+
JavaNativeTypesHandler nativeTypesHandler = new JavaNativeTypesHandler();
82+
Boolean resultTrue = nativeTypesHandler.validateServiceStackEndpoint("techstacks.io");
83+
Assert.assertEquals(true,resultTrue);
84+
Boolean resultFalse = nativeTypesHandler.validateServiceStackEndpoint("techstacks.io/foo");
85+
Assert.assertEquals(false, resultFalse);
86+
try {
87+
//Throws not found
88+
nativeTypesHandler.validateServiceStackEndpoint("google.com");
89+
} catch (Exception e) {
90+
Assert.assertTrue(e.getClass() == FileNotFoundException.class);
91+
}
92+
}
93+
94+
@Test
95+
public void testIsFileAServiceStackReference() throws Exception {
96+
97+
}
98+
99+
@Test
100+
public void testGetRelativeTypesUrl() throws Exception {
101+
102+
}
103+
}

src/ServiceStackEclipse/ServiceStackEclipse.Bundle/src/net/servicestack/eclipse/maven/EclipseMavenHelper.java

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,17 @@
11
package net.servicestack.eclipse.maven;
22

3-
import java.io.ByteArrayInputStream;
4-
import java.io.File;
5-
import java.io.FileReader;
6-
import java.io.FileWriter;
7-
import java.io.IOException;
8-
import java.io.InputStream;
9-
import java.io.StringWriter;
10-
import java.nio.charset.StandardCharsets;
11-
import java.util.List;
12-
import java.util.Objects;
13-
143
import org.apache.maven.model.Dependency;
154
import org.apache.maven.model.Model;
165
import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
176
import org.apache.maven.model.io.xpp3.MavenXpp3Writer;
187
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
198
import org.eclipse.core.resources.IFile;
209

10+
import java.io.*;
11+
import java.nio.charset.StandardCharsets;
12+
import java.util.List;
13+
import java.util.Objects;
14+
2115
public class EclipseMavenHelper {
2216
public boolean addMavenDependencyIfRequired(IFile pomFile, String groupId, String packageId, String version) throws Exception {
2317
boolean dependencyAdded = false;
@@ -33,7 +27,7 @@ public boolean addMavenDependencyIfRequired(IFile pomFile, String groupId, Strin
3327
}
3428
}
3529

36-
String content = null;
30+
String content;
3731
if(requiresPomDependency) {
3832
Dependency dependency = new Dependency();
3933
dependency.setGroupId(groupId);

src/ServiceStackEclipse/ServiceStackEclipse.Bundle/src/net/servicestack/eclipse/nativetypes/JavaNativeTypesHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public String generateUrl(String baseUrl, Map<String, String> options) {
9898

9999

100100
public String getUpdatedCode(String baseUrl, Map<String, String> options) throws IOException {
101-
String result = null;
101+
String result;
102102
String url = generateUrl(baseUrl, options);
103103
URL javaCodeUrl = new URL(url);
104104

0 commit comments

Comments
 (0)