IDEA-75975 Wrong coding in Open Task from
authorDmitry Avdeev <Dmitry.Avdeev@jetbrains.com>
Thu, 26 Jan 2012 13:48:29 +0000 (17:48 +0400)
committerDmitry Avdeev <Dmitry.Avdeev@jetbrains.com>
Thu, 26 Jan 2012 13:50:13 +0000 (17:50 +0400)
plugins/tasks/tasks-core/src/com/intellij/tasks/trac/TracRepository.java
plugins/tasks/tasks-tests/tasks-tests.iml
plugins/tasks/tasks-tests/test/com/intellij/tasks/integration/TracIntegrationTest.java [new file with mode: 0644]

index 136ed2161ebdcf3f0bd3d7e6c73caab5de283497..a4cb3f78ca8999c0682fb3ff8fe88e18d5f5c190 100644 (file)
@@ -23,10 +23,7 @@ import com.intellij.tasks.impl.BaseRepositoryImpl;
 import com.intellij.tasks.impl.LocalTaskImpl;
 import com.intellij.util.containers.ContainerUtil;
 import com.intellij.util.xmlb.annotations.Tag;
-import org.apache.xmlrpc.CommonsXmlRpcTransport;
-import org.apache.xmlrpc.XmlRpcClient;
-import org.apache.xmlrpc.XmlRpcException;
-import org.apache.xmlrpc.XmlRpcRequest;
+import org.apache.xmlrpc.*;
 import org.jetbrains.annotations.Nullable;
 
 import java.io.IOException;
@@ -41,6 +38,10 @@ import java.util.*;
 @SuppressWarnings({"UseOfObsoleteCollectionType", "unchecked"})
 public class TracRepository extends BaseRepositoryImpl {
 
+  static {
+    XmlRpc.setDefaultInputEncoding("UTF-8");
+  }
+
   private String myDefaultSearch = "status!=closed&owner={username}&summary~={query}";
   private Boolean myMaxSupported;
 
@@ -96,7 +97,7 @@ public class TracRepository extends BaseRepositoryImpl {
   }
 
   private XmlRpcClient getRpcClient() throws MalformedURLException {
-    return new XmlRpcClient(new URL(getUrl()));
+    return new XmlRpcClient(getUrl());
   }
 
   @Override
index f59b8dfccb7e2cac2de0f76377b55df5871b7da5..668e75245368d37d33f433688a49943e64a1c122 100644 (file)
@@ -14,6 +14,8 @@
     <orderEntry type="library" scope="TEST" name="JUnit4" level="project" />
     <orderEntry type="module" module-name="testFramework-java" scope="TEST" />
     <orderEntry type="module" module-name="vcs-impl" />
+    <orderEntry type="library" name="XmlRPC" level="project" />
+    <orderEntry type="module" module-name="spellchecker" scope="RUNTIME" />
   </component>
 </module>
 
diff --git a/plugins/tasks/tasks-tests/test/com/intellij/tasks/integration/TracIntegrationTest.java b/plugins/tasks/tasks-tests/test/com/intellij/tasks/integration/TracIntegrationTest.java
new file mode 100644 (file)
index 0000000..61a0b8f
--- /dev/null
@@ -0,0 +1,57 @@
+/*
+ * Copyright 2000-2012 JetBrains s.r.o.
+ *
+ * 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 com.intellij.tasks.integration;
+
+import com.intellij.tasks.Task;
+import com.intellij.tasks.TaskManagerTestCase;
+import com.intellij.tasks.trac.TracRepository;
+import org.apache.xmlrpc.CommonsXmlRpcTransport;
+import org.apache.xmlrpc.XmlRpc;
+import org.apache.xmlrpc.XmlRpcClient;
+import org.apache.xmlrpc.XmlRpcRequest;
+
+import java.net.URL;
+import java.util.Arrays;
+import java.util.Vector;
+
+/**
+ * @author Dmitry Avdeev
+ *         Date: 1/25/12
+ */
+public abstract class TracIntegrationTest extends TaskManagerTestCase {
+
+  public void testTracEncoding() throws Exception {
+
+    XmlRpc.setDefaultInputEncoding("UTF-8");
+    XmlRpcClient client = new XmlRpcClient("http://trac.shopware.de/trac/login/rpc");
+ //   client.setBasicAuthentication();
+
+    CommonsXmlRpcTransport transport = new CommonsXmlRpcTransport(new URL("http://trac.shopware.de/trac/login/rpc"));
+    transport.setBasicAuthentication("jetbrains", "jetbrains");
+    Object o = client.execute(new XmlRpcRequest("ticket.get", new Vector(Arrays.asList("5358"))),
+            transport);
+
+    System.out.println(o);
+
+    TracRepository repository = new TracRepository();
+    repository.setPassword("jetbrains");
+    repository.setUsername("jetbrains");
+    repository.setUrl("http://trac.shopware.de/trac/login/rpc");
+    Task[] issues = repository.getIssues("", 10, 0);
+    Task task = repository.findTask("5358");
+    System.out.println(task.getDescription());
+  }
+}