Author: gertv
Date: Mon May 28 11:50:05 2007
New Revision: 542294
URL: http://svn.apache.org/viewvc?view=rev&rev=542294
Log:
Fix for SM-598: Dynamically determine basic authentication credentials for HTTP
Added:
incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/expression/ExpressionEditor.java
incubator/servicemix/trunk/core/servicemix-core/src/test/java/org/apache/servicemix/expression/ExpressionEditorTest.java
incubator/servicemix/trunk/core/servicemix-core/src/test/java/org/apache/servicemix/expression/ExpressionTestSupport.java
incubator/servicemix/trunk/core/servicemix-core/src/test/resources/org/apache/servicemix/expression/
incubator/servicemix/trunk/core/servicemix-core/src/test/resources/org/apache/servicemix/expression/expression-editor.xml
incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-http/src/test/java/org/apache/servicemix/http/BasicAuthCredentialsTest.java
incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-http/src/test/java/org/apache/servicemix/http/BasicAuthTestSupport.java
incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-http/src/test/resources/org/apache/servicemix/http/basic-auth.xml
Added:
incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/expression/ExpressionEditor.java
URL:
http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/expression/ExpressionEditor.java?view=auto&rev=542294
==============================================================================
---
incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/expression/ExpressionEditor.java
(added)
+++
incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/expression/ExpressionEditor.java
Mon May 28 11:50:05 2007
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.apache.servicemix.expression;
+
+import java.beans.PropertyEditorSupport;
+
+public class ExpressionEditor extends PropertyEditorSupport {
+
+ @Override
+ public void setAsText(String text) throws IllegalArgumentException {
+ setValue(new ConstantExpression(text));
+ }
+
+}
Added:
incubator/servicemix/trunk/core/servicemix-core/src/test/java/org/apache/servicemix/expression/ExpressionEditorTest.java
URL:
http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-core/src/test/java/org/apache/servicemix/expression/ExpressionEditorTest.java?view=auto&rev=542294
==============================================================================
---
incubator/servicemix/trunk/core/servicemix-core/src/test/java/org/apache/servicemix/expression/ExpressionEditorTest.java
(added)
+++
incubator/servicemix/trunk/core/servicemix-core/src/test/java/org/apache/servicemix/expression/ExpressionEditorTest.java
Mon May 28 11:50:05 2007
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.apache.servicemix.expression;
+
+import javax.jbi.messaging.MessagingException;
+
+import junit.framework.TestCase;
+
+import org.apache.xbean.spring.context.ClassPathXmlApplicationContext;
+import org.springframework.context.ApplicationContext;
+
+public class ExpressionEditorTest extends TestCase {
+
+ private ApplicationContext context;
+
+ @Override
+ protected void setUp() throws Exception {
+ context = new
ClassPathXmlApplicationContext("org/apache/servicemix/expression/expression-editor.xml");
+ }
+
+ public void testSetAsTextString() throws MessagingException {
+ ExpressionTestSupport support = (ExpressionTestSupport)
context.getBean("ExpressionTestSupport");
+ assertTrue(support.getExpression() instanceof ConstantExpression);
+ assertEquals("test", support.getExpression().evaluate(null, null));
+ }
+
+}
Added:
incubator/servicemix/trunk/core/servicemix-core/src/test/java/org/apache/servicemix/expression/ExpressionTestSupport.java
URL:
http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-core/src/test/java/org/apache/servicemix/expression/ExpressionTestSupport.java?view=auto&rev=542294
==============================================================================
---
incubator/servicemix/trunk/core/servicemix-core/src/test/java/org/apache/servicemix/expression/ExpressionTestSupport.java
(added)
+++
incubator/servicemix/trunk/core/servicemix-core/src/test/java/org/apache/servicemix/expression/ExpressionTestSupport.java
Mon May 28 11:50:05 2007
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.apache.servicemix.expression;
+
+import org.apache.servicemix.expression.Expression;
+
+public class ExpressionTestSupport {
+
+ private Expression expression;
+
+ public Expression getExpression() {
+ return expression;
+ }
+
+ public void setExpression(Expression expression) {
+ this.expression = expression;
+ }
+}
Added:
incubator/servicemix/trunk/core/servicemix-core/src/test/resources/org/apache/servicemix/expression/expression-editor.xml
URL:
http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-core/src/test/resources/org/apache/servicemix/expression/expression-editor.xml?view=auto&rev=542294
==============================================================================
---
incubator/servicemix/trunk/core/servicemix-core/src/test/resources/org/apache/servicemix/expression/expression-editor.xml
(added)
+++
incubator/servicemix/trunk/core/servicemix-core/src/test/resources/org/apache/servicemix/expression/expression-editor.xml
Mon May 28 11:50:05 2007
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You 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.
+
+-->
+<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
"http://www.springframework.org/dtd/spring-beans.dtd">
+<beans>
+
+ <bean id="ExpressionTestSupport"
class="org.apache.servicemix.expression.ExpressionTestSupport">
+ <property name="expression"><value>test</value></property>
+ </bean>
+</beans>
\ No newline at end of file
Added:
incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-http/src/test/java/org/apache/servicemix/http/BasicAuthCredentialsTest.java
URL:
http://svn.apache.org/viewvc/incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-http/src/test/java/org/apache/servicemix/http/BasicAuthCredentialsTest.java?view=auto&rev=542294
==============================================================================
---
incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-http/src/test/java/org/apache/servicemix/http/BasicAuthCredentialsTest.java
(added)
+++
incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-http/src/test/java/org/apache/servicemix/http/BasicAuthCredentialsTest.java
Mon May 28 11:50:05 2007
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.apache.servicemix.http;
+
+import junit.framework.TestCase;
+
+import org.apache.xbean.spring.context.ClassPathXmlApplicationContext;
+import org.springframework.context.ApplicationContext;
+
+public class BasicAuthCredentialsTest extends TestCase {
+
+ private ApplicationContext context;
+
+ @Override
+ protected void setUp() throws Exception {
+ context = new
ClassPathXmlApplicationContext("org/apache/servicemix/http/basic-auth.xml");
+ }
+
+ public void testApplyCredentials() throws Exception {
+ BasicAuthTestSupport support = (BasicAuthTestSupport)
context.getBean("BasicAuthTestSupport");
+ assertEquals("testuser",
support.getBasicAuth().getUsername().evaluate(null, null));
+ assertEquals("testpass",
support.getBasicAuth().getPassword().evaluate(null, null));
+ }
+
+}
Added:
incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-http/src/test/java/org/apache/servicemix/http/BasicAuthTestSupport.java
URL:
http://svn.apache.org/viewvc/incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-http/src/test/java/org/apache/servicemix/http/BasicAuthTestSupport.java?view=auto&rev=542294
==============================================================================
---
incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-http/src/test/java/org/apache/servicemix/http/BasicAuthTestSupport.java
(added)
+++
incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-http/src/test/java/org/apache/servicemix/http/BasicAuthTestSupport.java
Mon May 28 11:50:05 2007
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.apache.servicemix.http;
+
+public class BasicAuthTestSupport {
+
+ private BasicAuthCredentials basicAuth;
+
+ public void setBasicAuth(BasicAuthCredentials basicAuth) {
+ this.basicAuth = basicAuth;
+ }
+
+ public BasicAuthCredentials getBasicAuth() {
+ return basicAuth;
+ }
+}
Added:
incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-http/src/test/resources/org/apache/servicemix/http/basic-auth.xml
URL:
http://svn.apache.org/viewvc/incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-http/src/test/resources/org/apache/servicemix/http/basic-auth.xml?view=auto&rev=542294
==============================================================================
---
incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-http/src/test/resources/org/apache/servicemix/http/basic-auth.xml
(added)
+++
incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-http/src/test/resources/org/apache/servicemix/http/basic-auth.xml
Mon May 28 11:50:05 2007
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You 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.
+
+-->
+<beans xmlns:http="http://servicemix.apache.org/http/1.0">
+
+ <bean id="BasicAuthTestSupport"
+ class="org.apache.servicemix.http.BasicAuthTestSupport">
+ <property name="basicAuth">
+ <http:basicAuthCredentials username="testuser" password="testpass"
/>
+ </property>
+ </bean>
+
+</beans>